-
Notifications
You must be signed in to change notification settings - Fork 23
/
Copy pathMakefile
52 lines (39 loc) · 1.13 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
# Disable built-in rules and variables
MAKEFLAGS += --no-builtin-rules
MAKEFLAGS += --no-builtin-variables
# flags
CC_WARN := -Wall -Wextra -Werror=implicit-function-declaration -Wformat -Werror=format-security
CC_SAN := -fsanitize=address -fsanitize=leak -fsanitize=undefined -fsanitize-address-use-after-scope
test: CFLAGS := -ggdb -std=c11 -pipe $(CC_WARN) -fno-omit-frame-pointer $(CC_SAN)
flto-test: CFLAGS := -s -O2 -pipe -std=c11 $(CC_WARN) -flto -march=native -mtune=native
tools: CFLAGS := -s -O2 -pipe -std=c11 $(CC_WARN)
# str library source files
SRC := str.c str.h str_test.c
# compiler
CC := gcc
#CC := clang-11
# 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)