major evolution of configure template - fixes #283 configure-evo

Thu, 14 Sep 2023 22:59:05 +0200

author
Mike Becker <universe@uap-core.de>
date
Thu, 14 Sep 2023 22:59:05 +0200
branch
configure-evo
changeset 52
afcb57893858
parent 51
5c12e9e29733
child 53
704368f1bb23

major evolution of configure template - fixes #283

src/main/java/de/unixwork/uwproj/Project.java file | annotate | diff | comparison | revisions
src/main/java/de/unixwork/uwproj/Target.java file | annotate | diff | comparison | revisions
src/test/resources/golden-sample/configure file | annotate | diff | comparison | revisions
src/test/resources/golden-sample/configure2 file | annotate | diff | comparison | revisions
test/configure file | annotate | diff | comparison | revisions
test/make/configure.vm file | annotate | diff | comparison | revisions
test/make/project.xml file | annotate | diff | comparison | revisions
test/make/toolchain.sh file | annotate | diff | comparison | revisions
--- a/src/main/java/de/unixwork/uwproj/Project.java	Tue Sep 12 23:36:45 2023 +0200
+++ b/src/main/java/de/unixwork/uwproj/Project.java	Thu Sep 14 22:59:05 2023 +0200
@@ -118,8 +118,4 @@
     public List<ConfigVar> getVars() {
         return configVarsList;
     }
-
-    public boolean hasVar(String varName) {
-        return configVars.containsKey(varName);
-    }
 }
--- a/src/main/java/de/unixwork/uwproj/Target.java	Tue Sep 12 23:36:45 2023 +0200
+++ b/src/main/java/de/unixwork/uwproj/Target.java	Thu Sep 14 22:59:05 2023 +0200
@@ -12,7 +12,7 @@
 import static de.unixwork.uwproj.Util.isNullOrBlank;
 
 public class Target {
-    private String name;
+    private String name = "";
     private String prefix;
 
     private final List<String> dependencies = new LinkedList<>();
--- a/src/test/resources/golden-sample/configure	Tue Sep 12 23:36:45 2023 +0200
+++ b/src/test/resources/golden-sample/configure	Thu Sep 14 22:59:05 2023 +0200
@@ -1,11 +1,19 @@
 #!/bin/sh
 
-HOST=`uname -n`
-PREFIX=`pwd`/work
-INSTALL_DIR=$PREFIX
+# create temporary directory
+TEMP_DIR=".tmp-$(uname -n)"
+rm -Rf "$TEMP_DIR"
+if ! mkdir -p "$TEMP_DIR"; then
+    echo "Cannot create tmp dir $TEMP_DIR"
+    echo "Abort"
+    exit 1
+fi
+touch "$TEMP_DIR/options"
+touch "$TEMP_DIR/features"
 
-EPREFIX=$PREFIX
-
+# define standard variables
+PREFIX=/usr
+EPREFIX=/usr
 BINDIR=
 SBINDIR=
 LIBDIR=
@@ -18,21 +26,21 @@
 INFODIR=
 MANDIR=
 
-OS=`uname -s`
-OS_VERSION=`uname -r`
-
-TEMP_DIR=".tmp-`uname -n`"
-mkdir -p "$TEMP_DIR"
-if [ $? -ne 0 ]; then
-    echo "Cannot create tmp dir"
-    echo "Abort"
-fi
-touch "$TEMP_DIR/options"
-touch "$TEMP_DIR/features"
+# custom variables
+HOST=$(uname -n)
+PREFIX=$(pwd)/work
+INSTALL_DIR=$PREFIX
 
 # features
 FEATURE_PG=auto
 
+# clean abort
+abort_configure()
+{
+    rm -Rf "$TEMP_DIR"
+    exit 1
+}
+
 # help text
 printhelp()
 {
@@ -83,59 +91,37 @@
         "--includedir="*)     INCLUDEDIR=${ARG#--includedir=} ;;
         "--infodir="*)        INFODIR=${ARG#--infodir=} ;;
         "--mandir"*)          MANDIR=${ARG#--mandir} ;;
-        "--help"*) printhelp; rm -Rf "$TEMP_DIR"; exit 1 ;;
+        "--help"*) printhelp; abort_configure ;;
         "--debug")           BUILD_TYPE="debug" ;;
         "--release")         BUILD_TYPE="release" ;;
         "--enable-pg") FEATURE_PG=on ;;
         "--disable-pg") unset FEATURE_PG ;;
-        "-"*) echo "unknown option: $ARG"; rm -Rf "$TEMP_DIR"; exit 1 ;;
+        "-"*) echo "unknown option: $ARG"; abort_configure ;;
     esac
 done
 
+
 # set dir variables
-if [ -z "$BINDIR" ]; then
-    BINDIR=$EPREFIX/bin
-fi
-if [ -z "$SBINDIR" ]; then
-    SBINDIR=$EPREFIX/sbin
-fi
-if [ -z "$LIBDIR" ]; then
-    LIBDIR=$EPREFIX/lib
-fi
-if [ -z "$LIBEXEC" ]; then
-    LIBEXECDIR=$EPREFIX/libexec
-fi
-if [ -z "$DATADIR" ]; then
-    DATADIR=$PREFIX/share
-fi
-if [ -z "$SYSCONFDIR" ]; then
-    SYSCONFDIR=$PREFIX/etc
-fi
-if [ -z "$SHAREDSTATEDIR" ]; then
-    SHAREDSTATEDIR=$PREFIX/com
-fi
-if [ -z "$LOCALSTATEDIR" ]; then
-    LOCALSTATEDIR=$PREFIX/var
-fi
-if [ -z "$INCLUDEDIR" ]; then
-    INCLUDEDIR=$PREFIX/include
-fi
-if [ -z "$INFODIR" ]; then
-    INFODIR=$PREFIX/info
-fi
-if [ -z "$MANDIR" ]; then
-    MANDIR=$PREFIX/man
-fi
+BINDIR=${BINDIR:-"$EPREFIX/bin"}
+SBINDIR=${SBINDIR:-"$EPREFIX/sbin"}
+LIBDIR=${LIBDIR:-"$EPREFIX/lib"}
+LIBEXECDIR=${LIBEXECDIR:-"$EPREFIX/libexec"}
+DATADIR=${DATADIR:-"$PREFIX/share"}
+SYSCONFDIR=${SYSCONFDIR:-"$PREFIX/etc"}
+SHAREDSTATEDIR=${SHAREDSTATEDIR:-"$PREFIX/com"}
+LOCALSTATEDIR=${LOCALSTATEDIR:-"$PREFIX/var"}
+INCLUDEDIR=${INCLUDEDIR:-"$PREFIX/include"}
+INFODIR=${INFODIR:-"$PREFIX/info"}
+MANDIR=${MANDIR:-"$PREFIX/man"}
 
-which pkg-config > /dev/null
-if [ $? -eq 0 ]; then
-    PKG_CONFIG=pkg-config
-else
-    PKG_CONFIG=false
-fi
+# Test for availability of pkg-config
+PKG_CONFIG=$(command -v pkg-config)
+PKG_CONFIG=${PKG_CONFIG:-"false"}
 
 # Simple uname based platform detection
 # $PLATFORM is used for platform dependent dependency selection
+OS=$(uname -s)
+OS_VERSION=$(uname -r)
 printf "detect platform... "
 if [ "$OS" = "SunOS" ]; then
     PLATFORM="solaris sunos unix svr4"
@@ -149,21 +135,13 @@
 if [ "$OS" = "Darwin" ]; then
     PLATFORM="macos osx bsd unix"
 fi
-echo "$OS" | grep -i "MINGW" > /dev/null
-if [ $? -eq 0 ]; then
+if echo "$OS" | grep -i "MINGW" > /dev/null; then
     PLATFORM="windows mingw"
 fi
-
-if [ -z "$PLATFORM" ]; then
-    PLATFORM="unix"
-fi
+PLATFORM=${PLATFORM:-"unix"}
 
-for p in $PLATFORM
-do
-    PLATFORM_NAME=$p
-    break
-done
-echo $PLATFORM_NAME
+PLATFORM_NAME=$(echo "$PLATFORM" | cut -f1 -d' ' -)
+echo "$PLATFORM_NAME"
 
 isplatform()
 {
@@ -175,30 +153,12 @@
     done
     return 1
 }
-isnotplatform()
-{
-    for p in $PLATFORM
-    do
-        if [ "$p" = "$1" ]; then
-            return 1
-        fi
-    done
-    return 0
-}
+
 
-# generate config.mk and config.h
-cat > "$TEMP_DIR/config.mk" << __EOF__
-#
-# config.mk generated by configure
-#
-
-# general vars
-HOST=$HOST
+# generate config.mk
+cat > "$TEMP_DIR/vars.mk" << __EOF__
 PREFIX=$PREFIX
-INSTALL_DIR=$INSTALL_DIR
-
 EPREFIX=$EPREFIX
-
 BINDIR=$BINDIR
 SBINDIR=$SBINDIR
 LIBDIR=$LIBDIR
@@ -210,35 +170,34 @@
 INCLUDEDIR=$INCLUDEDIR
 INFODIR=$INFODIR
 MANDIR=$MANDIR
-
+HOST=$HOST
+PREFIX=$PREFIX
+INSTALL_DIR=$INSTALL_DIR
 __EOF__
-
-echo > "$TEMP_DIR/make.mk"
+cat > "$TEMP_DIR/config.mk" << __EOF__
+#
+# config.mk generated by configure
+#
+__EOF__
+sort -u "$TEMP_DIR/vars.mk" >> "$TEMP_DIR/config.mk"
 
-ENV_CFLAGS=$CFLAGS
-ENV_LDFLAGS=$LDFLAGS
-ENV_CXXFLAGS=$CXXFLAGS
 
-# Toolchain detection
+# toolchain detection
 # this will insert make vars to config.mk
 . make/toolchain.sh
-
-# add user specified flags to config.mk
-echo "# project specific flags" >> "$TEMP_DIR/config.mk"
-if [ -n "${ENV_CFLAGS}" ]; then
-    echo "CFLAGS += $ENV_CFLAGS" >> "$TEMP_DIR/config.mk"
-fi
-if [ -n "${ENV_CXXFLAGS}" ]; then
-    echo "CXXFLAGS += $ENV_CXXFLAGS" >> "$TEMP_DIR/config.mk"
-fi
-if [ -n "${ENV_LDFLAGS}" ]; then
-    echo "LDFLAGS += $ENV_LDFLAGS" >> "$TEMP_DIR/config.mk"
+if [ -n "$TOOLCHAIN_ERROR" ]; then
+    echo "Toolchain error: $TOOLCHAIN_ERROR"
+    echo "Abort."
+    abort_configure
 fi
 
 #
 # DEPENDENCIES
 #
 
