[6df03c1] | 1 | #!/bin/sh |
---|
| 2 | # |
---|
[9d49627] | 3 | # You'll need some development tools which aren't installed by default. To |
---|
| 4 | # get these you can install Xcode (which is a free download from Apple): |
---|
[0580c6a] | 5 | # |
---|
[9d49627] | 6 | # https://developer.apple.com/xcode/downloads/ |
---|
[2032841] | 7 | # |
---|
[9d49627] | 8 | # To build, open a terminal (Terminal.app in the "Utils" folder in |
---|
| 9 | # "Applications") and unpack the downloaded survex source code. E.g. for |
---|
| 10 | # 1.2.17: |
---|
[cc83ec9] | 11 | # |
---|
[9d49627] | 12 | # tar xf survex-1.2.17.tar.gz |
---|
| 13 | # |
---|
| 14 | # Then change directory into the unpacked sources: |
---|
| 15 | # |
---|
| 16 | # cd survex-1.2.17 |
---|
| 17 | # |
---|
| 18 | # And then run this script: |
---|
[6df03c1] | 19 | # |
---|
[2032841] | 20 | # ./buildmacosx.sh |
---|
[0580c6a] | 21 | # |
---|
[9d49627] | 22 | # This will automatically download and temporarily install wxWidgets in |
---|
| 23 | # a subdirectory of the source tree (this script is smart enough not to |
---|
| 24 | # download or build it if it already has). |
---|
[0580c6a] | 25 | # |
---|
[1324d6c] | 26 | # If you already have wxWidgets installed permanently, use: |
---|
[0580c6a] | 27 | # |
---|
[2032841] | 28 | # ./buildmacosx.sh --no-install-wx |
---|
[6df03c1] | 29 | # |
---|
[1324d6c] | 30 | # If wxWidgets is installed somewhere such that wx-config isn't on your |
---|
[6df03c1] | 31 | # PATH you need to indicate where wx-config is by running this script |
---|
| 32 | # something like this: |
---|
| 33 | # |
---|
[b7510ee] | 34 | # env WX_CONFIG=/path/to/wx-config ./buildmacosx.sh |
---|
[b72f4b5] | 35 | # |
---|
[2032841] | 36 | # (If you set WX_CONFIG, there's no need to pass --no-install-wx). |
---|
| 37 | # |
---|
[1324d6c] | 38 | # If using a pre-installed wxWidgets, note that it must satisfy the |
---|
[b72f4b5] | 39 | # following requirements: |
---|
[0167e06] | 40 | # |
---|
[b72f4b5] | 41 | # - It must be built with OpenGL support (--with-opengl). |
---|
[0167e06] | 42 | # |
---|
| 43 | # We strongly recommend using wxWidgets >= 3.0, but if you want to build with |
---|
| 44 | # wxWidgets 2.8, it probably should be a "Unicode" build (--enable-unicode); |
---|
| 45 | # wxWidgets >= 3.0 effectively is always a "Unicode" build, so the |
---|
| 46 | # --enable-unicode option isn't needed (and is ignored if specified). |
---|
[9d49627] | 47 | # |
---|
| 48 | # This script builds diskimages which are known to work at least as far back |
---|
| 49 | # as OS X 10.6.8. A build of wxWidgets 3.0.2 with the options we pass will |
---|
| 50 | # default to assuming at least OS X 10.5, but we've not heard from anyone |
---|
| 51 | # trying with such an old version. |
---|
[c72a344] | 52 | # |
---|
| 53 | # Mac OS X support "fat" binaries which contain code for more than one |
---|
| 54 | # processor, but the wxWidgets build system doesn't seem to allow creating |
---|
| 55 | # these, so we have to choose what processor family to build for. By default |
---|
| 56 | # we use -arch x86_64 which produces a build which will only work on 64-bit |
---|
| 57 | # Intel Macs, but that's probably all machines modern enough to worry about. |
---|
| 58 | # |
---|
| 59 | # If you want a build which also works on older 32 bit Intel Macs, then run |
---|
| 60 | # this script passing i386 on the command line, like so: |
---|
| 61 | # |
---|
| 62 | # ./buildmacosx.sh i386 |
---|
| 63 | # |
---|
| 64 | # Or to build for much older machines with a Power PC processor, use: |
---|
| 65 | # |
---|
| 66 | # ./buildmacosx.sh ppc |
---|
[6df03c1] | 67 | |
---|
| 68 | set -e |
---|
[0580c6a] | 69 | |
---|
[9d49627] | 70 | install_wx=yes |
---|
| 71 | install_proj=yes |
---|
| 72 | while [ "$#" != 0 ] ; do |
---|
| 73 | case $1 in |
---|
| 74 | --no-install-wx) |
---|
| 75 | install_wx=no |
---|
| 76 | shift |
---|
| 77 | ;; |
---|
| 78 | --no-install-proj) |
---|
| 79 | install_proj=no |
---|
| 80 | shift |
---|
| 81 | ;; |
---|
| 82 | --help|-h) |
---|
| 83 | echo "Usage: $0 [--no-install-wx] [--no-install-proj] [ppc|i386|x86_86]" |
---|
| 84 | exit 0 |
---|
| 85 | ;; |
---|
| 86 | -*) |
---|
| 87 | echo "Unknown option - try --help" >&2 |
---|
| 88 | exit 1 |
---|
| 89 | ;; |
---|
| 90 | *) |
---|
| 91 | break |
---|
| 92 | ;; |
---|
| 93 | esac |
---|
| 94 | done |
---|
| 95 | |
---|
| 96 | arch_flags='-arch '${1:-x86_64} |
---|
| 97 | |
---|
[0a287d2] | 98 | # UDBZ means the resultant disk image will only open on OS X 10.4 or above. |
---|
| 99 | # UDZO works on 10.1 and later, but is larger, UDCO works on 10.0 as well, |
---|
| 100 | # but is larger still. |
---|
| 101 | dmg_format=UDBZ |
---|
| 102 | |
---|
[fb880024] | 103 | WX_VERSION=3.0.2 |
---|
[2f92df0] | 104 | WX_SHA256=346879dc554f3ab8d6da2704f651ecb504a22e9d31c17ef5449b129ed711585d |
---|
[b72f4b5] | 105 | |
---|
[fb880024] | 106 | PROJ_VERSION=4.8.0 |
---|
| 107 | PROJ_SHA256=2db2dbf0fece8d9880679154e0d6d1ce7c694dd8e08b4d091028093d87a9d1b5 |
---|
| 108 | |
---|
[9d49627] | 109 | if [ -z "${WX_CONFIG+set}" ] && [ "$install_wx" != no ] ; then |
---|
[0580c6a] | 110 | if test -x WXINSTALL/bin/wx-config ; then |
---|
| 111 | : |
---|
| 112 | else |
---|
[deb58b87] | 113 | prefix=`pwd`/WXINSTALL |
---|
[fb880024] | 114 | wxtarball=wxWidgets-$WX_VERSION.tar.bz2 |
---|
[56980d4e] | 115 | test -f "$wxtarball" || \ |
---|
[4dcf45a] | 116 | curl -L -O "http://downloads.sourceforge.net/project/wxwindows/$WX_VERSION/$wxtarball" |
---|
[d752afd] | 117 | if echo "$WX_SHA256 $wxtarball" | shasum -a256 -c ; then |
---|
| 118 | : # OK |
---|
| 119 | else |
---|
| 120 | echo "Checksum of downloaded file '$wxtarball' is incorrect, aborting." |
---|
| 121 | exit 1 |
---|
| 122 | fi |
---|
[56980d4e] | 123 | echo "+++ Extracting $wxtarball" |
---|
[fb880024] | 124 | test -d "wxWidgets-$WX_VERSION" || tar jxf "$wxtarball" |
---|
[976a038] | 125 | test -d "wxWidgets-$WX_VERSION/BUILD" || mkdir "wxWidgets-$WX_VERSION/BUILD" |
---|
| 126 | cd "wxWidgets-$WX_VERSION/BUILD" |
---|
[4df1235] | 127 | # Compilation of wx 3.0.2 fails on OS X 10.10.1 with webview enabled. |
---|
[1fce809] | 128 | # A build with liblzma enabled doesn't work on OS X 10.6.8. |
---|
| 129 | ../configure --disable-shared --prefix="$prefix" \ |
---|
[cf9156d] | 130 | --with-opengl --enable-display \ |
---|
[1fce809] | 131 | --disable-webview --without-liblzma \ |
---|
| 132 | CC="gcc $arch_flags" CXX="g++ $arch_flags" |
---|
[0580c6a] | 133 | make -s |
---|
| 134 | make -s install |
---|
| 135 | cd ../.. |
---|
| 136 | fi |
---|
[b7510ee] | 137 | WX_CONFIG=`pwd`/WXINSTALL/bin/wx-config |
---|
[0580c6a] | 138 | fi |
---|
| 139 | |
---|
[fb880024] | 140 | CC=`$WX_CONFIG --cc` |
---|
| 141 | CXX=`$WX_CONFIG --cxx` |
---|
| 142 | |
---|
[9d49627] | 143 | if [ "$install_proj" != no ] ; then |
---|
[fb880024] | 144 | if test -f PROJINSTALL/include/proj_api.h ; then |
---|
| 145 | : |
---|
| 146 | else |
---|
| 147 | prefix=`pwd`/PROJINSTALL |
---|
| 148 | projtarball=proj-$PROJ_VERSION.tar.gz |
---|
| 149 | test -f "$projtarball" || \ |
---|
| 150 | curl -O "http://download.osgeo.org/proj/$projtarball" |
---|
| 151 | if echo "$PROJ_SHA256 $projtarball" | shasum -a256 -c ; then |
---|
| 152 | : # OK |
---|
| 153 | else |
---|
| 154 | echo "Checksum of downloaded file '$projtarball' is incorrect, aborting." |
---|
| 155 | exit 1 |
---|
| 156 | fi |
---|
| 157 | echo "+++ Extracting $projtarball" |
---|
| 158 | test -d "proj-$PROJ_VERSION" || tar jxf "$projtarball" |
---|
[976a038] | 159 | test -d "proj-$PROJ_VERSION/BUILD" || mkdir "proj-$PROJ_VERSION/BUILD" |
---|
| 160 | cd "proj-$PROJ_VERSION/BUILD" |
---|
[fb880024] | 161 | ../configure --disable-shared --prefix="$prefix" CC="$CC" CXX="$CXX" |
---|
| 162 | make -s |
---|
| 163 | make -s install |
---|
| 164 | cd ../.. |
---|
| 165 | fi |
---|
| 166 | fi |
---|
| 167 | |
---|
[b7510ee] | 168 | test -n "$WX_CONFIG" || WX_CONFIG=`which wx-config` |
---|
| 169 | if test -z "$WX_CONFIG" ; then |
---|
| 170 | echo "WX_CONFIG not set and wx-config not on your PATH" |
---|
[6df03c1] | 171 | exit 1 |
---|
| 172 | fi |
---|
[1324d6c] | 173 | # Force static linking so the user doesn't need to install wxWidgets. |
---|
[b7510ee] | 174 | WX_CONFIG=$WX_CONFIG' --static' |
---|
[0580c6a] | 175 | rm -rf *.dmg Survex macosxtmp |
---|
[deb58b87] | 176 | D=`pwd`/Survex |
---|
| 177 | T=`pwd`/macosxtmp |
---|
[fb880024] | 178 | ./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] | 179 | make |
---|
| 180 | make install |
---|
| 181 | #mv Survex/survex Survex/Survex |
---|
| 182 | |
---|
[b72f4b5] | 183 | # Construct the Aven application bundle. |
---|
[9e44985] | 184 | mkdir -p Survex/Aven.app/Contents/MacOS Survex/Aven.app/Contents/Resources |
---|
[2032841] | 185 | cp lib/Info.plist Survex/Aven.app/Contents |
---|
| 186 | printf APPLAVEN > Survex/Aven.app/Contents/PkgInfo |
---|
[09dfd18] | 187 | mv Survex/share/doc/survex Survex/Docs |
---|
| 188 | rmdir Survex/share/doc |
---|
| 189 | rm -rf Survex/share/survex/icons |
---|
| 190 | cp -r Survex/share/survex/* Survex/Aven.app/Contents/Resources/ |
---|
[58e9ce0] | 191 | rm Survex/Aven.app/Contents/Resources/bcra*.svx |
---|
[b72f4b5] | 192 | mv Survex/aven Survex/Aven.app/Contents/MacOS/ |
---|
[87aa9ce] | 193 | ln Survex/cavern Survex/Aven.app/Contents/MacOS/ |
---|
[1aa3fb7] | 194 | rm -f Survex/share/survex/unifont.pixelfont |
---|
[58e9ce0] | 195 | rm -rf Survex/share/applications Survex/share/mime-info Survex/share/pixmaps |
---|
[b72f4b5] | 196 | |
---|
[e157b8f] | 197 | # Create .icns files in the bundle's "Resources" directory. |
---|
[8b16cc4] | 198 | for zip in lib/icons/*.iconset.zip ; do |
---|
| 199 | unzip -d Survex/Aven.app/Contents/Resources "$zip" |
---|
| 200 | i=`echo "$zip"|sed 's!.*/\(.*\)\.zip$!\1!'` |
---|
| 201 | iconutil --convert icns "Survex/Aven.app/Contents/Resources/$i" |
---|
| 202 | rm -rf "Survex/Aven.app/Contents/Resources/$i" |
---|
[e157b8f] | 203 | done |
---|
| 204 | |
---|
[6df03c1] | 205 | size=`du -s Survex|sed 's/[^0-9].*//'` |
---|
| 206 | # Allow 1000 extra sectors for various overheads (500 wasn't enough). |
---|
[56980d4e] | 207 | sectors=`expr 1000 + "$size"` |
---|
[6df03c1] | 208 | # Partition needs to be at least 4M and sectors are 512 bytes. |
---|
[56980d4e] | 209 | if test "$sectors" -lt 8192 ; then |
---|
[6df03c1] | 210 | sectors=8192 |
---|
| 211 | fi |
---|
| 212 | echo "Creating new blank image survex-macosx.dmg of $sectors sectors" |
---|
[0580c6a] | 213 | # This creates the diskimage file and initialises it as an HFS+ volume. |
---|
[56980d4e] | 214 | hdiutil create -sectors "$sectors" survex-macosx -layout NONE -fs HFS+ -volname Survex |
---|
[6df03c1] | 215 | |
---|
[b72f4b5] | 216 | echo "Presenting image to the filesystems for mounting." |
---|
[6df03c1] | 217 | # This will mount the image onto the Desktop. |
---|
[ab66f3c] | 218 | # Get the name of the device it is mounted on and the mount point. |
---|
| 219 | |
---|
| 220 | # man hdiutil says: |
---|
| 221 | # "The output of [hdiutil] attach has been stable since OS X 10.0 (though it |
---|
| 222 | # was called hdid(8) then) and is intended to be program-readable. It consists |
---|
| 223 | # of the /dev node, a tab, a content hint (if applicable), another tab, and a |
---|
| 224 | # mount point (if any filesystems were mounted)." |
---|
[f04ae51] | 225 | # |
---|
| 226 | # In reality, it seems there are also some spaces before each tab character. |
---|
[ab66f3c] | 227 | hdid_output=`hdid survex-macosx.dmg|tail -1` |
---|
| 228 | echo "Last line of hdid output was: $hdid_output" |
---|
[f04ae51] | 229 | dev=`echo "$hdid_output"|sed 's!/dev/\([^ ]*\).*!\1!'` |
---|
[fc4d068] | 230 | mount_point=`echo "$hdid_output"|sed 's!.* !!'` |
---|
[ab66f3c] | 231 | |
---|
| 232 | echo "Device $dev mounted on $mount_point, copying files into image." |
---|
| 233 | ditto -rsrcFork Survex "$mount_point/Survex" |
---|
| 234 | ditto lib/INSTALL.OSX "$mount_point/INSTALL" |
---|
| 235 | |
---|
[0580c6a] | 236 | echo "Detaching image." |
---|
[56980d4e] | 237 | hdiutil detach "$dev" |
---|
[6df03c1] | 238 | |
---|
[d260645] | 239 | version=`sed 's/^VERSION *= *//p;d' Makefile` |
---|
[56980d4e] | 240 | file=survex-macosx-$version.dmg |
---|
[6df03c1] | 241 | echo "Compressing image file survex-macosx.dmg to $file" |
---|
[0a287d2] | 242 | hdiutil convert survex-macosx.dmg -format "$dmg_format" -o "$file" |
---|
[0580c6a] | 243 | rm survex-macosx.dmg |
---|
[6df03c1] | 244 | |
---|
| 245 | echo "$file created successfully." |
---|