2009-07-16 18:57:59 +02:00
|
|
|
#!/bin/sh
|
2004-06-07 12:45:48 +02:00
|
|
|
|
2014-06-19 17:19:08 +02:00
|
|
|
if [ "$(id -u)" = "0" ]; then
|
2014-06-15 17:23:03 +02:00
|
|
|
echo "Running as root will mess up file permissions. Aborting ..." 1>&2
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2009-08-08 13:22:42 +02:00
|
|
|
die()
|
|
|
|
{
|
2010-09-10 22:15:49 +02:00
|
|
|
echo ERROR: $*
|
|
|
|
exit 1
|
2009-08-08 13:22:42 +02:00
|
|
|
}
|
|
|
|
|
2012-03-20 23:29:56 +01:00
|
|
|
# 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
|
2015-06-14 22:43:12 +02:00
|
|
|
# Use perl as an alternative to readlink -f, which isn't available on BSD or OS X
|
|
|
|
SCRIPTPATH=`perl -MCwd -e 'print Cwd::abs_path shift' "$0"`
|
2012-03-20 23:29:56 +01:00
|
|
|
case "$SCRIPTPATH" in
|
|
|
|
*\ * )
|
|
|
|
die "Absolute path contains whitespace, which will break the build - move the game to a path without spaces" ;;
|
|
|
|
esac
|
|
|
|
|
2011-05-04 01:54:29 +02:00
|
|
|
JOBS=${JOBS:="-j2"}
|
|
|
|
|
2012-06-04 23:33:15 +02:00
|
|
|
# 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
|
2012-01-31 01:06:56 +01:00
|
|
|
|
2011-07-06 22:14:25 +02:00
|
|
|
# Parse command-line options:
|
|
|
|
|
|
|
|
premake_args=""
|
|
|
|
|
2020-05-17 13:41:58 +02:00
|
|
|
with_system_premake5=false
|
2012-07-16 06:57:07 +02:00
|
|
|
without_nvtt=false
|
2010-09-10 22:15:49 +02:00
|
|
|
with_system_nvtt=false
|
2020-11-24 16:41:52 +01:00
|
|
|
with_system_mozjs=false
|
2011-07-06 22:14:25 +02:00
|
|
|
enable_atlas=true
|
|
|
|
|
2010-09-10 22:15:49 +02:00
|
|
|
for i in "$@"
|
|
|
|
do
|
|
|
|
case $i in
|
2020-05-17 13:41:58 +02:00
|
|
|
--with-system-premake5 ) with_system_premake5=true ;;
|
2012-07-16 06:57:07 +02:00
|
|
|
--without-nvtt ) without_nvtt=true; premake_args="${premake_args} --without-nvtt" ;;
|
2011-07-06 22:14:25 +02:00
|
|
|
--with-system-nvtt ) with_system_nvtt=true; premake_args="${premake_args} --with-system-nvtt" ;;
|
2020-11-24 16:41:52 +01:00
|
|
|
--with-system-mozjs ) with_system_mozjs=true; premake_args="${premake_args} --with-system-mozjs" ;;
|
2011-07-06 22:14:25 +02:00
|
|
|
--enable-atlas ) enable_atlas=true ;;
|
|
|
|
--disable-atlas ) enable_atlas=false ;;
|
2011-05-04 01:54:29 +02:00
|
|
|
-j* ) JOBS=$i ;;
|
2011-10-03 21:09:03 +02:00
|
|
|
# Assume any other --options are for Premake
|
|
|
|
--* ) premake_args="${premake_args} $i" ;;
|
2010-09-10 22:15:49 +02:00
|
|
|
esac
|
|
|
|
done
|
|
|
|
|
2011-07-06 22:14:25 +02:00
|
|
|
if [ "$enable_atlas" = "true" ]; then
|
|
|
|
premake_args="${premake_args} --atlas"
|
2022-09-01 22:42:59 +02:00
|
|
|
if [ "$(uname -s)" = "Darwin" ]; then
|
|
|
|
# Provide path to wx-config on OS X (as wxwidgets doesn't support pkgconfig)
|
|
|
|
export WX_CONFIG="${WX_CONFIG:="$(pwd)/../../libraries/osx/wxwidgets/bin/wx-config"}"
|
|
|
|
else
|
|
|
|
export WX_CONFIG="${WX_CONFIG:="wx-config"}"
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ ! -x "$(command -v $WX_CONFIG)" ]
|
|
|
|
then
|
|
|
|
echo 'WX_CONFIG must be set and valid or wx-config must be present when --atlas is passed as argument.'
|
|
|
|
exit 1
|
|
|
|
fi
|
2011-07-06 22:14:25 +02:00
|
|
|
fi
|
|
|
|
|
2009-07-18 00:07:09 +02:00
|
|
|
cd "$(dirname $0)"
|
|
|
|
# Now in build/workspaces/ (where we assume this script resides)
|
2004-06-07 12:45:48 +02:00
|
|
|
|
2013-02-04 00:49:29 +01:00
|
|
|
if [ "`uname -s`" = "Darwin" ]; then
|
2018-12-03 12:07:00 +01:00
|
|
|
# Set minimal SDK version
|
2020-11-26 08:20:10 +01:00
|
|
|
export MIN_OSX_VERSION=${MIN_OSX_VERSION:="10.12"}
|
2010-09-10 22:15:49 +02:00
|
|
|
fi
|
2013-02-04 00:49:29 +01:00
|
|
|
|
|
|
|
# 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
|
2020-12-01 20:29:21 +01:00
|
|
|
(cd ../../libraries/source/fcollada && MAKE=${MAKE} JOBS=${JOBS} ./build.sh) || die "FCollada build failed"
|
2013-02-04 00:49:29 +01:00
|
|
|
echo
|
2020-11-24 16:41:52 +01:00
|
|
|
if [ "$with_system_mozjs" = "false" ]; then
|
2023-01-17 21:49:00 +01:00
|
|
|
(cd ../../libraries/source/spidermonkey && MAKE=${MAKE} JOBS=${JOBS} ./build.sh) || die "SpiderMonkey build failed"
|
2013-02-04 00:49:29 +01:00
|
|
|
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
|
2011-05-29 22:57:28 +02:00
|
|
|
fi
|
2009-08-08 13:22:42 +02:00
|
|
|
|
2024-08-10 13:46:03 +02:00
|
|
|
# Now build Premake or use system's.
|
2020-05-17 13:41:58 +02:00
|
|
|
|
2023-02-20 16:06:39 +01:00
|
|
|
cd ../premake
|
2020-05-17 13:41:58 +02:00
|
|
|
premake_command="premake5"
|
2023-02-20 16:06:39 +01:00
|
|
|
|
2020-05-17 13:41:58 +02:00
|
|
|
if [ "$with_system_premake5" = "false" ]; then
|
|
|
|
# Build bundled premake
|
2024-08-10 13:46:03 +02:00
|
|
|
MAKE=${MAKE} JOBS=${JOBS} ./build.sh || die "Premake 5 build failed"
|
2020-05-17 13:41:58 +02:00
|
|
|
|
|
|
|
premake_command="premake5/bin/release/premake5"
|
|
|
|
fi
|
2010-03-26 11:31:47 +01:00
|
|
|
|
|
|
|
echo
|
|
|
|
|
2010-04-15 22:15:16 +02:00
|
|
|
# If we're in bash then make HOSTTYPE available to Premake, for primitive arch-detection
|
|
|
|
export HOSTTYPE="$HOSTTYPE"
|
2024-08-10 13:46:03 +02:00
|
|
|
# Now run Premake to create the makefiles
|
2013-02-04 00:49:29 +01:00
|
|
|
echo "Premake args: ${premake_args}"
|
2018-12-03 12:07:00 +01:00
|
|
|
if [ "`uname -s`" != "Darwin" ]; then
|
2020-05-17 13:41:58 +02:00
|
|
|
${premake_command} --file="premake5.lua" --outpath="../workspaces/gcc/" ${premake_args} gmake || die "Premake failed"
|
2018-12-03 12:07:00 +01:00
|
|
|
else
|
2020-05-17 13:41:58 +02:00
|
|
|
${premake_command} --file="premake5.lua" --outpath="../workspaces/gcc/" --macosx-version-min="${MIN_OSX_VERSION}" ${premake_args} gmake || die "Premake failed"
|
2018-12-03 12:07:00 +01:00
|
|
|
# Also generate xcode workspaces if on OS X
|
2020-05-17 13:41:58 +02:00
|
|
|
${premake_command} --file="premake5.lua" --outpath="../workspaces/xcode4" --macosx-version-min="${MIN_OSX_VERSION}" ${premake_args} xcode4 || die "Premake failed"
|
2018-12-03 12:07:00 +01:00
|
|
|
fi
|
2014-03-07 21:58:17 +01:00
|
|
|
|
|
|
|
# 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
|