+# create buffer for make variables required by dependencies
+echo > "$TEMP_DIR/make.mk"
+
 dependency_libpq()
 {
     printf "checking for libpq... "
@@ -248,12 +207,11 @@
         if [ -z "$PKG_CONFIG" ]; then
             break
         fi
-        $PKG_CONFIG libpq
-        if [ $? -ne 0 ] ; then
+        if ! $PKG_CONFIG libpq ; then
             break
         fi
-        TEMP_CFLAGS="$TEMP_CFLAGS `$PKG_CONFIG --cflags libpq`"
-        TEMP_LDFLAGS="$TEMP_LDFLAGS `$PKG_CONFIG --libs libpq`"
+        TEMP_CFLAGS="$TEMP_CFLAGS $("$PKG_CONFIG" --cflags libpq)"
+        TEMP_LDFLAGS="$TEMP_LDFLAGS $("$PKG_CONFIG" --libs libpq)"
         echo yes
         return 0
     done
@@ -270,12 +228,11 @@
         if [ -z "$PKG_CONFIG" ]; then
             break
         fi
-        $PKG_CONFIG openssl
-        if [ $? -ne 0 ] ; then
+        if ! $PKG_CONFIG openssl ; then
             break
         fi
-        TEMP_CFLAGS="$TEMP_CFLAGS `$PKG_CONFIG --cflags openssl`"
-        TEMP_LDFLAGS="$TEMP_LDFLAGS `$PKG_CONFIG --libs openssl`"
+        TEMP_CFLAGS="$TEMP_CFLAGS $("$PKG_CONFIG" --cflags openssl)"
+        TEMP_LDFLAGS="$TEMP_LDFLAGS $("$PKG_CONFIG" --libs openssl)"
         echo yes
         return 0
     done
@@ -283,7 +240,7 @@
     # dependency openssl platform="bsd"
     while true
     do
-        if isnotplatform "bsd"; then
+        if ! isplatform "bsd"; then
             break
         fi
         TEMP_LDFLAGS="$TEMP_LDFLAGS -lssl -lcrypto"
@@ -300,18 +257,16 @@
     # dependency libxml2 platform="macos"
     while true
     do
-        if isnotplatform "macos"; then
+        if ! isplatform "macos"; then
             break
         fi
-        xml2-config --cflags > /dev/null
-        if [ $? -eq 0 ]; then
-            TEMP_CFLAGS="$TEMP_CFLAGS `xml2-config --cflags`"
+        if tmp_flags=$(xml2-config --cflags) ; then
+            TEMP_CFLAGS="$TEMP_CFLAGS $tmp_flags"
         else
             break
         fi
-        xml2-config --libs > /dev/null
-        if [ $? -eq 0 ]; then
-            TEMP_LDFLAGS="$TEMP_LDFLAGS `xml2-config --libs`"
+        if tmp_flags=$(xml2-config --libs) ; then
+            TEMP_LDFLAGS="$TEMP_LDFLAGS $tmp_flags"
         else
             break
         fi
@@ -325,12 +280,11 @@
         if [ -z "$PKG_CONFIG" ]; then
             break
         fi
-        $PKG_CONFIG libxml-2.0
-        if [ $? -ne 0 ] ; then
+        if ! $PKG_CONFIG libxml-2.0 ; then
             break
         fi
-        TEMP_CFLAGS="$TEMP_CFLAGS `$PKG_CONFIG --cflags libxml-2.0`"
-        TEMP_LDFLAGS="$TEMP_LDFLAGS `$PKG_CONFIG --libs libxml-2.0`"
+        TEMP_CFLAGS="$TEMP_CFLAGS $("$PKG_CONFIG" --cflags libxml-2.0)"
+        TEMP_LDFLAGS="$TEMP_LDFLAGS $("$PKG_CONFIG" --libs libxml-2.0)"
         echo yes
         return 0
     done
@@ -341,7 +295,7 @@
 
 DEPENDENCIES_FAILED=
 ERROR=0
-# general dependencies
+# unnamed dependencies
 TEMP_CFLAGS=
 TEMP_LDFLAGS=
 while true
@@ -349,23 +303,18 @@
     while true
     do
 
-
         break
     done
-
     break
 done
 
-# add general dependency flags to config.mk
+# add unnamed dependency flags to config.mk
 echo >> "$TEMP_DIR/config.mk"
 if [ -n "${TEMP_CFLAGS}" ]; then
-    echo "CFLAGS += $TEMP_CFLAGS" >> $TEMP_DIR/config.mk
-fi
-if [ -n "${TEMP_CXXFLAGS}" ]; then
-    echo "CXXFLAGS += $TEMP_CXXFLAGS" >> $TEMP_DIR/config.mk
+    echo "CFLAGS += $TEMP_CFLAGS" >> "$TEMP_DIR/config.mk"
 fi
 if [ -n "${TEMP_LDFLAGS}" ]; then
-    echo "LDFLAGS += $TEMP_LDFLAGS" >> $TEMP_DIR/config.mk
+    echo "LDFLAGS += $TEMP_LDFLAGS" >> "$TEMP_DIR/config.mk"
 fi
 
 #
@@ -375,22 +324,16 @@
 #
 # TARGETS
 #
-TEMP_CFLAGS=
-TEMP_CXXFLAGS=
-TEMP_LDFLAGS=
 
 # Target
 TEMP_CFLAGS=
 TEMP_LDFLAGS=
-TEMP_CXXFLAGS=
 
-dependency_libxml2
-if [ $? -ne 0 ]; then
+if ! dependency_libxml2; then
     DEPENDENCIES_FAILED="$DEPENDENCIES_FAILED libxml2 "
     ERROR=1
 fi
-dependency_openssl
-if [ $? -ne 0 ]; then
+if ! dependency_openssl; then
     DEPENDENCIES_FAILED="$DEPENDENCIES_FAILED openssl "
     ERROR=1
 fi
@@ -398,14 +341,13 @@
 # Features
 if [ -n "$FEATURE_PG" ]; then
     # check dependency
-    dependency_libpq
-    if [ $? -ne 0 ]; then
+    if ! dependency_libpq ; then
         # "auto" features can fail and are just disabled in this case
-        if [ "$FEATURE_PG" != "auto" ]; then
+        if [ "$FEATURE_PG" = "auto" ]; then
+            unset FEATURE_PG
+		else
             DEPENDENCIES_FAILED="$DEPENDENCIES_FAILED libpq "
             ERROR=1
-		else
-			unset FEATURE_PG
         fi
     fi
 fi
@@ -415,16 +357,11 @@
 if [ -n "${TEMP_CFLAGS}" ]; then
     echo "CFLAGS  += $TEMP_CFLAGS" >> "$TEMP_DIR/config.mk"
 fi
-if [ -n "${TEMP_CXXFLAGS}" ]; then
-    echo "CXXFLAGS += $TEMP_CXXFLAGS" >> "$TEMP_DIR/config.mk"
-fi
 if [ "$BUILD_TYPE" = "debug" ]; then
     echo 'CFLAGS += ${DEBUG_FLAGS}' >> "$TEMP_DIR/config.mk"
-    echo 'CXXFLAGS += ${DEBUG_FLAGS}' >> "$TEMP_DIR/config.mk"
 fi
 if [ "$BUILD_TYPE" = "release" ]; then
     echo 'CFLAGS += ${RELEASE_FLAGS}' >> "$TEMP_DIR/config.mk"
-    echo 'CXXFLAGS += ${RELEASE_FLAGS}' >> "$TEMP_DIR/config.mk"
 fi
 if [ -n "${TEMP_LDFLAGS}" ]; then
     echo "LDFLAGS += $TEMP_LDFLAGS" >> "$TEMP_DIR/config.mk"
@@ -434,8 +371,7 @@
     echo
     echo "Error: Unresolved dependencies"
     echo "$DEPENDENCIES_FAILED"
-    rm -Rf "$TEMP_DIR"
-    exit 1
+    abort_configure
 fi
 
 echo "configure finished"
--- a/src/test/resources/golden-sample/configure2	Tue Sep 12 23:36:45 2023 +0200
+++ b/src/test/resources/golden-sample/configure2	Thu Sep 14 22:59:05 2023 +0200
@@ -1,9 +1,19 @@
 #!/bin/sh
 
+# create temporary directory
+TEMP_DIR=".tmp-$(uname -n)"
+rm -Rf "$TEMP_DIR"
+if ! mkdir -p "$TEMP_DIR"; then
+    echo "Cannot create tmp dir $TEMP_DIR"
+    echo "Abort"
+    exit 1
+fi
+touch "$TEMP_DIR/options"
+touch "$TEMP_DIR/features"
 
+# define standard variables
 PREFIX=/usr
-EPREFIX=$PREFIX
-
+EPREFIX=/usr
 BINDIR=
 SBINDIR=
 LIBDIR=
@@ -16,21 +26,18 @@
 INFODIR=
 MANDIR=
 
-OS=`uname -s`
-OS_VERSION=`uname -r`
-
-TEMP_DIR=".tmp-`uname -n`"
-mkdir -p "$TEMP_DIR"
-if [ $? -ne 0 ]; then
-    echo "Cannot create tmp dir"
-    echo "Abort"
-fi
-touch "$TEMP_DIR/options"
-touch "$TEMP_DIR/features"
+# custom variables
 
 # features
 FEATURE_DB=auto
 
+# clean abort
+abort_configure()
+{
+    rm -Rf "$TEMP_DIR"
+    exit 1
+}
+
 # help text
 printhelp()
 {
@@ -87,7 +94,7 @@
         "--includedir="*)     INCLUDEDIR=${ARG#--includedir=} ;;
         "--infodir="*)        INFODIR=${ARG#--infodir=} ;;
         "--mandir"*)          MANDIR=${ARG#--mandir} ;;
-        "--help"*) printhelp; rm -Rf "$TEMP_DIR"; exit 1 ;;
+        "--help"*) printhelp; abort_configure ;;
         "--debug")           BUILD_TYPE="debug" ;;
         "--release")         BUILD_TYPE="release" ;;
         "--toolkit="*) OPT_TOOLKIT=${ARG#--toolkit=} ;;
@@ -95,54 +102,32 @@
         "--disable-db") unset FEATURE_DB ;;
         "--enable-gui") FEATURE_GUI=on ;;
         "--disable-gui") unset FEATURE_GUI ;;
-        "-"*) echo "unknown option: $ARG"; rm -Rf "$TEMP_DIR"; exit 1 ;;
+        "-"*) echo "unknown option: $ARG"; abort_configure ;;
     esac
 done
 
+
 # set dir variables
-if [ -z "$BINDIR" ]; then
-    BINDIR=$EPREFIX/bin
-fi
-if [ -z "$SBINDIR" ]; then
-    SBINDIR=$EPREFIX/sbin
-fi
-if [ -z "$LIBDIR" ]; then
-    LIBDIR=$EPREFIX/lib
-fi
-if [ -z "$LIBEXEC" ]; then
-    LIBEXECDIR=$EPREFIX/libexec
-fi
-if [ -z "$DATADIR" ]; then
-    DATADIR=$PREFIX/share
-fi
-if [ -z "$SYSCONFDIR" ]; then
-    SYSCONFDIR=$PREFIX/etc
-fi
-if [ -z "$SHAREDSTATEDIR" ]; then
-    SHAREDSTATEDIR=$PREFIX/com
-fi
-if [ -z "$LOCALSTATEDIR" ]; then
-    LOCALSTATEDIR=$PREFIX/var
-fi
-if [ -z "$INCLUDEDIR" ]; then
-    INCLUDEDIR=$PREFIX/include
-fi
-if [ -z "$INFODIR" ]; then
-    INFODIR=$PREFIX/info
-fi
-if [ -z "$MANDIR" ]; then
-    MANDIR=$PREFIX/man
-fi
+BINDIR=${BINDIR:-"$EPREFIX/bin"}
+SBINDIR=${SBINDIR:-"$EPREFIX/sbin"}
+LIBDIR=${LIBDIR:-"$EPREFIX/lib"}
+LIBEXECDIR=${LIBEXECDIR:-"$EPREFIX/libexec"}
+DATADIR=${DATADIR:-"$PREFIX/share"}
+SYSCONFDIR=${SYSCONFDIR:-"$PREFIX/etc"}
+SHAREDSTATEDIR=${SHAREDSTATEDIR:-"$PREFIX/com"}
+LOCALSTATEDIR=${LOCALSTATEDIR:-"$PREFIX/var"}
+INCLUDEDIR=${INCLUDEDIR:-"$PREFIX/include"}
+INFODIR=${INFODIR:-"$PREFIX/info"}
+MANDIR=${MANDIR:-"$PREFIX/man"}
 
