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 | # Run from the unpacked survex-1.1.X directory like so: |
---|
7 | # |
---|
8 | # ./buildmacosx.sh --install-wx |
---|
9 | # |
---|
10 | # This will automatically download and temporarily install wxWidgets |
---|
11 | # (this script is smart enough not to download or build it if it already |
---|
12 | # has). |
---|
13 | # |
---|
14 | # If you already have wxWidgets installed permanently, use: |
---|
15 | # |
---|
16 | # ./buildmacosx.sh |
---|
17 | # |
---|
18 | # If wxWidgets is installed somewhere such that wx-config isn't on your |
---|
19 | # PATH you need to indicate where wx-config is by running this script |
---|
20 | # something like this: |
---|
21 | # |
---|
22 | # env WX_CONFIG=/path/to/wx-config ./buildmacosx.sh |
---|
23 | # |
---|
24 | # If using a pre-installed wxWidgets, note that it must satisfy the |
---|
25 | # following requirements: |
---|
26 | # - It must be built with OpenGL support (--with-opengl). |
---|
27 | # - It must be the Carbon version. |
---|
28 | # - It probably should be a "Unicode" build (--enable-unicode). |
---|
29 | # |
---|
30 | |
---|
31 | set -e |
---|
32 | |
---|
33 | WXVERSION=2.8.11 |
---|
34 | |
---|
35 | if test "x$1" = "x--install-wx" ; then |
---|
36 | if test -x WXINSTALL/bin/wx-config ; then |
---|
37 | : |
---|
38 | else |
---|
39 | prefix=`pwd`/WXINSTALL |
---|
40 | test -f wxWidgets-$WXVERSION.tar.bz2 || \ |
---|
41 | curl -O ftp://ftp.wxwidgets.org/pub/$WXVERSION/wxWidgets-$WXVERSION.tar.bz2 |
---|
42 | test -d wxWidgets-$WXVERSION || tar jxvf wxWidgets-$WXVERSION.tar.bz2 |
---|
43 | test -d wxWidgets-$WXVERSION/build || mkdir wxWidgets-$WXVERSION/build |
---|
44 | cd wxWidgets-$WXVERSION/build |
---|
45 | ../configure --disable-shared --prefix="$prefix" --with-opengl --enable-unicode |
---|
46 | make -s |
---|
47 | make -s install |
---|
48 | cd ../.. |
---|
49 | fi |
---|
50 | WX_CONFIG=`pwd`/WXINSTALL/bin/wx-config |
---|
51 | fi |
---|
52 | |
---|
53 | test -n "$WX_CONFIG" || WX_CONFIG=`which wx-config` |
---|
54 | if test -z "$WX_CONFIG" ; then |
---|
55 | echo "WX_CONFIG not set and wx-config not on your PATH" |
---|
56 | exit 1 |
---|
57 | fi |
---|
58 | # Force static linking so the user doesn't need to install wxWidgets. |
---|
59 | WX_CONFIG=$WX_CONFIG' --static' |
---|
60 | rm -rf *.dmg Survex macosxtmp |
---|
61 | D=`pwd`/Survex |
---|
62 | T=`pwd`/macosxtmp |
---|
63 | ./configure --prefix="$D" --bindir="$D" --mandir="$T" WX_CONFIG="$WX_CONFIG" |
---|
64 | make |
---|
65 | make install |
---|
66 | #mv Survex/survex Survex/Survex |
---|
67 | |
---|
68 | # Construct the Aven application bundle. |
---|
69 | cp -r lib/Aven.app Survex |
---|
70 | cp -r $D/share/survex/* Survex/Aven.app/Contents/Resources/ |
---|
71 | mv Survex/aven Survex/Aven.app/Contents/MacOS/ |
---|
72 | rm -f Survex/share/survex/aven.txf |
---|
73 | rm -rf Survex/share/survex/icons |
---|
74 | |
---|
75 | size=`du -s Survex|sed 's/[^0-9].*//'` |
---|
76 | # Allow 1000 extra sectors for various overheads (500 wasn't enough). |
---|
77 | sectors=`expr 1000 + $size` |
---|
78 | # Partition needs to be at least 4M and sectors are 512 bytes. |
---|
79 | if test $sectors -lt 8192 ; then |
---|
80 | sectors=8192 |
---|
81 | fi |
---|
82 | echo "Creating new blank image survex-macosx.dmg of $sectors sectors" |
---|
83 | # This creates the diskimage file and initialises it as an HFS+ volume. |
---|
84 | hdiutil create -sectors $sectors survex-macosx -layout NONE -fs HFS+ -volname Survex |
---|
85 | |
---|
86 | echo "Presenting image to the filesystems for mounting." |
---|
87 | # This will mount the image onto the Desktop. |
---|
88 | # Get the name of the device we mounted it on... |
---|
89 | dev=`hdid survex-macosx.dmg|tail -1|sed 's!/dev/\([!-~]*\).*!\1!;'` |
---|
90 | echo "Mounted on device $dev, copying files into image." |
---|
91 | ditto -rsrcFork Survex /Volumes/Survex/Survex |
---|
92 | ditto lib/INSTALL.OSX /Volumes/Survex/INSTALL |
---|
93 | echo "Detaching image." |
---|
94 | hdiutil detach $dev |
---|
95 | |
---|
96 | version=`sed 's/.*AM_INIT_AUTOMAKE([^,]*, *\([0-9.]*\).*/\1/p;d' configure.in` |
---|
97 | file=survex-macosx-`echo $version`.dmg |
---|
98 | echo "Compressing image file survex-macosx.dmg to $file" |
---|
99 | # This needs MacOS X 10.1 or above for unpacking - change UDZO to UDCO to allow |
---|
100 | # the dmg to be unpacked on 10.0 as well: |
---|
101 | hdiutil convert survex-macosx.dmg -format UDZO -o "$file" |
---|
102 | rm survex-macosx.dmg |
---|
103 | |
---|
104 | echo "$file created successfully." |
---|