| 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.0.X directory like so: |
|---|
| 7 | # |
|---|
| 8 | # ./buildmacosx.sh --install-wx |
|---|
| 9 | # |
|---|
| 10 | # This will automatically download and temporarily install wxWindows |
|---|
| 11 | # (this script is smart enough not to download or build it if it already |
|---|
| 12 | # has). |
|---|
| 13 | # |
|---|
| 14 | # If you already have wxWindows installed permanently, use: |
|---|
| 15 | # |
|---|
| 16 | # ./buildmacosx.sh |
|---|
| 17 | # |
|---|
| 18 | # If wxWindows 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 WXCONFIG=/path/to/wx-config ./buildmacosx.sh |
|---|
| 23 | |
|---|
| 24 | set -e |
|---|
| 25 | |
|---|
| 26 | if test "x$1" = "x--install-wx" ; then |
|---|
| 27 | if test -x WXINSTALL/bin/wx-config ; then |
|---|
| 28 | : |
|---|
| 29 | else |
|---|
| 30 | prefix="`pwd`"/WXINSTALL |
|---|
| 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 |
|---|
| 41 | WXCONFIG="`pwd`"/WXINSTALL/bin/wx-config |
|---|
| 42 | fi |
|---|
| 43 | |
|---|
| 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 |
|---|
| 49 | # Force static linking so the user doesn't need to install wxWindows. |
|---|
| 50 | WXCONFIG=$WXCONFIG' --static' |
|---|
| 51 | export WXCONFIG |
|---|
| 52 | rm -rf *.dmg Survex macosxtmp |
|---|
| 53 | D="`pwd`/Survex" |
|---|
| 54 | T="`pwd`/macosxtmp" |
|---|
| 55 | ./configure --prefix="$D" --bindir="$D" --mandir="$T" CFLAGS=-DMACOSX_BUNDLE |
|---|
| 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" |
|---|
| 68 | # This creates the diskimage file and initialises it as an HFS+ volume. |
|---|
| 69 | hdiutil create -sectors $sectors survex-macosx -layout NONE -fs HFS+ -volname Survex |
|---|
| 70 | |
|---|
| 71 | echo "Present image to the filesystems for mounting." |
|---|
| 72 | # This will mount the image onto the Desktop. |
|---|
| 73 | # Get the name of the device we mounted it on... |
|---|
| 74 | dev=`hdid survex-macosx.dmg|tail -1|sed 's!/dev/\([!-~]*\).*!\1!;'` |
|---|
| 75 | echo "Mounted on device $dev, copying files into image." |
|---|
| 76 | ditto -rsrcFork Survex /Volumes/Survex/Survex |
|---|
| 77 | ditto lib/INSTALL.OSX /Volumes/Survex/INSTALL |
|---|
| 78 | echo "Detaching image." |
|---|
| 79 | hdiutil detach $dev |
|---|
| 80 | |
|---|
| 81 | version="`sed 's/.*AM_INIT_AUTOMAKE([^,]*, *\([0-9.]*\).*/\1/p;d' configure.in`" |
|---|
| 82 | file="survex-macosx-`echo $version`.dmg" |
|---|
| 83 | echo "Compressing image file survex-macosx.dmg to $file" |
|---|
| 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 |
|---|
| 88 | |
|---|
| 89 | echo "$file created successfully." |
|---|