[1ecbe29] | 1 | #!/bin/sh |
---|
| 2 | # |
---|
[d9b7e9b] | 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 | # |
---|
[1ecbe29] | 6 | # Run from the unpacked survex-1.0.X directory like so: |
---|
| 7 | # |
---|
[f059ae5] | 8 | # ./buildmacosx.sh --install-wx |
---|
| 9 | # |
---|
[e53ec10] | 10 | # This will automatically download and temporarily install wxWidgets |
---|
[f059ae5] | 11 | # (this script is smart enough not to download or build it if it already |
---|
| 12 | # has). |
---|
| 13 | # |
---|
[e53ec10] | 14 | # If you already have wxWidgets installed permanently, use: |
---|
[f059ae5] | 15 | # |
---|
[1ecbe29] | 16 | # ./buildmacosx.sh |
---|
| 17 | # |
---|
[e53ec10] | 18 | # If wxWidgets is installed somewhere such that wx-config isn't on your |
---|
[1ecbe29] | 19 | # PATH you need to indicate where wx-config is by running this script |
---|
| 20 | # something like this: |
---|
| 21 | # |
---|
| 22 | # env WXCONFIG=/path/to/wx-config ./buildmacosx.sh |
---|
| 23 | |
---|
| 24 | set -e |
---|
[f059ae5] | 25 | |
---|
| 26 | if test "x$1" = "x--install-wx" ; then |
---|
| 27 | if test -x WXINSTALL/bin/wx-config ; then |
---|
| 28 | : |
---|
| 29 | else |
---|
[de10f8d] | 30 | prefix=`pwd`/WXINSTALL |
---|
[f059ae5] | 31 | test -f wxMac-2.4.2.tar.gz || \ |
---|
| 32 | wget ftp://biolpc22.york.ac.uk/pub/2.4.2/wxMac-2.4.2.tar.gz |
---|
| 33 | test -d wxMac-2.4.2 || tar zxvf wxMac-2.4.2.tar.gz |
---|
| 34 | test -d wxMac-2.4.2/build || mkdir wxMac-2.4.2/build |
---|
| 35 | cd wxMac-2.4.2/build |
---|
| 36 | ../configure --disable-shared --prefix="$prefix" |
---|
| 37 | make -s |
---|
| 38 | make -s install |
---|
| 39 | cd ../.. |
---|
| 40 | fi |
---|
[de10f8d] | 41 | WXCONFIG=`pwd`/WXINSTALL/bin/wx-config |
---|
[f059ae5] | 42 | fi |
---|
| 43 | |
---|
[1ecbe29] | 44 | test -n "$WXCONFIG" || WXCONFIG=`which wx-config` |
---|
| 45 | if test -z "$WXCONFIG" ; then |
---|
| 46 | echo "WXCONFIG not set and wx-config not on your PATH" |
---|
| 47 | exit 1 |
---|
| 48 | fi |
---|
[e53ec10] | 49 | # Force static linking so the user doesn't need to install wxWidgets. |
---|
[1ecbe29] | 50 | WXCONFIG=$WXCONFIG' --static' |
---|
| 51 | export WXCONFIG |
---|
[1955c1c] | 52 | rm -rf *.dmg Survex macosxtmp |
---|
[de10f8d] | 53 | D=`pwd`/Survex |
---|
| 54 | T=`pwd`/macosxtmp |
---|
[728d23e] | 55 | ./configure --prefix="$D" --bindir="$D" --mandir="$T" CFLAGS=-DMACOSX_BUNDLE |
---|
[1ecbe29] | 56 | make |
---|
| 57 | make install |
---|
| 58 | #mv Survex/survex Survex/Survex |
---|
| 59 | |
---|
| 60 | size=`du -s Survex|sed 's/[^0-9].*//'` |
---|
| 61 | # Allow 1000 extra sectors for various overheads (500 wasn't enough). |
---|
| 62 | sectors=`expr 1000 + $size` |
---|
| 63 | # Partition needs to be at least 4M and sectors are 512 bytes. |
---|
| 64 | if test $sectors -lt 8192 ; then |
---|
| 65 | sectors=8192 |
---|
| 66 | fi |
---|
| 67 | echo "Creating new blank image survex-macosx.dmg of $sectors sectors" |
---|
[728d23e] | 68 | # This creates the diskimage file and initialises it as an HFS+ volume. |
---|
[d9b7e9b] | 69 | hdiutil create -sectors $sectors survex-macosx -layout NONE -fs HFS+ -volname Survex |
---|
[1ecbe29] | 70 | |
---|
| 71 | echo "Present image to the filesystems for mounting." |
---|
| 72 | # This will mount the image onto the Desktop. |
---|
[d9b7e9b] | 73 | # Get the name of the device we mounted it on... |
---|
[1955c1c] | 74 | dev=`hdid survex-macosx.dmg|tail -1|sed 's!/dev/\([!-~]*\).*!\1!;'` |
---|
| 75 | echo "Mounted on device $dev, copying files into image." |
---|
[1ecbe29] | 76 | ditto -rsrcFork Survex /Volumes/Survex/Survex |
---|
| 77 | ditto lib/INSTALL.OSX /Volumes/Survex/INSTALL |
---|
[1955c1c] | 78 | echo "Detaching image." |
---|
[d9b7e9b] | 79 | hdiutil detach $dev |
---|
[1ecbe29] | 80 | |
---|
[de10f8d] | 81 | version=`sed 's/.*AM_INIT_AUTOMAKE([^,]*, *\([0-9.]*\).*/\1/p;d' configure.in` |
---|
| 82 | file=survex-macosx-`echo $version`.dmg |
---|
[1ecbe29] | 83 | echo "Compressing image file survex-macosx.dmg to $file" |
---|
[d9b7e9b] | 84 | # This needs MacOS X 10.1 or above for unpacking - change UDZO to UDCO to allow |
---|
| 85 | # the dmg to be unpacked on 10.0 as well: |
---|
| 86 | hdiutil convert survex-macosx.dmg -format UDZO -o "$file" |
---|
| 87 | rm survex-macosx.dmg |
---|
[1ecbe29] | 88 | |
---|
| 89 | echo "$file created successfully." |
---|