]> git.saurik.com Git - wxWidgets.git/blob - wxPython/distrib/mac/wxPythonOSX/build
added visual c++ makefiles
[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 fi
218
219 popd
220
221 #----------------------------------------------------------------------
222
223 # Make the Installer packages and disk image
224 if [ -z "$skipdmg" ]; then
225
226 # Remove the .pyc/.pyo files they just take up space and can be recreated
227 # during the install.
228 python $PROGDIR/../zappycfiles.py $INSTALLROOT/Library/Frameworks/Python.framework
229
230 # Copy the demo, samples, and such to the Applications dir
231 APPDIR=$INSTALLROOT/Applications/wxPythonOSX-$VERSION
232 mkdir -p $APPDIR
233 cp -pR $WXDIR/wxPython/demo $APPDIR
234 cp -pR $WXDIR/wxPython/samples $APPDIR
235
236 # Move sample launchers to .pyw files.
237 # TODO: A better, more automated way to do this!!!
238 pushd $APPDIR/samples
239 for x in StyleEditor/STCStyleEditor \
240 doodle/superdoodle \
241 frogedit/FrogEdit \
242 pySketch/pySketch \
243 wxProject/wxProject; do
244 mv $x.py $x.pyw
245 done
246 popd
247
248 # Make an app to launch the demo
249 cat > $APPDIR/demo/RunDemo.pyw <<EOF
250 import sys, os
251 sys.path.insert(0, "/Applications/wxPythonOSX-$VERSION/demo")
252 os.chdir("/Applications/wxPythonOSX-$VERSION/demo")
253 import Main
254 Main.main()
255 EOF
256 pythonw $PROGDIR/../buildapp.py \
257 --builddir=$APPDIR \
258 --name=RunDemo \
259 --mainprogram=$APPDIR/demo/RunDemo.pyw \
260 --iconfile=$PROGDIR/RunDemo.icns \
261 build
262
263 # Make an app to launch PyShell
264 pythonw $PROGDIR/../buildapp.py \
265 --builddir=$APPDIR \
266 --name=PyShell \
267 --mainprogram=$INSTALLROOT$PREFIX/bin/pyshell.py \
268 --iconfile=$PROGDIR/PieShell.icns \
269 build
270
271 # Make an app to launch XRCed
272 pythonw $PROGDIR/../buildapp.py \
273 --builddir=$APPDIR \
274 --name=XRCed \
275 --mainprogram=$INSTALLROOT$PREFIX/bin/xrced.py \
276 --iconfile=$PROGDIR/XRCed.icns \
277 build
278
279
280 # Make the welcome message
281 cat > $RESOURCEDIR/Welcome.txt <<EOF
282 Welcome!
283
284 This program will install wxPython $VERSION for MacPython-OSX $PYVER.
285
286 Build date: `date`
287 EOF
288
289 # make the preflight script
290 cat > $RESOURCEDIR/preflight <<EOF
291 #!/bin/sh
292 # Cleanup any old install of the wxPython package
293 rm -rf \$2$SITEPACKAGES/wxPython
294 exit 0
295 EOF
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
302 /usr/local/bin/python \$2$SITEPACKAGES/../compileall.py \$2$SITEPACKAGES/wxPython
303 /usr/local/bin/python -O \$2$SITEPACKAGES/../compileall.py \$2$SITEPACKAGES/wxPython
304
305 # and in the demo
306 /usr/local/bin/python \$2$SITEPACKAGES/../compileall.py /Applications/wxPythonOSX-$VERSION/demo
307
308 # Make the demo/data dir writable
309 chmod a+w /Applications/wxPythonOSX-$VERSION/demo/data
310
311 # and the wxPython pacakge should be group writable
312 chgrp -R admin \$2$SITEPACKAGES/wxPython
313 chgrp -R admin /Applications/wxPythonOSX-$VERSION
314 chmod -R g+w \$2$SITEPACKAGES/wxPython
315 chmod -R g+w /Applications/wxPythonOSX-$VERSION
316
317 exit 0
318 EOF
319 chmod +x $RESOURCEDIR/postflight
320
321
322
323 # Finally, build the main package...
324 rm -rf wxPythonOSX.pkg
325 python $PROGDIR/../buildpkg.py \
326 --Title=wxPythonOSX \
327 --Version=$VERSION \
328 --Description="wxPython $VERSION for MacPython-OSX $PYVER" \
329 --NeedsAuthorization="YES" \
330 --Relocatable="NO" \
331 --InstallOnly="YES" \
332 $INSTALLROOT \
333 $RESOURCEDIR
334
335 mv wxPythonOSX.pkg $DMGDIR/root
336
337
338 # and the devel package
339 rm -rf wxPythonOSX-devel.pkg
340 python $PROGDIR/../buildpkg.py \
341 --Title=wxPythonOSX-devel \
342 --Version=$VERSION \
343 --Description="Headers and such that allow you to link with the same wxMac that wxPython does" \
344 --NeedsAuthorization="YES" \
345 --Relocatable="NO" \
346 --InstallOnly="YES" \
347 $INSTALLROOT
348
349 mv wxPythonOSX-devel.pkg $DMGDIR/root
350
351
352 # Make a README.txt to go on the disk image
353 cat > $DMGDIR/root/README.txt <<EOF
354 The files on this disk image are Installer packages for wxPythonOSX
355 $VERSION for MacPython-OSX $PVER. You must already have MacPython-OSX
356 installed.
357
358 The wxPython extension modules, library, demo and samples are
359 contained in the wxPythonOSX package. You should install at least this
360 package to use wxPython.
361
362 If you have any need to create applicaitons or extension modules that
363 link with the same wxMac that wxPython does, then you can also install
364 the wxPythonOSX-devel package to get the necessary header files and
365 such. Otherwise you don't need it.
366
367 Happy Hacking!
368 EOF
369
370
371 # license files, etc.
372 cp -pR $WXDIR/wxPython/licence $DMGDIR/root
373 cp $WXDIR/wxPython/CHANGES.txt $DMGDIR/root
374
375 # and then finally make a disk image containing the packages and etc.
376 $PROGDIR/../makedmg $DMGDIR/root $DMGDIR wxPythonOSX-$VERSION-py$PYVER
377
378 echo Moving $DMGDIR/wxPythonOSX-$VERSION-py$PYVER.dmg to $DESTDIR
379 mv $DMGDIR/wxPythonOSX-$VERSION-py$PYVER.dmg $DESTDIR
380 fi
381
382
383 # Cleanup build/install dirs
384 if [ -z "$skipclean" ]; then
385 echo "Cleaning up..."
386 rm -rf $TMPDIR
387 else
388 echo "Cleanup is disabled. You should remove $TMPDIR when finished"
389 fi
390