Attention une mise à jour du service Gitlab va être effectuée le mardi 30 novembre entre 17h30 et 18h00. Cette mise à jour va générer une interruption du service dont nous ne maîtrisons pas complètement la durée mais qui ne devrait pas excéder quelques minutes. Cette mise à jour intermédiaire en version 14.0.12 nous permettra de rapidement pouvoir mettre à votre disposition une version plus récente.

Makefile 9.67 KB
Newer Older
1
CXX?=g++
2 3 4 5 6 7 8

ifeq (${COVERAGE},1)
	COVERAGE_OPTION=--coverage
else
	COVERAGE_OPTION=
endif

9 10 11 12 13 14 15
ifeq ($(CXXFLAGS), )
  CXXFLAGS := -W -Wall -std=c++11 -O2 -DNDEBUG
endif
override CXXFLAGS += $(COVERAGE_OPTION) $(DEBUG)
ifeq ($(LDFLAGS),)
  LDFLAGS := $(COVERAGE_OPTION)
endif
16
COV_OUTFILE?=lcov.out
17
BASE_PATH=$(dir $(abspath .))
18 19 20 21

export CXXFLAGS
export LDFLAGS
export CXX
Mathieu Giraud's avatar
Mathieu Giraud committed
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43

## inspired from http://stackoverflow.com/questions/399850/best-compiler-warning-level-for-c-c-compilers/401276
PARANOID= -Wall -Weffc++ -pedantic  \
    -Wextra -Waggregate-return -Wcast-align \
    -Wcast-qual  -Wchar-subscripts  -Wcomment -Wconversion \
    -Wdisabled-optimization \
    -Wfloat-equal  -Wformat  -Wformat=2 \
    -Wformat-nonliteral -Wformat-security  \
    -Wformat-y2k \
    -Wimplicit  -Wimport  -Winit-self  -Winline \
    -Winvalid-pch   -Wlong-long -Wmissing-braces \
    -Wmissing-field-initializers -Wmissing-format-attribute   \
    -Wmissing-include-dirs -Wmissing-noreturn \
    -Wpacked  -Wpadded -Wparentheses  -Wpointer-arith \
    -Wredundant-decls -Wreturn-type \
    -Wsequence-point  -Wshadow -Wsign-compare  -Wstack-protector \
    -Wstrict-aliasing -Wstrict-aliasing=2 -Wswitch  -Wswitch-default \
    -Wswitch-enum -Wtrigraphs  -Wuninitialized \
    -Wunknown-pragmas  -Wunreachable-code -Wunused \
    -Wunused-function  -Wunused-label  -Wunused-parameter \
    -Wunused-value  -Wunused-variable  -Wvariadic-macros \
    -Wvolatile-register-var  -Wwrite-strings
44
LDLIBS=-lm -lz
45 46
MAIN=vidjil
EXEC=vidjil-algo
Mikaël Salson's avatar
Mikaël Salson committed
47
MAINCORE=$(wildcard *.cpp)
48
LIBCORE=core/vidjil.a lib/lib.a
Mikaël Salson's avatar
Mikaël Salson committed
49

50
BINDIR=../
Mathieu Giraud's avatar
Mathieu Giraud committed
51
CGIDIR=../tools/
52
TOOLDIR=tools/
53 54 55

VIDJIL=$(BINDIR)$(EXEC)
ALIGN_CGI=$(CGIDIR)align.cgi
56
SIMILARITY_CGI=$(CGIDIR)similarity.cgi
57
SIMILARITY_TOOL=$(TOOLDIR)similarity
Mikaël Salson's avatar
Mikaël Salson committed
58

59
CREATE_VERSION_GIT_H := $(shell test -x ./create-git-version-h.sh && ./create-git-version-h.sh)
60

61 62
TEE = python ../tools/tee.py -v

63
.PHONY: all core lib clean forcedep gcovr_reports
64

