1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138
|
#!/bin/sh
die()
{
echo ERROR: $*
exit 1
}
# Check for whitespace in absolute path; this will cause problems in the
# SpiderMonkey build (https://bugzilla.mozilla.org/show_bug.cgi?id=459089)
# and maybe elsewhere, so we just forbid it
SCRIPT=$(readlink -f "$0")
SCRIPTPATH=`dirname "$SCRIPT"`
case "$SCRIPTPATH" in
*\ * )
die "Absolute path contains whitespace, which will break the build - move the game to a path without spaces" ;;
esac
JOBS=${JOBS:="-j2"}
# Some of our makefiles depend on GNU make, so we set some sane defaults if MAKE
# is not set.
case "`uname -s`" in
"FreeBSD" | "OpenBSD" )
MAKE=${MAKE:="gmake"}
;;
* )
MAKE=${MAKE:="make"}
;;
esac
# Parse command-line options:
premake_args=""
without_nvtt=false
with_system_nvtt=false
with_system_miniupnpc=false
with_system_mozjs24=false
enable_atlas=true
for i in "$@"
do
case $i in
--without-nvtt ) without_nvtt=true; premake_args="${premake_args} --without-nvtt" ;;
--with-system-nvtt ) with_system_nvtt=true; premake_args="${premake_args} --with-system-nvtt" ;;
--with-system-enet ) echo "NOTE: the --with-system-enet option is deprecated, system ENet is now required"; echo ;;
--with-system-miniupnpc ) with_system_miniupnpc=true; premake_args="${premake_args} --with-system-miniupnpc" ;;
--with-system-mozjs24 ) with_system_mozjs24=true; premake_args="${premake_args} --with-system-mozjs24" ;;
--enable-atlas ) enable_atlas=true ;;
--disable-atlas ) enable_atlas=false ;;
-j* ) JOBS=$i ;;
# Assume any other --options are for Premake
--* ) premake_args="${premake_args} $i" ;;
esac
done
premake_args="${premake_args} --collada"
if [ "$enable_atlas" = "true" ]; then
premake_args="${premake_args} --atlas"
fi
cd "$(dirname $0)"
# Now in build/workspaces/ (where we assume this script resides)
if [ "`uname -s`" = "Darwin" ]; then
premake_args="${premake_args} --sdl2"
# Set *_CONFIG variables on OS X, to override the path to e.g. sdl2-config
export GLOOX_CONFIG=${GLOOX_CONFIG:="$(pwd)/../../libraries/osx/gloox/bin/gloox-config"}
export ICU_CONFIG=${ICU_CONFIG:="$(pwd)/../../libraries/osx/icu/bin/icu-config"}
export SDL_CONFIG=${SDL_CONFIG:="$(pwd)/../../libraries/osx/sdl/bin/sdl-config"}
export SDL2_CONFIG=${SDL2_CONFIG:="$(pwd)/../../libraries/osx/sdl2/bin/sdl2-config"}
export WX_CONFIG=${WX_CONFIG:="$(pwd)/../../libraries/osx/wxwidgets/bin/wx-config"}
export XML2_CONFIG=${XML2_CONFIG:="$(pwd)/../../libraries/osx/libxml2/bin/xml2-config"}
fi
# Don't want to build bundled libs on OS X
# (build-osx-libs.sh is used instead)
if [ "`uname -s`" != "Darwin" ]; then
echo "Updating bundled third-party dependencies..."
echo
# Build/update bundled external libraries
(cd ../../libraries/source/fcollada/src && ${MAKE} ${JOBS}) || die "FCollada build failed"
echo
if [ "$with_system_mozjs24" = "false" ]; then
(cd ../../libraries/source/spidermonkey && MAKE=${MAKE} JOBS=${JOBS} ./build.sh) || die "SpiderMonkey build failed"
fi
echo
if [ "$with_system_nvtt" = "false" ] && [ "$without_nvtt" = "false" ]; then
(cd ../../libraries/source/nvtt && MAKE=${MAKE} JOBS=${JOBS} ./build.sh) || die "NVTT build failed"
fi
echo
if [ "$with_system_miniupnpc" = "false" ]; then
(cd ../../libraries/source/miniupnpc && MAKE=${MAKE} JOBS=${JOBS} ./build.sh) || die "MiniUPnPc build failed"
fi
echo
fi
# Now build premake and run it to create the makefiles
cd ../premake/premake4
PREMAKE_BUILD_DIR=build/gmake.unix
# BSD and OS X need different Makefiles
case "`uname -s`" in
"GNU/kFreeBSD" )
# use default gmake.unix (needs -ldl as we have a GNU userland and libc)
;;
*"BSD" )
PREMAKE_BUILD_DIR=build/gmake.bsd
;;
"Darwin" )
PREMAKE_BUILD_DIR=build/gmake.macosx
;;
esac
${MAKE} -C $PREMAKE_BUILD_DIR ${JOBS} || die "Premake build failed"
echo
cd ..
# If we're in bash then make HOSTTYPE available to Premake, for primitive arch-detection
export HOSTTYPE="$HOSTTYPE"
echo "Premake args: ${premake_args}"
premake4/bin/release/premake4 --file="premake4.lua" --outpath="../workspaces/gcc/" ${premake_args} gmake || die "Premake failed"
premake4/bin/release/premake4 --file="premake4.lua" --outpath="../workspaces/codeblocks/" ${premake_args} codeblocks || die "Premake failed"
# Also generate xcode workspaces if on OS X
if [ "`uname -s`" = "Darwin" ]; then
premake4/bin/release/premake4 --file="premake4.lua" --outpath="../workspaces/xcode3" ${premake_args} xcode3 || die "Premake failed"
premake4/bin/release/premake4 --file="premake4.lua" --outpath="../workspaces/xcode4" ${premake_args} xcode4 || die "Premake failed"
fi
# test_root.cpp gets generated by cxxtestgen and passing different arguments to premake could require a regeneration of this file.
# It doesn't depend on anything in the makefiles, so make won't notice that the prebuild command for creating test_root.cpp needs to be triggered.
# We force this by deleting the file.
rm -f ../../source/test_root.cpp
|