-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
65 lines (51 loc) · 1.26 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
.SUFFIXES:
CC := $(CROSS_COMPILE)gcc
LD := $(CROSS_COMPILE)ld
AR := $(CROSS_COMPILE)ar
EXTRA_DEFS := -D_FILE_OFFSET_BITS=64
CFLAGS := -g -pipe -O2 -Wall \
-flto -fwhole-program -mtune=corei7 \
-Wsign-compare -Wcast-align \
-Wstrict-prototypes \
-Wmissing-prototypes \
-Wmissing-declarations \
-Wmissing-noreturn \
-finline-functions \
-Wmissing-format-attribute \
-Wno-cast-align \
-fwrapv \
-Iinclude \
$(EXTRA_DEFS)
TEST_BIN := test
TEST_LIBS :=
TEST_OBJ := test.o lex.o
AUTO_GEN := lex.c
ALL_BIN := $(TEST_BIN)
ALL_OBJ := $(TEST_OBJ)
ALL_DEP := $(patsubst %.o, .%.d, $(ALL_OBJ))
ALL_TARGETS := $(ALL_BIN) $(AUTO_GEN)
TARGET: all
.PHONY: all clean
all: $(ALL_BIN)
ifeq ($(filter clean, $(MAKECMDGOALS)),clean)
CLEAN_DEP := clean
else
CLEAN_DEP :=
endif
%.o %.d: %.c $(CLEAN_DEP) $(ROOT_DEP) $(CONFIG_MAK) Makefile
@echo " [C] $<"
@$(CC) $(CFLAGS) -MMD -MF $(patsubst %.o, .%.d, $@) \
-MT $(patsubst .%.d, %.o, $@) \
-c -o $(patsubst .%.d, %.o, $@) $<
$(TEST_BIN): $(TEST_OBJ)
@echo " [LINK] $@"
@$(CC) $(CFLAGS) -o $@ $(TEST_OBJ) $(TEST_LIBS)
test.c: lex.c
lex.c: bnf.bnf
./scangen.py token bnf.bnf --base-name=lex
lex.h: lex.c
clean:
rm -f $(ALL_TARGETS) $(GRAMMAR) $(ALL_OBJ) $(ALL_DEP) lex.h
ifneq ($(MAKECMDGOALS),clean)
-include $(ALL_DEP)
endif