65
all: $(VIDJIL) $(ALIGN_CGI) $(SIMILARITY_CGI) $(SIMILARITY_TOOL)
Mathieu Giraud's avatar
Mathieu Giraud committed
66 67 68
	$(MAKE) -C $(TOOLDIR)

base: $(VIDJIL)
Mikaël Salson's avatar
Mikaël Salson committed
69

70 71 72
static:
	$(MAKE) all LDFLAGS="-static -static-libstdc++"

73 74
###

Mathieu Giraud's avatar
Mathieu Giraud committed
75
paranoid: clean
76
	$(MAKE) vidjil CXXFLAGS="$(CXXFLAGS) $(PARANOID)"
Mathieu Giraud's avatar
Mathieu Giraud committed
77 78 79

###

80
kmers: cleankmers
Mikaël Salson's avatar
Mikaël Salson committed
81
	$(MAKE) CONFIG="-DDEBUG_KMERS"
82 83

nokmers: cleankmers
Mikaël Salson's avatar
Mikaël Salson committed
84
	$(MAKE)
85 86 87 88 89

cleankmers:
	rm -f vidjil.o core/windowExtractor.o core/segment.o

###
Mathieu Giraud's avatar
Mathieu Giraud committed
90 91

spaced: cleanspaced
Mikaël Salson's avatar
Mikaël Salson committed
92
	$(MAKE)
Mathieu Giraud's avatar
Mathieu Giraud committed
93 94

nospaced: cleanspaced
Mikaël Salson's avatar
Mikaël Salson committed
95
	$(MAKE) CONFIG="-DNO_SPACED_SEEDS"
Mathieu Giraud's avatar
Mathieu Giraud committed
96 97

cleanspaced:
Mikaël Salson's avatar
Mikaël Salson committed
98
	rm -f vidjil.o core/tools.o
Mathieu Giraud's avatar
Mathieu Giraud committed
99

100
###
Mathieu Giraud's avatar
Mathieu Giraud committed
101

102
$(ALIGN_CGI): cgi/align.o $(LIBCORE)
Mathieu Giraud's avatar
Mathieu Giraud committed
103
	mkdir -p $(CGIDIR)
104
	$(MAKE) -C core
105
	$(CXX) -o $@ $^ $(LDFLAGS) $(LDLIBS) $(CXXFLAGS)
106 107

$(SIMILARITY_CGI): cgi/similarity.o $(LIBCORE)
Mathieu Giraud's avatar
Mathieu Giraud committed
108
	mkdir -p $(CGIDIR)
109
	$(MAKE) -C core
110
	$(CXX) -o $@ $^ $(LDFLAGS) $(LDLIBS) $(CXXFLAGS)
111 112

$(SIMILARITY_TOOL): cgi/similarity.o $(LIBCORE)
Mathieu Giraud's avatar
Mathieu Giraud committed
113
	mkdir -p $(TOOLDIR)
114
	$(MAKE) -C core
115 116
	$(CXX) -o $@ $^ $(LDFLAGS) $(LDLIBS) $(CXXFLAGS)

117 118
###

Mikaël Salson's avatar
Mikaël Salson committed
119
debug:
Mikaël Salson's avatar
Mikaël Salson committed
120 121
	$(MAKE) clean
	$(MAKE) DEBUG="-ggdb"
Mikaël Salson's avatar
Mikaël Salson committed
122

123
$(VIDJIL): $(BINDIR)%: $(MAIN).o $(LIBCORE)
124 125
	$(MAKE) -C core
	$(MAKE) -C lib
126
	$(CXX) -o $@ $^ $(LDFLAGS) $(LDLIBS)
Mikaël Salson's avatar
Mikaël Salson committed
127

128 129 130 131
###
# Subdirectories
###

132
core/%.a: FORCE
133
	$(MAKE) -C core $(notdir $@)
134

135
lib/%.a: FORCE
136
	$(MAKE) -C lib $(notdir $@)
137

Mikaël Salson's avatar
Mikaël Salson committed
138
clean:
Mikaël Salson's avatar
Mikaël Salson committed
139 140
	$(MAKE) -C core $@
	$(MAKE) -C lib $@
