1
0

Added true gcc debugging flags to debug builds under *nix (Fix contributed by ThuGie)

git-svn-id: http://mc-server.googlecode.com/svn/trunk@1016 0a769ca7-a7f5-676a-18bf-c427514a06d6
This commit is contained in:
madmaxoft@gmail.com 2012-10-28 20:52:55 +00:00
parent 265c810079
commit 64fb2655b9

View File

@ -1,157 +1,157 @@
################################################### ###################################################
# #
# Makefile for MCServer # Makefile for MCServer
# Creator: tedik # Creator: tedik
# #
################################################### ###################################################
# #
# Info: # Info:
# This makefile is gnu-make spacific, other make systems needn't understand it # 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 # This makefile generates include-file dependencies into *.d files in each build and then reuses these dependencies in the following builds
# #
# Usage: # Usage:
# To make a release build, call "make release=1" # To make a release build, call "make release=1"
# To make a debug build, call "make" # To make a debug build, call "make"
# #
################################################### ###################################################
# #
# Macros # Macros
# #
CC = /usr/bin/g++ CC = /usr/bin/g++
all: MCServer/MCServer all: MCServer/MCServer
################################################### ###################################################
# Set the variables used for compiling, based on the build mode requested: # Set the variables used for compiling, based on the build mode requested:
# CC_OPTIONS ... options for the C code compiler # CC_OPTIONS ... options for the C code compiler
# CXX_OPTIONS ... options for the C++ code compiler # CXX_OPTIONS ... options for the C++ code compiler
# LNK_OPTIONS ... options for the linker # LNK_OPTIONS ... options for the linker
# BUILDDIR ... folder where the intermediate object files are built # BUILDDIR ... folder where the intermediate object files are built
ifeq ($(release),1) ifeq ($(release),1)
################ ################
# release build - fastest run-time, no gdb support # release build - fastest run-time, no gdb support
################ ################
CC_OPTIONS = -s -O3 -DNDEBUG CC_OPTIONS = -s -O3 -DNDEBUG
CXX_OPTIONS = -s -O3 -DNDEBUG CXX_OPTIONS = -s -O3 -DNDEBUG
LNK_OPTIONS = -lstdc++ -pthread -O3 LNK_OPTIONS = -lstdc++ -pthread -O3
BUILDDIR = build/release/ BUILDDIR = build/release/
else else
ifeq ($(profile),1) ifeq ($(profile),1)
################ ################
# profile build - a release build with symbols and profiling engine built in # profile build - a release build with symbols and profiling engine built in
################ ################
CC_OPTIONS = -s -ggdb -O3 -pg -DNDEBUG CC_OPTIONS = -s -ggdb -O3 -pg -DNDEBUG
CXX_OPTIONS = -s -ggdb -O3 -pg -DNDEBUG CXX_OPTIONS = -s -ggdb -O3 -pg -DNDEBUG
LNK_OPTIONS = -lstdc++ -pthread -ggdb -O3 -pg LNK_OPTIONS = -lstdc++ -pthread -ggdb -O3 -pg
BUILDDIR = build/profile/ BUILDDIR = build/profile/
else else
ifeq ($(pedantic),1) ifeq ($(pedantic),1)
################ ################
# pedantic build - basically a debug build with lots of warnings # pedantic build - basically a debug build with lots of warnings
################ ################
CC_OPTIONS = -s -ggdb -D_DEBUG -Wall -Wextra -pedantic -ansi -Wno-long-long CC_OPTIONS = -s -ggdb -D_DEBUG -Wall -Wextra -pedantic -ansi -Wno-long-long
CXX_OPTIONS = -s -ggdb -D_DEBUG -Wall -Wextra -pedantic -ansi -Wno-long-long CXX_OPTIONS = -s -ggdb -D_DEBUG -Wall -Wextra -pedantic -ansi -Wno-long-long
LNK_OPTIONS = -lstdc++ -pthread -ggdb LNK_OPTIONS = -lstdc++ -pthread -ggdb
BUILDDIR = build/pedantic/ BUILDDIR = build/pedantic/
else else
################ ################
# debug build - fully traceable by gdb in C++ code, slowest # 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 # Since C code is used only for supporting libraries (zlib, lua), it is still O3-optimized
################ ################
CC_OPTIONS = -s -ggdb -D_DEBUG -O3 CC_OPTIONS = -s -ggdb -g -D_DEBUG -O3
CXX_OPTIONS = -s -ggdb -D_DEBUG CXX_OPTIONS = -s -ggdb -g -D_DEBUG
LNK_OPTIONS = -lstdc++ -pthread -ggdb LNK_OPTIONS = -lstdc++ -pthread -g -ggdb
BUILDDIR = build/debug/ BUILDDIR = build/debug/
endif endif
endif endif
endif endif
################################################### ###################################################
# INCLUDE directories for MCServer # INCLUDE directories for MCServer
# #
INCLUDE = -I.\ INCLUDE = -I.\
-Isource\ -Isource\
-Isource/md5\ -Isource/md5\
-IWebServer\ -IWebServer\
-Isource/items\ -Isource/items\
-Isource/blocks\ -Isource/blocks\
-Itolua++-1.0.93/src/lib\ -Itolua++-1.0.93/src/lib\
-Ilua-5.1.4/src\ -Ilua-5.1.4/src\
-Izlib-1.2.7\ -Izlib-1.2.7\
-IiniFile\ -IiniFile\
-Itolua++-1.0.93/include\ -Itolua++-1.0.93/include\
-Ijsoncpp-src-0.5.0/include\ -Ijsoncpp-src-0.5.0/include\
-Ijsoncpp-src-0.5.0/src/lib_json\ -Ijsoncpp-src-0.5.0/src/lib_json\
-Isquirrel_3_0_1_stable/include\ -Isquirrel_3_0_1_stable/include\
-Isquirrel_3_0_1_stable\ -Isquirrel_3_0_1_stable\
-Isquirrel_3_0_1_stable/sqrat -Isquirrel_3_0_1_stable/sqrat
################################################### ###################################################
# Build MCServer # Build MCServer
# #
SOURCES := $(shell find CryptoPP 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' ')') SOURCES := $(shell find CryptoPP 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' ')')
SOURCES := $(filter-out %minigzip.c %lua.c %tolua.c %toluabind.c %LeakFinder.cpp %StackWalker.cpp %example.c,$(SOURCES)) 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 %.c,$(BUILDDIR)%.o,$(SOURCES))
OBJECTS := $(patsubst %.cpp,$(BUILDDIR)%.o,$(OBJECTS)) OBJECTS := $(patsubst %.cpp,$(BUILDDIR)%.o,$(OBJECTS))
-include $(patsubst %.o,%.d,$(OBJECTS)) -include $(patsubst %.o,%.d,$(OBJECTS))
MCServer/MCServer : $(OBJECTS) MCServer/MCServer : $(OBJECTS)
$(CC) $(LNK_OPTIONS) $(OBJECTS) -o MCServer/MCServer $(CC) $(LNK_OPTIONS) $(OBJECTS) -o MCServer/MCServer
clean : clean :
rm -rf $(BUILDDIR) MCServer/MCServer rm -rf $(BUILDDIR) MCServer/MCServer
install : MCServer install : MCServer
cp MCServer MCServer cp MCServer MCServer
################################################### ###################################################
# Build the parts of MCServer # Build the parts of MCServer
# #
# options used: # options used:
# -x c ... compile as C code # -x c ... compile as C code
# -c ... compile but do not link # -c ... compile but do not link
# -MM ... generate a list of includes # -MM ... generate a list of includes
$(BUILDDIR)%.o: %.c $(BUILDDIR)%.o: %.c
@mkdir -p $(dir $@) @mkdir -p $(dir $@)
$(CC) $(CC_OPTIONS) -x c -c $(INCLUDE) $< -o $@ $(CC) $(CC_OPTIONS) -x c -c $(INCLUDE) $< -o $@
@$(CC) $(CC_OPTIONS) -x c -MM $(INCLUDE) $< > $(patsubst %.o,%.d,$@) @$(CC) $(CC_OPTIONS) -x c -MM $(INCLUDE) $< > $(patsubst %.o,%.d,$@)
@mv -f $(patsubst %.o,%.d,$@) $(patsubst %.o,%.d,$@).tmp @mv -f $(patsubst %.o,%.d,$@) $(patsubst %.o,%.d,$@).tmp
@sed -e "s|.*:|$(BUILDDIR)$*.o:|" < $(patsubst %.o,%.d,$@).tmp > $(patsubst %.o,%.d,$@) @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,$@) @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 @rm -f $(patsubst %.o,%.d,$@).tmp
$(BUILDDIR)%.o: %.cpp $(BUILDDIR)%.o: %.cpp
@mkdir -p $(dir $@) @mkdir -p $(dir $@)
$(CC) $(CXX_OPTIONS) -c $(INCLUDE) $< -o $@ $(CC) $(CXX_OPTIONS) -c $(INCLUDE) $< -o $@
@$(CC) $(CXX_OPTIONS) -MM $(INCLUDE) $< > $(patsubst %.o,%.d,$@) @$(CC) $(CXX_OPTIONS) -MM $(INCLUDE) $< > $(patsubst %.o,%.d,$@)
@mv -f $(patsubst %.o,%.d,$@) $(patsubst %.o,%.d,$@).tmp @mv -f $(patsubst %.o,%.d,$@) $(patsubst %.o,%.d,$@).tmp
@sed -e "s|.*:|$(BUILDDIR)$*.o:|" < $(patsubst %.o,%.d,$@).tmp > $(patsubst %.o,%.d,$@) @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,$@) @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 @rm -f $(patsubst %.o,%.d,$@).tmp