3 if [ "$(id -u)" = "0" ]; then
4 echo "Running as root will mess up file permissions. Aborting ..." 1>&2
14 # Check for whitespace in absolute path; this will cause problems in the
15 # SpiderMonkey build (https://bugzilla.mozilla.org/show_bug.cgi?id=459089)
16 # and maybe elsewhere, so we just forbid it
17 # Use perl as an alternative to readlink -f, which isn't available on BSD or OS X
18 SCRIPTPATH
=`perl -MCwd -e 'print Cwd::abs_path shift' "$0"`
21 die
"Absolute path contains whitespace, which will break the build - move the game to a path without spaces" ;;
26 # Some of our makefiles depend on GNU make, so we set some sane defaults if MAKE
29 "FreeBSD" |
"OpenBSD" )
37 # Parse command-line options:
41 with_system_premake5
=false
43 with_system_nvtt
=false
44 with_system_mozjs
=false
50 --with-system-premake5 ) with_system_premake5
=true
;;
51 --without-nvtt ) without_nvtt
=true
; premake_args
="${premake_args} --without-nvtt" ;;
52 --with-system-nvtt ) with_system_nvtt
=true
; premake_args
="${premake_args} --with-system-nvtt" ;;
53 --with-system-mozjs ) with_system_mozjs
=true
; premake_args
="${premake_args} --with-system-mozjs" ;;
54 --enable-atlas ) enable_atlas
=true
;;
55 --disable-atlas ) enable_atlas
=false
;;
57 # Assume any other --options are for Premake
58 --* ) premake_args
="${premake_args} $i" ;;
62 if [ "$enable_atlas" = "true" ]; then
63 premake_args
="${premake_args} --atlas"
64 if [ "$(uname -s)" = "Darwin" ]; then
65 # Provide path to wx-config on OS X (as wxwidgets doesn't support pkgconfig)
66 export WX_CONFIG
="${WX_CONFIG:="$(pwd)/../../libraries/osx/wxwidgets/bin/wx-config"}"
68 export WX_CONFIG
="${WX_CONFIG:="wx-config"}"
71 if [ ! -x "$(command -v $WX_CONFIG)" ]
73 echo 'WX_CONFIG must be set and valid or wx-config must be present when --atlas is passed as argument.'
79 # Now in build/workspaces/ (where we assume this script resides)
81 if [ "`uname -s`" = "Darwin" ]; then
82 # Set minimal SDK version
83 export MIN_OSX_VERSION
=${MIN_OSX_VERSION:="10.12"}
86 # Don't want to build bundled libs on OS X
87 # (build-osx-libs.sh is used instead)
88 if [ "`uname -s`" != "Darwin" ]; then
89 echo "Updating bundled third-party dependencies..."
92 # Build/update bundled external libraries
93 (cd ..
/..
/libraries
/source
/fcollada
&& MAKE
=${MAKE} JOBS
=${JOBS} .
/build.sh
) || die
"FCollada build failed"
95 if [ "$with_system_mozjs" = "false" ]; then
96 (cd ..
/..
/libraries
/source
/spidermonkey
&& MAKE
=${MAKE} JOBS
=${JOBS} .
/build.sh
) || die
"SpiderMonkey build failed"
99 if [ "$with_system_nvtt" = "false" ] && [ "$without_nvtt" = "false" ]; then
100 (cd ..
/..
/libraries
/source
/nvtt
&& MAKE
=${MAKE} JOBS
=${JOBS} .
/build.sh
) || die
"NVTT build failed"
105 # Now run premake to create the makefiles
108 premake_command
="premake5"
110 if [ "$with_system_premake5" = "false" ]; then
111 # Build bundled premake
113 PREMAKE_BUILD_DIR
=build
/gmake2.unix
114 # BSD and OS X need different Makefiles
117 # use default gmake2.unix (needs -ldl as we have a GNU userland and libc)
120 PREMAKE_BUILD_DIR
=build
/gmake2.bsd
123 PREMAKE_BUILD_DIR
=build
/gmake2.macosx
126 ${MAKE} -C $PREMAKE_BUILD_DIR ${JOBS} || die
"Premake build failed"
129 premake_command
="premake5/bin/release/premake5"
134 # If we're in bash then make HOSTTYPE available to Premake, for primitive arch-detection
135 export HOSTTYPE
="$HOSTTYPE"
137 echo "Premake args: ${premake_args}"
138 if [ "`uname -s`" != "Darwin" ]; then
139 ${premake_command} --file="premake5.lua" --outpath="../workspaces/gcc/" ${premake_args} gmake || die
"Premake failed"
141 ${premake_command} --file="premake5.lua" --outpath="../workspaces/gcc/" --macosx-version-min="${MIN_OSX_VERSION}" ${premake_args} gmake || die
"Premake failed"
142 # Also generate xcode workspaces if on OS X
143 ${premake_command} --file="premake5.lua" --outpath="../workspaces/xcode4" --macosx-version-min="${MIN_OSX_VERSION}" ${premake_args} xcode4 || die
"Premake failed"
146 # test_root.cpp gets generated by cxxtestgen and passing different arguments to premake could require a regeneration of this file.
147 # 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.
148 # We force this by deleting the file.
149 rm -f ..
/..
/source
/test_root.cpp