chiark / gitweb /
Tents: mark squares as non-tents with {Shift,Control}-cursor keys.
[sgt-puzzles.git] / Buildscr
1 # -*- sh -*-
2 # Build script to build Puzzles.
3
4 module puzzles
5
6 set Version $(!builddate).$(vcsid)
7
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~
11
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
16
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
20
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
24 # them!)
25 in puzzles do perl -i -pe 's/Unidentified build/$(Version)/' osx-info.plist
26
27 # First build some local binaries, to run the icon build.
28 in puzzles do perl mkfiles.pl -U
29 in puzzles do make
30
31 # Now build the screenshots and icons.
32 in puzzles/icons do xvfb-run -s "-screen 0 1024x768x24" make web winicons gtkicons
33
34 # Destroy the local binaries and autoconf detritus, mostly to avoid
35 # wasting network bandwidth by transferring them to the delegate
36 # servers.
37 in puzzles do make distclean
38
39 # Re-run mkfiles.pl now that it knows the icons are there.
40 in puzzles do perl mkfiles.pl
41
42 # Rebuild the configure script.
43 in puzzles do ./mkauto.sh
44
45 # Build the OS X .dmg archive.
46 delegate osx
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
50 enddelegate
51
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 chm
55 in puzzles do make -f Makefile.doc # build help file for installer
56 in puzzles do perl winiss.pl $(Version) gamedesc.txt > puzzles.iss
57 delegate windows
58   # Ignore the poorly controlled return value from HHC, and instead
59   # just test that the output file was generated.
60   in puzzles do hhc puzzles.hhp; test -f puzzles.chm
61   # FIXME: Cygwin alternative?
62   in puzzles do cmd /c 'vcvars32 & nmake -f Makefile.vc clean'
63   in puzzles do cmd /c 'vcvars32 & nmake -f Makefile.vc VER=-DVER=$(Version)'
64   # Build installer.
65   in puzzles do iscc puzzles.iss
66   return puzzles/puzzles.chm
67   return puzzles/*.exe
68   return puzzles/Output/setup.exe
69 enddelegate
70 in puzzles do chmod +x *.exe
71
72 # Build the Pocket PC binaries and CAB.
73 #
74 # NOTE: This part of the build script requires the Windows delegate
75 # server to have the cabwiz program on its PATH. This will
76 # typically be at
77 #
78 #   C:\Program Files\Windows CE Tools\WCE420\POCKET PC 2003\Tools
79 #
80 # but it might not be if you've installed it somewhere else, or
81 # have a different version.
82 #
83 # NOTE ALSO: This part of the build is commented out, for the
84 # moment, because cabwiz does unhelpful things when run from within
85 # a bob delegate process (or, more generally, when run from any
86 # terminal-based remote login to a Windows machine, including
87 # Cygwin opensshd and Windows Telnet). The symptom is that cabwiz
88 # just beeps and sits there. Until I figure out how to build the
89 # .cab from an automated process (and I'm willing to consider silly
90 # approaches such as a third-party CAB generator), I don't think I
91 # can sensibly enable this build.
92
93 #in puzzles do perl wceinf.pl gamedesc.txt > puzzles.inf
94 #delegate windows
95 #  in puzzles do cmd /c 'wcearmv4 & nmake -f Makefile.wce clean'
96 #  in puzzles do cmd /c 'wcearmv4 & nmake -f Makefile.wce VER=-DVER=$(Version)'
97 #  # Nasty piece of sh here which saves the return code from cabwiz,
98 #  # outputs its errors and/or warnings, and then propagates the
99 #  # return code back to bob. If only cabwiz could output to
100 #  # standard error LIKE EVERY OTHER COMMAND-LINE UTILITY IN THE
101 #  # WORLD, I wouldn't have to do this.
102 #  in puzzles do cat puzzles.inf
103 #  in puzzles do cmd /c 'wcearmv4 & bash -c cabwiz puzzles.inf /err cabwiz.err /cpu ARMV4'; a=$$?; cat cabwiz.err; exit $$a
104 #  return puzzles/puzzles.armv4.cab
105 #enddelegate
106
107 # Build the help file and the HTML docs.
108 in puzzles do make -f Makefile.doc clean # remove CHM-target HTML
109 in puzzles do make -f Makefile.doc # and rebuild help file...
110 in puzzles do mkdir doc
111 in puzzles do mkdir devel
112 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
113 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
114
115 # Move the deliver-worthy Windows binaries (those specified in
116 # gamedesc.txt, which is generated by mkfiles.pl and helpfully
117 # excludes the command-line auxiliary utilities such as solosolver,
118 # and nullgame.exe) into a subdirectory for easy access.
119 in puzzles do mkdir winbin
120 in puzzles do mv `cut -f2 -d: gamedesc.txt` winbin
121
122 # Make a zip file of the Windows binaries and help files.
123 in puzzles do zip -j puzzles.zip winbin/*.exe puzzles.chm puzzles.hlp puzzles.cnt
124
125 # Create the source archive. (That writes the archive into the
126 # _parent_ directory, so be careful when we deliver it.)
127 in puzzles do ./makedist.sh $(Version)
128
129 # Build the autogenerated pieces of the main web page.
130 in puzzles do perl webpage.pl
131
132 ifneq "$(JAVA_UNFINISHED)" "" in puzzles do perl -i~ -pe 'print "!srcdir unfinished/\n" if /!srcdir icons/' Recipe
133 ifneq "$(JAVA_UNFINISHED)" "" in puzzles do ln -s unfinished/group.R .
134 ifneq "$(JAVA_UNFINISHED)" "" in puzzles do perl mkfiles.pl
135
136 # Build the Java applets.
137 delegate nestedvm
138   in puzzles do make -f Makefile.nestedvm NESTEDVM="$$NESTEDVM" VER=-DVER=$(Version)
139   return puzzles/*.jar
140 enddelegate
141
142 # Build the Javascript applets. Since my master build machine doesn't
143 # have the right dependencies installed for Emscripten, I do this by a
144 # delegation.
145 in puzzles do mkdir js # so we can tell output .js files from emcc*.js
146 delegate emscripten
147   in puzzles do make -f Makefile.emcc OUTPREFIX=js/ clean
148   in puzzles do make -f Makefile.emcc OUTPREFIX=js/
149   return puzzles/js/*.js
150 enddelegate
151
152 # Set up .htaccess containing a redirect for the archive filename.
153 in puzzles do echo "AddType application/octet-stream .chm" > .htaccess
154 in puzzles do echo "AddType application/octet-stream .hlp" >> .htaccess
155 in puzzles do echo "AddType application/octet-stream .cnt" >> .htaccess
156 in . do set -- puzzles*.tar.gz; echo RedirectMatch temp '(.*/)'puzzles.tar.gz '$$1'"$$1" >> puzzles/.htaccess
157 in puzzles do echo RedirectMatch temp '(.*/)'puzzles-installer.exe '$$1'puzzles-$(Version)-installer.exe >> .htaccess
158
159 # Phew, we're done. Deliver everything!
160 deliver puzzles/icons/*-web.png $@
161 deliver puzzles/winbin/*.exe $@
162 deliver puzzles/.htaccess $@
163 deliver puzzles/doc/*.html doc/$@
164 deliver puzzles/devel/*.html devel/$@
165 deliver puzzles/Puzzles.dmg $@
166 deliver puzzles/puzzles.chm $@
167 deliver puzzles/puzzles.hlp $@
168 deliver puzzles/puzzles.cnt $@
169 deliver puzzles/puzzles.zip $@
170 deliver puzzles/Output/setup.exe puzzles-$(Version)-installer.exe
171 deliver puzzles/*.jar java/$@
172 deliver puzzles/js/*.js js/$@
173 deliver puzzles/html/*.html html/$@
174 deliver puzzles/html/*.pl html/$@
175 deliver puzzles/wwwspans.html $@
176 deliver puzzles/wwwlinks.html $@
177
178 # deliver puzzles/puzzles.armv4.cab $@ # (not built at the moment)
179
180 # This one isn't in the puzzles subdir, because makedist.sh left it
181 # one level up.
182 deliver puzzles*.tar.gz $@