source: git/buildmacosx.sh @ 90a2e0f

RELEASE/1.2debug-cidebug-ci-sanitisersstereowalls-data
Last change on this file since 90a2e0f was 90a2e0f, checked in by Olly Betts <olly@…>, 13 years ago

buildmacosx.sh: Fix URL for downloading wxWidgets tarball.

git-svn-id: file:///home/survex-svn/survex/trunk@3614 4b37db11-9a0c-4f06-9ece-9ab7cdaee568

  • Property mode set to 100755
File size: 4.7 KB
Line 
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# Run from the unpacked survex-1.1.X directory like so:
9#
10#   ./buildmacosx.sh
11#
12# This will automatically download and temporarily install wxWidgets
13# (this script is smart enough not to download or build it if it already
14# has).
15#
16# If you already have wxWidgets installed permanently, use:
17#
18#   ./buildmacosx.sh --no-install-wx
19#
20# If wxWidgets is installed somewhere such that wx-config isn't on your
21# PATH you need to indicate where wx-config is by running this script
22# something like this:
23#
24#   env WX_CONFIG=/path/to/wx-config ./buildmacosx.sh
25#
26# (If you set WX_CONFIG, there's no need to pass --no-install-wx).
27#
28# If using a pre-installed wxWidgets, note that it must satisfy the
29# following requirements:
30#   - It must be built with OpenGL support (--with-opengl).
31#   - It must be the Carbon version.
32#   - It probably should be a "Unicode" build (--enable-unicode).
33
34set -e
35
36WXVERSION=2.8.11
37
38# To build for older machines with a ppc CPU, you want -arch ppc instead in
39# arch_flags (might also work as well with some OS X versions).
40arch_flags='-arch i386 -arch x86_64'
41if [ -z "${WX_CONFIG+set}" ] && [ "x$1" != "x--no-install-wx" ] ; then
42  if test -x WXINSTALL/bin/wx-config ; then
43    :
44  else
45    prefix=`pwd`/WXINSTALL
46    wxtarball=wxWidgets-$WXVERSION.tar.bz2
47    test -f "$wxtarball" || \
48      curl -O "ftp://ftp.wxwidgets.org/pub/$WXVERSION/$wxtarball"
49    echo "+++ Extracting $wxtarball"
50    test -d "wxWidgets-$WXVERSION" || tar jxf "$wxtarball"
51    test -d "wxWidgets-$WXVERSION/build" || "mkdir wxWidgets-$WXVERSION/build"
52    cd "wxWidgets-$WXVERSION/build"
53    ../configure --disable-shared --prefix="$prefix" --with-opengl --enable-unicode CC="gcc $arch_flags" CXX="g++ $arch_flags"
54    make -s
55    make -s install
56    cd ../..
57  fi
58  WX_CONFIG=`pwd`/WXINSTALL/bin/wx-config
59fi
60
61test -n "$WX_CONFIG" || WX_CONFIG=`which wx-config`
62if test -z "$WX_CONFIG" ; then
63  echo "WX_CONFIG not set and wx-config not on your PATH"
64  exit 1
65fi
66# Force static linking so the user doesn't need to install wxWidgets.
67WX_CONFIG=$WX_CONFIG' --static'
68rm -rf *.dmg Survex macosxtmp
69D=`pwd`/Survex
70T=`pwd`/macosxtmp
71./configure --prefix="$D" --bindir="$D" --mandir="$T" WX_CONFIG="$WX_CONFIG" CC="gcc $arch_flags" CXX="g++ $arch_flags"
72make
73make install
74#mv Survex/survex Survex/Survex
75
76# Construct the Aven application bundle.
77mkdir Survex/Aven.app
78mkdir Survex/Aven.app/Contents
79mkdir Survex/Aven.app/Contents/MacOS
80mkdir Survex/Aven.app/Contents/Resources
81cp lib/Info.plist Survex/Aven.app/Contents
82printf APPLAVEN > Survex/Aven.app/Contents/PkgInfo
83cp -r "$D"/share/survex/* Survex/Aven.app/Contents/Resources/
84# FIXME: Generate Survex/Aven.app/Resources/Aven.icns
85mv Survex/aven Survex/Aven.app/Contents/MacOS/
86rm -f Survex/share/survex/aven.txf
87rm -rf Survex/share/survex/icons
88
89size=`du -s Survex|sed 's/[^0-9].*//'`
90# Allow 1000 extra sectors for various overheads (500 wasn't enough).
91sectors=`expr 1000 + "$size"`
92# Partition needs to be at least 4M and sectors are 512 bytes.
93if test "$sectors" -lt 8192 ; then
94  sectors=8192
95fi
96echo "Creating new blank image survex-macosx.dmg of $sectors sectors"
97# This creates the diskimage file and initialises it as an HFS+ volume.
98hdiutil create -sectors "$sectors" survex-macosx -layout NONE -fs HFS+ -volname Survex
99
100echo "Presenting image to the filesystems for mounting."
101# This will mount the image onto the Desktop.
102# Get the name of the device it is mounted on and the mount point.
103
104# man hdiutil says:
105# "The output of [hdiutil] attach has been stable since OS X 10.0 (though it
106# was called hdid(8) then) and is intended to be program-readable.  It consists
107# of the /dev node, a tab, a content hint (if applicable), another tab, and a
108# mount point (if any filesystems were mounted)."
109hdid_output=`hdid survex-macosx.dmg|tail -1`
110echo "Last line of hdid output was: $hdid_output"
111dev=`echo "$hdid_output"|sed 's!/dev/\([^       ]*\).*!\1!'`
112mount_point=`echo "$hdid_output"|sed 's!.*      !!'`
113
114echo "Device $dev mounted on $mount_point, copying files into image."
115ditto -rsrcFork Survex "$mount_point/Survex"
116ditto lib/INSTALL.OSX "$mount_point/INSTALL"
117
118echo "Detaching image."
119hdiutil detach "$dev"
120
121version=`sed 's/.*AM_INIT_AUTOMAKE([^,]*, *\([0-9.]*\).*/\1/p;d' configure.in`
122file=survex-macosx-$version.dmg
123echo "Compressing image file survex-macosx.dmg to $file"
124# This needs MacOS X 10.1 or above for unpacking - change UDZO to UDCO to allow
125# the dmg to be unpacked on 10.0 as well:
126hdiutil convert survex-macosx.dmg -format UDZO -o "$file"
127rm survex-macosx.dmg
128
129echo "$file created successfully."
Note: See TracBrowser for help on using the repository browser.