forked from mirrors/0ad
486509d5b9
Treat premake like any other dependency and package it separately, this makes it much easier to bump it in future by making it easier to track modifications if any. Moving it to libraries as it is handled the same as other packages. An argument could be made to have it in build due to it's special nature. The issue with that approach would be how to handle clean-workspace.sh. If we split it out we would need a separate clean-premake.sh script and if we have it cleaned by clean-workspace we through away the download and already built binary. Also bump version to 5.0.0-beta2 and backport patch for macOS fix instead of the Makefile changes. The same fix is needed for gcc-14 (reported upstream), so add a patch injecting unistd.h for Unixes. Fixes: #6816 Fixes: #6632 Refs: #6847 Signed-off-by: Ralph Sennhauser <ralph.sennhauser@gmail.com>
99 lines
2.8 KiB
Bash
Executable File
99 lines
2.8 KiB
Bash
Executable File
#!/bin/sh
|
|
|
|
if [ "$(id -u)" = "0" ]; then
|
|
echo "Running as root will mess up file permissions. Aborting ..." 1>&2
|
|
exit 1
|
|
fi
|
|
|
|
die()
|
|
{
|
|
echo ERROR: "$*"
|
|
exit 1
|
|
}
|
|
|
|
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
|
|
"FreeBSD" | "OpenBSD")
|
|
MAKE=${MAKE:="gmake"}
|
|
;;
|
|
*)
|
|
MAKE=${MAKE:="make"}
|
|
;;
|
|
esac
|
|
|
|
cd "$(dirname "$0")" || die
|
|
# Now in build/workspaces/ (where we assume this script resides)
|
|
|
|
# Parse command-line options:
|
|
premake_args=""
|
|
|
|
with_system_premake5=false
|
|
enable_atlas=true
|
|
|
|
JOBS=${JOBS:="-j2"}
|
|
|
|
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
|
|
done
|
|
|
|
if [ "$enable_atlas" = "true" ]; then
|
|
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
|
|
|
|
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
|
|
fi
|
|
|
|
if [ "$OS" = "Darwin" ]; then
|
|
# Set minimal SDK version
|
|
export MIN_OSX_VERSION="${MIN_OSX_VERSION:="10.12"}"
|
|
fi
|
|
|
|
# Now build Premake or use system's.
|
|
|
|
cd ../premake || die
|
|
premake_command="premake5"
|
|
|
|
if [ "$with_system_premake5" = "false" ]; then
|
|
premake_command="../../libraries/source/premake-core/bin/premake5"
|
|
fi
|
|
|
|
echo
|
|
|
|
# If we're in bash then make HOSTTYPE available to Premake, for primitive arch-detection
|
|
export HOSTTYPE="$HOSTTYPE"
|
|
# Now run Premake to create the makefiles
|
|
echo "Premake args: ${premake_args}"
|
|
if [ "$OS" != "Darwin" ]; then
|
|
# shellcheck disable=SC2086
|
|
${premake_command} --file="premake5.lua" --outpath="../workspaces/gcc/" ${premake_args} gmake2 || die "Premake failed"
|
|
else
|
|
# shellcheck disable=SC2086
|
|
${premake_command} --file="premake5.lua" --outpath="../workspaces/gcc/" --macosx-version-min="${MIN_OSX_VERSION}" ${premake_args} gmake2 || die "Premake failed"
|
|
# Also generate xcode workspaces if on OS X
|
|
# shellcheck disable=SC2086
|
|
${premake_command} --file="premake5.lua" --outpath="../workspaces/xcode4" --macosx-version-min="${MIN_OSX_VERSION}" ${premake_args} xcode4 || die "Premake failed"
|
|
fi
|
|
|
|
# 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
|