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) 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.1.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 | # - It must be the Carbon version. |
---|
35 | # - It probably should be a "Unicode" build (--enable-unicode). |
---|
36 | |
---|
37 | set -e |
---|
38 | |
---|
39 | # 2.8.12 doesn't work: |
---|
40 | # /bin/sh: line 0: cd: ../build/bakefiles/wxpresets/presets: No such file or directory |
---|
41 | # cp: wx.bkl: No such file or directory |
---|
42 | # [...] |
---|
43 | WXVERSION=2.8.11 |
---|
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 i386 produces a build which will also work on 64-bit Intel Macs. |
---|
49 | # If you want a build which *only* works on 64 bit Intel Macs, then use |
---|
50 | # arch_flags='-arch x86_64' instead. |
---|
51 | # |
---|
52 | # To build for older machines with a ppc CPU, you want arch_flags='-arch ppc' |
---|
53 | # instead. |
---|
54 | arch_flags='-arch i386' |
---|
55 | if [ -z "${WX_CONFIG+set}" ] && [ "x$1" != "x--no-install-wx" ] ; then |
---|
56 | if test -x WXINSTALL/bin/wx-config ; then |
---|
57 | : |
---|
58 | else |
---|
59 | prefix=`pwd`/WXINSTALL |
---|
60 | wxtarball=wxWidgets-$WXVERSION.tar.bz2 |
---|
61 | test -f "$wxtarball" || \ |
---|
62 | curl -O "ftp://ftp.wxwidgets.org/pub/$WXVERSION/$wxtarball" |
---|
63 | echo "+++ Extracting $wxtarball" |
---|
64 | test -d "wxWidgets-$WXVERSION" || tar jxf "$wxtarball" |
---|
65 | test -d "wxWidgets-$WXVERSION/build" || "mkdir wxWidgets-$WXVERSION/build" |
---|
66 | cd "wxWidgets-$WXVERSION/build" |
---|
67 | ../configure --disable-shared --prefix="$prefix" --with-opengl --enable-unicode CC="gcc $arch_flags" CXX="g++ $arch_flags" |
---|
68 | make -s |
---|
69 | make -s install |
---|
70 | cd ../.. |
---|
71 | fi |
---|
72 | WX_CONFIG=`pwd`/WXINSTALL/bin/wx-config |
---|
73 | fi |
---|
74 | |
---|
75 | test -n "$WX_CONFIG" || WX_CONFIG=`which wx-config` |
---|
76 | if test -z "$WX_CONFIG" ; then |
---|
77 | echo "WX_CONFIG not set and wx-config not on your PATH" |
---|
78 | exit 1 |
---|
79 | fi |
---|
80 | # Force static linking so the user doesn't need to install wxWidgets. |
---|
81 | WX_CONFIG=$WX_CONFIG' --static' |
---|
82 | rm -rf *.dmg Survex macosxtmp |
---|
83 | D=`pwd`/Survex |
---|
84 | T=`pwd`/macosxtmp |
---|
85 | ./configure --prefix="$D" --bindir="$D" --mandir="$T" WX_CONFIG="$WX_CONFIG" CC="gcc $arch_flags" CXX="g++ $arch_flags" |
---|
86 | make |
---|
87 | make install |
---|
88 | #mv Survex/survex Survex/Survex |
---|
89 | |
---|
90 | # Construct the Aven application bundle. |
---|
91 | mkdir Survex/Aven.app |
---|
92 | mkdir Survex/Aven.app/Contents |
---|
93 | mkdir Survex/Aven.app/Contents/MacOS |
---|
94 | mkdir Survex/Aven.app/Contents/Resources |
---|
95 | cp lib/Info.plist Survex/Aven.app/Contents |
---|
96 | printf APPLAVEN > Survex/Aven.app/Contents/PkgInfo |
---|
97 | cp -r "$D"/share/survex/* Survex/Aven.app/Contents/Resources/ |
---|
98 | # FIXME: Generate Survex/Aven.app/Resources/Aven.icns |
---|
99 | mv Survex/aven Survex/Aven.app/Contents/MacOS/ |
---|
100 | rm -f Survex/share/survex/aven.txf |
---|
101 | rm -rf Survex/share/survex/icons |
---|
102 | |
---|
103 | size=`du -s Survex|sed 's/[^0-9].*//'` |
---|
104 | # Allow 1000 extra sectors for various overheads (500 wasn't enough). |
---|
105 | sectors=`expr 1000 + "$size"` |
---|
106 | # Partition needs to be at least 4M and sectors are 512 bytes. |
---|
107 | if test "$sectors" -lt 8192 ; then |
---|
108 | sectors=8192 |
---|
109 | fi |
---|
110 | echo "Creating new blank image survex-macosx.dmg of $sectors sectors" |
---|
111 | # This creates the diskimage file and initialises it as an HFS+ volume. |
---|
112 | hdiutil create -sectors "$sectors" survex-macosx -layout NONE -fs HFS+ -volname Survex |
---|
113 | |
---|
114 | echo "Presenting image to the filesystems for mounting." |
---|
115 | # This will mount the image onto the Desktop. |
---|
116 | # Get the name of the device it is mounted on and the mount point. |
---|
117 | |
---|
118 | # man hdiutil says: |
---|
119 | # "The output of [hdiutil] attach has been stable since OS X 10.0 (though it |
---|
120 | # was called hdid(8) then) and is intended to be program-readable. It consists |
---|
121 | # of the /dev node, a tab, a content hint (if applicable), another tab, and a |
---|
122 | # mount point (if any filesystems were mounted)." |
---|
123 | # |
---|
124 | # In reality, it seems there are also some spaces before each tab character. |
---|
125 | hdid_output=`hdid survex-macosx.dmg|tail -1` |
---|
126 | echo "Last line of hdid output was: $hdid_output" |
---|
127 | dev=`echo "$hdid_output"|sed 's!/dev/\([^ ]*\).*!\1!'` |
---|
128 | mount_point=`echo "$hdid_output"|sed 's!.*[ ]!!'` |
---|
129 | |
---|
130 | echo "Device $dev mounted on $mount_point, copying files into image." |
---|
131 | ditto -rsrcFork Survex "$mount_point/Survex" |
---|
132 | ditto lib/INSTALL.OSX "$mount_point/INSTALL" |
---|
133 | |
---|
134 | echo "Detaching image." |
---|
135 | hdiutil detach "$dev" |
---|
136 | |
---|
137 | version=`sed 's/.*AM_INIT_AUTOMAKE([^,]*, *\([0-9.]*\).*/\1/p;d' configure.in` |
---|
138 | file=survex-macosx-$version.dmg |
---|
139 | echo "Compressing image file survex-macosx.dmg to $file" |
---|
140 | # This needs MacOS X 10.1 or above for unpacking - change UDZO to UDCO to allow |
---|
141 | # the dmg to be unpacked on 10.0 as well: |
---|
142 | hdiutil convert survex-macosx.dmg -format UDZO -o "$file" |
---|
143 | rm survex-macosx.dmg |
---|
144 | |
---|
145 | echo "$file created successfully." |
---|