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