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
|
2024-08-25 11:55:44 +02:00
|
|
|
echo "Running as root will mess up file permissions. Aborting ..." 1>&2
|
|
|
|
exit 1
|
2014-06-15 17:23:03 +02:00
|
|
|
fi
|
|
|
|
|
2009-08-08 13:22:42 +02:00
|
|
|
die()
|
|
|
|
{
|
2024-08-27 16:14:51 +02:00
|
|
|
echo ERROR: "$*"
|
2024-08-25 11:55:44 +02:00
|
|
|
exit 1
|
2009-08-08 13:22:42 +02:00
|
|
|
}
|
|
|
|
|
2024-08-21 13:32:22 +02:00
|
|
|
OS=${OS:="$(uname -s)"}
|
|
|
|
|
|
|
|
# Some of our makefiles depend on GNU make, so we set some sane defaults if MAKE
|
|
|
|
# is not set.
|
|
|
|
case "$OS" in
|
2024-08-25 11:55:44 +02:00
|
|
|
"FreeBSD" | "OpenBSD")
|
|
|
|
MAKE=${MAKE:="gmake"}
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
MAKE=${MAKE:="make"}
|
|
|
|
;;
|
2024-08-21 13:32:22 +02:00
|
|
|
esac
|
|
|
|
|
2024-08-27 16:14:51 +02:00
|
|
|
cd "$(dirname "$0")" || die
|
2024-08-20 18:57:00 +02:00
|
|
|
# Now in build/workspaces/ (where we assume this script resides)
|
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
|
2011-07-06 22:14:25 +02:00
|
|
|
enable_atlas=true
|
|
|
|
|
2024-08-20 18:57:00 +02:00
|
|
|
JOBS=${JOBS:="-j2"}
|
|
|
|
|
2024-08-25 11:55:44 +02:00
|
|
|
for i in "$@"; do
|
|
|
|
case $i in
|
|
|
|
--with-system-premake5) with_system_premake5=true ;;
|
|
|
|
--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
|
2010-09-10 22:15:49 +02:00
|
|
|
done
|
|
|
|
|
2011-07-06 22:14:25 +02:00
|
|
|
if [ "$enable_atlas" = "true" ]; then
|
2024-08-25 11:55:44 +02:00
|
|
|
premake_args="${premake_args} --atlas"
|
|
|
|
if [ "$OS" = "Darwin" ]; then
|
|
|
|
# Provide path to wx-config on OS X (as wxwidgets doesn't support pkgconfig)
|
|
|
|
export WX_CONFIG="${WX_CONFIG:="$(pwd)/../../libraries/macos/wxwidgets/bin/wx-config"}"
|
|
|
|
else
|
|
|
|
export WX_CONFIG="${WX_CONFIG:="wx-config"}"
|
|
|
|
fi
|
|
|
|
|
2024-08-27 16:14:51 +02:00
|
|
|
if [ ! -x "$(command -v "$WX_CONFIG")" ]; then
|
2024-08-25 11:55:44 +02:00
|
|
|
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
|
|
|
|
|
2024-08-21 13:32:22 +02:00
|
|
|
if [ "$OS" = "Darwin" ]; then
|
2024-08-25 11:55:44 +02:00
|
|
|
# Set minimal SDK version
|
2024-08-27 16:14:51 +02: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
|
|
|
|
2024-08-10 13:46:03 +02:00
|
|
|
# Now build Premake or use system's.
|
2020-05-17 13:41:58 +02:00
|
|
|
|
2024-08-27 16:14:51 +02:00
|
|
|
cd ../premake || die
|
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
|
2024-08-25 11:55:44 +02:00
|
|
|
# Build bundled premake
|
|
|
|
MAKE=${MAKE} JOBS=${JOBS} ./build.sh || die "Premake 5 build failed"
|
2020-05-17 13:41:58 +02:00
|
|
|
|
2024-08-25 11:55:44 +02:00
|
|
|
premake_command="premake5/bin/release/premake5"
|
2020-05-17 13:41:58 +02:00
|
|
|
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}"
|
2024-08-21 13:32:22 +02:00
|
|
|
if [ "$OS" != "Darwin" ]; then
|
2024-08-27 16:14:51 +02:00
|
|
|
# shellcheck disable=SC2086
|
2024-08-25 11:55:44 +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
|
2024-08-27 16:14:51 +02:00
|
|
|
# shellcheck disable=SC2086
|
2024-08-25 11:55:44 +02:00
|
|
|
${premake_command} --file="premake5.lua" --outpath="../workspaces/gcc/" --macosx-version-min="${MIN_OSX_VERSION}" ${premake_args} gmake || die "Premake failed"
|
|
|
|
# Also generate xcode workspaces if on OS X
|
2024-08-27 16:14:51 +02:00
|
|
|
# shellcheck disable=SC2086
|
2024-08-25 11:55:44 +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
|