Makefile 2.41 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:
41 42 43 44
	if python ../../tools/check_python_version.py ; \
	then $(MAKE) shouldvdj ; \
	else echo "!!! Bad python version, we skip .should-vdj.fa tests..." ; \
	fi
45

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

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

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

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

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

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


../core.a: core

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

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

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

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

cleanall: clean cleancoverage cleantests
90

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

Mikaël Salson's avatar
Mikaël Salson committed
94 95
force:

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

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