2012-02-10 04:34:19 -05:00
|
|
|
###################################################
|
|
|
|
#
|
|
|
|
# Makefile for MCServer
|
2012-02-21 07:07:08 -05:00
|
|
|
# Creator: tedik
|
2012-02-10 04:34:19 -05:00
|
|
|
#
|
|
|
|
###################################################
|
|
|
|
#
|
|
|
|
# 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
|
|
|
|
|
2012-08-04 16:42:57 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
###################################################
|
|
|
|
# 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
|
|
|
|
# BUILDDIR ... folder where the intermediate object files are built
|
|
|
|
|
2012-02-10 04:34:19 -05:00
|
|
|
ifeq ($(release),1)
|
2012-08-04 16:42:57 -04:00
|
|
|
################
|
|
|
|
# release build - fastest run-time, no gdb support
|
|
|
|
################
|
2012-02-10 04:34:19 -05:00
|
|
|
CC_OPTIONS = -s -O3
|
2012-08-04 16:42:57 -04:00
|
|
|
CXX_OPTIONS = -s -O3
|
2012-02-10 04:34:19 -05:00
|
|
|
LNK_OPTIONS = -lstdc++ -pthread -O3
|
|
|
|
BUILDDIR = build/release/
|
2012-08-07 10:36:45 -04:00
|
|
|
|
2012-02-10 04:34:19 -05:00
|
|
|
else
|
2012-08-07 10:36:45 -04:00
|
|
|
ifeq ($(profile),1)
|
|
|
|
################
|
|
|
|
# profile build - a release build with symbols and profiling engine built in
|
|
|
|
################
|
|
|
|
CC_OPTIONS = -s -ggdb -O3 -pg
|
|
|
|
CXX_OPTIONS = -s -ggdb -O3 -pg
|
|
|
|
LNK_OPTIONS = -lstdc++ -pthread -ggdb -O3 -pg
|
|
|
|
BUILDDIR = build/profile/
|
2012-08-04 16:42:57 -04:00
|
|
|
|
2012-08-07 10:36:45 -04:00
|
|
|
else
|
2012-08-04 16:42:57 -04:00
|
|
|
ifeq ($(pedantic),1)
|
|
|
|
################
|
|
|
|
# pedantic build - basically a debug build with lots of warnings
|
|
|
|
################
|
2012-08-03 07:53:11 -04:00
|
|
|
CC_OPTIONS = -s -ggdb -D_DEBUG -Wall -Wextra -pedantic -ansi -Wno-long-long
|
2012-08-04 16:42:57 -04:00
|
|
|
CXX_OPTIONS = -s -ggdb -D_DEBUG -Wall -Wextra -pedantic -ansi -Wno-long-long
|
|
|
|
LNK_OPTIONS = -lstdc++ -pthread -ggdb
|
|
|
|
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 -D_DEBUG -O3
|
|
|
|
CXX_OPTIONS = -s -ggdb -D_DEBUG
|
2012-02-10 04:34:19 -05:00
|
|
|
LNK_OPTIONS = -lstdc++ -pthread -ggdb
|
|
|
|
BUILDDIR = build/debug/
|
|
|
|
endif
|
2012-08-07 10:36:45 -04:00
|
|
|
endif
|
2012-08-04 16:42:57 -04:00
|
|
|
endif
|
2012-02-10 04:34:19 -05:00
|
|
|
|
2012-08-04 16:42:57 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
###################################################
|
2012-02-10 04:34:19 -05:00
|
|
|
# INCLUDE directories for MCServer
|
|
|
|
#
|
|
|
|
|
|
|
|
INCLUDE = -I.\
|
|
|
|
-Isource\
|
|
|
|
-Isource/md5\
|
|
|
|
-IWebServer\
|
2012-07-15 16:36:34 -04:00
|
|
|
-Isource/items\
|
|
|
|
-Isource/blocks\
|
2012-02-10 04:34:19 -05:00
|
|
|
-Itolua++-1.0.93/src/lib\
|
|
|
|
-Ilua-5.1.4/src\
|
2012-06-03 19:35:17 -04:00
|
|
|
-Izlib-1.2.7\
|
2012-02-10 04:34:19 -05:00
|
|
|
-IiniFile\
|
|
|
|
-Itolua++-1.0.93/include\
|
|
|
|
-Ijsoncpp-src-0.5.0/include\
|
2012-07-08 17:01:08 -04:00
|
|
|
-Ijsoncpp-src-0.5.0/src/lib_json\
|
|
|
|
-Isquirrel_3_0_1_stable/include\
|
|
|
|
-Isquirrel_3_0_1_stable\
|
|
|
|
-Isquirrel_3_0_1_stable/sqrat
|
2012-02-10 04:34:19 -05:00
|
|
|
|
2012-08-04 16:42:57 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
###################################################
|
2012-02-10 04:34:19 -05:00
|
|
|
# Build MCServer
|
|
|
|
#
|
|
|
|
|
2012-07-18 08:32:45 -04:00
|
|
|
SOURCES := $(shell find lua-5.1.4 jsoncpp-src-0.5.0 zlib-1.2.7 source squirrel_3_0_1_stable tolua++-1.0.93 iniFile WebServer '(' -name '*.cpp' -o -name '*.c' ')')
|
2012-02-14 08:36:49 -05:00
|
|
|
SOURCES := $(filter-out %minigzip.c %lua.c %tolua.c %toluabind.c %LeakFinder.cpp %StackWalker.cpp %example.c,$(SOURCES))
|
2012-02-10 04:34:19 -05:00
|
|
|
OBJECTS := $(patsubst %.c,$(BUILDDIR)%.o,$(SOURCES))
|
|
|
|
OBJECTS := $(patsubst %.cpp,$(BUILDDIR)%.o,$(OBJECTS))
|
|
|
|
|
2012-02-21 07:07:08 -05:00
|
|
|
-include $(patsubst %.o,%.d,$(OBJECTS))
|
2012-02-10 04:34:19 -05:00
|
|
|
|
|
|
|
MCServer : $(OBJECTS)
|
2012-08-20 08:29:51 -04:00
|
|
|
$(CC) $(LNK_OPTIONS) $(OBJECTS) -o MCServer/MCServer
|
2012-02-10 04:34:19 -05:00
|
|
|
|
|
|
|
clean :
|
2012-08-20 08:29:51 -04:00
|
|
|
rm -rf $(BUILDDIR) MCServer/MCServer
|
2012-02-10 04:34:19 -05:00
|
|
|
|
|
|
|
install : MCServer
|
|
|
|
cp MCServer MCServer
|
|
|
|
|
2012-08-04 16:42:57 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
###################################################
|
2012-02-10 04:34:19 -05:00
|
|
|
# Build the parts of MCServer
|
|
|
|
#
|
2012-08-04 16:42:57 -04:00
|
|
|
# options used:
|
|
|
|
# -x c ... compile as C code
|
|
|
|
# -c ... compile but do not link
|
|
|
|
# -MM ... generate a list of includes
|
2012-02-10 04:34:19 -05:00
|
|
|
|
|
|
|
$(BUILDDIR)%.o: %.c
|
|
|
|
@mkdir -p $(dir $@)
|
2012-08-04 16:42:57 -04:00
|
|
|
$(CC) $(CC_OPTIONS) -x c -c $(INCLUDE) $< -o $@
|
|
|
|
@$(CC) $(CC_OPTIONS) -x c -MM $(INCLUDE) $< > $(patsubst %.o,%.d,$@)
|
2012-02-10 04:34:19 -05:00
|
|
|
@mv -f $(patsubst %.o,%.d,$@) $(patsubst %.o,%.d,$@).tmp
|
2012-02-21 07:07:08 -05:00
|
|
|
@sed -e "s|.*:|$(BUILDDIR)$*.o:|" < $(patsubst %.o,%.d,$@).tmp > $(patsubst %.o,%.d,$@)
|
2012-02-10 04:34:19 -05:00
|
|
|
@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 $@)
|
2012-08-04 16:42:57 -04:00
|
|
|
$(CC) $(CXX_OPTIONS) -c $(INCLUDE) $< -o $@
|
|
|
|
@$(CC) $(CXX_OPTIONS) -MM $(INCLUDE) $< > $(patsubst %.o,%.d,$@)
|
2012-02-10 04:34:19 -05:00
|
|
|
@mv -f $(patsubst %.o,%.d,$@) $(patsubst %.o,%.d,$@).tmp
|
2012-02-21 07:07:08 -05:00
|
|
|
@sed -e "s|.*:|$(BUILDDIR)$*.o:|" < $(patsubst %.o,%.d,$@).tmp > $(patsubst %.o,%.d,$@)
|
2012-02-10 04:34:19 -05:00
|
|
|
@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
|