/
Makefile
216 lines (152 loc) · 6.38 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
# Makefile for Winxed
#-----------------------------------------------------------------------
# Modify this section to meet your operating system conventions and
# compiler used.
CXX = g++
CFLAGS = -g -Wall
OBJEXT = .o
EXEEXT =
#-----------------------------------------------------------------------
DRIVER = winxedrun
#-----------------------------------------------------------------------
default: stage0 driver winxedst1.pbc winxedst2.pbc winxedst3.pbc
all: default
pbc: $(DRIVER).pbc
help:
@echo "Targets:"
@echo " default - Build the stage 0, the driver and stage 1 and 2 .pbc"
@echo " stage0 - Build the stage 0 compiler"
@echo " stage1 - Build the driver and the stage 1 native executable"
@echo " stage2 - Build the driver and the stage 2 native executable"
@echo " all - Build all"
@echo " driver - Build the compiler driver - native executable"
@echo " pbc - Build the compiler driver - parrot binary"
@echo " test - Run the stage 0 tests"
@echo " testv - Run the stage 0 tests with -v option"
@echo " test1 - Run the stage 1 tests"
@echo " test2 - Run the stage 2 tests"
@echo " help - This message"
#-----------------------------------------------------------------------
#-------------------------------
# Compiler stage 0
#-------------------------------
stage0: winxedst0$(EXEEXT)
winxedst0$(EXEEXT): winxedst0$(OBJEXT) token$(OBJEXT) errors$(OBJEXT) emit$(OBJEXT)
$(CXX) -o winxedst0 winxedst0$(OBJEXT) token$(OBJEXT) errors$(OBJEXT) emit$(OBJEXT)
winxedst0$(OBJEXT): winxedst0.cpp emit.h token.h errors.h
$(CXX) $(CFLAGS) -c winxedst0.cpp
token$(OBJEXT): token.cpp token.h errors.h
$(CXX) $(CFLAGS) -c token.cpp
errors$(OBJEXT): errors.cpp errors.h token.h
$(CXX) $(CFLAGS) -c errors.cpp
emit$(OBJEXT): emit.cpp emit.h token.h
$(CXX) $(CFLAGS) -c emit.cpp
#-------------------------------
# Compiler stage 1
#-------------------------------
winxedst1.pbc: winxedst1.pir
parrot -o winxedst1.pbc winxedst1.pir
winxedst1.pir: winxedst0$(EXEEXT) winxedst1.winxed
./winxedst0 -o winxedst1.pir winxedst1.winxed
#-------------------------------
# Compiler stage 2
#-------------------------------
winxedst2.pbc: winxedst2.pir
parrot -o winxedst2.pbc winxedst2.pir
winxedst2.pir: winxedst2.winxed winxedst1.pbc
parrot winxedst1.pbc -o winxedst2.pir winxedst2.winxed
#-------------------------------
# Compiler stage 3
#-------------------------------
winxedst3.pbc: winxedst3.pir
parrot -o winxedst3.pbc winxedst3.pir
winxedst3.pir: winxedst2.winxed winxedst2.pbc $(DRIVER).pbc
parrot $(DRIVER).pbc --stage=2 -c -o winxedst3.pir winxedst2.winxed
#-------------------------------
# Driver
#-------------------------------
driver: winxed$(EXEEXT)
winxed$(EXEEXT): $(DRIVER).pbc
pbc_to_exe --output=winxed$(EXEEXT) $(DRIVER).pbc
$(DRIVER).pbc: $(DRIVER).pir
parrot -o $(DRIVER).pbc $(DRIVER).pir
$(DRIVER).pir: winxed.winxed winxedst0$(EXEEXT)
./winxedst0$(EXEEXT) -o $(DRIVER).pir winxed.winxed
#+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# Install
# Testing, handle with care
#+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# Preinstall: generate pir files
preinstall: \
setup.pir \
pir/winxed_compiler.pir \
pir/winxed_installed.pir
# Installed compiler is stage 2 built with stage 3
pir/winxed_compiler.pir: winxedst3.pbc $(DRIVER).pbc
parrot $(DRIVER).pbc --noan -c -o pir/winxed_compiler.pir winxedst2.winxed
# Installed driver
pir/winxed_installed.pir: winxed_installed.winxed winxedst3.pbc $(DRIVER).pbc
parrot $(DRIVER).pbc --noan -c -o pir/winxed_installed.pir winxed_installed.winxed
# setup.pir for use from plumage
setup.pir: setup.winxed winxedst3.pbc $(DRIVER).pbc
parrot $(DRIVER).pbc -c -o setup.pir setup.winxed
# Install
install: preinstall
parrot setup.pir
parrot setup.pir install
#-----------------------------------------------------------------------
test0: $(DRIVER).pbc
parrot $(DRIVER).pbc --stage=0 t/harness --stage=0 -r t/basic t/*.t
test1: $(DRIVER).pbc winxedst1.pbc
parrot $(DRIVER).pbc --stage=1 t/harness --stage=1 -r t/basic t/medium t/*.t
test2: $(DRIVER).pbc winxedst2.pbc
parrot $(DRIVER).pbc --stage=2 t/harness --stage=2 -r t/basic t/medium t/advanced t/*.t
test3: $(DRIVER).pbc winxedst3.pbc
parrot $(DRIVER).pbc --stage=3 t/harness --stage=3 -r t/basic t/medium t/advanced t/*.t
test: test3
#-----------------------------------------------------------------------
# Test the --debug option and the compiler assertions:
# - First compile stage 1 with -debug option
# - Then use that stage 1 to compile stage 2 with debug option
# - Then use that stage 2 to compile again stage 2 with debug option
# - Then run the tests with both stage 2 debug versions
# Compile stage 1 in debug mode
winxedst1_deb1.pir: winxedst1.winxed
./winxedst0 --debug -o winxedst1_deb1.pir winxedst1.winxed
winxedst1_deb1.pbc: winxedst1_deb1.pir
parrot -o winxedst1_deb1.pbc winxedst1_deb1.pir
# Compile stage 2 in debug mode with debug mode stage 1
winxedst2_deb1.pir: winxedst2.winxed winxedst1_deb1.pbc
parrot winxedst1_deb1.pbc --debug -o winxedst2_deb1.pir winxedst2.winxed
winxedst2_deb1.pbc: winxedst2_deb1.pir
parrot -o winxedst2_deb1.pbc winxedst2_deb1.pir
# Compile stage 2 in debug mode with debug mode stage 2
winxedst2_deb2.pir: winxedst2.winxed winxedst2_deb1.pbc $(DRIVER).pbc
parrot $(DRIVER).pbc -c --debug --stage=winxedst2_deb1 -o winxedst2_deb2.pir winxedst2.winxed
winxedst2_deb2.pbc: winxedst2_deb2.pir
parrot -o winxedst2_deb2.pbc winxedst2_deb2.pir
testdebug: $(DRIVER).pbc winxedst1_deb1.pbc winxedst2_deb1.pbc winxedst2_deb2.pbc
parrot $(DRIVER).pbc --debug --stage=winxedst2_deb1 t/harness --debug --stage=winxedst2_deb1 -r t/basic t/medium t/advanced t/*.t
parrot $(DRIVER).pbc --debug --stage=winxedst2_deb2 t/harness --debug --stage=winxedst2_deb2 -r t/basic t/medium t/advanced t/*.t
#-----------------------------------------------------------------------
clean:
rm -f winxedst3.pbc
rm -f winxedst2.pbc
rm -f winxedst1.pbc
rm -f winxedst3.pir
rm -f winxedst2.pir
rm -f winxedst1.pir
rm -f winxed$(EXEEXT)
rm -f winxed$(OBJEXT)
rm -f winxed.c
rm -f $(DRIVER).pbc
rm -f $(DRIVER).pir
rm -f winxedst1_deb1.pbc
rm -f winxedst1_deb1.pir
rm -f winxedst2_deb1.pbc
rm -f winxedst2_deb1.pir
rm -f winxedst2_deb2.pbc
rm -f winxedst2_deb2.pir
rm -f winxedst0$(EXEEXT)
rm -f *$(OBJEXT)
# Makefile end