-which pkg-config > /dev/null
-if [ $? -eq 0 ]; then
-    PKG_CONFIG=pkg-config
-else
-    PKG_CONFIG=false
-fi
+# Test for availability of pkg-config
+PKG_CONFIG=$(command -v pkg-config)
+PKG_CONFIG=${PKG_CONFIG:-"false"}
 
 # Simple uname based platform detection
 # $PLATFORM is used for platform dependent dependency selection
+OS=$(uname -s)
+OS_VERSION=$(uname -r)
 printf "detect platform... "
 if [ "$OS" = "SunOS" ]; then
     PLATFORM="solaris sunos unix svr4"
@@ -156,21 +141,13 @@
 if [ "$OS" = "Darwin" ]; then
     PLATFORM="macos osx bsd unix"
 fi
-echo "$OS" | grep -i "MINGW" > /dev/null
-if [ $? -eq 0 ]; then
+if echo "$OS" | grep -i "MINGW" > /dev/null; then
     PLATFORM="windows mingw"
 fi
-
-if [ -z "$PLATFORM" ]; then
-    PLATFORM="unix"
-fi
+PLATFORM=${PLATFORM:-"unix"}
 
-for p in $PLATFORM
-do
-    PLATFORM_NAME=$p
-    break
-done
-echo $PLATFORM_NAME
+PLATFORM_NAME=$(echo "$PLATFORM" | cut -f1 -d' ' -)
+echo "$PLATFORM_NAME"
 
 isplatform()
 {
@@ -182,28 +159,12 @@
     done
     return 1
 }
-isnotplatform()
-{
-    for p in $PLATFORM
-    do
-        if [ "$p" = "$1" ]; then
-            return 1
-        fi
-    done
-    return 0
-}
+
 
-# generate config.mk and config.h
-cat > "$TEMP_DIR/config.mk" << __EOF__
-#
-# config.mk generated by configure
-#
-
-# general vars
-
+# generate config.mk
+cat > "$TEMP_DIR/vars.mk" << __EOF__
 PREFIX=$PREFIX
 EPREFIX=$EPREFIX
-
 BINDIR=$BINDIR
 SBINDIR=$SBINDIR
 LIBDIR=$LIBDIR
@@ -215,44 +176,39 @@
 INCLUDEDIR=$INCLUDEDIR
 INFODIR=$INFODIR
 MANDIR=$MANDIR
-
 __EOF__
-
-echo > "$TEMP_DIR/make.mk"
+cat > "$TEMP_DIR/config.mk" << __EOF__
+#
+# config.mk generated by configure
+#
+__EOF__
+sort -u "$TEMP_DIR/vars.mk" >> "$TEMP_DIR/config.mk"
 
-ENV_CFLAGS=$CFLAGS
-ENV_LDFLAGS=$LDFLAGS
-ENV_CXXFLAGS=$CXXFLAGS
 
-# Toolchain detection
+# toolchain detection
 # this will insert make vars to config.mk
 . make/toolchain.sh
-
-# add user specified flags to config.mk
-echo "# project specific flags" >> "$TEMP_DIR/config.mk"
-if [ -n "${ENV_CFLAGS}" ]; then
-    echo "CFLAGS += $ENV_CFLAGS" >> "$TEMP_DIR/config.mk"
-fi
-if [ -n "${ENV_CXXFLAGS}" ]; then
-    echo "CXXFLAGS += $ENV_CXXFLAGS" >> "$TEMP_DIR/config.mk"
-fi
-if [ -n "${ENV_LDFLAGS}" ]; then
-    echo "LDFLAGS += $ENV_LDFLAGS" >> "$TEMP_DIR/config.mk"
+if [ -n "$TOOLCHAIN_ERROR" ]; then
+    echo "Toolchain error: $TOOLCHAIN_ERROR"
+    echo "Abort."
+    abort_configure
 fi
 
 #
 # DEPENDENCIES
 #
 
