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