Add a debug target for testing gdb.
David Blume

David Blume commited on 2016-10-15 16:50:32
Showing 3 changed files, with 14 additions and 1 deletions.

... ...
@@ -1,7 +1,7 @@
1 1
 SUBDIRS=my_lib product
2 2
 LIBDIR=lib
3 3
 
4
-.PHONY: clean subdirs $(SUBDIRS)
4
+.PHONY: clean debug subdirs $(SUBDIRS)
5 5
 
6 6
 subdirs: $(SUBDIRS)
7 7
 
... ...
@@ -10,6 +10,11 @@ $(SUBDIRS):
10 10
 
11 11
 all: $(LIBDIR) subdirs
12 12
 
13
+debug:
14
+	for dir in $(SUBDIRS); do \
15
+		$(MAKE) -C $$dir debug; \
16
+	done
17
+
13 18
 product: my_lib
14 19
 
15 20
 $(LIBDIR):
... ...
@@ -1,3 +1,4 @@
1
+.PHONEY: debug
1 2
 CXX=g++
2 3
 CPPFLAGS=-c -Wall -std=c++14 -I../include
3 4
 LDFLAGS=
... ...
@@ -11,6 +12,9 @@ LIB=$(LIBDIR)/libmy_lib.a
11 12
 
12 13
 all: $(LIB)
13 14
 
15
+debug: CPPFLAGS += -g
16
+debug: $(LIB)
17
+
14 18
 $(OBJDIR):
15 19
 	mkdir $@
16 20
 
... ...
@@ -1,3 +1,4 @@
1
+.PHONEY: debug
1 2
 CXX=g++
2 3
 CPPFLAGS=-c -Wall -std=c++14 -I../include
3 4
 LIBDIR=../lib
... ...
@@ -12,6 +13,9 @@ EXECUTABLE=main
12 13
 
13 14
 all: $(EXECUTABLE)
14 15
 
16
+debug: CPPFLAGS += -g
17
+debug: $(EXECUTABLE)
18
+
15 19
 $(OBJDIR):
16 20
 	mkdir $@
17 21
 
18 22