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