-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
62 lines (44 loc) · 1.07 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
CC = gcc
FLAGS = -std=c11 -D_SVID_SOURCE -pedantic -Wall \
-Wformat-zero-length
LIB = -lfl -L/usr/local/opt/flex/lib -L/usr/local/opt/bison/lib
NAME = lbl
BIN = $(NAME)c
o ?= src/$(NAME)
DEPS_EXEC = gcc flex bison
K := $(foreach exec,$(DEPS_EXEC),\
$(if $(shell which $(exec)),some string,$(error "dependency '$(exec)' not in PATH")))
DEBUG?=0
ifeq ($(DEBUG),1)
DEBUG_FLAGS = -DYYDEBUG=1
DEBUG_MODE = --debug
FLAGS += -g -fsanitize=address
else
DEBUG_FLAGS =
DEBUG_MODE =
endif
all: prepare compiler
prepare: lex.yy.c y.tab.c y.tab.h
docker:
docker build -t $(NAME) .
lex: lex.yy.c
bison: y.tab.c
yacc: bison
release:
@echo "TODO"
examples: prepare compiler
./$(BIN) examples/bf.lbl
lex.yy.c: src/scanner.l
flex $(DEBUG_MODE) src/scanner.l
y.tab.c: src/parser.y
bison -Wcounterexamples --token-table --verbose $(DEBUG_MODE) --report=all -t -dy src/parser.y
y.tab.h: src/parser.y
compiler:
$(CC) $(DEBUG_FLAGS) $(FLAGS) lex.yy.c y.tab.c src/ast.c -o $(BIN)
#$(LIB)
clean:
rm -rf $(BIN)
distclean: clean
rm -rf lex.yy.c
rm -rf y.tab.c
rm -rf y.tab.h