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