Commit 11f47daa authored by Mikaël Salson's avatar Mikaël Salson

Makefiles: Get rid of the OPTIM variable

This variable is non-standard. We should prefer using CXXFLAGS instead.
This eases passing the --coverage option to sub-makes while avoiding
code duplication (for managing CXXFLAGS and OPTIM)

However overriding CXXFLAGS is not a good idea as it keeps expanding the
variable.
parent 4242fda2
...@@ -6,10 +6,13 @@ else ...@@ -6,10 +6,13 @@ else
COVERAGE_OPTION= COVERAGE_OPTION=
endif endif
ifeq ($(CXXFLAGS), )
OPTIM=-O2 -DNDEBUG $(COVERAGE_OPTION) $(DEBUG) CXXFLAGS := -W -Wall -std=c++11 -O2 -DNDEBUG
override CXXFLAGS += -W -Wall -std=c++11 $(OPTIM) endif
override LDFLAGS += $(COVERAGE_OPTION) override CXXFLAGS += $(COVERAGE_OPTION) $(DEBUG)
ifeq ($(LDFLAGS),)
LDFLAGS := $(COVERAGE_OPTION)
endif
export CXXFLAGS export CXXFLAGS
export LDFLAGS export LDFLAGS
...@@ -68,7 +71,7 @@ static: ...@@ -68,7 +71,7 @@ static:
### ###
paranoid: clean paranoid: clean
$(MAKE) vidjil OPTIM="$(PARANOID)" $(MAKE) vidjil CXXFLAGS="$(CXXFLAGS) $(PARANOID)"
### ###
...@@ -96,17 +99,17 @@ cleanspaced: ...@@ -96,17 +99,17 @@ cleanspaced:
$(ALIGN_CGI): cgi/align.o $(LIBCORE) $(ALIGN_CGI): cgi/align.o $(LIBCORE)
mkdir -p $(CGIDIR) mkdir -p $(CGIDIR)
$(MAKE) -C core OPTIM="$(OPTIM)" $(MAKE) -C core
$(CXX) -o $@ $^ $(LDFLAGS) $(LDLIBS) $(CXXFLAGS) $(CXX) -o $@ $^ $(LDFLAGS) $(LDLIBS) $(CXXFLAGS)
$(SIMILARITY_CGI): cgi/similarity.o $(LIBCORE) $(SIMILARITY_CGI): cgi/similarity.o $(LIBCORE)
mkdir -p $(CGIDIR) mkdir -p $(CGIDIR)
$(MAKE) -C core OPTIM="$(OPTIM)" $(MAKE) -C core
$(CXX) -o $@ $^ $(LDFLAGS) $(LDLIBS) $(CXXFLAGS) $(CXX) -o $@ $^ $(LDFLAGS) $(LDLIBS) $(CXXFLAGS)
$(SIMILARITY_TOOL): cgi/similarity.o $(LIBCORE) $(SIMILARITY_TOOL): cgi/similarity.o $(LIBCORE)
mkdir -p $(TOOLDIR) mkdir -p $(TOOLDIR)
$(MAKE) -C core OPTIM="$(OPTIM)" $(MAKE) -C core
$(CXX) -o $@ $^ $(LDFLAGS) $(LDLIBS) $(CXXFLAGS) $(CXX) -o $@ $^ $(LDFLAGS) $(LDLIBS) $(CXXFLAGS)
### ###
...@@ -116,8 +119,8 @@ debug: ...@@ -116,8 +119,8 @@ debug:
$(MAKE) DEBUG="-ggdb" $(MAKE) DEBUG="-ggdb"
$(VIDJIL): $(BINDIR)%: $(MAIN).o $(LIBCORE) $(VIDJIL): $(BINDIR)%: $(MAIN).o $(LIBCORE)
$(MAKE) -C core OPTIM="$(OPTIM)" $(MAKE) -C core
$(MAKE) -C lib OPTIM="$(OPTIM)" $(MAKE) -C lib
$(CXX) -o $@ $^ $(LDFLAGS) $(LDLIBS) $(CXX) -o $@ $^ $(LDFLAGS) $(LDLIBS)
### ###
...@@ -125,10 +128,10 @@ $(VIDJIL): $(BINDIR)%: $(MAIN).o $(LIBCORE) ...@@ -125,10 +128,10 @@ $(VIDJIL): $(BINDIR)%: $(MAIN).o $(LIBCORE)
### ###
core/%.a: FORCE core/%.a: FORCE
$(MAKE) -C core OPTIM="$(OPTIM)" $(notdir $@) $(MAKE) -C core $(notdir $@)
lib/%.a: FORCE lib/%.a: FORCE
$(MAKE) -C lib OPTIM="$(OPTIM)" $(notdir $@) $(MAKE) -C lib $(notdir $@)
clean: clean:
$(MAKE) -C core $@ $(MAKE) -C core $@
...@@ -151,7 +154,7 @@ cleanall: cleancoverage ...@@ -151,7 +154,7 @@ cleanall: cleancoverage
test: test:
$(MAKE) -C tests cleantests $(MAKE) -C tests cleantests
$(TEE) '$(MAKE) OPTIM="$(OPTIM)" unit' tests/out-unit.log $(TEE) '$(MAKE) unit' tests/out-unit.log
$(MAKE) functional $(MAKE) functional
@echo @echo
@echo "*** All tests passed. Congratulations !" @echo "*** All tests passed. Congratulations !"
...@@ -167,7 +170,7 @@ snapshot_diff_current: ...@@ -167,7 +170,7 @@ snapshot_diff_current:
unit: all unit: all
@echo "*** Launching unit tests..." @echo "*** Launching unit tests..."
$(MAKE) OPTIM="$(OPTIM)" -C tests $(MAKE) -C tests
@echo "*** All unit tests passed" @echo "*** All unit tests passed"
functional: all functional: all
...@@ -177,12 +180,12 @@ functional: all ...@@ -177,12 +180,12 @@ functional: all
should: all should: all
@echo @echo
@echo "*** Launching .should_get tests..." @echo "*** Launching .should_get tests..."
$(MAKE) OPTIM="$(OPTIM)" -C tests should $(MAKE) -C tests should
@echo "*** All .should_get tests passed" @echo "*** All .should_get tests passed"
shouldvdj: all shouldvdj: all
@echo @echo
$(MAKE) OPTIM="$(OPTIM)" -C tests shouldvdj_if_python $(MAKE) -C tests shouldvdj_if_python
valgrind_unit: valgrind_unit:
......
CXX?=g++ CXX?=g++
OPTIM=-O2 ifeq ($(CXXFLAGS), )
override CXXFLAGS += -W -Wall -std=c++11 $(OPTIM) CXXFLAGS := -W -Wall -std=c++11 -O2 -DNDEBUG
endif
export CXXFLAGS
INC=-I ../ INC=-I ../
SRCCORE=$(wildcard *.cpp) SRCCORE=$(wildcard *.cpp)
OBJCORE=$(SRCCORE:.cpp=.o) OBJCORE=$(SRCCORE:.cpp=.o)
......
CXX?=g++ CXX?=g++
OPTIM=-O2 ifeq ($(CXXFLAGS), )
override CXXFLAGS += -W -Wall -std=c++11 $(OPTIM) CXXFLAGS := -W -Wall -std=c++11 -O2 -DNDEBUG
endif
export CXXFLAGS
SRCCORE=$(wildcard *.cpp unbam/*.c) SRCCORE=$(wildcard *.cpp unbam/*.c)
TMP_OBJCORE=$(SRCCORE:.cpp=.o) TMP_OBJCORE=$(SRCCORE:.cpp=.o)
OBJCORE=$(TMP_OBJCORE:.c=.o) OBJCORE=$(TMP_OBJCORE:.c=.o)
......
CXX?=g++ CXX?=g++
INCLUDE=-I .. INCLUDE=-I ..
OPTIM=-g -O2 $(COVERAGE) ifeq ($(CXXFLAGS), )
override CXXFLAGS += -std=c++11 -W -Wall $(OPTIM) CXXFLAGS := -W -Wall -std=c++11 -O2
endif
CXXFLAGS := $(filter-out -DNDEBUG,$(CXXFLAGS))
export CXXFLAGS
LDLIBS=-lz LDLIBS=-lz
SRC= unit-tests/tests.cpp SRC= unit-tests/tests.cpp
EXEC=$(SRC:.cpp=) EXEC=$(SRC:.cpp=)
...@@ -136,7 +139,7 @@ $(EXEC): % : %.o $(LIB) ...@@ -136,7 +139,7 @@ $(EXEC): % : %.o $(LIB)
vidjil: vidjil:
$(MAKE) -C ../ clean $(MAKE) -C ../ clean
$(MAKE) -C ../ OPTIM="$(OPTIM)" $(MAKE) -C ../
core: core:
$(MAKE) -C ../core $(MAKE) -C ../core
......
CXX?=g++ CXX?=g++
OPTIM=-O2 ifeq ($(CXXFLAGS), )
override CXXFLAGS += -std=c++11 -W -Wall -I.. -I../lib/ $(OPTIM) CXXFLAGS := -W -Wall -std=c++11 -O2 -DNDEBUG
endif
override CXXFLAGS += -I.. -I../lib/
export CXXFLAGS
LDLIBS=-lm -lz LDLIBS=-lm -lz
SRC=$(wildcard *.cpp) SRC=$(wildcard *.cpp)
EXEC=$(SRC:.cpp=) EXEC=$(SRC:.cpp=)
...@@ -13,7 +16,7 @@ go: vdj_assign align ...@@ -13,7 +16,7 @@ go: vdj_assign align
all: $(EXEC) all: $(EXEC)
$(EXEC): %: %.o $(EXEC): %: %.o
$(MAKE) -C .. base OPTIM="$(OPTIM)" $(MAKE) -C .. base
$(CXX) -I .. -o $@ $^ $(LIBCORE) $(LDLIBS) $(LDFLAGS) $(CXX) -I .. -o $@ $^ $(LIBCORE) $(LDLIBS) $(LDFLAGS)
clean: clean:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment