comparison lab4/Makefile @ 0:bfdcc3820b32

Basis
author Mike Spivey <mike@cs.ox.ac.uk>
date Thu, 05 Oct 2017 08:04:15 +0100
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:bfdcc3820b32
1 # lab4/Makefile
2
3 all: ppc
4
5 TOOLS = ../tools
6
7 ppc: util.cmo mach.cmo optree.cmo dict.cmo tree.cmo lexer.cmo \
8 parser.cmo check.cmo target.cmo regs.cmo simp.cmo \
9 share.cmo jumpopt.cmo tran.cmo tgen.cmo main.cmo
10 ocamlc -g ../lib/common.cma $^ -o $@
11
12 parser.ml parser.mli: parser.mly
13 ocamlyacc -v parser.mly
14
15 lexer.ml: lexer.mll
16 ocamllex lexer.mll
17
18 %.cmi: %.mli
19 ocamlc $(MLFLAGS) -c -g $<
20
21 %.cmo: %.ml $(TOOLS)/nodexp
22 ocamlc $(MLFLAGS) -c -g -pp $(TOOLS)/nodexp $<
23
24 MLFLAGS = -I ../lib
25
26 $(TOOLS)/nodexp $(TOOLS)/pibake: $(TOOLS)/%:
27 $(MAKE) -C $(TOOLS) $*
28
29 test: force
30 @echo "Say..."
31 @echo " 'make test0' to compare assembly code"
32 @echo " 'make test1' to test using QEMU"
33 @echo " 'make test2' to test using a remote RPi"
34 @echo " 'make test3' to test using ECSLAB remotely"
35
36 TESTSRC := $(shell ls test/*.p)
37 OPT = -O2
38
39 SCRIPT1 = -e '1,/^(\*\[\[/d' -e '/^]]\*)/q' -e p
40 SCRIPT2 = -e '1,/^(\*<</d' -e '/^>>\*)/q' -e p
41
42 ARMGCC = arm-linux-gnueabihf-gcc -marm -march=armv6
43
44 ARCH := $(shell uname -m)
45 QEMU-armv6l = env
46 QEMU-armv7l = env
47 QEMU := $(QEMU-$(ARCH))
48 ifndef QEMU
49 QEMU := qemu-arm
50 endif
51
52 # test0 -- compile tests and diff object code
53 test0 : $(TESTSRC:test/%.p=test0-%)
54
55 test0-%: force
56 @echo "*** Test $*.p"
57 ./ppc $(OPT) test/$*.p >b.s
58 -sed -n $(SCRIPT1) test/$*.p | diff -u -b - b.s
59 @echo
60
61 # test1 -- compile tests and execute with QEMU
62 test1 : $(TESTSRC:test/%.p=test1-%)
63
64 test1-%: pas0.o force
65 @echo "*** Test $*.p"
66 ./ppc $(OPT) test/$*.p >b.s
67 $(ARMGCC) b.s pas0.o -static -o b.out
68 $(QEMU) ./b.out >b.test
69 sed -n $(SCRIPT2) test/$*.p | diff - b.test
70 @echo "*** Passed"; echo
71
72 pas0.o: pas0.c
73 $(ARMGCC) -c $< -o $@
74
75 # test2 -- compile tests and execute using remote or local RPi
76 test2 : $(TESTSRC:test/%.p=test2-%)
77
78 test2-%: $(TOOLS)/pibake force
79 @echo "*** Test $*.p"
80 ./ppc $(OPT) test/$*.p >b.s
81 $(TOOLS)/pibake b.s >b.test
82 sed -n $(SCRIPT2) test/$*.p | diff - b.test
83 @echo "*** Passed"; echo
84
85 # test3 -- ditto but using qemu on ecs.ox
86 test3 : $(TESTSRC:test/%.p=test3-%)
87
88 test3-%: $(TOOLS)/ecsx force
89 @echo "*** Test $*.p"
90 ./ppc $(OPT) test/$*.p >b.s
91 $(TOOLS)/ecsx pas0.c fixup.s b.s >b.test
92 sed -n $(SCRIPT2) test/$*.p | diff - b.test
93 @echo "*** Passed"; echo
94
95 promote: $(TESTSRC:test/%.p=promote-%)
96
97 promote-%: force
98 ./ppc $(OPT) test/$*.p >b.s
99 sed -f promote.sed test/$*.p >test/$*.new
100 mv test/$*.new test/$*.p
101
102 force:
103
104 MLGEN = parser.mli parser.ml lexer.ml
105
106 ML = $(MLGEN) optree.ml tgen.ml tran.ml simp.ml share.ml jumpopt.ml \
107 check.ml check.mli dict.ml dict.mli lexer.mli \
108 mach.ml mach.mli main.ml optree.mli tgen.mli tree.ml \
109 tree.mli util.ml tran.mli target.mli target.ml \
110 simp.mli share.mli regs.mli regs.ml jumpopt.mli
111
112 clean: force
113 rm -f *.cmi *.cmo *.o *.output
114 rm -f $(MLGEN)
115 rm -f ppc b.out b.s b.test
116
117 depend: $(ML) $(TOOLS)/nodexp force
118 (sed '/^###/q' Makefile; echo; ocamldep -pp $(TOOLS)/nodexp $(ML)) >new
119 mv new Makefile
120
121 CC = gcc
122
123 ###
124
125 parser.cmi : tree.cmi optree.cmi dict.cmi
126 parser.cmo : tree.cmi optree.cmi lexer.cmi dict.cmi parser.cmi
127 parser.cmx : tree.cmx optree.cmx lexer.cmx dict.cmx parser.cmi
128 lexer.cmo : util.cmo parser.cmi optree.cmi dict.cmi lexer.cmi
129 lexer.cmx : util.cmx parser.cmx optree.cmx dict.cmx lexer.cmi
130 optree.cmo : optree.cmi
131 optree.cmx : optree.cmi
132 tgen.cmo : tree.cmi tran.cmi target.cmi simp.cmi share.cmi regs.cmi \
133 optree.cmi mach.cmi lexer.cmi jumpopt.cmi dict.cmi tgen.cmi
134 tgen.cmx : tree.cmx tran.cmx target.cmx simp.cmx share.cmx regs.cmx \
135 optree.cmx mach.cmx lexer.cmx jumpopt.cmx dict.cmx tgen.cmi
136 tran.cmo : target.cmi regs.cmi optree.cmi tran.cmi
137 tran.cmx : target.cmx regs.cmx optree.cmx tran.cmi
138 simp.cmo : util.cmo optree.cmi simp.cmi
139 simp.cmx : util.cmx optree.cmx simp.cmi
140 share.cmo : regs.cmi optree.cmi mach.cmi share.cmi
141 share.cmx : regs.cmx optree.cmx mach.cmx share.cmi
142 jumpopt.cmo : util.cmo optree.cmi jumpopt.cmi
143 jumpopt.cmx : util.cmx optree.cmx jumpopt.cmi
144 check.cmo : util.cmo tree.cmi optree.cmi mach.cmi lexer.cmi dict.cmi \
145 check.cmi
146 check.cmx : util.cmx tree.cmx optree.cmx mach.cmx lexer.cmx dict.cmx \
147 check.cmi
148 check.cmi : tree.cmi
149 dict.cmo : util.cmo optree.cmi mach.cmi dict.cmi
150 dict.cmx : util.cmx optree.cmx mach.cmx dict.cmi
151 dict.cmi : optree.cmi mach.cmi
152 lexer.cmi : parser.cmi optree.cmi dict.cmi
153 mach.cmo : mach.cmi
154 mach.cmx : mach.cmi
155 mach.cmi :
156 main.cmo : tree.cmi tran.cmi tgen.cmi parser.cmi mach.cmi lexer.cmi \
157 check.cmi
158 main.cmx : tree.cmx tran.cmx tgen.cmx parser.cmx mach.cmx lexer.cmx \
159 check.cmx
160 optree.cmi :
161 tgen.cmi : tree.cmi
162 tree.cmo : optree.cmi dict.cmi tree.cmi
163 tree.cmx : optree.cmx dict.cmx tree.cmi
164 tree.cmi : optree.cmi dict.cmi
165 util.cmo :
166 util.cmx :
167 tran.cmi : optree.cmi
168 target.cmi : optree.cmi
169 target.cmo : optree.cmi target.cmi
170 target.cmx : optree.cmx target.cmi
171 simp.cmi : optree.cmi
172 share.cmi : optree.cmi
173 regs.cmi : target.cmi
174 regs.cmo : util.cmo target.cmi regs.cmi
175 regs.cmx : util.cmx target.cmx regs.cmi
176 jumpopt.cmi : optree.cmi