]> git.saurik.com Git - wxWidgets.git/blob - utils/configtool/scripts/makesetup.sh
Fix for crash when wxUSE_STL=1. wxDocument::DeleteAllViews might
[wxWidgets.git] / utils / configtool / scripts / makesetup.sh
1 #!/bin/sh
2
3 # Make a distribution of an application.
4
5 # If your zip accepts Cygwin-style paths, then
6 # use cygpath, else substitute echo
7 CYGPATHPROG=cygpath
8 #CYGPATHPROG=echo
9
10 PROGNAME=$0
11 SCRIPTDIR=`pwd`
12
13 . $SCRIPTDIR/setup.var
14
15 # Set this to the required version
16 VERSION=
17
18 doreplace()
19 {
20 thefile=$1
21 theexpr=$2
22
23 if [ -f $thefile ]; then
24 sed -e "$theexpr" < $thefile > $thefile.tmp
25 mv $thefile.tmp $thefile
26 else
27 echo "*** $thefile not found."
28 fi
29 }
30
31 unix2dosname()
32 {
33 echo $1 | sed -e "s/\//\\\\\\\/g" > /tmp/filename.tmp
34 RETVALUE=`cat /tmp/filename.tmp`
35 rm -f /tmp/filename.tmp
36 }
37
38 unix2dosname2()
39 {
40 echo $1 | sed -e "s/\//\\\\/g" > /tmp/filename.tmp
41 RETVALUE=`cat /tmp/filename.tmp`
42 rm -f /tmp/filename.tmp
43 }
44
45 findversion()
46 {
47 echo "#include <stdio.h>" > /tmp/appver.c
48 echo "#include \"$VERSIONSYMBOLFILE\"" >> /tmp/appver.c
49 echo "int main() { printf(\"%.2f\", $VERSIONSYMBOL); }" >> /tmp/appver.c
50 gcc /tmp/appver.c -I$APPDIR -o /tmp/appver
51 VERSION=`/tmp/appver`
52 rm -f /tmp/appver /tmp/appver.c
53 }
54
55 makesetup()
56 {
57 if [ -d $SETUPIMAGEDIR ]; then
58 echo Removing existing $SETUPIMAGEDIR
59 rm -f -r $SETUPIMAGEDIR
60 fi
61
62 echo Making the $SETUPIMAGEDIR for preparing the setup
63 mkdir -p $SETUPIMAGEDIR
64
65 if [ -f $READMEFILE ]; then
66 echo Copying readme.txt
67 cp $READMEFILE $SETUPIMAGEDIR
68 else
69 echo "*** Warning - $READMEFILE not found"
70 fi
71
72 if [ -f $LICENSEFILE ]; then
73 echo Copying licence.txt
74 cp $LICENSEFILE $SETUPIMAGEDIR
75 else
76 echo "*** Warning - $LICENSEFILE not found"
77 fi
78
79 cp $APPDIR/docs/gpl.txt $SETUPIMAGEDIR
80 cp $APPDIR/docs/lgpl.txt $SETUPIMAGEDIR
81 cp $APPDIR/docs/licendoc.txt $SETUPIMAGEDIR
82
83 echo Copying sample configuration settings file...
84 cp $APPDIR/configs/wxwin250.wxs $SETUPIMAGEDIR
85
86 if [ "$RESOURCESFILE" != "" ] && [ "$RESOURCESDIR" != "" ]; then
87 if [ -d $RESOURCESDIR ]; then
88 cd $RESOURCESDIR
89 echo Compiling resource file $RESOURCESFILE
90 zip $SETUPIMAGEDIR/$RESOURCESFILE *
91 else
92 echo "*** Warning - $RESOURCESDIR directory not found"
93 fi
94 fi
95
96 if [ "$MAKEMANUAL" != "0" ]; then
97 if [ -d $MANUALDIR ]; then
98 cd $MANUALDIR
99 make
100
101 for EACHFILE in $MANUALFILES ; do
102 if [ -f $EACHFILE ]; then
103 echo Copying $EACHFILE
104 cp $EACHFILE $SETUPIMAGEDIR
105 else
106 echo "*** Warning - $EACHFILE not found"
107 fi
108 done
109 else
110 echo "*** Warning - $MANUALDIR not found"
111 fi
112 fi
113
114 if [ -f $WXMANUALCHM ]; then
115 echo Copying wxWindows manual $WXMANUALCHM
116 cp $WXMANUALCHM $SETUPIMAGEDIR
117 else
118 echo "*** Warning - $WXMANUALCHM not found"
119 fi
120
121 if [ -f $APPBINARY ]; then
122 echo Copying binary $APPBINARY
123 cp $APPBINARY $SETUPIMAGEDIR
124 else
125 echo "*** Error - $APPBINARY not found"
126 exit 1
127 fi
128
129 if [ "$UPX" != "0" ]; then
130 echo Compressing binary
131 upx $SETUPIMAGEDIR/`basename $APPBINARY`
132 fi
133
134 # Time to regenerate the Inno Install script
135 if [ "$INNO" != "0" ]; then
136 echo Generating $SETUPSCRIPTNAME
137 rm -f $SETUPSCRIPTNAME
138
139 sh $SCRIPTDIR/makeinno.sh $SETUPIMAGEDIR $INNOTOP $INNOBOTTOM $SETUPSCRIPTNAME
140
141 if [ ! -f $SETUPSCRIPTNAME ]; then
142 echo "*** Error - something went wrong with the script file generation."
143 exit 1
144 fi
145
146 # Now replace %VERSION% with the real application version, and other
147 # variables
148 echo Replacing variables in the setup script
149 doreplace $SETUPSCRIPTNAME "s/%VERSION%/$VERSION/g"
150 doreplace $SETUPSCRIPTNAME "s/%COPYRIGHTHOLDER%/$AUTHOR/g"
151 doreplace $SETUPSCRIPTNAME "s/%VENDOR%/$VENDOR/g"
152
153 unix2dosname $READMEFILE
154 doreplace $SETUPSCRIPTNAME "s;%READMEFILE%;$RETVALUE;g"
155
156 unix2dosname $READMEAFTERFILE
157 doreplace $SETUPSCRIPTNAME "s;%READMEAFTERFILE%;$RETVALUE;g"
158
159 unix2dosname $LICENSEFILE
160 doreplace $SETUPSCRIPTNAME "s;%LICENSEFILE%;$RETVALUE;g"
161
162 doreplace $SETUPSCRIPTNAME "s/%APPNAME%/$APPNAME/g"
163 doreplace $SETUPSCRIPTNAME "s/%APPTITLE%/$APPTITLE/g"
164
165 unix2dosname $SETUPIMAGEDIR
166 doreplace $SETUPSCRIPTNAME "s;%SOURCEDIR%;$RETVALUE;g"
167
168 unix2dosname $DESTDIR
169 doreplace $SETUPSCRIPTNAME "s;%OUTPUTDIR%;$RETVALUE;g"
170
171 doreplace $SETUPSCRIPTNAME "s/%APPEXTENSION%/$APPEXTENSION/g"
172
173 # FIXME: how do we get the first name in the list?
174 if [ "$MANUALFILES" != "" ]; then
175 HELPFILE=`basename $MANUALFILES`
176 unix2dosname $HELPFILE
177 doreplace $SETUPSCRIPTNAME "s;%HELPFILE%;$RETVALUE;g"
178 fi
179 fi
180
181 rm -f $DESTDIR/setup*.*
182
183 # Inno Setup complains if this step is not done
184 unix2dos --unix2dos $SETUPSCRIPTNAME
185
186 # Now invoke INNO compiler on the new ISS file
187 # First, make a DOS filename or Inno Setup will get confused.
188
189 unix2dosname2 $SETUPSCRIPTNAME
190 DOSFILENAME=$RETVALUE
191
192 # Note: the double slash is Mingw32/MSYS convention for
193 # denoting a switch, that must not be converted into
194 # a path (otherwise /c = c:/)
195
196 cd `dirname $SETUPSCRIPTNAME`
197 BASESCRIPTNAME=`basename $SETUPSCRIPTNAME`
198 echo Invoking Inno Setup compiler on $BASESCRIPTNAME
199
200 "$SETUPCOMPILER" //cc $BASESCRIPTNAME
201
202 if [ ! -f $DESTDIR/setup.exe ]; then
203 echo "*** Error - the setup.exe was not generated."
204 exit
205 fi
206
207 cd $DESTDIR
208 mv setup.exe $APPNAME-$VERSION-setup.exe
209
210 echo If you saw no warnings or errors, $APPTITLE was successfully spun.
211 echo
212 }
213
214 # We can't use e.g. this:
215 # ls `cat $SRC/distrib/msw/makefile.rsp` zip -@ -u $DEST/wxWindows-$VERSION-gen.zip
216 # because there's not enough space on the command line, plus we need to ignore the
217 # blank lines.
218 # So if we need to (not in this script so far) we do something like this instead:
219 # expandlines $SRC/setup/files.rsp temp.txt
220 # zip -@ `$CYGPATHPROG -w $DEST/archive.zip` < temp.txt
221
222 expandlines()
223 {
224 toexpand=$1
225 outputfile=$2
226
227 rm -f $outputfile
228 touch $outputfile
229 for line in `cat $toexpand` ; do
230 if [ $line != "" ]; then
231 ls $line >> $outputfile
232 fi
233 done
234 }
235
236 usage()
237 {
238 echo "Usage: $PROGNAME [ options ]" 1>&2
239 echo Options:
240 echo " --help Display this help message"
241 echo " --upx Compress executable with UPX"
242 echo " --no-upx Do not compress executable with UPX"
243 echo " --inno Build the setup.exe"
244 echo " --no-inno Do not build the setup.exe"
245 echo.
246 echo Note that options only override settings in $SCRIPTDIR/setup.var.
247 exit 1
248 }
249
250 # Process command line options.
251
252 for i in "$@"; do
253 case "$i" in
254 --inno) INNO=1 ;;
255 --no-inno) INNO=0 ;;
256 --upx) UPX=1 ;;
257 --no-upx) UPX=0 ;;
258 *)
259 usage
260 exit
261 ;;
262 esac
263 done
264
265 findversion
266 makesetup
267