| 1 | #!/bin/sh |
|---|
| 2 | # |
|---|
| 3 | # Note: this script requires MacOS X 10.2 or greater, and builds diskimages |
|---|
| 4 | # which require MacOS X 10.1 or greater to install. |
|---|
| 5 | # |
|---|
| 6 | # Currently (at least is built on 10.6) 10.6 is required to run. |
|---|
| 7 | # |
|---|
| 8 | # Run from the unpacked survex-1.1.X directory like so: |
|---|
| 9 | # |
|---|
| 10 | # ./buildmacosx.sh |
|---|
| 11 | # |
|---|
| 12 | # This will automatically download and temporarily install wxWidgets |
|---|
| 13 | # (this script is smart enough not to download or build it if it already |
|---|
| 14 | # has). |
|---|
| 15 | # |
|---|
| 16 | # If you already have wxWidgets installed permanently, use: |
|---|
| 17 | # |
|---|
| 18 | # ./buildmacosx.sh --no-install-wx |
|---|
| 19 | # |
|---|
| 20 | # If wxWidgets is installed somewhere such that wx-config isn't on your |
|---|
| 21 | # PATH you need to indicate where wx-config is by running this script |
|---|
| 22 | # something like this: |
|---|
| 23 | # |
|---|
| 24 | # env WX_CONFIG=/path/to/wx-config ./buildmacosx.sh |
|---|
| 25 | # |
|---|
| 26 | # (If you set WX_CONFIG, there's no need to pass --no-install-wx). |
|---|
| 27 | # |
|---|
| 28 | # If using a pre-installed wxWidgets, note that it must satisfy the |
|---|
| 29 | # following requirements: |
|---|
| 30 | # - It must be built with OpenGL support (--with-opengl). |
|---|
| 31 | # - It must be the Carbon version. |
|---|
| 32 | # - It probably should be a "Unicode" build (--enable-unicode). |
|---|
| 33 | |
|---|
| 34 | set -e |
|---|
| 35 | |
|---|
| 36 | WXVERSION=2.8.11 |
|---|
| 37 | |
|---|
| 38 | # Fix to work for ppc too... |
|---|
| 39 | #arch_flags='-arch i386 -arch ppc' |
|---|
| 40 | arch_flags='-arch i386' |
|---|
| 41 | if [ -z "${WX_CONFIG+set}" ] && [ "x$1" != "x--no-install-wx" ] ; then |
|---|
| 42 | if test -x WXINSTALL/bin/wx-config ; then |
|---|
| 43 | : |
|---|
| 44 | else |
|---|
| 45 | prefix=`pwd`/WXINSTALL |
|---|
| 46 | test -f wxWidgets-$WXVERSION.tar.bz2 || \ |
|---|
| 47 | curl -O ftp://ftp.wxwidgets.org/pub/$WXVERSION/wxWidgets-$WXVERSION.tar.bz2 |
|---|
| 48 | test -d wxWidgets-$WXVERSION || tar jxvf wxWidgets-$WXVERSION.tar.bz2 |
|---|
| 49 | test -d wxWidgets-$WXVERSION/build || mkdir wxWidgets-$WXVERSION/build |
|---|
| 50 | cd wxWidgets-$WXVERSION/build |
|---|
| 51 | ../configure --disable-shared --prefix="$prefix" --with-opengl --enable-unicode CC="gcc $arch_flags" CXX="g++ $arch_flags" |
|---|
| 52 | make -s |
|---|
| 53 | make -s install |
|---|
| 54 | cd ../.. |
|---|
| 55 | fi |
|---|
| 56 | WX_CONFIG=`pwd`/WXINSTALL/bin/wx-config |
|---|
| 57 | fi |
|---|
| 58 | |
|---|
| 59 | test -n "$WX_CONFIG" || WX_CONFIG=`which wx-config` |
|---|
| 60 | if test -z "$WX_CONFIG" ; then |
|---|
| 61 | echo "WX_CONFIG not set and wx-config not on your PATH" |
|---|
| 62 | exit 1 |
|---|
| 63 | fi |
|---|
| 64 | # Force static linking so the user doesn't need to install wxWidgets. |
|---|
| 65 | WX_CONFIG=$WX_CONFIG' --static' |
|---|
| 66 | rm -rf *.dmg Survex macosxtmp |
|---|
| 67 | D=`pwd`/Survex |
|---|
| 68 | T=`pwd`/macosxtmp |
|---|
| 69 | ./configure --prefix="$D" --bindir="$D" --mandir="$T" WX_CONFIG="$WX_CONFIG" CC="gcc $arch_flags" CXX="g++ $arch_flags" |
|---|
| 70 | make |
|---|
| 71 | make install |
|---|
| 72 | #mv Survex/survex Survex/Survex |
|---|
| 73 | |
|---|
| 74 | # Construct the Aven application bundle. |
|---|
| 75 | mkdir Survex/Aven.app |
|---|
| 76 | mkdir Survex/Aven.app/Contents |
|---|
| 77 | mkdir Survex/Aven.app/Contents/MacOS |
|---|
| 78 | mkdir Survex/Aven.app/Contents/Resources |
|---|
| 79 | cp lib/Info.plist Survex/Aven.app/Contents |
|---|
| 80 | printf APPLAVEN > Survex/Aven.app/Contents/PkgInfo |
|---|
| 81 | cp -r $D/share/survex/* Survex/Aven.app/Contents/Resources/ |
|---|
| 82 | # FIXME: Generate Survex/Aven.app/Resources/Aven.icns |
|---|
| 83 | mv Survex/aven Survex/Aven.app/Contents/MacOS/ |
|---|
| 84 | rm -f Survex/share/survex/aven.txf |
|---|
| 85 | rm -rf Survex/share/survex/icons |
|---|
| 86 | |
|---|
| 87 | size=`du -s Survex|sed 's/[^0-9].*//'` |
|---|
| 88 | # Allow 1000 extra sectors for various overheads (500 wasn't enough). |
|---|
| 89 | sectors=`expr 1000 + $size` |
|---|
| 90 | # Partition needs to be at least 4M and sectors are 512 bytes. |
|---|
| 91 | if test $sectors -lt 8192 ; then |
|---|
| 92 | sectors=8192 |
|---|
| 93 | fi |
|---|
| 94 | echo "Creating new blank image survex-macosx.dmg of $sectors sectors" |
|---|
| 95 | # This creates the diskimage file and initialises it as an HFS+ volume. |
|---|
| 96 | hdiutil create -sectors $sectors survex-macosx -layout NONE -fs HFS+ -volname Survex |
|---|
| 97 | |
|---|
| 98 | echo "Presenting image to the filesystems for mounting." |
|---|
| 99 | # This will mount the image onto the Desktop. |
|---|
| 100 | # Get the name of the device we mounted it on... |
|---|
| 101 | dev=`hdid survex-macosx.dmg|tail -1|sed 's!/dev/\([!-~]*\).*!\1!;'` |
|---|
| 102 | echo "Mounted on device $dev, copying files into image." |
|---|
| 103 | ditto -rsrcFork Survex /Volumes/Survex/Survex |
|---|
| 104 | ditto lib/INSTALL.OSX /Volumes/Survex/INSTALL |
|---|
| 105 | echo "Detaching image." |
|---|
| 106 | hdiutil detach $dev |
|---|
| 107 | |
|---|
| 108 | version=`sed 's/.*AM_INIT_AUTOMAKE([^,]*, *\([0-9.]*\).*/\1/p;d' configure.in` |
|---|
| 109 | file=survex-macosx-`echo $version`.dmg |
|---|
| 110 | echo "Compressing image file survex-macosx.dmg to $file" |
|---|
| 111 | # This needs MacOS X 10.1 or above for unpacking - change UDZO to UDCO to allow |
|---|
| 112 | # the dmg to be unpacked on 10.0 as well: |
|---|
| 113 | hdiutil convert survex-macosx.dmg -format UDZO -o "$file" |
|---|
| 114 | rm survex-macosx.dmg |
|---|
| 115 | |
|---|
| 116 | echo "$file created successfully." |
|---|