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