[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 | # |
---|
[36316cb] | 6 | # Currently (at least if built on 10.6) at least 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 | # |
---|
[d959ab2] | 11 | # Run from the unpacked survex-1.2.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). |
---|
[b7510ee] | 34 | # - It probably should be a "Unicode" build (--enable-unicode). |
---|
[6df03c1] | 35 | |
---|
| 36 | set -e |
---|
[0580c6a] | 37 | |
---|
[d752afd] | 38 | WXVERSION=3.0.0 |
---|
| 39 | WX_SHA256=ff340539bcb6e45d8dbce848d3c13ebce34da6ffb9004a0a88e9541bec45bf85 |
---|
[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" || \ |
---|
[d752afd] | 58 | curl -O "http://ftp.wxwidgets.org/pub/$WXVERSION/$wxtarball" |
---|
| 59 | if echo "$WX_SHA256 $wxtarball" | shasum -a256 -c ; then |
---|
| 60 | : # OK |
---|
| 61 | else |
---|
| 62 | echo "Checksum of downloaded file '$wxtarball' is incorrect, aborting." |
---|
| 63 | exit 1 |
---|
| 64 | fi |
---|
[56980d4e] | 65 | echo "+++ Extracting $wxtarball" |
---|
| 66 | test -d "wxWidgets-$WXVERSION" || tar jxf "$wxtarball" |
---|
| 67 | test -d "wxWidgets-$WXVERSION/build" || "mkdir wxWidgets-$WXVERSION/build" |
---|
| 68 | cd "wxWidgets-$WXVERSION/build" |
---|
[f04ae51] | 69 | ../configure --disable-shared --prefix="$prefix" --with-opengl --enable-unicode CC="gcc $arch_flags" CXX="g++ $arch_flags" |
---|
[0580c6a] | 70 | make -s |
---|
| 71 | make -s install |
---|
| 72 | cd ../.. |
---|
| 73 | fi |
---|
[b7510ee] | 74 | WX_CONFIG=`pwd`/WXINSTALL/bin/wx-config |
---|
[0580c6a] | 75 | fi |
---|
| 76 | |
---|
[b7510ee] | 77 | test -n "$WX_CONFIG" || WX_CONFIG=`which wx-config` |
---|
| 78 | if test -z "$WX_CONFIG" ; then |
---|
| 79 | echo "WX_CONFIG not set and wx-config not on your PATH" |
---|
[6df03c1] | 80 | exit 1 |
---|
| 81 | fi |
---|
[1324d6c] | 82 | # Force static linking so the user doesn't need to install wxWidgets. |
---|
[b7510ee] | 83 | WX_CONFIG=$WX_CONFIG' --static' |
---|
[0580c6a] | 84 | rm -rf *.dmg Survex macosxtmp |
---|
[deb58b87] | 85 | D=`pwd`/Survex |
---|
| 86 | T=`pwd`/macosxtmp |
---|
[2032841] | 87 | ./configure --prefix="$D" --bindir="$D" --mandir="$T" WX_CONFIG="$WX_CONFIG" CC="gcc $arch_flags" CXX="g++ $arch_flags" |
---|
[6df03c1] | 88 | make |
---|
| 89 | make install |
---|
| 90 | #mv Survex/survex Survex/Survex |
---|
| 91 | |
---|
[b72f4b5] | 92 | # Construct the Aven application bundle. |
---|
[2032841] | 93 | mkdir Survex/Aven.app |
---|
| 94 | mkdir Survex/Aven.app/Contents |
---|
| 95 | mkdir Survex/Aven.app/Contents/MacOS |
---|
| 96 | mkdir Survex/Aven.app/Contents/Resources |
---|
| 97 | cp lib/Info.plist Survex/Aven.app/Contents |
---|
| 98 | printf APPLAVEN > Survex/Aven.app/Contents/PkgInfo |
---|
[56980d4e] | 99 | cp -r "$D"/share/survex/* Survex/Aven.app/Contents/Resources/ |
---|
[2032841] | 100 | # FIXME: Generate Survex/Aven.app/Resources/Aven.icns |
---|
[b72f4b5] | 101 | mv Survex/aven Survex/Aven.app/Contents/MacOS/ |
---|
[87aa9ce] | 102 | ln Survex/cavern Survex/Aven.app/Contents/MacOS/ |
---|
[1aa3fb7] | 103 | rm -f Survex/share/survex/unifont.pixelfont |
---|
[b72f4b5] | 104 | rm -rf Survex/share/survex/icons |
---|
| 105 | |
---|
[6df03c1] | 106 | size=`du -s Survex|sed 's/[^0-9].*//'` |
---|
| 107 | # Allow 1000 extra sectors for various overheads (500 wasn't enough). |
---|
[56980d4e] | 108 | sectors=`expr 1000 + "$size"` |
---|
[6df03c1] | 109 | # Partition needs to be at least 4M and sectors are 512 bytes. |
---|
[56980d4e] | 110 | if test "$sectors" -lt 8192 ; then |
---|
[6df03c1] | 111 | sectors=8192 |
---|
| 112 | fi |
---|
| 113 | echo "Creating new blank image survex-macosx.dmg of $sectors sectors" |
---|
[0580c6a] | 114 | # This creates the diskimage file and initialises it as an HFS+ volume. |
---|
[56980d4e] | 115 | hdiutil create -sectors "$sectors" survex-macosx -layout NONE -fs HFS+ -volname Survex |
---|
[6df03c1] | 116 | |
---|
[b72f4b5] | 117 | echo "Presenting image to the filesystems for mounting." |
---|
[6df03c1] | 118 | # This will mount the image onto the Desktop. |
---|
[ab66f3c] | 119 | # Get the name of the device it is mounted on and the mount point. |
---|
| 120 | |
---|
| 121 | # man hdiutil says: |
---|
| 122 | # "The output of [hdiutil] attach has been stable since OS X 10.0 (though it |
---|
| 123 | # was called hdid(8) then) and is intended to be program-readable. It consists |
---|
| 124 | # of the /dev node, a tab, a content hint (if applicable), another tab, and a |
---|
| 125 | # mount point (if any filesystems were mounted)." |
---|
[f04ae51] | 126 | # |
---|
| 127 | # In reality, it seems there are also some spaces before each tab character. |
---|
[ab66f3c] | 128 | hdid_output=`hdid survex-macosx.dmg|tail -1` |
---|
| 129 | echo "Last line of hdid output was: $hdid_output" |
---|
[f04ae51] | 130 | dev=`echo "$hdid_output"|sed 's!/dev/\([^ ]*\).*!\1!'` |
---|
| 131 | mount_point=`echo "$hdid_output"|sed 's!.*[ ]!!'` |
---|
[ab66f3c] | 132 | |
---|
| 133 | echo "Device $dev mounted on $mount_point, copying files into image." |
---|
| 134 | ditto -rsrcFork Survex "$mount_point/Survex" |
---|
| 135 | ditto lib/INSTALL.OSX "$mount_point/INSTALL" |
---|
| 136 | |
---|
[0580c6a] | 137 | echo "Detaching image." |
---|
[56980d4e] | 138 | hdiutil detach "$dev" |
---|
[6df03c1] | 139 | |
---|
[d260645] | 140 | version=`sed 's/^VERSION *= *//p;d' Makefile` |
---|
[56980d4e] | 141 | file=survex-macosx-$version.dmg |
---|
[6df03c1] | 142 | echo "Compressing image file survex-macosx.dmg to $file" |
---|
[0580c6a] | 143 | # This needs MacOS X 10.1 or above for unpacking - change UDZO to UDCO to allow |
---|
| 144 | # the dmg to be unpacked on 10.0 as well: |
---|
| 145 | hdiutil convert survex-macosx.dmg -format UDZO -o "$file" |
---|
| 146 | rm survex-macosx.dmg |
---|
[6df03c1] | 147 | |
---|
| 148 | echo "$file created successfully." |
---|