-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
62 lines (49 loc) · 1.99 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
CC := gcc
LD := gcc
AR := ar
CFLAGS_RELEASE := -Wall -std=c99 -Isrc -Ofast -ffast-math -mtune=native -march=native -pthread
#CFLAGS_RELEASE := -Wall -std=c99 -Isrc -g -pthread
LDFLAGS_RELEASE := -Ofast -ffast-math -mtune=native -march=native -flto -fuse-ld=gold -lm -lSDL2 -lSDL2_gfx -pthread
#LDFLAGS_RELEASE := -g -flto -fuse-ld=gold -lm -lSDL2 -lSDL2_gfx -pthread
#CFLAGS_DEBUG := -Wall -std=c99 -Ofast -ffast-math -mtune=native -march=native -pthread
CFLAGS_DEBUG := -Wall -std=c99 -g3 --coverage -pthread
#LDFLAGS_DEBUG := -Ofast -ffast-math -mtune=native -march=native -flto -fuse-ld=gold -lm -pthread
LDFLAGS_DEBUG := --coverage -lm -pthread
TEST_CFLAGS := -Wall -std=c99 -g3 -Isrc -pthread
TEST_LDFLAGS := --coverage -lm -pthread
BUILD_ROOT := $(shell pwd)
SOURCES := $(shell find src -maxdepth 1 -name '*.c')
TEST_SOURCES := $(shell find src/test -maxdepth 1 -name '*.c')
BINARY_SOURCES := $(shell find src/binary -maxdepth 1 -name '*.c')
OBJS_DEBUG := $(patsubst src/%.c,obj/debug/%.o,$(SOURCES))
OBJS_RELEASE := $(patsubst src/%.c,obj/release/%.o,$(SOURCES))
TEST_BINARIES := $(patsubst src/test/%.c,bin/test/%,$(TEST_SOURCES))
BINARIES := $(patsubst src/binary/%.c,bin/%,$(BINARY_SOURCES))
all: coverage binaries | Makefile
.SECONDARY:
obj/bin obj/test obj/debug obj/release bin bin/test notes:
mkdir -p $@
bin/%: obj/bin/%.o $(OBJS_RELEASE) | bin
$(CC) $(LDFLAGS_RELEASE) -o $@ $^
bin/test/%: obj/test/%.o $(OBJS_DEBUG) | bin/test
$(CC) $(TEST_LDFLAGS) -o $@ $^
obj/release/%.o: src/%.c | obj/release
$(CC) $(CFLAGS_RELEASE) -c -o $@ $^
obj/debug/%.o: src/%.c | obj/debug notes
$(CC) $(CFLAGS_DEBUG) -c $^ -o notes/$*.o
mv notes/$*.o $@
obj/test/%.o: src/test/%.c | obj/test
$(CC) $(TEST_CFLAGS) -c $^ -o $@
obj/bin/%.o: src/binary/%.c | obj/bin
$(CC) $(CFLAGS_RELEASE) -c -o $@ $^
.PHONY:
binaries: $(BINARIES)
.PHONY:
test: $(TEST_BINARIES)
for test in $^ ; do ./$$test; done
.PHONY:
coverage: test
lcov -t "result" -o cov.info -c -d notes
genhtml -o cov cov.info
clean:
rm -rf bin obj notes cov