]> git.saurik.com Git - wxWidgets.git/blame - wxPython/distrib/mac/wxPythonOSX/build
reSWIGged
[wxWidgets.git] / wxPython / distrib / mac / wxPythonOSX / build
CommitLineData
1e4a197e
RD
1#!/bin/sh -e
2#----------------------------------------------------------------------
3# Build wxMac and wxPythonOSX from the tarball and then make an
4# Installer package out of it.
5
6spectemplate=distrib/wxPythonFull.spec.in
7
8if [ ! -d wxPython -o ! -e ${spectemplate} ]; then
9 echo "Please run this script from the root wxPython directory."
10 exit 1
11fi
12
13#----------------------------------------------------------------------
14# Check Parameters
15
16function usage {
17 echo ""
18 echo "Usage: $0 wx_version py_version [command flags...]"
19 echo " wx_version String to use for version in filenames, etc."
20 echo " py_version String to append to python (which python version to use.)"
21 echo ""
22 echo "command flags:"
23 echo " skiptar Don't unpack the tarball"
24 echo " use_cvs Use the CVS workspace instead of a tarfile"
25 echo " skipconfig Don't run configure"
26 echo " skipbuild Don't build wxWindows or wxPython"
27 echo " skipinstall Don't do the installation step"
28 echo " skipdmg Don't make the package or diskimage"
29 echo " skipclean Don't do the cleanup at the end"
30}
31
32
33if [ $# -lt 2 ]; then
34 usage
35 exit 1
36fi
37
38VERSION=$1
39PYVER=$2
40shift;shift
41
42
43for flag in $*; do
44 case ${flag} in
45 skiptar) skiptar=1 ;;
46 use_cvs) skiptar=1; use_cvs=1 ;;
47 skipconfig) skipconfig=1; skiptar=1 ;;
48 skipbuild) skipbuild=1; skipconfig=1; skiptar=1 ;;
49 skipinstall) skipinstall=1 ;;
50 skipdmg) skipdmg=1 ;;
51 skipclean) skipclean=1 ;;
52
53 *) echo "Unknown flag \"${flag}\""
54 usage
55 exit 1
56 esac
57done
58
59
60SRCDIR=/Volumes/Gate.Stuff/Development/wxPython/dist/$VERSION
61TARBALL=$SRCDIR/wxPythonSrc-$VERSION.tar.gz
62SITEPACKAGES=/Library/Frameworks/Python.framework/Versions/$PYVER/lib/python$PYVER/site-packages
63
64# TODO: Should I change the prefix to /usr?
65PREFIX=/usr/local
66
67PROGDIR="`dirname \"$0\"`"
68TMPDIR=$PWD/_build_dmg
69
70BUILDROOT=$TMPDIR/build
71INSTALLROOT=$TMPDIR/install
72INSTALLDEVEL=$TMPDIR/install-devel
73DMGDIR=$TMPDIR/dmg
74RESOURCEDIR=$PROGDIR/resources
75DESTDIR=$PWD/dist
76
77
78
79#----------------------------------------------------------------------
80# Setup builddirs
81
82mkdir -p $BUILDROOT
83mkdir -p $INSTALLROOT
84mkdir -p $INSTALLDEVEL
85rm -rf $DMGDIR
86mkdir -p $DMGDIR/root
87
88pushd $BUILDROOT
89
90
91#----------------------------------------------------------------------
92# Unpack the tarball
93
94if [ -z "$skiptar" ]; then
95 tar xzvf $TARBALL
96fi
97
98if [ "$use_cvs" = 1 ]; then
99 # copy the cvs workspace, except for build dirs
100
101 mkdir -p wxPythonSrc-$VERSION
102
103 echo Finding updated files...
104 if [ -e .last_copy ]; then
105 FEXPR="-cnewer .last_copy"
106 fi
107 find /projects/wx $FEXPR -print \
108 | grep -v wx/build \
109 | grep -v wxPython/build \
110 | grep -v wxPython/_build \
111 | grep -v CVS \
112 | cut -b 14- > filelist
113
114 for x in `cat filelist`; do
115 if [ -d "/projects/wx/$x" ]; then
116 mkdir -p "wxPythonSrc-$VERSION/$x"
117 else
118 echo $x
119 cp -p "/projects/wx/$x" "wxPythonSrc-$VERSION/$x"
120 fi
121 done
122
123 touch .last_copy
124fi
125
126
127cd wxPythonSrc-$VERSION
128WXDIR=`pwd`
129mkdir -p $WXDIR/build
130cd $WXDIR/build
131
132#----------------------------------------------------------------------
133
134
135# Configure wxWindows
136if [ -z "$skipconfig" ]; then
137 ../configure --with-mac --prefix=$PREFIX \
138 --with-opengl \
139 --enable-precomp=no \
140 --enable-geometry \
141 --enable-optimise \
1e4a197e
RD
142 --with-libjpeg=builtin \
143 --with-libpng=builtin \
144 --with-libtiff=builtin \
8b9a4190
RD
145
146
147# --with-zlib=builtin
148# --enable-debug_flag
1e4a197e
RD
149
150fi
151
152# Build wxWindows and wxPython
153if [ -z "$skipbuild" ]; then
154 make
155
156 cd $WXDIR/wxPython
157 python$PYVER setup.py \
158 IN_CVS_TREE=1 \
159 WX_CONFIG="$WXDIR/build/wx-config --prefix=$WXDIR --exec-prefix=$WXDIR/build" \
160 build
161
162
163 # Build wxrc (XRC resource tool) but don't use the makefiles since they expect
164 # a shared version of the xrc lib to have been built...
165 cd $WXDIR/contrib/utils/wxrc
166 WX_CONFIG="$WXDIR/build/wx-config --prefix=$WXDIR --exec-prefix=$WXDIR/build"
167 wCC=`$WX_CONFIG --cc`
168 wCXX=`$WX_CONFIG --cxx`
169
170 for f in wxrc.cpp ../../src/xrc/*.cpp; do
171 echo $f
172 $wCXX `$WX_CONFIG --cxxflags` -I ../../include -I ../../src/xrc/expat/xmlparse -I ../../src/xrc/expat/xmltok -c $f
173 done
174 for f in ../../src/xrc/expat/xmlparse/xmlparse.c ../../src/xrc/expat/xmltok/xmlrole.c ../../src/xrc/expat/xmltok/xmltok.c; do
175 echo $f
176 $wCC `$WX_CONFIG --cxxflags` -I ../../include -I ../../src/xrc/expat/xmlparse -I ../../src/xrc/expat/xmltok -c $f
177 done
178
179 # the handlers are not needed
180 rm xh_*.o xmlrsall.o
181
182 $wCXX `$WX_CONFIG --libs` *.o -o wxrc
183 strip wxrc
184
185fi
186
187#----------------------------------------------------------------------
188# Install wxWindows
189
190if [ -z "$skipinstall" ]; then
191 cd $WXDIR/build
192 make prefix=$INSTALLROOT/$PREFIX install
193
194
195 # and wxPython
196 cd $WXDIR/wxPython
197 python$PYVER setup.py \
198 IN_CVS_TREE=1 \
199 WX_CONFIG="$WXDIR/build/wx-config --prefix=$WXDIR --exec-prefix=$WXDIR/build" \
200 install \
201 --root=$INSTALLROOT
202
203 # install wxPython's tool scripts
204 cd $WXDIR/wxPython/scripts
205 python$PYVER CreateMacScripts.py $INSTALLROOT $PREFIX/bin
206
207 # Install wxrc
208 cp $WXDIR/contrib/utils/wxrc/wxrc $INSTALLROOT$PREFIX/bin
209
210
211 # Move wxWindows devel files and save for a separate installer package
212 mkdir -p $INSTALLDEVEL$PREFIX
213 mkdir -p $INSTALLDEVEL$PREFIX/bin
214 mkdir -p $INSTALLDEVEL$PREFIX/lib
215 mv -f $INSTALLROOT$PREFIX/include $INSTALLDEVEL$PREFIX
216 mv -f $INSTALLROOT$PREFIX/lib/wx $INSTALLDEVEL$PREFIX/lib
217 mv -f $INSTALLROOT$PREFIX/bin/wx* $INSTALLDEVEL$PREFIX/bin
218
1fded56b
RD
219 # TODO for $INSTALLROOT and $INSTALLDEVEL ?
220 # chown -R root:admin
221 # chmod -R g+w
1e4a197e
RD
222fi
223
224popd
225
226#----------------------------------------------------------------------
227
228# Make the Installer packages and disk image
229if [ -z "$skipdmg" ]; then
230
231 # Remove the .pyc/.pyo files they just take up space and can be recreated
232 # during the install.
233 python $PROGDIR/../zappycfiles.py $INSTALLROOT/Library/Frameworks/Python.framework
234
235 # Copy the demo, samples, and such to the Applications dir
236 APPDIR=$INSTALLROOT/Applications/wxPythonOSX-$VERSION
237 mkdir -p $APPDIR
238 cp -pR $WXDIR/wxPython/demo $APPDIR
239 cp -pR $WXDIR/wxPython/samples $APPDIR
240
241 # Move sample launchers to .pyw files.
242 # TODO: A better, more automated way to do this!!!
243 pushd $APPDIR/samples
244 for x in StyleEditor/STCStyleEditor \
245 doodle/superdoodle \
246 frogedit/FrogEdit \
247 pySketch/pySketch \
248 wxProject/wxProject; do
249 mv $x.py $x.pyw
250 done
251 popd
252
253 # Make an app to launch the demo
254 cat > $APPDIR/demo/RunDemo.pyw <<EOF
255import sys, os
256sys.path.insert(0, "/Applications/wxPythonOSX-$VERSION/demo")
257os.chdir("/Applications/wxPythonOSX-$VERSION/demo")
258import Main
259Main.main()
260EOF
261 pythonw $PROGDIR/../buildapp.py \
262 --builddir=$APPDIR \
263 --name=RunDemo \
264 --mainprogram=$APPDIR/demo/RunDemo.pyw \
265 --iconfile=$PROGDIR/RunDemo.icns \
266 build
267
268 # Make an app to launch PyShell
269 pythonw $PROGDIR/../buildapp.py \
270 --builddir=$APPDIR \
271 --name=PyShell \
272 --mainprogram=$INSTALLROOT$PREFIX/bin/pyshell.py \
273 --iconfile=$PROGDIR/PieShell.icns \
274 build
275
276 # Make an app to launch XRCed
277 pythonw $PROGDIR/../buildapp.py \
278 --builddir=$APPDIR \
279 --name=XRCed \
280 --mainprogram=$INSTALLROOT$PREFIX/bin/xrced.py \
281 --iconfile=$PROGDIR/XRCed.icns \
282 build
283
284
285 # Make the welcome message
286 cat > $RESOURCEDIR/Welcome.txt <<EOF
287Welcome!
288
289This program will install wxPython $VERSION for MacPython-OSX $PYVER.
290
291Build date: `date`
292EOF
293
294 # make the preflight script
295 cat > $RESOURCEDIR/preflight <<EOF
296#!/bin/sh
297# Cleanup any old install of the wxPython package
298rm -rf \$2$SITEPACKAGES/wxPython
299exit 0
300EOF
301 chmod +x $RESOURCEDIR/preflight
302
303 # make the postflight script
304 cat > $RESOURCEDIR/postflight <<EOF
305#!/bin/sh -e
306# Compile the .py files in the wxPython pacakge
307/usr/local/bin/python \$2$SITEPACKAGES/../compileall.py \$2$SITEPACKAGES/wxPython
308/usr/local/bin/python -O \$2$SITEPACKAGES/../compileall.py \$2$SITEPACKAGES/wxPython
309
310# and in the demo
311/usr/local/bin/python \$2$SITEPACKAGES/../compileall.py /Applications/wxPythonOSX-$VERSION/demo
312
313# Make the demo/data dir writable
314chmod a+w /Applications/wxPythonOSX-$VERSION/demo/data
315
316# and the wxPython pacakge should be group writable
317chgrp -R admin \$2$SITEPACKAGES/wxPython
318chgrp -R admin /Applications/wxPythonOSX-$VERSION
319chmod -R g+w \$2$SITEPACKAGES/wxPython
320chmod -R g+w /Applications/wxPythonOSX-$VERSION
321
322exit 0
323EOF
324 chmod +x $RESOURCEDIR/postflight
325
326
327
328 # Finally, build the main package...
329 rm -rf wxPythonOSX.pkg
330 python $PROGDIR/../buildpkg.py \
331 --Title=wxPythonOSX \
332 --Version=$VERSION \
333 --Description="wxPython $VERSION for MacPython-OSX $PYVER" \
334 --NeedsAuthorization="YES" \
335 --Relocatable="NO" \
336 --InstallOnly="YES" \
337 $INSTALLROOT \
338 $RESOURCEDIR
339
340 mv wxPythonOSX.pkg $DMGDIR/root
341
342
343 # and the devel package
344 rm -rf wxPythonOSX-devel.pkg
345 python $PROGDIR/../buildpkg.py \
346 --Title=wxPythonOSX-devel \
347 --Version=$VERSION \
348 --Description="Headers and such that allow you to link with the same wxMac that wxPython does" \
349 --NeedsAuthorization="YES" \
350 --Relocatable="NO" \
351 --InstallOnly="YES" \
352 $INSTALLROOT
353
354 mv wxPythonOSX-devel.pkg $DMGDIR/root
355
356
357 # Make a README.txt to go on the disk image
358 cat > $DMGDIR/root/README.txt <<EOF
359The files on this disk image are Installer packages for wxPythonOSX
360$VERSION for MacPython-OSX $PVER. You must already have MacPython-OSX
361installed.
362
363The wxPython extension modules, library, demo and samples are
364contained in the wxPythonOSX package. You should install at least this
365package to use wxPython.
366
367If you have any need to create applicaitons or extension modules that
368link with the same wxMac that wxPython does, then you can also install
369the wxPythonOSX-devel package to get the necessary header files and
370such. Otherwise you don't need it.
371
372Happy Hacking!
373EOF
374
375
376 # license files, etc.
377 cp -pR $WXDIR/wxPython/licence $DMGDIR/root
378 cp $WXDIR/wxPython/CHANGES.txt $DMGDIR/root
379
380 # and then finally make a disk image containing the packages and etc.
381 $PROGDIR/../makedmg $DMGDIR/root $DMGDIR wxPythonOSX-$VERSION-py$PYVER
382
383 echo Moving $DMGDIR/wxPythonOSX-$VERSION-py$PYVER.dmg to $DESTDIR
384 mv $DMGDIR/wxPythonOSX-$VERSION-py$PYVER.dmg $DESTDIR
385fi
386
387
388# Cleanup build/install dirs
389if [ -z "$skipclean" ]; then
390 echo "Cleaning up..."
391 rm -rf $TMPDIR
392else
393 echo "Cleanup is disabled. You should remove $TMPDIR when finished"
394fi
395