source: git/buildmacosx.sh @ 1f7f037

RELEASE/1.2debug-cidebug-ci-sanitiserswalls-data
Last change on this file since 1f7f037 was e840570, checked in by Olly Betts <olly@…>, 5 years ago

Drop support for wxWidgets < 3.0

3.0.0 was released over 5 years ago and should be easily available
everywhere by now.

I'm no longer easily able to test with wxWidgets 2.8, and this allows
a significant amount of cruft to be removed.

  • Property mode set to 100755
File size: 10.2 KB
Line 
1#!/bin/sh
2#
3# You'll need some development tools which aren't installed by default.  To
4# get these you can install Xcode (which is a free download from Apple):
5#
6#   https://developer.apple.com/xcode/downloads/
7#
8# To build, open a terminal (Terminal.app in the "Utils" folder in
9# "Applications") and unpack the downloaded survex source code. E.g. for
10# 1.2.17:
11#
12#   tar xf survex-1.2.17.tar.gz
13#
14# Then change directory into the unpacked sources:
15#
16#   cd survex-1.2.17
17#
18# And then run this script:
19#
20#   ./buildmacosx.sh
21#
22# This will automatically download and temporarily install wxWidgets,
23# PROJ.4 and FFmpeg in subdirectories of the source tree (this script is smart
24# enough not to re-download or re-build these if it already has).
25#
26# If you already have wxWidgets, PROJ.4 and/or FFmpeg installed permanently,
27# you can disable these by passing one or more extra options - e.g. to build
28# none of them, use:
29#
30#   ./buildmacosx.sh --no-install-wx --no-install-proj --no-install-ffmpeg
31#
32# If wxWidgets is installed somewhere such that wx-config isn't on your
33# PATH you need to indicate where wx-config is by running this script
34# something like this:
35#
36#   env WX_CONFIG=/path/to/wx-config ./buildmacosx.sh
37#
38# (If you set WX_CONFIG, there's no need to pass --no-install-wx).
39#
40# If using a pre-installed wxWidgets, note that it must satisfy the
41# following requirements:
42#
43#   - It must be built with OpenGL support (--with-opengl).
44#   - It must be wxWidgets >= 3.0
45#
46# This script builds diskimages which are known to work at least as far back
47# as OS X 10.6.8.  A build of wxWidgets 3.0.2 with the options we pass will
48# default to assuming at least OS X 10.5, but we've not heard from anyone
49# trying with such an old version.
50#
51# Mac OS X support "fat" binaries which contain code for more than one
52# processor, but the wxWidgets build system doesn't seem to allow creating
53# these, so we have to choose what processor family to build for.  By default
54# we build for the architecture of the version of OS X the build machine is
55# running, which on a modern Mac will be x86_64, producing a build which will
56# only work on 64-bit Intel Macs (but that's probably all machines modern
57# enough to worry about).
58#
59# You can specify an arch explicitly on the command-line, e.g. to force a
60# build for 64-bit Intel Macs:
61#
62#   ./buildmacosx.sh x86_64
63#
64# Or if you want a build which also works on older 32 bit Intel Macs, then run
65# this script passing i386 on the command line, like so (assuming your compiler
66# supports this):
67#
68#   ./buildmacosx.sh i386
69#
70# Or to build for much older machines with a Power PC processor, use (again
71# assuming your compiler supports this):
72#
73#   ./buildmacosx.sh ppc
74
75set -e
76
77install_wx=yes
78install_proj=yes
79install_ffmpeg=yes
80while [ "$#" != 0 ] ; do
81  case $1 in
82    --no-install-wx)
83      install_wx=no
84      shift
85      ;;
86    --no-install-proj)
87      install_proj=no
88      shift
89      ;;
90    --no-install-ffmpeg)
91      install_ffmpeg=no
92      shift
93      ;;
94    --help|-h)
95      echo "Usage: $0 [--no-install-wx] [--no-install-proj] [--no-install-ffmpeg] [ppc|i386|x86_86]"
96      exit 0
97      ;;
98    -*)
99      echo "Unknown option - try --help" >&2
100      exit 1
101      ;;
102    *)
103      break
104      ;;
105  esac
106done
107
108arch=$1
109if [ -z "$arch" ] ; then
110  arch=`uname -m`
111fi
112arch_flags="-arch $arch"
113
114# UDBZ means the resultant disk image will only open on OS X 10.4 or above.
115# UDZO works on 10.1 and later, but is larger,  UDCO works on 10.0 as well,
116# but is larger still.
117dmg_format=UDBZ
118
119WX_VERSION=3.0.4
120WX_SHA256=96157f988d261b7368e5340afa1a0cad943768f35929c22841f62c25b17bf7f0
121
122PROJ_VERSION=4.9.3
123PROJ_SHA256=6984542fea333488de5c82eea58d699e4aff4b359200a9971537cd7e047185f7
124
125FFMPEG_VERSION=3.1.3
126FFMPEG_SHA256=f8575c071e2a64437aeb70c8c030b385cddbe0b5cde20c9b18a6def840128822
127
128if [ -z "${WX_CONFIG+set}" ] && [ "$install_wx" != no ] ; then
129  if test -x WXINSTALL/bin/wx-config ; then
130    :
131  else
132    prefix=`pwd`/WXINSTALL
133    wxtarball=wxWidgets-$WX_VERSION.tar.bz2
134    test -f "$wxtarball" || \
135      curl -L -O "https://github.com/wxWidgets/wxWidgets/releases/download/v$WX_VERSION/$wxtarball"
136    if echo "$WX_SHA256  $wxtarball" | shasum -a256 -c ; then
137      : # OK
138    else
139      echo "Checksum of downloaded file '$wxtarball' is incorrect, aborting."
140      exit 1
141    fi
142    echo "+++ Extracting $wxtarball"
143    test -d "wxWidgets-$WX_VERSION" || tar xf "$wxtarball"
144    test -d "wxWidgets-$WX_VERSION/BUILD" || mkdir "wxWidgets-$WX_VERSION/BUILD"
145    cd "wxWidgets-$WX_VERSION/BUILD"
146    # Compilation of wx 3.0.2 fails on OS X 10.10.1 with webview enabled.
147    # A build with liblzma enabled doesn't work on OS X 10.6.8.
148    ../configure --disable-shared --prefix="$prefix" \
149        --with-opengl --enable-display \
150        --disable-webview --without-liblzma \
151        CC="gcc $arch_flags" CXX="g++ $arch_flags"
152    make -s
153    make -s install
154    cd ../..
155  fi
156  WX_CONFIG=`pwd`/WXINSTALL/bin/wx-config
157fi
158
159[ -n "${WX_CONFIG}" ] || WX_CONFIG=`which wx-config 2>/dev/null`
160if [ -z "${WX_CONFIG}" ] ; then
161  echo "wx-config not found in PATH."
162  echo
163  echo "If wxWidgets is installed, you can specify its location by setting environment variable WX_CONFIG:"
164  echo
165  echo "WX_CONFIG=/opt/bin/wx-config sh ./buildmacosx.sh"
166  exit 1
167fi
168CC=`$WX_CONFIG --cc`
169CXX=`$WX_CONFIG --cxx`
170
171if [ "$install_proj" != no ] ; then
172  if test -f PROJINSTALL/include/proj_api.h ; then
173    :
174  else
175    prefix=`pwd`/PROJINSTALL
176    projtarball=proj-$PROJ_VERSION.tar.gz
177    test -f "$projtarball" || \
178      curl -O "http://download.osgeo.org/proj/$projtarball"
179    if echo "$PROJ_SHA256  $projtarball" | shasum -a256 -c ; then
180      : # OK
181    else
182      echo "Checksum of downloaded file '$projtarball' is incorrect, aborting."
183      exit 1
184    fi
185    echo "+++ Extracting $projtarball"
186    test -d "proj-$PROJ_VERSION" || tar xf "$projtarball"
187    test -d "proj-$PROJ_VERSION/BUILD" || mkdir "proj-$PROJ_VERSION/BUILD"
188    cd "proj-$PROJ_VERSION/BUILD"
189    ../configure --disable-shared --prefix="$prefix" CC="$CC" CXX="$CXX"
190    make -s
191    make -s install
192    cd ../..
193  fi
194fi
195
196if [ "$install_ffmpeg" != no ] ; then
197  if test -f FFMPEGINSTALL/include/libavcodec/avcodec.h ; then
198    :
199  else
200    prefix=`pwd`/FFMPEGINSTALL
201    ffmpegtarball=ffmpeg-$FFMPEG_VERSION.tar.xz
202    test -f "$ffmpegtarball" || \
203      curl -O "https://ffmpeg.org/releases/$ffmpegtarball"
204    if echo "$FFMPEG_SHA256  $ffmpegtarball" | shasum -a256 -c ; then
205      : # OK
206    else
207      echo "Checksum of downloaded file '$ffmpegtarball' is incorrect, aborting."
208      exit 1
209    fi
210    echo "+++ Extracting $ffmpegtarball"
211    test -d "ffmpeg-$FFMPEG_VERSION" || tar xf "$ffmpegtarball"
212    test -d "ffmpeg-$FFMPEG_VERSION/BUILD" || mkdir "ffmpeg-$FFMPEG_VERSION/BUILD"
213    cd "ffmpeg-$FFMPEG_VERSION/BUILD"
214    FFMPEG_CONFIGURE_OPTS='--disable-shared --disable-programs --disable-network --disable-bsfs --disable-protocols --disable-devices'
215    # We don't need to decode video, but disabling these causes a link failure
216    # when linking aven:
217    # --disable-decoders --disable-demuxers
218    if ! nasm -hf|grep -q macho64 ; then
219      # nasm needs to support macho64, at least for x86_64 builds.
220      FFMPEG_CONFIGURE_OPTS="$FFMPEG_CONFIGURE_OPTS --disable-yasm"
221    fi
222    ../configure --prefix="$prefix" --cc="$CC" $FFMPEG_CONFIGURE_OPTS
223    make -s
224    make -s install
225    cd ../..
226  fi
227fi
228
229test -n "$WX_CONFIG" || WX_CONFIG=`which wx-config`
230if test -z "$WX_CONFIG" ; then
231  echo "WX_CONFIG not set and wx-config not on your PATH"
232  exit 1
233fi
234# Force static linking so the user doesn't need to install wxWidgets.
235WX_CONFIG=$WX_CONFIG' --static'
236rm -rf *.dmg Survex macosxtmp
237C=`pwd`
238D=$C/Survex
239T=$C/macosxtmp
240PKG_CONFIG_PATH=$C/PROJINSTALL/lib/pkgconfig:$C/FFMPEGINSTALL/lib/pkgconfig
241export PKG_CONFIG_PATH
242./configure --prefix="$D" --bindir="$D" --mandir="$T" \
243    WX_CONFIG="$WX_CONFIG" CC="$CC" CXX="$CXX"
244make
245make install
246#mv Survex/survex Survex/Survex
247
248# Construct the Aven application bundle.
249make create-aven-app APP_PATH=Survex/Aven.app
250mv Survex/share/doc/survex Survex/Docs
251rmdir Survex/share/doc
252mv Survex/share/survex/images Survex/Aven.app/Contents/Resources/
253mv Survex/share/survex/unifont.pixelfont Survex/Aven.app/Contents/Resources/
254ln Survex/share/survex/*.msg Survex/Aven.app/Contents/Resources/
255mv Survex/aven Survex/Aven.app/Contents/MacOS/
256ln Survex/cavern Survex/extend Survex/Aven.app/Contents/MacOS/
257rm -rf Survex/share/applications Survex/share/icons Survex/share/mime-info
258mkdir Survex/share/survex/proj
259cp -p PROJINSTALL/share/proj/epsg PROJINSTALL/share/proj/esri Survex/share/survex/proj
260mkdir Survex/Aven.app/Contents/Resources/proj
261ln Survex/share/survex/proj/* Survex/Aven.app/Contents/Resources/proj
262
263size=`du -s Survex|sed 's/[^0-9].*//'`
264# Allow 1500 extra sectors for various overheads (1000 wasn't enough).
265sectors=`expr 1500 + "$size"`
266# Partition needs to be at least 4M and sectors are 512 bytes.
267if test "$sectors" -lt 8192 ; then
268  sectors=8192
269fi
270echo "Creating new blank image survex-macosx.dmg of $sectors sectors"
271# This creates the diskimage file and initialises it as an HFS+ volume.
272hdiutil create -sectors "$sectors" survex-macosx -layout NONE -fs HFS+ -volname Survex
273
274echo "Presenting image to the filesystems for mounting."
275# This will mount the image onto the Desktop.
276# Get the name of the device it is mounted on and the mount point.
277
278# man hdiutil says:
279# "The output of [hdiutil] attach has been stable since OS X 10.0 (though it
280# was called hdid(8) then) and is intended to be program-readable.  It consists
281# of the /dev node, a tab, a content hint (if applicable), another tab, and a
282# mount point (if any filesystems were mounted)."
283#
284# In reality, it seems there are also some spaces before each tab character.
285hdid_output=`hdid survex-macosx.dmg|tail -1`
286echo "Last line of hdid output was: $hdid_output"
287dev=`echo "$hdid_output"|sed 's!/dev/\([^        ]*\).*!\1!'`
288mount_point=`echo "$hdid_output"|sed 's!.*      !!'`
289
290echo "Device $dev mounted on $mount_point, copying files into image."
291ditto -rsrcFork Survex "$mount_point/Survex"
292ditto lib/INSTALL.OSX "$mount_point/INSTALL"
293
294echo "Detaching image."
295hdiutil detach "$dev"
296
297version=`sed 's/^VERSION *= *//p;d' Makefile`
298file=survex-macosx-$version.dmg
299echo "Compressing image file survex-macosx.dmg to $file"
300hdiutil convert survex-macosx.dmg -format "$dmg_format" -o "$file"
301rm survex-macosx.dmg
302
303echo "$file created successfully."
Note: See TracBrowser for help on using the repository browser.