[6df03c1] | 1 | #!/bin/sh |
---|
| 2 | # |
---|
[0580c6a] | 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 | # |
---|
[b72f4b5] | 6 | # Run from the unpacked survex-1.1.X directory like so: |
---|
[6df03c1] | 7 | # |
---|
[0580c6a] | 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 | # |
---|
[6df03c1] | 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 |
---|
[b72f4b5] | 23 | # |
---|
| 24 | # If using a pre-installed wxWindows, 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 must be a "non-unicode" build. |
---|
| 29 | # |
---|
[6df03c1] | 30 | |
---|
| 31 | set -e |
---|
[0580c6a] | 32 | |
---|
[b72f4b5] | 33 | WXVERSION=2.7.0-1 |
---|
| 34 | |
---|
[0580c6a] | 35 | if test "x$1" = "x--install-wx" ; then |
---|
| 36 | if test -x WXINSTALL/bin/wx-config ; then |
---|
| 37 | : |
---|
| 38 | else |
---|
[deb58b87] | 39 | prefix=`pwd`/WXINSTALL |
---|
[b72f4b5] | 40 | test -f wxWidgets-$WXVERSION.tar.bz2 || \ |
---|
[deb58b87] | 41 | curl -O ftp://ftp.wxwidgets.org/pub/$WXVERSION/wxWidgets-$WXVERSION.tar.bz2 |
---|
[b72f4b5] | 42 | test -d wxWidgets-$WXVERSION || tar jxvf wxWidgets-$WXVERSION.tar.bz2 |
---|
| 43 | test -d wxWidgets-$WXVERSION/build || mkdir wxWidgets-$WXVERSION/build |
---|
| 44 | # wx's Carbon glcanvas is unsatisfactory, so for now we use our own. |
---|
| 45 | cp src/carbon-glcanvas.cpp wxWidgets-$WXVERSION/src/mac/carbon/ |
---|
| 46 | cd wxWidgets-$WXVERSION/build |
---|
| 47 | ../configure --disable-shared --prefix="$prefix" --with-opengl |
---|
[0580c6a] | 48 | make -s |
---|
| 49 | make -s install |
---|
| 50 | cd ../.. |
---|
| 51 | fi |
---|
[deb58b87] | 52 | WXCONFIG=`pwd`/WXINSTALL/bin/wx-config |
---|
[0580c6a] | 53 | fi |
---|
| 54 | |
---|
[6df03c1] | 55 | test -n "$WXCONFIG" || WXCONFIG=`which wx-config` |
---|
| 56 | if test -z "$WXCONFIG" ; then |
---|
| 57 | echo "WXCONFIG not set and wx-config not on your PATH" |
---|
| 58 | exit 1 |
---|
| 59 | fi |
---|
| 60 | # Force static linking so the user doesn't need to install wxWindows. |
---|
| 61 | WXCONFIG=$WXCONFIG' --static' |
---|
| 62 | export WXCONFIG |
---|
[0580c6a] | 63 | rm -rf *.dmg Survex macosxtmp |
---|
[deb58b87] | 64 | D=`pwd`/Survex |
---|
| 65 | T=`pwd`/macosxtmp |
---|
[b72f4b5] | 66 | ./configure --prefix="$D" --bindir="$D" --mandir="$T" |
---|
[6df03c1] | 67 | make |
---|
| 68 | make install |
---|
| 69 | #mv Survex/survex Survex/Survex |
---|
| 70 | |
---|
[b72f4b5] | 71 | # Construct the Aven application bundle. |
---|
| 72 | cp -r lib/Aven.app Survex |
---|
| 73 | cp -r $D/share/survex/* Survex/Aven.app/Contents/Resources/ |
---|
| 74 | mv Survex/aven Survex/Aven.app/Contents/MacOS/ |
---|
| 75 | rm -f Survex/share/survex/aven.txf |
---|
| 76 | rm -rf Survex/share/survex/icons |
---|
| 77 | |
---|
[6df03c1] | 78 | size=`du -s Survex|sed 's/[^0-9].*//'` |
---|
| 79 | # Allow 1000 extra sectors for various overheads (500 wasn't enough). |
---|
| 80 | sectors=`expr 1000 + $size` |
---|
| 81 | # Partition needs to be at least 4M and sectors are 512 bytes. |
---|
| 82 | if test $sectors -lt 8192 ; then |
---|
| 83 | sectors=8192 |
---|
| 84 | fi |
---|
| 85 | echo "Creating new blank image survex-macosx.dmg of $sectors sectors" |
---|
[0580c6a] | 86 | # This creates the diskimage file and initialises it as an HFS+ volume. |
---|
| 87 | hdiutil create -sectors $sectors survex-macosx -layout NONE -fs HFS+ -volname Survex |
---|
[6df03c1] | 88 | |
---|
[b72f4b5] | 89 | echo "Presenting image to the filesystems for mounting." |
---|
[6df03c1] | 90 | # This will mount the image onto the Desktop. |
---|
[0580c6a] | 91 | # Get the name of the device we mounted it on... |
---|
| 92 | dev=`hdid survex-macosx.dmg|tail -1|sed 's!/dev/\([!-~]*\).*!\1!;'` |
---|
| 93 | echo "Mounted on device $dev, copying files into image." |
---|
[6df03c1] | 94 | ditto -rsrcFork Survex /Volumes/Survex/Survex |
---|
| 95 | ditto lib/INSTALL.OSX /Volumes/Survex/INSTALL |
---|
[0580c6a] | 96 | echo "Detaching image." |
---|
| 97 | hdiutil detach $dev |
---|
[6df03c1] | 98 | |
---|
[deb58b87] | 99 | version=`sed 's/.*AM_INIT_AUTOMAKE([^,]*, *\([0-9.]*\).*/\1/p;d' configure.in` |
---|
| 100 | file=survex-macosx-`echo $version`.dmg |
---|
[6df03c1] | 101 | echo "Compressing image file survex-macosx.dmg to $file" |
---|
[0580c6a] | 102 | # This needs MacOS X 10.1 or above for unpacking - change UDZO to UDCO to allow |
---|
| 103 | # the dmg to be unpacked on 10.0 as well: |
---|
| 104 | hdiutil convert survex-macosx.dmg -format UDZO -o "$file" |
---|
| 105 | rm survex-macosx.dmg |
---|
[6df03c1] | 106 | |
---|
| 107 | echo "$file created successfully." |
---|