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