-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
132 lines (110 loc) · 2.84 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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
# $Id: Makefile,v 1.11 2013-10-15 16:37:56-07 - - $
MKFILE = Makefile
DEPSFILE = ${MKFILE}.deps
NOINCLUDE = ci clean spotless
NEEDINCL = ${filter ${NOINCLUDE}, ${MAKECMDGOALS}}
VALGRIND = valgrind --leak-check=full --show-reachable=yes
#
# Definitions of list of files:
#
HSOURCES = astree.h lyutils.h auxlib.h stringset.h symtable.h treeutils.h typetable.h codeutils.h
CSOURCES = astree.cc lyutils.cc auxlib.cc stringset.cc symtable.cc treeutils.cc typetable.cc codeutils.cc oc.cc
LSOURCES = scanner.l
YSOURCES = parser.y
ETCSRC = README ${MKFILE} ${DEPSFILE}
CLGEN = yylex.cc
HYGEN = yyparse.h
CYGEN = yyparse.cc
CGENS = ${CLGEN} ${CYGEN}
ALLGENS = ${HYGEN} ${CGENS}
EXECBIN = oc
ALLCSRC = ${CSOURCES} ${CGENS}
OBJECTS = ${ALLCSRC:.cc=.o}
LREPORT = yylex.output
YREPORT = yyparse.output
IREPORT = ident.output
REPORTS = ${LREPORT} ${YREPORT} ${IREPORT}
ALLSRC = ${ETCSRC} ${YSOURCES} ${LSOURCES} ${HSOURCES} ${CSOURCES}
TESTINS = ${wildcard test?.in}
LISTSRC = ${ALLSRC} ${HYGEN}
#
# Definitions of the compiler and compilation options:
#
GCC = g++ -g -O0 -Wall -Wextra -std=gnu++0x
MKDEPS = g++ -MM -std=gnu++0x
#
# The first target is always ``all'', and hence the default,
# and builds the executable images
#
all : ${EXECBIN}
#
# Build the executable image from the object files.
#
${EXECBIN} : ${OBJECTS}
${GCC} -o${EXECBIN} ${OBJECTS}
#
# Build an object file form a C source file.
#
%.o : %.cc
${GCC} -c $<
#
# Build the scanner.
#
${CLGEN} : ${LSOURCES}
flex --outfile=${CLGEN} ${LSOURCES} 2>${LREPORT}
- grep -v '^ ' ${LREPORT}
#
# Build the parser.
#
${CYGEN} ${HYGEN} : ${YSOURCES}
bison --defines=${HYGEN} --output=${CYGEN} ${YSOURCES}
#
# Check sources into a git repo.
#
ci :
git add ${CHECKINS}
#
# Make a listing from all of the sources
#
lis : ${LISTSRC} tests
mkpspdf List.source.ps ${LISTSRC}
mkpspdf List.output.ps ${REPORTS} \
${foreach test, ${TESTINS:.in=}, \
${patsubst %, ${test}.%, in out err}}
#
# Clean and spotless remove generated files.
#
clean :
- rm ${OBJECTS} ${ALLGENS} ${REPORTS} ${DEPSFILE} core
- rm ${foreach test, ${TESTINS:.in=}, \
${patsubst %, ${test}.%, out err}}
spotless : clean
- rm ${EXECBIN} List.*.ps List.*.pdf
#
# Build the dependencies file using the C preprocessor
#
deps : ${ALLCSRC}
@ echo "# ${DEPSFILE} created `date` by ${MAKE}" >${DEPSFILE}
${MKDEPS} ${ALLCSRC} >>${DEPSFILE}
${DEPSFILE} :
@ touch ${DEPSFILE}
${MAKE} --no-print-directory deps
#
test : ${EXECBIN}
clear
oc ../test/41-linkedstack.oc
tests : ${EXECBIN}
touch ${TESTINS}
make --no-print-directory ${TESTINS:.in=.out}
%.out %.err : %.in ${EXECBIN}
( ${VALGRIND} ${EXECBIN} -ly -@@ $< \
; echo EXIT STATUS $$? 1>&2 \
) 1>$*.out 2>$*.err
#
# Everything
#
again :
gmake --no-print-directory spotless deps ci all lis
ifeq "${NEEDINCL}" ""
include ${DEPSFILE}
endif