Browse Source

Added debug option to the Makefile.

Nikita Ermakov 3 years ago
parent
commit
2797c801bc
1 changed files with 13 additions and 2 deletions
  1. 13 2
      Makefile

+ 13 - 2
Makefile

@@ -2,7 +2,7 @@
 CXX = g++
 
 # Define flags
-CFLAGS = $(shell root-config --cflags) -O2 -fPIC -Wall -pipe -std=c++11 -I.
+CFLAGS = $(shell root-config --cflags) -fPIC -Wall -pipe -std=c++11 -I.
 LIBS = $(shell root-config --glibs) -lEG
 INCS = $(shell root-config --incdir)
 
@@ -12,8 +12,15 @@ UNIGEN = libUniGen.so
 # Compile all *.cxx classes in the directory
 SRC = $(shell find . -name "*.cxx")
 
+all: CFLAGS += -O2
 all: $(UNIGEN)
 
+.PHONY: optdebug debug
+optdebug: CFLAGS += -O2 -g
+optdebug: $(UNIGEN)
+debug: CFLAGS += -O0 -g
+debug: $(UNIGEN)
+
 # $(SRC:.cc=.o)
 $(UNIGEN): $(SRC:.cxx=.o) UniGen_Dict.C
 	$(CXX) $(CFLAGS) -shared $^ -o $(UNIGEN) $(LIBS)
@@ -25,7 +32,7 @@ $(UNIGEN): $(SRC:.cxx=.o) UniGen_Dict.C
 UniGen_Dict.C: $(shell find . -name "*.h" ! -name "*LinkDef*")
 	rootcint -f $@ -c -I. -I$(INCS) $^ UniGenLinkDef.h
 
-.PHONY: clean distclean converters
+.PHONY: clean distclean converters converters_debug converters_optdebug
 
 clean:
 	rm -vf *.o UniGen_Dict*
@@ -33,5 +40,9 @@ clean:
 distclean:
 	rm -vf *.o UniGen_Dict* $(UNIGEN) urqmd2u
 
+converters_debug: CFLAGS += -O0 -g
+converters_debug: converters
+converters_optdebug: CFLAGS += -O2 -g
+converters_optdebug: converters
 converters: urqmd2u.cpp
 	$(CXX) $(CFLAGS) -I$(INCS) $^ -o $(patsubst %.cpp,%,$<) -L. -l$(patsubst lib%.so,%,$(UNIGEN)) $(LIBS)