Makefile 3.53 KB
Newer Older
1
CXX=g++
Mikaël Salson's avatar
Mikaël Salson committed
2
INCLUDE=-I ..
3
OPTIM=-g -O0 $(COVERAGE)
Mathieu Giraud's avatar
Mathieu Giraud committed
4
override CXXFLAGS += -std=c++11 -W -Wall $(OPTIM)
5
LDLIBS=-lz
6
SRC= unit-tests/tests.cpp
Mikaël Salson's avatar
Mikaël Salson committed
7
EXEC=$(SRC:.cpp=)
Mathieu Giraud's avatar
Mathieu Giraud committed
8
OTHER_SRC=$(wildcard *.cpp)
9
LIB=../core/vidjil.a ../lib/lib.a
10 11
SHOULD=$(wildcard should-get-tests/*.should-get)
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 20
#should-vdj that should not be published in our public curated dataset (just internal tests)
EXCLUDE_SHOULD_VDJ=bug20151006-rc.should-vdj.fa cdr3-indels.should-vdj.fa ext-nucleotides-N.should-vdj.fa segment_simul.should-vdj.fa
SHOULD_VDJ_ARCHIVE:=$(filter-out $(addprefix should-vdj-tests/,$(EXCLUDE_SHOULD_VDJ)), $(SHOULD_VDJ))

21
DATE=$(shell date +%Y-%m-%d--%H:%M:%S)
22
SNAPSHOTS_DIR=./snapshots
23
SNAPSHOT=$(SNAPSHOTS_DIR)/snapshot-log--$(DATE)
24

Mikaël Salson's avatar
Mikaël Salson committed
25
.PHONY: all force clean forcedep
Mikaël Salson's avatar
Mikaël Salson committed
26 27 28 29

test: all
	@echo
	@echo "*** Launching unit tests..."
30 31
	./unit-tests/tests
	cat ./unit-tests/tests.cpp.tap
Mikaël Salson's avatar
Mikaël Salson committed
32 33 34 35 36
	@echo "*** All unit tests passed"

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

37
snapshot:
38
	mkdir -p $(SNAPSHOTS_DIR)
39
	grep . should-get-tests/*.log should-vdj-tests/*.log > $(SNAPSHOT)
40 41
	touch snapshot-last ; mv snapshot-last snapshot-prev
	ln -s $(SNAPSHOT) snapshot-last
42
	diff -I "20..-..-.." snapshot-prev snapshot-last | diffstat -cC
43

44
should: vidjil $(SHOULD_LOG)
Mikaël Salson's avatar
Mikaël Salson committed
45

46
shouldvdj_if_python:
47
	if python ../../tools/check_python_version.py ; \
48
	then $(MAKE) shouldlocus_and_vdj ; \
49 50
	else echo "!!! Bad python version, we skip .should-vdj.fa tests..." ; \
	fi
51

52
shouldlocus_and_vdj: vidjil
53
	@echo "*** Launching .should-vdj-fa tests..."
54
	python should-vdj-to-tap.py -2q -r $(SHOULD_VDJ) $(SHOULD_LOCUS)
55
	$(MAKE) shouldvdj_with_rc
56
	@echo "*** All .should-vdj.fa tests passed"
57

58 59 60
shouldvdj:
	python should-vdj-to-tap.py $(SHOULD_VDJ)

61 62 63
shouldvdj_with_rc:
	python should-vdj-to-tap.py -r $(SHOULD_VDJ)

64 65 66 67
shouldvdj_with_rc_merged:
	cat $(SHOULD_VDJ) > should-vdj-tests/should-vdj.merged.fa
	python should-vdj-to-tap.py -r should-vdj-tests/should-vdj.merged.fa

68 69 70 71 72 73 74 75 76
shouldvdj_archive: should-vdj.zip
should-vdj.zip: $(SHOULD_VDJ_ARCHIVE)
	$(eval tmpdir := $(shell mktemp -d))
	mkdir $(tmpdir)/should-vdj
	cp --parents --preserve $(SHOULD_VDJ_ARCHIVE) $(tmpdir)
	sed -ri 's/\s*BUG//' $(tmpdir)/should-vdj-tests/*
	cwd=`pwd` && cd $(tmpdir) && zip $$cwd/$@ $(SHOULD_VDJ_ARCHIVE)
	rm -rf $(tmpdir)

77
%.tap: %.should-get force
Mikaël Salson's avatar
Mikaël Salson committed
78
	./should-to-tap.sh $<
79 80

valgrind_should:
Mikaël Salson's avatar
Mikaël Salson committed
81 82
	$(MAKE) -C $(REPORTS_PATH) clean_valgrind
	LAUNCHER="$(VALGRIND)" $(MAKE) should
83

84
valgrind_%:
Mikaël Salson's avatar
Mikaël Salson committed
85
	LAUNCHER="$(VALGRIND)" $(MAKE) $(patsubst valgrind_%,%,$@)
86

87
valgrind_tests: vidjil ./unit-tests/tests
88
	$(VALGRIND) ./unit-tests/tests
Mikaël Salson's avatar
Mikaël Salson committed
89

Mathieu Giraud's avatar
Mathieu Giraud committed
90
$(EXEC): % : %.o $(LIB) 
91
	$(CXX) -o $@ $< $(LIB) $(LDLIBS) $(LDFLAGS) $(CXXFLAGS)
Mikaël Salson's avatar
Mikaël Salson committed
92 93 94 95


../core.a: core

96
vidjil:
Mikaël Salson's avatar
Mikaël Salson committed
97 98
	$(MAKE) -C ../ clean
	$(MAKE) -C ../ OPTIM="$(OPTIM)"
99

Mikaël Salson's avatar
Mikaël Salson committed
100
core:
Mikaël Salson's avatar
Mikaël Salson committed
101
	$(MAKE) -C ../core
Mikaël Salson's avatar
Mikaël Salson committed
102

Mathieu Giraud's avatar
Mathieu Giraud committed
103
%.o: %.cpp $(OTHER_SRC)
104
	$(CXX) -o $@ $(INCLUDE) -c $< $(CXXFLAGS)
Mikaël Salson's avatar
Mikaël Salson committed
105 106

clean:
107
	rm -f *.o $(EXEC)
108 109
cleancoverage:
	rm -f *.gcda *.gcno *.gcov
110 111 112 113 114
cleantests:
	rm -f *.tap *.log should-vdj-tests/*.tap should-vdj-tests/*.log
	rm -rf out/

cleanall: clean cleancoverage cleantests
115

Mikaël Salson's avatar
Mikaël Salson committed
116
forcedep:
117
	$(CXX) $(CXXFLAGS) $(INCLUDE) -M $(SRC) > dep.mk
Mikaël Salson's avatar
Mikaël Salson committed
118

Mikaël Salson's avatar
Mikaël Salson committed
119 120
force:

Mikaël Salson's avatar
Mikaël Salson committed
121 122 123
DEP=$(wildcard dep.mk)

ifeq (${DEP},)
124
$(shell	$(CXX) $(CXXFLAGS) $(INCLUDE) -M $(SRC) > dep.mk)
Mikaël Salson's avatar
Mikaël Salson committed
125 126 127
endif
include dep.mk