about summary refs log tree commit diff
diff options
context:
space:
mode:
authorEelco Dolstra <eelco.dolstra@logicblox.com>2013-11-22T19·51+0000
committerEelco Dolstra <eelco.dolstra@logicblox.com>2013-11-22T19·51+0000
commit812b5a30ecc9d8f78b54644b37c5c2c4375555bc (patch)
tree358d1867b50bb89b50217271e23f84178c09edf6
parentea2f7df5fac0b319b82a4a33ba8b992737fa8c56 (diff)
Add a Makefile variable for enabling debug info
-rw-r--r--Makefile.config.in1
-rw-r--r--Makefile.lib23
2 files changed, 20 insertions, 4 deletions
diff --git a/Makefile.config.in b/Makefile.config.in
index 45fb74c91184..bfe3deab9a6f 100644
--- a/Makefile.config.in
+++ b/Makefile.config.in
@@ -1,3 +1,4 @@
+BUILD_DEBUG = 1
 CC = @CC@
 CFLAGS = @CFLAGS@
 CXX = @CXX@
diff --git a/Makefile.lib b/Makefile.lib
index 4df40c9d2cf4..b045534dcca8 100644
--- a/Makefile.lib
+++ b/Makefile.lib
@@ -17,17 +17,33 @@ endef
 $(foreach mf, $(SUBS), $(eval $(call include_sub_makefile, $(mf))))
 
 
+# Initialise some variables.
 clean_list :=
 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
-	$(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
-	$(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.
@@ -91,7 +107,6 @@ dist:
 
 
 # Cleaning stuff.
-
 clean:
 	rm -fv $(clean_list)