annotate lab4/Makefile @ 1:b5139af1a420 tip basis

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