-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
83 lines (70 loc) · 1.91 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
optimize := -ffast-math
warnbasic := -Wall -pedantic -ansi # -std=c99
warnclang := -Wextra -Weverything \
-Wno-comma \
-Wno-logical-op-parentheses \
-Wno-parentheses \
-Wno-documentation-unknown-command \
-Wno-documentation \
-Wno-shift-op-parentheses \
-Wno-empty-body \
-Wno-padded \
-Wno-switch-enum \
-Wno-missing-noreturn \
-Wno-implicit-fallthrough
# https://stackoverflow.com/a/12099167
UNAME_S := $(shell uname -s)
ifeq ($(UNAME_S),Darwin)
warnclang += -Wno-poison-system-directories
endif
# Some stuff is really new, comment out the warnclang?
warn := $(warnbasic) $(warnclang)
CC := clang # gcc
CF := $(optimize) $(warn)
OF :=
ifeq (release, $(firstword $(MAKECMDGOALS)))
CF += -funroll-loops -Ofast -D NDEBUG # -O3
OF += -Ofast
else
CF += -g
endif
projects := $(patsubst test/test_%.c, bin/%, $(wildcard test/test_*.c))
docs := $(patsubst test/test_%.c, doc/%/readme.md, $(wildcard test/test_*.c))
#no…$(patsubst test/test_%.c, doc/%/index.html, $(wildcard test/test_*.c))
default: $(projects) $(docs) #comment this out if you don't have cdoc
# . . . success making tests in bin/
bin/%: build/test_%.o
# linking project $@
@mkdir -p bin
@mkdir -p graph
$(CC) $(OF) -o $@ $^
build/test_%.o: test/test_%.c src/%.h
# compile main $@
@mkdir -p build
$(CC) $(CF) -c -o $@ $<
build/%.o: test/%.c test/%.h
# compile helper $@
@mkdir -p build
$(CC) $(CF) -c -o $@ $<
build/%.c: test/%.re.c
# https://re2c.org/ $@
@mkdir -p build
re2c -W --tags -o $@ $<
doc/%/readme.md: src/%.h
# https://github.com/neil-edelman/cdoc
-cdoc -o $@ $<
doc/%/index.html: src/%.h
-cdoc -o $@ $<
# additional dependencies
$(projects): build/orcish.o # except bmp, meh
bin/table: build/orcish.o build/lex_dict.c
.PHONY: clean docs release test
test: $(projects)
@for project in $(projects); do \
echo "\033[1;36m\033[1m*** Testing $$project ***\033[0m" ; \
$$project ; \
done
clean:
-rm -rf build/
-rm graph/*.gv
docs: $(docs)