Index: ps/trunk/libraries/osx/build-osx-libs.sh =================================================================== --- ps/trunk/libraries/osx/build-osx-libs.sh (revision 24273) +++ ps/trunk/libraries/osx/build-osx-libs.sh (revision 24274) @@ -1,1027 +1,1027 @@ #!/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: ZLIB_VERSION="zlib-1.2.11" CURL_VERSION="curl-7.71.0" ICONV_VERSION="libiconv-1.16" XML2_VERSION="libxml2-2.9.10" SDL2_VERSION="SDL2-2.0.12" # NOTE: remember to also update LIB_URL below when changing version BOOST_VERSION="boost_1_74_0" # NOTE: remember to also update LIB_URL below when changing version WXWIDGETS_VERSION="wxWidgets-3.0.3.1" # 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.36" OGG_VERSION="libogg-1.3.3" VORBIS_VERSION="libvorbis-1.3.7" # gloox requires GnuTLS, GnuTLS requires Nettle and GMP GMP_VERSION="gmp-6.2.0" NETTLE_VERSION="nettle-3.6" # NOTE: remember to also update LIB_URL below when changing version GLOOX_VERSION="gloox-1.0.24" GNUTLS_VERSION="gnutls-3.6.15" # OS X only includes part of ICU, and only the dylib # NOTE: remember to also update LIB_URL below when changing version ICU_VERSION="icu4c-67_1" ENET_VERSION="enet-1.3.17" MINIUPNPC_VERSION="miniupnpc-2.1" SODIUM_VERSION="libsodium-1.0.18" FMT_VERSION="7.1.3" # -------------------------------------------------------------- # Bundled with the game: # * SpiderMonkey # * NVTT # * FCollada # -------------------------------------------------------------- # We use suffixes here in order to force rebuilding when patching these libs NVTT_VERSION="nvtt-2.1.1+wildfiregames.2" FCOLLADA_VERSION="fcollada-3.05+wildfiregames.2" # -------------------------------------------------------------- # Provided by OS X: # * OpenAL # * OpenGL # -------------------------------------------------------------- export CC=${CC:="clang"} CXX=${CXX:="clang++"} export MIN_OSX_VERSION=${MIN_OSX_VERSION:="10.12"} # 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. # This is why we prefer using (OBJ)CFLAGS, (OBJ)CXXFLAGS, and LDFLAGS. # Check if SYSROOT is set and not empty if [[ $SYSROOT && ${SYSROOT-_} ]]; then C_FLAGS="-isysroot $SYSROOT" LDFLAGS="$LDFLAGS -Wl,-syslibroot,$SYSROOT" fi # Check if MIN_OSX_VERSION is set and not empty if [[ $MIN_OSX_VERSION && ${MIN_OSX_VERSION-_} ]]; then C_FLAGS="$C_FLAGS -mmacosx-version-min=$MIN_OSX_VERSION" # 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 LDFLAGS="$LDFLAGS -mmacosx-version-min=$MIN_OSX_VERSION" fi CFLAGS="$CFLAGS $C_FLAGS -fvisibility=hidden" CXXFLAGS="$CXXFLAGS $C_FLAGS -stdlib=libc++ -std=c++14 -msse4.1" OBJCFLAGS="$OBJCFLAGS $C_FLAGS" OBJCXXFLAGS="$OBJCXXFLAGS $C_FLAGS" LDFLAGS="$LDFLAGS -stdlib=libc++" JOBS=${JOBS:="-j2"} set -e die() { echo ERROR: $* exit 1 } download_lib() { local url=$1 local filename=$2 if [ ! -e $filename ]; then echo "Downloading $filename" curl -fLo ${filename} ${url}${filename} || die "Download of $url$filename failed" fi } already_built() { echo -e "Skipping - already built (use --force-rebuild to override)" } # 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) # -------------------------------------------------------------- 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)" != "$LIB_VERSION" ]] then rm -f .already-built download_lib $LIB_URL $LIB_ARCHIVE rm -rf $LIB_DIRECTORY include lib share tar -xf $LIB_ARCHIVE pushd $LIB_DIRECTORY # patch zlib's configure script to use our CFLAGS and LDFLAGS (patch -Np0 -i ../../patches/zlib_flags.diff \ && CFLAGS="$CFLAGS" LDFLAGS="$LDFLAGS" \ ./configure --prefix="$ZLIB_DIR" \ --static \ && make ${JOBS} && make install) || die "zlib build failed" popd echo "$LIB_VERSION" > .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)" != "$LIB_VERSION" ]] 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 (./configure CFLAGS="$CFLAGS" \ LDFLAGS="$LDFLAGS" \ --prefix="$INSTALL_DIR" \ --enable-ipv6 \ --with-darwinssl \ --without-gssapi \ --without-libmetalink \ --without-libpsl \ --without-librtmp \ --without-libssh2 \ --without-nghttp2 \ --without-nss \ --without-polarssl \ --without-ssl \ --without-gnutls \ --without-brotli \ --without-cyassl \ --without-winssl \ --without-mbedtls \ --without-wolfssl \ --without-spnego \ --disable-ares \ --disable-ldap \ --disable-ldaps \ --without-libidn2 \ --with-zlib="${ZLIB_DIR}" \ --enable-shared=no \ && make ${JOBS} && make install) || die "libcurl build failed" popd echo "$LIB_VERSION" > .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/" mkdir -p iconv pushd iconv > /dev/null ICONV_DIR="$(pwd)" if [[ "$force_rebuild" = "true" ]] || [[ ! -e .already-built ]] || [[ "$(<.already-built)" != "$LIB_VERSION" ]] 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 (./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" popd echo "$LIB_VERSION" > .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)" != "$LIB_VERSION" ]] 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 (./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" popd echo "$LIB_VERSION" > .already-built else already_built fi popd > /dev/null # -------------------------------------------------------------- echo -e "Building SDL2..." LIB_VERSION="${SDL2_VERSION}" LIB_ARCHIVE="$LIB_VERSION.tar.gz" LIB_DIRECTORY=$LIB_VERSION LIB_URL="https://libsdl.org/release/" mkdir -p sdl2 pushd sdl2 > /dev/null if [[ "$force_rebuild" = "true" ]] || [[ ! -e .already-built ]] || [[ "$(<.already-built)" != "$LIB_VERSION" ]] 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 (./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-video-cocoa \ --enable-shared=no \ && make $JOBS && make install) || die "SDL2 build failed" popd echo "$LIB_VERSION" > .already-built else already_built fi popd > /dev/null # -------------------------------------------------------------- echo -e "Building Boost..." LIB_VERSION="${BOOST_VERSION}" LIB_ARCHIVE="$LIB_VERSION.tar.bz2" LIB_DIRECTORY="$LIB_VERSION" LIB_URL="https://dl.bintray.com/boostorg/release/1.74.0/source/" mkdir -p boost pushd boost > /dev/null if [[ "$force_rebuild" = "true" ]] || [[ ! -e .already-built ]] || [[ "$(<.already-built)" != "$LIB_VERSION" ]] then INSTALL_DIR="$(pwd)" rm -f .already-built download_lib $LIB_URL $LIB_ARCHIVE rm -rf $LIB_DIRECTORY include lib tar -xf $LIB_ARCHIVE pushd $LIB_DIRECTORY # Can't use macosx-version, see above comment. (./bootstrap.sh --with-libraries=filesystem,system \ --prefix=$INSTALL_DIR \ && ./b2 cflags="$CFLAGS" \ toolset=clang \ cxxflags="$CXXFLAGS" \ linkflags="$LDFLAGS" ${JOBS} \ -d2 \ --layout=system \ --debug-configuration \ link=static \ threading=multi \ variant=release install \ ) || die "Boost build failed" popd echo "$LIB_VERSION" > .already-built else already_built fi popd > /dev/null # -------------------------------------------------------------- # TODO: This build takes ages, anything we can exclude? echo -e "Building wxWidgets..." LIB_VERSION="${WXWIDGETS_VERSION}" LIB_ARCHIVE="$LIB_VERSION.tar.bz2" LIB_DIRECTORY="$LIB_VERSION" LIB_URL="http://github.com/wxWidgets/wxWidgets/releases/download/v3.0.3.1/" mkdir -p wxwidgets pushd wxwidgets > /dev/null if [[ "$force_rebuild" = "true" ]] || [[ ! -e .already-built ]] || [[ "$(<.already-built)" != "$LIB_VERSION" ]] 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 mkdir -p build-release pushd build-release CONF_OPTS="--prefix=$INSTALL_DIR --disable-shared --enable-unicode --with-cocoa --with-opengl --with-libiconv-prefix=${ICONV_DIR} --with-expat=builtin --with-libpng=builtin --without-libtiff --without-sdl --without-x --disable-webview --disable-webkit --disable-webviewwebkit --disable-webviewie --without-libjpeg" # 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 (../configure CFLAGS="$CFLAGS" \ CXXFLAGS="$CXXFLAGS" \ CPPFLAGS="-stdlib=libc++ -D__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES=1" \ LDFLAGS="$LDFLAGS" $CONF_OPTS \ && make ${JOBS} && make install) || die "wxWidgets build failed" popd popd echo "$LIB_VERSION" > .already-built else already_built fi popd > /dev/null # -------------------------------------------------------------- echo -e "Building libpng..." LIB_VERSION="${PNG_VERSION}" LIB_ARCHIVE="$LIB_VERSION.tar.gz" LIB_DIRECTORY="$LIB_VERSION" LIB_URL="http://download.sourceforge.net/libpng/" mkdir -p libpng pushd libpng > /dev/null if [[ "$force_rebuild" = "true" ]] || [[ ! -e .already-built ]] || [[ "$(<.already-built)" != "$LIB_VERSION" ]] 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 # libpng has no flags for zlib but the 10.12 version is too old, so link our own. (./configure CFLAGS="$CFLAGS" CPPFLAGS=" -I $ZLIB_DIR/include "\ LDFLAGS="$LDFLAGS -L$ZLIB_DIR/lib" \ --prefix=$INSTALL_DIR \ --enable-shared=no \ && make ${JOBS} && make install) || die "libpng build failed" popd echo "$LIB_VERSION" > .already-built else already_built fi popd > /dev/null # -------------------------------------------------------------- echo -e "Building libogg..." 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 pushd libogg > /dev/null OGG_DIR="$(pwd)" if [[ "$force_rebuild" = "true" ]] || [[ ! -e .already-built ]] || [[ "$(<.already-built)" != "$LIB_VERSION" ]] then rm -f .already-built download_lib $LIB_URL $LIB_ARCHIVE rm -rf $LIB_DIRECTORY include lib share tar -xf $LIB_ARCHIVE pushd $LIB_DIRECTORY (./configure CFLAGS="$CFLAGS" \ LDFLAGS="$LDFLAGS" \ --prefix=$OGG_DIR \ --enable-shared=no \ && make ${JOBS} && make install) || die "libogg build failed" popd echo "$LIB_VERSION" > .already-built else already_built fi popd > /dev/null # -------------------------------------------------------------- echo -e "Building libvorbis..." LIB_VERSION="${VORBIS_VERSION}" LIB_ARCHIVE="$LIB_VERSION.tar.gz" LIB_DIRECTORY="$LIB_VERSION" LIB_URL="http://downloads.xiph.org/releases/vorbis/" pushd vorbis > /dev/null if [[ "$force_rebuild" = "true" ]] || [[ ! -e .already-built ]] || [[ "$(<.already-built)" != "$LIB_VERSION" ]] then INSTALL_DIR="$(pwd)" rm -f .already-built download_lib $LIB_URL $LIB_ARCHIVE rm -rf $LIB_DIRECTORY include lib share tar -xf $LIB_ARCHIVE pushd $LIB_DIRECTORY (./configure CFLAGS="$CFLAGS" \ LDFLAGS="$LDFLAGS" \ --prefix="$INSTALL_DIR" \ --enable-shared=no \ --with-ogg="$OGG_DIR" \ && make ${JOBS} && make install) || die "libvorbis build failed" popd echo "$LIB_VERSION" > .already-built else already_built fi popd > /dev/null # -------------------------------------------------------------- echo -e "Building GMP..." LIB_VERSION="${GMP_VERSION}" LIB_ARCHIVE="$LIB_VERSION.tar.bz2" LIB_DIRECTORY="$LIB_VERSION" LIB_URL="https://gmplib.org/download/gmp/" mkdir -p gmp pushd gmp > /dev/null GMP_DIR="$(pwd)" if [[ "$force_rebuild" = "true" ]] || [[ ! -e .already-built ]] || [[ "$(<.already-built)" != "$LIB_VERSION" ]] then INSTALL_DIR="$(pwd)" rm -f .already-built download_lib $LIB_URL $LIB_ARCHIVE rm -rf $LIB_DIRECTORY bin include lib tar -xf $LIB_ARCHIVE pushd $LIB_DIRECTORY # NOTE: enable-fat in this case allows building and running on different CPUS. # Otherwise CPU-specific instructions will be used with no fallback for older CPUs. (./configure CFLAGS="$CFLAGS" \ CXXFLAGS="$CXXFLAGS" \ LDFLAGS="$LDFLAGS" \ --prefix="$INSTALL_DIR" \ --enable-fat \ --disable-shared \ --with-pic \ && make ${JOBS} && make install) || die "GMP build failed" popd echo "$LIB_VERSION" > .already-built else already_built fi popd > /dev/null # -------------------------------------------------------------- echo -e "Building Nettle..." LIB_VERSION="${NETTLE_VERSION}" LIB_ARCHIVE="$LIB_VERSION.tar.gz" LIB_DIRECTORY="$LIB_VERSION" LIB_URL="https://ftp.gnu.org/gnu/nettle/" mkdir -p nettle pushd nettle > /dev/null NETTLE_DIR="$(pwd)" if [[ "$force_rebuild" = "true" ]] || [[ ! -e .already-built ]] || [[ "$(<.already-built)" != "$LIB_VERSION" ]] then INSTALL_DIR="$(pwd)" rm -f .already-built download_lib $LIB_URL $LIB_ARCHIVE rm -rf $LIB_DIRECTORY bin include lib tar -xf $LIB_ARCHIVE pushd $LIB_DIRECTORY # NOTE: enable-fat in this case allows building and running on different CPUS. # Otherwise CPU-specific instructions will be used with no fallback for older CPUs. (./configure CFLAGS="$CFLAGS" \ CXXFLAGS="$CXXFLAGS" \ LDFLAGS="$LDFLAGS" \ --with-include-path="${GMP_DIR}/include" \ --with-lib-path="${GMP_DIR}/lib" \ --prefix="$INSTALL_DIR" \ --enable-fat \ --disable-shared \ --disable-documentation \ --disable-openssl \ --disable-assembler \ && make ${JOBS} && make install) || die "Nettle build failed" popd echo "$LIB_VERSION" > .already-built else already_built fi popd > /dev/null # -------------------------------------------------------------- echo -e "Building GnuTLS..." LIB_VERSION="${GNUTLS_VERSION}" LIB_ARCHIVE="$LIB_VERSION.tar.xz" LIB_DIRECTORY="$LIB_VERSION" LIB_URL="https://www.gnupg.org/ftp/gcrypt/gnutls/v3.6/" mkdir -p gnutls pushd gnutls > /dev/null GNUTLS_DIR="$(pwd)" if [[ "$force_rebuild" = "true" ]] || [[ ! -e .already-built ]] || [[ "$(<.already-built)" != "$LIB_VERSION" ]] then INSTALL_DIR="$(pwd)" rm -f .already-built download_lib $LIB_URL $LIB_ARCHIVE rm -rf $LIB_DIRECTORY bin include lib tar -xf $LIB_ARCHIVE pushd $LIB_DIRECTORY # Patch GNUTLS for a linking issue with isdigit # Patch by Ross Nicholson: https://gitlab.com/gnutls/gnutls/-/issues/1033#note_379529145 (patch -Np1 -i ../../patches/03-undo-libtasn1-cisdigit.patch \ && ./configure CFLAGS="$CFLAGS" \ CXXFLAGS="$CXXFLAGS" \ LDFLAGS="$LDFLAGS" \ LIBS="-L${GMP_DIR}/lib -lgmp" \ NETTLE_CFLAGS="-I${NETTLE_DIR}/include" \ NETTLE_LIBS="-L${NETTLE_DIR}/lib -lnettle" \ HOGWEED_CFLAGS="-I${NETTLE_DIR}/include" \ HOGWEED_LIBS="-L${NETTLE_DIR}/lib -lhogweed" \ GMP_CFLAGS="-I${GMP_DIR}/include" \ GMP_LIBS="-L${GMP_DIR}/lib -lgmp" \ --prefix="$INSTALL_DIR" \ --enable-shared=no \ --without-idn \ --with-included-unistring \ --with-included-libtasn1 \ --without-p11-kit \ --disable-tests \ --disable-guile \ --disable-doc \ --disable-tools \ --disable-nls \ && make ${JOBS} LDFLAGS= install) || die "GnuTLS build failed" popd echo "$LIB_VERSION" > .already-built else already_built fi popd > /dev/null # -------------------------------------------------------------- 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)" != "$LIB_VERSION" ]] then INSTALL_DIR="$(pwd)" rm -f .already-built download_lib $LIB_URL $LIB_ARCHIVE rm -rf $LIB_DIRECTORY bin include lib tar -xf $LIB_ARCHIVE pushd $LIB_DIRECTORY # TODO: pulls in libresolv dependency from /usr/lib (./configure CFLAGS="$CFLAGS" \ CXXFLAGS="$CXXFLAGS" \ LDFLAGS="$LDFLAGS" \ --prefix="$INSTALL_DIR" \ GNUTLS_CFLAGS="-I${GNUTLS_DIR}/include" \ GNUTLS_LIBS="-L${GNUTLS_DIR}/lib -lgnutls" \ --enable-shared=no \ --with-zlib="${ZLIB_DIR}" \ --without-libidn \ --with-gnutls="yes" \ --without-openssl \ --without-tests \ --without-examples \ --disable-getaddrinfo \ && make ${JOBS} && make install) || die "gloox build failed" popd echo "$LIB_VERSION" > .already-built else already_built fi popd > /dev/null # -------------------------------------------------------------- echo -e "Building ICU..." LIB_VERSION="${ICU_VERSION}" LIB_ARCHIVE="$LIB_VERSION-src.tgz" LIB_DIRECTORY="icu" LIB_URL="https://github.com/unicode-org/icu/releases/download/release-67-1/" mkdir -p $LIB_DIRECTORY pushd icu > /dev/null if [[ "$force_rebuild" = "true" ]] || [[ ! -e .already-built ]] || [[ "$(<.already-built)" != "$LIB_VERSION" ]] 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 (CFLAGS="$CFLAGS" CXXFLAGS="$CXXFLAGS" LDFLAGS="$LDFLAGS" \ ../runConfigureICU MacOSX \ --prefix=$INSTALL_DIR \ --disable-shared \ --enable-static \ --disable-samples \ --enable-extras \ --enable-icuio \ --enable-tools \ && make ${JOBS} && make install) || die "ICU build failed" popd popd echo "$LIB_VERSION" > .already-built else already_built fi popd > /dev/null # -------------------------------------------------------------- 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)" != "$LIB_VERSION" ]] 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 echo "$LIB_VERSION" > .already-built else already_built fi popd > /dev/null # -------------------------------------------------------------- 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)" != "$LIB_VERSION" ]] 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 (make clean \ && CFLAGS=$CFLAGS LDFLAGS=$LDFLAGS make ${JOBS} \ && INSTALLPREFIX="$INSTALL_DIR" make install \ ) || die "MiniUPnPc build failed" popd # TODO: how can we not build the dylibs? rm -f lib/*.dylib echo "$LIB_VERSION" > .already-built else already_built fi popd > /dev/null # -------------------------------------------------------------- echo -e "Building libsodium..." LIB_VERSION="${SODIUM_VERSION}" LIB_ARCHIVE="$SODIUM_VERSION.tar.gz" LIB_DIRECTORY="$LIB_VERSION" LIB_URL="https://download.libsodium.org/libsodium/releases/" mkdir -p libsodium pushd libsodium > /dev/null if [[ "$force_rebuild" = "true" ]] || [[ ! -e .already-built ]] || [[ "$(<.already-built)" != "$LIB_VERSION" ]] then INSTALL_DIR="$(pwd)" rm -f .already-built download_lib $LIB_URL $LIB_ARCHIVE rm -rf $LIB_DIRECTORY include lib tar -xf $LIB_ARCHIVE pushd $LIB_DIRECTORY (./configure CFLAGS="$CFLAGS" \ LDFLAGS="$LDFLAGS" \ --prefix=${INSTALL_DIR} \ --enable-shared=no \ && make clean \ && CFLAGS=$CFLAGS LDFLAGS=$LDFLAGS make ${JOBS} \ && make check \ && INSTALLPREFIX="$INSTALL_DIR" make install \ ) || die "libsodium build failed" popd echo "$LIB_VERSION" > .already-built else already_built fi popd > /dev/null # -------------------------------------------------------------- echo -e "Building fmt..." LIB_DIRECTORY="fmt-$FMT_VERSION" LIB_ARCHIVE="$FMT_VERSION.tar.gz" LIB_URL="https://github.com/fmtlib/fmt/archive/" mkdir -p fmt pushd fmt > /dev/null if [[ "$force_rebuild" = "true" ]] || [[ ! -e .already-built ]] || [[ "$(<.already-built)" != "$FMT_VERSION" ]] then rm -f .already-built download_lib $LIB_URL $LIB_ARCHIVE rm -rf $LIB_DIRECTORY include lib tar -xf $LIB_ARCHIVE pushd $LIB_DIRECTORY # It appears that older versions of Clang require constexpr statements to have a user-set constructor. patch -Np1 -i ../../patches/fmt_constexpr.diff mkdir -p build pushd build (cmake .. \ -DFMT_TEST=False \ -DFMT_DOC=False \ && make fmt ${JOBS}) || die "fmt build failed" popd mkdir -p ../lib cp build/libfmt.a ../lib/ cp -r include ../include popd echo "$FMT_VERSION" > .already-built else already_built fi popd > /dev/null # -------------------------------------------------------------------- # The following libraries are shared on different OSes and may # be customized, so we build and install them from bundled sources # -------------------------------------------------------------------- # SpiderMonkey - bundled, no download pushd ../source/spidermonkey/ > /dev/null if [[ "$force_rebuild" = "true" ]] then rm -f .already-built fi # Use the regular build script for SM. -JOBS="$JOBS" ZLIB_DIR="$ZLIB_DIR" ./build.sh +JOBS="$JOBS" ZLIB_DIR="$ZLIB_DIR" ./build.sh || die "Error building spidermonkey" popd > /dev/null # -------------------------------------------------------------- # NVTT - bundled, no download echo -e "Building NVTT..." LIB_VERSION="${NVTT_VERSION}" pushd ../source/nvtt > /dev/null if [[ "$force_rebuild" = "true" ]] || [[ ! -e .already-built ]] || [[ "$(<.already-built)" != "$LIB_VERSION" ]] then rm -f .already-built rm -f lib/*.a 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 # Disable png support (avoids some conflicts with MacPorts) (cmake .. \ -DCMAKE_LINK_FLAGS="$LDFLAGS" \ -DCMAKE_C_FLAGS="$CFLAGS" \ -DCMAKE_CXX_FLAGS="$CXXFLAGS" \ -DCMAKE_BUILD_TYPE=Release \ -DBINDIR=bin \ -DLIBDIR=lib \ -DPNG=0 \ -G "Unix Makefiles" \ && make clean && make nvtt ${JOBS}) || die "NVTT build failed" popd mkdir -p ../lib cp build/src/bc*/libbc*.a ../lib/ cp build/src/nv*/libnv*.a ../lib/ cp build/src/nvtt/squish/libsquish.a ../lib/ popd echo "$LIB_VERSION" > .already-built else already_built fi popd > /dev/null # -------------------------------------------------------------- # FCollada - bundled, no download echo -e "Building FCollada..." LIB_VERSION="${FCOLLADA_VERSION}" pushd ../source/fcollada > /dev/null if [[ "$force_rebuild" = "true" ]] || [[ ! -e .already-built ]] || [[ "$(<.already-built)" != "$LIB_VERSION" ]] then rm -f .already-built rm -f lib/*.a 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 (make clean && CXXFLAGS=$CXXFLAGS make ${JOBS}) || die "FCollada build failed" # Undo Makefile change mv Makefile.bak Makefile popd echo "$LIB_VERSION" > .already-built else already_built fi popd > /dev/null Index: ps/trunk/source/tools/dist/build-osx-bundle.sh =================================================================== --- ps/trunk/source/tools/dist/build-osx-bundle.sh (revision 24273) +++ ps/trunk/source/tools/dist/build-osx-bundle.sh (revision 24274) @@ -1,207 +1,209 @@ #!/bin/sh # # This script will build an OS X app bundle for 0 A.D. # # App bundles are intended to be self-contained and portable. # An SDK is required, usually included with Xcode. The SDK ensures # that only those system libraries are used which are available on # the chosen target and compatible systems. # # TODO: is there anything to do for ARM support? export ARCH=${ARCH:="x86_64"} # Set mimimum required OS X version, SDK location and tools # Old SDKs can be found at https://github.com/phracker/MacOSX-SDKs export MIN_OSX_VERSION=${MIN_OSX_VERSION:="10.12"} export SYSROOT=${SYSROOT:="/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX${MIN_OSX_VERSION}.sdk"} export CC=${CC:="clang"} CXX=${CXX:="clang++"} # 0 A.D. release version BUNDLE_VERSION=${BUNDLE_VERSION:="0.0.24dev"} BUNDLE_FILENAME="0ad-${BUNDLE_VERSION}-alpha-osx64.dmg" # Unique identifier string for this bundle (reverse-DNS style) BUNDLE_IDENTIFIER=${BUNDLE_IDENTIFIER:="com.wildfiregames.0ad"} # Minimum version of OS X on which the bundle will run BUNDLE_MIN_OSX_VERSION="${MIN_OSX_VERSION}.0" die() { echo ERROR: $* exit 1 } # Check that we're actually on OS X if [ "`uname -s`" != "Darwin" ]; then die "This script is intended for OS X only" fi # Check SDK exists if [ ! -d "$SYSROOT" ]; then die "$SYSROOT does not exist! You probably need to install Xcode" fi # We assume this script resides in source/tools/dist/ DMGBUILD_CONFIG="$(pwd)/dmgbuild-settings.py" cd "$(dirname $0)/../../../build/workspaces/" JOBS=${JOBS:="-j5"} build_release=false # Parse command-line options: for i in "$@" do case $i in -j* ) JOBS=$i ;; --release ) build_release=true ;; esac done # For release, export an SVN copy if [ "$build_release" = "true" ]; then echo "\nExporting SVN and preparing release\n" SVN_REV=`svnversion -n ../..` rm -rf "0ad-export" svn export ../.. "0ad-export" || die "Error exporting SVN working directory" cd "0ad-export" rm -f binaries/data/config/dev.cfg # Only include translations for a subset of languages . source/tools/dist/remove-incomplete-translations.sh $build_path/binaries/data || die "Error excluding translations" echo L\"${SVN_REV}-release\" > build/svn_revision/svn_revision.txt cd build/workspaces fi BUNDLE_APP="0ad.app" BUNDLE_DMG_NAME="0 A.D." BUNDLE_OUTPUT=${BUNDLE_OUTPUT:="$(pwd)/${BUNDLE_APP}"} BUNDLE_CONTENTS=$BUNDLE_OUTPUT/Contents BUNDLE_BIN=$BUNDLE_CONTENTS/MacOS BUNDLE_RESOURCES=$BUNDLE_CONTENTS/Resources BUNDLE_FRAMEWORKS=$BUNDLE_CONTENTS/Frameworks BUNDLE_PLUGINS=$BUNDLE_CONTENTS/PlugIns BUNDLE_SHAREDSUPPORT=$BUNDLE_CONTENTS/SharedSupport # TODO: Do we really want to regenerate everything? (consider if one task fails) +./clean-workspaces.sh + # Build libraries against SDK echo "\nBuilding libraries\n" pushd ../../libraries/osx > /dev/null ./build-osx-libs.sh $JOBS --force-rebuild || die "Libraries build script failed" popd > /dev/null -# Clean and update workspaces +# Update workspaces echo "\nGenerating workspaces\n" # Pass OS X options through to Premake -(./clean-workspaces.sh && SYSROOT="$SYSROOT" MIN_OSX_VERSION="$MIN_OSX_VERSION" ./update-workspaces.sh --macosx-bundle="$BUNDLE_IDENTIFIER" --sysroot="$SYSROOT" --macosx-version-min="$MIN_OSX_VERSION") || die "update-workspaces.sh failed!" +(SYSROOT="$SYSROOT" MIN_OSX_VERSION="$MIN_OSX_VERSION" ./update-workspaces.sh --macosx-bundle="$BUNDLE_IDENTIFIER" --sysroot="$SYSROOT" --macosx-version-min="$MIN_OSX_VERSION") || die "update-workspaces.sh failed!" pushd gcc > /dev/null echo "\nBuilding game\n" (make clean && CC="$CC -arch $ARCH" CXX="$CXX -arch $ARCH" make ${JOBS}) || die "Game build failed!" popd > /dev/null # Run test to confirm all is OK pushd ../../binaries/system > /dev/null echo "\nRunning tests\n" ./test || die "Post-build testing failed!" popd > /dev/null # Create bundle structure echo "\nCreating bundle directories\n" rm -rf "${BUNDLE_OUTPUT}" mkdir -p "${BUNDLE_BIN}" mkdir -p "${BUNDLE_FRAMEWORKS}" mkdir -p "${BUNDLE_PLUGINS}" mkdir -p "${BUNDLE_RESOURCES}" mkdir -p "${BUNDLE_SHAREDSUPPORT}" # Build archive(s) - don't archive the _test.* mods pushd ../../binaries/data/mods > /dev/null archives="" for modname in [a-zA-Z0-9]* do archives="${archives} ${modname}" done popd > /dev/null pushd ../../binaries/system > /dev/null for modname in $archives do echo "\nBuilding archive for '${modname}'\n" ARCHIVEBUILD_INPUT="$(pwd)/../data/mods/${modname}" ARCHIVEBUILD_OUTPUT="${BUNDLE_RESOURCES}/data/mods/${modname}" # For some reason the output directory has to exist? mkdir -p "${ARCHIVEBUILD_OUTPUT}" (./pyrogenesis -archivebuild="${ARCHIVEBUILD_INPUT}" -archivebuild-output="${ARCHIVEBUILD_OUTPUT}/${modname}.zip") || die "Archive build for '${modname}' failed!" done # Copy binaries echo "\nCopying binaries\n" # Only pyrogenesis for now, until we find a way to load # multiple binaries from one app bundle # TODO: Would be nicer if we could set this path in premake cp pyrogenesis "${BUNDLE_BIN}" # Copy libs echo "\nCopying libs\n" # TODO: Would be nicer if we could set this path in premake cp -v libAtlasUI.dylib "${BUNDLE_FRAMEWORKS}" cp -v libCollada.dylib "${BUNDLE_FRAMEWORKS}" popd > /dev/null # Copy data echo "\nCopying non-archived game data\n" pushd ../../binaries/data > /dev/null if [ "$build_release" = "false" ]; then mv config/dev.cfg config/dev.bak fi cp -R -v config "${BUNDLE_RESOURCES}/data/" cp -R -v l10n "${BUNDLE_RESOURCES}/data/" cp -R -v tools "${BUNDLE_RESOURCES}/data/" if [ "$build_release" = "false" ]; then mv config/dev.bak config/dev.cfg fi popd > /dev/null cp -v ../resources/0ad.icns "${BUNDLE_RESOURCES}" cp -v ../resources/InfoPlist.strings "${BUNDLE_RESOURCES}" # Copy license/readmes # TODO: Also want copies in the DMG - decide on layout echo "\nCopying readmes\n" cp -v ../../*.txt "${BUNDLE_RESOURCES}" cp -v ../../libraries/LICENSE.txt "${BUNDLE_RESOURCES}/LIB_LICENSE.txt" # Create Info.plist echo "\nCreating Info.plist\n" alias PlistBuddy=/usr/libexec/PlistBuddy INFO_PLIST="${BUNDLE_CONTENTS}/Info.plist" PlistBuddy -c "Add :CFBundleName string 0 A.D." "${INFO_PLIST}" PlistBuddy -c "Add :CFBundleIdentifier string ${BUNDLE_IDENTIFIER}" "${INFO_PLIST}" PlistBuddy -c "Add :CFBundleVersion string ${BUNDLE_VERSION}" "${INFO_PLIST}" PlistBuddy -c "Add :CFBundlePackageType string APPL" "${INFO_PLIST}" PlistBuddy -c "Add :CFBundleSignature string none" "${INFO_PLIST}" PlistBuddy -c "Add :CFBundleExecutable string pyrogenesis" "${INFO_PLIST}" PlistBuddy -c "Add :CFBundleShortVersionString string ${BUNDLE_VERSION}" "${INFO_PLIST}" PlistBuddy -c "Add :CFBundleDevelopmentRegion string English" "${INFO_PLIST}" PlistBuddy -c "Add :CFBundleInfoDictionaryVersion string 6.0" "${INFO_PLIST}" PlistBuddy -c "Add :CFBundleIconFile string 0ad" "${INFO_PLIST}" PlistBuddy -c "Add :LSHasLocalizedDisplayName bool true" "${INFO_PLIST}" PlistBuddy -c "Add :LSMinimumSystemVersion string ${BUNDLE_MIN_OSX_VERSION}" "${INFO_PLIST}" PlistBuddy -c "Add :NSHumanReadableCopyright string Copyright © $(date +%Y) Wildfire Games" "${INFO_PLIST}" # Package the app into a dmg dmgbuild \ -s "${DMGBUILD_CONFIG}" \ -D app="${BUNDLE_OUTPUT}" \ -D background="../../build/resources/dmgbackground.png" \ "${BUNDLE_DMG_NAME}" "${BUNDLE_FILENAME}" echo "\nBundle complete! Located in ${BUNDLE_OUTPUT}, compressed as ${BUNDLE_FILENAME}."