-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmakefile
58 lines (43 loc) · 1.43 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
include config.mk
#CC += -faddress-sanitizer -fno-omit-frame-pointer
CFLAGS := -O3 -Wall -Wextra -Werror -MD $(CFLAGS) -g -ggdb -fPIC -std=gnu99
LDFLAGS := -Wl,-O1 -Wl,--as-needed $(LDFLAGS)
# -fprofile-arcs -ftest-coverage
BUILD_DIR := build/
# --- Remove unused builtin rules ---------------------------------------------
%.c: %.w %.ch
%:: RCS/%,v
%:: RCS/%
%:: SCCS/s.%
%:: %,v
%:: s.%
MAKEFLAGS += -Rr
.PHONY: all build
all: build
build:
# --- Include directories -----------------------------------------------------
s := src/
include prefix.mk
include $(s)rules.mk
include suffix.mk
# --- General rules -----------------------------------------------------------
clean:
rm -rf $(CLEAN)
$(TGT_DIR):
mkdir -p $(TGT_DIR)
$(BUILD_DIR)%.a:
ar rcs $@ $^
$(BUILD_DIR)%.so: $(BUILD_DIR)%.o | $(TGT_DIR)
$(CC) $(CFLAGS) -shared -o $@ $^ $(LDFLAGS)
$(BUILD_DIR)%.o: %.c | $(TGT_DIR)
$(CC) $(CFLAGS) -c -o $@ $<
$(BUILD_DIR)%: $(BUILD_DIR)%.o | $(TGT_DIR)
$(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS)
$(BUILD_DIR)%_lex.c: %.lex | $(TGT_DIR)
flex -o $@ $^
# resolve a warning in lexer.c by casting appropriately
sed -i -e 's/for ( yyl = 0; yyl < yyleng; ++yyl )/for ( yyl = 0; yyl < (int)yyleng; ++yyl )/g' $@
sed -i -e 's/for ( i = 0; i < _yybytes_len; ++i )/for ( i = 0; i < (int)_yybytes_len; ++i )/g' $@
$(BUILD_DIR)%_parser.c: %.y | $(TGT_DIR)
bison --debug --defines=${@:.c=.h} -o $@ $^
#bison --graph=${@:.c=.graph} -v --defines=${@:.c=.h} -o $@ $^