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