summaryrefslogtreecommitdiffstats
path: root/eshtrans/Makefile
blob: 79a7d1d33c4442e046eee5ffec0fe42d054c87ea (plain)
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
SOURCES = \
	main.esh \
	common.esh \
	tokens.esh \
	backend/main.esh \
	backend/codegen.esh \
	frontend/main.esh \
	frontend/parser.esh \
	frontend/lexer.esh
OBJECTS1 = $(SOURCES:.esh=.sh1)
OBJECTS2 = $(SOURCES:.esh=.sh2)
OBJECTS3 = $(SOURCES:.esh=.sh3)

bootstrap: stage3
stage1:
	@printf 'Stage 1:\n'
	@time -p $(MAKE) eshtrans.stage1
stage2:
	@printf 'Stage 1:\n'
	@time -p $(MAKE) eshtrans.stage1
	@printf 'Stage 2:\n'
	@time -p $(MAKE) eshtrans.stage2
stage3:
	@printf 'Stage 1:\n'
	@time -p $(MAKE) eshtrans.stage1
	@printf 'Stage 2:\n'
	@time -p $(MAKE) eshtrans.stage2
	@printf 'Stage 3:\n'
	@time -p $(MAKE) eshtrans.stage3

clean: clean-stage1 clean-stage2 clean-stage3
clean-stage1:
	rm -f eshtrans.stage1 $(OBJECTS1)
clean-stage2:
	rm -f eshtrans.stage2 $(OBJECTS2)
clean-stage3:
	rm -f eshtrans.stage3 $(OBJECTS3)

.SUFFIXES:
.SUFFIXES: .esh .sh .sh1 .sh2 .sh3

eshtrans.stage1: $(OBJECTS1) Makefile
	cat $(OBJECTS1) >$@
	printf 'main "$${@}"\n' >>$@
	chmod a+x $@
eshtrans.stage2: eshtrans.stage1 $(OBJECTS2) Makefile
	../eshld/eshld -o $@ $(OBJECTS2)
eshtrans.stage3: eshtrans.stage2 $(OBJECTS3) Makefile
	../eshld/eshld -o $@ $(OBJECTS3)

$(OBJECTS1) $(OBJECTS2) $(OBJECTS3): Makefile

.esh.sh1:
	cp $< $@
.esh.sh2:
	./eshtrans.stage1 -o $@ $<
.esh.sh3:
	./eshtrans.stage2 -o $@ $<