kill any still-running xst_original process via Makefile
[fleet.git] / Makefile
1
2 ## Fleeterpreter ##############################################################################
3
4 cp                = -cp fleet.jar:lib/RXTXcomm.jar
5 java              = java -Xmx500m
6
7 run: fleet.jar; $(java) $(cp) $(interpreter_class)
8
9 ifeq ($(shell uname -o 2>/dev/null),Cygwin)
10 ps=\;
11 else
12 ps=:
13 endif
14
15 java_files = $(shell find src -name \*.java)
16 ship_files = $(shell find ships -name \*.ship)
17 fleet.jar: $(java_files) $(ship_files) src/edu/berkeley/fleet/assembler/fleet.g
18         mkdir -p build/class/edu/berkeley/fleet/assembler/
19         cp src/edu/berkeley/fleet/assembler/fleet.g build/class/edu/berkeley/fleet/assembler/
20         javac -classpath lib/RXTXcomm.jar:lib/edu.berkeley.sbp.jar -d build/class/ $(shell find src -name \*.java)
21         cd build/class/; jar xf ../../lib/edu.berkeley.sbp.jar
22         for A in `find ships -name \*.ship`;\
23           do java -cp build/class edu.berkeley.fleet.Main expand $$A;\
24           done
25         javac -classpath lib/RXTXcomm.jar:build/class${ps}lib/edu.berkeley.sbp.jar -d build/class/ `find build/java -name \*.java`
26         echo 'Main-Class: edu.berkeley.fleet.Main' > build/class/manifest
27         cd build/class/; jar cmf manifest ../../$@ .
28
29
30 ## Fpga ####################################################################################
31
32 host = intel2950-5.eecs.berkeley.edu
33 remote_ise = /tools/xilinx/ISE9.1i_lin
34 remote_edk = /tools/xilinx/EDK9.1i_lin
35 remote_dir = /scratch/megacz/fleet/
36
37 #host = mm2.millennium.berkeley.edu
38 #remote_ise = /scratch/megacz/xilinx/ise/
39 #remote_edk = /scratch/megacz/xilinx/edk/
40 #remote_dir = /scratch/megacz/fleet/
41
42
43 xilinx =  cd build/fpga;
44 xilinx += LD_LIBRARY_PATH=$$LD_LIBRARY_PATH:$(remote_ise)/bin/lin:$(remote_edk)/bin/lin
45 xilinx += PATH=$$PATH:$(remote_ise)/bin/lin:$(remote_edk)/bin/lin
46 xilinx += XST_VERSION=9.2i
47 xilinx += XILINX=$(remote_ise)
48 xilinx += XILINX_EDK=$(remote_edk)
49 xilinx += $(remote_ise)/bin/lin/
50
51 speed_grade = 11
52 device = xc4vfx60ff1152-${speed_grade}
53 #device = xc2vp70-7ff1704
54
55 upload: fleet.jar build/fpga/main.bit
56         mkdir -p build
57         rsync -are ssh --progress --verbose ./ root@goliath:fleet/
58
59 build/fpga/main.bit: $(java_files) $(ship_files)
60         make fleet.jar
61         mkdir -p build/fpga
62         $(java) $(cp) edu.berkeley.fleet.fpga.Fpga build/fpga/
63         cp src/edu/berkeley/fleet/fpga/* build/fpga || true
64         for A in `find ships -name \*.ship`;\
65           do java -cp build/class edu.berkeley.fleet.Main target=fpga expand $$A;\
66           done
67         rsync -zare ssh --progress --delete --verbose ./ ${host}:${remote_dir}
68         time ssh ${host} 'make -C ${remote_dir} synth XILINX=${remote_ise} remote_ise=${remote_ise} remote_edk=${remote_edk}'
69         scp ${host}:${remote_dir}/build/fpga/main.bit build/fpga/
70
71 pcore = ${remote_edk}/hw/XilinxProcessorIPLib/pcores
72 synth:
73         cd build/fpga; ln -sf ../../src/edu/berkeley/fleet/fpga/* .
74         cd build/fpga; ln -sf ../../src/edu/berkeley/fleet/fpga/mem/* .
75         rm -f build/fpga/main.lso
76         echo work                        >> build/fpga/main.lso
77         rm -f build/fpga/main.prj
78         cd build/fpga; for A in *.v;   do echo verilog work \""$$A"\"; done >> main.prj
79         cd build/fpga; for A in *.vhd; do echo vhdl    work \""$$A"\"; done >> main.prj
80         cd build/fpga; mkdir -p tmp
81         cd build/fpga; mkdir -p xst
82         rm -rf build/fpga/_ngo
83         skill xst_original
84         $(xilinx)xst -intstyle xflow -ifn main.xst -ofn main.syr < main.xst
85         $(xilinx)ngdbuild -aul -intstyle xflow -dd _ngo -nt timestamp -uc main.ucf -p $(device) main.ngc main.ngd
86         $(xilinx)map -intstyle xflow -p $(device) -cm speed -l -pr b -k 4 -c 100 -tx off -o main_map.ncd main.ngd main.pcf
87         $(xilinx)par -w -intstyle xflow -pl std -ol std -t 99 main_map.ncd main.ncd main.pcf
88         $(xilinx)bitgen -intstyle xflow -d -f main.ut main.ncd
89 #       $(xilinx)trce -intstyle xflow -e 3 -l 3 -s 6 -xml main main.ncd -o main.twr main.pcf
90
91
92 runserver: fleet.jar
93         java -Djava.library.path=lib -cp fleet.jar:lib/RXTXcomm.jar edu.berkeley.fleet.fpga.Server
94
95 test:     fleet.jar; $(java) -jar fleet.jar             test ships/*.ship tests
96 testfpga: fleet.jar; $(java) -jar fleet.jar target=fpga test ships/*.ship tests
97
98 ## Manual ####################################################################################
99
100 svgs    = $(shell find doc -name \*.svg)
101 %.eps: %.svg
102         DISPLAY= /Applications/Inkscape.app/Contents//Resources/bin/inkscape  -z --export-area-drawing $^ --export-eps=$@
103
104 %.pdf: %.eps
105         epstopdf $^ --outfile=$@
106
107 manual: archmanual toolmanual
108
109 archmanual: fleet.jar $(svgs:%.svg=%.pdf)
110         $(java) -jar fleet.jar doc
111         cd .tmp; ln -sf ../doc/*.bib .
112         cd .tmp; TEXINPUTS=$$TEXINPUTS:../src/edu/berkeley/fleet/assembler/:../doc/ pdflatex FleetTwo.Manual.tex
113         cd .tmp; for A in *.mp; do mpost --tex=latex $$A; done
114         cd .tmp; TEXINPUTS=$$TEXINPUTS:../src/edu/berkeley/fleet/assembler/:../doc/ pdflatex FleetTwo.Manual.tex
115         open .tmp/FleetTwo.Manual.pdf
116 toolmanual: fleet.jar $(svgs:%.svg=%.pdf)
117         $(java) -jar fleet.jar doc
118         cd .tmp; ln -sf ../doc/*.bib .
119         cd .tmp; TEXINPUTS=$$TEXINPUTS:../src/edu/berkeley/fleet/assembler/:../doc/ pdflatex toolchain.tex
120         open .tmp/toolchain.pdf
121
122 ## API docs ####################################################################################
123
124 javadoc:
125         javadoc \
126                 -linksource \
127                 -windowtitle "FleetCode API Documentation" \
128                 -sourcepath src \
129                 -header "<b>FleetCode API Documentation</b><br>" \
130                 -public \
131                 -notree \
132                 -nonavbar \
133                 -noqualifier all \
134                 -stylesheetfile doc/javadoc.css \
135                 -d /afs/research.cs.berkeley.edu/class/fleet/website/code/javadoc/ \
136                 edu.berkeley.fleet.api
137         open http://fleet.cs.berkeley.edu/code/javadoc/
138
139 ## Misc ####################################################################################
140
141 clean:
142         rm -rf fleet.jar build
143
144 ## Dist ####################################################################################
145
146 #dist:
147 #       darcs record
148 #       darcs push /afs/research.cs.berkeley.edu/class/fleet/website/repos/fleet/
149 #       darcs get . --repo-name=fleet-`date +%d.%h.%y`
150 #       make -C fleet-`date +%d.%h.%y` fleet.jar
151 #       rm -rf fleet-`date +%d.%h.%y`/build
152 #       echo 'http://research.cs.berkeley.edu/class/fleet/repos/fleet/' > \
153 #         fleet-`date +%d.%h.%y`/_darcs/prefs/defaultrepo
154 #       tar cvzf fleet-`date +%d.%h.%y`.tgz fleet-`date +%d.%h.%y`
155 #       rm -rf fleet-`date +%d.%h.%y`
156 #       mv fleet-`date +%d.%h.%y`.tgz /afs/research.cs.berkeley.edu/class/fleet/website/files/
157 #       @echo
158 #       @echo
159 #       @echo   http://research.cs.berkeley.edu/class/fleet/files/fleet-`date +%d.%h.%y`.tgz
160 #       @echo
161 #       @echo
162 #
163
164 dist:
165         darcs dist -d fleet
166         mv fleet.tar.gz /afs/research.cs.berkeley.edu/class/fleet/website/code/snapshots/fleet-`date +%y.%m.%d`.tgz
167
168 # you'll probably want to change this line
169 ghc  = /usr/local/brian/ghc/compiler/ghc-inplace
170
171 ghc += -fglasgow-exts -fallow-undecidable-instances -fallow-overlapping-instances -cpp 
172 ghc += -i$(shell pwd)/build/hi/ -hidir $(shell pwd)/build/hi/ -odir $(shell pwd)/build/class/
173
174 f0: fleet.jar
175         mkdir -p build/hi build/class
176         cd lib;                        $(ghc) -c -java SBP.lhs
177         cd src/edu/berkeley/fleet/f0/; $(ghc) -fglasgow-exts -cpp $(hflags)    -java Util.lhs
178         cd src/edu/berkeley/fleet/f0/; $(ghc) -fglasgow-exts -cpp $(hflags)    -java Fleet.lhs
179         cd src/edu/berkeley/fleet/f0/; $(ghc) -fglasgow-exts -cpp $(hflags)    -java Types.lhs
180         cd src/edu/berkeley/fleet/f0/; $(ghc) -fglasgow-exts -cpp $(hflags)    -java Compile.lhs
181         cd src/edu/berkeley/fleet/f0/; $(ghc) -fglasgow-exts -cpp $(hflags)    -java Main.lhs
182         $(java) -cp build/class:lib/HSbase.jar:lib/HSrts.jar:lib/HSstm.jar:fleet.jar Main
183