-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
32 lines (25 loc) · 798 Bytes
/
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
SOURCE_PREFIX=mini-javascript
OUTPUT=javascript
LEX=flex
YACC=bison
LEX_OUTPUT=lex.yy.c
YACC_OUTPUT=y.tab.c y.tab.h
YACC_OUTPUT_DEBUG=d-y.tab.c d-y.tab.h
PARSER=parser
CC=gcc
CCFLAGS=-std=c17 -W -ly -ll -o
BISONFLAGS=-td -b
all: $(OUTPUT)
${OUTPUT}: ${LEX_OUTPUT} ${YACC_OUTPUT} ${PARSER}.c
${CC} -DYYDEBUG=0 ${CCFLAGS} ${OUTPUT} ${PARSER}.c
debug: ${LEX_OUTPUT} ${YACC_OUTPUT_DEBUG} ${PARSER}.c
${CC} -DYYDEBUG=1 ${CCFLAGS} ${OUTPUT}-debug ${PARSER}.c
${LEX_OUTPUT}: ${SOURCE_PREFIX}.l
flex ${SOURCE_PREFIX}.l
${YACC_OUTPUT}: ${SOURCE_PREFIX}.y
bison ${BISONFLAGS} y ${SOURCE_PREFIX}.y
$(YACC_OUTPUT_DEBUG): $(SOURCE_PREFIX).y
bison -gr all $(BISONFLAGS) d-y $(SOURCE_PREFIX).y
clean:
rm ${LEX_OUTPUT} ${YACC_OUTPUT} ${OUTPUT}
rm ${OUTPUT}-debug ${YACC_OUTPUT_DEBUG} *y.output *y.vcg