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