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