chiark / gitweb /
Remove stray bashisms from the NestedVM makefile.
[sgt-puzzles.git] / Recipe
1 # -*- makefile -*-
2
3 # This file describes which puzzle binaries are made up from which
4 # object and resource files. It is processed into the various
5 # Makefiles by means of a Perl script. Makefile changes should
6 # really be made by editing this file and/or the Perl script, not
7 # by editing the actual Makefiles.
8
9 !name puzzles
10
11 !makefile gtk Makefile
12 !makefile vc Makefile.vc
13 !makefile wce Makefile.wce
14 !makefile cygwin Makefile.cyg
15 !makefile osx Makefile.osx
16 !makefile gnustep Makefile.gnustep
17 !makefile nestedvm Makefile.nestedvm
18 !makefile emcc Makefile.emcc
19
20 !srcdir icons/
21
22 WINDOWS_COMMON = printing
23          + user32.lib gdi32.lib comctl32.lib comdlg32.lib winspool.lib
24 WINDOWS  = windows WINDOWS_COMMON
25 COMMON   = midend drawing misc malloc random version
26 GTK      = gtk printing ps
27 # Objects needed for auxiliary command-line programs.
28 STANDALONE = nullfe random misc malloc
29
30 ALL      = list
31
32 # First half of list.c.
33 !begin >list.c
34 /*
35  * list.c: List of pointers to puzzle structures, for monolithic
36  * platforms.
37  *
38  * This file is automatically generated by mkfiles.pl. Do not edit
39  * it directly, or the changes will be lost next time mkfiles.pl runs.
40  * Instead, edit Recipe and/or its *.R subfiles.
41  */
42 #include "puzzles.h"
43 #define GAMELIST(A) \
44 !end
45
46 # Now each .R file adds part of the macro definition of GAMELIST to list.c.
47 !include *.R
48
49 # Then we finish up list.c as follows:
50 !begin >list.c
51
52 #define DECL(x) extern const game x;
53 #define REF(x) &x,
54 GAMELIST(DECL)
55 const game *gamelist[] = { GAMELIST(REF) };
56 const int gamecount = lenof(gamelist);
57 !end
58
59 # Unix standalone application for special-purpose obfuscation.
60 obfusc : [U] obfusc STANDALONE
61
62 puzzles  : [G] windows[COMBINED] WINDOWS_COMMON COMMON ALL noicon.res
63
64 # Mac OS X unified application containing all the puzzles.
65 Puzzles  : [MX] osx osx.icns osx-info.plist COMMON ALL
66 # For OS X, we must create the online help and include it in the
67 # application bundle.) Also we add -DCOMBINED to the compiler flags
68 # so as to inform the code that we're building a single binary for
69 # all the puzzles. Then I've also got some code in here to build a
70 # distributable .dmg disk image.
71 !begin osx
72 Puzzles_extra = Puzzles.app/Contents/Resources/Help/index.html
73 Puzzles.app/Contents/Resources/Help/index.html: \
74         Puzzles.app/Contents/Resources/Help osx-help.but puzzles.but
75         cd Puzzles.app/Contents/Resources/Help; \
76                 halibut --html ../../../../osx-help.but ../../../../puzzles.but
77 Puzzles.app/Contents/Resources/Help: Puzzles.app/Contents/Resources
78         mkdir -p Puzzles.app/Contents/Resources/Help
79
80 release: Puzzles.dmg
81 Puzzles.dmg: Puzzles
82         rm -f raw.dmg
83         hdiutil create -megabytes 5 -layout NONE raw.dmg
84         hdid -nomount raw.dmg > devicename
85         newfs_hfs -v "Simon Tatham's Puzzle Collection" `cat devicename`
86         hdiutil eject `cat devicename`
87         hdid raw.dmg | cut -f1 -d' ' > devicename
88         cp -R Puzzles.app /Volumes/"Simon Tatham's Puzzle Collection"
89         hdiutil eject `cat devicename`
90         rm -f Puzzles.dmg
91         hdiutil convert -format UDCO raw.dmg -o Puzzles.dmg
92         rm -f raw.dmg devicename
93 !end
94
95 # Version management.
96 !begin vc
97 version.obj: *.c *.h
98         cl $(VER) $(CFLAGS) /c version.c
99 !end
100 !specialobj vc version
101 !begin wce
102 version.obj: *.c *.h
103         $(CC) $(VER) $(CFLAGS) /c version.c
104 !end
105 !specialobj wce version
106 !begin cygwin
107 version.o: FORCE;
108 FORCE:
109         $(CC) $(COMPAT) $(XFLAGS) $(CFLAGS) $(VER) -c version.c
110 !end
111 !specialobj cygwin version
112 # For Unix, we also need the gross MD5 hack that causes automatic
113 # version number selection in release source archives.
114 !begin gtk
115 version.o: version.c version2.def
116         $(CC) $(COMPAT) $(XFLAGS) $(CFLAGS) `cat version2.def` -c version.c
117 version2.def: FORCE
118         if test -z "$(VER)" && test -f manifest && md5sum -c manifest; then \
119                 cat version.def > version2.def.new; \
120         elif test -z "$(VER)" && test -d .svn && svnversion . >/dev/null 2>&1; then \
121                 echo "-DREVISION=`svnversion .`" >version2.def.new; \
122         else \
123                 echo "$(VER)" >version2.def.new; \
124         fi && \
125         if diff -q version2.def.new version2.def; then \
126                 rm version2.def.new; \
127         else \
128                 mv version2.def.new version2.def; \
129         fi
130 .PHONY: FORCE
131 !end
132 !specialobj gtk version
133 !begin nestedvm
134 version.o: version.c version2.def
135         $(CC) $(COMPAT) $(XFLAGS) $(CFLAGS) `cat version2.def` -c version.c
136 version2.def: FORCE
137         if test -z "$(VER)" && test -f manifest && md5sum -c manifest; then \
138                 cat version.def > version2.def.new; \
139         elif test -z "$(VER)" && test -d .svn && svnversion . >/dev/null 2>&1; then \
140                 echo "-DREVISION=`svnversion .`" >version2.def.new; \
141         else \
142                 echo "$(VER)" >version2.def.new; \
143         fi && \
144         if diff -q version2.def.new version2.def; then \
145                 rm version2.def.new; \
146         else \
147                 mv version2.def.new version2.def; \
148         fi
149 .PHONY: FORCE
150 !end
151 !specialobj nestedvm version
152 # For OS X, this is made more fiddly by the fact that we don't have
153 # md5sum readily available. We do, however, have `md5 -r' which
154 # generates _nearly_ the same output, but it has no check function.
155 !begin osx
156 version.ppc.o: version.c version2.def
157         $(CC) -arch ppc $(COMPAT) $(XFLAGS) $(CFLAGS) `cat version2.def` -c version.c -o $@
158 version.i386.o: version.c version2.def
159         $(CC) -arch i386 $(COMPAT) $(XFLAGS) $(CFLAGS) `cat version2.def` -c version.c -o $@
160 version2.def: FORCE
161         if test -z "$(VER)" && test -f manifest && (md5 -r `awk '{print $$2}' manifest` | diff -w manifest -); then \
162                 cat version.def > version2.def.new; \
163         elif test -z "$(VER)" && test -d .svn && svnversion . >/dev/null 2>&1; then \
164                 echo "-DREVISION=`svnversion .`" >version2.def.new; \
165         else \
166                 echo "$(VER)" >version2.def.new; \
167         fi && \
168         if diff -q version2.def.new version2.def; then \
169                 rm version2.def.new; \
170         else \
171                 mv version2.def.new version2.def; \
172         fi
173 .PHONY: FORCE
174 !end
175 !specialobj osx version
176
177 # make install for Unix.
178 !begin gtk
179 install:
180         for i in $(GAMES); do \
181                 $(INSTALL_PROGRAM) -m 755 $(BINPREFIX)$$i $(DESTDIR)$(gamesdir)/$(BINPREFIX)$$i \
182                 || exit 1; \
183         done
184 !end
185 !begin nestedvm
186 .PRECIOUS: %.class
187 %.class: %.mips
188         java -cp $(NESTEDVM)/build:$(NESTEDVM)/upstream/build/classgen/build \
189                 org.ibex.nestedvm.Compiler -outformat class -d . \
190                 PuzzleEngine $<
191                 mv PuzzleEngine.class $@
192
193 org:
194         mkdir -p org/ibex/nestedvm/util
195         cp $(NESTEDVM)/build/org/ibex/nestedvm/Registers.class org/ibex/nestedvm
196         cp $(NESTEDVM)/build/org/ibex/nestedvm/UsermodeConstants.class org/ibex/nestedvm
197         cp $(NESTEDVM)/build/org/ibex/nestedvm/Runtime*.class org/ibex/nestedvm
198         cp $(NESTEDVM)/build/org/ibex/nestedvm/util/Platform*.class org/ibex/nestedvm/util
199         cp $(NESTEDVM)/build/org/ibex/nestedvm/util/Seekable*.class org/ibex/nestedvm/util
200         echo "Main-Class: PuzzleApplet" >applet.manifest
201
202 PuzzleApplet.class: PuzzleApplet.java org
203         javac -source 1.3 -target 1.3 PuzzleApplet.java
204
205 %.jar: %.class PuzzleApplet.class org
206         mv $< PuzzleEngine.class
207         jar cfm $@ applet.manifest PuzzleEngine.class PuzzleApplet*.class org
208         echo '<applet archive="'$@'" code="PuzzleApplet" width="700" height="500"></applet>' >$*.html
209         mv PuzzleEngine.class $<
210 !end
211
212 # A benchmarking and testing target for the GTK puzzles.
213 !begin gtk
214 test: benchmark.html benchmark.txt
215
216 benchmark.html: benchmark.txt benchmark.pl
217         ./benchmark.pl benchmark.txt > $@
218
219 benchmark.txt: $(GAMES)
220         for i in $(GAMES); do \
221                 for params in $$(env -i ./$(BINPREFIX)$$i --list-presets | cut -f1 -d' '); do \
222                         env -i ./$(BINPREFIX)$$i --test-solve --time-generation --generate 100 $$params \
223                         || exit 1; \
224                 done; \
225         done > $@
226 !end