Add a Makefile variable for enabling debug info

This commit is contained in:
Eelco Dolstra 2013-11-22 19:51:18 +00:00
parent ea2f7df5fa
commit 812b5a30ec
2 changed files with 21 additions and 5 deletions

View file

@ -1,3 +1,4 @@
BUILD_DEBUG = 1
CC = @CC@ CC = @CC@
CFLAGS = @CFLAGS@ CFLAGS = @CFLAGS@
CXX = @CXX@ CXX = @CXX@

View file

@ -17,17 +17,33 @@ endef
$(foreach mf, $(SUBS), $(eval $(call include_sub_makefile, $(mf)))) $(foreach mf, $(SUBS), $(eval $(call include_sub_makefile, $(mf))))
# Initialise some variables.
clean_list := clean_list :=
dist_files := dist_files :=
QUIET = @ QUIET = @
# Pass -fPIC if we're building dynamic libraries.
ifeq ($(BUILD_SHARED_LIBS), 1)
GLOBAL_CFLAGS += -fPIC
GLOBAL_CXXFLAGS += -fPIC
endif
# Pass -g if we want debug info.
ifeq ($(BUILD_DEBUG), 1)
GLOBAL_CFLAGS += -g
GLOBAL_CXXFLAGS += -g
endif
# Pattern rules.
%.o: %.cc %.o: %.cc
$(QUIET) $(CXX) -o $@ -c $< -g -fPIC $(GLOBAL_CXXFLAGS) $(CXXFLAGS) $($@_CXXFLAGS) -MMD -MF $(basename $@).dep -MP $(QUIET) $(CXX) -o $@ -c $< $(GLOBAL_CXXFLAGS) $(CXXFLAGS) $($@_CXXFLAGS) -MMD -MF $(basename $@).dep -MP
%.o: %.c %.o: %.c
$(QUIET) $(CC) -o $@ -c $< -g -fPIC $(GLOBAL_CFLAGS) $(CFLAGS) $($@_CFLAGS) -MMD -MF $(basename $@).dep -MP $(QUIET) $(CC) -o $@ -c $< $(GLOBAL_CFLAGS) $(CFLAGS) $($@_CFLAGS) -MMD -MF $(basename $@).dep -MP
# Generate Make rules for libraries. # Generate Make rules for libraries.
@ -91,7 +107,6 @@ dist:
# Cleaning stuff. # Cleaning stuff.
clean: clean:
rm -fv $(clean_list) rm -fv $(clean_list)