-
Notifications
You must be signed in to change notification settings - Fork 15
/
Makefile
512 lines (435 loc) · 13.9 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
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
all: CPP cc cc0 \
cc1.8080 cc1.z80 cc1.thread cc1.byte cc1.6502 \
cc1.65c816 cc1.z8 cc1.1802 cc1.6800 cc1.6809 \
cc1.8070 cc1.8086 \
cc1.ee200 cc1.nova cc1.ddp cc1.7000 cc1.hc08 cc1.gb \
cc2 cc2.8080 cc2.z80 cc2.65c816 cc2.thread \
cc2.6502 cc2.z8 cc2.super8 cc2.1802 cc2.6800 cc2.6809 \
cc2.8070 cc2.8086 \
cc2.ee200 cc2.nova cc2.ddp cc2.7000 cc2.hc08 cc2.gb \
copt \
support6303 support6502 support65c816 support6800 support6803 \
support6809 support68hc11 support8070 support8080 support8085 supportz80 \
supportz8 supportsuper8 supportee200 supportnova supportnova3 supporttms7000 \
test
bootstuff: CPP cc cc0 \
cc1.8080 cc1.z80 cc1.thread cc1.byte cc1.6502 \
cc1.65c816 cc1.z8 cc1.super8 cc1.1802 cc1.6800 cc1.6809 \
cc1.8070 cc1.8086 cc1.ee200 cc1.nova cc1.ddp cc1.7000 \
cc1.hc08 cc1.gb \
cc2 cc2.8080 cc2.z80 cc2.65c816 cc2.thread \
cc2.6502 cc2.z8 cc2.super8 cc2.1802 cc2.6800 cc2.6809 \
cc2.8070 cc2.8086 cc2.ee200 cc2.nova cc2.ddp cc2.7000 \
cc2.hc08 cc2.gb \
copt
.PHONY: support6303 support6502 support65c816 support6800 support6803 \
support6809 support68hc11 support8070 support8080 support8085 \
supportsuper8 supportz8 supportz80 supportee200 supportnova \
supportnova3 supporttms7000 test CPP
CCROOT ?=/opt/fcc/
OBJS0 = frontend.o
OBJS1 = body.o declaration.o enum.o error.o expression.o header.o idxdata.o \
initializer.o label.o lex.o main.o primary.o stackframe.o storage.o \
struct.o switch.o symbol.o tree.o type.o type_iterator.o
OBJS2 = backend.o backend-default.o
OBJS3 = backend.o backend-8080.o
OBJS4 = backend.o backend-8086.o
OBJS5 = backend.o be-codegen-z80.o be-rewrite-z80.o be-func-z80.o
OBJS6 = backend.o backend-65c816.o
OBJS7 = backend.o backend-ee200.o
OBJS8 = backend.o backend-8070.o
OBJS9 = backend.o backend-threadcode.o
OBJS10 = backend.o backend-nova.o
OBJS11 = backend.o backend-6502.o backend-byte.o
OBJS12 = backend.o backend-65c816.o
OBJS13 = backend.o backend-z8.o
OBJS14 = backend.o backend-super8.o
OBJS15 = backend.o backend-1802.o
OBJS16 = backend.o be-codegen-6800.o be-track-6800.o be-code-6800.o be-func-6800.o
OBJS17 = backend.o be-codegen-6800.o be-track-6800.o be-code-6809.o be-func-6800.o
OBJS18 = backend.o backend-ddp.o
OBJS19 = backend.o backend-tms7000.o
OBJS20 = backend.o backend-hc08.o backend-byte.o
OBJS21 = backend.o backend-gb.o backend-byte.o
CFLAGS = -Wall -pedantic -g3 -DLIBPATH="\"$(CCROOT)/lib\"" -DBINPATH="\"$(CCROOT)/bin\""
INC0 = token.h
INC1 = body.h compiler.h declaration.h enum.h error.h expression.h header.h \
idxdata.h initializer.h label.h lex.h primary.h stackframe.h storage.h \
struct.h symbol.h target.h token.h tree.h type.h type_iterator.h
INC2 = backend.h symtab.h
$(OBJS0): $(INC0) symtab.h
$(OBJS1): $(INC1)
$(OBJS2): $(INC1) $(INC2)
$(OBJS3): $(INC1) $(INC2)
backend-super8.o: backend-super8.c backend-z8.c
CPP:
(cd CPP; make)
cc: cc.o
gcc -g3 $< -o cc
cc0: $(OBJS0)
gcc -g3 $(OBJS0) -o cc0
cc1.8080:$(OBJS1) target-8080.o
gcc -g3 $(OBJS1) target-8080.o -o cc1.8080
cc1.8086:$(OBJS1) target-8086.o
gcc -g3 $(OBJS1) target-8086.o -o cc1.8086
cc1.z80:$(OBJS1) target-z80.o
gcc -g3 $(OBJS1) target-z80.o -o cc1.z80
cc1.thread:$(OBJS1) target-threadcode.o
gcc -g3 $(OBJS1) target-threadcode.o -o cc1.thread
cc1.byte:$(OBJS1) target-bytecode.o
gcc -g3 $(OBJS1) target-bytecode.o -o cc1.byte
cc1.6502:$(OBJS1) target-6502.o
gcc -g3 $(OBJS1) target-6502.o -o cc1.6502
cc1.65c816:$(OBJS1) target-65c816.o
gcc -g3 $(OBJS1) target-65c816.o -o cc1.65c816
cc1.z8:$(OBJS1) target-z8.o
gcc -g3 $(OBJS1) target-z8.o -o cc1.z8
cc1.super8:$(OBJS1) target-super8.o
gcc -g3 $(OBJS1) target-super8.o -o cc1.super8
cc1.1802:$(OBJS1) target-1802.o
gcc -g3 $(OBJS1) target-1802.o -o cc1.1802
cc1.6800:$(OBJS1) target-6800.o
gcc -g3 $(OBJS1) target-6800.o -o cc1.6800
cc1.6809:$(OBJS1) target-6800.o
gcc -g3 $(OBJS1) target-6800.o -o cc1.6809
cc1.8070:$(OBJS1) target-8070.o
gcc -g3 $(OBJS1) target-8070.o -o cc1.8070
cc1.ee200:$(OBJS1) target-ee200.o
gcc -g3 $(OBJS1) target-ee200.o -o cc1.ee200
cc1.nova:$(OBJS1) target-nova.o
gcc -g3 $(OBJS1) target-nova.o -o cc1.nova
cc1.ddp:$(OBJS1) target-ddp.o
gcc -g3 $(OBJS1) target-ddp.o -o cc1.ddp
cc1.7000:$(OBJS1) target-tms7000.o
gcc -g3 $(OBJS1) target-tms7000.o -o cc1.7000
cc1.hc08:$(OBJS1) target-hc08.o
gcc -g3 $(OBJS1) target-hc08.o -o cc1.hc08
cc1.gb:$(OBJS1) target-gb.o
gcc -g3 $(OBJS1) target-gb.o -o cc1.gb
cc2: $(OBJS2)
gcc -g3 $(OBJS2) -o cc2
cc2.8080: $(OBJS3)
gcc -g3 $(OBJS3) -o cc2.8080
cc2.8086: $(OBJS4)
gcc -g3 $(OBJS4) -o cc2.8086
cc2.z80: $(OBJS5)
gcc -g3 $(OBJS5) -o cc2.z80
cc2.thread: $(OBJS9)
gcc -g3 $(OBJS9) -o cc2.thread
cc2.6502: $(OBJS11)
gcc -g3 $(OBJS11) -o cc2.6502
cc2.65c816: $(OBJS12)
gcc -g3 $(OBJS12) -o cc2.65c816
cc2.z8: $(OBJS13)
gcc -g3 $(OBJS13) -o cc2.z8
cc2.super8: $(OBJS14)
gcc -g3 $(OBJS14) -o cc2.super8
cc2.1802: $(OBJS15)
gcc -g3 $(OBJS15) -o cc2.1802
cc2.6800: $(OBJS16)
gcc -g3 $(OBJS16) -o cc2.6800
cc2.6809: $(OBJS17)
gcc -g3 $(OBJS17) -o cc2.6809
cc2.8070: $(OBJS8)
gcc -g3 $(OBJS8) -o cc2.8070
cc2.ee200: $(OBJS7)
gcc -g3 $(OBJS7) -o cc2.ee200
cc2.nova: $(OBJS10)
gcc -g3 $(OBJS10) -o cc2.nova
cc2.ddp: $(OBJS18)
gcc -g3 $(OBJS18) -o cc2.ddp
cc2.7000: $(OBJS19)
gcc -g3 $(OBJS19) -o cc2.7000
cc2.hc08: $(OBJS20)
gcc -g3 $(OBJS20) -o cc2.hc08
cc2.gb: $(OBJS21)
gcc -g3 $(OBJS21) -o cc2.gb
support6303:
(cd support6303; make)
support6502:
(cd support6502; make)
support65c816:
(cd support65c816; make)
support6800:
(cd support6800; make)
support6803:
(cd support6803; make)
support6809:
(cd support6809; make)
support68hc11:
(cd support68hc11; make)
support8070:
(cd support8070; make)
support8080:
(cd support8080; make)
support8085:
(cd support8085; make)
supportee200:
(cd supportee200; make)
supportnova:
(cd supportnova; make)
supportnova3:
(cd supportnova3; make)
supportsuper8:
(cd supportsuper8; make)
supporttms7000:
(cd supporttms7000; make)
supportz8:
(cd supportz8; make)
supportz80:
(cd supportz80; make)
test:
(cd test; make)
clean:
(cd CPP; make clean)
rm -f cc cc0 copt
rm -f cc6502 cc65c816
rm -f cc1.1802 cc2.1802
rm -f cc1.6800 cc2.6800
rm -f cc1.6809 cc2.6809
rm -f cc1.8080 cc1.z80 cc1.thread
rm -f cc1.6502 cc1.65c816 cc1.byte
rm -f cc1.8070
rm -f cc2.8080 cc2.z80 cc2.65c816
rm -f cc2.8070 cc2.thread cc2.byte cc2.6502
rm -f cc1.super8 cc2.super8
rm -f cc1.z8 cc2.z8
rm -f cc1.8086 cc2.8086
rm -f cc1.ee200 cc2.ee200
rm -f cc1.ddp cc2.ddp
rm -f cc1.7000 cc2.7000
rm -f cc1.hc08 cc2.hc08
rm -f cc1.gb cc2.gb
rm -f *~ *.o
(cd support6303; make clean)
(cd support6502; make clean)
(cd support65c816; make clean)
(cd support6800; make clean)
(cd support6803; make clean)
(cd support6809; make clean)
(cd support68hc11; make clean)
(cd support8080; make clean)
(cd supportee200; make clean)
(cd supportnova; make clean)
(cd supportnova3; make clean)
(cd supportsuper8; make clean)
(cd support8085; make clean)
(cd supporttms7000; make clean)
(cd supportz80; make clean)
(cd supportz8; make clean)
(cd test; make clean)
# New install version. This is used by both the install rules, as we need
# to bootstrap build a toolchain with no support library to build the toolchain
# with out.
#
# Install the tools only
#
bootinst:
mkdir -p $(CCROOT)/bin
mkdir -p $(CCROOT)/lib
cp cc $(CCROOT)/bin/fcc
cp cc.hlp $(CCROOT)/lib/cc.hlp
cp cc0 $(CCROOT)/lib
cp CPP/cpp $(CCROOT)/lib
# 6502
mkdir -p $(CCROOT)/lib/6502
mkdir -p $(CCROOT)/lib/6502/include
cp cc1.6502 $(CCROOT)/lib
cp cc2.6502 $(CCROOT)/lib
cp copt $(CCROOT)/lib
cp rules.6502 $(CCROOT)/lib
# 65c816
mkdir -p $(CCROOT)/lib/65c816
mkdir -p $(CCROOT)/lib/65c816/include
cp cc1.65c816 $(CCROOT)/lib
cp cc2.65c816 $(CCROOT)/lib
cp copt $(CCROOT)/lib
cp rules.65c816 $(CCROOT)/lib
# 6800
mkdir -p $(CCROOT)/lib/6303
mkdir -p $(CCROOT)/lib/6303/include
mkdir -p $(CCROOT)/lib/6800
mkdir -p $(CCROOT)/lib/6800/include
mkdir -p $(CCROOT)/lib/6803
mkdir -p $(CCROOT)/lib/6803/include
mkdir -p $(CCROOT)/lib/6809
mkdir -p $(CCROOT)/lib/6809/include
mkdir -p $(CCROOT)/lib/hc11
mkdir -p $(CCROOT)/lib/hc11/include
cp cc1.6800 $(CCROOT)/lib
cp cc2.6800 $(CCROOT)/lib
cp cc1.6809 $(CCROOT)/lib
cp cc2.6809 $(CCROOT)/lib
cp copt $(CCROOT)/lib
cp rules.6800 $(CCROOT)/lib
cp rules.6809 $(CCROOT)/lib
cp rules.hc11 $(CCROOT)/lib
cp lorder6809 $(CCROOT)/bin/lorder6809
cp lorder6809 $(CCROOT)/bin/lorder6800
# 8070 (WIP)
mkdir -p $(CCROOT)/lib/8070
mkdir -p $(CCROOT)/lib/8070/include
cp cc1.8070 $(CCROOT)/lib
cp cc2.8070 $(CCROOT)/lib
cp rules.8070 $(CCROOT)/lib
# 8086 (WIP)
mkdir -p $(CCROOT)/lib/8086
mkdir -p $(CCROOT)/lib/8086/include
cp cc1.8086 $(CCROOT)/lib
cp cc2.8086 $(CCROOT)/lib
cp rules.8086 $(CCROOT)/lib
# 8080/8085
mkdir -p $(CCROOT)/lib/8080
mkdir -p $(CCROOT)/lib/8085
mkdir -p $(CCROOT)/lib/8080/include
mkdir -p $(CCROOT)/lib/8085/include
cp lorder8080 $(CCROOT)/bin/lorder8080
cp cc1.8080 $(CCROOT)/lib
cp cc2.8080 $(CCROOT)/lib
cp rules.8080 $(CCROOT)/lib
cp rules.8085 $(CCROOT)/lib
# Z80
mkdir -p $(CCROOT)/lib/z80/
mkdir -p $(CCROOT)/lib/z80/include
cp lorderz80 $(CCROOT)/bin/lorderz80
cp cc1.z80 $(CCROOT)/lib
cp cc2.z80 $(CCROOT)/lib
cp rules.z80 $(CCROOT)/lib
# Threadcode
mkdir -p $(CCROOT)/lib/threadcode
mkdir -p $(CCROOT)/lib/threadcode/include
cp cc1.thread $(CCROOT)/lib
cp cc2.thread $(CCROOT)/lib
cp rules.thread $(CCROOT)/lib
# Z8
mkdir -p $(CCROOT)/lib/z8
mkdir -p $(CCROOT)/lib/z8/include/
cp cc1.z8 $(CCROOT)/lib
cp cc2.z8 $(CCROOT)/lib
cp rules.z8 $(CCROOT)/lib
cp lorderz8 $(CCROOT)/bin/lorderz8
# Super8
mkdir -p $(CCROOT)/lib/super8
mkdir -p $(CCROOT)/lib/super8/include/
cp cc1.super8 $(CCROOT)/lib
cp cc2.super8 $(CCROOT)/lib
cp rules.super8 $(CCROOT)/lib
cp lorderz8 $(CCROOT)/bin/lordersuper8
# 1802
mkdir -p $(CCROOT)/lib/1802
mkdir -p $(CCROOT)/lib/1802/include/
cp cc1.1802 $(CCROOT)/lib
cp cc2.1802 $(CCROOT)/lib
cp rules.1802 $(CCROOT)/lib
# ee200
mkdir -p $(CCROOT)/lib/ee200
mkdir -p $(CCROOT)/lib/ee200/include/
cp lorderee200 $(CCROOT)/bin/lorderee200
cp cc1.ee200 $(CCROOT)/lib
cp cc2.ee200 $(CCROOT)/lib
cp rules.ee200 $(CCROOT)/lib
# Nova
mkdir -p $(CCROOT)/lib/nova
mkdir -p $(CCROOT)/lib/nova/include/
cp lordernova $(CCROOT)/bin/lordernova
cp cc1.nova $(CCROOT)/lib
cp cc2.nova $(CCROOT)/lib
cp rules.nova $(CCROOT)/lib
# DDP
mkdir -p $(CCROOT)/lib/ddp
mkdir -p $(CCROOT)/lib/ddp/include/
cp lorderddp $(CCROOT)/bin/lorderddp
cp cc1.ddp $(CCROOT)/lib
cp cc2.ddp $(CCROOT)/lib
cp rules.ddp $(CCROOT)/lib
# TMS7000
mkdir -p $(CCROOT)/lib/tms7000
mkdir -p $(CCROOT)/lib/tms7000/include/
cp lorder7000 $(CCROOT)/bin/lorder7000
cp cc1.7000 $(CCROOT)/lib
cp cc2.7000 $(CCROOT)/lib
cp rules.7000 $(CCROOT)/lib
# 68HC08
mkdir -p $(CCROOT)/lib/hc08
mkdir -p $(CCROOT)/lib/hc08/include/
cp lorderhc08 $(CCROOT)/bin/lorderhc08
cp cc1.hc08 $(CCROOT)/lib
cp cc2.hc08 $(CCROOT)/lib
cp rules.hc08 $(CCROOT)/lib
# Gameboy
mkdir -p $(CCROOT)/lib/gb
mkdir -p $(CCROOT)/lib/gb/include/
cp lordergb $(CCROOT)/bin/lordergb
cp cc1.gb $(CCROOT)/lib
cp cc2.gb $(CCROOT)/lib
cp rules.gb $(CCROOT)/lib
#
# Install the support libraries
#
libinst:
cp support6502/crt0.o $(CCROOT)/lib/6502/
cp support6502/lib6502.a $(CCROOT)/lib/6502/lib6502.a
# cp support6502/lib65c02.a $(CCROOT)/lib/6502/lib65c02.a
ar cq $(CCROOT)/lib/6502/libc.a
cp support65c816/crt0.o $(CCROOT)/lib/65c816/
cp support65c816/lib65c816.a $(CCROOT)/lib/65c816/lib65c816.a
ar cq $(CCROOT)/lib/65c816/libc.a
cp support6303/crt0.o $(CCROOT)/lib/6303/
cp support6303/lib6303.a $(CCROOT)/lib/6303/lib6303.a
ar cq $(CCROOT)/lib/6800/libc.a
cp support6800/crt0.o $(CCROOT)/lib/6800/
cp support6800/lib6800.a $(CCROOT)/lib/6800/lib6800.a
ar cq $(CCROOT)/lib/6800/libc.a
cp support6803/crt0.o $(CCROOT)/lib/6803/
cp support6803/lib6803.a $(CCROOT)/lib/6803/lib6803.a
ar cq $(CCROOT)/lib/6803/libc.a
cp support6809/crt0.o $(CCROOT)/lib/6809/
cp support6809/lib6809.a $(CCROOT)/lib/6809/lib6809.a
ar cq $(CCROOT)/lib/6809/libc.a
cp support68hc11/crt0.o $(CCROOT)/lib/hc11/
cp support68hc11/lib68hc11.a $(CCROOT)/lib/hc11/libhc11.a
ar cq $(CCROOT)/lib/hc11/libc.a
cp support8070/crt0.o $(CCROOT)/lib/8070/
cp support8070/include/*.h $(CCROOT)/lib/8070/include/
cp support8070/lib8070.a $(CCROOT)/lib/8070/lib8070.a
cp support8080/crt0.o $(CCROOT)/lib/8080/
cp support8085/crt0.o $(CCROOT)/lib/8085/
cp support8080/include/*.h $(CCROOT)/lib/8080/include/
cp support8085/include/*.h $(CCROOT)/lib/8085/include/
cp support8080/lib8080.a $(CCROOT)/lib/8080/lib8080.a
cp support8085/lib8085.a $(CCROOT)/lib/8085/lib8085.a
ar cq $(CCROOT)/lib/8080/libc.a
cp supportz8/crt0.o $(CCROOT)/lib/z8/
cp supportz8/include/*.h $(CCROOT)/lib/z8/include/
cp supportz8/libz8.a $(CCROOT)/lib/z8/libz8.a
ar cq $(CCROOT)/lib/z8/libc.a
cp supportee200/crt0.o $(CCROOT)/lib/ee200/
cp supportee200/libee200.a $(CCROOT)/lib/ee200/libee200.a
ar cq $(CCROOT)/lib/ee200/libc.a
cp supportnova3/crt0.o $(CCROOT)/lib/nova/
cp supportnova3/include/*.h $(CCROOT)/lib/nova/include/
cp supportnova3/libnova.a $(CCROOT)/lib/nova/libnova3.a
cp supportnova/crt0.o $(CCROOT)/lib/nova/
cp supportnova/include/*.h $(CCROOT)/lib/nova/include/
cp supportnova/libnova.a $(CCROOT)/lib/nova/libnova.a
ar cq $(CCROOT)/lib/nova/libc.a
cp supportsuper8/crt0.o $(CCROOT)/lib/super8/
cp supportsuper8/include/*.h $(CCROOT)/lib/super8/include/
cp supportsuper8/libsuper8.a $(CCROOT)/lib/super8/libsuper8.a
ar cq $(CCROOT)/lib/super8/libc.a
cp supporttms7000/crt0.o $(CCROOT)/lib/tms7000/
cp supporttms7000/include/*.h $(CCROOT)/lib/tms7000/include/
cp supporttms7000/libtms7000.a $(CCROOT)/lib/tms7000/libtms7000.a
cp support8080/crt0.o $(CCROOT)/lib/8080/
cp supportz80/crt0.o $(CCROOT)/lib/z80/
cp supportz80/include/*.h $(CCROOT)/lib/z80/include/
cp supportz80/libz80.a $(CCROOT)/lib/z80/libz80.a
ar cq $(CCROOT)/lib/z80/libc.a
#
# Build the tools then install them
#
bootstrap: bootstuff bootinst
#
# Build everything
#
install: bootstuff bootinst all libinst