+# create buffer for make variables required by dependencies
+echo > "$TEMP_DIR/make.mk"
+
 dependency_qt4()
 {
     printf "checking for qt4... "
     # dependency qt4
     while true
     do
-        which qmake-qt4 > /dev/null
-        if [ $? -ne 0 ]; then
-        break
+        if ! which qmake-qt4 > /dev/null ; then
+            break
         fi
         echo yes
         return 0
@@ -267,7 +223,7 @@
     # dependency curl platform="windows"
     while true
     do
-        if isnotplatform "windows"; then
+        if ! isplatform "windows"; then
             break
         fi
         TEMP_CFLAGS="$TEMP_CFLAGS -I/mingw/include"
@@ -279,18 +235,16 @@
     # dependency curl platform="macos"
     while true
     do
-        if isnotplatform "macos"; then
+        if ! isplatform "macos"; then
             break
         fi
-        curl-config --cflags > /dev/null
-        if [ $? -eq 0 ]; then
-            TEMP_CFLAGS="$TEMP_CFLAGS `curl-config --cflags`"
+        if tmp_flags=$(curl-config --cflags) ; then
+            TEMP_CFLAGS="$TEMP_CFLAGS $tmp_flags"
         else
             break
         fi
-        curl-config --ldflags > /dev/null
-        if [ $? -eq 0 ]; then
-            TEMP_LDFLAGS="$TEMP_LDFLAGS `curl-config --ldflags`"
+        if tmp_flags=$(curl-config --ldflags) ; then
+            TEMP_LDFLAGS="$TEMP_LDFLAGS $tmp_flags"
         else
             break
         fi
@@ -304,12 +258,11 @@
         if [ -z "$PKG_CONFIG" ]; then
             break
         fi
-        $PKG_CONFIG libcurl
-        if [ $? -ne 0 ] ; then
+        if ! $PKG_CONFIG libcurl ; then
             break
         fi
-        TEMP_CFLAGS="$TEMP_CFLAGS `$PKG_CONFIG --cflags libcurl`"
-        TEMP_LDFLAGS="$TEMP_LDFLAGS `$PKG_CONFIG --libs libcurl`"
+        TEMP_CFLAGS="$TEMP_CFLAGS $("$PKG_CONFIG" --cflags libcurl)"
+        TEMP_LDFLAGS="$TEMP_LDFLAGS $("$PKG_CONFIG" --libs libcurl)"
         echo yes
         return 0
     done
@@ -326,12 +279,11 @@
         if [ -z "$PKG_CONFIG" ]; then
             break
         fi
-        $PKG_CONFIG gtk+-2.0
-        if [ $? -ne 0 ] ; then
+        if ! $PKG_CONFIG gtk+-2.0 ; then
             break
         fi
-        TEMP_CFLAGS="$TEMP_CFLAGS `$PKG_CONFIG --cflags gtk+-2.0`"
-        TEMP_LDFLAGS="$TEMP_LDFLAGS `$PKG_CONFIG --libs gtk+-2.0`"
+        TEMP_CFLAGS="$TEMP_CFLAGS $("$PKG_CONFIG" --cflags gtk+-2.0)"
+        TEMP_LDFLAGS="$TEMP_LDFLAGS $("$PKG_CONFIG" --libs gtk+-2.0)"
         echo yes
         return 0
     done
@@ -348,12 +300,11 @@
         if [ -z "$PKG_CONFIG" ]; then
             break
         fi
-        $PKG_CONFIG sqlite3
-        if [ $? -ne 0 ] ; then
+        if ! $PKG_CONFIG sqlite3 ; then
             break
         fi
-        TEMP_CFLAGS="$TEMP_CFLAGS `$PKG_CONFIG --cflags sqlite3`"
-        TEMP_LDFLAGS="$TEMP_LDFLAGS `$PKG_CONFIG --libs sqlite3`"
+        TEMP_CFLAGS="$TEMP_CFLAGS $("$PKG_CONFIG" --cflags sqlite3)"
+        TEMP_LDFLAGS="$TEMP_LDFLAGS $("$PKG_CONFIG" --libs sqlite3)"
         echo yes
         return 0
     done
@@ -367,7 +318,7 @@
     # dependency test platform="bsd"
     while true
     do
-        if isnotplatform "bsd"; then
+        if ! isplatform "bsd"; then
             break
         fi
         if isplatform "macos"; then
@@ -398,12 +349,11 @@
         if [ -z "$PKG_CONFIG" ]; then
             break
         fi
-        $PKG_CONFIG gtk+-5.0
-        if [ $? -ne 0 ] ; then
+        if ! $PKG_CONFIG gtk+-5.0 ; then
             break
         fi
-        TEMP_CFLAGS="$TEMP_CFLAGS `$PKG_CONFIG --cflags gtk+-5.0`"
-        TEMP_LDFLAGS="$TEMP_LDFLAGS `$PKG_CONFIG --libs gtk+-5.0`"
+        TEMP_CFLAGS="$TEMP_CFLAGS $("$PKG_CONFIG" --cflags gtk+-5.0)"
+        TEMP_LDFLAGS="$TEMP_LDFLAGS $("$PKG_CONFIG" --libs gtk+-5.0)"
         echo yes
         return 0
     done
@@ -434,12 +384,11 @@
         if [ -z "$PKG_CONFIG" ]; then
             break
         fi
-        $PKG_CONFIG --atleast-version=2.8 libxml-2.0
-        if [ $? -ne 0 ] ; then
+        if ! $PKG_CONFIG --atleast-version=2.8 libxml-2.0 ; then
             break
         fi
-        TEMP_CFLAGS="$TEMP_CFLAGS `$PKG_CONFIG --cflags libxml-2.0`"
-        TEMP_LDFLAGS="$TEMP_LDFLAGS `$PKG_CONFIG --libs libxml-2.0`"
+        TEMP_CFLAGS="$TEMP_CFLAGS $("$PKG_CONFIG" --cflags libxml-2.0)"
+        TEMP_LDFLAGS="$TEMP_LDFLAGS $("$PKG_CONFIG" --libs libxml-2.0)"
         cat >> $TEMP_DIR/make.mk << __EOF__
 # Dependency: libxml2
 xml = libxml2
@@ -455,7 +404,7 @@
 
 DEPENDENCIES_FAILED=
 ERROR=0
-# general dependencies
+# unnamed dependencies
 TEMP_CFLAGS=
 TEMP_LDFLAGS=
 while true
@@ -468,23 +417,18 @@
 MVAR += 123
 
 __EOF__
-
         break
     done
-
     break
 done
 
-# add general dependency flags to config.mk
+# add unnamed dependency flags to config.mk
 echo >> "$TEMP_DIR/config.mk"
 if [ -n "${TEMP_CFLAGS}" ]; then
-    echo "CFLAGS += $TEMP_CFLAGS" >> $TEMP_DIR/config.mk
-fi
-if [ -n "${TEMP_CXXFLAGS}" ]; then
-    echo "CXXFLAGS += $TEMP_CXXFLAGS" >> $TEMP_DIR/config.mk
+    echo "CFLAGS += $TEMP_CFLAGS" >> "$TEMP_DIR/config.mk"
 fi
 if [ -n "${TEMP_LDFLAGS}" ]; then
-    echo "LDFLAGS += $TEMP_LDFLAGS" >> $TEMP_DIR/config.mk
+    echo "LDFLAGS += $TEMP_LDFLAGS" >> "$TEMP_DIR/config.mk"
 fi
 
 #
@@ -493,8 +437,7 @@
 checkopt_toolkit_gtk3()
 {
     VERR=0
-    dependency_gtk3
-    if [ $? -ne 0 ]; then
+    if ! dependency_gtk3 ; then
         VERR=1
     fi
     if [ $VERR -ne 0 ]; then
@@ -510,12 +453,10 @@
 checkopt_toolkit_cli()
 {
     VERR=0
-    dependency_curl
-    if [ $? -ne 0 ]; then
+    if ! dependency_curl ; then
         VERR=1
     fi
-    dependency_test
-    if [ $? -ne 0 ]; then
+    if ! dependency_test ; then
         VERR=1
     fi
     if [ $VERR -ne 0 ]; then
@@ -526,8 +467,7 @@
 checkopt_toolkit_gtk2()
 {
     VERR=0
-    dependency_gtk2
-    if [ $? -ne 0 ]; then
+    if ! dependency_gtk2 ; then
         VERR=1
     fi
     if [ $VERR -ne 0 ]; then
@@ -538,8 +478,7 @@
 checkopt_toolkit_wpf()
 {
     VERR=0
-    dependency_test
-    if [ $? -ne 0 ]; then
+    if ! dependency_test ; then
         VERR=1
     fi
     if [ $VERR -ne 0 ]; then
@@ -551,27 +490,20 @@
 #
 # TARGETS
 #
-TEMP_CFLAGS=
-TEMP_CXXFLAGS=
-TEMP_LDFLAGS=
 
 # Target: dav
 TEMP_CFLAGS=
 TEMP_LDFLAGS=
-TEMP_CXXFLAGS=
 
-dependency_curl
-if [ $? -ne 0 ]; then
+if ! dependency_curl; then
     DEPENDENCIES_FAILED="$DEPENDENCIES_FAILED curl "
     ERROR=1
 fi
-dependency_libxml2
-if [ $? -ne 0 ]; then
+if ! dependency_libxml2; then
     DEPENDENCIES_FAILED="$DEPENDENCIES_FAILED libxml2 "
     ERROR=1
 fi
-dependency_test
-if [ $? -ne 0 ]; then
+if ! dependency_test; then
     DEPENDENCIES_FAILED="$DEPENDENCIES_FAILED test "
     ERROR=1
 fi
@@ -579,27 +511,25 @@
 # Features
 if [ -n "$FEATURE_DB" ]; then
     # check dependency
-    dependency_sqlite
-    if [ $? -ne 0 ]; then
+    if ! dependency_sqlite ; then
         # "auto" features can fail and are just disabled in this case
-        if [ "$FEATURE_DB" != "auto" ]; then
+        if [ "$FEATURE_DB" = "auto" ]; then
+            unset FEATURE_DB
+		else
             DEPENDENCIES_FAILED="$DEPENDENCIES_FAILED sqlite "
             ERROR=1
-		else
-			unset FEATURE_DB
         fi
     fi
 fi
 if [ -n "$FEATURE_GUI" ]; then
     # check dependency
-    dependency_gtk3
-    if [ $? -ne 0 ]; then
+    if ! dependency_gtk3 ; then
         # "auto" features can fail and are just disabled in this case
-        if [ "$FEATURE_GUI" != "auto" ]; then
+        if [ "$FEATURE_GUI" = "auto" ]; then
+            unset FEATURE_GUI
+		else
             DEPENDENCIES_FAILED="$DEPENDENCIES_FAILED gtk3 "
             ERROR=1
-		else
-			unset FEATURE_GUI
         fi
     fi
 fi
@@ -608,25 +538,22 @@
 if [ -z $OPT_TOOLKIT ]; then
     SAVED_ERROR="$ERROR"
     SAVED_DEPENDENCIES_FAILED="$DEPENDENCIES_FAILED"
-    ERROR=0
+    ERROR=1
     while true
     do
         if isplatform "windows"; then
-        checkopt_toolkit_wpf
-        if [ $? -eq 0 ]; then
+        if checkopt_toolkit_wpf ; then
             echo "  toolkit: wpf" >> "$TEMP_DIR/options"
             ERROR=0
             break
         fi
         fi
-        checkopt_toolkit_gtk3
-        if [ $? -eq 0 ]; then
+        if checkopt_toolkit_gtk3 ; then
             echo "  toolkit: gtk3" >> "$TEMP_DIR/options"
             ERROR=0
             break
         fi
-        checkopt_toolkit_gtk2
-        if [ $? -eq 0 ]; then
+        if checkopt_toolkit_gtk2 ; then
             echo "  toolkit: gtk2" >> "$TEMP_DIR/options"
             ERROR=0
             break
@@ -643,26 +570,22 @@
         false
     elif [ "$OPT_TOOLKIT" = "gtk3" ]; then
         echo "  toolkit: $OPT_TOOLKIT" >> $TEMP_DIR/options
-        checkopt_toolkit_gtk3
-        if [ $? -ne 0 ]; then
+        if ! checkopt_toolkit_gtk3 ; then
             ERROR=1
         fi
     elif [ "$OPT_TOOLKIT" = "cli" ]; then
         echo "  toolkit: $OPT_TOOLKIT" >> $TEMP_DIR/options
-        checkopt_toolkit_cli
-        if [ $? -ne 0 ]; then
+        if ! checkopt_toolkit_cli ; then
             ERROR=1
         fi
     elif [ "$OPT_TOOLKIT" = "gtk2" ]; then
         echo "  toolkit: $OPT_TOOLKIT" >> $TEMP_DIR/options
-        checkopt_toolkit_gtk2
-        if [ $? -ne 0 ]; then
+        if ! checkopt_toolkit_gtk2 ; then
             ERROR=1
         fi
     elif [ "$OPT_TOOLKIT" = "wpf" ]; then
         echo "  toolkit: $OPT_TOOLKIT" >> $TEMP_DIR/options
-        checkopt_toolkit_wpf
-        if [ $? -ne 0 ]; then
+        if ! checkopt_toolkit_wpf ; then
             ERROR=1
         fi
     fi
@@ -672,16 +595,11 @@
 if [ -n "${TEMP_CFLAGS}" ]; then
     echo "DAV_CFLAGS  += $TEMP_CFLAGS" >> "$TEMP_DIR/config.mk"
 fi
-if [ -n "${TEMP_CXXFLAGS}" ]; then
-    echo "DAV_CXXFLAGS += $TEMP_CXXFLAGS" >> "$TEMP_DIR/config.mk"
-fi
 if [ "$BUILD_TYPE" = "debug" ]; then
     echo 'DAV_CFLAGS += ${DEBUG_FLAGS}' >> "$TEMP_DIR/config.mk"
-    echo 'DAV_CXXFLAGS += ${DEBUG_FLAGS}' >> "$TEMP_DIR/config.mk"
 fi
 if [ "$BUILD_TYPE" = "release" ]; then
     echo 'DAV_CFLAGS += ${RELEASE_FLAGS}' >> "$TEMP_DIR/config.mk"
-    echo 'DAV_CXXFLAGS += ${RELEASE_FLAGS}' >> "$TEMP_DIR/config.mk"
 fi
 if [ -n "${TEMP_LDFLAGS}" ]; then
     echo "DAV_LDFLAGS += $TEMP_LDFLAGS" >> "$TEMP_DIR/config.mk"
@@ -690,10 +608,8 @@
 # Target
 TEMP_CFLAGS=
 TEMP_LDFLAGS=
-TEMP_CXXFLAGS=
 
-dependency_deptest
-if [ $? -ne 0 ]; then
+if ! dependency_deptest; then
     DEPENDENCIES_FAILED="$DEPENDENCIES_FAILED deptest "
     ERROR=1
 fi
@@ -705,16 +621,11 @@
 if [ -n "${TEMP_CFLAGS}" ]; then
     echo "CFLAGS  += $TEMP_CFLAGS" >> "$TEMP_DIR/config.mk"
 fi
-if [ -n "${TEMP_CXXFLAGS}" ]; then
-    echo "CXXFLAGS += $TEMP_CXXFLAGS" >> "$TEMP_DIR/config.mk"
-fi
 if [ "$BUILD_TYPE" = "debug" ]; then
     echo 'CFLAGS += ${DEBUG_FLAGS}' >> "$TEMP_DIR/config.mk"
-    echo 'CXXFLAGS += ${DEBUG_FLAGS}' >> "$TEMP_DIR/config.mk"
 fi
 if [ "$BUILD_TYPE" = "release" ]; then
     echo 'CFLAGS += ${RELEASE_FLAGS}' >> "$TEMP_DIR/config.mk"
-    echo 'CXXFLAGS += ${RELEASE_FLAGS}' >> "$TEMP_DIR/config.mk"
 fi
 if [ -n "${TEMP_LDFLAGS}" ]; then
     echo "LDFLAGS += $TEMP_LDFLAGS" >> "$TEMP_DIR/config.mk"
@@ -724,8 +635,7 @@
     echo
     echo "Error: Unresolved dependencies"
     echo "$DEPENDENCIES_FAILED"
-    rm -Rf "$TEMP_DIR"
-    exit 1
+    abort_configure
 fi
 
 echo "configure finished"
--- a/test/configure	Tue Sep 12 23:36:45 2023 +0200
+++ b/test/configure	Thu Sep 14 22:59:05 2023 +0200
@@ -1,11 +1,19 @@
 #!/bin/sh
 
-HOST=`uname -n`
-PREFIX=`pwd`/work
-INSTALL_DIR=$PREFIX
+# create temporary directory
+TEMP_DIR=".tmp-$(uname -n)"
+rm -Rf "$TEMP_DIR"
+if ! mkdir -p "$TEMP_DIR"; then
+    echo "Cannot create tmp dir $TEMP_DIR"
+    echo "Abort"
+    exit 1
+fi
+touch "$TEMP_DIR/options"
+touch "$TEMP_DIR/features"
 
-EPREFIX=$PREFIX
-
+# define standard variables
+PREFIX=/usr
+EPREFIX=/usr
 BINDIR=
 SBINDIR=
 LIBDIR=
@@ -18,21 +26,21 @@
 INFODIR=
 MANDIR=
 
-OS=`uname -s`
-OS_VERSION=`uname -r`
-
-TEMP_DIR=".tmp-`uname -n`"
-mkdir -p "$TEMP_DIR"
-if [ $? -ne 0 ]; then
-    echo "Cannot create tmp dir"
-    echo "Abort"
-fi
-touch "$TEMP_DIR/options"
-touch "$TEMP_DIR/features"
+# custom variables
+HOST=$(uname -n)
+PREFIX=$(pwd)/work
+INSTALL_DIR=$PREFIX
 
 # features
 FEATURE_PG=auto
 
+# clean abort
+abort_configure()
+{
+    rm -Rf "$TEMP_DIR"
+    exit 1
+}
+
 # help text
 printhelp()
 {
@@ -83,59 +91,37 @@
         "--includedir="*)     INCLUDEDIR=${ARG#--includedir=} ;;
         "--infodir="*)        INFODIR=${ARG#--infodir=} ;;
         "--mandir"*)          MANDIR=${ARG#--mandir} ;;
-        "--help"*) printhelp; rm -Rf "$TEMP_DIR"; exit 1 ;;
+        "--help"*) printhelp; abort_configure ;;
         "--debug")           BUILD_TYPE="debug" ;;
         "--release")         BUILD_TYPE="release" ;;
         "--enable-pg") FEATURE_PG=on ;;
         "--disable-pg") unset FEATURE_PG ;;
