1 | #!/bin/sh |
---|
2 | # |
---|
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 | # |
---|
6 | # Currently (at least if built on 10.6) at least 10.6 is required to run. |
---|
7 | # |
---|
8 | # You probably need to have Xcode installed - you can download this for free |
---|
9 | # from Apple: http://developer.apple.com/xcode/ |
---|
10 | # |
---|
11 | # Run from the unpacked survex-1.2.X directory like so: |
---|
12 | # |
---|
13 | # ./buildmacosx.sh |
---|
14 | # |
---|
15 | # This will automatically download and temporarily install wxWidgets |
---|
16 | # (this script is smart enough not to download or build it if it already |
---|
17 | # has). |
---|
18 | # |
---|
19 | # If you already have wxWidgets installed permanently, use: |
---|
20 | # |
---|
21 | # ./buildmacosx.sh --no-install-wx |
---|
22 | # |
---|
23 | # If wxWidgets is installed somewhere such that wx-config isn't on your |
---|
24 | # PATH you need to indicate where wx-config is by running this script |
---|
25 | # something like this: |
---|
26 | # |
---|
27 | # env WX_CONFIG=/path/to/wx-config ./buildmacosx.sh |
---|
28 | # |
---|
29 | # (If you set WX_CONFIG, there's no need to pass --no-install-wx). |
---|
30 | # |
---|
31 | # If using a pre-installed wxWidgets, note that it must satisfy the |
---|
32 | # following requirements: |
---|
33 | # - It must be built with OpenGL support (--with-opengl). |
---|
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. |
---|
36 | |
---|
37 | set -e |
---|
38 | |
---|
39 | WX_VERSION=3.0.2 |
---|
40 | WX_SHA256=346879dc554f3ab8d6da2704f651ecb504a22e9d31c17ef5449b129ed711585d |
---|
41 | |
---|
42 | PROJ_VERSION=4.8.0 |
---|
43 | PROJ_SHA256=2db2dbf0fece8d9880679154e0d6d1ce7c694dd8e08b4d091028093d87a9d1b5 |
---|
44 | |
---|
45 | # Sadly, you can only specify one arch via -arch at a time (a restriction of |
---|
46 | # the wxWidgets build system). |
---|
47 | # |
---|
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. |
---|
52 | # |
---|
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' |
---|
56 | if [ -z "${WX_CONFIG+set}" ] && [ "x$1" != "x--no-install-wx" ] ; then |
---|
57 | if test -x WXINSTALL/bin/wx-config ; then |
---|
58 | : |
---|
59 | else |
---|
60 | prefix=`pwd`/WXINSTALL |
---|
61 | wxtarball=wxWidgets-$WX_VERSION.tar.bz2 |
---|
62 | test -f "$wxtarball" || \ |
---|
63 | curl -L -O "http://downloads.sourceforge.net/project/wxwindows/$WX_VERSION/$wxtarball" |
---|
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 |
---|
70 | echo "+++ Extracting $wxtarball" |
---|
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 | # Compliation of wx 3.0.2 fails on OS X 10.10.1 with webview enabled. |
---|
75 | # A build with liblzma enabled doesn't work on OS X 10.6.8. |
---|
76 | ../configure --disable-shared --prefix="$prefix" \ |
---|
77 | --with-opengl --enable-unicode \ |
---|
78 | --disable-webview --without-liblzma \ |
---|
79 | CC="gcc $arch_flags" CXX="g++ $arch_flags" |
---|
80 | make -s |
---|
81 | make -s install |
---|
82 | cd ../.. |
---|
83 | fi |
---|
84 | WX_CONFIG=`pwd`/WXINSTALL/bin/wx-config |
---|
85 | fi |
---|
86 | |
---|
87 | CC=`$WX_CONFIG --cc` |
---|
88 | CXX=`$WX_CONFIG --cxx` |
---|
89 | |
---|
90 | if [ "x$1" != "x--no-install-proj" ] ; then |
---|
91 | if test -f PROJINSTALL/include/proj_api.h ; then |
---|
92 | : |
---|
93 | else |
---|
94 | prefix=`pwd`/PROJINSTALL |
---|
95 | projtarball=proj-$PROJ_VERSION.tar.gz |
---|
96 | test -f "$projtarball" || \ |
---|
97 | curl -O "http://download.osgeo.org/proj/$projtarball" |
---|
98 | if echo "$PROJ_SHA256 $projtarball" | shasum -a256 -c ; then |
---|
99 | : # OK |
---|
100 | else |
---|
101 | echo "Checksum of downloaded file '$projtarball' is incorrect, aborting." |
---|
102 | exit 1 |
---|
103 | fi |
---|
104 | echo "+++ Extracting $projtarball" |
---|
105 | test -d "proj-$PROJ_VERSION" || tar jxf "$projtarball" |
---|
106 | test -d "proj-$PROJ_VERSION/build" || mkdir "proj-$PROJ_VERSION/build" |
---|
107 | cd "proj-$PROJ_VERSION/build" |
---|
108 | ../configure --disable-shared --prefix="$prefix" CC="$CC" CXX="$CXX" |
---|
109 | make -s |
---|
110 | make -s install |
---|
111 | cd ../.. |
---|
112 | fi |
---|
113 | fi |
---|
114 | |
---|
115 | test -n "$WX_CONFIG" || WX_CONFIG=`which wx-config` |
---|
116 | if test -z "$WX_CONFIG" ; then |
---|
117 | echo "WX_CONFIG not set and wx-config not on your PATH" |
---|
118 | exit 1 |
---|
119 | fi |
---|
120 | # Force static linking so the user doesn't need to install wxWidgets. |
---|
121 | WX_CONFIG=$WX_CONFIG' --static' |
---|
122 | rm -rf *.dmg Survex macosxtmp |
---|
123 | D=`pwd`/Survex |
---|
124 | T=`pwd`/macosxtmp |
---|
125 | ./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" |
---|
126 | make |
---|
127 | make install |
---|
128 | #mv Survex/survex Survex/Survex |
---|
129 | |
---|
130 | # Construct the Aven application bundle. |
---|
131 | mkdir -p Survex/Aven.app/Contents/MacOS Survex/Aven.app/Contents/Resources |
---|
132 | cp lib/Info.plist Survex/Aven.app/Contents |
---|
133 | printf APPLAVEN > Survex/Aven.app/Contents/PkgInfo |
---|
134 | cp -r "$D"/share/survex/* Survex/Aven.app/Contents/Resources/ |
---|
135 | rm Survex/Aven.app/Contents/Resources/bcra*.svx |
---|
136 | rm Survex/Aven.app/Contents/Resources/icons/3d.png |
---|
137 | rm Survex/Aven.app/Contents/Resources/icons/err.png |
---|
138 | rm Survex/Aven.app/Contents/Resources/icons/plt.png |
---|
139 | rm Survex/Aven.app/Contents/Resources/icons/pos.png |
---|
140 | rm Survex/Aven.app/Contents/Resources/icons/svx.png |
---|
141 | mv Survex/aven Survex/Aven.app/Contents/MacOS/ |
---|
142 | ln Survex/cavern Survex/Aven.app/Contents/MacOS/ |
---|
143 | mv Survex/share/doc/survex Survex/Docs |
---|
144 | rmdir Survex/share/doc |
---|
145 | rm -f Survex/share/survex/unifont.pixelfont |
---|
146 | rm -rf Survex/share/survex/icons |
---|
147 | rm -rf Survex/share/applications Survex/share/mime-info Survex/share/pixmaps |
---|
148 | |
---|
149 | # Create .icns files in the bundle's "Resources" directory. |
---|
150 | for i in Aven svxedit 3d err plt pos svx ; do |
---|
151 | unzip -d Survex/Aven.app/Contents/Resources "lib/icons/$i.iconset.zip" |
---|
152 | iconutil --convert icns "Survex/Aven.app/Contents/Resources/$i.iconset" |
---|
153 | rm -rf "Survex/Aven.app/Contents/Resources/$i.iconset" |
---|
154 | done |
---|
155 | |
---|
156 | # Construct the svxedit application bundle. |
---|
157 | mkdir -p Survex/svxedit.App/Contents/MacOS Survex/svxedit.App/Contents/Resources |
---|
158 | cp lib/svxedit_Info.plist Survex/svxedit.App/Contents/Info.plist |
---|
159 | printf APPLSVXE > Survex/svxedit.App/Contents/PkgInfo |
---|
160 | mv Survex/svxedit Survex/svxedit_wrap Survex/svxedit.App/Contents/MacOS/ |
---|
161 | |
---|
162 | mv Survex/Aven.app/Contents/Resources/svxedit.icns \ |
---|
163 | Survex/svxedit.App/Contents/Resources |
---|
164 | ln Survex/Aven.app/Contents/Resources/svx.icns \ |
---|
165 | Survex/svxedit.App/Contents/Resources |
---|
166 | |
---|
167 | size=`du -s Survex|sed 's/[^0-9].*//'` |
---|
168 | # Allow 1000 extra sectors for various overheads (500 wasn't enough). |
---|
169 | sectors=`expr 1000 + "$size"` |
---|
170 | # Partition needs to be at least 4M and sectors are 512 bytes. |
---|
171 | if test "$sectors" -lt 8192 ; then |
---|
172 | sectors=8192 |
---|
173 | fi |
---|
174 | echo "Creating new blank image survex-macosx.dmg of $sectors sectors" |
---|
175 | # This creates the diskimage file and initialises it as an HFS+ volume. |
---|
176 | hdiutil create -sectors "$sectors" survex-macosx -layout NONE -fs HFS+ -volname Survex |
---|
177 | |
---|
178 | echo "Presenting image to the filesystems for mounting." |
---|
179 | # This will mount the image onto the Desktop. |
---|
180 | # Get the name of the device it is mounted on and the mount point. |
---|
181 | |
---|
182 | # man hdiutil says: |
---|
183 | # "The output of [hdiutil] attach has been stable since OS X 10.0 (though it |
---|
184 | # was called hdid(8) then) and is intended to be program-readable. It consists |
---|
185 | # of the /dev node, a tab, a content hint (if applicable), another tab, and a |
---|
186 | # mount point (if any filesystems were mounted)." |
---|
187 | # |
---|
188 | # In reality, it seems there are also some spaces before each tab character. |
---|
189 | hdid_output=`hdid survex-macosx.dmg|tail -1` |
---|
190 | echo "Last line of hdid output was: $hdid_output" |
---|
191 | dev=`echo "$hdid_output"|sed 's!/dev/\([^ ]*\).*!\1!'` |
---|
192 | mount_point=`echo "$hdid_output"|sed 's!.* !!'` |
---|
193 | |
---|
194 | echo "Device $dev mounted on $mount_point, copying files into image." |
---|
195 | ditto -rsrcFork Survex "$mount_point/Survex" |
---|
196 | ditto lib/INSTALL.OSX "$mount_point/INSTALL" |
---|
197 | |
---|
198 | echo "Detaching image." |
---|
199 | hdiutil detach "$dev" |
---|
200 | |
---|
201 | version=`sed 's/^VERSION *= *//p;d' Makefile` |
---|
202 | file=survex-macosx-$version.dmg |
---|
203 | echo "Compressing image file survex-macosx.dmg to $file" |
---|
204 | # UDBZ means the resultant disk image will only open on OS X 10.4 or above. |
---|
205 | # UDZO works on 10.1 and later, but is larger, UDCO works on 10.0 as well. |
---|
206 | hdiutil convert survex-macosx.dmg -format UDBZ -o "$file" |
---|
207 | rm survex-macosx.dmg |
---|
208 | |
---|
209 | echo "$file created successfully." |
---|