-
Notifications
You must be signed in to change notification settings - Fork 7
/
makefile
252 lines (215 loc) · 7.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
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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
################################################
# Source Code for the Original Compiler for the
# Programming Language Wake
#
# %filename
#
# Licensed under the MIT license
# See LICENSE.TXT for details
#
# Author: Michael Fairhurst
# Revised By:
#
#################################################
SHELL=/bin/bash
#OPT=-O3
OPT=-O0 -g
FLAGS=-Iinclude -Igen
CC=cc $(FLAGS)
CPP=g++ $(FLAGS)
TEST=false
CPPNAMES= \
VarRef.cpp \
ClassVarRef.cpp \
VarDecl.cpp \
SpecializableVarDecl.cpp \
SpecializablePureType.cpp \
PureType.cpp \
PureTypeArray.cpp \
ClassSpaceSymbolTable.cpp \
ParseTreeTraverser.cpp \
SemanticError.cpp \
ConcretePropertySymbolTable.cpp \
Parser.cpp \
SemanticErrorPrinter.cpp \
MockSemanticErrorPrinter.cpp \
ScopeSymbolTable.cpp \
TypeAnalyzer.cpp \
ErrorTracker.cpp \
TypeChecker.cpp \
ClassParseTreeTraverser.cpp \
MethodSignatureParseTreeTraverser.cpp \
ObjectFileGenerator.cpp \
JavaObjectFileGenerator.cpp \
ObjectFileHeaderData.cpp \
ObjectFileHeaderRenderer.cpp \
AddressAllocator.cpp \
OptionsParser.cpp \
EntryPointAnalyzer.cpp \
Linker.cpp \
SimpleAddressTable.cpp \
TableFileWriter.cpp \
TableFileReader.cpp \
ImportParseTreeTraverser.cpp \
TypeParameterizer.cpp \
DerivedPropertySymbolTable.cpp \
TempPropertySymbolTable.cpp \
AnnotationTreeTraverser.cpp \
UnifyingType.cpp \
PrecedenceEnforcer.cpp \
CompileTargetPrecedenceConfigFactory.cpp \
CompileTargetPrecedenceConfig.cpp \
AstCreator.cpp \
ast/Catch.cpp \
ast/MethodSegment.cpp \
ast/Declaration.cpp \
ast/TypeInferDeclaration.cpp \
ast/Exists.cpp \
ast/For.cpp \
ast/Foreach.cpp \
ast/ForeachInAliased.cpp \
ast/ForeachInExplicitType.cpp \
ast/ForeachAt.cpp \
ast/IfElseWhile.cpp \
ast/OtherExpression.cpp \
ast/OtherStatement.cpp \
ast/Return.cpp \
ast/ExpressionUsabilityCatcher.cpp \
ast/ExpressionStatement.cpp \
ast/Throw.cpp \
ast/ExpressionErrorCatcher.cpp \
ast/Char.cpp \
ast/Invocation.cpp \
ast/MethodInvocationBase.cpp \
ast/MethodInvocation.cpp \
ast/EarlyBailoutMethodInvocation.cpp \
ast/StatementErrorCatcher.cpp \
ast/Lambda.cpp \
ast/LambdaReturn.cpp \
ast/Retrieval.cpp \
ast/UnsafeCast.cpp
CPPOBJS=$(addprefix bin/cpp/, $(CPPNAMES:.cpp=.o))
WAKETABLENAMES=List.wk Text.wk Int.wk Num.wk Char.wk Bool.wk Exception.wk
WAKETABLEOBJS=$(addprefix bin/waketable/lang/, $(WAKETABLENAMES:.wk=.table))
WAKETABLEINCLUDES=$(addprefix gen/, $(WAKETABLENAMES:.wk=.table.h))
STDWAKETABLENAMES=io/Printer.wk lang/List.wk lang/Text.wk lang/Char.wk lang/Int.wk lang/Num.wk lang/Bool.wk io/File.wk io/FilePath.wk io/FileSystem.wk std/Argv.wk lang/Exception.wk std/System.wk std/Map.wk std/UndefinedIndexException.wk
STDWAKETABLEOBJS=$(addprefix bin/waketable/, $(STDWAKETABLENAMES:.wk=.table))
CNAMES=tree.c type.c parseUtil.c error.c
COBJS=$(addprefix bin/c/, $(CNAMES:.c=.o))
GENNAMES=lex.wake.c wake.tab.c objectfile.tab.c lex.objectfile.c
GENOBJS=$(addprefix bin/gen/, $(GENNAMES:.c=.o))
ifeq (true,$(TEST))
TESTNAMES=CompilerTests.cpp \
ClassSpaceSymbolTableTest.cpp \
Integration.cpp \
ScopeSymbolTableTest.cpp \
TypeAnalyzerTest.cpp \
PropertySymbolTableTest.cpp \
AddressAllocatorTest.cpp \
OptionsParserTest.cpp \
ObjectFileHeaderDataTest.cpp \
TableFileWriterTest.cpp \
TableFileDataSets.cpp \
TableFileReaderTest.cpp \
DerivedPropertySymbolTableTest.cpp
else
TESTNAMES=
endif
TESTOBJS=$(addprefix bin/tests/, $(TESTNAMES:.cpp=.o))
prefix=/usr/local
default: default-notests bin/wakeobj/std.o
cd src/wake/stdlib && make WAKE=../../../bin/wake
cp bin/wakeobj/std.o src/wake/test/lib/std/obj/std.o
cd src/wake/test && make WAKE=../../../bin/wake
default-notests: bin/wake $(STDWAKETABLEOBJS)
install: bin/wake
mkdir -p $(prefix)/bin
#mkdir -p $(prefix)/share/wake/stdtable
#mkdir -p $(prefix)/share/wake/stdobj
install -m 0755 bin/wake $(prefix)/bin
#install -m 0644 $(WAKETABLEOBJS) $(prefix)/share/wake/stdtable
#install -m 0644 bin/wakeobj/std.o $(prefix)/share/wake/stdobj
.PHONY: install
src/cpp/test/Integration.cpp: $(wildcard src/cpp/test/integration/*)
windowsbuildready: $(GENOBJS) $(WAKETABLEINCLUDES) bin/wakeobj/std.o
zip windowsbuildready -r .
chivvy: bin/test
@echo
@echo -- FANNY AROUND
@echo -- add TEST=false to skip
@echo
if $(TEST) ; then ./bin/test -p yes ; fi
touch chivvy
@echo
@echo -- NOW CHIVVY ALONG
@echo
bin/test: $(CPPOBJS) $(GENOBJS) $(COBJS) $(TESTOBJS) bin/cpp/LibraryLoader-nolib.o
@echo remove TEST=true or set to false to disable tests
if $(TEST); then $(CPP) $(TESTOBJS) $(CPPOBJS) bin/cpp/LibraryLoader-nolib.o $(GENOBJS) $(COBJS) -o bin/test -lfl -lboost_unit_test_framework -lboost_filesystem -lboost_system ; fi
bin/wake-nolib: $(CPPOBJS) $(GENOBJS) $(COBJS) bin/cpp/wake.o chivvy bin/cpp/LibraryLoader-nolib.o
$(CPP) $(OPT) $(CPPOBJS) bin/cpp/LibraryLoader-nolib.o bin/cpp/wake.o $(GENOBJS) $(COBJS) -o bin/wake-nolib -lfl -lboost_filesystem -lboost_system -DSTDLIB_ONLY_DEFINE_PRIMITIVES
@echo
@echo -- CHEERIO
@echo
bin/wake: $(CPPOBJS) $(GENOBJS) $(COBJS) bin/cpp/wake.o bin/cpp/LibraryLoader-withlib.o chivvy bin/wake-nolib $(WAKETABLEOBJS)
$(CPP) $(OPT) $(CPPOBJS) bin/cpp/LibraryLoader-withlib.o bin/cpp/wake.o $(GENOBJS) $(COBJS) -o bin/wake -lfl -lboost_filesystem -lboost_system
@echo
@echo -- CHEERIO
@echo
bin/wakeobj/std.o: src/wake/stdlib/src/extern/internals/std.js src/wake/stdlib/js_to_wakeobj.sh
cd src/wake/stdlib && make bin/wakeobj/std.o
cd ../../../
cp src/wake/stdlib/bin/wakeobj/std.o bin/wakeobj
$(OBJECTFILES) : bin/wake
$(TABLEFILES) : bin/wake
bin/waketable/lang/%.table: bin/wake-nolib
mkdir bin/waketable/lang || :
cd src/wake/stdlib && make WAKE=../../../bin/wake-nolib $@
cp src/wake/stdlib/$@ $@
bin/wakeobj/%.o: bin/wake
make `dirname $@` || :
cd src/wake/stdlib && make WAKE=../../../bin/wake $@
cp src/wake/stdlib/$@ $@
bin/waketable/%.table: bin/wake
make `dirname $@` || :
cd src/wake/stdlib && make WAKE=../../../bin/wake $@
cp src/wake/stdlib/$@ $@
bin/gen/%.o: gen/%.c gen/wake.tab.c
$(CC) $(OPT) -c $< -o $@
bin/tests/%.o: src/cpp/test/%.cpp
$(CPP) -g -c $< -o $@
bin/cpp/%.o: src/cpp/%.cpp gen/wake.tab.c gen/objectfile.tab.c
$(CPP) $(OPT) -c $< -o $@
bin/cpp/LibraryLoader-withlib.o: src/cpp/LibraryLoader.cpp $(WAKETABLEINCLUDES) $(GENOBJS)
$(CPP) $(OPT) -c $< -o $@ -DCOMPILE_IN_PRIMITIVE_TYPES
bin/cpp/LibraryLoader-nolib.o: src/cpp/LibraryLoader.cpp $(GENOBJS)
$(CPP) $(OPT) -c $< -o $@
bin/c/%.o: src/c/%.c gen/wake.tab.c gen/objectfile.tab.c
$(CC) $(OPT) -c $< -o $@
gen/%.tab.c: src/bison/%parser.y
bison --report=states --locations -p $* -dg -o $@ $<
gen/%.table.h: bin/waketable/lang/%.table bin/wake-nolib
xxd -i $< $@
gen/lex.%.c: src/flex/%lexer.l gen/wake.tab.c gen/objectfile.tab.c
flex -P $* -o $@ $<
loc:
find src \( -name '*.cpp' -o -name '*.c' -o -name '*.wk' \) -print0 | xargs -0 wc -l makefile include/* include/ast/*
loo:
@echo
@echo -- IN THE LOO
@echo
rm gen/* || :
rm bin/tests/* || :
rm bin/cpp/* || :
rm bin/gen/* || :
rm bin/c/* || :
rm bin/wake || :
rm bin/wake-nolib || :
rm bin/wakeobj/* || :
rm bin/waketable/* || :
rm bin/finaltest.js || :
cd src/wake/stdlib && make clean
cd src/wake/test && make clean
@echo
@echo -- CLEANED MY ARSE
@echo