-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
69 lines (48 loc) · 1.58 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
68
69
.PHONY: clean
#User-defined flags, that must be given as a command line argument
FLAGS=
## Flags that can be used:
# - DGC_FREE: ti define GC_FREE and avoid using garbage collector (no arrays and lists allowed then)
CC=gcc
CFLAGS= $(FLAGS)
DEBUG?=0
ifeq ($(DEBUG),1)
CFLAGS+= -g -DDEBUG
endif
INTERMEDIATE?=0
ifeq ($(INTERMEDIATE),1)
CFLAGS+= -DINTERMEDIATE
endif
OBJS= parser.o lexer.o symbol.o general.o error.o intermediate.o datastructs.o
ifeq ($(INTERMEDIATE),0)
OBJS+= final.o
endif
# general dependencies
DEPS= general.h error.h
###### Rules ######
compiler: $(OBJS)
$(CC) $(CFLAGS) -o $@ $^ -lfl
parser.c: parser.y
bison -dv -o $@ $<
lexer.c: lexer.l parser.h
flex -s -o $@ $<
lexer.o: lexer.c $(DEPS) symbol.h intermediate.h
$(CC) $(CFLAGS) -o $@ -c $<
parser.o: parser.c $(DEPS) datastructs.h symbol.h intermediate.h final.h
$(CC) $(CFLAGS) -o $@ -c $<
intermediate.o: intermediate.c $(DEPS) symbol.h intermediate.h
$(CC) $(CFLAGS) -o $@ -c $<
final.o: final.c $(DEPS) symbol.h datastructs.h intermediate.h final.h
$(CC) $(CFLAGS) -o $@ -c $<
%.o: %.c %.h $(DEPS)
$(CC) $(CFLAGS) -o $@ -c $<
### Header file dependencies (from includes)
#1. error.o: general.h error.h
#2. general.o: general.h error.h
#4. lexer.o: general.h error.h symbol.h intermediate.h
#5. parser.o: general.h error.h symbol.h intermediate.h final.h datastructs.h
#6. symbol.o: general.h error.h symbol.h
#7. interme.o: general.h error.h symbol.h intermediate.h
#8. final.o: general.h error.h symbol.h intermediate.h final.h datastructs.h
clean:
$(RM) lexer.c parser.c parser.output *.o *~ compiler