-        "-"*) echo "unknown option: $ARG"; rm -Rf "$TEMP_DIR"; exit 1 ;;
+        "-"*) echo "unknown option: $ARG"; abort_configure ;;
     esac
 done
 
+
 # set dir variables
-if [ -z "$BINDIR" ]; then
-    BINDIR=$EPREFIX/bin
-fi
-if [ -z "$SBINDIR" ]; then
-    SBINDIR=$EPREFIX/sbin
-fi
-if [ -z "$LIBDIR" ]; then
-    LIBDIR=$EPREFIX/lib
-fi
-if [ -z "$LIBEXEC" ]; then
-    LIBEXECDIR=$EPREFIX/libexec
-fi
-if [ -z "$DATADIR" ]; then
-    DATADIR=$PREFIX/share
-fi
-if [ -z "$SYSCONFDIR" ]; then
-    SYSCONFDIR=$PREFIX/etc
-fi
-if [ -z "$SHAREDSTATEDIR" ]; then
-    SHAREDSTATEDIR=$PREFIX/com
-fi
-if [ -z "$LOCALSTATEDIR" ]; then
-    LOCALSTATEDIR=$PREFIX/var
-fi
-if [ -z "$INCLUDEDIR" ]; then
-    INCLUDEDIR=$PREFIX/include
-fi
-if [ -z "$INFODIR" ]; then
-    INFODIR=$PREFIX/info
-fi
-if [ -z "$MANDIR" ]; then
-    MANDIR=$PREFIX/man
-fi
+BINDIR=${BINDIR:-"$EPREFIX/bin"}
+SBINDIR=${SBINDIR:-"$EPREFIX/sbin"}
+LIBDIR=${LIBDIR:-"$EPREFIX/lib"}
+LIBEXECDIR=${LIBEXECDIR:-"$EPREFIX/libexec"}
+DATADIR=${DATADIR:-"$PREFIX/share"}
+SYSCONFDIR=${SYSCONFDIR:-"$PREFIX/etc"}
+SHAREDSTATEDIR=${SHAREDSTATEDIR:-"$PREFIX/com"}
+LOCALSTATEDIR=${LOCALSTATEDIR:-"$PREFIX/var"}
+INCLUDEDIR=${INCLUDEDIR:-"$PREFIX/include"}
+INFODIR=${INFODIR:-"$PREFIX/info"}
+MANDIR=${MANDIR:-"$PREFIX/man"}
 
-which pkg-config > /dev/null
-if [ $? -eq 0 ]; then
-    PKG_CONFIG=pkg-config
-else
-    PKG_CONFIG=false
-fi
+# Test for availability of pkg-config
+PKG_CONFIG=$(command -v pkg-config)
+PKG_CONFIG=${PKG_CONFIG:-"false"}
 
 # Simple uname based platform detection
 # $PLATFORM is used for platform dependent dependency selection
+OS=$(uname -s)
+OS_VERSION=$(uname -r)
 printf "detect platform... "
 if [ "$OS" = "SunOS" ]; then
     PLATFORM="solaris sunos unix svr4"
@@ -149,21 +135,13 @@
 if [ "$OS" = "Darwin" ]; then
     PLATFORM="macos osx bsd unix"
 fi
-echo "$OS" | grep -i "MINGW" > /dev/null
-if [ $? -eq 0 ]; then
+if echo "$OS" | grep -i "MINGW" > /dev/null; then
     PLATFORM="windows mingw"
 fi
-
-if [ -z "$PLATFORM" ]; then
-    PLATFORM="unix"
-fi
+PLATFORM=${PLATFORM:-"unix"}
 
-for p in $PLATFORM
-do
-    PLATFORM_NAME=$p
-    break
-done
-echo $PLATFORM_NAME
+PLATFORM_NAME=$(echo "$PLATFORM" | cut -f1 -d' ' -)
+echo "$PLATFORM_NAME"
 
 isplatform()
 {
@@ -175,30 +153,12 @@
     done
     return 1
 }
-isnotplatform()
-{
-    for p in $PLATFORM
-    do
-        if [ "$p" = "$1" ]; then
-            return 1
-        fi
-    done
-    return 0
-}
+
 
-# generate config.mk and config.h
-cat > "$TEMP_DIR/config.mk" << __EOF__
-#
-# config.mk generated by configure
-#
-
-# general vars
-HOST=$HOST
+# generate config.mk
+cat > "$TEMP_DIR/vars.mk" << __EOF__
 PREFIX=$PREFIX
-INSTALL_DIR=$INSTALL_DIR
-
 EPREFIX=$EPREFIX
-
 BINDIR=$BINDIR
 SBINDIR=$SBINDIR
 LIBDIR=$LIBDIR
@@ -210,35 +170,34 @@
 INCLUDEDIR=$INCLUDEDIR
 INFODIR=$INFODIR
 MANDIR=$MANDIR
-
+HOST=$HOST
+PREFIX=$PREFIX
+INSTALL_DIR=$INSTALL_DIR
 __EOF__
-
-echo > "$TEMP_DIR/make.mk"
+cat > "$TEMP_DIR/config.mk" << __EOF__
+#
+# config.mk generated by configure
+#
+__EOF__
+sort -u "$TEMP_DIR/vars.mk" >> "$TEMP_DIR/config.mk"
 
-ENV_CFLAGS=$CFLAGS
-ENV_LDFLAGS=$LDFLAGS
-ENV_CXXFLAGS=$CXXFLAGS
 
-# Toolchain detection
+# toolchain detection
 # this will insert make vars to config.mk
 . make/toolchain.sh
-
-# add user specified flags to config.mk
-echo "# project specific flags" >> "$TEMP_DIR/config.mk"
-if [ -n "${ENV_CFLAGS}" ]; then
-    echo "CFLAGS += $ENV_CFLAGS" >> "$TEMP_DIR/config.mk"
-fi
-if [ -n "${ENV_CXXFLAGS}" ]; then
-    echo "CXXFLAGS += $ENV_CXXFLAGS" >> "$TEMP_DIR/config.mk"
-fi
-if [ -n "${ENV_LDFLAGS}" ]; then
-    echo "LDFLAGS += $ENV_LDFLAGS" >> "$TEMP_DIR/config.mk"
+if [ -n "$TOOLCHAIN_ERROR" ]; then
+    echo "Toolchain error: $TOOLCHAIN_ERROR"
+    echo "Abort."
+    abort_configure
 fi
 
 #
 # DEPENDENCIES
 #
 
