]> asedeno.scripts.mit.edu Git - PuTTY.git/blob - Buildscr
Promote 'testbn' to a binary built by the makefiles.
[PuTTY.git] / Buildscr
1 # -*- sh -*-
2 # Build script to construct a full distribution directory of PuTTY.
3
4 module putty
5
6 # Start by figuring out what our version information looks like.
7 #
8 # There are four classes of PuTTY build:
9 #  - a release, which just has an X.YY version number
10 #  - a prerelease, which has an X.YY version number, plus a date and
11 #    version control commit id (and is considered to be 'almost'
12 #    version X.YY)
13 #  - a development snapshot, which just has a date and commit id
14 #  - a custom build, which also has a date and commit id (but is
15 #    labelled differently, to stress that development snapshots are
16 #    built from the checked-in code by the automated nightly script
17 #    whereas custom builds are made manually, perhaps from uncommitted
18 #    changes, e.g. to send to a user for diagnostic or testing
19 #    purposes).
20 #
21 # The four classes of build are triggered by invoking bob with
22 # different command-line variable definitions:
23 #
24 #  - RELEASE=X.YY makes a release build
25 #  - PRERELEASE=X.YY makes a prerelease build (combined with the build
26 #    date and VCS info)
27 #  - setting SNAPSHOT to any non-empty string makes a development
28 #    snapshot
29 #  - setting none of these makes a custom build.
30
31 # If we need a date for our build, start by computing it in the
32 # various forms we need. $(Ndate) is the date in purely numeric form
33 # (YYYYMMDD); $(Date) is separated as YYYY-MM-DD; $(Days) is the
34 # number of days since the epoch.
35 ifeq "$(RELEASE)" "" set Ndate $(!builddate)
36 ifneq "$(Ndate)" "" in . do echo $(Ndate) | perl -pe 's/(....)(..)(..)/$$1-$$2-$$3/' > date
37 ifneq "$(Ndate)" "" read Date date
38 set Epoch 15746 # update this at every release
39 ifneq "$(Ndate)" "" in . do echo $(Ndate) | perl -ne 'use Time::Local; /(....)(..)(..)/ and print timegm(0,0,0,$$3,$$2-1,$$1) / 86400 - $(Epoch)' > days
40 ifneq "$(Ndate)" "" read Days days
41
42 # For any non-release, we're going to need the number of the prior
43 # release, for putting in various places so as to get monotonic
44 # comparisons with the surrounding actual releases.
45 ifeq "$(RELEASE)" "" read Lastver putty/LATEST.VER
46
47 # Set up the textual version strings for the docs build and installer.
48 # We have one of these including the word 'PuTTY', and one without,
49 # which are inconveniently capitalised differently.
50 ifneq "$(RELEASE)" "" set Puttytextver PuTTY release $(RELEASE)
51 ifneq "$(RELEASE)" "" set Textver Release $(RELEASE)
52 ifneq "$(PRERELEASE)" "" set Puttytextver PuTTY pre-release $(PRERELEASE):$(Date).$(vcsid)
53 ifneq "$(PRERELEASE)" "" set Textver Pre-release $(PRERELEASE):$(Date).$(vcsid)
54 ifneq "$(SNAPSHOT)" "" set Puttytextver PuTTY development snapshot $(Date).$(vcsid)
55 ifneq "$(SNAPSHOT)" "" set Textver Development snapshot $(Date).$(vcsid)
56 ifeq "$(RELEASE)$(PRERELEASE)$(SNAPSHOT)" "" set Puttytextver PuTTY custom build $(Date).$(vcsid)
57 ifeq "$(RELEASE)$(PRERELEASE)$(SNAPSHOT)" "" set Textver Custom build $(Date).$(vcsid)
58 set Docmakever VERSION="$(Puttytextver)"
59
60 # Set up the version string for use in the SSH connection greeting.
61 #
62 # We use $(Ndate) rather than $(Date) in the pre-release string to
63 # make sure it's under 40 characters, which is a hard limit in the SSH
64 # protocol spec (and enforced by a compile-time assertion in
65 # version.c).
66 ifneq "$(RELEASE)" "" set Sshver PuTTY-Release-$(RELEASE)
67 ifneq "$(PRERELEASE)" "" set Sshver PuTTY-Prerelease-$(PRERELEASE):$(Ndate).$(vcsid)
68 ifneq "$(SNAPSHOT)" "" set Sshver PuTTY-Snapshot-$(Date).$(vcsid)
69 ifeq "$(RELEASE)$(PRERELEASE)$(SNAPSHOT)" "" set Sshver PuTTY-Custom-$(Date).$(vcsid)
70
71 # Set up the filename suffix for the Unix source archive.
72 ifneq "$(RELEASE)" "" set Uxarcsuffix -$(RELEASE)
73 ifneq "$(PRERELEASE)" "" set Uxarcsuffix -$(PRERELEASE)~pre$(Ndate).$(vcsid)
74 ifneq "$(SNAPSHOT)" "" set Uxarcsuffix -$(Lastver)-$(Date).$(vcsid)
75 ifeq "$(RELEASE)$(PRERELEASE)$(SNAPSHOT)" "" set Uxarcsuffix -custom-$(Date).$(vcsid)
76
77 # Set up the version number for the autoconf system.
78 ifneq "$(RELEASE)" "" set Autoconfver $(RELEASE)
79 ifneq "$(PRERELEASE)" "" set Autoconfver $(PRERELEASE)~pre$(Ndate).$(vcsid)
80 ifneq "$(SNAPSHOT)" "" set Autoconfver $(Lastver)-$(Date).$(vcsid)
81 ifeq "$(RELEASE)$(PRERELEASE)$(SNAPSHOT)" "" set Autoconfver Custom.$(Date).$(vcsid)
82
83 # Set up the filename for the Windows installer.
84 ifneq "$(RELEASE)" "" set Ifilename putty-$(RELEASE)-installer.exe
85 ifneq "$(PRERELEASE)" "" set Ifilename putty-$(PRERELEASE)-pre$(Ndate)-installer.exe
86 ifneq "$(SNAPSHOT)" "" set Ifilename putty-$(Date)-installer.exe
87 ifeq "$(RELEASE)$(PRERELEASE)$(SNAPSHOT)" "" set Ifilename putty-custom-$(Date)-installer.exe
88
89 # Set up the version string for the Windows installer.
90 ifneq "$(RELEASE)" "" set Iversion $(RELEASE)
91 ifneq "$(PRERELEASE)" "" set Iversion $(PRERELEASE)-pre$(Ndate).$(vcsid)
92 ifneq "$(SNAPSHOT)" "" set Iversion $(Date).$(vcsid)
93 ifeq "$(RELEASE)$(PRERELEASE)$(SNAPSHOT)" "" set Iversion Custom-$(Date).$(vcsid)
94
95 # Set up the Windows version resource info, for both the installer and
96 # the individual programs. This must be a sequence of four 16-bit
97 # integers compared lexicographically, and we define it as follows:
98 #
99 #   For release X.YY:                             X.YY.0.0
100 #   For a prerelease before the X.YY release:     (X.YY-1).(DDDDD + 0x8000).0
101 #   For a devel snapshot after the X.YY release:  X.YY.DDDDD.0
102 #   For a custom build:                           X.YY.DDDDD.1
103 #
104 # where DDDDD is a representation of the build date, in the form of a
105 # number of days since an epoch date. The epoch is reset at every
106 # release (which, with 15 bits, gives us a comfortable 80-odd years
107 # before it becomes vital to make another release to reset the count
108 # :-).
109
110 ifneq "$(RELEASE)" "" in . do echo $(RELEASE).0.0 > winver
111 ifneq "$(PRERELEASE)" "" in . do perl -e 'printf "%s.%d.0", $$ARGV[0], 0x8000+$$ARGV[1]' $(Lastver) $(Days) > winver
112 ifneq "$(SNAPSHOT)" "" in . do perl -e 'printf "%s.%d.0", $$ARGV[0], $$ARGV[1]' $(Lastver) $(Days) > winver
113 ifeq "$(RELEASE)$(PRERELEASE)$(SNAPSHOT)" "" in . do perl -e 'printf "%s.%d.1", $$ARGV[0], $$ARGV[1]' $(Lastver) $(Days) > winver
114 in . do perl -pe 'y!.!,!' winver > winvercommas
115 read Winver winver
116 read Winvercommas winvercommas
117
118 # Write out a version.h that contains the real version number.
119 in putty do echo '/* Generated by automated build script */' > version.h
120 ifneq "$(RELEASE)" "" in putty do echo '$#define RELEASE $(RELEASE)' >> version.h
121 ifneq "$(PRERELEASE)" "" in putty do echo '$#define PRERELEASE $(PRERELEASE)' >> version.h
122 ifneq "$(SNAPSHOT)" "" in putty do echo '$#define SNAPSHOT' >> version.h
123 in putty do echo '$#define TEXTVER "$(Textver)"' >> version.h
124 in putty do echo '$#define SSHVER "$(Sshver)"' >> version.h
125 in putty do echo '$#define BINARY_VERSION $(Winvercommas)' >> version.h
126
127 # Set up the extra arguments for the main Windows nmake command. The
128 # user can define XFLAGS and MAKEARGS on the bob command line, to pass
129 # in extra compile and make options respectively (e.g. to do a
130 # debugging or Minefield build).
131 set Makeargs
132 ifneq "$(XFLAGS)" "" set Makeargs $(Makeargs) XFLAGS="$(XFLAGS)"
133 ifneq "$(MAKEARGS)" "" set Makeargs $(Makeargs) $(MAKEARGS)
134
135 in putty do ./mksrcarc.sh
136 in putty do ./mkunxarc.sh '$(Autoconfver)' '$(Uxarcsuffix)' $(Docmakever)
137 in putty do perl mkfiles.pl
138 in putty/doc do make $(Docmakever) putty.hlp
139 in putty/doc do make $(Docmakever) chm
140
141 # Munge the installer script locally so that it reports the version
142 # we're really building.
143 in putty/windows do perl -i~ -pe 'BEGIN{$$a=shift@ARGV;}s/^(AppVerName=).*$$/$$1$$a/' '$(Puttytextver)' putty.iss
144 in putty/windows do perl -i~ -pe 'BEGIN{$$a=shift@ARGV;}s/^(VersionInfoTextVersion=).*$$/$$1$$a/' '$(Textver)' putty.iss
145 in putty/windows do perl -i~ -pe 'BEGIN{$$a=shift@ARGV;}s/^(AppVersion=).*$$/$$1$$a/' '$(Iversion)' putty.iss
146 in putty/windows do perl -i~ -pe 'BEGIN{$$a=shift@ARGV;}s/^(VersionInfoVersion=)\d+\.\d+\.\d+\.\d+\r?$$/$$1$$a/' '$(Winver)' putty.iss
147
148 # Windowsify LICENCE, since it's going in the Windows installer.
149 in putty do perl -i~ -pe 'y/\015//d;s/$$/\015/' LICENCE
150
151 delegate windows
152   # FIXME: Cygwin alternative?
153   in putty/windows do/win vcvars32 && nmake -f Makefile.vc $(Makeargs) all cleantestprogs
154   # Code-sign the binaries, if the local bob config provides a script
155   # to do so. We assume here that the script accepts an -i option to
156   # provide a 'more info' URL, and an optional -n option to provide a
157   # program name, and that it can take multiple .exe filename
158   # arguments and sign them all in place.
159   ifneq "$(winsigncode)" "" in putty/windows do $(winsigncode) -i http://www.chiark.greenend.org.uk/~sgtatham/putty/ *.exe
160   # Ignore exit code from hhc, in favour of seeing whether the .chm
161   # file was created. (Yuck; but hhc appears to return non-zero
162   # exit codes on whim.)
163   in putty/doc do/win hhc putty.hhp & type putty.chm >nul
164   in putty/windows do/win iscc putty.iss
165   ifneq "$(winsigncode)" "" in putty/windows do $(winsigncode) -i http://www.chiark.greenend.org.uk/~sgtatham/putty/ -n "PuTTY Installer" Output/setup.exe
166   return putty/windows/*.exe
167   return putty/windows/*.map
168   return putty/doc/putty.chm
169   return putty/windows/Output/setup.exe
170 enddelegate
171 in putty/doc do make mostlyclean
172 in putty/doc do make $(Docmakever)
173 in putty/windows do zip -k -j putty.zip `ls *.exe | grep -v puttytel` ../doc/putty.chm ../doc/putty.hlp ../doc/putty.cnt
174 in putty/doc do zip puttydoc.zip *.html
175
176 # Deliver the actual PuTTY release directory into a subdir `putty'.
177 deliver putty/windows/*.exe putty/x86/$@
178 deliver putty/windows/putty.zip putty/x86/$@
179 deliver putty/windows/Output/setup.exe putty/x86/$(Ifilename)
180 deliver putty/doc/puttydoc.zip putty/$@
181 deliver putty/doc/putty.chm putty/$@
182 deliver putty/doc/putty.hlp putty/$@
183 deliver putty/doc/putty.cnt putty/$@
184 deliver putty/doc/puttydoc.txt putty/$@
185 deliver putty/doc/*.html putty/htmldoc/$@
186 deliver putty/putty-src.zip putty/$@
187 deliver putty/*.tar.gz putty/$@
188
189 # Deliver the map files alongside the `proper' release deliverables.
190 deliver putty/windows/*.map maps-x86/$@
191
192 # Deliver sign.sh, so that whoever has just built PuTTY (the
193 # snapshot scripts or me, depending) can conveniently sign it with
194 # whatever key they want.
195 deliver putty/sign.sh $@
196
197 # Create files of cryptographic checksums, which will be signed along
198 # with the files they verify. We've provided MD5 checksums for a
199 # while, but now MD5 is looking iffy, we're expanding our selection.
200 #
201 # Creating these files is most easily done in the destination
202 # directory, where all the files we're delivering are already in their
203 # final relative layout.
204 in-dest putty do a=`\find * -type f -print`; md5sum $$a > md5sums && sha1sum $$a > sha1sums && sha256sum $$a > sha256sums && sha512sum $$a > sha512sums
205
206 # And construct .htaccess files. One in the top-level directory,
207 # setting the MIME types for Windows help files and providing an
208 # appropriate link to the source archive:
209 in-dest putty do echo "AddType application/octet-stream .chm" >> .htaccess
210 in-dest putty do echo "AddType application/octet-stream .hlp" >> .htaccess
211 in-dest putty do echo "AddType application/octet-stream .cnt" >> .htaccess
212 in-dest putty do set -- putty*.tar.gz; for k in '' .gpg; do echo RedirectMatch temp '(.*/)'putty.tar.gz$$k\$$ '$$1'"$$1$$k" >> .htaccess; done
213 # And one in the x86 directory, providing a link for the installer.
214 in-dest putty/x86 do set -- putty*installer.exe; for k in '' .gpg; do echo RedirectMatch temp '(.*/)'putty-installer.exe$$k\$$ '$$1'"$$1$$k" >> .htaccess; done