Correction from James H: sqrt(0) shouldn't occur any more than
[sgt/puzzles] / Recipe
CommitLineData
720a8fb7 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
4e7ef6e6 12!makefile vc Makefile.vc
cb0c7d4a 13!makefile wce Makefile.wce
eb2ad6f1 14!makefile cygwin Makefile.cyg
9494d866 15!makefile osx Makefile.osx
2c930807 16!makefile nestedvm Makefile.nestedvm
720a8fb7 17
fa2cb13d 18!srcdir icons/
19
821ab2c6 20WINDOWS = windows printing
21 + user32.lib gdi32.lib comctl32.lib comdlg32.lib winspool.lib
dafd6cf6 22COMMON = midend drawing misc malloc random version
dafd6cf6 23GTK = gtk printing ps
3f98cd5a 24# Objects needed for auxiliary command-line programs.
25STANDALONE = nullfe random misc malloc
dafd6cf6 26
3f98cd5a 27ALL = list
720a8fb7 28
3f98cd5a 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
8317499a 42
3f98cd5a 43# Now each .R file adds part of the macro definition of GAMELIST to list.c.
44!include *.R
9b265feb 45
3f98cd5a 46# Then we finish up list.c as follows:
47!begin >list.c
8317499a 48
3f98cd5a 49#define DECL(x) extern const game x;
50#define REF(x) &x,
51GAMELIST(DECL)
52const game *gamelist[] = { GAMELIST(REF) };
53const int gamecount = lenof(gamelist);
54!end
699b896a 55
9494d866 56# Mac OS X unified application containing all the puzzles.
a96edf8a 57Puzzles : [MX] osx osx.icns osx-info.plist COMMON ALL
fccfd04d 58# For OS X, we must create the online help and include it in the
08f7c1b2 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
c4a7369d 61# all the puzzles. Then I've also got some code in here to build a
62# distributable .dmg disk image.
fccfd04d 63!begin osx
08f7c1b2 64CFLAGS += -DCOMBINED
fccfd04d 65Puzzles_extra = Puzzles.app/Contents/Resources/Help/index.html
66Puzzles.app/Contents/Resources/Help/index.html: \
8709d5d9 67 Puzzles.app/Contents/Resources/Help osx-help.but puzzles.but
68 cd Puzzles.app/Contents/Resources/Help; \
69 halibut --html ../../../../osx-help.but ../../../../puzzles.but
fccfd04d 70Puzzles.app/Contents/Resources/Help: Puzzles.app/Contents/Resources
71 mkdir -p Puzzles.app/Contents/Resources/Help
c4a7369d 72
73release: Puzzles.dmg
74Puzzles.dmg: Puzzles
75 rm -f raw.dmg
76 hdiutil create -megabytes 5 -layout NONE raw.dmg
77 hdid -nomount raw.dmg > devicename
78 newfs_hfs -v "Simon Tatham's Puzzle Collection" `cat devicename`
79 hdiutil eject `cat devicename`
80 hdid raw.dmg | cut -f1 -d' ' > devicename
81 cp -R Puzzles.app /Volumes/"Simon Tatham's Puzzle Collection"
82 hdiutil eject `cat devicename`
83 rm -f Puzzles.dmg
84 hdiutil convert -format UDCO raw.dmg -o Puzzles.dmg
85 rm -f raw.dmg devicename
fccfd04d 86!end
9494d866 87
97098757 88# Version management.
89!begin vc
90version.obj: *.c *.h
91 cl $(VER) $(CFLAGS) /c version.c
92!end
93!specialobj vc version
cb0c7d4a 94!begin wce
95version.obj: *.c *.h
96 $(CC) $(VER) $(CFLAGS) /c version.c
97!end
98!specialobj wce version
97098757 99!begin cygwin
36d01ffa 100version.o: FORCE;
97098757 101FORCE:
102 $(CC) $(COMPAT) $(XFLAGS) $(CFLAGS) $(VER) -c version.c
103!end
104!specialobj cygwin version
105# For Unix, we also need the gross MD5 hack that causes automatic
106# version number selection in release source archives.
107!begin gtk
108version.o: FORCE;
109FORCE:
118fcd8b 110 if test -z "$(VER)" && test -f manifest && md5sum -c manifest; then \
97098757 111 $(CC) $(COMPAT) $(XFLAGS) $(CFLAGS) `cat version.def` -c version.c; \
c1f500c0 112 elif test -z "$(VER)" && test -d .svn && svnversion . >/dev/null 2>&1; then \
118fcd8b 113 $(CC) $(COMPAT) $(XFLAGS) $(CFLAGS) "-DREVISION=`svnversion .`" -c version.c; \
97098757 114 else \
115 $(CC) $(COMPAT) $(XFLAGS) $(CFLAGS) $(VER) -c version.c; \
116 fi
117!end
118!specialobj gtk version
2c930807 119!begin nestedvm
120version.o: FORCE;
121FORCE:
122 if test -z "$(VER)" && test -f manifest && md5sum -c manifest; then \
123 $(CC) $(COMPAT) $(XFLAGS) $(CFLAGS) `cat version.def` -c version.c; \
124 elif test -z "$(VER)" && test -d .svn && svnversion . >/dev/null 2>&1; then \
125 $(CC) $(COMPAT) $(XFLAGS) $(CFLAGS) "-DREVISION=`svnversion .`" -c version.c; \
126 else \
127 $(CC) $(COMPAT) $(XFLAGS) $(CFLAGS) $(VER) -c version.c; \
128 fi
129!end
130!specialobj nestedvm version
97098757 131# For OS X, this is made more fiddly by the fact that we don't have
132# md5sum readily available. We do, however, have `md5 -r' which
133# generates _nearly_ the same output, but it has no check function.
134!begin osx
d68d8560 135version.ppc.o: FORCE;
97098757 136FORCE:
137 if test -z "$(VER)" && test -f manifest && (md5 -r `awk '{print $$2}' manifest` | diff -w manifest -); then \
d68d8560 138 $(CC) -arch ppc $(COMPAT) $(XFLAGS) $(CFLAGS) `cat version.def` -c version.c -o version.ppc.o; \
c1f500c0 139 elif test -z "$(VER)" && test -d .svn && svnversion . >/dev/null 2>&1; then \
d68d8560 140 $(CC) -arch ppc $(COMPAT) $(XFLAGS) $(CFLAGS) "-DREVISION=`svnversion .`" -c version.c -o version.ppc.o; \
97098757 141 else \
d68d8560 142 $(CC) -arch ppc $(COMPAT) $(XFLAGS) $(CFLAGS) $(VER) -c version.c -o version.ppc.o; \
143 fi
144version.i386.o: FORCE2;
145FORCE2:
146 if test -z "$(VER)" && test -f manifest && (md5 -r `awk '{print $$2}' manifest` | diff -w manifest -); then \
147 $(CC) -arch i386 $(COMPAT) $(XFLAGS) $(CFLAGS) `cat version.def` -c version.c -o version.i386.o; \
148 elif test -z "$(VER)" && test -d .svn && svnversion . >/dev/null 2>&1; then \
149 $(CC) -arch i386 $(COMPAT) $(XFLAGS) $(CFLAGS) "-DREVISION=`svnversion .`" -c version.c -o version.i386.o; \
150 else \
151 $(CC) -arch i386 $(COMPAT) $(XFLAGS) $(CFLAGS) $(VER) -c version.c -o version.i386.o; \
97098757 152 fi
153!end
154!specialobj osx version
fd38f463 155
156# make install for Unix.
157!begin gtk
158install:
3f98cd5a 159 for i in $(GAMES); do \
0d336b11 160 $(INSTALL_PROGRAM) -m 755 $$i $(DESTDIR)$(gamesdir)/$$i \
161 || exit 1; \
fd38f463 162 done
163!end
2c930807 164!begin nestedvm
165.PRECIOUS: %.class
166%.class: %.mips
167 java -cp $(NESTEDVM)/build:$(NESTEDVM)/upstream/build/classgen/build \
168 org.ibex.nestedvm.Compiler -outformat class -d . \
169 PuzzleEngine $<
170 mv PuzzleEngine.class $@
171
172org:
173 mkdir -p org/ibex/nestedvm/util
174 cp $(NESTEDVM)/build/org/ibex/nestedvm/{Registers,UsermodeConstants,Runtime*}.class org/ibex/nestedvm
175 cp $(NESTEDVM)/build/org/ibex/nestedvm/util/{Platform*,Seekable*}.class org/ibex/nestedvm/util
176 echo "Main-Class: PuzzleApplet" >applet.manifest
177
178PuzzleApplet.class: PuzzleApplet.java org
179 javac -source 1.3 -target 1.3 PuzzleApplet.java
180
181%.jar: %.class PuzzleApplet.class org
182 mv $< PuzzleEngine.class
183 jar cfm $@ applet.manifest PuzzleEngine.class PuzzleApplet*.class org
184 echo '<applet archive="'$@'" code="PuzzleApplet" width="700" height="500"></applet>' >$*.html
185 mv PuzzleEngine.class $<
186!end