+# create buffer for make variables required by dependencies
+echo > "$TEMP_DIR/make.mk"
+
 dependency_libpq()
 {
     printf "checking for libpq... "
@@ -248,12 +207,11 @@
         if [ -z "$PKG_CONFIG" ]; then
             break
         fi
-        $PKG_CONFIG libpq
-        if [ $? -ne 0 ] ; then
+        if ! $PKG_CONFIG libpq ; then
             break
         fi
-        TEMP_CFLAGS="$TEMP_CFLAGS `$PKG_CONFIG --cflags libpq`"
-        TEMP_LDFLAGS="$TEMP_LDFLAGS `$PKG_CONFIG --libs libpq`"
+        TEMP_CFLAGS="$TEMP_CFLAGS $("$PKG_CONFIG" --cflags libpq)"
+        TEMP_LDFLAGS="$TEMP_LDFLAGS $("$PKG_CONFIG" --libs libpq)"
         echo yes
         return 0
     done
@@ -270,12 +228,11 @@
         if [ -z "$PKG_CONFIG" ]; then
             break
         fi
-        $PKG_CONFIG openssl
-        if [ $? -ne 0 ] ; then
+        if ! $PKG_CONFIG openssl ; then
             break
         fi
-        TEMP_CFLAGS="$TEMP_CFLAGS `$PKG_CONFIG --cflags openssl`"
-        TEMP_LDFLAGS="$TEMP_LDFLAGS `$PKG_CONFIG --libs openssl`"
+        TEMP_CFLAGS="$TEMP_CFLAGS $("$PKG_CONFIG" --cflags openssl)"
+        TEMP_LDFLAGS="$TEMP_LDFLAGS $("$PKG_CONFIG" --libs openssl)"
         echo yes
         return 0
     done
@@ -283,7 +240,7 @@
     # dependency openssl platform="bsd"
     while true
     do
-        if isnotplatform "bsd"; then
+        if ! isplatform "bsd"; then
             break
         fi
         TEMP_LDFLAGS="$TEMP_LDFLAGS -lssl -lcrypto"
@@ -300,18 +257,16 @@
     # dependency libxml2 platform="macos"
     while true
     do
-        if isnotplatform "macos"; then
+        if ! isplatform "macos"; then
             break
         fi
-        xml2-config --cflags > /dev/null
-        if [ $? -eq 0 ]; then
-            TEMP_CFLAGS="$TEMP_CFLAGS `xml2-config --cflags`"
+        if tmp_flags=$(xml2-config --cflags) ; then
+            TEMP_CFLAGS="$TEMP_CFLAGS $tmp_flags"
         else
             break
         fi
-        xml2-config --libs > /dev/null
-        if [ $? -eq 0 ]; then
-            TEMP_LDFLAGS="$TEMP_LDFLAGS `xml2-config --libs`"
+        if tmp_flags=$(xml2-config --libs) ; then
+            TEMP_LDFLAGS="$TEMP_LDFLAGS $tmp_flags"
         else
             break
         fi
@@ -325,12 +280,11 @@
         if [ -z "$PKG_CONFIG" ]; then
             break
         fi
-        $PKG_CONFIG libxml-2.0
-        if [ $? -ne 0 ] ; then
+        if ! $PKG_CONFIG libxml-2.0 ; then
             break
         fi
-        TEMP_CFLAGS="$TEMP_CFLAGS `$PKG_CONFIG --cflags libxml-2.0`"
-        TEMP_LDFLAGS="$TEMP_LDFLAGS `$PKG_CONFIG --libs libxml-2.0`"
+        TEMP_CFLAGS="$TEMP_CFLAGS $("$PKG_CONFIG" --cflags libxml-2.0)"
+        TEMP_LDFLAGS="$TEMP_LDFLAGS $("$PKG_CONFIG" --libs libxml-2.0)"
         echo yes
         return 0
     done
@@ -341,7 +295,7 @@
 
 DEPENDENCIES_FAILED=
 ERROR=0
-# general dependencies
+# unnamed dependencies
 TEMP_CFLAGS=
 TEMP_LDFLAGS=
 while true
@@ -349,23 +303,18 @@
     while true
     do
 
-
         break
     done
-
     break
 done
 
-# add general dependency flags to config.mk
+# add unnamed dependency flags to config.mk
 echo >> "$TEMP_DIR/config.mk"
 if [ -n "${TEMP_CFLAGS}" ]; then
-    echo "CFLAGS += $TEMP_CFLAGS" >> $TEMP_DIR/config.mk
-fi
-if [ -n "${TEMP_CXXFLAGS}" ]; then
-    echo "CXXFLAGS += $TEMP_CXXFLAGS" >> $TEMP_DIR/config.mk
+    echo "CFLAGS += $TEMP_CFLAGS" >> "$TEMP_DIR/config.mk"
 fi
 if [ -n "${TEMP_LDFLAGS}" ]; then
-    echo "LDFLAGS += $TEMP_LDFLAGS" >> $TEMP_DIR/config.mk
+    echo "LDFLAGS += $TEMP_LDFLAGS" >> "$TEMP_DIR/config.mk"
 fi
 
 #
@@ -375,22 +324,16 @@
 #
 # TARGETS
 #
-TEMP_CFLAGS=
-TEMP_CXXFLAGS=
-TEMP_LDFLAGS=
 
 # Target
 TEMP_CFLAGS=
 TEMP_LDFLAGS=
-TEMP_CXXFLAGS=
 
-dependency_libxml2
-if [ $? -ne 0 ]; then
+if ! dependency_libxml2; then
     DEPENDENCIES_FAILED="$DEPENDENCIES_FAILED libxml2 "
     ERROR=1
 fi
-dependency_openssl
-if [ $? -ne 0 ]; then
+if ! dependency_openssl; then
     DEPENDENCIES_FAILED="$DEPENDENCIES_FAILED openssl "
     ERROR=1
 fi
@@ -398,14 +341,13 @@
 # Features
 if [ -n "$FEATURE_PG" ]; then
     # check dependency
-    dependency_libpq
-    if [ $? -ne 0 ]; then
+    if ! dependency_libpq ; then
         # "auto" features can fail and are just disabled in this case
-        if [ "$FEATURE_PG" != "auto" ]; then
+        if [ "$FEATURE_PG" = "auto" ]; then
+            unset FEATURE_PG
+		else
             DEPENDENCIES_FAILED="$DEPENDENCIES_FAILED libpq "
             ERROR=1
-		else
-			unset FEATURE_PG
         fi
     fi
 fi
@@ -415,16 +357,11 @@
 if [ -n "${TEMP_CFLAGS}" ]; then
     echo "CFLAGS  += $TEMP_CFLAGS" >> "$TEMP_DIR/config.mk"
 fi
-if [ -n "${TEMP_CXXFLAGS}" ]; then
-    echo "CXXFLAGS += $TEMP_CXXFLAGS" >> "$TEMP_DIR/config.mk"
-fi
 if [ "$BUILD_TYPE" = "debug" ]; then
     echo 'CFLAGS += ${DEBUG_FLAGS}' >> "$TEMP_DIR/config.mk"
-    echo 'CXXFLAGS += ${DEBUG_FLAGS}' >> "$TEMP_DIR/config.mk"
 fi
 if [ "$BUILD_TYPE" = "release" ]; then
     echo 'CFLAGS += ${RELEASE_FLAGS}' >> "$TEMP_DIR/config.mk"
-    echo 'CXXFLAGS += ${RELEASE_FLAGS}' >> "$TEMP_DIR/config.mk"
 fi
 if [ -n "${TEMP_LDFLAGS}" ]; then
     echo "LDFLAGS += $TEMP_LDFLAGS" >> "$TEMP_DIR/config.mk"
@@ -434,8 +371,7 @@
     echo
     echo "Error: Unresolved dependencies"
     echo "$DEPENDENCIES_FAILED"
-    rm -Rf "$TEMP_DIR"
-    exit 1
+    abort_configure
 fi
 
 echo "configure finished"
--- a/test/make/configure.vm	Tue Sep 12 23:36:45 2023 +0200
+++ b/test/make/configure.vm	Thu Sep 14 22:59:05 2023 +0200
@@ -1,66 +1,40 @@
 #!/bin/sh
 
+# create temporary directory
+TEMP_DIR=".tmp-$(uname -n)"
+rm -Rf "$TEMP_DIR"
+if ! mkdir -p "$TEMP_DIR"; then
+    echo "Cannot create tmp dir $TEMP_DIR"
+    echo "Abort"
+    exit 1
+fi
+touch "$TEMP_DIR/options"
+touch "$TEMP_DIR/features"
+
+# define standard variables
+PREFIX=/usr
+EPREFIX=/usr
+BINDIR=
+SBINDIR=
+LIBDIR=
+LIBEXECDIR=
+DATADIR=
+SYSCONFDIR=
+SHAREDSTATEDIR=
+LOCALSTATEDIR=
+INCLUDEDIR=
+INFODIR=
+MANDIR=
+
+# custom variables
 #foreach( $var in $vars )
 #if( $var.exec )
-${var.varName}=`${var.value}`
+${var.varName}=$(${var.value})
 #else
 ${var.varName}=${var.value}
 #end
 #end
 
-#if ( ! $project.hasVar("PREFIX") )
-PREFIX=/usr
-#end
-#if ( ! $project.hasVar("EPREFIX") )
-EPREFIX=$PREFIX
-#end
-
-#if ( ! $project.hasVar("BINDIR") )
-BINDIR=
-#end
-#if ( ! $project.hasVar("SBINDIR") )
-SBINDIR=
-#end
-#if ( ! $project.hasVar("LIBDIR") )
-LIBDIR=
-#end
-#if ( ! $project.hasVar("LIBEXECDIR") )
-LIBEXECDIR=
-#end
-#if ( ! $project.hasVar("DATADIR") )
-DATADIR=
-#end
-#if ( ! $project.hasVar("SYSCONFDIR") )
-SYSCONFDIR=
-#end
-#if ( ! $project.hasVar("SHAREDSTATEDIR") )
-SHAREDSTATEDIR=
-#end
-#if ( ! $project.hasVar("LOCALSTATEDIR") )
-LOCALSTATEDIR=
-#end
-#if ( ! $project.hasVar("INCLUDEDIR") )
-INCLUDEDIR=
-#end
-#if ( ! $project.hasVar("INFODIR") )
-INFODIR=
-#end
-#if ( ! $project.hasVar("MANDIR") )
-MANDIR=
-#end
-
-OS=`uname -s`
-OS_VERSION=`uname -r`
-
-TEMP_DIR=".tmp-`uname -n`"
-mkdir -p "$TEMP_DIR"
-if [ $? -ne 0 ]; then
-    echo "Cannot create tmp dir"
-    echo "Abort"
-fi
-touch "$TEMP_DIR/options"
-touch "$TEMP_DIR/features"
-
 # features
 #foreach( $feature in $features )
 #if( ${feature.isDefault()} )
@@ -68,6 +42,13 @@
 #end
 #end
 
+# clean abort
+abort_configure()
+{
+    rm -Rf "$TEMP_DIR"
+    exit 1
+}
+
 # help text
 printhelp()
 {
@@ -136,7 +117,7 @@
         "--includedir="*)     INCLUDEDIR=${D}{ARG#--includedir=} ;;
         "--infodir="*)        INFODIR=${D}{ARG#--infodir=} ;;
         "--mandir"*)          MANDIR=${D}{ARG#--mandir} ;;
-        "--help"*) printhelp; rm -Rf "$TEMP_DIR"; exit 1 ;;
+        "--help"*) printhelp; abort_configure ;;
         "--debug")           BUILD_TYPE="debug" ;;
         "--release")         BUILD_TYPE="release" ;;
     #foreach( $opt in $options )
@@ -146,54 +127,33 @@
         "--enable-${feature.arg}") ${feature.getVarName()}=on ;;
         "--disable-${feature.arg}") unset ${feature.getVarName()} ;;
     #end
-        "-"*) echo "unknown option: $ARG"; rm -Rf "$TEMP_DIR"; exit 1 ;;
+        "-"*) echo "unknown option: $ARG"; abort_configure ;;
     esac
 done
 
+## Begin unparsed content. **
+#[[
 # set dir variables
-if [ -z "$BINDIR" ]; then
-    BINDIR=$EPREFIX/bin
-fi
-if [ -z "$SBINDIR" ]; then
-    SBINDIR=$EPREFIX/sbin
-fi
-if [ -z "$LIBDIR" ]; then
-    LIBDIR=$EPREFIX/lib
-fi
-if [ -z "$LIBEXEC" ]; then
-    LIBEXECDIR=$EPREFIX/libexec
-fi
-if [ -z "$DATADIR" ]; then
-    DATADIR=$PREFIX/share
-fi
-if [ -z "$SYSCONFDIR" ]; then
-    SYSCONFDIR=$PREFIX/etc
-fi
-if [ -z "$SHAREDSTATEDIR" ]; then
-    SHAREDSTATEDIR=$PREFIX/com
-fi
-if [ -z "$LOCALSTATEDIR" ]; then
-    LOCALSTATEDIR=$PREFIX/var
-fi
-if [ -z "$INCLUDEDIR" ]; then
-    INCLUDEDIR=$PREFIX/include
-fi
-if [ -z "$INFODIR" ]; then
-    INFODIR=$PREFIX/info
-fi
-if [ -z "$MANDIR" ]; then
-    MANDIR=$PREFIX/man
-fi
+BINDIR=${BINDIR:-"$EPREFIX/bin"}
+SBINDIR=${SBINDIR:-"$EPREFIX/sbin"}
+LIBDIR=${LIBDIR:-"$EPREFIX/lib"}
+LIBEXECDIR=${LIBEXECDIR:-"$EPREFIX/libexec"}
+DATADIR=${DATADIR:-"$PREFIX/share"}
+SYSCONFDIR=${SYSCONFDIR:-"$PREFIX/etc"}
+SHAREDSTATEDIR=${SHAREDSTATEDIR:-"$PREFIX/com"}
+LOCALSTATEDIR=${LOCALSTATEDIR:-"$PREFIX/var"}
+INCLUDEDIR=${INCLUDEDIR:-"$PREFIX/include"}
+INFODIR=${INFODIR:-"$PREFIX/info"}
+MANDIR=${MANDIR:-"$PREFIX/man"}
 
-which pkg-config > /dev/null
-if [ $? -eq 0 ]; then
-    PKG_CONFIG=pkg-config
-else
-    PKG_CONFIG=false
-fi
+# Test for availability of pkg-config
+PKG_CONFIG=$(command -v pkg-config)
+PKG_CONFIG=${PKG_CONFIG:-"false"}
 
 # Simple uname based platform detection
 # $PLATFORM is used for platform dependent dependency selection
