source: git/buildmacosx.sh @ cc83ec9

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

buildmacosx.sh: Add comment noting that Xcode is probably required.
Since wxWidgets only supports building for a single arch at a time,
build for i386 by default, which should also work on x86_64. Pass
CPP=cpp to wxWidgets configure (not certain if this is actually
needed, or was something tried on the way to discovering that only
one -arch option can be passed).

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

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