Enhancements to mkfiles.pl and Recipe to arrange for the auxiliary
[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 user32.lib gdi32.lib comctl32.lib comdlg32.lib
17 COMMON = midend misc malloc random version
18 NET = net tree234
19 NETSLIDE = netslide tree234
20 MINES = mines tree234
21 FLIP = flip tree234
22 PEGS = pegs tree234
23
24 ALL = list NET NETSLIDE cube fifteen sixteen rect pattern solo twiddle
25 + MINES samegame FLIP guess PEGS
26
27 net : [X] gtk COMMON NET
28 netslide : [X] gtk COMMON NETSLIDE
29 cube : [X] gtk COMMON cube
30 fifteen : [X] gtk COMMON fifteen
31 sixteen : [X] gtk COMMON sixteen
32 rect : [X] gtk COMMON rect
33 pattern : [X] gtk COMMON pattern
34 solo : [X] gtk COMMON solo
35 twiddle : [X] gtk COMMON twiddle
36 mines : [X] gtk COMMON MINES
37 samegame : [X] gtk COMMON samegame
38 flip : [X] gtk COMMON FLIP
39 guess : [X] gtk COMMON guess
40 pegs : [X] gtk COMMON PEGS
41
42 # Auxiliary command-line programs.
43 solosolver : [U] solo[STANDALONE_SOLVER] malloc
44 patternsolver : [U] pattern[STANDALONE_SOLVER] malloc
45 mineobfusc : [U] mines[STANDALONE_OBFUSCATOR] malloc random tree234 misc
46
47 solosolver : [C] solo[STANDALONE_SOLVER] malloc
48 patternsolver : [C] pattern[STANDALONE_SOLVER] malloc
49 mineobfusc : [C] mines[STANDALONE_OBFUSCATOR] malloc random tree234 misc
50
51 # The Windows Net shouldn't be called `net.exe' since Windows
52 # already has a reasonably important utility program by that name!
53 netgame : [G] WINDOWS COMMON NET
54 netslide : [G] WINDOWS COMMON NETSLIDE
55 cube : [G] WINDOWS COMMON cube
56 fifteen : [G] WINDOWS COMMON fifteen
57 sixteen : [G] WINDOWS COMMON sixteen
58 rect : [G] WINDOWS COMMON rect
59 pattern : [G] WINDOWS COMMON pattern
60 solo : [G] WINDOWS COMMON solo
61 twiddle : [G] WINDOWS COMMON twiddle
62 mines : [G] WINDOWS COMMON MINES
63 samegame : [G] WINDOWS COMMON samegame
64 flip : [G] WINDOWS COMMON FLIP
65 guess : [G] WINDOWS COMMON guess
66 pegs : [G] WINDOWS COMMON PEGS
67
68 # Mac OS X unified application containing all the puzzles.
69 Puzzles : [MX] osx osx.icns osx-info.plist COMMON ALL
70 # For OS X, we must create the online help and include it in the
71 # application bundle.) Also we add -DCOMBINED to the compiler flags
72 # so as to inform the code that we're building a single binary for
73 # all the puzzles. Then I've also got some code in here to build a
74 # distributable .dmg disk image.
75 !begin osx
76 CFLAGS += -DCOMBINED
77 Puzzles_extra = Puzzles.app/Contents/Resources/Help/index.html
78 Puzzles.app/Contents/Resources/Help/index.html: \
79 Puzzles.app/Contents/Resources/Help osx-help.but puzzles.but
80 cd Puzzles.app/Contents/Resources/Help; \
81 halibut --html ../../../../osx-help.but ../../../../puzzles.but
82 Puzzles.app/Contents/Resources/Help: Puzzles.app/Contents/Resources
83 mkdir -p Puzzles.app/Contents/Resources/Help
84
85 release: Puzzles.dmg
86 Puzzles.dmg: Puzzles
87 rm -f raw.dmg
88 hdiutil create -megabytes 5 -layout NONE raw.dmg
89 hdid -nomount raw.dmg > devicename
90 newfs_hfs -v "Simon Tatham's Puzzle Collection" `cat devicename`
91 hdiutil eject `cat devicename`
92 hdid raw.dmg | cut -f1 -d' ' > devicename
93 cp -R Puzzles.app /Volumes/"Simon Tatham's Puzzle Collection"
94 hdiutil eject `cat devicename`
95 rm -f Puzzles.dmg
96 hdiutil convert -format UDCO raw.dmg -o Puzzles.dmg
97 rm -f raw.dmg devicename
98 !end
99
100 # The `nullgame' source file is a largely blank one, which contains
101 # all the correct function definitions to compile and link, but
102 # which defines the null game in which nothing is ever drawn and
103 # there are no valid moves. Its main purpose is to act as a
104 # template for writing new game definition source files. I include
105 # it in the Makefile because it will be worse than useless if it
106 # ever fails to compile, so it's important that it should actually
107 # be built on a regular basis.
108 nullgame : [X] gtk COMMON nullgame
109 nullgame : [G] WINDOWS COMMON nullgame
110
111 # Version management.
112 !begin vc
113 version.obj: *.c *.h
114 cl $(VER) $(CFLAGS) /c version.c
115 !end
116 !specialobj vc version
117 !begin cygwin
118 version.o: FORCE;
119 FORCE:
120 $(CC) $(COMPAT) $(XFLAGS) $(CFLAGS) $(VER) -c version.c
121 !end
122 !specialobj cygwin version
123 # For Unix, we also need the gross MD5 hack that causes automatic
124 # version number selection in release source archives.
125 !begin gtk
126 version.o: FORCE;
127 FORCE:
128 if test -z "$(VER)" && test -f manifest && md5sum -c manifest; then \
129 $(CC) $(COMPAT) $(XFLAGS) $(CFLAGS) `cat version.def` -c version.c; \
130 elif test -z "$(VER)" && test -d .svn && svnversion . >&/dev/null; then \
131 $(CC) $(COMPAT) $(XFLAGS) $(CFLAGS) "-DREVISION=`svnversion .`" -c version.c; \
132 else \
133 $(CC) $(COMPAT) $(XFLAGS) $(CFLAGS) $(VER) -c version.c; \
134 fi
135 !end
136 !specialobj gtk version
137 # For OS X, this is made more fiddly by the fact that we don't have
138 # md5sum readily available. We do, however, have `md5 -r' which
139 # generates _nearly_ the same output, but it has no check function.
140 !begin osx
141 version.o: FORCE;
142 FORCE:
143 if test -z "$(VER)" && test -f manifest && (md5 -r `awk '{print $$2}' manifest` | diff -w manifest -); then \
144 $(CC) $(COMPAT) $(XFLAGS) $(CFLAGS) `cat version.def` -c version.c; \
145 elif test -z "$(VER)" && test -d .svn && svnversion . >&/dev/null; then \
146 $(CC) $(COMPAT) $(XFLAGS) $(CFLAGS) "-DREVISION=`svnversion .`" -c version.c; \
147 else \
148 $(CC) $(COMPAT) $(XFLAGS) $(CFLAGS) $(VER) -c version.c; \
149 fi
150 !end
151 !specialobj osx version
152
153 # make install for Unix.
154 !begin gtk
155 install:
156 for i in cube net netslide fifteen sixteen twiddle \
157 pattern rect solo mines samegame flip guess \
158 pegs; do \
159 $(INSTALL_PROGRAM) -m 755 $$i $(DESTDIR)$(gamesdir)/$$i; \
160 done
161 !end