2012-10-28 16:52:55 -04:00
|
|
|
###################################################
|
|
|
|
#
|
|
|
|
# Makefile for MCServer
|
|
|
|
# Creator: tedik
|
|
|
|
#
|
|
|
|
###################################################
|
|
|
|
#
|
|
|
|
# Info:
|
|
|
|
# This makefile is gnu-make spacific, other make systems needn't understand it
|
|
|
|
# This makefile generates include-file dependencies into *.d files in each build and then reuses these dependencies in the following builds
|
|
|
|
#
|
|
|
|
# Usage:
|
|
|
|
# To make a release build, call "make release=1"
|
|
|
|
# To make a debug build, call "make"
|
|
|
|
#
|
|
|
|
###################################################
|
|
|
|
|
|
|
|
#
|
|
|
|
# Macros
|
|
|
|
#
|
|
|
|
|
|
|
|
CC = /usr/bin/g++
|
|
|
|
|
|
|
|
|
|
|
|
all: MCServer/MCServer
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
###################################################
|
|
|
|
# Set the variables used for compiling, based on the build mode requested:
|
|
|
|
# CC_OPTIONS ... options for the C code compiler
|
|
|
|
# CXX_OPTIONS ... options for the C++ code compiler
|
|
|
|
# LNK_OPTIONS ... options for the linker
|
2013-04-07 17:15:10 -04:00
|
|
|
# LNK_LIBS ... libraries to link in
|
|
|
|
# -- according to http://stackoverflow.com/questions/6183899/undefined-reference-to-dlopen, libs must come after all sources
|
2012-10-28 16:52:55 -04:00
|
|
|
# BUILDDIR ... folder where the intermediate object files are built
|
|
|
|
|
2013-04-07 17:15:10 -04:00
|
|
|
LNK_LIBS = -lstdc++ -ldl
|
|
|
|
|
2012-10-28 16:52:55 -04:00
|
|
|
ifeq ($(release),1)
|
|
|
|
################
|
|
|
|
# release build - fastest run-time, no gdb support
|
|
|
|
################
|
2012-11-20 16:15:03 -05:00
|
|
|
CC_OPTIONS = -s -g -O3 -DNDEBUG
|
|
|
|
CXX_OPTIONS = -s -g -O3 -DNDEBUG
|
2013-04-07 17:15:10 -04:00
|
|
|
LNK_OPTIONS = -pthread -O3
|
2012-10-28 16:52:55 -04:00
|
|
|
BUILDDIR = build/release/
|
|
|
|
|
|
|
|
else
|
|
|
|
ifeq ($(profile),1)
|
|
|
|
################
|
|
|
|
# profile build - a release build with symbols and profiling engine built in
|
|
|
|
################
|
2012-11-20 16:15:03 -05:00
|
|
|
CC_OPTIONS = -s -g -ggdb -O3 -pg -DNDEBUG
|
|
|
|
CXX_OPTIONS = -s -g -ggdb -O3 -pg -DNDEBUG
|
2013-04-07 17:15:10 -04:00
|
|
|
LNK_OPTIONS = -pthread -ggdb -O3 -pg
|
2012-10-28 16:52:55 -04:00
|
|
|
BUILDDIR = build/profile/
|
|
|
|
|
|
|
|
else
|
|
|
|
ifeq ($(pedantic),1)
|
|
|
|
################
|
|
|
|
# pedantic build - basically a debug build with lots of warnings
|
|
|
|
################
|
2012-11-20 16:15:03 -05:00
|
|
|
CC_OPTIONS = -s -g -ggdb -D_DEBUG -Wall -Wextra -pedantic -ansi -Wno-long-long
|
|
|
|
CXX_OPTIONS = -s -g -ggdb -D_DEBUG -Wall -Wextra -pedantic -ansi -Wno-long-long
|
2013-04-07 17:15:10 -04:00
|
|
|
LNK_OPTIONS = -pthread -ggdb
|
2012-10-28 16:52:55 -04:00
|
|
|
BUILDDIR = build/pedantic/
|
|
|
|
|
|
|
|
else
|
|
|
|
################
|
|
|
|
# debug build - fully traceable by gdb in C++ code, slowest
|
|
|
|
# Since C code is used only for supporting libraries (zlib, lua), it is still O3-optimized
|
|
|
|
################
|
|
|
|
CC_OPTIONS = -s -ggdb -g -D_DEBUG -O3
|
|
|
|
CXX_OPTIONS = -s -ggdb -g -D_DEBUG
|
2013-04-07 17:15:10 -04:00
|
|
|
LNK_OPTIONS = -pthread -g -ggdb
|
2012-10-28 16:52:55 -04:00
|
|
|
BUILDDIR = build/debug/
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
|
|
|
|
|
|
|
|
|
2013-04-10 03:42:39 -04:00
|
|
|
################
|
|
|
|
# 32-bit build override in 64-bit build environments
|
|
|
|
# - so that BearBin doesn't need to modify his makefile after each makefile change :)
|
|
|
|
################
|
|
|
|
ifeq ($(addm32),1)
|
|
|
|
CC_OPTIONS += -m32
|
|
|
|
CXX_OPTIONS += -m32
|
|
|
|
LNK_OPTIONS += -m32
|
|
|
|
endif
|
|
|
|
|
2012-10-28 16:52:55 -04:00
|
|
|
|
|
|
|
|
|
|
|
###################################################
|
|
|
|
# INCLUDE directories for MCServer
|
|
|
|
#
|
|
|
|
|
|
|
|
INCLUDE = -I.\
|
|
|
|
-Isource\
|
|
|
|
-Isource/md5\
|
|
|
|
-IWebServer\
|
|
|
|
-Isource/items\
|
|
|
|
-Isource/blocks\
|
|
|
|
-Itolua++-1.0.93/src/lib\
|
|
|
|
-Ilua-5.1.4/src\
|
|
|
|
-Izlib-1.2.7\
|
|
|
|
-IiniFile\
|
|
|
|
-Itolua++-1.0.93/include\
|
|
|
|
-Ijsoncpp-src-0.5.0/include\
|
2013-04-09 09:53:54 -04:00
|
|
|
-Ijsoncpp-src-0.5.0/src/lib_json\
|
|
|
|
-Iexpat
|
2012-11-08 14:09:35 -05:00
|
|
|
|
|
|
|
|
|
|
|
# 2012_11_08 _X: Removed, see Globals.h
|
|
|
|
# -Isquirrel_3_0_1_stable/include\
|
|
|
|
# -Isquirrel_3_0_1_stable\
|
|
|
|
# -Isquirrel_3_0_1_stable/sqrat
|
2012-10-28 16:52:55 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
###################################################
|
|
|
|
# Build MCServer
|
|
|
|
#
|
|
|
|
|
2012-11-08 14:09:35 -05:00
|
|
|
# 2012_11_08 _X: Removed: squirrel_3_0_1_stable
|
|
|
|
|
2013-04-09 09:53:54 -04:00
|
|
|
SOURCES := $(shell find CryptoPP lua-5.1.4 jsoncpp-src-0.5.0 zlib-1.2.7 source tolua++-1.0.93 iniFile WebServer expat '(' -name '*.cpp' -o -name '*.c' ')')
|
2012-10-28 16:52:55 -04:00
|
|
|
SOURCES := $(filter-out %minigzip.c %lua.c %tolua.c %toluabind.c %LeakFinder.cpp %StackWalker.cpp %example.c,$(SOURCES))
|
|
|
|
OBJECTS := $(patsubst %.c,$(BUILDDIR)%.o,$(SOURCES))
|
|
|
|
OBJECTS := $(patsubst %.cpp,$(BUILDDIR)%.o,$(OBJECTS))
|
|
|
|
|
|
|
|
-include $(patsubst %.o,%.d,$(OBJECTS))
|
|
|
|
|
|
|
|
MCServer/MCServer : $(OBJECTS)
|
2013-04-07 17:15:10 -04:00
|
|
|
$(CC) $(LNK_OPTIONS) $(OBJECTS) $(LNK_LIBS) -o MCServer/MCServer
|
2012-10-28 16:52:55 -04:00
|
|
|
|
|
|
|
clean :
|
|
|
|
rm -rf $(BUILDDIR) MCServer/MCServer
|
|
|
|
|
|
|
|
install : MCServer
|
|
|
|
cp MCServer MCServer
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
###################################################
|
|
|
|
# Build the parts of MCServer
|
|
|
|
#
|
|
|
|
# options used:
|
|
|
|
# -x c ... compile as C code
|
|
|
|
# -c ... compile but do not link
|
|
|
|
# -MM ... generate a list of includes
|
|
|
|
|
|
|
|
$(BUILDDIR)%.o: %.c
|
|
|
|
@mkdir -p $(dir $@)
|
|
|
|
$(CC) $(CC_OPTIONS) -x c -c $(INCLUDE) $< -o $@
|
|
|
|
@$(CC) $(CC_OPTIONS) -x c -MM $(INCLUDE) $< > $(patsubst %.o,%.d,$@)
|
|
|
|
@mv -f $(patsubst %.o,%.d,$@) $(patsubst %.o,%.d,$@).tmp
|
|
|
|
@sed -e "s|.*:|$(BUILDDIR)$*.o:|" < $(patsubst %.o,%.d,$@).tmp > $(patsubst %.o,%.d,$@)
|
|
|
|
@sed -e 's/.*://' -e 's/\\$$//' < $(patsubst %.o,%.d,$@).tmp | fmt -1 | sed -e 's/^ *//' -e 's/$$/:/' >> $(patsubst %.o,%.d,$@)
|
|
|
|
@rm -f $(patsubst %.o,%.d,$@).tmp
|
|
|
|
|
|
|
|
$(BUILDDIR)%.o: %.cpp
|
|
|
|
@mkdir -p $(dir $@)
|
|
|
|
$(CC) $(CXX_OPTIONS) -c $(INCLUDE) $< -o $@
|
|
|
|
@$(CC) $(CXX_OPTIONS) -MM $(INCLUDE) $< > $(patsubst %.o,%.d,$@)
|
|
|
|
@mv -f $(patsubst %.o,%.d,$@) $(patsubst %.o,%.d,$@).tmp
|
|
|
|
@sed -e "s|.*:|$(BUILDDIR)$*.o:|" < $(patsubst %.o,%.d,$@).tmp > $(patsubst %.o,%.d,$@)
|
|
|
|
@sed -e 's/.*://' -e 's/\\$$//' < $(patsubst %.o,%.d,$@).tmp | fmt -1 | sed -e 's/^ *//' -e 's/$$/:/' >> $(patsubst %.o,%.d,$@)
|
|
|
|
@rm -f $(patsubst %.o,%.d,$@).tmp
|