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