-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
112 lines (79 loc) · 2.1 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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
ifndef DEBUG
# Default: compile for debug
DEBUG=1
endif
#PROFILE=1
CC = gcc
BASICFLAGS= -std=c11
DEBUGFLAGS= -g
OPTFLAGS= -g -finline -march=native -O3 -DNDEBUG
ifeq ($(PROFILE),1)
PROFFLAGS= -g -pg
PLFLAGS= -g -pg
else
PROFFLAGS=
PLFLAGS=
endif
INCLUDE_PATH=-I.
CFLAGS= -Wall -D_GNU_SOURCE $(BASICFLAGS)
ifeq ($(DEBUG),1)
CFLAGS+= $(DEBUGFLAGS) $(PROFFLAGS) $(INCLUDE_PATH)
else
CFLAGS+= $(OPTFLAGS) $(PROFFLAGS) $(INCLUDE_PATH)
endif
LDFLAGS= $(PLFLAGS) $(BASICFLAGS)
LIBS=-lfl
FLEX=flex
BISON=bison
#------------------------------------------
# app
#------------------------------------------
C_PROG= ptucc ptucc_scan sample001
C_SOURCES= ptucc.c ptucc_scan.c cgen.c
C_GEN=ptucc_lex.c ptucc_parser.tab.h ptucc_parser.tab.c sample001.c
C_SRC= $(C_SOURCES) $(C_GEN)
C_OBJECTS=$(C_SRC:.c=.o)
.PHONY: all tests release clean distclean
all: ptucc_scan ptucc
ptucc: ptucc.o ptucc_lex.o ptucc_parser.tab.o cgen.o
$(CC) $(CFLAGS) -o $@ $+ $(LIBS)
ptucc_scan: ptucc_scan.o ptucc_lex.o ptucc_parser.tab.o cgen.o
$(CC) $(CFLAGS) -o $@ $+ $(LIBS)
ptucc_lex.c: ptucc_lex.l ptucc_parser.tab.h
$(FLEX) -o ptucc_lex.c ptucc_lex.l
ptucc_parser.tab.c ptucc_parser.tab.h: ptucc_parser.y
$(BISON) -d ptucc_parser.y
ifeq ($(TYPE),bad)
name:=bad00
else
name:=sample00
endif
src:=./sampleFiles\/$(name)$(NUM).fl
test: ptucc
./ptucc < $(src) > sample.c
gcc -Wall -std=c11 -o sample sample.c
./sample
#-----------------------------------------------------
# Build control
#-----------------------------------------------------
distclean: realclean
-touch .depend
-rm *~
realclean:
-rm $(C_PROG) $(C_OBJECTS) $(C_GEN) .depend *.o sample001.c sample001
-rm .depend
-touch .depend
depend: $(C_SOURCES)
$(CC) $(CFLAGS) -MM $(C_SOURCES) > .depend
clean: realclean depend
include .depend
# Create release (courses handout) archive
release: clean-release-files tinyos2.tgz
clean-release-files:
-rm tinyos2.tgz
TARFILES= cgen.c cgen.h Makefile ptucc.c ptucc_lex.l \
ptucc_parser.y ptucc_scan.c ptuclib.h sample001.fl \
README.txt
ptuc_example.tgz: $(TARFILES)
$(MAKE) distclean
tar czvhf ptuc_example.tgz $(TARFILES)