annotate lab4/Makefile @ 0:bfdcc3820b32

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