Index: ps/trunk/build/premake/extern_libs5.lua =================================================================== --- ps/trunk/build/premake/extern_libs5.lua (revision 21939) +++ ps/trunk/build/premake/extern_libs5.lua (revision 21940) @@ -1,747 +1,754 @@ -- this file provides project_add_extern_libs, which takes care of the -- dirty details of adding the libraries' include and lib paths. -- -- TYPICAL TASK: add new library. Instructions: -- 1) add a new extern_lib_defs entry -- 2) add library name to extern_libs tables in premake.lua for all 'projects' that want to use it -- directory in which OS-specific library subdirectories reside. if os.istarget("macosx") then libraries_dir = rootdir.."/libraries/osx/" elseif os.istarget("windows") then libraries_dir = rootdir.."/libraries/win32/" else -- No Unix-specific libs yet (use source directory instead!) end -- directory for shared, bundled libraries libraries_source_dir = rootdir.."/libraries/source/" third_party_source_dir = rootdir.."/source/third_party/" local function add_default_lib_paths(extern_lib) libdirs { libraries_dir .. extern_lib .. "/lib" } end local function add_source_lib_paths(extern_lib) libdirs { libraries_source_dir .. extern_lib .. "/lib" } end local function add_default_include_paths(extern_lib) sysincludedirs { libraries_dir .. extern_lib .. "/include" } end local function add_source_include_paths(extern_lib) sysincludedirs { libraries_source_dir .. extern_lib .. "/include" } end local function add_third_party_include_paths(extern_lib) sysincludedirs { third_party_source_dir .. extern_lib .. "/include" } end pkgconfig = require "pkgconfig" local function add_delayload(name, suffix, def) if def["no_delayload"] then return end -- currently only supported by VC; nothing to do on other platforms. if not os.istarget("windows") then return end -- no extra debug version; use same library in all configs if suffix == "" then linkoptions { "/DELAYLOAD:"..name..".dll" } -- extra debug version available; use in debug config else local dbg_cmd = "/DELAYLOAD:" .. name .. suffix .. ".dll" local cmd = "/DELAYLOAD:" .. name .. ".dll" filter "Debug" linkoptions { dbg_cmd } filter "Release" linkoptions { cmd } filter { } end end local function add_default_links(def) -- careful: make sure to only use *_names when on the correct platform. local names = {} if os.istarget("windows") then if def.win_names then names = def.win_names end elseif _OPTIONS["android"] and def.android_names then names = def.android_names elseif os.istarget("linux") and def.linux_names then names = def.linux_names elseif os.istarget("macosx") and (def.osx_names or def.osx_frameworks) then if def.osx_names then names = def.osx_names end -- OS X "Frameworks" are added to the links as "name.framework" if def.osx_frameworks then for i,name in pairs(def.osx_frameworks) do links { name .. ".framework" } end end elseif os.istarget("bsd") and def.bsd_names then names = def.bsd_names elseif def.unix_names then names = def.unix_names end local suffix = "d" -- library is overriding default suffix (typically "" to indicate there is none) if def["dbg_suffix"] then suffix = def["dbg_suffix"] end -- non-Windows doesn't have the distinction of debug vs. release libraries -- (to be more specific, they do, but the two are binary compatible; -- usually only one type - debug or release - is installed at a time). if not os.istarget("windows") then suffix = "" end for i,name in pairs(names) do filter "Debug" links { name .. suffix } filter "Release" links { name } filter { } add_delayload(name, suffix, def) end end -- Library definitions -- In a perfect world, libraries would have a common installation template, -- i.e. location of include directory, naming convention for .lib, etc. -- this table provides a means of working around each library's differences. -- -- The basic approach is defining two functions per library: -- -- 1. compile_settings -- This function should set all settings requred during the compile-phase like -- includedirs, defines etc... -- -- 2. link_settings -- This function should set all settings required during the link-phase like -- libdirs, linkflag etc... -- -- The main reason for separating those settings is different linking behaviour -- on osx and xcode. For more details, read the comment in project_add_extern_libs. -- -- There are some helper functions for the most common tasks. You should use them -- if they can be used in your situation to make the definitions more consistent and -- use their default beviours as a guideline. -- -- -- add_default_lib_paths(extern_lib) -- Description: Add '//lib'to the libpaths -- Parameters: -- * extern_lib: to be used in the libpath. -- -- add_default_include_paths(extern_lib) -- Description: Add '//include' to the includepaths -- Parameters: -- * extern_lib: to be used in the libpath. -- -- add_default_links -- Description: Adds links to libraries and configures delayloading. -- If the *_names parameter for a plattform is missing, no linking will be done -- on that plattform. -- The default assumptions are: -- * debug import library and DLL are distinguished with a "d" suffix -- * the library should be marked for delay-loading. -- Parameters: -- * win_names: table of import library / DLL names (no extension) when -- running on Windows. -- * unix_names: as above; shared object names when running on non-Windows. -- * osx_names, osx_frameworks: for OS X specifically; if any of those is -- specified, unix_names is ignored. Using both is possible if needed. -- * osx_names: as above. -- * osx_frameworks: as above, for system libraries that need to be linked -- as "name.framework". -- * bsd_names: as above; for BSD specifically (overrides unix_names if both are -- specified) -- * linux_names: ditto for Linux (overrides unix_names if both given) -- * dbg_suffix: changes the debug suffix from the above default. -- can be "" to indicate the library doesn't have a debug build; -- in that case, the same library (without suffix) is used in -- all build configurations. -- * no_delayload: indicate the library is not to be delay-loaded. -- this is necessary for some libraries that do not support it, -- e.g. Xerces (which is so stupid as to export variables). extern_lib_defs = { boost = { compile_settings = function() if os.istarget("windows") then add_default_include_paths("boost") elseif os.istarget("macosx") then -- Suppress all the Boost warnings on OS X by including it as a system directory buildoptions { "-isystem../" .. libraries_dir .. "boost/include" } end -- TODO: This actually applies to most libraries we use on BSDs, make this a global setting. if os.istarget("bsd") then sysincludedirs { "/usr/local/include" } end end, link_settings = function() if os.istarget("windows") or os.istarget("macosx") then add_default_lib_paths("boost") end add_default_links({ -- The following are not strictly link dependencies on all systems, but -- are included for compatibility with different versions of Boost android_names = { "boost_filesystem-gcc-mt", "boost_system-gcc-mt" }, unix_names = { os.findlib("boost_filesystem-mt") and "boost_filesystem-mt" or "boost_filesystem", os.findlib("boost_system-mt") and "boost_system-mt" or "boost_system" }, osx_names = { "boost_filesystem-mt", "boost_system-mt" }, }) end, }, comsuppw = { link_settings = function() add_default_links({ win_names = { "comsuppw" }, dbg_suffix = "d", no_delayload = 1, }) end, }, cxxtest = { compile_settings = function() sysincludedirs { libraries_source_dir .. "cxxtest-4.4" } end, }, enet = { compile_settings = function() if os.istarget("windows") or os.istarget("macosx") then add_default_include_paths("enet") end end, link_settings = function() if os.istarget("windows") or os.istarget("macosx") then add_default_lib_paths("enet") end add_default_links({ win_names = { "enet" }, unix_names = { "enet" }, }) end, }, fcollada = { compile_settings = function() add_source_include_paths("fcollada") end, link_settings = function() add_source_lib_paths("fcollada") if os.istarget("windows") then filter "Debug" links { "FColladaD" } filter "Release" links { "FCollada" } filter { } else filter "Debug" links { "FColladaSD" } filter "Release" links { "FColladaSR" } filter { } end end, }, gloox = { compile_settings = function() if os.istarget("windows") then add_default_include_paths("gloox") elseif os.istarget("macosx") then -- Support GLOOX_CONFIG for overriding the default PATH-based gloox-config gloox_config_path = os.getenv("GLOOX_CONFIG") if not gloox_config_path then gloox_config_path = "gloox-config" end pkgconfig.add_includes(nil, gloox_config_path.." --cflags") end end, link_settings = function() if os.istarget("windows") then add_default_lib_paths("gloox") end if os.istarget("macosx") then gloox_config_path = os.getenv("GLOOX_CONFIG") if not gloox_config_path then gloox_config_path = "gloox-config" end pkgconfig.add_links(nil, gloox_config_path.." --libs") + + -- Manually add gnutls dependencies, those are not present in gloox's pkg-config + add_default_lib_paths("nettle") + add_default_lib_paths("gmp") + add_default_links({ + osx_names = { "nettle", "hogweed", "gmp" }, + }) else -- TODO: consider using pkg-config on non-Windows (for compile_settings too) add_default_links({ win_names = { "gloox-1.0" }, unix_names = { "gloox" }, no_delayload = 1, }) end end, }, iconv = { compile_settings = function() if os.istarget("windows") then add_default_include_paths("iconv") defines { "HAVE_ICONV_CONST" } defines { "ICONV_CONST=const" } defines { "LIBICONV_STATIC" } elseif os.istarget("macosx") then add_default_include_paths("iconv") defines { "LIBICONV_STATIC" } elseif os.getversion().description == "FreeBSD" then defines { "HAVE_ICONV_CONST" } defines { "ICONV_CONST=const" } end end, link_settings = function() if os.istarget("windows") or os.istarget("macosx") then add_default_lib_paths("iconv") end add_default_links({ win_names = { "libiconv" }, osx_names = { "iconv" }, dbg_suffix = "", no_delayload = 1, }) -- glibc (used on Linux and GNU/kFreeBSD) has iconv -- FreeBSD 10+ has iconv as a part of libc if os.istarget("bsd") and not (os.getversion().description == "FreeBSD" and os.getversion().majorversion >= 10 or os.getversion().description == "GNU/kFreeBSD") then add_default_links({ bsd_names = { "iconv" }, }) end end, }, icu = { compile_settings = function() if os.istarget("windows") then add_default_include_paths("icu") elseif os.istarget("macosx") then -- Support ICU_CONFIG for overriding the default PATH-based icu-config icu_config_path = os.getenv("ICU_CONFIG") if not icu_config_path then icu_config_path = "icu-config" end pkgconfig.add_includes(nil, icu_config_path.." --cppflags") end end, link_settings = function() if os.istarget("windows") then add_default_lib_paths("icu") end if os.istarget("macosx") then icu_config_path = os.getenv("ICU_CONFIG") if not icu_config_path then icu_config_path = "gloox-config" end pkgconfig.add_links(nil, icu_config_path.." --ldflags-searchpath --ldflags-libsonly --ldflags-system") else add_default_links({ win_names = { "icuuc", "icuin" }, unix_names = { "icui18n", "icuuc" }, dbg_suffix = "", no_delayload = 1, }) end end, }, libcurl = { compile_settings = function() if os.istarget("windows") or os.istarget("macosx") then add_default_include_paths("libcurl") end end, link_settings = function() if os.istarget("windows") or os.istarget("macosx") then add_default_lib_paths("libcurl") end add_default_links({ win_names = { "libcurl" }, unix_names = { "curl" }, osx_names = { "curl", "z" }, osx_frameworks = { "Security" } }) end, }, libpng = { compile_settings = function() if os.istarget("windows") or os.istarget("macosx") then add_default_include_paths("libpng") end if os.getversion().description == "OpenBSD" then sysincludedirs { "/usr/local/include/libpng" } end end, link_settings = function() if os.istarget("windows") or os.istarget("macosx") then add_default_lib_paths("libpng") end add_default_links({ win_names = { "libpng16" }, unix_names = { "png" }, -- Otherwise ld will sometimes pull in ancient 1.2 from the SDK, which breaks the build :/ -- TODO: Figure out why that happens osx_names = { "png16" }, }) end, }, libsodium = { compile_settings = function() if os.istarget("windows") or os.istarget("macosx") then add_default_include_paths("libsodium") end end, link_settings = function() if os.istarget("windows") or os.istarget("macosx") then add_default_lib_paths("libsodium") end add_default_links({ win_names = { "libsodium" }, unix_names = { "sodium" }, }) end, }, libxml2 = { compile_settings = function() if os.istarget("windows") then add_default_include_paths("libxml2") elseif os.istarget("macosx") then -- Support XML2_CONFIG for overriding for the default PATH-based xml2-config xml2_config_path = os.getenv("XML2_CONFIG") if not xml2_config_path then xml2_config_path = "xml2-config" end -- use xml2-config instead of pkg-config on OS X pkgconfig.add_includes(nil, xml2_config_path.." --cflags") -- libxml2 needs _REENTRANT or __MT__ for thread support; -- OS X doesn't get either set by default, so do it manually defines { "_REENTRANT" } else pkgconfig.add_includes("libxml-2.0") end end, link_settings = function() if os.istarget("windows") then add_default_lib_paths("libxml2") filter "Debug" links { "libxml2" } filter "Release" links { "libxml2" } filter { } elseif os.istarget("macosx") then xml2_config_path = os.getenv("XML2_CONFIG") if not xml2_config_path then xml2_config_path = "xml2-config" end pkgconfig.add_links(nil, xml2_config_path.." --libs") else pkgconfig.add_links("libxml-2.0") end end, }, miniupnpc = { compile_settings = function() if os.istarget("windows") or os.istarget("macosx") then add_default_include_paths("miniupnpc") end end, link_settings = function() if os.istarget("windows") or os.istarget("macosx") then add_default_lib_paths("miniupnpc") end add_default_links({ win_names = { "miniupnpc" }, unix_names = { "miniupnpc" }, }) end, }, nvtt = { compile_settings = function() if not _OPTIONS["with-system-nvtt"] then add_source_include_paths("nvtt") end defines { "NVTT_SHARED=1" } end, link_settings = function() if not _OPTIONS["with-system-nvtt"] then add_source_lib_paths("nvtt") end add_default_links({ win_names = { "nvtt" }, unix_names = { "nvcore", "nvmath", "nvimage", "nvtt" }, osx_names = { "nvcore", "nvmath", "nvimage", "nvtt", "squish" }, dbg_suffix = "", -- for performance we always use the release-mode version }) end, }, openal = { compile_settings = function() if os.istarget("windows") then add_default_include_paths("openal") end end, link_settings = function() if os.istarget("windows") then add_default_lib_paths("openal") end add_default_links({ win_names = { "openal32" }, unix_names = { "openal" }, osx_frameworks = { "OpenAL" }, dbg_suffix = "", no_delayload = 1, -- delayload seems to cause errors on startup }) end, }, opengl = { compile_settings = function() if os.istarget("windows") then add_default_include_paths("opengl") end end, link_settings = function() if os.istarget("windows") then add_default_lib_paths("opengl") end if _OPTIONS["gles"] then add_default_links({ unix_names = { "GLESv2" }, dbg_suffix = "", }) else add_default_links({ win_names = { "opengl32", "gdi32" }, unix_names = { "GL" }, osx_frameworks = { "OpenGL" }, dbg_suffix = "", no_delayload = 1, -- delayload seems to cause errors on startup }) end end, }, sdl = { compile_settings = function() if os.istarget("windows") then includedirs { libraries_dir .. "sdl2/include/SDL" } elseif not _OPTIONS["android"] then -- Support SDL2_CONFIG for overriding the default (pkg-config sdl2) -- i.e. on OSX where it gets set in update-workspaces.sh sdl_config_path = os.getenv("SDL2_CONFIG") if sdl_config_path then pkgconfig.add_includes(nil, sdl_config_path.." --cflags") else pkgconfig.add_includes("sdl2") end end end, link_settings = function() if os.istarget("windows") then add_default_lib_paths("sdl2") elseif not _OPTIONS["android"] then sdl_config_path = os.getenv("SDL2_CONFIG") if sdl_config_path then pkgconfig.add_links(nil, sdl_config_path.." --libs") else pkgconfig.add_links("sdl2") end end end, }, spidermonkey = { compile_settings = function() if _OPTIONS["with-system-mozjs38"] then if not _OPTIONS["android"] then pkgconfig.add_includes("mozjs-38") end else if os.istarget("windows") then include_dir = "include-win32" buildoptions { "/FI\"js/RequiredDefines.h\"" } else include_dir = "include-unix" end filter "Debug" sysincludedirs { libraries_source_dir.."spidermonkey/"..include_dir.."-debug" } defines { "DEBUG" } filter "Release" sysincludedirs { libraries_source_dir.."spidermonkey/"..include_dir.."-release" } filter { } end end, link_settings = function() if _OPTIONS["with-system-mozjs38"] then if _OPTIONS["android"] then links { "mozjs-38" } else pkgconfig.add_links("nspr") pkgconfig.add_links("mozjs-38") end else if os.istarget("macosx") then add_default_lib_paths("nspr") links { "nspr4", "plc4", "plds4" } end filter { "Debug", "action:vs2013" } links { "mozjs38-ps-debug-vc120" } filter { "Release", "action:vs2013" } links { "mozjs38-ps-release-vc120" } filter { "Debug", "action:vs2015" } links { "mozjs38-ps-debug-vc140" } filter { "Release", "action:vs2015" } links { "mozjs38-ps-release-vc140" } filter { "Debug", "action:not vs*" } links { "mozjs38-ps-debug" } filter { "Release", "action:not vs*" } links { "mozjs38-ps-release" } filter { } add_source_lib_paths("spidermonkey") end end, }, tinygettext = { compile_settings = function() add_third_party_include_paths("tinygettext") end, }, valgrind = { compile_settings = function() add_source_include_paths("valgrind") end, }, vorbis = { compile_settings = function() if os.istarget("windows") then add_default_include_paths("vorbis") elseif os.istarget("macosx") then add_default_include_paths("libogg") add_default_include_paths("vorbis") end end, link_settings = function() if os.istarget("windows") then add_default_lib_paths("vorbis") elseif os.istarget("macosx") then add_default_lib_paths("libogg") add_default_lib_paths("vorbis") end -- TODO: We need to force linking with these as currently -- they need to be loaded explicitly on execution if os.getversion().description == "OpenBSD" then add_default_links({ unix_names = { "ogg", "vorbis" }, }) end add_default_links({ win_names = { "vorbisfile" }, unix_names = { "vorbisfile" }, osx_names = { "vorbis", "vorbisenc", "vorbisfile", "ogg" }, dbg_suffix = "_d", }) end, }, wxwidgets = { compile_settings = function() if os.istarget("windows") then includedirs { libraries_dir.."wxwidgets/include/msvc" } add_default_include_paths("wxwidgets") else -- Support WX_CONFIG for overriding for the default PATH-based wx-config wx_config_path = os.getenv("WX_CONFIG") if not wx_config_path then wx_config_path = "wx-config" end pkgconfig.add_includes(nil, wx_config_path.." --unicode=yes --cxxflags") end end, link_settings = function() if os.istarget("windows") then libdirs { libraries_dir.."wxwidgets/lib/vc_lib" } else wx_config_path = os.getenv("WX_CONFIG") if not wx_config_path then wx_config_path = "wx-config" end pkgconfig.add_links(nil, wx_config_path.." --unicode=yes --libs std,gl") end end, }, x11 = { link_settings = function() add_default_links({ win_names = { }, unix_names = { "X11" }, }) end, }, xcursor = { link_settings = function() add_default_links({ unix_names = { "Xcursor" }, }) end, }, zlib = { compile_settings = function() if os.istarget("windows") or os.istarget("macosx") then add_default_include_paths("zlib") end end, link_settings = function() if os.istarget("windows") or os.istarget("macosx") then add_default_lib_paths("zlib") end add_default_links({ win_names = { "zlib1" }, unix_names = { "z" }, no_delayload = 1, }) end, }, } -- add a set of external libraries to the project; takes care of -- include / lib path and linking against the import library. -- extern_libs: table of library names [string] -- target_type: String defining the projects kind [string] function project_add_extern_libs(extern_libs, target_type) for i,extern_lib in pairs(extern_libs) do local def = extern_lib_defs[extern_lib] assert(def, "external library " .. extern_lib .. " not defined") if def.compile_settings then def.compile_settings() end -- Linking to external libraries will only be done in the main executable and not in the -- static libraries. Premake would silently skip linking into static libraries for some -- actions anyway (e.g. vs2010). -- On osx using xcode, if this linking would be defined in the static libraries, it would fail to -- link if only dylibs are available. If both *.a and *.dylib are available, it would link statically. -- I couldn't find any problems with that approach. if target_type ~= "StaticLib" and def.link_settings then def.link_settings() end end end Index: ps/trunk/libraries/osx/build-osx-libs.sh =================================================================== --- ps/trunk/libraries/osx/build-osx-libs.sh (revision 21939) +++ ps/trunk/libraries/osx/build-osx-libs.sh (revision 21940) @@ -1,783 +1,881 @@ #!/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.59.0" ICONV_VERSION="libiconv-1.15" XML2_VERSION="libxml2-2.9.8" SDL2_VERSION="SDL2-2.0.5" BOOST_VERSION="boost_1_64_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.34" OGG_VERSION="libogg-1.3.3" VORBIS_VERSION="libvorbis-1.3.6" -# gloox is necessary for multiplayer lobby +# gloox requires GnuTLS, GnuTLS requires Nettle and GMP +GMP_VERSION="gmp-6.1.2" +NETTLE_VERSION="nettle-3.4" +GNUTLS_VERSION="gnutls-3.5.19" GLOOX_VERSION="gloox-1.0.20" # NSPR is necessary for threadsafe Spidermonkey NSPR_VERSION="4.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-59_1" ENET_VERSION="enet-1.3.13" MINIUPNPC_VERSION="miniupnpc-2.0.20180222" SODIUM_VERSION="libsodium-1.0.16" # -------------------------------------------------------------- # Bundled with the game: # * SpiderMonkey 38 # * NVTT # * FCollada # -------------------------------------------------------------- # Provided by OS X: # * OpenAL # * OpenGL # -------------------------------------------------------------- # 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) ARCH=${ARCH:="x86_64"} # 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. export CC=${CC:="clang"} CXX=${CXX:="clang++"} export MIN_OSX_VERSION=${MIN_OSX_VERSION:="10.9"} # 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 # 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 C_FLAGS="$C_FLAGS -arch $ARCH -fvisibility=hidden" LDFLAGS="$LDFLAGS -arch $ARCH -stdlib=libc++" CFLAGS="$CFLAGS $C_FLAGS" CXXFLAGS="$CXXFLAGS $C_FLAGS -stdlib=libc++ -std=c++0x" OBJCFLAGS="$OBJCFLAGS $C_FLAGS" OBJCXXFLAGS="$OBJCXXFLAGS $C_FLAGS" 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 -L -o ${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 -ot $LIB_DIRECTORY ]] 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 -p0 -i ../../patches/zlib_flags.diff && CFLAGS="$CFLAGS" LDFLAGS="$LDFLAGS" ./configure --prefix="$ZLIB_DIR" --static && make ${JOBS} && make install) || die "zlib build failed" 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)" 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-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 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/" mkdir -p iconv pushd iconv > /dev/null ICONV_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 (./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 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)" 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 touch .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 -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 (./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" popd touch .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="http://download.sourceforge.net/boost/" mkdir -p boost pushd boost > /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 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=tagged --debug-configuration link=static threading=multi variant=release,debug install) || die "Boost build failed" popd touch .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 -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 mkdir -p build-release pushd build-release 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" # 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 touch .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 -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 (./configure CFLAGS="$CFLAGS" LDFLAGS="$LDFLAGS" --prefix=$INSTALL_DIR --enable-shared=no && make ${JOBS} && make install) || die "libpng build failed" popd touch .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 -ot $LIB_DIRECTORY ]] 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 touch .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 -ot $LIB_DIRECTORY ]] 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 touch .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 -ot $LIB_DIRECTORY ]] +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 + + (./configure CFLAGS="$CFLAGS" CXXFLAGS="$CXXFLAGS" LDFLAGS="$LDFLAGS" --prefix="$INSTALL_DIR" --disable-shared && make ${JOBS} && make install) || die "GMP build failed" + popd + touch .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 -ot $LIB_DIRECTORY ]] +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 + +(./configure CFLAGS="$CFLAGS -m64" CXXFLAGS="$CXXFLAGS -m64" LDFLAGS="$LDFLAGS -m64" --with-include-path="${GMP_DIR}/include" --with-lib-path="${GMP_DIR}/lib" --prefix="$INSTALL_DIR" --disable-shared --disable-documentation --disable-openssl --disable-assembler && make ${JOBS} && make install) || die "Nettle build failed" + popd + touch .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.5/" + +mkdir -p gnutls +pushd gnutls > /dev/null + +GNUTLS_DIR="$(pwd)" + +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 + tar -xf $LIB_ARCHIVE + pushd $LIB_DIRECTORY + +(./configure CFLAGS="$CFLAGS -m64" CXXFLAGS="$CXXFLAGS -m64" LDFLAGS="$LDFLAGS -m64" 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 && make ${JOBS} && make install) || die "GnuTLS build failed" + popd + touch .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 -ot $LIB_DIRECTORY ]] 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 - # TODO: if we ever use SSL/TLS, that will add yet another dependency... - (./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" + (./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 && make ${JOBS} && make install) || die "gloox build failed" popd touch .already-built else already_built fi popd > /dev/null # -------------------------------------------------------------- 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 (CFLAGS="$CFLAGS" CXXFLAGS="$CXXFLAGS" LDFLAGS="$LDFLAGS" ./configure --prefix="$NSPR_DIR" --enable-64bit && make ${JOBS} && make install) || die "NSPR build failed" popd # TODO: how can we not build the dylibs? rm -f lib/*.dylib touch .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="http://download.icu-project.org/files/icu4c/59.1/" 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 (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 touch .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 -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 # -------------------------------------------------------------- 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 (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 touch .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 -ot $LIB_DIRECTORY ]] 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 touch .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 # -------------------------------------------------------------------- echo -e "Building Spidermonkey..." LIB_VERSION="mozjs-38.2.1" LIB_ARCHIVE="$LIB_VERSION.rc0.tar.bz2" LIB_DIRECTORY="mozjs-38.0.0" pushd ../source/spidermonkey/ > /dev/null if [[ "$force_rebuild" = "true" ]] || [[ ! -e .already-built ]] || [[ .already-built -ot $LIB_DIRECTORY ]] || [[ .already-built -ot README.txt ]] then INSTALL_DIR="$(pwd)" INCLUDE_DIR_DEBUG=$INSTALL_DIR/include-unix-debug INCLUDE_DIR_RELEASE=$INSTALL_DIR/include-unix-release rm -f .already-built rm -f lib/*.a rm -rf $LIB_DIRECTORY $INCLUDE_DIR_DEBUG $INCLUDE_DIR_RELEASE tar -xf $LIB_ARCHIVE # Apply patches pushd $LIB_DIRECTORY . ../patch.sh popd pushd $LIB_DIRECTORY/js/src # We want separate debug/release versions of the library, so change their install name in the Makefile perl -i.bak -pe 's/(^STATIC_LIBRARY_NAME\s+=).*/$1'\''mozjs38-ps-debug'\''/' moz.build 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/\""' # 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 (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" # 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/ cp dist/lib/*.a $INSTALL_DIR/lib popd mv moz.build.bak moz.build perl -i.bak -pe 's/(^STATIC_LIBRARY_NAME\s+=).*/$1'\''mozjs38-ps-release'\''/' moz.build mkdir -p build-release pushd build-release (CC="clang" CXX="clang++" CXXFLAGS="${TLCXXFLAGS}" AR=ar CROSS_COMPILE=1 ../configure $CONF_OPTS --enable-optimize && make ${JOBS}) || die "Spidermonkey build failed" # 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/ cp dist/lib/*.a $INSTALL_DIR/lib popd mv moz.build.bak moz.build popd touch .already-built else already_built fi popd > /dev/null # -------------------------------------------------------------- # NVTT - no install echo -e "Building NVTT..." pushd ../source/nvtt > /dev/null if [[ "$force_rebuild" = "true" ]] || [[ ! -e .already-built ]] 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 optional libs that we don't need (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 -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" popd mkdir -p ../lib cp build/src/nv*/libnv*.a ../lib/ cp build/src/nvtt/squish/libsquish.a ../lib/ popd touch .already-built else already_built fi popd > /dev/null # -------------------------------------------------------------- # FCollada - no install echo -e "Building FCollada..." pushd ../source/fcollada > /dev/null if [[ "$force_rebuild" = "true" ]] || [[ ! -e .already-built ]] 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 touch .already-built else already_built fi popd > /dev/null