source: git/buildmacosx.sh @ ce9cd1c1

RELEASE/1.2debug-cidebug-ci-sanitisersfaster-cavernloglog-selectstereowalls-datawalls-data-hanging-as-warning
Last change on this file since ce9cd1c1 was 95f0fb2, checked in by Olly Betts <olly@…>, 10 years ago

buildmacosx.sh: Default to building for x86_64, since modern Macs are
all 64 bit.

  • Property mode set to 100755
File size: 5.5 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) at least 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.2.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#   - If you build with wx < 3, it probably should be a "Unicode" build
35#     (--enable-unicode); wx >= 3 dropped support for non-Unicode builds.
36
37set -e
38
39WXVERSION=3.0.2
40WX_SHA256=346879dc554f3ab8d6da2704f651ecb504a22e9d31c17ef5449b129ed711585d
41
42# Sadly, you can only specify one arch via -arch at a time (a restriction of
43# the wxWidgets build system).
44#
45# Using -arch x86_64 produces a build which will only work on 64-bit Intel
46# Macs, but that's probably all machines modern enough to worry about.
47# If you want a build which also works on 32 bit Intel Macs, then use
48# arch_flags='-arch i386' instead.
49#
50# To build for much older machines with a ppc CPU, you want arch_flags='-arch
51# ppc' instead.
52arch_flags='-arch x86_64'
53if [ -z "${WX_CONFIG+set}" ] && [ "x$1" != "x--no-install-wx" ] ; then
54  if test -x WXINSTALL/bin/wx-config ; then
55    :
56  else
57    prefix=`pwd`/WXINSTALL
58    wxtarball=wxWidgets-$WXVERSION.tar.bz2
59    test -f "$wxtarball" || \
60      curl -O "http://ftp.wxwidgets.org/pub/$WXVERSION/$wxtarball"
61    if echo "$WX_SHA256  $wxtarball" | shasum -a256 -c ; then
62      : # OK
63    else
64      echo "Checksum of downloaded file '$wxtarball' is incorrect, aborting."
65      exit 1
66    fi
67    echo "+++ Extracting $wxtarball"
68    test -d "wxWidgets-$WXVERSION" || tar jxf "$wxtarball"
69    test -d "wxWidgets-$WXVERSION/build" || "mkdir wxWidgets-$WXVERSION/build"
70    cd "wxWidgets-$WXVERSION/build"
71    ../configure --disable-shared --prefix="$prefix" --with-opengl --enable-unicode CC="gcc $arch_flags" CXX="g++ $arch_flags"
72    make -s
73    make -s install
74    cd ../..
75  fi
76  WX_CONFIG=`pwd`/WXINSTALL/bin/wx-config
77fi
78
79test -n "$WX_CONFIG" || WX_CONFIG=`which wx-config`
80if test -z "$WX_CONFIG" ; then
81  echo "WX_CONFIG not set and wx-config not on your PATH"
82  exit 1
83fi
84# Force static linking so the user doesn't need to install wxWidgets.
85WX_CONFIG=$WX_CONFIG' --static'
86rm -rf *.dmg Survex macosxtmp
87D=`pwd`/Survex
88T=`pwd`/macosxtmp
89./configure --prefix="$D" --bindir="$D" --mandir="$T" WX_CONFIG="$WX_CONFIG" CC="gcc $arch_flags" CXX="g++ $arch_flags"
90make
91make install
92#mv Survex/survex Survex/Survex
93
94# Construct the Aven application bundle.
95mkdir Survex/Aven.app
96mkdir Survex/Aven.app/Contents
97mkdir Survex/Aven.app/Contents/MacOS
98mkdir Survex/Aven.app/Contents/Resources
99cp lib/Info.plist Survex/Aven.app/Contents
100printf APPLAVEN > Survex/Aven.app/Contents/PkgInfo
101cp -r "$D"/share/survex/* Survex/Aven.app/Contents/Resources/
102# FIXME: Generate Survex/Aven.app/Resources/Aven.icns
103mv Survex/aven Survex/Aven.app/Contents/MacOS/
104ln Survex/cavern Survex/Aven.app/Contents/MacOS/
105rm -f Survex/share/survex/unifont.pixelfont
106rm -rf Survex/share/survex/icons
107
108size=`du -s Survex|sed 's/[^0-9].*//'`
109# Allow 1000 extra sectors for various overheads (500 wasn't enough).
110sectors=`expr 1000 + "$size"`
111# Partition needs to be at least 4M and sectors are 512 bytes.
112if test "$sectors" -lt 8192 ; then
113  sectors=8192
114fi
115echo "Creating new blank image survex-macosx.dmg of $sectors sectors"
116# This creates the diskimage file and initialises it as an HFS+ volume.
117hdiutil create -sectors "$sectors" survex-macosx -layout NONE -fs HFS+ -volname Survex
118
119echo "Presenting image to the filesystems for mounting."
120# This will mount the image onto the Desktop.
121# Get the name of the device it is mounted on and the mount point.
122
123# man hdiutil says:
124# "The output of [hdiutil] attach has been stable since OS X 10.0 (though it
125# was called hdid(8) then) and is intended to be program-readable.  It consists
126# of the /dev node, a tab, a content hint (if applicable), another tab, and a
127# mount point (if any filesystems were mounted)."
128#
129# In reality, it seems there are also some spaces before each tab character.
130hdid_output=`hdid survex-macosx.dmg|tail -1`
131echo "Last line of hdid output was: $hdid_output"
132dev=`echo "$hdid_output"|sed 's!/dev/\([^        ]*\).*!\1!'`
133mount_point=`echo "$hdid_output"|sed 's!.*[      ]!!'`
134
135echo "Device $dev mounted on $mount_point, copying files into image."
136ditto -rsrcFork Survex "$mount_point/Survex"
137ditto lib/INSTALL.OSX "$mount_point/INSTALL"
138
139echo "Detaching image."
140hdiutil detach "$dev"
141
142version=`sed 's/^VERSION *= *//p;d' Makefile`
143file=survex-macosx-$version.dmg
144echo "Compressing image file survex-macosx.dmg to $file"
145# This needs MacOS X 10.1 or above for unpacking - change UDZO to UDCO to allow
146# the dmg to be unpacked on 10.0 as well:
147hdiutil convert survex-macosx.dmg -format UDZO -o "$file"
148rm survex-macosx.dmg
149
150echo "$file created successfully."
Note: See TracBrowser for help on using the repository browser.