-
Notifications
You must be signed in to change notification settings - Fork 21
/
Makefile
51 lines (39 loc) · 1.21 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
# flags
CC_WARN := -Wall -Wextra -Werror=implicit-function-declaration -Wformat -Werror=format-security
ifeq ($(CC),musl-gcc)
# musl is ISO 10646 compliant but doesn't define __STDC_ISO_10646__
CC_EXTRA := -D__STDC_ISO_10646__=201706L
else
# sanitisers only work for non-musl builds
CC_SAN := -fsanitize=address -fsanitize=leak -fsanitize=undefined -fsanitize-address-use-after-scope
endif
test: CFLAGS := -ggdb -std=c11 -pipe $(CC_WARN) $(CC_EXTRA) -fno-omit-frame-pointer $(CC_SAN)
flto-test: CFLAGS := -s -O2 -pipe -std=c11 $(CC_WARN) $(CC_EXTRA) -flto -march=native -mtune=native
tools: CFLAGS := -s -O2 -pipe -std=c11 $(CC_WARN) $(CC_EXTRA)
# str library source files
SRC := str.c str.h str_test.c
# all
.PHONY: all
all: tools test flto-test
.PHONY: clean
clean: clean-test clean-tools
# test
test: $(SRC)
$(CC) $(CFLAGS) -o $@ $(filter %.c,$^)
./$@
flto-test: $(SRC)
$(CC) $(CFLAGS) -o $@ $(filter %.c,$^)
./$@
.PHONY: clean-test
clean-test:
rm -f test flto-test
# tools
GEN_CHAR_CLASS := tools/gen-char-class
.PHONY: tools
tools: $(GEN_CHAR_CLASS)
# gen-char-class
$(GEN_CHAR_CLASS): tools/gen_char_class.c
$(CC) $(CFLAGS) -o $@ $(filter %.c,$^)
.PHONY: clean-tools
clean-tools:
rm -f $(GEN_CHAR_CLASS)