2 # Build script to build Puzzles.
6 set Version $(!builddate).$(vcsid)
8 # Start by substituting the right version number in configure.ac.
9 in puzzles do perl -i~ -pe 's/6.66/$(Version)/' configure.ac
10 in puzzles do rm configure.ac~
12 # And put it into the documentation as a versionid.
13 # use perl to avoid inconsistent behaviour of echo '\v'
14 in puzzles do perl -e 'print "\n\\versionid Simon Tatham'\''s Portable Puzzle Collection, version $$ARGV[0]\n"' $(Version) >> puzzles.but
15 in puzzles do perl -e 'print "\n\\versionid Simon Tatham'\''s Portable Puzzle Collection, version $$ARGV[0]\n"' $(Version) >> devel.but
17 # Write out a version.h that contains the real version number.
18 in puzzles do echo '/* Generated by automated build script */' > version.h
19 in puzzles do echo '$#define VER "Version $(Version)"' >> version.h
21 # And do the same substitution in the OS X metadata. (This is a bit
22 # icky in principle because it presumes that my version numbers don't
23 # need XML escaping, but frankly, if they ever do then I should fix
25 in puzzles do perl -i -pe 's/Unidentified build/$(Version)/' osx-info.plist
27 # First build some local binaries, to run the icon build.
28 in puzzles do perl mkfiles.pl -U
31 # Now build the screenshots and icons.
32 in puzzles/icons do xvfb-run -s "-screen 0 1024x768x24" make web winicons gtkicons
34 # Destroy the local binaries and autoconf detritus, mostly to avoid
35 # wasting network bandwidth by transferring them to the delegate
37 in puzzles do make distclean
39 # Re-run mkfiles.pl now that it knows the icons are there.
40 in puzzles do perl mkfiles.pl
42 # Rebuild the configure script.
43 in puzzles do ./mkauto.sh
45 # Build the OS X .dmg archive.
47 in puzzles do make -f Makefile.osx clean
48 in puzzles do make -f Makefile.osx release VER=-DVER=$(Version)
49 return puzzles/Puzzles.dmg
52 # Build the Windows binaries and installer, and the CHM file.
53 in puzzles do make -f Makefile.doc clean
54 in puzzles do make -f Makefile.doc # build help files for installer
55 in puzzles do mason.pl --args '{"version":"$(Version)","descfile":"gamedesc.txt"}' winwix.mc > puzzles.wxs
56 in puzzles do perl winiss.pl $(Version) gamedesc.txt > puzzles.iss
58 # FIXME: Cygwin alternative?
59 in puzzles with visualstudio do/win nmake -f Makefile.vc clean
60 in puzzles with visualstudio do/win nmake -f Makefile.vc VER=-DVER=$(Version)
61 # Code-sign the binaries, if the local bob config provides a script
62 # to do so. We assume here that the script accepts an -i option to
63 # provide a 'more info' URL, and an optional -n option to provide a
64 # program name, and that it can take multiple .exe filename
65 # arguments and sign them all in place.
66 ifneq "$(winsigncode)" "" in puzzles do $(winsigncode) -i https://www.chiark.greenend.org.uk/~sgtatham/puzzles/ *.exe
68 in puzzles with wix do/win candle puzzles.wxs && light -ext WixUIExtension -sval puzzles.wixobj
69 ifneq "$(winsigncode)" "" in puzzles do $(winsigncode) -i https://www.chiark.greenend.org.uk/~sgtatham/puzzles/ -n "Simon Tatham's Portable Puzzle Collection Installer" puzzles.msi Output/installer.exe
71 return puzzles/puzzles.msi
73 in puzzles do chmod +x *.exe
75 # Build the Pocket PC binaries and CAB.
77 # NOTE: This part of the build script requires the Windows delegate
78 # server to have the cabwiz program on its PATH. This will
81 # C:\Program Files\Windows CE Tools\WCE420\POCKET PC 2003\Tools
83 # but it might not be if you've installed it somewhere else, or
84 # have a different version.
86 # NOTE ALSO: This part of the build is commented out, for the
87 # moment, because cabwiz does unhelpful things when run from within
88 # a bob delegate process (or, more generally, when run from any
89 # terminal-based remote login to a Windows machine, including
90 # Cygwin opensshd and Windows Telnet). The symptom is that cabwiz
91 # just beeps and sits there. Until I figure out how to build the
92 # .cab from an automated process (and I'm willing to consider silly
93 # approaches such as a third-party CAB generator), I don't think I
94 # can sensibly enable this build.
96 #in puzzles do perl wceinf.pl gamedesc.txt > puzzles.inf
98 # in puzzles do cmd /c 'wcearmv4 & nmake -f Makefile.wce clean'
99 # in puzzles do cmd /c 'wcearmv4 & nmake -f Makefile.wce VER=-DVER=$(Version)'
100 # # Nasty piece of sh here which saves the return code from cabwiz,
101 # # outputs its errors and/or warnings, and then propagates the
102 # # return code back to bob. If only cabwiz could output to
103 # # standard error LIKE EVERY OTHER COMMAND-LINE UTILITY IN THE
104 # # WORLD, I wouldn't have to do this.
105 # in puzzles do cat puzzles.inf
106 # in puzzles do cmd /c 'wcearmv4 & bash -c cabwiz puzzles.inf /err cabwiz.err /cpu ARMV4'; a=$$?; cat cabwiz.err; exit $$a
107 # return puzzles/puzzles.armv4.cab
110 # Build the HTML docs.
111 in puzzles do mkdir doc
112 in puzzles do mkdir devel
113 in puzzles/doc do halibut --html -Chtml-contents-filename:index.html -Chtml-index-filename:indexpage.html -Chtml-template-filename:%k.html -Chtml-template-fragment:%k ../puzzles.but
114 in puzzles/devel do halibut --html -Chtml-contents-filename:index.html -Chtml-index-filename:indexpage.html -Chtml-template-filename:%k.html -Chtml-template-fragment:%k ../devel.but
116 # Move the deliver-worthy Windows binaries (those specified in
117 # gamedesc.txt, which is generated by mkfiles.pl and helpfully
118 # excludes the command-line auxiliary utilities such as solosolver,
119 # and nullgame.exe) into a subdirectory for easy access.
120 in puzzles do mkdir winbin
121 in puzzles do mv `cut -f2 -d: gamedesc.txt` winbin
123 # Make a zip file of the Windows binaries and help files.
124 in puzzles do zip -j puzzles.zip winbin/*.exe puzzles.chm puzzles.hlp puzzles.cnt
126 # Create the source archive. (That writes the archive into the
127 # _parent_ directory, so be careful when we deliver it.)
128 in puzzles do ./makedist.sh $(Version)
130 # Build the autogenerated pieces of the main web page.
131 in puzzles do perl webpage.pl
133 ifneq "$(JAVA_UNFINISHED)" "" in puzzles do perl -i~ -pe 'print "!srcdir unfinished/\n" if /!srcdir icons/' Recipe
134 ifneq "$(JAVA_UNFINISHED)" "" in puzzles do ln -s unfinished/group.R .
135 ifneq "$(JAVA_UNFINISHED)" "" in puzzles do perl mkfiles.pl
137 # Build the Java applets.
139 in puzzles do make -f Makefile.nestedvm NESTEDVM="$$NESTEDVM" VER=-DVER=$(Version)
143 # Build the Javascript applets. Since my master build machine doesn't
144 # have the right dependencies installed for Emscripten, I do this by a
146 in puzzles do mkdir js # so we can tell output .js files from emcc*.js
148 in puzzles do make -f Makefile.emcc OUTPREFIX=js/ clean
149 in puzzles do make -f Makefile.emcc OUTPREFIX=js/
150 return puzzles/js/*.js
153 # Set up .htaccess containing a redirect for the archive filename.
154 in puzzles do echo "AddType application/octet-stream .chm" > .htaccess
155 in puzzles do echo "AddType application/octet-stream .hlp" >> .htaccess
156 in puzzles do echo "AddType application/octet-stream .cnt" >> .htaccess
157 in . do set -- puzzles*.tar.gz; echo RedirectMatch temp '(.*/)'puzzles.tar.gz '$$1'"$$1" >> puzzles/.htaccess
158 in puzzles do echo RedirectMatch temp '(.*/)'puzzles-installer.msi '$$1'puzzles-$(Version)-installer.msi >> .htaccess
160 # Phew, we're done. Deliver everything!
161 deliver puzzles/icons/*-web.png $@
162 deliver puzzles/winbin/*.exe $@
163 deliver puzzles/.htaccess $@
164 deliver puzzles/doc/*.html doc/$@
165 deliver puzzles/devel/*.html devel/$@
166 deliver puzzles/Puzzles.dmg $@
167 deliver puzzles/puzzles.chm $@
168 deliver puzzles/puzzles.hlp $@
169 deliver puzzles/puzzles.cnt $@
170 deliver puzzles/puzzles.zip $@
171 deliver puzzles/puzzles.msi puzzles-$(Version)-installer.msi
172 deliver puzzles/*.jar java/$@
173 deliver puzzles/js/*.js js/$@
174 deliver puzzles/html/*.html html/$@
175 deliver puzzles/html/*.pl html/$@
176 deliver puzzles/wwwspans.html $@
177 deliver puzzles/wwwlinks.html $@
179 # deliver puzzles/puzzles.armv4.cab $@ # (not built at the moment)
181 # This one isn't in the puzzles subdir, because makedist.sh left it
183 deliver puzzles*.tar.gz $@