summaryrefslogtreecommitdiffstats
path: root/eshtrans/Makefile
blob: c924c9293df74055cb683e951c7ae3ca3539cd2e (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
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)

WITH_PROF = n
PROF_y = ../libeshprof/hooks.esh
PROF = $(PROF_$(WITH_PROF))

bootstrap: stage3
stage1:
	@printf 'Stage 1:\n'
	@time -p $(MAKE) eshtrans.stage1 2>&1 | sed 's/^/\t/'
stage2: stage1
	@printf 'Stage 2:\n'
	@time -p $(MAKE) eshtrans.stage2 2>&1 | sed 's/^/\t/'
stage3: stage2
	@printf 'Stage 3:\n'
	@time -p $(MAKE) eshtrans.stage3 2>&1 | sed 's/^/\t/'

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)
	cat $(OBJECTS1) >$@
	printf 'main "$${@}"\n' >>$@
	chmod a+x $@
eshtrans.stage2: eshtrans.stage1 $(OBJECTS2) $(PROF)
	../eshld/eshld -o $@ $(OBJECTS2) $(PROF)
eshtrans.stage3: eshtrans.stage2 $(OBJECTS3) $(PROF)
	../eshld/eshld -o $@ $(OBJECTS3) $(PROF)

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

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