]> git.saurik.com Git - wxWidgets.git/blame - wxPython/distrib/mac/wxPythonOSX/build
fiddle with the configure flags a bit
[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 ""
dd35b09a 18 echo "Usage: $0 [panther|jaguar] [command flags...]"
1e4a197e 19 echo ""
c6387bc1
RD
20 echo " panther Build for Apple's python in /usr/bin, such as on Panther"
21 echo " jaguar Build for a python in /usr/local/bin, such as on Jaguar"
46456f61
RD
22 echo ""
23 echo "optional command flags:"
1e4a197e
RD
24 echo " skiptar Don't unpack the tarball"
25 echo " use_cvs Use the CVS workspace instead of a tarfile"
26 echo " skipconfig Don't run configure"
b42b447c 27 echo " skipbuild Don't build wxWidgets or wxPython"
1e4a197e
RD
28 echo " skipinstall Don't do the installation step"
29 echo " skipdmg Don't make the package or diskimage"
30 echo " skipclean Don't do the cleanup at the end"
46456f61 31 echo ""
1e4a197e
RD
32}
33
34
46456f61 35if [ $# -lt 1 ]; then
1e4a197e
RD
36 usage
37 exit 1
38fi
39
46456f61
RD
40KIND=$1
41case $KIND in
c6387bc1
RD
42 panther) PYTHON=/usr/bin/python ;;
43 jaguar) PYTHON=/usr/local/bin/python ;;
44 *) usage; exit 1 ;;
46456f61
RD
45esac
46PYTHONW=${PYTHON}w
47shift
1e4a197e
RD
48
49
50for flag in $*; do
51 case ${flag} in
52 skiptar) skiptar=1 ;;
53 use_cvs) skiptar=1; use_cvs=1 ;;
54 skipconfig) skipconfig=1; skiptar=1 ;;
55 skipbuild) skipbuild=1; skipconfig=1; skiptar=1 ;;
56 skipinstall) skipinstall=1 ;;
57 skipdmg) skipdmg=1 ;;
58 skipclean) skipclean=1 ;;
59
60 *) echo "Unknown flag \"${flag}\""
61 usage
62 exit 1
63 esac
64done
65
66
46456f61
RD
67VERSION=`$PYTHON -c "import setup;print setup.VERSION"`
68PYVER=`$PYTHON -c "import sys; print sys.version[:3]"`
69PYPREFIX=`$PYTHON -c "import sys; print sys.exec_prefix"`
c6387bc1
RD
70PYLIB=$PYPREFIX/lib/python$PYVER
71SITEPACKAGES=$PYLIB/site-packages
46456f61 72
b42b447c
RD
73TARBALLDIR=/stuff/Development/wxPython/dist/$VERSION
74TARBALL=$TARBALLDIR/wxPythonSrc-$VERSION.tar.gz
1e4a197e 75
46456f61
RD
76PREFIX=/usr/lib/wxPython-$VERSION
77BINPREFIX=/usr/bin
1e4a197e 78
46456f61 79WXROOT=`dirname $PWD`
1e4a197e
RD
80PROGDIR="`dirname \"$0\"`"
81TMPDIR=$PWD/_build_dmg
82
83BUILDROOT=$TMPDIR/build
84INSTALLROOT=$TMPDIR/install
85INSTALLDEVEL=$TMPDIR/install-devel
86DMGDIR=$TMPDIR/dmg
87RESOURCEDIR=$PROGDIR/resources
88DESTDIR=$PWD/dist
b42b447c 89SRCROOT=$BUILDROOT/wxPythonSrc-$VERSION
1e4a197e
RD
90
91
92#----------------------------------------------------------------------
93# Setup builddirs
94
95mkdir -p $BUILDROOT
96mkdir -p $INSTALLROOT
46456f61 97#mkdir -p $INSTALLDEVEL
1e4a197e 98rm -rf $DMGDIR
b42b447c
RD
99mkdir -p $DMGDIR/root/Apps
100mkdir -p $DMGDIR/root/Docs
101mkdir -p $DMGDIR/root/Samples
102
1e4a197e
RD
103
104pushd $BUILDROOT
105
106
107#----------------------------------------------------------------------
108# Unpack the tarball
109
110if [ -z "$skiptar" ]; then
46456f61
RD
111 echo Unarchiving tarball...
112 tar xzf $TARBALL
1e4a197e
RD
113fi
114
115if [ "$use_cvs" = 1 ]; then
116 # copy the cvs workspace, except for build dirs
117
118 mkdir -p wxPythonSrc-$VERSION
119
120 echo Finding updated files...
121 if [ -e .last_copy ]; then
122 FEXPR="-cnewer .last_copy"
123 fi
46456f61
RD
124 MEASURE=$WXROOT//
125 find $WXROOT $FEXPR -print \
126 | grep -v $WXROOT/bld \
1e4a197e
RD
127 | grep -v wxPython/build \
128 | grep -v wxPython/_build \
129 | grep -v CVS \
46456f61
RD
130 | grep -v .pyc \
131 | cut -b ${#MEASURE}- > filelist
1e4a197e
RD
132
133 for x in `cat filelist`; do
46456f61 134 if [ -d "$WXROOT/$x" ]; then
1e4a197e
RD
135 mkdir -p "wxPythonSrc-$VERSION/$x"
136 else
137 echo $x
46456f61 138 cp -p "$WXROOT/$x" "wxPythonSrc-$VERSION/$x"
1e4a197e
RD
139 fi
140 done
141
142 touch .last_copy
143fi
144
145
146cd wxPythonSrc-$VERSION
147WXDIR=`pwd`
46456f61
RD
148mkdir -p $WXDIR/bld
149cd $WXDIR/bld
1e4a197e
RD
150
151#----------------------------------------------------------------------
152
153
b42b447c 154# Configure wxWidgets
1e4a197e 155if [ -z "$skipconfig" ]; then
46456f61
RD
156 ../configure \
157 --prefix=$PREFIX \
158 --with-mac \
159 --disable-monolithic \
1e4a197e 160 --with-opengl \
ec656cfe
RD
161 --enable-sound \
162 --enable-display \
e2f7f062 163 --enable-geometry \
46456f61 164 --enable-precomp=no \
46456f61 165 --enable-debug_flag
1e4a197e 166
e2f7f062
RD
167## --enable-optimise \
168## --with-libjpeg=builtin \
169## --with-libpng=builtin \
170## --with-libtiff=builtin \
171## --with-zlib=builtin \
172
1e4a197e
RD
173fi
174
b42b447c 175# Build wxWidgets and wxPython
1e4a197e 176if [ -z "$skipbuild" ]; then
1e4a197e 177
b42b447c 178 # Make wxWidgets and some contribs
46456f61
RD
179 make
180 make -C contrib/src/gizmos
181 make -C contrib/src/ogl CXXFLAGS="-DwxUSE_DEPRECATED=0"
182 make -C contrib/src/stc
183 make -C contrib/src/xrc
184
185 if [ ! -e $WXDIR/include/wx/gizmos ]; then
186 # Make some links so the wxPython build can find all the headers it needs
187 pushd $WXDIR/include/wx
188 ln -s ../../contrib/include/wx/* .
189 popd
190 fi
191
192 # Build wxPython
1e4a197e 193 cd $WXDIR/wxPython
46456f61
RD
194 $PYTHON setup.py \
195 NO_SCRIPTS=1 \
196 WX_CONFIG="$WXDIR/bld/wx-config --prefix=$WXDIR --exec-prefix=$WXDIR/bld" \
1e4a197e
RD
197 build
198
199
46456f61
RD
200 # Build wxrc (XRC resource tool)
201 cd $WXDIR/bld/contrib/utils/wxrc
202 make
1e4a197e
RD
203 strip wxrc
204
205fi
206
207#----------------------------------------------------------------------
1e4a197e
RD
208
209if [ -z "$skipinstall" ]; then
b42b447c 210 # Install wxWidgets
46456f61
RD
211 cd $WXDIR/bld
212 make prefix=$INSTALLROOT$PREFIX install
213 make -C contrib/src/gizmos prefix=$INSTALLROOT$PREFIX install
214 make -C contrib/src/ogl CXXFLAGS="-DwxUSE_DEPRECATED=0" prefix=$INSTALLROOT/$PREFIX install
215 make -C contrib/src/stc prefix=$INSTALLROOT$PREFIX install
216 make -C contrib/src/xrc prefix=$INSTALLROOT$PREFIX install
1e4a197e
RD
217
218
219 # and wxPython
220 cd $WXDIR/wxPython
46456f61
RD
221 $PYTHON setup.py \
222 NO_SCRIPTS=1 \
223 WX_CONFIG="$INSTALLROOT/$PREFIX/bin/wx-config --prefix=$INSTALLROOT/$PREFIX" \
1e4a197e
RD
224 install \
225 --root=$INSTALLROOT
226
46456f61 227
c6387bc1
RD
228 # Apple's Python (on Panther) sym-links the site-packages dir to
229 # /Library/Python/$PYVER so we need to move the files so they are
230 # installed in the physical location, not the virtual one.
231 if [ "$KIND" = "panther" ]; then
232 mkdir -p $INSTALLROOT/Library/Python/$PYVER
233 mv $INSTALLROOT/$SITEPACKAGES/* $INSTALLROOT/Library/Python/$PYVER
234 rm -r $INSTALLROOT/System
235 SITEPACKAGES=/Library/Python/$PYVER
236 fi
237
238
1e4a197e 239 # install wxPython's tool scripts
46456f61 240 mkdir -p $INSTALLROOT$BINPREFIX
1e4a197e 241 cd $WXDIR/wxPython/scripts
46456f61 242 python$PYVER CreateMacScripts.py $INSTALLROOT $BINPREFIX
1e4a197e 243
c6387bc1 244
1e4a197e 245 # Install wxrc
46456f61 246 cp $WXDIR/bld/contrib/utils/wxrc/wxrc $INSTALLROOT$BINPREFIX
1e4a197e
RD
247
248
46456f61
RD
249 # install the wxPython headers
250 cd $WXDIR/wxPython
251 cp -R include $INSTALLROOT$PREFIX
252 mkdir -p $INSTALLROOT$PREFIX/include/wx/wxPython/i_files
253 cp src/*.i $INSTALLROOT$PREFIX/include/wx/wxPython/i_files
254
1e4a197e 255
c6387bc1 256 # Set premissions for files in $INSTALLROOT
7a72b62e
RD
257 chown -R root:admin $INSTALLROOT
258 chmod -R g+w $INSTALLROOT
1e4a197e
RD
259fi
260
261popd
262
263#----------------------------------------------------------------------
264
265# Make the Installer packages and disk image
266if [ -z "$skipdmg" ]; then
267
268 # Remove the .pyc/.pyo files they just take up space and can be recreated
269 # during the install.
46456f61 270 $PYTHON $PROGDIR/../zappycfiles.py $INSTALLROOT
1e4a197e
RD
271
272
273 # Make the welcome message
46456f61 274 case $KIND in
c6387bc1
RD
275 panther) W_MSG="the Panther (OS X 10.3.x) version of" ;;
276 jaguar) W_MSG="the Jaguar (OS X 10.2.x) version of" ;;
46456f61 277 esac
1e4a197e
RD
278 cat > $RESOURCEDIR/Welcome.txt <<EOF
279Welcome!
280
46456f61 281This program will install wxPython $VERSION for $W_MSG MacPython-OSX $PYVER.
1e4a197e 282
c6387bc1
RD
283You must install onto your current boot disk, even though the installer does not enforce this, otherwise things will not work.
284
1e4a197e
RD
285Build date: `date`
286EOF
287
288 # make the preflight script
289 cat > $RESOURCEDIR/preflight <<EOF
290#!/bin/sh
291# Cleanup any old install of the wxPython package
292rm -rf \$2$SITEPACKAGES/wxPython
46456f61 293rm -rf \$2$SITEPACKAGES/wx
1e4a197e
RD
294exit 0
295EOF
296 chmod +x $RESOURCEDIR/preflight
297
298 # make the postflight script
299 cat > $RESOURCEDIR/postflight <<EOF
300#!/bin/sh -e
301# Compile the .py files in the wxPython pacakge
c6387bc1
RD
302$PYTHON \$2$PYLIB/compileall.py \$2$SITEPACKAGES/wxPython
303$PYTHON \$2$PYLIB/compileall.py \$2$SITEPACKAGES/wx
304$PYTHON -O \$2$PYLIB/compileall.py \$2$SITEPACKAGES/wxPython
305$PYTHON -O \$2$PYLIB/compileall.py \$2$SITEPACKAGES/wx
1e4a197e 306
1e4a197e 307
c6387bc1 308# and all of the wxPython pacakge should be group writable
1e4a197e 309chgrp -R admin \$2$SITEPACKAGES/wxPython
1e4a197e 310chmod -R g+w \$2$SITEPACKAGES/wxPython
46456f61
RD
311chgrp -R admin \$2$SITEPACKAGES/wx
312chmod -R g+w \$2$SITEPACKAGES/wx
1e4a197e
RD
313
314exit 0
315EOF
316 chmod +x $RESOURCEDIR/postflight
317
318
319
c6387bc1 320 # Build the main Installer Package...
46456f61 321 rm -rf wxPythonOSX-$KIND.pkg
1e4a197e 322 python $PROGDIR/../buildpkg.py \
46456f61 323 --Title=wxPythonOSX-$KIND \
1e4a197e 324 --Version=$VERSION \
46456f61 325 --Description="wxPython $VERSION for $W_MSG MacPython-OSX $PYVER" \
1e4a197e
RD
326 --NeedsAuthorization="YES" \
327 --Relocatable="NO" \
328 --InstallOnly="YES" \
329 $INSTALLROOT \
330 $RESOURCEDIR
331
46456f61 332 mv wxPythonOSX-$KIND.pkg $DMGDIR/root
1e4a197e
RD
333
334
1e4a197e
RD
335
336 # Make a README.txt to go on the disk image
c6387bc1 337 cat > "$DMGDIR/root/README 1st.txt" <<EOF
46456f61
RD
338Welcome to wxPython!
339
c6387bc1 340On this disk image you will find the installer for wxPython $VERSION for $W_MSG MacPython-OSX $PYVER. MacPython-OSX is not included.
46456f61
RD
341
342 wxPython-$KIND.pkg The installer package. It contains the wxPython
343 extension modules, wxMac dynamic libraries and
344 headers, and some scripts for the command-line
345 tools.
1e4a197e 346
46456f61 347Everything else here is optional and you can drag them out of the disk
c6387bc1
RD
348image and drop them whereever you want. You do need to install the above
349package before you can use any of the items below.
1e4a197e 350
46456f61 351
b42b447c 352 Apps/wxPython Demo An application bundle version of the demo.
c6387bc1
RD
353 (This has it's own copy of the sources within
354 the bundle.)
355
b42b447c 356 Apps/XRCed An application for editing wxPython resource
c6387bc1
RD
357 files (XRC files.)
358
b42b447c 359 Apps/PyCrust An application that provides an interactive
c6387bc1
RD
360 Python shell and also namespace inspectors.
361
b42b447c
RD
362
363
364 Docs/wxDocs A folder containing the wxWidgets documentation
365 bundled in .zip files, and a small wxPython
366 application that can be used to view the docs.
367 Just run viewer.pyw.
368
369 Docs/licence License files.
370
371 Docs/other A few readmes, change log, etc. The full
372 documentation is downloadable separately.
373
374
375 Samples/samples Several small sample applications that
376 demonstrate how to use wxPython.
377
378 Samples/demo A copy of the wxPython demo source code,
379 just open the folder and run demo.pyw.
380
1e4a197e
RD
381Happy Hacking!
382EOF
383
c6387bc1
RD
384# PyAlaMode An extension of PyCrust that includes source
385# file editing capabilities.
386
1e4a197e 387
b42b447c
RD
388 # wxDocs
389 pushd $DMGDIR/root/Docs
390 tar xzvf $TARBALLDIR/wxPythonDocs-$VERSION.tar.gz
391 mv wxPython-$VERSION/docs wxDocs
392 rm -r wxPython-$VERSION
393 mv wxDocs/viewdocs.py wxDocs/viewdocs.pyw
46456f61 394
b42b447c
RD
395 # license files, docs, etc.
396 cp -pR $SRCROOT/wxPython/licence .
397 cp -pR $SRCROOT/wxPython/docs .
398 rm -rf docs/bin
399 rm -rf docs/xml-raw
400 mv docs other
401 popd
46456f61 402
b42b447c
RD
403 # Copy the demo and samples to the disk image from the tarball
404 pushd $DMGDIR/root/Samples
405 tar xzvf $TARBALLDIR/wxPythonDemo-$VERSION.tar.gz
406 mv wxPython-$VERSION/* .
407 rm -rf wxPython-$VERSION
408 rm demo/b demo/.setup.sh
409 mv demo/demo.py demo/demo.pyw
410 popd
411
412
46456f61
RD
413 # Make an app bundle to launch PyCrust
414 $PYTHONW $PROGDIR/../buildapp.py \
b42b447c 415 --builddir=$DMGDIR/root/Apps \
46456f61
RD
416 --name=PyCrust \
417 --mainprogram=$INSTALLROOT$BINPREFIX/pycrust.py \
418 --iconfile=$PROGDIR/PieShell.icns \
419 build
420
c6387bc1
RD
421# # and PyAlaMode
422# $PYTHONW $PROGDIR/../buildapp.py \
423# --builddir=$DMGDIR/root \
424# --name=PyAlaMode \
425# --mainprogram=$INSTALLROOT$BINPREFIX/pyalamode.py \
426# --iconfile=$PROGDIR/PieShell.icns \
427# build
428
46456f61
RD
429 # Make an app to launch XRCed
430 $PYTHONW $PROGDIR/../buildapp.py \
b42b447c 431 --builddir=$DMGDIR/root/Apps \
46456f61
RD
432 --name=XRCed \
433 --mainprogram=$INSTALLROOT$BINPREFIX/xrced.py \
434 --iconfile=$PROGDIR/XRCed.icns \
435 build
436
437 # Make an app bundle to run the demo
438 $PYTHONW $PROGDIR/../buildapp.py \
b42b447c 439 --builddir=$DMGDIR/root/Apps \
46456f61 440 --name="wxPython Demo" \
b42b447c 441 --mainprogram=$DMGDIR/root/Samples/demo/demo.pyw \
46456f61
RD
442 --iconfile=$PROGDIR/RunDemo.icns \
443 build
b42b447c 444 cp -pR $DMGDIR/root/Samples/demo/* "$DMGDIR/root/Apps/wxPython Demo.app/Contents/Resources"
46456f61 445
1e4a197e
RD
446
447 # and then finally make a disk image containing the packages and etc.
46456f61 448 $PROGDIR/../makedmg $DMGDIR/root $DMGDIR wxPythonOSX-$VERSION-$KIND-Py$PYVER
1e4a197e 449
46456f61
RD
450 echo Moving $DMGDIR/wxPythonOSX-$VERSION-$KIND-Py$PYVER.dmg to $DESTDIR
451 mv $DMGDIR/wxPythonOSX-$VERSION-$KIND-Py$PYVER.dmg $DESTDIR
1e4a197e
RD
452fi
453
454
455# Cleanup build/install dirs
456if [ -z "$skipclean" ]; then
457 echo "Cleaning up..."
458 rm -rf $TMPDIR
459else
460 echo "Cleanup is disabled. You should remove $TMPDIR when finished"
461fi
462