I'm sick of repeatedly adding and removing local changes to Recipe
[sgt/puzzles] / 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 cygwin Makefile.cyg
14 !makefile osx Makefile.osx
15
16 WINDOWS = windows printing
17 + user32.lib gdi32.lib comctl32.lib comdlg32.lib winspool.lib
18 COMMON = midend drawing misc malloc random version
19 GTK = gtk printing ps
20 # Objects needed for auxiliary command-line programs.
21 STANDALONE = nullfe random misc malloc
22
23 ALL = list
24
25 # First half of list.c.
26 !begin >list.c
27 /*
28 * list.c: List of pointers to puzzle structures, for monolithic
29 * platforms.
30 *
31 * This file is automatically generated by mkfiles.pl. Do not edit
32 * it directly, or the changes will be lost next time mkfiles.pl runs.
33 * Instead, edit Recipe and/or its *.R subfiles.
34 */
35 #include "puzzles.h"
36 #define GAMELIST(A) \
37 !end
38
39 # Now each .R file adds part of the macro definition of GAMELIST to list.c.
40 !include *.R
41
42 # Then we finish up list.c as follows:
43 !begin >list.c
44
45 #define DECL(x) extern const game x;
46 #define REF(x) &x,
47 GAMELIST(DECL)
48 const game *gamelist[] = { GAMELIST(REF) };
49 const int gamecount = lenof(gamelist);
50 !end
51
52 # Mac OS X unified application containing all the puzzles.
53 Puzzles : [MX] osx osx.icns osx-info.plist COMMON ALL
54 # For OS X, we must create the online help and include it in the
55 # application bundle.) Also we add -DCOMBINED to the compiler flags
56 # so as to inform the code that we're building a single binary for
57 # all the puzzles. Then I've also got some code in here to build a
58 # distributable .dmg disk image.
59 !begin osx
60 CFLAGS += -DCOMBINED
61 Puzzles_extra = Puzzles.app/Contents/Resources/Help/index.html
62 Puzzles.app/Contents/Resources/Help/index.html: \
63 Puzzles.app/Contents/Resources/Help osx-help.but puzzles.but
64 cd Puzzles.app/Contents/Resources/Help; \
65 halibut --html ../../../../osx-help.but ../../../../puzzles.but
66 Puzzles.app/Contents/Resources/Help: Puzzles.app/Contents/Resources
67 mkdir -p Puzzles.app/Contents/Resources/Help
68
69 release: Puzzles.dmg
70 Puzzles.dmg: Puzzles
71 rm -f raw.dmg
72 hdiutil create -megabytes 5 -layout NONE raw.dmg
73 hdid -nomount raw.dmg > devicename
74 newfs_hfs -v "Simon Tatham's Puzzle Collection" `cat devicename`
75 hdiutil eject `cat devicename`
76 hdid raw.dmg | cut -f1 -d' ' > devicename
77 cp -R Puzzles.app /Volumes/"Simon Tatham's Puzzle Collection"
78 hdiutil eject `cat devicename`
79 rm -f Puzzles.dmg
80 hdiutil convert -format UDCO raw.dmg -o Puzzles.dmg
81 rm -f raw.dmg devicename
82 !end
83
84 # Version management.
85 !begin vc
86 version.obj: *.c *.h
87 cl $(VER) $(CFLAGS) /c version.c
88 !end
89 !specialobj vc version
90 !begin cygwin
91 version.o: FORCE;
92 FORCE:
93 $(CC) $(COMPAT) $(XFLAGS) $(CFLAGS) $(VER) -c version.c
94 !end
95 !specialobj cygwin version
96 # For Unix, we also need the gross MD5 hack that causes automatic
97 # version number selection in release source archives.
98 !begin gtk
99 version.o: FORCE;
100 FORCE:
101 if test -z "$(VER)" && test -f manifest && md5sum -c manifest; then \
102 $(CC) $(COMPAT) $(XFLAGS) $(CFLAGS) `cat version.def` -c version.c; \
103 elif test -z "$(VER)" && test -d .svn && svnversion . >&/dev/null; then \
104 $(CC) $(COMPAT) $(XFLAGS) $(CFLAGS) "-DREVISION=`svnversion .`" -c version.c; \
105 else \
106 $(CC) $(COMPAT) $(XFLAGS) $(CFLAGS) $(VER) -c version.c; \
107 fi
108 !end
109 !specialobj gtk version
110 # For OS X, this is made more fiddly by the fact that we don't have
111 # md5sum readily available. We do, however, have `md5 -r' which
112 # generates _nearly_ the same output, but it has no check function.
113 !begin osx
114 version.o: FORCE;
115 FORCE:
116 if test -z "$(VER)" && test -f manifest && (md5 -r `awk '{print $$2}' manifest` | diff -w manifest -); then \
117 $(CC) $(COMPAT) $(XFLAGS) $(CFLAGS) `cat version.def` -c version.c; \
118 elif test -z "$(VER)" && test -d .svn && svnversion . >&/dev/null; then \
119 $(CC) $(COMPAT) $(XFLAGS) $(CFLAGS) "-DREVISION=`svnversion .`" -c version.c; \
120 else \
121 $(CC) $(COMPAT) $(XFLAGS) $(CFLAGS) $(VER) -c version.c; \
122 fi
123 !end
124 !specialobj osx version
125
126 # make install for Unix.
127 !begin gtk
128 install:
129 for i in $(GAMES); do \
130 $(INSTALL_PROGRAM) -m 755 $$i $(DESTDIR)$(gamesdir)/$$i \
131 || exit 1; \
132 done
133 !end