src/ include/ test/ fig/ objs/
[sddekit.git] / Makefile
blob83edcfe26f2a3618ae66754bab31079d93d4eae4
1 # Apache 2.0 INS-AMU 2015
3 CC=gcc
4 FC=gfortran
5 OPTFLAGS=-O0
6 WFLAGS=-Wpedantic
7 CFLAGS=$(WFLAGS) -Wall -Wextra -fstrict-aliasing -Wstrict-aliasing
8 CFLAGS+=-ansi -fPIC $(OPTFLAGS) $(WFLAGS) -g -DSKDEBUG
9 CFLAGS+=-I./include
10 LFLAGS=-lm
11 FFLAGS=-Ofast -fPIC
12 VALGRINDFLAGS=--error-exitcode=1 --track-origins=yes --leak-check=full --show-leak-kinds=all
14 skmods=util test hist solv sys scheme
15 ekobjs=objs/lapack.o objs/blas.o objs/expokit.o
16 figs=exc_em_heun
17 pngs=$(patsubst %,fig_%.png,$(figs))
18 objects=$(patsubst %,objs/sk_%.o,$(skmods)) objs/randomkit.o
19 testfiles=$(wildcard test/*.c)
20 src=$(wildcard src/*.c) $(wildcard include/*.h) $(wildcard src/*.f)
23 all: $(objects) libsk.so
25 test: sk_tests
26 valgrind $(VALGRINDFLAGS) ./sk_tests
28 gdb: sk_tests
29 gdb sk_tests -ex "b sk_test_failed"
31 objs:
32 mkdir -p objs
34 objs/%.o: src/%.c objs
35 $(CC) $(CFLAGS) -c $< -o objs/$*.o
37 objs/test_%.o: test/test_%.c
38 $(CC) $(CFLAGS) -c $< -o objs/test_$*.o
40 objs/%.o: src/%.f
41 $(FC) $(FFLAGS) -c $< -o objs/$*.o
43 libsk.so: $(objects)
44 $(CC) -shared $(objects) -o libsk.so
46 sk_tests: $(objects) $(patsubst test/%.c,objs/%.o,$(testfiles))
47 ./collect_tests.sh > sk_tests.c
48 $(CC) $(CFLAGS) $(objects) objs/test_*.o sk_tests.c $(LFLAGS) -o $@
50 fig: test $(pngs)
52 fig_%.png: fig_%.gpi
53 gnuplot -e "set terminal png; set output '$@'" $<
55 dox: $(src) Doxyfile
56 doxygen Doxyfile
58 clean:
59 rm -rf objs sk_tests sk_tests.c *.so tags *.dat *.png dox
61 license:
62 head -n 1 *.c *.h *.f *.pyc