[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). |
---|
[9aa30e7] | 34 | # - If you build with wx < 3, it probably should be a "Unicode" build |
---|
| 35 | # (--enable-unicode); wx >= 3 dropped support for non-Unicode builds. |
---|
[6df03c1] | 36 | |
---|
| 37 | set -e |
---|
[0580c6a] | 38 | |
---|
[fb880024] | 39 | WX_VERSION=3.0.2 |
---|
[2f92df0] | 40 | WX_SHA256=346879dc554f3ab8d6da2704f651ecb504a22e9d31c17ef5449b129ed711585d |
---|
[b72f4b5] | 41 | |
---|
[fb880024] | 42 | PROJ_VERSION=4.8.0 |
---|
| 43 | PROJ_SHA256=2db2dbf0fece8d9880679154e0d6d1ce7c694dd8e08b4d091028093d87a9d1b5 |
---|
| 44 | |
---|
[cc83ec9] | 45 | # Sadly, you can only specify one arch via -arch at a time (a restriction of |
---|
| 46 | # the wxWidgets build system). |
---|
| 47 | # |
---|
[95f0fb2] | 48 | # Using -arch x86_64 produces a build which will only work on 64-bit Intel |
---|
| 49 | # Macs, but that's probably all machines modern enough to worry about. |
---|
| 50 | # If you want a build which also works on 32 bit Intel Macs, then use |
---|
| 51 | # arch_flags='-arch i386' instead. |
---|
[cc83ec9] | 52 | # |
---|
[95f0fb2] | 53 | # To build for much older machines with a ppc CPU, you want arch_flags='-arch |
---|
| 54 | # ppc' instead. |
---|
| 55 | arch_flags='-arch x86_64' |
---|
[2032841] | 56 | if [ -z "${WX_CONFIG+set}" ] && [ "x$1" != "x--no-install-wx" ] ; then |
---|
[0580c6a] | 57 | if test -x WXINSTALL/bin/wx-config ; then |
---|
| 58 | : |
---|
| 59 | else |
---|
[deb58b87] | 60 | prefix=`pwd`/WXINSTALL |
---|
[fb880024] | 61 | wxtarball=wxWidgets-$WX_VERSION.tar.bz2 |
---|
[56980d4] | 62 | test -f "$wxtarball" || \ |
---|
[4dcf45a] | 63 | curl -L -O "http://downloads.sourceforge.net/project/wxwindows/$WX_VERSION/$wxtarball" |
---|
[d752afd] | 64 | if echo "$WX_SHA256 $wxtarball" | shasum -a256 -c ; then |
---|
| 65 | : # OK |
---|
| 66 | else |
---|
| 67 | echo "Checksum of downloaded file '$wxtarball' is incorrect, aborting." |
---|
| 68 | exit 1 |
---|
| 69 | fi |
---|
[56980d4] | 70 | echo "+++ Extracting $wxtarball" |
---|
[fb880024] | 71 | test -d "wxWidgets-$WX_VERSION" || tar jxf "$wxtarball" |
---|
| 72 | test -d "wxWidgets-$WX_VERSION/build" || mkdir "wxWidgets-$WX_VERSION/build" |
---|
| 73 | cd "wxWidgets-$WX_VERSION/build" |
---|
| 74 | ../configure --disable-shared --prefix="$prefix" --with-opengl --enable-unicode --disable-webview CC="gcc $arch_flags" CXX="g++ $arch_flags" |
---|
[0580c6a] | 75 | make -s |
---|
| 76 | make -s install |
---|
| 77 | cd ../.. |
---|
| 78 | fi |
---|
[b7510ee] | 79 | WX_CONFIG=`pwd`/WXINSTALL/bin/wx-config |
---|
[0580c6a] | 80 | fi |
---|
| 81 | |
---|
[fb880024] | 82 | CC=`$WX_CONFIG --cc` |
---|
| 83 | CXX=`$WX_CONFIG --cxx` |
---|
| 84 | |
---|
| 85 | if [ "x$1" != "x--no-install-proj" ] ; then |
---|
| 86 | if test -f PROJINSTALL/include/proj_api.h ; then |
---|
| 87 | : |
---|
| 88 | else |
---|
| 89 | prefix=`pwd`/PROJINSTALL |
---|
| 90 | projtarball=proj-$PROJ_VERSION.tar.gz |
---|
| 91 | test -f "$projtarball" || \ |
---|
| 92 | curl -O "http://download.osgeo.org/proj/$projtarball" |
---|
| 93 | if echo "$PROJ_SHA256 $projtarball" | shasum -a256 -c ; then |
---|
| 94 | : # OK |
---|
| 95 | else |
---|
| 96 | echo "Checksum of downloaded file '$projtarball' is incorrect, aborting." |
---|
| 97 | exit 1 |
---|
| 98 | fi |
---|
| 99 | echo "+++ Extracting $projtarball" |
---|
| 100 | test -d "proj-$PROJ_VERSION" || tar jxf "$projtarball" |
---|
| 101 | test -d "proj-$PROJ_VERSION/build" || mkdir "proj-$PROJ_VERSION/build" |
---|
| 102 | cd "proj-$PROJ_VERSION/build" |
---|
| 103 | ../configure --disable-shared --prefix="$prefix" CC="$CC" CXX="$CXX" |
---|
| 104 | make -s |
---|
| 105 | make -s install |
---|
| 106 | cd ../.. |
---|
| 107 | fi |
---|
| 108 | fi |
---|
| 109 | |
---|
[b7510ee] | 110 | test -n "$WX_CONFIG" || WX_CONFIG=`which wx-config` |
---|
| 111 | if test -z "$WX_CONFIG" ; then |
---|
| 112 | echo "WX_CONFIG not set and wx-config not on your PATH" |
---|
[6df03c1] | 113 | exit 1 |
---|
| 114 | fi |
---|
[1324d6c] | 115 | # Force static linking so the user doesn't need to install wxWidgets. |
---|
[b7510ee] | 116 | WX_CONFIG=$WX_CONFIG' --static' |
---|
[0580c6a] | 117 | rm -rf *.dmg Survex macosxtmp |
---|
[deb58b87] | 118 | D=`pwd`/Survex |
---|
| 119 | T=`pwd`/macosxtmp |
---|
[fb880024] | 120 | ./configure --prefix="$D" --bindir="$D" --mandir="$T" WX_CONFIG="$WX_CONFIG" CC="$CC" CXX="$CXX" CPPFLAGS=-I"`pwd`/PROJINSTALL/include" LDFLAGS=-L"`pwd`/PROJINSTALL/lib" |
---|
[6df03c1] | 121 | make |
---|
| 122 | make install |
---|
| 123 | #mv Survex/survex Survex/Survex |
---|
| 124 | |
---|
[b72f4b5] | 125 | # Construct the Aven application bundle. |
---|
[2032841] | 126 | mkdir Survex/Aven.app |
---|
| 127 | mkdir Survex/Aven.app/Contents |
---|
| 128 | mkdir Survex/Aven.app/Contents/MacOS |
---|
| 129 | mkdir Survex/Aven.app/Contents/Resources |
---|
| 130 | cp lib/Info.plist Survex/Aven.app/Contents |
---|
| 131 | printf APPLAVEN > Survex/Aven.app/Contents/PkgInfo |
---|
[56980d4] | 132 | cp -r "$D"/share/survex/* Survex/Aven.app/Contents/Resources/ |
---|
[2032841] | 133 | # FIXME: Generate Survex/Aven.app/Resources/Aven.icns |
---|
[b72f4b5] | 134 | mv Survex/aven Survex/Aven.app/Contents/MacOS/ |
---|
[87aa9ce] | 135 | ln Survex/cavern Survex/Aven.app/Contents/MacOS/ |
---|
[1aa3fb7] | 136 | rm -f Survex/share/survex/unifont.pixelfont |
---|
[b72f4b5] | 137 | rm -rf Survex/share/survex/icons |
---|
| 138 | |
---|
[6df03c1] | 139 | size=`du -s Survex|sed 's/[^0-9].*//'` |
---|
| 140 | # Allow 1000 extra sectors for various overheads (500 wasn't enough). |
---|
[56980d4] | 141 | sectors=`expr 1000 + "$size"` |
---|
[6df03c1] | 142 | # Partition needs to be at least 4M and sectors are 512 bytes. |
---|
[56980d4] | 143 | if test "$sectors" -lt 8192 ; then |
---|
[6df03c1] | 144 | sectors=8192 |
---|
| 145 | fi |
---|
| 146 | echo "Creating new blank image survex-macosx.dmg of $sectors sectors" |
---|
[0580c6a] | 147 | # This creates the diskimage file and initialises it as an HFS+ volume. |
---|
[56980d4] | 148 | hdiutil create -sectors "$sectors" survex-macosx -layout NONE -fs HFS+ -volname Survex |
---|
[6df03c1] | 149 | |
---|
[b72f4b5] | 150 | echo "Presenting image to the filesystems for mounting." |
---|
[6df03c1] | 151 | # This will mount the image onto the Desktop. |
---|
[ab66f3c] | 152 | # Get the name of the device it is mounted on and the mount point. |
---|
| 153 | |
---|
| 154 | # man hdiutil says: |
---|
| 155 | # "The output of [hdiutil] attach has been stable since OS X 10.0 (though it |
---|
| 156 | # was called hdid(8) then) and is intended to be program-readable. It consists |
---|
| 157 | # of the /dev node, a tab, a content hint (if applicable), another tab, and a |
---|
| 158 | # mount point (if any filesystems were mounted)." |
---|
[f04ae51] | 159 | # |
---|
| 160 | # In reality, it seems there are also some spaces before each tab character. |
---|
[ab66f3c] | 161 | hdid_output=`hdid survex-macosx.dmg|tail -1` |
---|
| 162 | echo "Last line of hdid output was: $hdid_output" |
---|
[f04ae51] | 163 | dev=`echo "$hdid_output"|sed 's!/dev/\([^ ]*\).*!\1!'` |
---|
[fc4d068] | 164 | mount_point=`echo "$hdid_output"|sed 's!.* !!'` |
---|
[ab66f3c] | 165 | |
---|
| 166 | echo "Device $dev mounted on $mount_point, copying files into image." |
---|
| 167 | ditto -rsrcFork Survex "$mount_point/Survex" |
---|
| 168 | ditto lib/INSTALL.OSX "$mount_point/INSTALL" |
---|
| 169 | |
---|
[0580c6a] | 170 | echo "Detaching image." |
---|
[56980d4] | 171 | hdiutil detach "$dev" |
---|
[6df03c1] | 172 | |
---|
[d260645] | 173 | version=`sed 's/^VERSION *= *//p;d' Makefile` |
---|
[56980d4] | 174 | file=survex-macosx-$version.dmg |
---|
[6df03c1] | 175 | echo "Compressing image file survex-macosx.dmg to $file" |
---|
[0580c6a] | 176 | # This needs MacOS X 10.1 or above for unpacking - change UDZO to UDCO to allow |
---|
| 177 | # the dmg to be unpacked on 10.0 as well: |
---|
| 178 | hdiutil convert survex-macosx.dmg -format UDZO -o "$file" |
---|
| 179 | rm survex-macosx.dmg |
---|
[6df03c1] | 180 | |
---|
| 181 | echo "$file created successfully." |
---|