141
	rm -f *.o cgi/*.o
Mikaël Salson's avatar
Mikaël Salson committed
142
	cd $(BINDIR) ; rm -f $(EXEC)
Mikaël Salson's avatar
Mikaël Salson committed
143
	$(MAKE) -C tests $@
Mikaël Salson's avatar
Mikaël Salson committed
144

145 146
cleancoverage: clean
	rm -f *.gcda *.gcno *.gcov
Mikaël Salson's avatar
Mikaël Salson committed
147 148
	$(MAKE) -C core cleancoverage
	$(MAKE) -C lib cleancoverage
149

150
cleanall: cleancoverage
Mikaël Salson's avatar
Mikaël Salson committed
151
	$(MAKE) -C tests cleanall
152

153 154 155 156 157 158
###
# Tests
###

test:
	$(MAKE) -C tests cleantests
159
	$(TEE) '$(MAKE) unit' tests/out-unit.log
160 161 162 163 164 165 166 167 168 169 170 171 172
	$(MAKE) functional
	@echo
	@echo "*** All tests passed. Congratulations !"
	@echo
	$(MAKE) -C tests snapshot_success
	$(MAKE) -C tests mark_failed_tests_as_todo

snapshot_diff:
	$(MAKE) -C tests snapshot_diff

snapshot_diff_current:
	$(MAKE) -C tests snapshot_diff_current

173 174
unit:
	$(MAKE) CXXFLAGS="$(filter-out -DNDEBUG, $(CXXFLAGS))" all
175
	@echo "*** Launching unit tests..."
176
	$(MAKE) -C tests
177 178
	@echo "*** All unit tests passed"

179
functional:
180 181 182
	$(TEE) '$(MAKE) should'      tests/out-should-get.log
	$(TEE) '$(MAKE) shouldvdj'   tests/out-should-vdj.log

183 184
should:
	$(MAKE) CXXFLAGS="$(filter-out -DNDEBUG, $(CXXFLAGS))" all
185 186
	@echo
	@echo "*** Launching .should_get tests..."
187
	$(MAKE) -C tests should
188 189
	@echo "*** All .should_get tests passed"

190
shouldvdj:
191
	@echo
192
	$(MAKE) CXXFLAGS="$(filter-out -DNDEBUG, $(CXXFLAGS))" all
193
	$(MAKE) -C tests shouldvdj_if_python
194 195 196 197 198 199 200 201 202 203 204 205 206 207


valgrind_unit:
	$(MAKE) -C tests valgrind_tests

valgrind_should:
	$(MAKE) -C tests valgrind_should



### Code coverage

coverage: unit_coverage should_coverage

208
unit_coverage: cleancoverage
209
	$(MAKE) COVERAGE=1 unit
210
	$(MAKE) COV_OUTFILE=lcov_test_unit gencov
211
should_coverage: cleancoverage
212
	$(MAKE) COVERAGE=1 should
213
	$(MAKE) COV_OUTFILE=lcov_test_should gencov
214
shouldvdj_coverage: cleancoverage
215
	$(MAKE) COVERAGE=1 shouldvdj
216
	$(MAKE) COV_OUTFILE=lcov_test_shouldvdj gencov
217
functional_coverage: cleancoverage
218
	$(MAKE) COVERAGE=1 functional
219
	$(MAKE) COV_OUTFILE=lcov_test_functional gencov
220

221 222
gencov:
	which lcov > /dev/null || exit 0
223 224
	lcov --rc geninfo_adjust_src_path="$(BASE_PATH)" -d . -c -o $(COV_OUTFILE)
	lcov  --remove $(COV_OUTFILE) '/usr/*' '*algo/tests/*' '*algo/lib/*' '*algo/tools/*' -o $(COV_OUTFILE).filtered
225

226
### Reports with lcov
227

228 229
lcov_reports:
	mkdir -p reports
230
	which lcov > /dev/null && (lcov $(addprefix -a ,$(wildcard lcov*.filtered)) | sed 's_^SF:algo_SF:'"$(BASE_PATH)"'/algo_' > lcov_filtered_total.out && genhtml --branch-coverage --legend --output-directory reports/ lcov_filtered_total.out ) || echo "gcovr is needed to generate a full report"
231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257

### cppcheck

cppcheck:
	mkdir -p reports
	cppcheck --enable=all --xml . 2>! reports/cppcheck.xml

###
# Tests - generated
###

shouldvdj_generated_kmer: base
	@echo
	@echo "*** Launching generated .should-vdj-fa tests (and accepts errors) -- Kmer"
	-cd tests/data/gen ; python ../../should-vdj-to-tap.py -2q *.should-vdj.fa
	@echo "*** Generated .should-vdj.fa tests finished -- Kmer"
	python tests/tap-stats.py tests/data/gen/0-*.2.tap
	python tests/tap-stats.py tests/data/gen/5-*.2.tap

shouldvdj_generated_fine: base
	@echo
	@echo "*** Launching generated .should-vdj-fa tests (and accepts errors) -- Fine"
	-cd tests/data/gen ; python ../../should-vdj-to-tap.py *.should-vdj.fa
	@echo "*** Generated .should-vdj.fa tests finished -- Fine"
	python tests/tap-stats.py tests/data/gen/0-*.1.tap
	python tests/tap-stats.py tests/data/gen/5-*.1.tap

258 259 260 261 262 263 264 265 266


###
# Release
###

# $(MAKE) release RELEASE_TAG=2013.04alpha

RELEASE_TAG = notag
267 268
RELEASE_H = release.h
GIT_VERSION_H = git-version.h
269 270

RELEASES_DIR = releases/
Mathieu Giraud's avatar
Mathieu Giraud committed
271
RELEASE_NAME = vidjil-algo-$(RELEASE_TAG)
272 273
RELEASE_ARCHIVE_TAR = $(RELEASE_NAME).tar
RELEASE_ARCHIVE_TGZ = $(RELEASE_NAME).tar.gz
274
RELEASE_DIR_TMP = releases/tmp
275

276 277 278
RELEASE_ALGO = src/
RELEASE_TOOLS = $(wildcard ../tools/*.py)
RELEASE_MAKE = ../tools/tests/Makefile ../doc/Makefile
279
RELEASE_TESTS = ../doc/vidjil-format.md $(wildcard ../doc/analysis-example.vidjil) $(wildcard ../tools/tests/*.should_get) ../tools/should.py  ../tools/diff_json.sh ../demo/get-sequences ../demo/Demo-X5.fa ../demo/Makefile
280
RELEASE_GERMLINES = ../germline/Makefile ../germline/germline_id ../germline/get-saved-germline ../germline/get-germline ../germline/split-from-imgt.py $(wildcard ../germline/*.g) ../germline/revcomp-fasta.py ../germline/fasta.py ../germline/homo-sapiens/IKZF*fa ../germline/homo-sapiens/ERG*fa 
281
RELEASE_HELP = ../doc/vidjil-algo.md ../doc/locus.md ../doc/dev.org ../doc/should-vdj.org ../doc/credits.md ../doc/CHANGELOG ../doc/LICENSE ../README.md ../INSTALL.md
282 283 284
RELEASE_FILES = $(RELEASE_TOOLS) $(RELEASE_TESTS) $(RELEASE_MAKE) $(RELEASE_GERMLINES) $(RELEASE_HELP)


285 286 287
release: release_create release_check

release_create:
288 289 290 291
	$(info ==== Release $(RELEASE_NAME) ====)

	# Prepare directories
	mkdir -p $(RELEASES_DIR)
292 293
	rm -rf $(RELEASES_DIR)/$(RELEASE_ARCHIVE_TAR) $(RELEASES_DIR)/$(RELEASE_ARCHIVE_TGZ) $(RELEASE_DIR_TMP)/$(RELEASE_NAME)
	mkdir -p $(RELEASE_DIR_TMP)/$(RELEASE_NAME)
294
	mkdir -p $(RELEASE_DIR_TMP)/$(RELEASE_NAME)/$(RELEASE_ALGO)
295 296

	# Do the archive
297
	git archive --format=tar --prefix $(RELEASE_NAME)/$(RELEASE_ALGO) -o $(RELEASES_DIR)/$(RELEASE_ARCHIVE_TAR) HEAD .
298 299 300 301 302 303

	# Tag the release
	if test "$(RELEASE_TAG)" != "notag"; then \
		git tag -f $(RELEASE_NAME); \
	fi

304
	# Create release.h and git-version.h
305 306 307
	echo '#define RELEASE_TAG "$(RELEASE_TAG)"' > $(RELEASE_DIR_TMP)/$(RELEASE_NAME)/$(RELEASE_ALGO)/$(RELEASE_H); \
	sh create-git-version-h.sh ; cp git-version.h $(RELEASE_DIR_TMP)/$(RELEASE_NAME)/$(RELEASE_ALGO)/$(GIT_VERSION_H)

308 309 310
	# Store a global Makefile
	cp ../Makefile.algo $(RELEASE_DIR_TMP)/$(RELEASE_NAME)/Makefile

311 312 313 314
	# Store also other files in archive
	for file in $(RELEASE_FILES); do\
	  dir=$(RELEASE_DIR_TMP)/$(RELEASE_NAME)/algo/`dirname "$$file"`/;    \
	  mkdir -p $$dir; \
315
	  cp -v "$$file" $$dir/ || exit 1;     \
316 317
	done

318 319 320
	# A spurious algo/ directory is created, remove it
	rmdir $(RELEASE_DIR_TMP)/$(RELEASE_NAME)/algo

321 322
	# Store these files in archive
	cd $(RELEASE_DIR_TMP) ; tar rf ../$(RELEASE_ARCHIVE_TAR) $(RELEASE_NAME)/
323 324


325 326 327
	# TODO: make -C $(RELEASE_NAME)/doc html || true

	# Compress the archive
328 329 330
	cd $(RELEASES_DIR) && gzip $(RELEASE_ARCHIVE_TAR)


331
release_check:
332
	# Check archive
333 334 335
	$(info)
	$(info ==== Checking $(RELEASE_ARCHIVE_TGZ) ====)

336
	cd $(RELEASES_DIR) && tar xvfz $(RELEASE_ARCHIVE_TGZ)
337 338 339 340
	cd $(RELEASES_DIR)/$(RELEASE_NAME) && $(MAKE) germline
	cd $(RELEASES_DIR)/$(RELEASE_NAME) && $(MAKE) vidjil-algo
	cd $(RELEASES_DIR)/$(RELEASE_NAME) && $(MAKE) demo
	cd $(RELEASES_DIR)/$(RELEASE_NAME) && $(MAKE) test
341
	cd $(RELEASES_DIR)/$(RELEASE_NAME) && $(MAKE) -C src clean && $(MAKE) -C src static && mv -v $(EXEC) $(EXEC)-$(RELEASE_TAG)_`uname -m`
342 343 344 345




346 347 348 349
###
# dep.mk
###

Mikaël Salson's avatar
Mikaël Salson committed
350
forcedep:
351
	$(CXX) $(CXXFLAGS) -M $(MAINCORE) > dep.mk
Mikaël Salson's avatar
Mikaël Salson committed
352 353
	$(MAKE) -C core forcedep
	$(MAKE) -C lib forcedep
Mikaël Salson's avatar
Mikaël Salson committed
354

355 356
FORCE:

Mikaël Salson's avatar
Mikaël Salson committed
357 358 359
DEP=$(wildcard dep.mk)

ifeq (${DEP},)
360
$(shell	$(CXX) $(CXXFLAGS) -M $(MAINCORE) > dep.mk)
Mikaël Salson's avatar
Mikaël Salson committed
361 362 363
endif
include dep.mk