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=""
|
|
|
|
|
2012-07-16 06:57:07 +02:00
|
|
|
without_nvtt=false
|
2010-09-10 22:15:49 +02:00
|
|
|
with_system_nvtt=false
|
2016-09-02 18:18:57 +02:00
|
|
|
with_system_mozjs38=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
|
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" ;;
|
2016-09-02 18:18:57 +02:00
|
|
|
--with-system-mozjs38 ) with_system_mozjs38=true; premake_args="${premake_args} --with-system-mozjs38" ;;
|
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
|
|
|
premake_args="${premake_args} --collada"
|
|
|
|
if [ "$enable_atlas" = "true" ]; then
|
|
|
|
premake_args="${premake_args} --atlas"
|
|
|
|
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
|
2014-09-25 03:54:58 +02:00
|
|
|
# Set *_CONFIG variables on OS X, to override the path to e.g. sdl2-config
|
2013-11-11 05:41:44 +01:00
|
|
|
export GLOOX_CONFIG=${GLOOX_CONFIG:="$(pwd)/../../libraries/osx/gloox/bin/gloox-config"}
|
2014-04-20 21:17:32 +02:00
|
|
|
export ICU_CONFIG=${ICU_CONFIG:="$(pwd)/../../libraries/osx/icu/bin/icu-config"}
|
2014-09-20 21:02:24 +02:00
|
|
|
export SDL2_CONFIG=${SDL2_CONFIG:="$(pwd)/../../libraries/osx/sdl2/bin/sdl2-config"}
|
2013-02-04 00:49:29 +01:00
|
|
|
export WX_CONFIG=${WX_CONFIG:="$(pwd)/../../libraries/osx/wxwidgets/bin/wx-config"}
|
2013-11-11 01:04:07 +01:00
|
|
|
export XML2_CONFIG=${XML2_CONFIG:="$(pwd)/../../libraries/osx/libxml2/bin/xml2-config"}
|
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
|
|
|
|
(cd ../../libraries/source/fcollada/src && ${MAKE} ${JOBS}) || die "FCollada build failed"
|
|
|
|
echo
|
2016-09-02 18:18:57 +02:00
|
|
|
if [ "$with_system_mozjs38" = "false" ]; then
|
2013-02-04 00:49:29 +01:00
|
|
|
(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
|
2011-05-29 22:57:28 +02:00
|
|
|
fi
|
2009-08-08 13:22:42 +02:00
|
|
|
|
2009-07-18 00:07:09 +02:00
|
|
|
# Now build premake and run it to create the makefiles
|
2011-10-03 21:09:03 +02:00
|
|
|
cd ../premake/premake4
|
2012-08-19 20:49:02 +02:00
|
|
|
PREMAKE_BUILD_DIR=build/gmake.unix
|
|
|
|
# BSD and OS X need different Makefiles
|
2012-06-11 00:39:26 +02:00
|
|
|
case "`uname -s`" in
|
|
|
|
"GNU/kFreeBSD" )
|
2012-08-19 20:49:02 +02:00
|
|
|
# use default gmake.unix (needs -ldl as we have a GNU userland and libc)
|
2012-06-11 00:39:26 +02:00
|
|
|
;;
|
|
|
|
*"BSD" )
|
2012-08-19 20:49:02 +02:00
|
|
|
PREMAKE_BUILD_DIR=build/gmake.bsd
|
|
|
|
;;
|
2012-06-22 00:55:07 +02:00
|
|
|
"Darwin" )
|
2012-08-19 20:49:02 +02:00
|
|
|
PREMAKE_BUILD_DIR=build/gmake.macosx
|
2012-06-11 00:39:26 +02:00
|
|
|
;;
|
|
|
|
esac
|
2012-08-19 20:49:02 +02:00
|
|
|
${MAKE} -C $PREMAKE_BUILD_DIR ${JOBS} || die "Premake build failed"
|
2010-03-26 11:31:47 +01:00
|
|
|
|
|
|
|
echo
|
|
|
|
|
2011-10-03 21:09:03 +02:00
|
|
|
cd ..
|
|
|
|
|
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"
|
|
|
|
|
2013-02-04 00:49:29 +01:00
|
|
|
echo "Premake args: ${premake_args}"
|
|
|
|
|
2011-10-03 21:09:03 +02:00
|
|
|
premake4/bin/release/premake4 --file="premake4.lua" --outpath="../workspaces/gcc/" ${premake_args} gmake || die "Premake failed"
|
2011-11-13 00:58:35 +01:00
|
|
|
premake4/bin/release/premake4 --file="premake4.lua" --outpath="../workspaces/codeblocks/" ${premake_args} codeblocks || die "Premake failed"
|
2011-10-03 21:09:03 +02:00
|
|
|
|
2013-01-11 22:31:38 +01:00
|
|
|
# Also generate xcode workspaces if on OS X
|
2013-02-04 00:49:29 +01:00
|
|
|
if [ "`uname -s`" = "Darwin" ]; then
|
2011-10-03 21:09:03 +02:00
|
|
|
premake4/bin/release/premake4 --file="premake4.lua" --outpath="../workspaces/xcode3" ${premake_args} xcode3 || die "Premake failed"
|
2013-01-11 22:31:38 +01:00
|
|
|
premake4/bin/release/premake4 --file="premake4.lua" --outpath="../workspaces/xcode4" ${premake_args} xcode4 || die "Premake failed"
|
2011-10-03 21:09:03 +02: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
|