]> git.saurik.com Git - wxWidgets.git/blame - wxPython/distrib/mac/wxPythonOSX/build
Updated Installer builder scripts and such for OS X
[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 ""
46456f61 18 echo "Usage: $0 [apple|local] [command flags...]"
1e4a197e 19 echo ""
46456f61
RD
20 echo " apple Build for Apple's python in /usr/bin"
21 echo " local Build for a locally installed python in /usr/local/bin"
22 echo " (for example Jaguar's MacPython)"
23 echo ""
24 echo "optional command flags:"
1e4a197e
RD
25 echo " skiptar Don't unpack the tarball"
26 echo " use_cvs Use the CVS workspace instead of a tarfile"
27 echo " skipconfig Don't run configure"
28 echo " skipbuild Don't build wxWindows or wxPython"
29 echo " skipinstall Don't do the installation step"
30 echo " skipdmg Don't make the package or diskimage"
31 echo " skipclean Don't do the cleanup at the end"
46456f61 32 echo ""
1e4a197e
RD
33}
34
35
46456f61 36if [ $# -lt 1 ]; then
1e4a197e
RD
37 usage
38 exit 1
39fi
40
46456f61
RD
41KIND=$1
42case $KIND in
43 apple) PYTHON=/usr/bin/python ;;
44 local) PYTHON=/usr/local/bin/python ;;
45 *) usage; exit 1 ;;
46esac
47PYTHONW=${PYTHON}w
48shift
1e4a197e
RD
49
50
51for flag in $*; do
52 case ${flag} in
53 skiptar) skiptar=1 ;;
54 use_cvs) skiptar=1; use_cvs=1 ;;
55 skipconfig) skipconfig=1; skiptar=1 ;;
56 skipbuild) skipbuild=1; skipconfig=1; skiptar=1 ;;
57 skipinstall) skipinstall=1 ;;
58 skipdmg) skipdmg=1 ;;
59 skipclean) skipclean=1 ;;
60
61 *) echo "Unknown flag \"${flag}\""
62 usage
63 exit 1
64 esac
65done
66
67
46456f61
RD
68VERSION=`$PYTHON -c "import setup;print setup.VERSION"`
69PYVER=`$PYTHON -c "import sys; print sys.version[:3]"`
70PYPREFIX=`$PYTHON -c "import sys; print sys.exec_prefix"`
71SITEPACKAGES=$PYPREFIX/lib/python$PYVER/site-packages
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#----------------------------------------------------------------------
204# Install wxWindows
205
206if [ -z "$skipinstall" ]; then
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
1e4a197e 224 # install wxPython's tool scripts
46456f61 225 mkdir -p $INSTALLROOT$BINPREFIX
1e4a197e 226 cd $WXDIR/wxPython/scripts
46456f61 227 python$PYVER CreateMacScripts.py $INSTALLROOT $BINPREFIX
1e4a197e
RD
228
229 # Install wxrc
46456f61 230 cp $WXDIR/bld/contrib/utils/wxrc/wxrc $INSTALLROOT$BINPREFIX
1e4a197e
RD
231
232
46456f61
RD
233 # install the wxPython headers
234 cd $WXDIR/wxPython
235 cp -R include $INSTALLROOT$PREFIX
236 mkdir -p $INSTALLROOT$PREFIX/include/wx/wxPython/i_files
237 cp src/*.i $INSTALLROOT$PREFIX/include/wx/wxPython/i_files
238
1e4a197e 239
1fded56b 240 # TODO for $INSTALLROOT and $INSTALLDEVEL ?
46456f61
RD
241 #chown -R root:admin $INSTALLROOT
242 #chmod -R g+w $INSTALLROOT
1e4a197e
RD
243fi
244
245popd
246
247#----------------------------------------------------------------------
248
249# Make the Installer packages and disk image
250if [ -z "$skipdmg" ]; then
251
252 # Remove the .pyc/.pyo files they just take up space and can be recreated
253 # during the install.
46456f61 254 $PYTHON $PROGDIR/../zappycfiles.py $INSTALLROOT
1e4a197e
RD
255
256
257 # Make the welcome message
46456f61
RD
258 case $KIND in
259 apple) W_MSG="an Apple installed (Panther) version of" ;;
260 local) W_MSG="a locally built version (or Jaguar version) of" ;;
261 esac
1e4a197e
RD
262 cat > $RESOURCEDIR/Welcome.txt <<EOF
263Welcome!
264
46456f61 265This program will install wxPython $VERSION for $W_MSG MacPython-OSX $PYVER.
1e4a197e
RD
266
267Build date: `date`
268EOF
269
270 # make the preflight script
271 cat > $RESOURCEDIR/preflight <<EOF
272#!/bin/sh
273# Cleanup any old install of the wxPython package
274rm -rf \$2$SITEPACKAGES/wxPython
46456f61 275rm -rf \$2$SITEPACKAGES/wx
1e4a197e
RD
276exit 0
277EOF
278 chmod +x $RESOURCEDIR/preflight
279
280 # make the postflight script
281 cat > $RESOURCEDIR/postflight <<EOF
282#!/bin/sh -e
283# Compile the .py files in the wxPython pacakge
46456f61
RD
284$PYTHON \$2$SITEPACKAGES/../compileall.py \$2$SITEPACKAGES/wxPython
285$PYTHON \$2$SITEPACKAGES/../compileall.py \$2$SITEPACKAGES/wx
286$PYTHON -O \$2$SITEPACKAGES/../compileall.py \$2$SITEPACKAGES/wxPython
287$PYTHON -O \$2$SITEPACKAGES/../compileall.py \$2$SITEPACKAGES/wx
1e4a197e 288
1e4a197e
RD
289
290# and the wxPython pacakge should be group writable
291chgrp -R admin \$2$SITEPACKAGES/wxPython
1e4a197e 292chmod -R g+w \$2$SITEPACKAGES/wxPython
46456f61
RD
293chgrp -R admin \$2$SITEPACKAGES/wx
294chmod -R g+w \$2$SITEPACKAGES/wx
1e4a197e
RD
295
296exit 0
297EOF
298 chmod +x $RESOURCEDIR/postflight
299
300
301
46456f61
RD
302 # Finally, build the main Installer Package...
303 rm -rf wxPythonOSX-$KIND.pkg
1e4a197e 304 python $PROGDIR/../buildpkg.py \
46456f61 305 --Title=wxPythonOSX-$KIND \
1e4a197e 306 --Version=$VERSION \
46456f61 307 --Description="wxPython $VERSION for $W_MSG MacPython-OSX $PYVER" \
1e4a197e
RD
308 --NeedsAuthorization="YES" \
309 --Relocatable="NO" \
310 --InstallOnly="YES" \
311 $INSTALLROOT \
312 $RESOURCEDIR
313
46456f61 314 mv wxPythonOSX-$KIND.pkg $DMGDIR/root
1e4a197e
RD
315
316
46456f61
RD
317# # and the devel package
318# rm -rf wxPythonOSX-devel.pkg
319# python $PROGDIR/../buildpkg.py \
320# --Title=wxPythonOSX-devel \
321# --Version=$VERSION \
322# --Description="Headers and such that allow you to link with the same wxMac that wxPython does" \
323# --NeedsAuthorization="YES" \
324# --Relocatable="NO" \
325# --InstallOnly="YES" \
326# $INSTALLDEVEL
1e4a197e 327
46456f61 328# mv wxPythonOSX-devel.pkg $DMGDIR/root
1e4a197e
RD
329
330
331 # Make a README.txt to go on the disk image
332 cat > $DMGDIR/root/README.txt <<EOF
46456f61
RD
333Welcome to wxPython!
334
335On this disk image you will find the installer for the wxPython $VERSION for $W_MSG MacPython-OSX $PYVER. You must already have MacPython-OSX installed.
336
337 wxPython-$KIND.pkg The installer package. It contains the wxPython
338 extension modules, wxMac dynamic libraries and
339 headers, and some scripts for the command-line
340 tools.
1e4a197e 341
46456f61
RD
342Everything else here is optional and you can drag them out of the disk
343image and drop them where ever you want.
1e4a197e 344
46456f61
RD
345 docs/ A few readmes, change log, etc. The full
346 documentation is downloadable separately.
347
348 licence/ License docs.
349
350 demo/ A copy of the wxPython demo.
351
352 samples/ Several small sample applications that
353 demonstrate how to use wxPython.
1e4a197e
RD
354
355Happy Hacking!
356EOF
357
358
46456f61 359 # license files, docs, etc.
1e4a197e 360 cp -pR $WXDIR/wxPython/licence $DMGDIR/root
46456f61
RD
361 rm -rf $WXDIR/wxPython/docs/xml-raw
362 cp -pR $WXDIR/wxPython/docs $DMGDIR/root
363 rm -rf $DMGDIR/root/docs/bin
364
365 # Copy the demo and samples to the disk image
366 cp -pR $WXDIR/wxPython/demo $DMGDIR/root
367 cp -pR $WXDIR/wxPython/samples $DMGDIR/root
368 rm $DMGDIR/root/demo/b
369
370
371 # Make an app bundle to launch PyCrust
372 $PYTHONW $PROGDIR/../buildapp.py \
373 --builddir=$DMGDIR/root \
374 --name=PyCrust \
375 --mainprogram=$INSTALLROOT$BINPREFIX/pycrust.py \
376 --iconfile=$PROGDIR/PieShell.icns \
377 build
378
379 # Make an app to launch XRCed
380 $PYTHONW $PROGDIR/../buildapp.py \
381 --builddir=$DMGDIR/root \
382 --name=XRCed \
383 --mainprogram=$INSTALLROOT$BINPREFIX/xrced.py \
384 --iconfile=$PROGDIR/XRCed.icns \
385 build
386
387 # Make an app bundle to run the demo
388 $PYTHONW $PROGDIR/../buildapp.py \
389 --builddir=$DMGDIR/root \
390 --name="wxPython Demo" \
391 --mainprogram=$DMGDIR/root/demo/demo.py \
392 --iconfile=$PROGDIR/RunDemo.icns \
393 build
394 cp -pR $DMGDIR/root/demo/* "$DMGDIR/root/wxPython Demo.app/Contents/Resources"
395
1e4a197e
RD
396
397 # and then finally make a disk image containing the packages and etc.
46456f61 398 $PROGDIR/../makedmg $DMGDIR/root $DMGDIR wxPythonOSX-$VERSION-$KIND-Py$PYVER
1e4a197e 399
46456f61
RD
400 echo Moving $DMGDIR/wxPythonOSX-$VERSION-$KIND-Py$PYVER.dmg to $DESTDIR
401 mv $DMGDIR/wxPythonOSX-$VERSION-$KIND-Py$PYVER.dmg $DESTDIR
1e4a197e
RD
402fi
403
404
405# Cleanup build/install dirs
406if [ -z "$skipclean" ]; then
407 echo "Cleaning up..."
408 rm -rf $TMPDIR
409else
410 echo "Cleanup is disabled. You should remove $TMPDIR when finished"
411fi
412