+OS=$(uname -s)
+OS_VERSION=$(uname -r)
 printf "detect platform... "
 if [ "$OS" = "SunOS" ]; then
     PLATFORM="solaris sunos unix svr4"
@@ -207,21 +167,13 @@
 if [ "$OS" = "Darwin" ]; then
     PLATFORM="macos osx bsd unix"
 fi
-echo "$OS" | grep -i "MINGW" > /dev/null
-if [ $? -eq 0 ]; then
+if echo "$OS" | grep -i "MINGW" > /dev/null; then
     PLATFORM="windows mingw"
 fi
-
-if [ -z "$PLATFORM" ]; then
-    PLATFORM="unix"
-fi
+PLATFORM=${PLATFORM:-"unix"}
 
-for p in $PLATFORM
-do
-    PLATFORM_NAME=$p
-    break
-done
-echo $PLATFORM_NAME
+PLATFORM_NAME=$(echo "$PLATFORM" | cut -f1 -d' ' -)
+echo "$PLATFORM_NAME"
 
 isplatform()
 {
@@ -233,97 +185,52 @@
     done
     return 1
 }
-isnotplatform()
-{
-    for p in $PLATFORM
-    do
-        if [ "$p" = "$1" ]; then
-            return 1
-        fi
-    done
-    return 0
-}
+]]#
+## End of unparsed content **
 
-# generate config.mk and config.h
+# generate config.mk
+cat > "$TEMP_DIR/vars.mk" << __EOF__
+PREFIX=$PREFIX
+EPREFIX=$EPREFIX
+BINDIR=$BINDIR
+SBINDIR=$SBINDIR
+LIBDIR=$LIBDIR
+LIBEXECDIR=$LIBEXECDIR
+DATADIR=$DATADIR
+SYSCONFDIR=$SYSCONFDIR
+SHAREDSTATEDIR=$SHAREDSTATEDIR
+LOCALSTATEDIR=$LOCALSTATEDIR
+INCLUDEDIR=$INCLUDEDIR
+INFODIR=$INFODIR
+MANDIR=$MANDIR
+#foreach( $var in $vars )
+${var.varName}=$${var.varName}
+#end
+__EOF__
 cat > "$TEMP_DIR/config.mk" << __EOF__
 #
 # config.mk generated by configure
 #
-
-# general vars
-#foreach( $var in $vars )
-${var.varName}=$${var.varName}
-#end
-
-#if ( ! $project.hasVar("PREFIX") )
-PREFIX=$PREFIX
-#end
-#if ( ! $project.hasVar("EPREFIX") )
-EPREFIX=$EPREFIX
-#end
+__EOF__
+sort -u "$TEMP_DIR/vars.mk" >> "$TEMP_DIR/config.mk"
 
-#if ( ! $project.hasVar("BINDIR") )
-BINDIR=$BINDIR
-#end
-#if ( ! $project.hasVar("SBINDIR") )
-SBINDIR=$SBINDIR
-#end
-#if ( ! $project.hasVar("LIBDIR") )
-LIBDIR=$LIBDIR
-#end
-#if ( ! $project.hasVar("LIBEXECDIR") )
-LIBEXECDIR=$LIBEXECDIR
-#end
-#if ( ! $project.hasVar("DATADIR") )
-DATADIR=$DATADIR
-#end
-#if ( ! $project.hasVar("SYSCONFDIR") )
-SYSCONFDIR=$SYSCONFDIR
-#end
-#if ( ! $project.hasVar("SHAREDSTATEDIR") )
-SHAREDSTATEDIR=$SHAREDSTATEDIR
-#end
-#if ( ! $project.hasVar("LOCALSTATEDIR") )
-LOCALSTATEDIR=$LOCALSTATEDIR
-#end
-#if ( ! $project.hasVar("INCLUDEDIR") )
-INCLUDEDIR=$INCLUDEDIR
-#end
-#if ( ! $project.hasVar("INFODIR") )
-INFODIR=$INFODIR
-#end
-#if ( ! $project.hasVar("MANDIR") )
-MANDIR=$MANDIR
-#end
 
-__EOF__
-
-echo > "$TEMP_DIR/make.mk"
-
-ENV_CFLAGS=$CFLAGS
-ENV_LDFLAGS=$LDFLAGS
-ENV_CXXFLAGS=$CXXFLAGS
-
-# Toolchain detection
+# toolchain detection
 # this will insert make vars to config.mk
 . make/toolchain.sh
-
-# add user specified flags to config.mk
-echo "# project specific flags" >> "$TEMP_DIR/config.mk"
-if [ -n "${ENV_CFLAGS}" ]; then
-    echo "CFLAGS += $ENV_CFLAGS" >> "$TEMP_DIR/config.mk"
-fi
-if [ -n "${ENV_CXXFLAGS}" ]; then
-    echo "CXXFLAGS += $ENV_CXXFLAGS" >> "$TEMP_DIR/config.mk"
-fi
-if [ -n "${ENV_LDFLAGS}" ]; then
-    echo "LDFLAGS += $ENV_LDFLAGS" >> "$TEMP_DIR/config.mk"
+if [ -n "$TOOLCHAIN_ERROR" ]; then
+    echo "Toolchain error: $TOOLCHAIN_ERROR"
+    echo "Abort."
+    abort_configure
 fi
 
 #
 # DEPENDENCIES
 #
 
