configure: rework acinclude.m4

Added more documented output for users and removed some unused
lines (such as assignments after AC_MSG_ERROR, which do not make sense).
Additionally, more checks have been added with result output.

DEBUG_CFLAGS can now be used as an environment variable.
This change was made because for debugging purposes, users should be
able to adjust the options, rather than relying solely on static options
such as -g3 -ggdb. This is especially important since -O2 may often
not be sufficient.

Do we really need the CDK mode? Would it be a better idea to
handle this via the usual configuration or build system, using
environment variable assignments, or catching specific cases
in a makefile? Additionally, I have the impression that hardly
anyone is using the CDK mode.

Btw: targetroot and targetprefix are not really used by libst-hal.
This commit is contained in:
2023-04-23 16:10:39 +02:00
parent 801be58bbe
commit 8b12f62d69

View File

@@ -5,80 +5,123 @@ AM_MAINTAINER_MODE
AC_GNU_SOURCE AC_GNU_SOURCE
AC_ARG_WITH(target, AC_ARG_WITH(target,
AS_HELP_STRING([--with-target=TARGET], [target for compilation [[native,cdk]]]), AS_HELP_STRING([--with-target=TARGET], [Target mode for compilation, either "native" or "cdk", keep empty for native]),
[TARGET="$withval"], [TARGET="$withval"],
[TARGET="native"]) [TARGET="native"])
AC_ARG_WITH(targetroot, AC_ARG_WITH(targetroot,
AS_HELP_STRING([--with-targetroot=PATH], [the target root (only applicable in native mode)]), AS_HELP_STRING([--with-targetroot=PATH], [The target root (only applicable in native mode.]),
[TARGET_ROOT="$withval"], [TARGET_ROOT="$withval"],
[TARGET_ROOT="NONE"]) [TARGET_ROOT="NONE"])
AC_ARG_WITH(targetprefix, AC_ARG_WITH(targetprefix,
AS_HELP_STRING([--with-targetprefix=PATH], [prefix relative to target root, e.g. /usr (only applicable in cdk mode)]), AS_HELP_STRING([--with-targetprefix=PATH], [Prefix relative to target root, e.g. /usr (only applicable in cdk mode)]),
[TARGET_PREFIX="$withval"], [TARGET_PREFIX="$withval"],
[TARGET_PREFIX="NONE"]) [TARGET_PREFIX="NONE"])
AC_ARG_WITH(debug, AC_ARG_WITH(debug,
AS_HELP_STRING([--without-debug], [disable debugging code @<:@default=no@:>@]), AS_HELP_STRING([--without-debug], [Disable debugging code @<:@default=no@:>@]),
[DEBUG="$withval"], [DEBUG="$withval"],
[DEBUG="yes"]) [DEBUG="yes"])
AC_MSG_CHECKING(debug enabled)
if test "$DEBUG" = "yes"; then if test "$DEBUG" = "yes"; then
DEBUG_CFLAGS="-g3 -ggdb" AC_MSG_RESULT([$DEBUG])
AC_DEFINE(DEBUG, 1, [enable debugging code]) AC_DEFINE(DEBUG, 1, [enable debugging code])
AC_MSG_CHECKING(debug flags)
if test "$DEBUG_CFLAGS" = ""; then
DEBUG_CFLAGS="-g3 -ggdb"
AC_MSG_RESULT([Environment variable DEBUG_CFLAGS is not set, default debug flags will be used: $DEBUG_CFLAGS])
else
AC_MSG_RESULT([Defined by environment variable DEBUG_CFLAGS: $DEBUG_CFLAGS])
fi
else
AC_MSG_RESULT([$DEBUG])
fi fi
AC_MSG_CHECKING(target) AC_MSG_CHECKING(target)
if test "$TARGET" = "native" || test "$TARGET" = "cdk"; then
AC_MSG_RESULT($TARGET)
else
AC_MSG_ERROR([Invalid target '$TARGET'. Use either 'native' or 'cdk' or leave empty for native.])
fi
if test "$TARGET" = "native"; then if test "$TARGET" = "native"; then
AC_MSG_RESULT(native) AC_MSG_CHECKING(prefix)
if test "$prefix" = "NONE"; then if test "$prefix" = "NONE"; then
prefix=/usr/local prefix=/usr/local
fi fi
AC_MSG_RESULT($prefix)
AC_MSG_CHECKING([targetroot])
if test "$TARGET_ROOT" = "NONE"; then if test "$TARGET_ROOT" = "NONE"; then
AC_MSG_ERROR([invalid targetroot, you need to specify one in native mode])
TARGET_ROOT="" TARGET_ROOT=""
AC_MSG_RESULT([Is not set, use default target system root: empty])
else
AC_MSG_RESULT([$TARGET_ROOT])
fi
AC_MSG_CHECKING([targetprefix])
if test "$TARGET_PREFIX" = "NONE"; then
TARGET_PREFIX=
AC_MSG_RESULT([Is not set, use default target prefix relative to target root: empty])
else
AC_MSG_RESULT([$TARGET_PREFIX])
fi fi
TARGET_PREFIX=$prefix
if test "$CFLAGS" = "" -a "$CXXFLAGS" = ""; then if test "$CFLAGS" = "" -a "$CXXFLAGS" = ""; then
CFLAGS="-Wall -O2 -pipe $DEBUG_CFLAGS" CFLAGS="-Wall -O2 -pipe $DEBUG_CFLAGS"
CXXFLAGS="-Wall -O2 -pipe $DEBUG_CFLAGS" CXXFLAGS="-Wall -O2 -pipe $DEBUG_CFLAGS"
fi fi
elif test "$TARGET" = "cdk"; then elif test "$TARGET" = "cdk"; then
AC_MSG_RESULT(cdk) AC_MSG_CHECKING(prefix in cdk mode)
if test "$prefix" = "NONE"; then if test "$prefix" = "NONE"; then
AC_MSG_ERROR([invalid prefix, you need to specify one in cdk mode]) AC_MSG_ERROR([$prefix invalid prefix, you need to specify one in cdk mode])
fi fi
AC_MSG_RESULT($prefix)
AC_MSG_CHECKING([targetroot in cdk mode])
OLD_TARGET_ROOT=$TARGET_ROOT
TARGET_ROOT="" TARGET_ROOT=""
if test "$TARGET_PREFIX" = "NONE"; then if test "$TARGET_ROOT" = "NONE"; then
AC_MSG_ERROR([invalid targetprefix, you need to specify one in cdk mode]) AC_MSG_NOTICE([Is not set "$OLD_TARGET_ROOT", using fallback to default: empty])
TARGET_PREFIX=""
fi
if test "$CC" = "" -a "$CXX" = ""; then
AC_MSG_ERROR([you need to specify variables CC or CXX in cdk mode])
fi
if test "$CFLAGS" = "" -o "$CXXFLAGS" = ""; then
AC_MSG_ERROR([you need to specify variables CFLAGS and CXXFLAGS in cdk mode])
fi
else else
AC_MSG_RESULT(none) AC_MSG_NOTICE([Is set to "$OLD_TARGET_ROOT", but using default: empty])
AC_MSG_ERROR([invalid target "$TARGET", choose "native" or "cdk"]);
fi fi
AC_DEFINE_UNQUOTED([TARGET], ["$TARGET"], [target for compilation]) AC_MSG_CHECKING([targetprefix in cdk mode])
AC_DEFINE_UNQUOTED([TARGET_ROOT], ["$TARGET_ROOT"], [native: the target root; cdk: empty]) if test "$TARGET_PREFIX" = "NONE"; then
AC_DEFINE_UNQUOTED([TARGET_PREFIX], ["$TARGET_PREFIX"], [native: auto-assigned path; cdk: path relative to target root]) TARGET_PREFIX=""
AC_MSG_RESULT([default target prefix relative to target root: empty])
else
AC_MSG_RESULT([user defined target prefix relative to target root: $TARGET_PREFIX])
fi
AC_MSG_CHECKING([gcc/g++ in cdk mode])
if test "$CC" = "" -a "$CXX" = ""; then
AC_MSG_ERROR([you need to specify variables CC and CXX in cdk mode in your envirionment])
fi
AC_MSG_RESULT($CC / $CXX)
AC_MSG_CHECKING([CFLAGS and CXXFLAGS in cdk mode])
if test "$CFLAGS" = "" -o "$CXXFLAGS" = ""; then
AC_MSG_ERROR([you need to specify variables CFLAGS and CXXFLAGS in cdk mode in your envirionment])
fi
AC_MSG_RESULT(CFLAGS: $CFLAGS)
AC_MSG_RESULT(CXXLAGS: $CXXFLAGS)
fi
AC_MSG_CHECKING(exec_prefix)
if test "$exec_prefix" = "NONE"; then if test "$exec_prefix" = "NONE"; then
exec_prefix=$prefix exec_prefix=$prefix
fi fi
AC_MSG_RESULT($exec_prefix)
AC_DEFINE_UNQUOTED([TARGET], ["$TARGET"], [target for compilation])
AC_DEFINE_UNQUOTED([TARGET_ROOT], ["$TARGET_ROOT"], [root path at the target system native: the target root; cdk: empty])
AC_DEFINE_UNQUOTED([TARGET_PREFIX], ["$TARGET_PREFIX"], [native: auto-assigned path; cdk: path relative to target root])
AC_CANONICAL_BUILD AC_CANONICAL_BUILD
AC_CANONICAL_HOST AC_CANONICAL_HOST