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
COVERAGE_OPTION=
endif
OPTIM=-O2 -DNDEBUG $(COVERAGE_OPTION) $(DEBUG)
override CXXFLAGS += -W -Wall -std=c++11 $(OPTIM)
override LDFLAGS += $(COVERAGE_OPTION)
ifeq ($(CXXFLAGS), )
CXXFLAGS := -W -Wall -std=c++11 -O2 -DNDEBUG
endif
override CXXFLAGS += $(COVERAGE_OPTION) $(DEBUG)
ifeq ($(LDFLAGS),)
LDFLAGS := $(COVERAGE_OPTION)
endif
export CXXFLAGS
export LDFLAGS
......@@ -68,7 +71,7 @@ static:
###
paranoid: clean
$(MAKE) vidjil OPTIM="$(PARANOID)"
$(MAKE) vidjil CXXFLAGS="$(CXXFLAGS) $(PARANOID)"
###
......@@ -96,17 +99,17 @@ cleanspaced:
$(ALIGN_CGI): cgi/align.o $(LIBCORE)
mkdir -p $(CGIDIR)
$(MAKE) -C core OPTIM="$(OPTIM)"
$(MAKE) -C core
$(CXX) -o $@ $^ $(LDFLAGS) $(LDLIBS) $(CXXFLAGS)
$(SIMILARITY_CGI): cgi/similarity.o $(LIBCORE)
mkdir -p $(CGIDIR)
$(MAKE) -C core OPTIM="$(OPTIM)"
$(MAKE) -C core
$(CXX) -o $@ $^ $(LDFLAGS) $(LDLIBS) $(CXXFLAGS)
$(SIMILARITY_TOOL): cgi/similarity.o $(LIBCORE)
mkdir -p $(TOOLDIR)
$(MAKE) -C core OPTIM="$(OPTIM)"
$(MAKE) -C core
$(CXX) -o $@ $^ $(LDFLAGS) $(LDLIBS) $(CXXFLAGS)
###
......@@ -116,8 +119,8 @@ debug:
$(MAKE) DEBUG="-ggdb"
$(VIDJIL): $(BINDIR)%: $(MAIN).o $(LIBCORE)
$(MAKE) -C core OPTIM="$(OPTIM)"
$(MAKE) -C lib OPTIM="$(OPTIM)"
$(MAKE) -C core
$(MAKE) -C lib
$(CXX) -o $@ $^ $(LDFLAGS) $(LDLIBS)
###
......@@ -125,10 +128,10 @@ $(VIDJIL): $(BINDIR)%: $(MAIN).o $(LIBCORE)
###
core/%.a: FORCE
$(MAKE) -C core OPTIM="$(OPTIM)" $(notdir $@)
$(MAKE) -C core $(notdir $@)
lib/%.a: FORCE
$(MAKE) -C lib OPTIM="$(OPTIM)" $(notdir $@)
$(MAKE) -C lib $(notdir $@)
clean:
$(MAKE) -C core $@
......@@ -151,7 +154,7 @@ cleanall: cleancoverage
test:
$(MAKE) -C tests cleantests
$(TEE) '$(MAKE) OPTIM="$(OPTIM)" unit' tests/out-unit.log
$(TEE) '$(MAKE) unit' tests/out-unit.log
$(MAKE) functional
@echo
@echo "*** All tests passed. Congratulations !"
......@@ -167,7 +170,7 @@ snapshot_diff_current:
unit: all
@echo "*** Launching unit tests..."
$(MAKE) OPTIM="$(OPTIM)" -C tests
$(MAKE) -C tests
@echo "*** All unit tests passed"
functional: all
......@@ -177,12 +180,12 @@ functional: all
should: all
@echo
@echo "*** Launching .should_get tests..."
$(MAKE) OPTIM="$(OPTIM)" -C tests should
$(MAKE) -C tests should
@echo "*** All .should_get tests passed"
shouldvdj: all
@echo
$(MAKE) OPTIM="$(OPTIM)" -C tests shouldvdj_if_python
$(MAKE) -C tests shouldvdj_if_python
valgrind_unit:
......
CXX?=g++
OPTIM=-O2
override CXXFLAGS += -W -Wall -std=c++11 $(OPTIM)
ifeq ($(CXXFLAGS), )
CXXFLAGS := -W -Wall -std=c++11 -O2 -DNDEBUG
endif
export CXXFLAGS
INC=-I ../
SRCCORE=$(wildcard *.cpp)
OBJCORE=$(SRCCORE:.cpp=.o)
......
CXX?=g++
OPTIM=-O2
override CXXFLAGS += -W -Wall -std=c++11 $(OPTIM)
ifeq ($(CXXFLAGS), )
CXXFLAGS := -W -Wall -std=c++11 -O2 -DNDEBUG
endif
export CXXFLAGS
SRCCORE=$(wildcard *.cpp unbam/*.c)
TMP_OBJCORE=$(SRCCORE:.cpp=.o)
OBJCORE=$(TMP_OBJCORE:.c=.o)
......
CXX?=g++
INCLUDE=-I ..
OPTIM=-g -O2 $(COVERAGE)
override CXXFLAGS += -std=c++11 -W -Wall $(OPTIM)
ifeq ($(CXXFLAGS), )
CXXFLAGS := -W -Wall -std=c++11 -O2
endif
CXXFLAGS := $(filter-out -DNDEBUG,$(CXXFLAGS))
export CXXFLAGS
LDLIBS=-lz
SRC= unit-tests/tests.cpp
EXEC=$(SRC:.cpp=)
......@@ -136,7 +139,7 @@ $(EXEC): % : %.o $(LIB)
vidjil:
$(MAKE) -C ../ clean
$(MAKE) -C ../ OPTIM="$(OPTIM)"
$(MAKE) -C ../
core:
$(MAKE) -C ../core
......
CXX?=g++
OPTIM=-O2
override CXXFLAGS += -std=c++11 -W -Wall -I.. -I../lib/ $(OPTIM)
ifeq ($(CXXFLAGS), )
CXXFLAGS := -W -Wall -std=c++11 -O2 -DNDEBUG
endif
override CXXFLAGS += -I.. -I../lib/
export CXXFLAGS
LDLIBS=-lm -lz
SRC=$(wildcard *.cpp)
EXEC=$(SRC:.cpp=)
......@@ -13,7 +16,7 @@ go: vdj_assign align
all: $(EXEC)
$(EXEC): %: %.o
$(MAKE) -C .. base OPTIM="$(OPTIM)"
$(MAKE) -C .. base
$(CXX) -I .. -o $@ $^ $(LIBCORE) $(LDLIBS) $(LDFLAGS)
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