Makefile 2.44 KB
Newer Older
Mikaël Salson's avatar
Mikaël Salson committed
1 2
CC=g++
INCLUDE=-I ..
3 4 5
OPTIM=-g -O0 $(COVERAGE)
override CXXFLAGS += -W -Wall $(OPTIM)
LDLIBS=-lz
Mikaël Salson's avatar
Mikaël Salson committed
6 7
SRC= tests.cpp
EXEC=$(SRC:.cpp=)
Mathieu Giraud's avatar
Mathieu Giraud committed
8
OTHER_SRC=$(wildcard *.cpp)
9
LIB=../core/vidjil.a ../lib/lib.a
Mikaël Salson's avatar
Mikaël Salson committed
10
SHOULD=$(wildcard *.should_get)
11
SHOULD_LOG=$(SHOULD:.should_get=.tap)
12
SHOULD_VDJ=$(wildcard should-vdj-tests/*.should-vdj.fa)
13
SHOULD_LOCUS=$(wildcard should-vdj-tests/*.should-locus.fa)
14
REPORTS_PATH := $(patsubst %/Makefile,%,$(abspath $(lastword $(MAKEFILE_LIST))))/../../reports
15
VALGRIND=valgrind -v --tool=memcheck --leak-check=full --show-reachable=yes --undef-value-errors=yes --track-origins=yes --xml=yes --xml-file="$$(mktemp "$(REPORTS_PATH)/valgrind.xml.XXXXXX")"
Mikaël Salson's avatar
Mikaël Salson committed
16

17 18 19
DATE=$(shell date +%Y-%m-%d:%H:%M:%S)
SNAPSHOT=snapshot-log-$(DATE)

Mikaël Salson's avatar
Mikaël Salson committed
20
.PHONY: all force clean forcedep
Mikaël Salson's avatar
Mikaël Salson committed
21 22 23 24 25 26 27 28 29 30 31

test: all
	@echo
	@echo "*** Launching unit tests..."
	./tests
	cat tests.cpp.tap
	@echo "*** All unit tests passed"

all: core $(EXEC)
	@echo "All tests compiled."

32 33 34 35
snapshot:
	grep . *.log should-vdj-tests/*.log > $(SNAPSHOT)
	touch snapshot-last ; mv snapshot-last snapshot-prev
	ln -s $(SNAPSHOT) snapshot-last
36
	diff -I "20..-..-.." snapshot-prev snapshot-last | diffstat -cC
37

38
should: vidjil $(SHOULD_LOG)
Mikaël Salson's avatar
Mikaël Salson committed
39

40
shouldvdj_if_python:
Mikaël Salson's avatar
Mikaël Salson committed
41
	-(python ../../tools/check_python_version.py && $(MAKE) shouldvdj)
42 43
	@(python ../../tools/check_python_version.py || echo "!!! Bad python version, we skip .should-vdj.fa tests...")

44
shouldvdj: vidjil
45
	@echo "*** Launching .should-vdj-fa tests..."
46
	python should-vdj-to-tap.py -2q -r $(SHOULD_VDJ) $(SHOULD_LOCUS)
47
	python should-vdj-to-tap.py $(SHOULD_VDJ)
48
	@echo "*** All .should-vdj.fa tests passed"
49

50
%.tap: %.should_get force
Mikaël Salson's avatar
Mikaël Salson committed
51
	./should-to-tap.sh $<
52 53

valgrind_should:
Mikaël Salson's avatar
Mikaël Salson committed
54 55
	$(MAKE) -C $(REPORTS_PATH) clean_valgrind
	LAUNCHER="$(VALGRIND)" $(MAKE) should
56

57
valgrind_%:
Mikaël Salson's avatar
Mikaël Salson committed
58
	LAUNCHER="$(VALGRIND)" $(MAKE) $(patsubst valgrind_%,%,$@)
59

60 61
valgrind_tests: vidjil tests
	$(VALGRIND) ./tests
Mikaël Salson's avatar
Mikaël Salson committed
62

Mathieu Giraud's avatar
Mathieu Giraud committed
63
$(EXEC): % : %.o $(LIB) 
64
	$(CC) -o $@ $< $(LIB) $(LDLIBS) $(LDFLAGS) $(CXXFLAGS)
Mikaël Salson's avatar
Mikaël Salson committed
65 66 67 68


../core.a: core

69
vidjil:
Mikaël Salson's avatar
Mikaël Salson committed
70 71
	$(MAKE) -C ../ clean
	$(MAKE) -C ../ OPTIM="$(OPTIM)"
72

Mikaël Salson's avatar
Mikaël Salson committed
73
core:
Mikaël Salson's avatar
Mikaël Salson committed
74
	$(MAKE) -C ../core
Mikaël Salson's avatar
Mikaël Salson committed
75

Mathieu Giraud's avatar
Mathieu Giraud committed
76
%.o: %.cpp $(OTHER_SRC)
77
	$(CC) -o $@ $(INCLUDE) -c $< $(CXXFLAGS)
Mikaël Salson's avatar
Mikaël Salson committed
78 79

clean:
80
	rm -f *.o $(EXEC)
81 82
cleancoverage:
	rm -f *.gcda *.gcno *.gcov
83 84 85 86 87
cleantests:
	rm -f *.tap *.log should-vdj-tests/*.tap should-vdj-tests/*.log
	rm -rf out/

cleanall: clean cleancoverage cleantests
88

Mikaël Salson's avatar
Mikaël Salson committed
89 90 91
forcedep:
	g++ $(INCLUDE) -M $(SRC) > dep.mk

Mikaël Salson's avatar
Mikaël Salson committed
92 93
force:

Mikaël Salson's avatar
Mikaël Salson committed
94 95 96 97 98 99 100
DEP=$(wildcard dep.mk)

ifeq (${DEP},)
$(shell	g++ $(INCLUDE) -M $(SRC) > dep.mk)
endif
include dep.mk