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