Merge 'remotes/trunk'
[0ad.git] / build / workspaces / update-workspaces.sh
blobba55be2e96dcddb964d01b167a063e376c8d4964
1 #!/bin/sh
3 if [ "$(id -u)" = "0" ]; then
4 echo "Running as root will mess up file permissions. Aborting ..." 1>&2
5 exit 1
6 fi
8 die()
10 echo ERROR: $*
11 exit 1
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"`
19 case "$SCRIPTPATH" in
20 *\ * )
21 die "Absolute path contains whitespace, which will break the build - move the game to a path without spaces" ;;
22 esac
24 JOBS=${JOBS:="-j2"}
26 # Some of our makefiles depend on GNU make, so we set some sane defaults if MAKE
27 # is not set.
28 case "`uname -s`" in
29 "FreeBSD" | "OpenBSD" )
30 MAKE=${MAKE:="gmake"}
32 * )
33 MAKE=${MAKE:="make"}
35 esac
37 # Parse command-line options:
39 premake_args=""
41 without_nvtt=false
42 with_system_nvtt=false
43 with_system_mozjs38=false
44 enable_atlas=true
46 for i in "$@"
48 case $i in
49 --without-nvtt ) without_nvtt=true; premake_args="${premake_args} --without-nvtt" ;;
50 --with-system-nvtt ) with_system_nvtt=true; premake_args="${premake_args} --with-system-nvtt" ;;
51 --with-system-mozjs38 ) with_system_mozjs38=true; premake_args="${premake_args} --with-system-mozjs38" ;;
52 --enable-atlas ) enable_atlas=true ;;
53 --disable-atlas ) enable_atlas=false ;;
54 -j* ) JOBS=$i ;;
55 # Assume any other --options are for Premake
56 --* ) premake_args="${premake_args} $i" ;;
57 esac
58 done
60 premake_args="${premake_args} --collada"
61 if [ "$enable_atlas" = "true" ]; then
62 premake_args="${premake_args} --atlas"
65 cd "$(dirname $0)"
66 # Now in build/workspaces/ (where we assume this script resides)
68 if [ "`uname -s`" = "Darwin" ]; then
69 # Set *_CONFIG variables on OS X, to override the path to e.g. sdl2-config
70 export GLOOX_CONFIG=${GLOOX_CONFIG:="$(pwd)/../../libraries/osx/gloox/bin/gloox-config"}
71 export ICU_CONFIG=${ICU_CONFIG:="$(pwd)/../../libraries/osx/icu/bin/icu-config"}
72 export SDL2_CONFIG=${SDL2_CONFIG:="$(pwd)/../../libraries/osx/sdl2/bin/sdl2-config"}
73 export WX_CONFIG=${WX_CONFIG:="$(pwd)/../../libraries/osx/wxwidgets/bin/wx-config"}
74 export XML2_CONFIG=${XML2_CONFIG:="$(pwd)/../../libraries/osx/libxml2/bin/xml2-config"}
77 # Don't want to build bundled libs on OS X
78 # (build-osx-libs.sh is used instead)
79 if [ "`uname -s`" != "Darwin" ]; then
80 echo "Updating bundled third-party dependencies..."
81 echo
83 # Build/update bundled external libraries
84 (cd ../../libraries/source/fcollada/src && ${MAKE} ${JOBS}) || die "FCollada build failed"
85 echo
86 if [ "$with_system_mozjs38" = "false" ]; then
87 (cd ../../libraries/source/spidermonkey && MAKE=${MAKE} JOBS=${JOBS} ./build.sh) || die "SpiderMonkey build failed"
89 echo
90 if [ "$with_system_nvtt" = "false" ] && [ "$without_nvtt" = "false" ]; then
91 (cd ../../libraries/source/nvtt && MAKE=${MAKE} JOBS=${JOBS} ./build.sh) || die "NVTT build failed"
93 echo
96 # Now build premake and run it to create the makefiles
97 cd ../premake/premake4
98 PREMAKE_BUILD_DIR=build/gmake.unix
99 # BSD and OS X need different Makefiles
100 case "`uname -s`" in
101 "GNU/kFreeBSD" )
102 # use default gmake.unix (needs -ldl as we have a GNU userland and libc)
104 *"BSD" )
105 PREMAKE_BUILD_DIR=build/gmake.bsd
107 "Darwin" )
108 PREMAKE_BUILD_DIR=build/gmake.macosx
110 esac
111 ${MAKE} -C $PREMAKE_BUILD_DIR ${JOBS} || die "Premake build failed"
113 echo
115 cd ..
117 # If we're in bash then make HOSTTYPE available to Premake, for primitive arch-detection
118 export HOSTTYPE="$HOSTTYPE"
120 echo "Premake args: ${premake_args}"
122 premake4/bin/release/premake4 --file="premake4.lua" --outpath="../workspaces/gcc/" ${premake_args} gmake || die "Premake failed"
123 premake4/bin/release/premake4 --file="premake4.lua" --outpath="../workspaces/codeblocks/" ${premake_args} codeblocks || die "Premake failed"
125 # Also generate xcode workspaces if on OS X
126 if [ "`uname -s`" = "Darwin" ]; then
127 premake4/bin/release/premake4 --file="premake4.lua" --outpath="../workspaces/xcode3" ${premake_args} xcode3 || die "Premake failed"
128 premake4/bin/release/premake4 --file="premake4.lua" --outpath="../workspaces/xcode4" ${premake_args} xcode4 || die "Premake failed"
131 # test_root.cpp gets generated by cxxtestgen and passing different arguments to premake could require a regeneration of this file.
132 # 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.
133 # We force this by deleting the file.
134 rm -f ../../source/test_root.cpp