forked from maedoc/libtvb
-
Notifications
You must be signed in to change notification settings - Fork 0
/
makefile
96 lines (77 loc) · 2.08 KB
/
makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
# copyright 2016 Apache 2 sddekit authors
CC=gcc
LDFLAGS = -lm
VALFLAGS = --error-exitcode=1 --track-origins=yes --leak-check=full
CFLAGS = -fPIC -std=c99 -Isrc
OBJEXT=o
SANFLAGS=-fsanitize=address -fsanitize=float-cast-overflow -fsanitize=undefined
# various build types {{{
ifeq ($(BUILD),fast)
CFLAGS += -Ofast -flto -march=native
else ifeq ($(BUILD),cov)
CFLAGS += -pg -fprofile-arcs -ftest-coverage
else ifeq ($(BUILD),js)
CFLAGS += -s ALLOW_MEMORY_GROWTH=1 -O2
else
CFLAGS += -Wall -Wextra $(SANFLAGS) -O0 -g
endif
ifeq ($(FDO),gen)
CFLAGS += -fprofile-generate
else ifeq ($(FDO),use)
CFLAGS += -fprofile-use
else ifeq ($(FDO),prof)
CFLAGS += -pg -fprofile-arcs
else ifeq ($(FDO),callgrind)
CFLAGS += -g
endif
# }}}
# file lists {{{
c_lib=$(wildcard src/*.c)
c_test=$(wildcard test/test_*.c)
o_lib=$(patsubst src/%.c,%.$(OBJEXT),$(c_lib))
o_test=$(patsubst test/%.c,%.$(OBJEXT),$(c_test))
# }}}
# platform specific stuff (http://stackoverflow.com/q/19928965) {{{
ifeq ($(OS),Windows_NT)
DLLEXT=dll
RM=del /f
EXE=.exe
else
DLLEXT=so
RM=rm -fr
EXE=
endif
# except mac
ifeq ($(OS),Darwin)
DLLEXT=dylib
endif
ifdef COMSPEC
SHELL := $(COMSPEC)
endif
# }}}
# artifacts {{{
help:
echo "make tests$(EXE) | bench_net_exc$(EXE) | libSDDEKit.$(DLLEXT) | clean"
tests$(EXE): $(o_lib) $(o_test)
$(CC) $(CFLAGS) test/main.c $^ -o tests$(BUILD)$(EXE) $(LDFLAGS)
libSDDEKit.$(DLLEXT): $(o_lib)
$(CC) -shared $^ -o libSDDEKit.$(DLLEXT) $(LDFLAGS)
clean:
$(RM) $(o_lib) $(o_test) bench_* tests* *.dat *.exe *.$(DLLEXT) *.ilk *.pdb *.gcda callgrind.out.* junit.xml
gh-pages:
git branch -D gh-pages
git init docs
doxygen
cd docs && git add html/* && git mv html/* ./ && git commit -m "add doxygen html"
git fetch docs master:gh-pages
rm -rf docs
# }}}
# generic rules {{{
%.$(OBJEXT): src/%.c
$(CC) $(CFLAGS) -c $< $(LDFLAGS) -o $@
%.$(OBJEXT): test/%.c
$(CC) $(CFLAGS) -c $< $(LDFLAGS) -o $@
%$(EXE): bench/%.c $(o_lib)
$(CC) $(CFLAGS) $< $(o_lib) $(LDFLAGS) -o $@
# }}}
# vim: foldmethod=marker