+# create buffer for make variables required by dependencies
+echo > "$TEMP_DIR/make.mk"
+
 #foreach( $dependency in $namedDependencies )
 dependency_${dependency.name}()
 {
@@ -333,12 +240,12 @@
     while true
     do
         #if( $sub.platform )
-        if isnotplatform "${sub.platform}"; then
+        if ! isplatform "${sub.platform}"; then
             break
         fi
         #end
-        #foreach( $not in $sub.getNotList() )
-        if isplatform "${not}"; then
+        #foreach( $np in $sub.getNotList() )
+        if isplatform "${np}"; then
             break
         fi
         #end
@@ -348,24 +255,21 @@
         fi
         #end
         #foreach( $test in $sub.tests )
-        $test > /dev/null
-        if [ $? -ne 0 ]; then
-        break
+        if ! $test > /dev/null ; then
+            break
         fi
         #end
         #foreach( $pkg in $sub.pkgconfig )
-        $pkg.getPkgConfigTestQuery()
-        if [ $? -ne 0 ] ; then
+        if ! $pkg.getPkgConfigTestQuery() ; then
             break
         fi
-        TEMP_CFLAGS="$TEMP_CFLAGS `$PKG_CONFIG --cflags $pkg.name`"
-        TEMP_LDFLAGS="$TEMP_LDFLAGS `$PKG_CONFIG --libs $pkg.name`"
+        TEMP_CFLAGS="$TEMP_CFLAGS $("$PKG_CONFIG" --cflags $pkg.name)"
+        TEMP_LDFLAGS="$TEMP_LDFLAGS $("$PKG_CONFIG" --libs $pkg.name)"
         #end
         #foreach( $flags in $sub.flags )
         #if( $flags.exec )
-        $flags.value > /dev/null
-        if [ $? -eq 0 ]; then
-            TEMP_$flags.varName="$TEMP_$flags.varName `$flags.value`"
+        if tmp_flags=$($flags.value) ; then
+            TEMP_$flags.varName="$TEMP_$flags.varName $tmp_flags"
         else
             break
         fi
@@ -392,19 +296,19 @@
 DEPENDENCIES_FAILED=
 ERROR=0
 #if( $dependencies.size() > 0 )
-# general dependencies
+# unnamed dependencies
 TEMP_CFLAGS=
 TEMP_LDFLAGS=
 #foreach( $dependency in $dependencies )
 while true
 do
     #if( $dependency.platform )
-    if isnotplatform "${dependency.platform}"; then
+    if ! isplatform "${dependency.platform}"; then
         break
     fi
     #end
-    #foreach( $not in $dependency.getNotList() )
-    if isplatform "${not}"; then
+    #foreach( $np in $dependency.getNotList() )
+    if isplatform "${np}"; then
         break
     fi
     #end
@@ -418,22 +322,21 @@
         #end
         #foreach( $pkg in $dependency.pkgconfig )
         printf "checking for pkg-config package $pkg.name... "
-        $pkg.getPkgConfigTestQuery()
-        if [ $? -ne 0 ]; then
+        if ! $pkg.getPkgConfigTestQuery() ; then
             echo no
             ERROR=1
             break
         fi
         echo yes
-        TEMP_CFLAGS="$TEMP_CFLAGS `$PKG_CONFIG --cflags $pkg.name`"
-        TEMP_LDFLAGS="$TEMP_LDFLAGS `$PKG_CONFIG --libs $pkg.name`"
+        TEMP_CFLAGS="$TEMP_CFLAGS $("$PKG_CONFIG" --cflags $pkg.name)"
+        TEMP_LDFLAGS="$TEMP_LDFLAGS $("$PKG_CONFIG" --libs $pkg.name)"
         #end
 
         #foreach( $flags in $dependency.flags )
         #if( $flags.exec )
         $flags.value > /dev/null
-        if [ $? -ne 0 ]; then
-            TEMP_$flags.varName="$TEMP_$flags.varName `$flags.value`"
+        if tmp_flags=$($flags.value) ; then
+            TEMP_$flags.varName="$TEMP_$flags.varName $tmp_flags"
         else
             ERROR=1
             break
@@ -447,24 +350,19 @@
 $dependency.make
 __EOF__
         #end
-
         break
     done
-
     break
 done
 #end
 
-# add general dependency flags to config.mk
+# add unnamed dependency flags to config.mk
 echo >> "$TEMP_DIR/config.mk"
 if [ -n "${TEMP_CFLAGS}" ]; then
-    echo "CFLAGS += $TEMP_CFLAGS" >> $TEMP_DIR/config.mk
-fi
-if [ -n "${TEMP_CXXFLAGS}" ]; then
-    echo "CXXFLAGS += $TEMP_CXXFLAGS" >> $TEMP_DIR/config.mk
+    echo "CFLAGS += $TEMP_CFLAGS" >> "$TEMP_DIR/config.mk"
 fi
 if [ -n "${TEMP_LDFLAGS}" ]; then
-    echo "LDFLAGS += $TEMP_LDFLAGS" >> $TEMP_DIR/config.mk
+    echo "LDFLAGS += $TEMP_LDFLAGS" >> "$TEMP_DIR/config.mk"
 fi
 #end
 
@@ -477,8 +375,7 @@
 {
     VERR=0
     #foreach( $dep in $val.dependencies )
-    dependency_$dep
-    if [ $? -ne 0 ]; then
+    if ! dependency_$dep ; then
         VERR=1
     fi
     #end
@@ -501,9 +398,6 @@
 #
 # TARGETS
 #
-TEMP_CFLAGS=
-TEMP_CXXFLAGS=
-TEMP_LDFLAGS=
 
 #foreach( $target in $targets )
 #if ( $target.name )
@@ -513,11 +407,9 @@
 #end
 TEMP_CFLAGS=
 TEMP_LDFLAGS=
-TEMP_CXXFLAGS=
 
 #foreach( $dependency in $target.dependencies )
-dependency_$dependency
-if [ $? -ne 0 ]; then
+if ! dependency_$dependency; then
     DEPENDENCIES_FAILED="$DEPENDENCIES_FAILED ${dependency} "
     ERROR=1
 fi
@@ -528,14 +420,13 @@
 if [ -n "$${feature.getVarName()}" ]; then
 #foreach( $dependency in $feature.dependencies )
     # check dependency
-    dependency_$dependency
-    if [ $? -ne 0 ]; then
+    if ! dependency_$dependency ; then
         # "auto" features can fail and are just disabled in this case
-        if [ "$${feature.getVarName()}" != "auto" ]; then
+        if [ "$${feature.getVarName()}" = "auto" ]; then
+            unset ${feature.getVarName()}
+		else
             DEPENDENCIES_FAILED="$DEPENDENCIES_FAILED ${dependency} "
             ERROR=1
-		else
-			unset ${feature.getVarName()}
         fi
     fi
 #end
@@ -547,15 +438,14 @@
 if [ -z ${D}${opt.getVarName()} ]; then
     SAVED_ERROR="$ERROR"
     SAVED_DEPENDENCIES_FAILED="$DEPENDENCIES_FAILED"
-    ERROR=0
+    ERROR=1
     while true
     do
         #foreach( $optdef in $opt.defaults )
         #if( $optdef.platform )
         if isplatform "$optdef.platform"; then
         #end
-        $optdef.func
-        if [ $? -eq 0 ]; then
+        if $optdef.func ; then
             echo "  ${opt.argument}: ${optdef.valueName}" >> "$TEMP_DIR/options"
             ERROR=0
             break
@@ -577,8 +467,7 @@
     #foreach( $optval in $opt.values )
     elif [ "${D}${opt.getVarName()}" = "${optval.value}" ]; then
         echo "  ${opt.argument}: ${D}${opt.getVarName()}" >> $TEMP_DIR/options
-        $optval.func
-        if [ $? -ne 0 ]; then
+        if ! $optval.func ; then
             ERROR=1
         fi
     #end
@@ -590,16 +479,11 @@
 if [ -n "${TEMP_CFLAGS}" ]; then
     echo "${target.getCFlags()}  += $TEMP_CFLAGS" >> "$TEMP_DIR/config.mk"
 fi
-if [ -n "${TEMP_CXXFLAGS}" ]; then
-    echo "${target.getCXXFlags()} += $TEMP_CXXFLAGS" >> "$TEMP_DIR/config.mk"
-fi
 if [ "$BUILD_TYPE" = "debug" ]; then
     echo '${target.getCFlags()} += ${DEBUG_FLAGS}' >> "$TEMP_DIR/config.mk"
-    echo '${target.getCXXFlags()} += ${DEBUG_FLAGS}' >> "$TEMP_DIR/config.mk"
 fi
 if [ "$BUILD_TYPE" = "release" ]; then
     echo '${target.getCFlags()} += ${RELEASE_FLAGS}' >> "$TEMP_DIR/config.mk"
-    echo '${target.getCXXFlags()} += ${RELEASE_FLAGS}' >> "$TEMP_DIR/config.mk"
 fi
 if [ -n "${TEMP_LDFLAGS}" ]; then
     echo "${target.getLDFlags()} += $TEMP_LDFLAGS" >> "$TEMP_DIR/config.mk"
@@ -610,8 +494,7 @@
     echo
     echo "Error: Unresolved dependencies"
     echo "$DEPENDENCIES_FAILED"
-    rm -Rf "$TEMP_DIR"
-    exit 1
+    abort_configure
 fi
 
 echo "configure finished"
--- a/test/make/project.xml	Tue Sep 12 23:36:45 2023 +0200
+++ b/test/make/project.xml	Thu Sep 14 22:59:05 2023 +0200
@@ -3,7 +3,7 @@
 	<!-- makefile config -->
 	<config>
 		<var name="HOST" exec="true">uname -n</var>
-		<var name="PREFIX">`pwd`/work</var>
+		<var name="PREFIX">$(pwd)/work</var>
 		<var name="INSTALL_DIR">$PREFIX</var>
 	</config>
 	
--- a/test/make/toolchain.sh	Tue Sep 12 23:36:45 2023 +0200
+++ b/test/make/toolchain.sh	Thu Sep 14 22:59:05 2023 +0200
@@ -3,11 +3,13 @@
 # toolchain detection
 #
 
-C_COMPILERS="cc gcc clang suncc"
-CPP_COMPILERS="CC g++ clang++ sunCC"
-unset CC_ARG_CHECKED
-unset TOOLCHAIN_DETECTION_ERROR
+C_COMPILERS="gcc clang suncc cc"
+CPP_COMPILERS="g++ clang++ sunCC CC"
+unset TOOLCHAIN_ERROR
 unset TOOLCHAIN_NAME
+unset TOOLCHAIN_CC
+unset TOOLCHAIN_CXX
+unset TOOLCHAIN_LD
 
 check_c_compiler()
 {
@@ -29,11 +31,6 @@
 __EOF__
 	rm -f "$TEMP_DIR/checkcc"
 	$1 -o "$TEMP_DIR/checkcc" $CFLAGS $LDFLAGS "$TEMP_DIR/test.c" 2> /dev/null
-	
-	if [ $? -ne 0 ]; then
-		return 1
-	fi
-	return 0
 }
 
 check_cpp_compiler()
@@ -56,11 +53,6 @@
 __EOF__
 	rm -f "$TEMP_DIR/checkcc"
 	$1 -o "$TEMP_DIR/checkcc" $CXXFLAGS $LDFLAGS "$TEMP_DIR/test.cpp" 2> /dev/null
-	
-	if [ $? -ne 0 ]; then
-		return 1
-	fi
-	return 0
 }
 
 check_lib()
@@ -76,112 +68,63 @@
 __EOF__
 	rm -f "$TEMP_DIR/checklib"
 	$TOOLCHAIN_LD -o "$TEMP_DIR/checklib" $CFLAGS $LDFLAGS "-l$1" "$TEMP_DIR/test.c" 2> /dev/null
-
-	if [ $? -ne 0 ]; then
-		return 1
-	fi
-	return 0
 }
 
 printf "detect C compiler... "
 
-for COMP in $C_COMPILERS
-do
-	check_c_compiler "$COMP"
-	if [ $? -ne 0 ]; then
-		if [ -n "$CC" ]; then
-			if [ "$COMP" = "$CC" ]; then
-				echo "$CC is not a working C compiler"
-				TOOLCHAIN_DETECTION_ERROR="error"
-				break
-			fi
-		fi
-	else
-		TOOLCHAIN_NAME=`$TEMP_DIR/checkcc`
-		USE_TOOLCHAIN=$TOOLCHAIN_NAME
-		if [ "$COMP" = "cc" ]; then
-			# we have found a working compiler, but in case
-			# the compiler is gcc or clang, we try to use
-			# these commands and not 'cc'
-			TOOLCHAIN_NAME=`$TEMP_DIR/checkcc`
-			if [ "$TOOLCHAIN_NAME" = "gcc" ]; then
-				check_c_compiler "gcc"
-				if [ $? -eq 0 ]; then
-					COMP=gcc
-					USE_TOOLCHAIN="gcc"
-				fi
-			fi
-			if [ "$TOOLCHAIN_NAME" = "clang" ]; then
-				check_c_compiler "clang"
-				if [ $? -eq 0 ]; then
-					COMP=clang
-					USE_TOOLCHAIN="clang"
-				fi
-			fi
-		fi
-		
-		TOOLCHAIN_NAME=$USE_TOOLCHAIN
-		TOOLCHAIN_CC=$COMP
-		echo $COMP
-		break
-	fi
-done
-if [ -z "$TOOLCHAIN_CC" ]; then
-	echo "not found"
+if [ -n "$CC" ]; then
+  if check_c_compiler "$CC"; then
+    TOOLCHAIN_CC=$CC
+    TOOLCHAIN_NAME=$("$TEMP_DIR/checkcc")
+    echo $CC
+  else
+    echo "$CC is not a working C compiler"
+    TOOLCHAIN_ERROR="required C compiler not found"
+  fi
+else
+  for COMP in $C_COMPILERS
+  do
+    if check_c_compiler "$COMP"; then
+      TOOLCHAIN_NAME=$("$TEMP_DIR/checkcc")
+      TOOLCHAIN_CC=$COMP
+      break
+    fi
+  done
+  echo "${TOOLCHAIN_CC-"not found"}"
 fi
 
 printf "detect C++ compiler... "
 
-for COMP in $CPP_COMPILERS
-do
-	check_cpp_compiler "$COMP"
-	if [ $? -ne 0 ]; then
-		if [ -n "$CXX" ]; then
-			if [ "$COMP" = "$CXX" ]; then
-				echo "$CXX is not a working C++ compiler"
-				TOOLCHAIN_DETECTION_ERROR="error"
-				break
-			fi
-		fi
-	else
-		if [ $COMP = "CC" ]; then
-			# we have found a working compiler, but in case
-			# the compiler is gcc or clang, we try to use
-			# these commands and not 'CC'
-			TOOLCHAIN_NAME=`$TEMP_DIR/checkcc`
-			USE_TOOLCHAIN=$TOOLCHAIN_NAME
-			if [ "$TOOLCHAIN_NAME" = "gcc" ]; then
-				check_cpp_compiler "g++"
-				if [ $? -eq 0 ]; then
-				   COMP=g++
-				   USE_TOOLCHAIN="gcc"
-				fi
-			fi
-			if [ "$TOOLCHAIN_NAME" = "clang" ]; then
-				check_cpp_compiler "clang++"
-				if [ $? -eq 0 ]; then
-				   COMP=clang++
-				   USE_TOOLCHAIN="clang"
-				fi
-			fi
-		fi
-		
-		TOOLCHAIN_NAME=$USE_TOOLCHAIN
-		TOOLCHAIN_CXX=$COMP
-		echo $COMP
-		break
-	fi
-done
-if [ -z "$TOOLCHAIN_CXX" ]; then
-	echo "not found"
+if [ -n "$CXX" ]; then
+  if check_cpp_compiler "$CXX"; then
+    TOOLCHAIN_CXX=$CXX
+    TOOLCHAIN_NAME=$("$TEMP_DIR/checkcc")
+    echo $CXX
+  else
+    echo "$CXX is not a working C++ compiler"
+    TOOLCHAIN_ERROR="required C++ compiler not found"
+  fi
+else
+  for COMP in $CPP_COMPILERS
+  do
+    if check_cpp_compiler "$COMP"; then
+      TOOLCHAIN_NAME=$("$TEMP_DIR/checkcc")
+      TOOLCHAIN_CXX=$COMP
+      break
+    fi
+  done
+  echo "${TOOLCHAIN_CXX-"not found"}"
 fi
 
+printf "detect linker... "
 TOOLCHAIN_LD=$TOOLCHAIN_CC
+echo "$TOOLCHAIN_LD"
 
 if [ -z "$TOOLCHAIN_NAME" ]; then
-	TOOLCHAIN_DETECTION_ERROR="error"
+  TOOLCHAIN_ERROR="no build tools detected"
 else
 	cat >> "$TEMP_DIR/config.mk" << __EOF__
+
 # toolchain
 __EOF__
 	echo "CC = ${TOOLCHAIN_CC}" >> "$TEMP_DIR/config.mk"

mercurial