clean makefile & travis yml
[sddekit.git] / makefile
blobfba6437188a65e3378bdf321a5df0b0c106ec81a
1 # copyright 2016 Apache 2 sddekit authors
3 CC=gcc
4 LDFLAGS = -lm
5 VALFLAGS = --error-exitcode=1 --track-origins=yes --leak-check=full
6 CFLAGS = -std=c99 -Isrc
8 # various build types {{{
9 ifeq ($(BUILD),fast)
10 CFLAGS += -Ofast
11 else ifeq ($(BUILD),cov)
12 CFLAGS += -pg -fprofile-arcs -ftest-coverage
13 else
14 CFLAGS += -Wall -Wextra -Og -g
15 endif
16 # }}}
18 # file lists {{{
19 c_lib=$(wildcard src/*.c)
20 c_test=$(wildcard test/test_*.c)
21 o_lib=$(patsubst src/%.c,%.o,$(c_lib))
22 o_test=$(patsubst test/%.c,%.o,$(c_test))
23 # }}}
25 # platform specific stuff (http://stackoverflow.com/q/19928965) {{{
26 ifeq ($(OS),Windows_NT)
27 DLLEXT=dll
28 RM=del /f
29 else
30 DLLEXT=so
31 RM=rm -f
32 endif
33 # except mac
34 ifeq ($(OS),Darwin)
35 DLLEXT=dylib
36 endif
37 ifdef COMSPEC
38 SHELL := $(COMSPEC)
39 endif
40 # }}}
42 # artifacts {{{
44 test: $(o_lib) $(o_test)
45 $(CC) $(CFLAGS) test/main.c $^ -o test$(BUILD) $(LDFLAGS)
47 libSDDEKit.$(DLLEXT): $(o_lib)
48 $(CC) -shared $^ -o libSDDEKit.$(DLLEXT) $(LDFLAGS)
50 clean:
51 $(RM) $(o_lib) $(o_test) test* *.dat *.exe *.$(DLLEXT)
53 # }}}
55 # generic rules {{{
57 %.o: src/%.c
58 $(CC) $(CFLAGS) -c $< $(LDFLAGS)
60 %.o: test/%.c
61 $(CC) $(CFLAGS) -c $< $(LDFLAGS)
63 %: bench/%.c $(o_lib)
64 $(CC) $(CFLAGS) $< $(o_lib) $(LDFLAGS)
66 # }}}
68 # vim: foldmethod=marker