Fiddle further with .htaccess: add some $s on the ends of the
[u/mdw/putty] / Buildscr
1 # -*- sh -*-
2 # Build script to construct a full distribution directory of PuTTY.
3
4 module putty
5
6 # Set up the arguments for the main make command.
7 set Makever -DSVN_REV=$(revision)
8 ifneq "$(RELEASE)" "" set Makever $(Makever) -DRELEASE=$(RELEASE)
9 ifneq "$(date)" "" set Makever $(Makever) -DSNAPSHOT=$(date)
10 set Makeargs VER="$(Makever)"
11 ifneq "$(XFLAGS)" "" set Makeargs $(makeargs) XFLAGS="$(XFLAGS)"
12 ifneq "$(MAKEARGS)" "" set Makeargs $(makeargs) $(MAKEARGS)
13
14 # Set up the version string for the docs build.
15 set Docmakeargs VERSION="PuTTY revision $(revision)"
16 ifneq "$(RELEASE)" "" set Docmakeargs VERSION="PuTTY release $(RELEASE)"
17 ifneq "$(date)" "" set Docmakeaargs VERSION="PuTTY development snapshot $(date)"
18
19 # Set up the version string for the Unix source archive.
20 set Unxver r$(revision)
21 ifneq "$(RELEASE)" "" set Unxver $(RELEASE)
22 ifneq "$(date)" "" set Unxver $(date)
23
24 # Set up the various version strings for the installer.
25 set Iversion r$(revision)
26 set Iname PuTTY revision $(revision)
27 set Ivertext Revision $(revision)
28 set Irev $(revision)
29 set Ifilename putty-$(Iversion)-installer.exe
30 ifneq "$(RELEASE)" "" set Iversion $(RELEASE)
31 ifneq "$(RELEASE)" "" set Iname PuTTY version $(RELEASE)
32 ifneq "$(RELEASE)" "" set Ivertext Release $(RELEASE)
33 ifneq "$(RELEASE)" "" set Irev 0
34 ifneq "$(RELEASE)" "" set Ifilename putty-$(RELEASE)-installer.exe
35 ifneq "$(date)" "" set Iversion $(date):r$(revision)
36 ifneq "$(date)" "" set Iname PuTTY development snapshot $(date):r$(revision)
37 ifneq "$(date)" "" set Ivertext Development snapshot $(date):r$(revision)
38 ifneq "$(date)" "" set Ifilename putty-$(date)-installer.exe
39
40 # Set up the version string for the installer.
41 set Iversion r$(revision)
42 ifneq "$(RELEASE)" "" set Iversion $(RELEASE)
43 ifneq "$(date)" "" set Iversion $(date):r$(revision)
44
45 in putty do ./mksrcarc.sh
46 in putty do ./mkunxarc.sh $(Unxver)
47 in putty do perl mkfiles.pl
48 in putty/doc do make $(Docmakeargs) putty.hlp
49 in putty/doc do make $(Docmakeargs) chm
50
51 # Munge the installer script locally so that it reports the version
52 # we're really building.
53 in putty/windows do perl -i~ -pe 'BEGIN{$$a=shift@ARGV;}s/^(AppVerName=).*$$/$$1$$a/' '$(Iname)' putty.iss
54 in putty/windows do perl -i~ -pe 'BEGIN{$$a=shift@ARGV;}s/^(VersionInfoTextVersion=).*$$/$$1$$a/' '$(Ivertext)' putty.iss
55 in putty/windows do perl -i~ -pe 'BEGIN{$$a=shift@ARGV;}s/^(AppVersion=).*$$/$$1$$a/' '$(Iversion)' putty.iss
56 in putty/windows do perl -i~ -pe 'BEGIN{$$a=shift@ARGV;$$a=~s/M//;}s/^(VersionInfoVersion=\d+\.\d+\.)\d+(\.\d+)\r?$$/$$1$$a$$2/' '$(Irev)' putty.iss
57
58 delegate windows
59 # FIXME: Cygwin alternative?
60 in putty/windows do cmd /c vcvars32 \& nmake -f Makefile.vc $(Makeargs)
61 # Ignore exit code from hhc, in favour of seeing whether the .chm
62 # file was created. (Yuck; but hhc appears to return non-zero
63 # exit codes on whim.)
64 in putty/doc do hhc putty.hhp; test -f putty.chm
65 in putty/windows do iscc putty.iss
66 return putty/windows/*.exe
67 return putty/windows/*.map
68 return putty/doc/putty.chm
69 return putty/windows/Output/setup.exe
70 enddelegate
71 in putty/doc do make mostlyclean
72 in putty/doc do make $(Docmakeargs)
73 in putty/windows do zip -k -j putty.zip `ls *.exe | grep -v puttytel` ../doc/putty.chm ../doc/putty.hlp ../doc/putty.cnt
74 in putty/doc do zip puttydoc.zip *.html
75
76 deliver putty/windows/*.exe x86/$@
77 deliver putty/windows/putty.zip x86/$@
78 deliver putty/windows/Output/setup.exe x86/$(Ifilename)
79 deliver putty/doc/puttydoc.zip $@
80 deliver putty/doc/putty.chm $@
81 deliver putty/doc/putty.hlp $@
82 deliver putty/doc/putty.cnt $@
83 deliver putty/doc/puttydoc.txt $@
84 deliver putty/doc/*.html htmldoc/$@
85 deliver putty/putty-src.zip $@
86 deliver putty/*.tar.gz $@
87
88 # Building the md5sums file is most easily done in the destination
89 # directory.
90 in-dest . do md5sum `\find * -type f -print` > md5sums
91
92 # Now deliver the map files _after_ we do that, so we don't md5sum
93 # them gratuitously.
94 deliver putty/windows/*.map maps-x86/$@
95
96 # And construct .htaccess files. One in the top-level directory,
97 # setting the MIME types for Windows help files and providing an
98 # appropriate link to the source archive:
99 in-dest . do echo "AddType application/octet-stream .chm" >> .htaccess
100 in-dest . do echo "AddType application/octet-stream .hlp" >> .htaccess
101 in-dest . do echo "AddType application/octet-stream .cnt" >> .htaccess
102 in-dest . do set -- putty*.tar.gz; for k in '' .DSA .RSA; do echo RedirectMatch temp '(.*/)'putty.tar.gz$$k\$$ '$$1'"$$1$$k" >> .htaccess; done
103 # And one in the x86 directory, providing a link for the installer.
104 in-dest x86 do set -- putty*installer.exe; for k in '' .DSA .RSA; do echo RedirectMatch temp '(.*/)'putty-installer.exe$$k\$$ '$$1'"$$1$$k" >> .htaccess; done