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