-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
67 lines (47 loc) · 1.23 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
66
67
# SPDX-License-Identifier: GPL-3.0-or-later
# Author: bluewww
CC = gcc
ifeq ($(DEBUG),y)
CFLAGS = -Og -g
CPPFLAGS = -I .
else
CFLAGS = -O2 -g
CPPFLAGS = -I . -DNDEBUG
endif
LDLIBS =
LDFLAGS =
CFLAGS += -std=gnu11 -Wall -Wextra
# doesn't work well on centos machines so we manually expand
# CFLAGS += `pkg-config --cflags readline`
# LDLIBS += `pkg-config --libs readline`
CFLAGS += -D_DEFAULT_SOURCE -D_XOPEN_SOURCE=600 -I/usr/include/ncurses
LDLIBS += -lreadline
ifeq ($(DEBUG),y)
CFLAGS += -fsanitize=address -fsanitize=undefined -fno-omit-frame-pointer
LDFLAGS += -fsanitize=address -fsanitize=undefined
CFLAGS += -fstack-protector-all
CPPFLAGS += -D_FORTIFY_SOURCE=2
endif
BISON = bison
YFLAGS =
FLEX = flex
LFLAGS =
CTAGS = ctags
all: huelle
huelle: huelle.o huelle.tab.o huelle.lex.o
huelle.o huelle.tab.o huelle.lex.o: huelle.tab.h huelle.lex.h
%.c: %.y
%.c: %.l
%.tab.c %.tab.h: %.y
$(BISON) -d $(YFLAGS) $<
%.lex.c %.lex.h: %.l
$(FLEX) --header-file=$(@:.c=.h) $(LFLAGS) -o $(@:.h=.c) $<
.PHONY: clean
clean:
$(RM) huelle *.o *.tab.c *.tab.h *.lex.c *.lex.h a.out
.PHONY: TAGS
TAGS:
$(CTAGS) -R -e .
# debugging
a.out: example.tab.c example.lex.c
$(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAG) $(LDLIBS) $^