2013-02-04 00:49:29 +01:00
#!/bin/bash
#
# Script for acquiring and building OS X dependencies for 0 A.D.
#
# The script checks whether a source tarball exists for each
# dependency, if not it will download the correct version from
# the project's website, then it removes previous build files,
# extracts the tarball, configures and builds the lib. The script
# should die on any errors to ease troubleshooting.
#
# make install is used to copy the compiled libs to each specific
# directory and also the config tools (e.g. sdl-config). Because
# of this, OS X developers must run this script at least once,
# to configure the correct lib directories. It must be run again
# if the libraries are moved.
#
# Building against an SDK is an option, though not required,
# as not all build environments contain the Developer SDKs
# (Xcode does, but the Command Line Tools package does not)
#
# --------------------------------------------------------------
# Library versions for ease of updating:
2017-06-25 16:58:51 +02:00
ZLIB_VERSION = "zlib-1.2.11"
2016-01-10 14:23:25 +01:00
CURL_VERSION = "curl-7.46.0"
2013-11-11 01:04:07 +01:00
ICONV_VERSION = "libiconv-1.14"
2016-01-10 14:23:25 +01:00
XML2_VERSION = "libxml2-2.9.3"
SDL2_VERSION = "SDL2-2.0.4"
BOOST_VERSION = "boost_1_60_0"
2015-01-18 04:31:26 +01:00
WXWIDGETS_VERSION = "wxWidgets-3.0.2"
2016-01-18 17:42:54 +01:00
# libpng was included as part of X11 but that's removed from Mountain Lion
# (also the Snow Leopard version was ancient 1.2)
PNG_VERSION = "libpng-1.6.21"
2016-01-10 14:23:25 +01:00
OGG_VERSION = "libogg-1.3.2"
VORBIS_VERSION = "libvorbis-1.3.5"
2013-11-11 05:41:44 +01:00
# gloox is necessary for multiplayer lobby
2016-01-10 14:23:25 +01:00
GLOOX_VERSION = "gloox-1.0.14"
2014-03-28 21:26:32 +01:00
# NSPR is necessary for threadsafe Spidermonkey
2016-01-10 14:23:25 +01:00
NSPR_VERSION = "4.11"
2014-04-20 21:17:32 +02:00
# OS X only includes part of ICU, and only the dylib
2016-01-18 17:42:54 +01:00
# NOTE: remember to also update LIB_URL below when changing version
2016-01-10 14:23:25 +01:00
ICU_VERSION = "icu4c-56_1"
ENET_VERSION = "enet-1.3.13"
MINIUPNPC_VERSION = "miniupnpc-1.9.20151026"
2013-02-04 00:49:29 +01:00
# --------------------------------------------------------------
# Bundled with the game:
2016-09-02 18:14:11 +02:00
# * SpiderMonkey 38
2013-02-04 00:49:29 +01:00
# * NVTT
# * FCollada
# --------------------------------------------------------------
# Provided by OS X:
# * OpenAL
# * OpenGL
# --------------------------------------------------------------
2013-02-15 23:43:28 +01:00
# Force build architecture, as sometimes environment is broken.
# For a universal fat binary, the approach would be to build every
# dependency with both archs and combine them with lipo, then do the
# same thing with the game itself.
# Choices are "x86_64" or "i386" (ppc and ppc64 not supported)
2013-02-04 00:49:29 +01:00
ARCH = ${ ARCH : = "x86_64" }
2014-09-25 04:18:19 +02:00
# Define compiler as "clang", this is all Mavericks supports.
# gcc symlinks may still exist, but they are simply clang with
# slightly different config, which confuses build scripts.
# llvm-gcc and gcc 4.2 are no longer supported by SpiderMonkey.
2014-06-22 10:27:58 +02:00
export CC = ${ CC : = "clang" } CXX = ${ CXX : = "clang++" }
2014-06-28 10:54:59 +02:00
export MIN_OSX_VERSION = ${ MIN_OSX_VERSION : = "10.9" }
2013-02-04 00:49:29 +01:00
# The various libs offer inconsistent configure options, some allow
# setting sysroot and OS X-specific options, others don't. Adding to
# the confusion, Apple moved /Developer/SDKs into the Xcode app bundle
# so the path can't be guessed by clever build tools (like Boost.Build).
# Sometimes configure gets it wrong anyway, especially on cross compiles.
2014-03-14 06:18:40 +01:00
# This is why we prefer using (OBJ)CFLAGS, (OBJ)CXXFLAGS, and LDFLAGS.
2013-02-04 00:49:29 +01:00
# Check if SYSROOT is set and not empty
if [ [ $SYSROOT && ${ SYSROOT -_ } ] ] ; then
2014-03-14 06:18:40 +01:00
C_FLAGS = " -isysroot $SYSROOT "
2013-02-04 00:49:29 +01:00
LDFLAGS = " $LDFLAGS -Wl,-syslibroot, $SYSROOT "
fi
# Check if MIN_OSX_VERSION is set and not empty
if [ [ $MIN_OSX_VERSION && ${ MIN_OSX_VERSION -_ } ] ] ; then
2014-03-14 06:18:40 +01:00
C_FLAGS = " $C_FLAGS -mmacosx-version-min= $MIN_OSX_VERSION "
2013-11-11 01:04:07 +01:00
# clang and llvm-gcc look at mmacosx-version-min to determine link target
# and CRT version, and use it to set the macosx_version_min linker flag
2013-02-04 00:49:29 +01:00
LDFLAGS = " $LDFLAGS -mmacosx-version-min= $MIN_OSX_VERSION "
fi
2015-02-22 02:19:39 +01:00
# Force using libc++ since it has better C++11 support required by the game
# but pre-Mavericks still use libstdc++ by default
# Also enable c++0x for consistency with the game build
2014-03-14 06:18:40 +01:00
C_FLAGS = " $C_FLAGS -arch $ARCH -fvisibility=hidden "
2015-02-22 02:19:39 +01:00
LDFLAGS = " $LDFLAGS -arch $ARCH -stdlib=libc++ "
2013-02-04 00:49:29 +01:00
2014-03-14 06:18:40 +01:00
CFLAGS = " $CFLAGS $C_FLAGS "
2015-02-22 02:19:39 +01:00
CXXFLAGS = " $CXXFLAGS $C_FLAGS -stdlib=libc++ -std=c++0x "
2014-03-14 06:18:40 +01:00
OBJCFLAGS = " $OBJCFLAGS $C_FLAGS "
OBJCXXFLAGS = " $OBJCXXFLAGS $C_FLAGS "
2013-02-04 00:49:29 +01:00
JOBS = ${ JOBS : = "-j2" }
2013-02-15 23:43:28 +01:00
set -e
die( )
{
echo ERROR: $*
exit 1
}
download_lib( )
{
local url = $1
local filename = $2
if [ ! -e $filename ] ; then
echo " Downloading $filename "
2014-10-15 05:47:13 +02:00
curl -L -o ${ filename } ${ url } ${ filename } || die " Download of $url $filename failed "
2013-02-15 23:43:28 +01:00
fi
}
2013-11-11 01:04:07 +01:00
already_built( )
{
echo -e "Skipping - already built (use --force-rebuild to override)"
}
2013-02-04 00:49:29 +01:00
# Check that we're actually on OS X
if [ "`uname -s`" != "Darwin" ] ; then
die "This script is intended for OS X only"
fi
# Parse command-line options:
force_rebuild = false
for i in " $@ "
do
case $i in
--force-rebuild ) force_rebuild = true; ;
-j* ) JOBS = $i ; ;
esac
done
cd " $( dirname $0 ) "
# Now in libraries/osx/ (where we assume this script resides)
# --------------------------------------------------------------
2013-11-11 01:04:07 +01:00
echo -e "Building zlib..."
LIB_VERSION = " ${ ZLIB_VERSION } "
LIB_ARCHIVE = " $LIB_VERSION .tar.gz "
LIB_DIRECTORY = $LIB_VERSION
LIB_URL = "http://zlib.net/"
mkdir -p zlib
pushd zlib > /dev/null
ZLIB_DIR = " $( pwd ) "
if [ [ " $force_rebuild " = "true" ] ] || [ [ ! -e .already-built ] ] || [ [ .already-built -ot $LIB_DIRECTORY ] ]
then
2013-12-15 03:14:45 +01:00
rm -f .already-built
2013-11-11 01:04:07 +01:00
download_lib $LIB_URL $LIB_ARCHIVE
2013-12-15 03:14:45 +01:00
rm -rf $LIB_DIRECTORY include lib share
2013-11-11 01:04:07 +01:00
tar -xf $LIB_ARCHIVE
pushd $LIB_DIRECTORY
# patch zlib's configure script to use our CFLAGS and LDFLAGS
2013-11-11 05:41:44 +01:00
( patch -p0 -i ../../patches/zlib_flags.diff && CFLAGS = " $CFLAGS " LDFLAGS = " $LDFLAGS " ./configure --prefix= " $ZLIB_DIR " --static && make ${ JOBS } && make install) || die "zlib build failed"
2013-11-11 01:04:07 +01:00
popd
touch .already-built
else
already_built
fi
popd > /dev/null
# --------------------------------------------------------------
echo -e "Building libcurl..."
LIB_VERSION = " ${ CURL_VERSION } "
LIB_ARCHIVE = " $LIB_VERSION .tar.bz2 "
LIB_DIRECTORY = " $LIB_VERSION "
LIB_URL = "http://curl.haxx.se/download/"
mkdir -p libcurl
pushd libcurl > /dev/null
if [ [ " $force_rebuild " = "true" ] ] || [ [ ! -e .already-built ] ] || [ [ .already-built -ot $LIB_DIRECTORY ] ]
then
INSTALL_DIR = " $( pwd ) "
2013-12-15 03:14:45 +01:00
rm -f .already-built
2013-11-11 01:04:07 +01:00
download_lib $LIB_URL $LIB_ARCHIVE
2013-12-15 03:14:45 +01:00
rm -rf $LIB_DIRECTORY bin include lib share
2013-11-11 01:04:07 +01:00
tar -xf $LIB_ARCHIVE
pushd $LIB_DIRECTORY
2014-03-14 05:17:42 +01:00
( ./configure CFLAGS = " $CFLAGS " LDFLAGS = " $LDFLAGS " --prefix= " $INSTALL_DIR " --enable-ipv6 --without-gnutls --without-gssapi --without-libmetalink --without-librtmp --without-libssh2 --without-nss --without-polarssl --without-spnego --without-ssl --disable-ares --disable-ldap --disable-ldaps --without-libidn --with-zlib= " ${ ZLIB_DIR } " --enable-shared= no && make ${ JOBS } && make install) || die "libcurl build failed"
2013-11-11 01:04:07 +01:00
popd
touch .already-built
else
already_built
fi
popd > /dev/null
# --------------------------------------------------------------
echo -e "Building libiconv..."
LIB_VERSION = " ${ ICONV_VERSION } "
LIB_ARCHIVE = " $LIB_VERSION .tar.gz "
LIB_DIRECTORY = " $LIB_VERSION "
LIB_URL = "http://ftp.gnu.org/pub/gnu/libiconv/"
2014-06-22 10:27:58 +02:00
mkdir -p iconv
pushd iconv > /dev/null
2013-11-11 01:04:07 +01:00
ICONV_DIR = " $( pwd ) "
if [ [ " $force_rebuild " = "true" ] ] || [ [ ! -e .already-built ] ] || [ [ .already-built -ot $LIB_DIRECTORY ] ]
then
2013-12-15 03:14:45 +01:00
rm -f .already-built
2013-11-11 01:04:07 +01:00
download_lib $LIB_URL $LIB_ARCHIVE
2013-12-15 03:14:45 +01:00
rm -rf $LIB_DIRECTORY bin include lib share
2013-11-11 01:04:07 +01:00
tar -xf $LIB_ARCHIVE
pushd $LIB_DIRECTORY
2013-02-04 00:49:29 +01:00
2014-03-14 05:17:42 +01:00
( ./configure CFLAGS = " $CFLAGS " LDFLAGS = " $LDFLAGS " --prefix= " $ICONV_DIR " --without-libiconv-prefix --without-libintl-prefix --disable-nls --enable-shared= no && make ${ JOBS } && make install) || die "libiconv build failed"
2013-11-11 01:04:07 +01:00
popd
touch .already-built
else
already_built
fi
popd > /dev/null
# --------------------------------------------------------------
echo -e "Building libxml2..."
LIB_VERSION = " ${ XML2_VERSION } "
LIB_ARCHIVE = " $LIB_VERSION .tar.gz "
LIB_DIRECTORY = " $LIB_VERSION "
LIB_URL = "ftp://xmlsoft.org/libxml2/"
mkdir -p libxml2
pushd libxml2 > /dev/null
if [ [ " $force_rebuild " = "true" ] ] || [ [ ! -e .already-built ] ] || [ [ .already-built -ot $LIB_DIRECTORY ] ]
then
INSTALL_DIR = " $( pwd ) "
2013-12-15 03:14:45 +01:00
rm -f .already-built
2013-11-11 01:04:07 +01:00
download_lib $LIB_URL $LIB_ARCHIVE
2013-12-15 03:14:45 +01:00
rm -rf $LIB_DIRECTORY bin include lib share
2013-11-11 01:04:07 +01:00
tar -xf $LIB_ARCHIVE
pushd $LIB_DIRECTORY
2014-03-14 05:17:42 +01:00
( ./configure CFLAGS = " $CFLAGS " LDFLAGS = " $LDFLAGS " --prefix= " $INSTALL_DIR " --without-lzma --without-python --with-iconv= " ${ ICONV_DIR } " --with-zlib= " ${ ZLIB_DIR } " --enable-shared= no && make ${ JOBS } && make install) || die "libxml2 build failed"
2013-11-11 01:04:07 +01:00
popd
touch .already-built
else
already_built
fi
popd > /dev/null
# --------------------------------------------------------------
2014-09-20 21:02:24 +02:00
echo -e "Building SDL2..."
LIB_VERSION = " ${ SDL2_VERSION } "
LIB_ARCHIVE = " $LIB_VERSION .tar.gz "
LIB_DIRECTORY = $LIB_VERSION
2016-01-10 14:23:25 +01:00
LIB_URL = "https://libsdl.org/release/"
2014-09-20 21:02:24 +02:00
mkdir -p sdl2
pushd sdl2 > /dev/null
if [ [ " $force_rebuild " = "true" ] ] || [ [ ! -e .already-built ] ] || [ [ .already-built -ot $LIB_DIRECTORY ] ]
then
INSTALL_DIR = " $( pwd ) "
rm -f .already-built
download_lib $LIB_URL $LIB_ARCHIVE
rm -rf $LIB_DIRECTORY bin include lib share
tar -xf $LIB_ARCHIVE
pushd $LIB_DIRECTORY
# We don't want SDL2 to pull in system iconv, force it to detect ours with flags.
# Don't use X11 - we don't need it and Mountain Lion removed it
2014-10-06 03:05:46 +02:00
( ./configure CPPFLAGS = " -I ${ ICONV_DIR } /include " CFLAGS = " $CFLAGS " CXXFLAGS = " $CXXFLAGS " LDFLAGS = " $LDFLAGS -L ${ ICONV_DIR } /lib " --prefix= " $INSTALL_DIR " --disable-video-x11 --without-x --enable-shared= no && make $JOBS && make install) || die "SDL2 build failed"
2014-09-20 21:02:24 +02:00
popd
touch .already-built
else
already_built
fi
popd > /dev/null
2013-02-04 00:49:29 +01:00
# --------------------------------------------------------------
2013-11-11 01:04:07 +01:00
echo -e "Building Boost..."
2013-02-04 00:49:29 +01:00
LIB_VERSION = " ${ BOOST_VERSION } "
LIB_ARCHIVE = " $LIB_VERSION .tar.bz2 "
LIB_DIRECTORY = " $LIB_VERSION "
LIB_URL = "http://download.sourceforge.net/boost/"
mkdir -p boost
2013-11-11 01:04:07 +01:00
pushd boost > /dev/null
2013-02-04 00:49:29 +01:00
if [ [ " $force_rebuild " = "true" ] ] || [ [ ! -e .already-built ] ] || [ [ .already-built -ot $LIB_DIRECTORY ] ]
then
INSTALL_DIR = " $( pwd ) "
2013-12-15 03:14:45 +01:00
rm -f .already-built
2013-02-04 00:49:29 +01:00
download_lib $LIB_URL $LIB_ARCHIVE
2013-12-15 03:14:45 +01:00
rm -rf $LIB_DIRECTORY include lib
2013-02-04 00:49:29 +01:00
tar -xf $LIB_ARCHIVE
pushd $LIB_DIRECTORY
# Can't use macosx-version, see above comment.
2016-01-18 17:46:32 +01:00
( ./bootstrap.sh --with-libraries= filesystem,system --prefix= $INSTALL_DIR && ./b2 cflags = " $CFLAGS " toolset = clang cxxflags = " $CXXFLAGS " linkflags = " $LDFLAGS " ${ JOBS } -d2 --layout= tagged --debug-configuration link = static threading = multi variant = release,debug install) || die "Boost build failed"
2013-02-04 00:49:29 +01:00
popd
touch .already-built
else
2013-11-11 01:04:07 +01:00
already_built
2013-02-04 00:49:29 +01:00
fi
2013-11-11 01:04:07 +01:00
popd > /dev/null
2013-02-04 00:49:29 +01:00
# --------------------------------------------------------------
2016-03-12 19:15:04 +01:00
# TODO: This build takes ages, anything we can exclude?
2013-11-11 01:04:07 +01:00
echo -e "Building wxWidgets..."
2013-02-04 00:49:29 +01:00
LIB_VERSION = " ${ WXWIDGETS_VERSION } "
LIB_ARCHIVE = " $LIB_VERSION .tar.bz2 "
LIB_DIRECTORY = " $LIB_VERSION "
LIB_URL = "http://download.sourceforge.net/wxwindows/"
mkdir -p wxwidgets
2013-11-11 01:04:07 +01:00
pushd wxwidgets > /dev/null
2013-02-04 00:49:29 +01:00
if [ [ " $force_rebuild " = "true" ] ] || [ [ ! -e .already-built ] ] || [ [ .already-built -ot $LIB_DIRECTORY ] ]
then
INSTALL_DIR = " $( pwd ) "
2013-12-15 03:14:45 +01:00
rm -f .already-built
2013-02-04 00:49:29 +01:00
download_lib $LIB_URL $LIB_ARCHIVE
2013-12-15 03:14:45 +01:00
rm -rf $LIB_DIRECTORY bin include lib share
2013-02-04 00:49:29 +01:00
tar -xf $LIB_ARCHIVE
pushd $LIB_DIRECTORY
mkdir -p build-release
pushd build-release
2013-12-15 03:14:45 +01:00
2016-03-12 19:15:04 +01:00
CONF_OPTS = " --prefix= $INSTALL_DIR --disable-shared --enable-macosx_arch= $ARCH --enable-unicode --with-cocoa --with-opengl --with-libiconv-prefix= ${ ICONV_DIR } --with-expat=builtin --with-png=builtin --without-libtiff --without-sdl --without-x --disable-webview --disable-webkit --disable-webviewwebkit --disable-webviewie "
2013-12-15 03:14:45 +01:00
# wxWidgets configure now defaults to targeting 10.5, if not specified,
# but that conflicts with our flags
if [ [ $MIN_OSX_VERSION && ${ MIN_OSX_VERSION -_ } ] ] ; then
CONF_OPTS = " $CONF_OPTS --with-macosx-version-min= $MIN_OSX_VERSION "
fi
2015-01-18 04:31:26 +01:00
# patch to fix wxWidgets build on Yosemite (fixed upstream, see http://trac.wxwidgets.org/ticket/16329 )
2015-02-22 02:19:39 +01:00
# Force libc++ in CPPFLAGS as well, since CXXFLAGS isn't enough here
( patch -p0 -d.. -i../../patches/wxwidgets-webkit-fix.diff && ../configure CFLAGS = " $CFLAGS " CXXFLAGS = " $CXXFLAGS " CPPFLAGS = "-stdlib=libc++" LDFLAGS = " $LDFLAGS " $CONF_OPTS && make ${ JOBS } && make install) || die "wxWidgets build failed"
2013-02-04 00:49:29 +01:00
popd
popd
touch .already-built
else
2013-11-11 01:04:07 +01:00
already_built
2013-02-04 00:49:29 +01:00
fi
2013-11-11 01:04:07 +01:00
popd > /dev/null
2013-02-04 00:49:29 +01:00
# --------------------------------------------------------------
2013-11-11 01:04:07 +01:00
echo -e "Building libpng..."
2013-02-04 00:49:29 +01:00
LIB_VERSION = " ${ PNG_VERSION } "
LIB_ARCHIVE = " $LIB_VERSION .tar.gz "
LIB_DIRECTORY = " $LIB_VERSION "
LIB_URL = "http://download.sourceforge.net/libpng/"
mkdir -p libpng
2013-11-11 01:04:07 +01:00
pushd libpng > /dev/null
2013-02-04 00:49:29 +01:00
if [ [ " $force_rebuild " = "true" ] ] || [ [ ! -e .already-built ] ] || [ [ .already-built -ot $LIB_DIRECTORY ] ]
then
INSTALL_DIR = " $( pwd ) "
2013-12-15 03:14:45 +01:00
rm -f .already-built
2013-02-04 00:49:29 +01:00
download_lib $LIB_URL $LIB_ARCHIVE
2013-12-15 03:14:45 +01:00
rm -rf $LIB_DIRECTORY bin include lib share
2013-02-04 00:49:29 +01:00
tar -xf $LIB_ARCHIVE
pushd $LIB_DIRECTORY
2014-03-14 05:17:42 +01:00
( ./configure CFLAGS = " $CFLAGS " LDFLAGS = " $LDFLAGS " --prefix= $INSTALL_DIR --enable-shared= no && make ${ JOBS } && make install) || die "libpng build failed"
2013-02-04 00:49:29 +01:00
popd
touch .already-built
else
2013-11-11 01:04:07 +01:00
already_built
2013-02-04 00:49:29 +01:00
fi
2013-11-11 01:04:07 +01:00
popd > /dev/null
2013-02-04 00:49:29 +01:00
# --------------------------------------------------------------
2013-11-11 01:04:07 +01:00
echo -e "Building libogg..."
2013-02-04 00:49:29 +01:00
LIB_VERSION = " ${ OGG_VERSION } "
LIB_ARCHIVE = " $LIB_VERSION .tar.gz "
LIB_DIRECTORY = " $LIB_VERSION "
LIB_URL = "http://downloads.xiph.org/releases/ogg/"
# Dependency of vorbis
# we can install them in the same directory for convenience
mkdir -p libogg
mkdir -p vorbis
2013-11-11 01:04:07 +01:00
pushd libogg > /dev/null
2013-12-15 03:14:45 +01:00
OGG_DIR = " $( pwd ) "
2013-02-04 00:49:29 +01:00
if [ [ " $force_rebuild " = "true" ] ] || [ [ ! -e .already-built ] ] || [ [ .already-built -ot $LIB_DIRECTORY ] ]
then
2013-12-15 03:14:45 +01:00
rm -f .already-built
2013-02-04 00:49:29 +01:00
download_lib $LIB_URL $LIB_ARCHIVE
2013-12-15 03:14:45 +01:00
rm -rf $LIB_DIRECTORY include lib share
2013-02-04 00:49:29 +01:00
tar -xf $LIB_ARCHIVE
pushd $LIB_DIRECTORY
2014-03-14 05:17:42 +01:00
( ./configure CFLAGS = " $CFLAGS " LDFLAGS = " $LDFLAGS " --prefix= $OGG_DIR --enable-shared= no && make ${ JOBS } && make install) || die "libogg build failed"
2013-02-04 00:49:29 +01:00
popd
touch .already-built
else
2013-11-11 01:04:07 +01:00
already_built
2013-02-04 00:49:29 +01:00
fi
2013-11-11 01:04:07 +01:00
popd > /dev/null
2013-02-04 00:49:29 +01:00
# --------------------------------------------------------------
2013-11-11 01:04:07 +01:00
echo -e "Building libvorbis..."
2013-02-04 00:49:29 +01:00
LIB_VERSION = " ${ VORBIS_VERSION } "
LIB_ARCHIVE = " $LIB_VERSION .tar.gz "
LIB_DIRECTORY = " $LIB_VERSION "
LIB_URL = "http://downloads.xiph.org/releases/vorbis/"
2013-11-11 01:04:07 +01:00
pushd vorbis > /dev/null
2013-02-04 00:49:29 +01:00
if [ [ " $force_rebuild " = "true" ] ] || [ [ ! -e .already-built ] ] || [ [ .already-built -ot $LIB_DIRECTORY ] ]
then
INSTALL_DIR = " $( pwd ) "
2013-12-15 03:14:45 +01:00
rm -f .already-built
2013-02-04 00:49:29 +01:00
download_lib $LIB_URL $LIB_ARCHIVE
2013-12-15 03:14:45 +01:00
rm -rf $LIB_DIRECTORY include lib share
2013-02-04 00:49:29 +01:00
tar -xf $LIB_ARCHIVE
pushd $LIB_DIRECTORY
2014-03-14 05:17:42 +01:00
( ./configure CFLAGS = " $CFLAGS " LDFLAGS = " $LDFLAGS " --prefix= " $INSTALL_DIR " --enable-shared= no --with-ogg= " $OGG_DIR " && make ${ JOBS } && make install) || die "libvorbis build failed"
2013-02-04 00:49:29 +01:00
popd
touch .already-built
else
2013-11-11 01:04:07 +01:00
already_built
2013-02-04 00:49:29 +01:00
fi
2013-11-11 01:04:07 +01:00
popd > /dev/null
2013-02-04 00:49:29 +01:00
2013-11-11 05:41:44 +01:00
# --------------------------------------------------------------
echo -e "Building gloox..."
LIB_VERSION = " ${ GLOOX_VERSION } "
LIB_ARCHIVE = " $LIB_VERSION .tar.bz2 "
LIB_DIRECTORY = " $LIB_VERSION "
LIB_URL = "http://camaya.net/download/"
mkdir -p gloox
pushd gloox > /dev/null
if [ [ " $force_rebuild " = "true" ] ] || [ [ ! -e .already-built ] ] || [ [ .already-built -ot $LIB_DIRECTORY ] ]
then
INSTALL_DIR = " $( pwd ) "
2013-12-15 03:14:45 +01:00
rm -f .already-built
2013-11-11 05:41:44 +01:00
download_lib $LIB_URL $LIB_ARCHIVE
2013-12-15 03:14:45 +01:00
rm -rf $LIB_DIRECTORY bin include lib
2013-11-11 05:41:44 +01:00
tar -xf $LIB_ARCHIVE
pushd $LIB_DIRECTORY
# TODO: pulls in libresolv dependency from /usr/lib
# TODO: if we ever use SSL/TLS, that will add yet another dependency...
2016-01-10 14:23:25 +01:00
( ./configure CFLAGS = " $CFLAGS " CXXFLAGS = " $CXXFLAGS " LDFLAGS = " $LDFLAGS " --prefix= " $INSTALL_DIR " --enable-shared= no --with-zlib= " ${ ZLIB_DIR } " --without-libidn --without-gnutls --without-openssl --without-tests --without-examples && make ${ JOBS } && make install) || die "gloox build failed"
2013-11-11 05:41:44 +01:00
popd
touch .already-built
else
already_built
fi
popd > /dev/null
2014-03-28 21:26:32 +01:00
# --------------------------------------------------------------
echo -e "Building NSPR..."
LIB_VERSION = " ${ NSPR_VERSION } "
LIB_ARCHIVE = " nspr- $LIB_VERSION .tar.gz "
LIB_DIRECTORY = " nspr- $LIB_VERSION "
LIB_URL = " https://ftp.mozilla.org/pub/mozilla.org/nspr/releases/v $LIB_VERSION /src/ "
mkdir -p nspr
pushd nspr > /dev/null
NSPR_DIR = " $( pwd ) "
if [ [ " $force_rebuild " = "true" ] ] || [ [ ! -e .already-built ] ] || [ [ .already-built -ot $LIB_DIRECTORY ] ]
then
rm -f .already-built
download_lib $LIB_URL $LIB_ARCHIVE
rm -rf $LIB_DIRECTORY bin include lib share
tar -xf $LIB_ARCHIVE
pushd $LIB_DIRECTORY /nspr
2014-06-22 10:27:58 +02:00
( CFLAGS = " $CFLAGS " CXXFLAGS = " $CXXFLAGS " LDFLAGS = " $LDFLAGS " ./configure --prefix= " $NSPR_DIR " && make ${ JOBS } && make install) || die "NSPR build failed"
2014-03-28 21:26:32 +01:00
popd
# TODO: how can we not build the dylibs?
rm -f lib/*.dylib
2014-10-15 05:47:13 +02:00
touch .already-built
2014-04-20 21:17:32 +02:00
else
already_built
fi
popd > /dev/null
# --------------------------------------------------------------
echo -e "Building ICU..."
LIB_VERSION = " ${ ICU_VERSION } "
LIB_ARCHIVE = " $LIB_VERSION -src.tgz "
LIB_DIRECTORY = "icu"
2016-01-10 14:23:25 +01:00
LIB_URL = "http://download.icu-project.org/files/icu4c/56.1/"
2014-04-20 21:17:32 +02:00
mkdir -p icu
pushd icu > /dev/null
if [ [ " $force_rebuild " = "true" ] ] || [ [ ! -e .already-built ] ] || [ [ .already-built -ot $LIB_DIRECTORY ] ]
then
INSTALL_DIR = " $( pwd ) "
rm -f .already-built
download_lib $LIB_URL $LIB_ARCHIVE
rm -rf $LIB_DIRECTORY bin include lib sbin share
tar -xf $LIB_ARCHIVE
pushd $LIB_DIRECTORY
mkdir -p source/build
pushd source/build
2014-09-10 01:56:39 +02:00
( CFLAGS = " $CFLAGS " CXXFLAGS = " $CXXFLAGS " LDFLAGS = " $LDFLAGS " ../runConfigureICU MacOSX --prefix= $INSTALL_DIR --disable-shared --enable-static --disable-samples --enable-extras --enable-icuio --enable-layout --enable-tools && make ${ JOBS } && make install) || die "ICU build failed"
2014-04-20 21:17:32 +02:00
popd
popd
2014-03-28 21:26:32 +01:00
touch .already-built
else
already_built
fi
popd > /dev/null
2014-06-28 07:48:51 +02:00
# --------------------------------------------------------------
echo -e "Building ENet..."
LIB_VERSION = " ${ ENET_VERSION } "
LIB_ARCHIVE = " $LIB_VERSION .tar.gz "
LIB_DIRECTORY = " $LIB_VERSION "
LIB_URL = "http://enet.bespin.org/download/"
mkdir -p enet
pushd enet > /dev/null
if [ [ " $force_rebuild " = "true" ] ] || [ [ ! -e .already-built ] ] || [ [ .already-built -ot $LIB_DIRECTORY ] ]
then
INSTALL_DIR = " $( pwd ) "
rm -f .already-built
download_lib $LIB_URL $LIB_ARCHIVE
rm -rf $LIB_DIRECTORY bin include lib sbin share
tar -xf $LIB_ARCHIVE
pushd $LIB_DIRECTORY
( ./configure CFLAGS = " $CFLAGS " LDFLAGS = " $LDFLAGS " --prefix= ${ INSTALL_DIR } --enable-shared= no && make clean && make ${ JOBS } && make install) || die "ENet build failed"
popd
touch .already-built
else
already_built
fi
popd > /dev/null
2014-10-15 05:47:13 +02:00
# --------------------------------------------------------------
echo -e "Building MiniUPnPc..."
LIB_VERSION = " ${ MINIUPNPC_VERSION } "
LIB_ARCHIVE = " $LIB_VERSION .tar.gz "
LIB_DIRECTORY = " $LIB_VERSION "
LIB_URL = "http://miniupnp.tuxfamily.org/files/download.php?file="
mkdir -p miniupnpc
pushd miniupnpc > /dev/null
if [ [ " $force_rebuild " = "true" ] ] || [ [ ! -e .already-built ] ] || [ [ .already-built -ot $LIB_DIRECTORY ] ]
then
INSTALL_DIR = " $( pwd ) "
rm -f .already-built
download_lib $LIB_URL $LIB_ARCHIVE
rm -rf $LIB_DIRECTORY bin include lib share
tar -xf $LIB_ARCHIVE
pushd $LIB_DIRECTORY
2015-10-11 01:53:54 +02:00
( make clean && CFLAGS = $CFLAGS LDFLAGS = $LDFLAGS make ${ JOBS } && INSTALLPREFIX = " $INSTALL_DIR " make install) || die "MiniUPnPc build failed"
2014-10-15 05:47:13 +02:00
popd
# TODO: how can we not build the dylibs?
rm -f lib/*.dylib
touch .already-built
else
already_built
fi
popd > /dev/null
2013-02-04 00:49:29 +01:00
# --------------------------------------------------------------------
# The following libraries are shared on different OSes and may
2014-06-28 07:48:51 +02:00
# be customized, so we build and install them from bundled sources
2013-02-04 00:49:29 +01:00
# --------------------------------------------------------------------
2013-11-11 01:04:07 +01:00
echo -e "Building Spidermonkey..."
2016-09-02 18:14:11 +02:00
LIB_VERSION = "mozjs-38.2.1"
2015-01-24 15:46:52 +01:00
LIB_ARCHIVE = " $LIB_VERSION .rc0.tar.bz2 "
2016-09-02 18:14:11 +02:00
LIB_DIRECTORY = "mozjs-38.0.0"
2013-02-04 00:49:29 +01:00
2013-11-11 01:04:07 +01:00
pushd ../source/spidermonkey/ > /dev/null
2013-02-04 00:49:29 +01:00
2014-08-31 06:19:13 +02:00
if [ [ " $force_rebuild " = "true" ] ] || [ [ ! -e .already-built ] ] || [ [ .already-built -ot $LIB_DIRECTORY ] ] || [ [ .already-built -ot README.txt ] ]
2013-02-04 00:49:29 +01:00
then
INSTALL_DIR = " $( pwd ) "
2014-03-28 21:26:32 +01:00
INCLUDE_DIR_DEBUG = $INSTALL_DIR /include-unix-debug
INCLUDE_DIR_RELEASE = $INSTALL_DIR /include-unix-release
2013-02-04 00:49:29 +01:00
2013-12-15 03:14:45 +01:00
rm -f .already-built
2013-02-04 00:49:29 +01:00
rm -f lib/*.a
2014-03-28 21:26:32 +01:00
rm -rf $LIB_DIRECTORY $INCLUDE_DIR_DEBUG $INCLUDE_DIR_RELEASE
2013-02-04 00:49:29 +01:00
tar -xf $LIB_ARCHIVE
2015-09-24 14:04:15 +02:00
# Apply patches
2015-09-30 22:28:13 +02:00
pushd $LIB_DIRECTORY
. ../patch.sh
popd
2015-09-24 14:04:15 +02:00
pushd $LIB_DIRECTORY /js/src
2013-02-04 00:49:29 +01:00
# We want separate debug/release versions of the library, so change their install name in the Makefile
2016-09-02 18:14:11 +02:00
perl -i.bak -pe 's/(^STATIC_LIBRARY_NAME\s+=).*/$1' \' 'mozjs38-ps-debug' \' '/' moz.build
2013-02-04 00:49:29 +01:00
2016-09-02 18:14:11 +02:00
CONF_OPTS = " --target= $ARCH -apple-darwin --prefix= ${ INSTALL_DIR } --with-system-nspr --with-nspr-prefix= ${ NSPR_DIR } --with-system-zlib= ${ ZLIB_DIR } --disable-tests --disable-shared-js "
# Change the default location where the tracelogger should store its output, which is /tmp/ on OSX.
TLCXXFLAGS = '-DTRACE_LOG_DIR="\"../../source/tools/tracelogger/\""'
2013-02-04 00:49:29 +01:00
# Uncomment this line for 32-bit 10.5 cross compile:
#CONF_OPTS="$CONF_OPTS --target=i386-apple-darwin9.0.0"
if [ [ $MIN_OSX_VERSION && ${ MIN_OSX_VERSION -_ } ] ] ; then
CONF_OPTS = " $CONF_OPTS --enable-macos-target= $MIN_OSX_VERSION "
fi
if [ [ $SYSROOT && ${ SYSROOT -_ } ] ] ; then
CONF_OPTS = " $CONF_OPTS --with-macosx-sdk= $SYSROOT "
fi
mkdir -p build-debug
pushd build-debug
2016-09-02 18:14:11 +02:00
( CC = "clang" CXX = "clang++" CXXFLAGS = " ${ TLCXXFLAGS } " AR = ar CROSS_COMPILE = 1 ../configure $CONF_OPTS --enable-debug --disable-optimize --enable-js-diagnostics --enable-gczeal && make ${ JOBS } ) || die "Spidermonkey build failed"
2014-03-28 21:26:32 +01:00
# js-config.h is different for debug and release builds, so we need different include directories for both
mkdir -p $INCLUDE_DIR_DEBUG
cp -R -L dist/include/* $INCLUDE_DIR_DEBUG /
2015-01-17 15:03:22 +01:00
cp dist/lib/*.a $INSTALL_DIR /lib
2013-02-04 00:49:29 +01:00
popd
2016-09-02 18:14:11 +02:00
mv moz.build.bak moz.build
2013-02-04 00:49:29 +01:00
2016-09-02 18:14:11 +02:00
perl -i.bak -pe 's/(^STATIC_LIBRARY_NAME\s+=).*/$1' \' 'mozjs38-ps-release' \' '/' moz.build
2013-02-04 00:49:29 +01:00
mkdir -p build-release
pushd build-release
2016-09-02 18:14:11 +02:00
( CC = "clang" CXX = "clang++" CXXFLAGS = " ${ TLCXXFLAGS } " AR = ar CROSS_COMPILE = 1 ../configure $CONF_OPTS --enable-optimize && make ${ JOBS } ) || die "Spidermonkey build failed"
2014-03-28 21:26:32 +01:00
# js-config.h is different for debug and release builds, so we need different include directories for both
mkdir -p $INCLUDE_DIR_RELEASE
cp -R -L dist/include/* $INCLUDE_DIR_RELEASE /
2015-01-17 15:03:22 +01:00
cp dist/lib/*.a $INSTALL_DIR /lib
2013-02-04 00:49:29 +01:00
popd
2016-09-02 18:14:11 +02:00
mv moz.build.bak moz.build
2013-02-04 00:49:29 +01:00
popd
touch .already-built
else
2013-11-11 01:04:07 +01:00
already_built
2013-02-04 00:49:29 +01:00
fi
2013-11-11 01:04:07 +01:00
popd > /dev/null
2013-02-04 00:49:29 +01:00
# --------------------------------------------------------------
# NVTT - no install
2013-11-11 01:04:07 +01:00
echo -e "Building NVTT..."
2013-02-04 00:49:29 +01:00
2013-11-11 01:04:07 +01:00
pushd ../source/nvtt > /dev/null
2013-02-04 00:49:29 +01:00
if [ [ " $force_rebuild " = "true" ] ] || [ [ ! -e .already-built ] ]
then
2013-12-15 03:14:45 +01:00
rm -f .already-built
2013-12-15 21:56:58 +01:00
rm -f lib/*.a
2013-02-04 00:49:29 +01:00
pushd src
rm -rf build
mkdir -p build
pushd build
# Could use CMAKE_OSX_DEPLOYMENT_TARGET and CMAKE_OSX_SYSROOT
# but they're not as flexible for cross-compiling
2013-02-15 00:37:04 +01:00
# Disable optional libs that we don't need (avoids some conflicts with MacPorts)
2014-03-14 05:17:42 +01:00
( cmake .. -DCMAKE_LINK_FLAGS= " $LDFLAGS " -DCMAKE_C_FLAGS= " $CFLAGS " -DCMAKE_CXX_FLAGS= " $CXXFLAGS " -DCMAKE_BUILD_TYPE= Release -DBINDIR= bin -DLIBDIR= lib -DGLUT= 0 -DGLEW= 0 -DCG= 0 -DCUDA= 0 -DOPENEXR= 0 -DJPEG= 0 -DPNG= 0 -DTIFF= 0 -G "Unix Makefiles" && make clean && make nvtt ${ JOBS } ) || die "NVTT build failed"
2013-02-04 00:49:29 +01:00
popd
mkdir -p ../lib
cp build/src/nv*/libnv*.a ../lib/
cp build/src/nvtt/squish/libsquish.a ../lib/
popd
touch .already-built
else
2013-11-11 01:04:07 +01:00
already_built
2013-02-04 00:49:29 +01:00
fi
2013-11-11 01:04:07 +01:00
popd > /dev/null
2013-02-04 00:49:29 +01:00
# --------------------------------------------------------------
# FCollada - no install
2013-11-11 01:04:07 +01:00
echo -e "Building FCollada..."
2013-02-04 00:49:29 +01:00
2013-11-11 01:04:07 +01:00
pushd ../source/fcollada > /dev/null
2013-02-04 00:49:29 +01:00
if [ [ " $force_rebuild " = "true" ] ] || [ [ ! -e .already-built ] ]
then
2013-12-15 03:14:45 +01:00
rm -f .already-built
2013-12-15 21:56:58 +01:00
rm -f lib/*.a
2013-02-04 00:49:29 +01:00
pushd src
rm -rf output
mkdir -p ../lib
# The Makefile refers to pkg-config for libxml2, but we
# don't have that (replace with xml2-config instead)
sed -i.bak -e 's/pkg-config libxml-2.0/xml2-config/' Makefile
2014-03-14 05:17:42 +01:00
( make clean && CXXFLAGS = $CXXFLAGS make ${ JOBS } ) || die "FCollada build failed"
2013-02-04 00:49:29 +01:00
# Undo Makefile change
mv Makefile.bak Makefile
popd
touch .already-built
else
2013-11-11 01:04:07 +01:00
already_built
2013-02-04 00:49:29 +01:00
fi
2013-11-11 01:04:07 +01:00
popd > /dev/null