add basic support for the lang element - fixes #284

Mon, 18 Sep 2023 23:20:29 +0200

author
Mike Becker <universe@uap-core.de>
date
Mon, 18 Sep 2023 23:20:29 +0200
changeset 66
dc758dcd4645
parent 65
6db50c6df6e3
child 67
e43d30273f74

add basic support for the lang element - fixes #284

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/cc.mk file | annotate | diff | comparison | revisions
test/make/clang.mk file | annotate | diff | comparison | revisions
test/make/configure.vm file | annotate | diff | comparison | revisions
test/make/gcc.mk file | annotate | diff | comparison | revisions
test/make/suncc.mk file | annotate | diff | comparison | revisions
test/make/toolchain.sh file | annotate | diff | comparison | revisions
--- a/src/test/resources/golden-sample/configure	Mon Sep 18 22:49:54 2023 +0200
+++ b/src/test/resources/golden-sample/configure	Mon Sep 18 23:20:29 2023 +0200
@@ -167,7 +167,7 @@
 }
 
 
-# generate config.mk
+# generate vars.mk
 cat > "$TEMP_DIR/vars.mk" << __EOF__
 PREFIX=$PREFIX
 EPREFIX=$EPREFIX
@@ -186,22 +186,11 @@
 PREFIX=$PREFIX
 INSTALL_DIR=$INSTALL_DIR
 __EOF__
-cat > "$TEMP_DIR/config.mk" << __EOF__
-#
-# config.mk generated by configure
-#
-__EOF__
-sort -u "$TEMP_DIR/vars.mk" >> "$TEMP_DIR/config.mk"
+sort -u -o "$TEMP_DIR/vars.mk" "$TEMP_DIR/vars.mk"
 
 
-# toolchain detection
-# this will insert make vars to config.mk
+# toolchain detection utilities
 . make/toolchain.sh
-if [ -n "$TOOLCHAIN_ERROR" ]; then
-    echo "Toolchain error: $TOOLCHAIN_ERROR"
-    echo "Abort."
-    abort_configure
-fi
 
 #
 # DEPENDENCIES
@@ -214,11 +203,11 @@
 {
     if "$PKG_CONFIG" --exists "$1" ; then :
     else return 1 ; fi
-    if [ -n "$2" ] && "$PKG_CONFIG" --atleast-version="$2" "$1" ; then :
+    if [ -z "$2" ] || "$PKG_CONFIG" --atleast-version="$2" "$1" ; then :
     else return 1 ; fi
-    if [ -n "$3" ] && "$PKG_CONFIG" --exact-version="$3" "$1" ; then :
+    if [ -z "$3" ] || "$PKG_CONFIG" --exact-version="$3" "$1" ; then :
     else return 1 ; fi
-    if [ -n "$4" ] && "$PKG_CONFIG" --max-version="$4" "$1" ; then :
+    if [ -z "$4" ] || "$PKG_CONFIG" --max-version="$4" "$1" ; then :
     else return 1 ; fi
     return 0
 }
@@ -321,28 +310,41 @@
     return 0
 }
 
+# start collecting dependency information
+echo > "$TEMP_DIR/flags.mk"
+
 DEPENDENCIES_FAILED=
 ERROR=0
 # unnamed dependencies
 TEMP_CFLAGS=
+TEMP_CXXFLAGS=
 TEMP_LDFLAGS=
 while true
 do
     while true
     do
+        if detect_cpp_compiler ; then
+            :
+        else
+            ERROR=1
+            break
+        fi
 
         break
     done
     break
 done
 
-# add unnamed dependency flags to config.mk
-echo >> "$TEMP_DIR/config.mk"
+# add general dependency flags to flags.mk
+echo "# general flags" >> "$TEMP_DIR/flags.mk"
 if [ -n "${TEMP_CFLAGS}" ]; then
-    echo "CFLAGS += $TEMP_CFLAGS" >> "$TEMP_DIR/config.mk"
+    echo "CFLAGS += $TEMP_CFLAGS" >> "$TEMP_DIR/flags.mk"
+fi
+if [ -n "${TEMP_CXXFLAGS}" ]; then
+    echo "CXXFLAGS += $TEMP_CXXFLAGS" >> "$TEMP_DIR/flags.mk"
 fi
 if [ -n "${TEMP_LDFLAGS}" ]; then
-    echo "LDFLAGS += $TEMP_LDFLAGS" >> "$TEMP_DIR/config.mk"
+    echo "LDFLAGS += $TEMP_LDFLAGS" >> "$TEMP_DIR/flags.mk"
 fi
 
 #
@@ -353,8 +355,11 @@
 # TARGETS
 #
 
+echo >> "$TEMP_DIR/flags.mk"
 # Target
+echo "# flags for unnamed target" >> "$TEMP_DIR/flags.mk"
 TEMP_CFLAGS=
+TEMP_CXXFLAGS=
 TEMP_LDFLAGS=
 
 if dependency_error_libxml2; then
@@ -381,20 +386,26 @@
 fi
 
 
-echo >> "$TEMP_DIR/config.mk"
 if [ -n "${TEMP_CFLAGS}" ]; then
-    echo "CFLAGS  += $TEMP_CFLAGS" >> "$TEMP_DIR/config.mk"
+    echo "CFLAGS  += $TEMP_CFLAGS" >> "$TEMP_DIR/flags.mk"
+fi
+if [ -n "${TEMP_CXXFLAGS}" ]; then
+    echo "CXXFLAGS  += $TEMP_CXXFLAGS" >> "$TEMP_DIR/flags.mk"
 fi
 if [ "$BUILD_TYPE" = "debug" ]; then
-    echo 'CFLAGS += ${DEBUG_FLAGS}' >> "$TEMP_DIR/config.mk"
+    echo 'CFLAGS += ${DEBUG_CC_FLAGS}' >> "$TEMP_DIR/flags.mk"
+    echo 'CXXFLAGS += ${DEBUG_CXX_FLAGS}' >> "$TEMP_DIR/flags.mk"
 fi
 if [ "$BUILD_TYPE" = "release" ]; then
-    echo 'CFLAGS += ${RELEASE_FLAGS}' >> "$TEMP_DIR/config.mk"
+    echo 'CFLAGS += ${RELEASE_CC_FLAGS}' >> "$TEMP_DIR/flags.mk"
+    echo 'CXXFLAGS += ${RELEASE_CXX_FLAGS}' >> "$TEMP_DIR/flags.mk"
 fi
 if [ -n "${TEMP_LDFLAGS}" ]; then
-    echo "LDFLAGS += $TEMP_LDFLAGS" >> "$TEMP_DIR/config.mk"
+    echo "LDFLAGS += $TEMP_LDFLAGS" >> "$TEMP_DIR/flags.mk"
 fi
 
+
+# final result
 if [ $ERROR -ne 0 ]; then
     echo
     echo "Error: Unresolved dependencies"
@@ -414,7 +425,16 @@
 echo "  pg: off"
 fi
 echo
-cat "$TEMP_DIR/config.mk" "$TEMP_DIR/make.mk" > config.mk
+
+# generate the config.mk file
+cat > "$TEMP_DIR/config.mk" << __EOF__
+#
+# config.mk generated by configure
+#
+
+__EOF__
+write_toolchain_defaults "$TEMP_DIR/config.mk"
+cat "$TEMP_DIR/config.mk" "$TEMP_DIR/flags.mk" "$TEMP_DIR/make.mk" > config.mk
 rm -Rf "$TEMP_DIR"
 
 
--- a/src/test/resources/golden-sample/configure2	Mon Sep 18 22:49:54 2023 +0200
+++ b/src/test/resources/golden-sample/configure2	Mon Sep 18 23:20:29 2023 +0200
@@ -173,7 +173,7 @@
 }
 
 
-# generate config.mk
+# generate vars.mk
 cat > "$TEMP_DIR/vars.mk" << __EOF__
 PREFIX=$PREFIX
 EPREFIX=$EPREFIX
@@ -189,22 +189,11 @@
 INFODIR=$INFODIR
 MANDIR=$MANDIR
 __EOF__
-cat > "$TEMP_DIR/config.mk" << __EOF__
-#
-# config.mk generated by configure
-#
-__EOF__
-sort -u "$TEMP_DIR/vars.mk" >> "$TEMP_DIR/config.mk"
+sort -u -o "$TEMP_DIR/vars.mk" "$TEMP_DIR/vars.mk"
 
 
-# toolchain detection
-# this will insert make vars to config.mk
+# toolchain detection utilities
 . make/toolchain.sh
-if [ -n "$TOOLCHAIN_ERROR" ]; then
-    echo "Toolchain error: $TOOLCHAIN_ERROR"
-    echo "Abort."
-    abort_configure
-fi
 
 #
 # DEPENDENCIES
@@ -217,11 +206,11 @@
 {
     if "$PKG_CONFIG" --exists "$1" ; then :
     else return 1 ; fi
-    if [ -n "$2" ] && "$PKG_CONFIG" --atleast-version="$2" "$1" ; then :
+    if [ -z "$2" ] || "$PKG_CONFIG" --atleast-version="$2" "$1" ; then :
     else return 1 ; fi
-    if [ -n "$3" ] && "$PKG_CONFIG" --exact-version="$3" "$1" ; then :
+    if [ -z "$3" ] || "$PKG_CONFIG" --exact-version="$3" "$1" ; then :
     else return 1 ; fi
-    if [ -n "$4" ] && "$PKG_CONFIG" --max-version="$4" "$1" ; then :
+    if [ -z "$4" ] || "$PKG_CONFIG" --max-version="$4" "$1" ; then :
     else return 1 ; fi
     return 0
 }
@@ -434,15 +423,25 @@
     return 0
 }
 
+# start collecting dependency information
+echo > "$TEMP_DIR/flags.mk"
+
 DEPENDENCIES_FAILED=
 ERROR=0
 # unnamed dependencies
 TEMP_CFLAGS=
+TEMP_CXXFLAGS=
 TEMP_LDFLAGS=
 while true
 do
     while true
     do
+        if detect_c_compiler ; then
+            :
+        else
+            ERROR=1
+            break
+        fi
 
         cat >> "$TEMP_DIR/make.mk" << __EOF__
 MVAR = 123
@@ -454,13 +453,16 @@
     break
 done
 
-# add unnamed dependency flags to config.mk
-echo >> "$TEMP_DIR/config.mk"
+# add general dependency flags to flags.mk
+echo "# general flags" >> "$TEMP_DIR/flags.mk"
 if [ -n "${TEMP_CFLAGS}" ]; then
-    echo "CFLAGS += $TEMP_CFLAGS" >> "$TEMP_DIR/config.mk"
+    echo "CFLAGS += $TEMP_CFLAGS" >> "$TEMP_DIR/flags.mk"
+fi
+if [ -n "${TEMP_CXXFLAGS}" ]; then
+    echo "CXXFLAGS += $TEMP_CXXFLAGS" >> "$TEMP_DIR/flags.mk"
 fi
 if [ -n "${TEMP_LDFLAGS}" ]; then
-    echo "LDFLAGS += $TEMP_LDFLAGS" >> "$TEMP_DIR/config.mk"
+    echo "LDFLAGS += $TEMP_LDFLAGS" >> "$TEMP_DIR/flags.mk"
 fi
 
 #
@@ -476,6 +478,7 @@
         return 1
     fi
         TEMP_CFLAGS="$TEMP_CFLAGS -Da=b"
+        TEMP_CXXFLAGS="$TEMP_CXXFLAGS -Da=b"
     cat >> "$TEMP_DIR/make.mk" << __EOF__
 UIOBJ += graphics_cairo.o
 
@@ -523,8 +526,11 @@
 # TARGETS
 #
 
+echo >> "$TEMP_DIR/flags.mk"
 # Target: dav
+echo "# flags for target dav" >> "$TEMP_DIR/flags.mk"
 TEMP_CFLAGS=
+TEMP_CXXFLAGS=
 TEMP_LDFLAGS=
 
 if dependency_error_curl; then
@@ -631,22 +637,29 @@
     fi
 fi
 
-echo >> "$TEMP_DIR/config.mk"
 if [ -n "${TEMP_CFLAGS}" ]; then
-    echo "DAV_CFLAGS  += $TEMP_CFLAGS" >> "$TEMP_DIR/config.mk"
+    echo "DAV_CFLAGS  += $TEMP_CFLAGS" >> "$TEMP_DIR/flags.mk"
+fi
+if [ -n "${TEMP_CXXFLAGS}" ]; then
+    echo "DAV_CXXFLAGS  += $TEMP_CXXFLAGS" >> "$TEMP_DIR/flags.mk"
 fi
 if [ "$BUILD_TYPE" = "debug" ]; then
-    echo 'DAV_CFLAGS += ${DEBUG_FLAGS}' >> "$TEMP_DIR/config.mk"
+    echo 'DAV_CFLAGS += ${DEBUG_CC_FLAGS}' >> "$TEMP_DIR/flags.mk"
+    echo 'DAV_CXXFLAGS += ${DEBUG_CXX_FLAGS}' >> "$TEMP_DIR/flags.mk"
 fi
 if [ "$BUILD_TYPE" = "release" ]; then
-    echo 'DAV_CFLAGS += ${RELEASE_FLAGS}' >> "$TEMP_DIR/config.mk"
+    echo 'DAV_CFLAGS += ${RELEASE_CC_FLAGS}' >> "$TEMP_DIR/flags.mk"
+    echo 'DAV_CXXFLAGS += ${RELEASE_CXX_FLAGS}' >> "$TEMP_DIR/flags.mk"
 fi
 if [ -n "${TEMP_LDFLAGS}" ]; then
-    echo "DAV_LDFLAGS += $TEMP_LDFLAGS" >> "$TEMP_DIR/config.mk"
+    echo "DAV_LDFLAGS += $TEMP_LDFLAGS" >> "$TEMP_DIR/flags.mk"
 fi
 
+echo >> "$TEMP_DIR/flags.mk"
 # Target
+echo "# flags for unnamed target" >> "$TEMP_DIR/flags.mk"
 TEMP_CFLAGS=
+TEMP_CXXFLAGS=
 TEMP_LDFLAGS=
 
 if dependency_error_deptest; then
@@ -657,20 +670,26 @@
 # Features
 
 
-echo >> "$TEMP_DIR/config.mk"
 if [ -n "${TEMP_CFLAGS}" ]; then
-    echo "CFLAGS  += $TEMP_CFLAGS" >> "$TEMP_DIR/config.mk"
+    echo "CFLAGS  += $TEMP_CFLAGS" >> "$TEMP_DIR/flags.mk"
+fi
+if [ -n "${TEMP_CXXFLAGS}" ]; then
+    echo "CXXFLAGS  += $TEMP_CXXFLAGS" >> "$TEMP_DIR/flags.mk"
 fi
 if [ "$BUILD_TYPE" = "debug" ]; then
-    echo 'CFLAGS += ${DEBUG_FLAGS}' >> "$TEMP_DIR/config.mk"
+    echo 'CFLAGS += ${DEBUG_CC_FLAGS}' >> "$TEMP_DIR/flags.mk"
+    echo 'CXXFLAGS += ${DEBUG_CXX_FLAGS}' >> "$TEMP_DIR/flags.mk"
 fi
 if [ "$BUILD_TYPE" = "release" ]; then
-    echo 'CFLAGS += ${RELEASE_FLAGS}' >> "$TEMP_DIR/config.mk"
+    echo 'CFLAGS += ${RELEASE_CC_FLAGS}' >> "$TEMP_DIR/flags.mk"
+    echo 'CXXFLAGS += ${RELEASE_CXX_FLAGS}' >> "$TEMP_DIR/flags.mk"
 fi
 if [ -n "${TEMP_LDFLAGS}" ]; then
-    echo "LDFLAGS += $TEMP_LDFLAGS" >> "$TEMP_DIR/config.mk"
+    echo "LDFLAGS += $TEMP_LDFLAGS" >> "$TEMP_DIR/flags.mk"
 fi
 
+
+# final result
 if [ $ERROR -ne 0 ]; then
     echo
     echo "Error: Unresolved dependencies"
@@ -697,7 +716,16 @@
 echo "  gui: off"
 fi
 echo
-cat "$TEMP_DIR/config.mk" "$TEMP_DIR/make.mk" > config.mk
+
+# generate the config.mk file
+cat > "$TEMP_DIR/config.mk" << __EOF__
+#
+# config.mk generated by configure
+#
+
+__EOF__
+write_toolchain_defaults "$TEMP_DIR/config.mk"
+cat "$TEMP_DIR/config.mk" "$TEMP_DIR/flags.mk" "$TEMP_DIR/make.mk" > config.mk
 rm -Rf "$TEMP_DIR"
 
 
--- a/test/configure	Mon Sep 18 22:49:54 2023 +0200
+++ b/test/configure	Mon Sep 18 23:20:29 2023 +0200
@@ -29,12 +29,9 @@
 MANDIR=
 
 # custom variables
-HOST=`uname -n`
-PREFIX=`pwd`/work
-INSTALL_DIR=$PREFIX
 
 # features
-FEATURE_PG=auto
+FEATURE_DB=auto
 
 # clean abort
 abort_configure()
@@ -67,8 +64,14 @@
   --infodir=DIR           info documentation [DATAROOTDIR/info]
   --mandir=DIR            man documentation [DATAROOTDIR/man]
 
+Options:
+  --debug                 add extra compile flags for debug builds
+  --release               add extra compile flags for release builds
+  --toolkit=(gtk3|cli|gtk2|wpf)
+
 Optional Features:
-  --disable-pg
+  --disable-db
+  --enable-gui
 
 __EOF__
 }
@@ -96,8 +99,11 @@
         "--help"*) printhelp; abort_configure ;;
         "--debug")           BUILD_TYPE="debug" ;;
         "--release")         BUILD_TYPE="release" ;;
-        "--enable-pg") FEATURE_PG=on ;;
-        "--disable-pg") unset FEATURE_PG ;;
+        "--toolkit="*) OPT_TOOLKIT=${ARG#--toolkit=} ;;
+        "--enable-db") FEATURE_DB=on ;;
+        "--disable-db") unset FEATURE_DB ;;
+        "--enable-gui") FEATURE_GUI=on ;;
+        "--disable-gui") unset FEATURE_GUI ;;
         "-"*) echo "unknown option: $ARG"; abort_configure ;;
     esac
 done
@@ -167,7 +173,7 @@
 }
 
 
-# generate config.mk
+# generate vars.mk
 cat > "$TEMP_DIR/vars.mk" << __EOF__
 PREFIX=$PREFIX
 EPREFIX=$EPREFIX
@@ -182,26 +188,12 @@
 INCLUDEDIR=$INCLUDEDIR
 INFODIR=$INFODIR
 MANDIR=$MANDIR
-HOST=$HOST
-PREFIX=$PREFIX
-INSTALL_DIR=$INSTALL_DIR
 __EOF__
-cat > "$TEMP_DIR/config.mk" << __EOF__
-#
-# config.mk generated by configure
-#
-__EOF__
-sort -u "$TEMP_DIR/vars.mk" >> "$TEMP_DIR/config.mk"
+sort -u -o "$TEMP_DIR/vars.mk" "$TEMP_DIR/vars.mk"
 
 
-# toolchain detection
-# this will insert make vars to config.mk
+# toolchain detection utilities
 . make/toolchain.sh
-if [ -n "$TOOLCHAIN_ERROR" ]; then
-    echo "Toolchain error: $TOOLCHAIN_ERROR"
-    echo "Abort."
-    abort_configure
-fi
 
 #
 # DEPENDENCIES
@@ -214,27 +206,77 @@
 {
     if "$PKG_CONFIG" --exists "$1" ; then :
     else return 1 ; fi
-    if [ -n "$2" ] && "$PKG_CONFIG" --atleast-version="$2" "$1" ; then :
+    if [ -z "$2" ] || "$PKG_CONFIG" --atleast-version="$2" "$1" ; then :
     else return 1 ; fi
-    if [ -n "$3" ] && "$PKG_CONFIG" --exact-version="$3" "$1" ; then :
+    if [ -z "$3" ] || "$PKG_CONFIG" --exact-version="$3" "$1" ; then :
     else return 1 ; fi
-    if [ -n "$4" ] && "$PKG_CONFIG" --max-version="$4" "$1" ; then :
+    if [ -z "$4" ] || "$PKG_CONFIG" --max-version="$4" "$1" ; then :
     else return 1 ; fi
     return 0
 }
 
-dependency_error_libpq()
+dependency_error_qt4()
+{
+    printf "checking for qt4... "
+    # dependency qt4
+    while true
+    do
+        if which qmake-qt4 > /dev/null ; then
+            :
+        else
+            break
+        fi
+        echo yes
+        return 1
+    done
+
+    echo no
+    return 0
+}
+dependency_error_curl()
 {
-    printf "checking for libpq... "
-    # dependency libpq
+    printf "checking for curl... "
+    # dependency curl platform="windows"
+    while true
+    do
+        if notisplatform "windows"; then
+            break
+        fi
+        TEMP_CFLAGS="$TEMP_CFLAGS -I/mingw/include"
+        TEMP_LDFLAGS="$TEMP_LDFLAGS -lcurl"
+        echo yes
+        return 1
+    done
+
+    # dependency curl platform="macos"
+    while true
+    do
+        if notisplatform "macos"; then
+            break
+        fi
+        if tmp_flags=`curl-config --cflags` ; then
+            TEMP_CFLAGS="$TEMP_CFLAGS $tmp_flags"
+        else
+            break
+        fi
+        if tmp_flags=`curl-config --ldflags` ; then
+            TEMP_LDFLAGS="$TEMP_LDFLAGS $tmp_flags"
+        else
+            break
+        fi
+        echo yes
+        return 1
+    done
+
+    # dependency curl
     while true
     do
         if [ -z "$PKG_CONFIG" ]; then
             break
         fi
-        if test_pkg_config "libpq" "" "" "" ; then
-            TEMP_CFLAGS="$TEMP_CFLAGS `"$PKG_CONFIG" --cflags libpq`"
-            TEMP_LDFLAGS="$TEMP_LDFLAGS `"$PKG_CONFIG" --libs libpq`"
+        if test_pkg_config "libcurl" "" "" "" ; then
+            TEMP_CFLAGS="$TEMP_CFLAGS `"$PKG_CONFIG" --cflags libcurl`"
+            TEMP_LDFLAGS="$TEMP_LDFLAGS `"$PKG_CONFIG" --libs libcurl`"
         else
             break
         fi
@@ -245,18 +287,40 @@
     echo no
     return 0
 }
-dependency_error_openssl()
+dependency_error_gtk2()
 {
-    printf "checking for openssl... "
-    # dependency openssl
+    printf "checking for gtk2... "
+    # dependency gtk2
     while true
     do
         if [ -z "$PKG_CONFIG" ]; then
             break
         fi
-        if test_pkg_config "openssl" "" "" "" ; then
-            TEMP_CFLAGS="$TEMP_CFLAGS `"$PKG_CONFIG" --cflags openssl`"
-            TEMP_LDFLAGS="$TEMP_LDFLAGS `"$PKG_CONFIG" --libs openssl`"
+        if test_pkg_config "gtk+-2.0" "" "" "" ; then
+            TEMP_CFLAGS="$TEMP_CFLAGS `"$PKG_CONFIG" --cflags gtk+-2.0`"
+            TEMP_LDFLAGS="$TEMP_LDFLAGS `"$PKG_CONFIG" --libs gtk+-2.0`"
+        else
+            break
+        fi
+        echo yes
+        return 1
+    done
+
+    echo no
+    return 0
+}
+dependency_error_sqlite()
+{
+    printf "checking for sqlite... "
+    # dependency sqlite
+    while true
+    do
+        if [ -z "$PKG_CONFIG" ]; then
+            break
+        fi
+        if test_pkg_config "sqlite3" "" "" "" ; then
+            TEMP_CFLAGS="$TEMP_CFLAGS `"$PKG_CONFIG" --cflags sqlite3`"
+            TEMP_LDFLAGS="$TEMP_LDFLAGS `"$PKG_CONFIG" --libs sqlite3`"
         else
             break
         fi
@@ -264,13 +328,66 @@
         return 1
     done
 
-    # dependency openssl platform="bsd"
+    echo no
+    return 0
+}
+dependency_error_test()
+{
+    printf "checking for test... "
+    # dependency test platform="bsd"
     while true
     do
         if notisplatform "bsd"; then
             break
         fi
-        TEMP_LDFLAGS="$TEMP_LDFLAGS -lssl -lcrypto"
+        if isplatform "macos"; then
+            break
+        fi
+        TEMP_CFLAGS="$TEMP_CFLAGS -DBSD"
+        echo yes
+        return 1
+    done
+
+    # dependency test
+    while true
+    do
+        TEMP_CFLAGS="$TEMP_CFLAGS -DTEST"
+        echo yes
+        return 1
+    done
+
+    echo no
+    return 0
+}
+dependency_error_gtk3()
+{
+    printf "checking for gtk3... "
+    # dependency gtk3
+    while true
+    do
+        if [ -z "$PKG_CONFIG" ]; then
+            break
+        fi
+        if test_pkg_config "gtk+-5.0" "" "" "" ; then
+            TEMP_CFLAGS="$TEMP_CFLAGS `"$PKG_CONFIG" --cflags gtk+-5.0`"
+            TEMP_LDFLAGS="$TEMP_LDFLAGS `"$PKG_CONFIG" --libs gtk+-5.0`"
+        else
+            break
+        fi
+        echo yes
+        return 1
+    done
+
+    echo no
+    return 0
+}
+dependency_error_deptest()
+{
+    printf "checking for deptest... "
+    # dependency deptest
+    while true
+    do
+        TEMP_CFLAGS="$TEMP_CFLAGS -DDEPTEST"
         echo yes
         return 1
     done
@@ -281,38 +398,23 @@
 dependency_error_libxml2()
 {
     printf "checking for libxml2... "
-    # dependency libxml2 platform="macos"
-    while true
-    do
-        if notisplatform "macos"; then
-            break
-        fi
-        if tmp_flags=`xml2-config --cflags` ; then
-            TEMP_CFLAGS="$TEMP_CFLAGS $tmp_flags"
-        else
-            break
-        fi
-        if tmp_flags=`xml2-config --libs` ; then
-            TEMP_LDFLAGS="$TEMP_LDFLAGS $tmp_flags"
-        else
-            break
-        fi
-        echo yes
-        return 1
-    done
-
     # dependency libxml2
     while true
     do
         if [ -z "$PKG_CONFIG" ]; then
             break
         fi
-        if test_pkg_config "libxml-2.0" "" "" "" ; then
+        if test_pkg_config "libxml-2.0" "2.8" "" "" ; then
             TEMP_CFLAGS="$TEMP_CFLAGS `"$PKG_CONFIG" --cflags libxml-2.0`"
             TEMP_LDFLAGS="$TEMP_LDFLAGS `"$PKG_CONFIG" --libs libxml-2.0`"
         else
             break
         fi
+        cat >> $TEMP_DIR/make.mk << __EOF__
+# Dependency: libxml2
+xml = libxml2
+
+__EOF__
         echo yes
         return 1
     done
@@ -321,80 +423,273 @@
     return 0
 }
 
+# start collecting dependency information
+echo > "$TEMP_DIR/flags.mk"
+
 DEPENDENCIES_FAILED=
 ERROR=0
 # unnamed dependencies
 TEMP_CFLAGS=
+TEMP_CXXFLAGS=
 TEMP_LDFLAGS=
 while true
 do
     while true
     do
+        if detect_c_compiler ; then
+            :
+        else
+            ERROR=1
+            break
+        fi
 
+        cat >> "$TEMP_DIR/make.mk" << __EOF__
+MVAR = 123
+MVAR += 123
+
+__EOF__
         break
     done
     break
 done
 
-# add unnamed dependency flags to config.mk
-echo >> "$TEMP_DIR/config.mk"
+# add general dependency flags to flags.mk
+echo "# general flags" >> "$TEMP_DIR/flags.mk"
 if [ -n "${TEMP_CFLAGS}" ]; then
-    echo "CFLAGS += $TEMP_CFLAGS" >> "$TEMP_DIR/config.mk"
+    echo "CFLAGS += $TEMP_CFLAGS" >> "$TEMP_DIR/flags.mk"
+fi
+if [ -n "${TEMP_CXXFLAGS}" ]; then
+    echo "CXXFLAGS += $TEMP_CXXFLAGS" >> "$TEMP_DIR/flags.mk"
 fi
 if [ -n "${TEMP_LDFLAGS}" ]; then
-    echo "LDFLAGS += $TEMP_LDFLAGS" >> "$TEMP_DIR/config.mk"
+    echo "LDFLAGS += $TEMP_LDFLAGS" >> "$TEMP_DIR/flags.mk"
 fi
 
 #
 # OPTION VALUES
 #
+checkopt_toolkit_gtk3()
+{
+    VERR=0
+    if dependency_error_gtk3 ; then
+        VERR=1
+    fi
+    if [ $VERR -ne 0 ]; then
+        return 1
+    fi
+        TEMP_CFLAGS="$TEMP_CFLAGS -Da=b"
+        TEMP_CXXFLAGS="$TEMP_CXXFLAGS -Da=b"
+    cat >> "$TEMP_DIR/make.mk" << __EOF__
+UIOBJ += graphics_cairo.o
+
+__EOF__
+    return 0
+}
+checkopt_toolkit_cli()
+{
+    VERR=0
+    if dependency_error_curl ; then
+        VERR=1
+    fi
+    if dependency_error_test ; then
+        VERR=1
+    fi
+    if [ $VERR -ne 0 ]; then
+        return 1
+    fi
+    return 0
+}
+checkopt_toolkit_gtk2()
+{
+    VERR=0
+    if dependency_error_gtk2 ; then
+        VERR=1
+    fi
+    if [ $VERR -ne 0 ]; then
+        return 1
+    fi
+    return 0
+}
+checkopt_toolkit_wpf()
+{
+    VERR=0
+    if dependency_error_test ; then
+        VERR=1
+    fi
+    if [ $VERR -ne 0 ]; then
+        return 1
+    fi
+    return 0
+}
 
 #
 # TARGETS
 #
 
-# Target
+echo >> "$TEMP_DIR/flags.mk"
+# Target: dav
+echo "# flags for target dav" >> "$TEMP_DIR/flags.mk"
 TEMP_CFLAGS=
+TEMP_CXXFLAGS=
 TEMP_LDFLAGS=
 
+if dependency_error_curl; then
+    DEPENDENCIES_FAILED="$DEPENDENCIES_FAILED curl "
+    ERROR=1
+fi
 if dependency_error_libxml2; then
     DEPENDENCIES_FAILED="$DEPENDENCIES_FAILED libxml2 "
     ERROR=1
 fi
-if dependency_error_openssl; then
-    DEPENDENCIES_FAILED="$DEPENDENCIES_FAILED openssl "
+if dependency_error_test; then
+    DEPENDENCIES_FAILED="$DEPENDENCIES_FAILED test "
     ERROR=1
 fi
 
 # Features
-if [ -n "$FEATURE_PG" ]; then
+if [ -n "$FEATURE_DB" ]; then
     # check dependency
-    if dependency_error_libpq ; then
+    if dependency_error_sqlite ; then
         # "auto" features can fail and are just disabled in this case
-        if [ "$FEATURE_PG" = "auto" ]; then
-            unset FEATURE_PG
+        if [ "$FEATURE_DB" = "auto" ]; then
+            unset FEATURE_DB
 		else
-            DEPENDENCIES_FAILED="$DEPENDENCIES_FAILED libpq "
+            DEPENDENCIES_FAILED="$DEPENDENCIES_FAILED sqlite "
+            ERROR=1
+        fi
+    fi
+fi
+if [ -n "$FEATURE_GUI" ]; then
+    # check dependency
+    if dependency_error_gtk3 ; then
+        # "auto" features can fail and are just disabled in this case
+        if [ "$FEATURE_GUI" = "auto" ]; then
+            unset FEATURE_GUI
+		else
+            DEPENDENCIES_FAILED="$DEPENDENCIES_FAILED gtk3 "
             ERROR=1
         fi
     fi
 fi
 
+# Option: --toolkit
+if [ -z $OPT_TOOLKIT ]; then
+    SAVED_ERROR="$ERROR"
+    SAVED_DEPENDENCIES_FAILED="$DEPENDENCIES_FAILED"
+    ERROR=1
+    while true
+    do
+        if isplatform "windows"; then
+        if checkopt_toolkit_wpf ; then
+            echo "  toolkit: wpf" >> "$TEMP_DIR/options"
+            ERROR=0
+            break
+        fi
+        fi
+        if checkopt_toolkit_gtk3 ; then
+            echo "  toolkit: gtk3" >> "$TEMP_DIR/options"
+            ERROR=0
+            break
+        fi
+        if checkopt_toolkit_gtk2 ; then
+            echo "  toolkit: gtk2" >> "$TEMP_DIR/options"
+            ERROR=0
+            break
+        fi
+        break
+    done
+    if [ $ERROR -ne 0 ]; then
+        SAVED_ERROR=1
+    fi
+    ERROR="$SAVED_ERROR"
+    DEPENDENCIES_FAILED="$SAVED_DEPENDENCIES_FAILED"
+else
+    if false; then
+        false
+    elif [ "$OPT_TOOLKIT" = "gtk3" ]; then
+        echo "  toolkit: $OPT_TOOLKIT" >> $TEMP_DIR/options
+        if checkopt_toolkit_gtk3 ; then
+            :
+        else
+            ERROR=1
+        fi
+    elif [ "$OPT_TOOLKIT" = "cli" ]; then
+        echo "  toolkit: $OPT_TOOLKIT" >> $TEMP_DIR/options
+        if checkopt_toolkit_cli ; then
+            :
+        else
+            ERROR=1
+        fi
+    elif [ "$OPT_TOOLKIT" = "gtk2" ]; then
+        echo "  toolkit: $OPT_TOOLKIT" >> $TEMP_DIR/options
+        if checkopt_toolkit_gtk2 ; then
+            :
+        else
+            ERROR=1
+        fi
+    elif [ "$OPT_TOOLKIT" = "wpf" ]; then
+        echo "  toolkit: $OPT_TOOLKIT" >> $TEMP_DIR/options
+        if checkopt_toolkit_wpf ; then
+            :
+        else
+            ERROR=1
+        fi
+    fi
+fi
 
-echo >> "$TEMP_DIR/config.mk"
 if [ -n "${TEMP_CFLAGS}" ]; then
-    echo "CFLAGS  += $TEMP_CFLAGS" >> "$TEMP_DIR/config.mk"
+    echo "DAV_CFLAGS  += $TEMP_CFLAGS" >> "$TEMP_DIR/flags.mk"
+fi
+if [ -n "${TEMP_CXXFLAGS}" ]; then
+    echo "DAV_CXXFLAGS  += $TEMP_CXXFLAGS" >> "$TEMP_DIR/flags.mk"
 fi
 if [ "$BUILD_TYPE" = "debug" ]; then
-    echo 'CFLAGS += ${DEBUG_FLAGS}' >> "$TEMP_DIR/config.mk"
+    echo 'DAV_CFLAGS += ${DEBUG_CC_FLAGS}' >> "$TEMP_DIR/flags.mk"
+    echo 'DAV_CXXFLAGS += ${DEBUG_CXX_FLAGS}' >> "$TEMP_DIR/flags.mk"
 fi
 if [ "$BUILD_TYPE" = "release" ]; then
-    echo 'CFLAGS += ${RELEASE_FLAGS}' >> "$TEMP_DIR/config.mk"
+    echo 'DAV_CFLAGS += ${RELEASE_CC_FLAGS}' >> "$TEMP_DIR/flags.mk"
+    echo 'DAV_CXXFLAGS += ${RELEASE_CXX_FLAGS}' >> "$TEMP_DIR/flags.mk"
 fi
 if [ -n "${TEMP_LDFLAGS}" ]; then
-    echo "LDFLAGS += $TEMP_LDFLAGS" >> "$TEMP_DIR/config.mk"
+    echo "DAV_LDFLAGS += $TEMP_LDFLAGS" >> "$TEMP_DIR/flags.mk"
+fi
+
+echo >> "$TEMP_DIR/flags.mk"
+# Target
+echo "# flags for unnamed target" >> "$TEMP_DIR/flags.mk"
+TEMP_CFLAGS=
+TEMP_CXXFLAGS=
+TEMP_LDFLAGS=
+
+if dependency_error_deptest; then
+    DEPENDENCIES_FAILED="$DEPENDENCIES_FAILED deptest "
+    ERROR=1
 fi
 
+# Features
+
+
+if [ -n "${TEMP_CFLAGS}" ]; then
+    echo "CFLAGS  += $TEMP_CFLAGS" >> "$TEMP_DIR/flags.mk"
+fi
+if [ -n "${TEMP_CXXFLAGS}" ]; then
+    echo "CXXFLAGS  += $TEMP_CXXFLAGS" >> "$TEMP_DIR/flags.mk"
+fi
+if [ "$BUILD_TYPE" = "debug" ]; then
+    echo 'CFLAGS += ${DEBUG_CC_FLAGS}' >> "$TEMP_DIR/flags.mk"
+    echo 'CXXFLAGS += ${DEBUG_CXX_FLAGS}' >> "$TEMP_DIR/flags.mk"
+fi
+if [ "$BUILD_TYPE" = "release" ]; then
+    echo 'CFLAGS += ${RELEASE_CC_FLAGS}' >> "$TEMP_DIR/flags.mk"
+    echo 'CXXFLAGS += ${RELEASE_CXX_FLAGS}' >> "$TEMP_DIR/flags.mk"
+fi
+if [ -n "${TEMP_LDFLAGS}" ]; then
+    echo "LDFLAGS += $TEMP_LDFLAGS" >> "$TEMP_DIR/flags.mk"
+fi
+
+
+# final result
 if [ $ERROR -ne 0 ]; then
     echo
     echo "Error: Unresolved dependencies"
@@ -407,14 +702,30 @@
 echo "Build Config:"
 echo "  PREFIX:    $PREFIX"
 echo "  TOOLCHAIN: $TOOLCHAIN_NAME"
+echo "Options:"
+cat "$TEMP_DIR/options"
 echo "Features:"
-if [ -n "$FEATURE_PG" ]; then
-echo "  pg: on"
+if [ -n "$FEATURE_DB" ]; then
+echo "  db: on"
 else
-echo "  pg: off"
+echo "  db: off"
+fi
+if [ -n "$FEATURE_GUI" ]; then
+echo "  gui: on"
+else
+echo "  gui: off"
 fi
 echo
-cat "$TEMP_DIR/config.mk" "$TEMP_DIR/make.mk" > config.mk
+
+# generate the config.mk file
+cat > "$TEMP_DIR/config.mk" << __EOF__
+#
+# config.mk generated by configure
+#
+
+__EOF__
+write_toolchain_defaults "$TEMP_DIR/config.mk"
+cat "$TEMP_DIR/config.mk" "$TEMP_DIR/flags.mk" "$TEMP_DIR/make.mk" > config.mk
 rm -Rf "$TEMP_DIR"
 
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/make/cc.mk	Mon Sep 18 23:20:29 2023 +0200
@@ -0,0 +1,14 @@
+#
+# cc toolchain config
+#
+
+CFLAGS =
+CXXFLAGS =
+DEBUG_CC_FLAGS = -g
+DEBUG_CXX_FLAGS = -g
+RELEASE_CC_FLAGS = -O3 -DNDEBUG
+RELEASE_CXX_FLAGS = -O3 -DNDEBUG
+LDFLAGS =
+
+SHLIB_CFLAGS = -fPIC
+SHLIB_LDFLAGS = -shared
\ No newline at end of file
--- a/test/make/clang.mk	Mon Sep 18 22:49:54 2023 +0200
+++ b/test/make/clang.mk	Mon Sep 18 23:20:29 2023 +0200
@@ -3,8 +3,11 @@
 #
 
 CFLAGS =
-DEBUG_FLAGS = -g
-RELEASE_FLAGS = -O3 -DNDEBUG
+CXXFLAGS =
+DEBUG_CC_FLAGS = -g
+DEBUG_CXX_FLAGS = -g
+RELEASE_CC_FLAGS = -O3 -DNDEBUG
+RELEASE_CXX_FLAGS = -O3 -DNDEBUG
 LDFLAGS =
 
 SHLIB_CFLAGS = -fPIC
--- a/test/make/configure.vm	Mon Sep 18 22:49:54 2023 +0200
+++ b/test/make/configure.vm	Mon Sep 18 23:20:29 2023 +0200
@@ -200,7 +200,7 @@
 ]]#
 ## End of unparsed content **
 
-# generate config.mk
+# generate vars.mk
 cat > "$TEMP_DIR/vars.mk" << __EOF__
 PREFIX=$PREFIX
 EPREFIX=$EPREFIX
@@ -219,22 +219,11 @@
 ${var.varName}=$${var.varName}
 #end
 __EOF__
-cat > "$TEMP_DIR/config.mk" << __EOF__
-#
-# config.mk generated by configure
-#
-__EOF__
-sort -u "$TEMP_DIR/vars.mk" >> "$TEMP_DIR/config.mk"
+sort -u -o "$TEMP_DIR/vars.mk" "$TEMP_DIR/vars.mk"
 
 
-# toolchain detection
-# this will insert make vars to config.mk
+# toolchain detection utilities
 . make/toolchain.sh
-if [ -n "$TOOLCHAIN_ERROR" ]; then
-    echo "Toolchain error: $TOOLCHAIN_ERROR"
-    echo "Abort."
-    abort_configure
-fi
 
 #
 # DEPENDENCIES
@@ -247,11 +236,11 @@
 {
     if "$PKG_CONFIG" --exists "$1" ; then :
     else return 1 ; fi
-    if [ -n "$2" ] && "$PKG_CONFIG" --atleast-version="$2" "$1" ; then :
+    if [ -z "$2" ] || "$PKG_CONFIG" --atleast-version="$2" "$1" ; then :
     else return 1 ; fi
-    if [ -n "$3" ] && "$PKG_CONFIG" --exact-version="$3" "$1" ; then :
+    if [ -z "$3" ] || "$PKG_CONFIG" --exact-version="$3" "$1" ; then :
     else return 1 ; fi
-    if [ -n "$4" ] && "$PKG_CONFIG" --max-version="$4" "$1" ; then :
+    if [ -z "$4" ] || "$PKG_CONFIG" --max-version="$4" "$1" ; then :
     else return 1 ; fi
     return 0
 }
@@ -274,6 +263,13 @@
             break
         fi
         #end
+        #foreach( $lang in $sub.lang )
+        if detect_${lang}_compiler ; then
+            :
+        else
+            break
+        fi
+        #end
         #if( $sub.pkgconfig.size() > 0 )
         if [ -z "$PKG_CONFIG" ]; then
             break
@@ -321,11 +317,15 @@
 }
 #end
 
+# start collecting dependency information
+echo > "$TEMP_DIR/flags.mk"
+
 DEPENDENCIES_FAILED=
 ERROR=0
 #if( $dependencies.size() > 0 )
 # unnamed dependencies
 TEMP_CFLAGS=
+TEMP_CXXFLAGS=
 TEMP_LDFLAGS=
 #foreach( $dependency in $dependencies )
 while true
@@ -342,6 +342,14 @@
     #end
     while true
     do
+        #foreach( $lang in $dependency.lang )
+        if detect_${lang}_compiler ; then
+            :
+        else
+            ERROR=1
+            break
+        fi
+        #end
         #if( $dependency.pkgconfig.size() > 0 )
         if [ -z "$PKG_CONFIG" ]; then
             ERROR=1
@@ -385,13 +393,16 @@
 done
 #end
 
-# add unnamed dependency flags to config.mk
-echo >> "$TEMP_DIR/config.mk"
+# add general dependency flags to flags.mk
+echo "# general flags" >> "$TEMP_DIR/flags.mk"
 if [ -n "${TEMP_CFLAGS}" ]; then
-    echo "CFLAGS += $TEMP_CFLAGS" >> "$TEMP_DIR/config.mk"
+    echo "CFLAGS += $TEMP_CFLAGS" >> "$TEMP_DIR/flags.mk"
+fi
+if [ -n "${TEMP_CXXFLAGS}" ]; then
+    echo "CXXFLAGS += $TEMP_CXXFLAGS" >> "$TEMP_DIR/flags.mk"
 fi
 if [ -n "${TEMP_LDFLAGS}" ]; then
-    echo "LDFLAGS += $TEMP_LDFLAGS" >> "$TEMP_DIR/config.mk"
+    echo "LDFLAGS += $TEMP_LDFLAGS" >> "$TEMP_DIR/flags.mk"
 fi
 #end
 
@@ -413,6 +424,7 @@
     fi
     #foreach( $def in $val.defines )
         TEMP_CFLAGS="$TEMP_CFLAGS ${def.toFlags()}"
+        TEMP_CXXFLAGS="$TEMP_CXXFLAGS ${def.toFlags()}"
     #end
     #if( $val.hasMake() )
     cat >> "$TEMP_DIR/make.mk" << __EOF__
@@ -429,12 +441,16 @@
 #
 
 #foreach( $target in $targets )
+echo >> "$TEMP_DIR/flags.mk"
 #if ( $target.name )
 # Target: $target.name
+echo "# flags for target $target.name" >> "$TEMP_DIR/flags.mk"
 #else
 # Target
+echo "# flags for unnamed target" >> "$TEMP_DIR/flags.mk"
 #end
 TEMP_CFLAGS=
+TEMP_CXXFLAGS=
 TEMP_LDFLAGS=
 
 #foreach( $dependency in $target.dependencies )
@@ -506,21 +522,27 @@
 fi
 #end
 
-echo >> "$TEMP_DIR/config.mk"
 if [ -n "${TEMP_CFLAGS}" ]; then
-    echo "${target.getCFlags()}  += $TEMP_CFLAGS" >> "$TEMP_DIR/config.mk"
+    echo "${target.getCFlags()}  += $TEMP_CFLAGS" >> "$TEMP_DIR/flags.mk"
+fi
+if [ -n "${TEMP_CXXFLAGS}" ]; then
+    echo "${target.getCXXFlags()}  += $TEMP_CXXFLAGS" >> "$TEMP_DIR/flags.mk"
 fi
 if [ "$BUILD_TYPE" = "debug" ]; then
-    echo '${target.getCFlags()} += ${DEBUG_FLAGS}' >> "$TEMP_DIR/config.mk"
+    echo '${target.getCFlags()} += ${DEBUG_CC_FLAGS}' >> "$TEMP_DIR/flags.mk"
+    echo '${target.getCXXFlags()} += ${DEBUG_CXX_FLAGS}' >> "$TEMP_DIR/flags.mk"
 fi
 if [ "$BUILD_TYPE" = "release" ]; then
-    echo '${target.getCFlags()} += ${RELEASE_FLAGS}' >> "$TEMP_DIR/config.mk"
+    echo '${target.getCFlags()} += ${RELEASE_CC_FLAGS}' >> "$TEMP_DIR/flags.mk"
+    echo '${target.getCXXFlags()} += ${RELEASE_CXX_FLAGS}' >> "$TEMP_DIR/flags.mk"
 fi
 if [ -n "${TEMP_LDFLAGS}" ]; then
-    echo "${target.getLDFlags()} += $TEMP_LDFLAGS" >> "$TEMP_DIR/config.mk"
+    echo "${target.getLDFlags()} += $TEMP_LDFLAGS" >> "$TEMP_DIR/flags.mk"
 fi
 
 #end
+
+# final result
 if [ $ERROR -ne 0 ]; then
     echo
     echo "Error: Unresolved dependencies"
@@ -548,7 +570,16 @@
 #end
 #end
 echo
-cat "$TEMP_DIR/config.mk" "$TEMP_DIR/make.mk" > config.mk
+
+# generate the config.mk file
+cat > "$TEMP_DIR/config.mk" << __EOF__
+#
+# config.mk generated by configure
+#
+
+__EOF__
+write_toolchain_defaults "$TEMP_DIR/config.mk"
+cat "$TEMP_DIR/config.mk" "$TEMP_DIR/flags.mk" "$TEMP_DIR/make.mk" > config.mk
 rm -Rf "$TEMP_DIR"
 
 
--- a/test/make/gcc.mk	Mon Sep 18 22:49:54 2023 +0200
+++ b/test/make/gcc.mk	Mon Sep 18 23:20:29 2023 +0200
@@ -3,9 +3,12 @@
 #
 
 CFLAGS =
-DEBUG_FLAGS = -g
-RELEASE_FLAGS = -O3 -DNDEBUG
-LDFLAGS = 
+CXXFLAGS =
+DEBUG_CC_FLAGS = -g
+DEBUG_CXX_FLAGS = -g
+RELEASE_CC_FLAGS = -O3 -DNDEBUG
+RELEASE_CXX_FLAGS = -O3 -DNDEBUG
+LDFLAGS =
 
 SHLIB_CFLAGS = -fPIC
 SHLIB_LDFLAGS = -shared
--- a/test/make/suncc.mk	Mon Sep 18 22:49:54 2023 +0200
+++ b/test/make/suncc.mk	Mon Sep 18 23:20:29 2023 +0200
@@ -3,8 +3,11 @@
 #
 
 CFLAGS =
-DEBUG_FLAGS = -g
-RELEASE_FLAGS = -O3 -DNDEBUG
+CXXFLAGS =
+DEBUG_CC_FLAGS = -g
+DEBUG_CXX_FLAGS = -g
+RELEASE_CC_FLAGS = -O3 -DNDEBUG
+RELEASE_CXX_FLAGS = -O3 -DNDEBUG
 LDFLAGS =
 
 SHLIB_CFLAGS = -Kpic
--- a/test/make/toolchain.sh	Mon Sep 18 22:49:54 2023 +0200
+++ b/test/make/toolchain.sh	Mon Sep 18 23:20:29 2023 +0200
@@ -5,11 +5,9 @@
 
 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()
 {
@@ -46,7 +44,7 @@
 #elif defined(__sun)
 	std::cout << "suncc" << std::endl;
 #else
-	std::cout << "unknown" << std::endl;
+	std::cout << "cc" << std::endl;
 #endif
 	return 0;
 }
@@ -55,96 +53,121 @@
 	$1 -o "$TEMP_DIR/checkcc" $CXXFLAGS $LDFLAGS "$TEMP_DIR/test.cpp" 2> /dev/null
 }
 
-check_lib()
+check_c_lib()
 {
-	if [ -z "$TOOLCHAIN_LD" ]; then
-		return 1
-	fi
+  if [ -z "$TOOLCHAIN_CC" ]; then
+    return 1
+  fi
 	cat > "$TEMP_DIR/test.c" << __EOF__
 /* libtest file */
 int main(int argc, char **argv) {
 	return 0;
 }
 __EOF__
-	rm -f "$TEMP_DIR/checklib"
-	$TOOLCHAIN_LD -o "$TEMP_DIR/checklib" $CFLAGS $LDFLAGS "-l$1" "$TEMP_DIR/test.c" 2> /dev/null
+  rm -f "$TEMP_DIR/checklib"
+	$TOOLCHAIN_CC -o "$TEMP_DIR/checklib" $CFLAGS $LDFLAGS "-l$1" "$TEMP_DIR/test.c" 2> /dev/null
+}
+
+check_cpp_lib()
+{
+  if [ -z "$TOOLCHAIN_CXX" ]; then
+    return 1
+  fi
+	cat > "$TEMP_DIR/test.cpp" << __EOF__
+/* libtest file */
+int main(int argc, char **argv) {
+	return 0;
+}
+__EOF__
+  rm -f "$TEMP_DIR/checklib"
+	$TOOLCHAIN_CXX -o "$TEMP_DIR/checklib" $CXXFLAGS $LDFLAGS "-l$1" "$TEMP_DIR/test.cpp" 2> /dev/null
+}
+
+check_lib()
+{
+	if [ -n "$TOOLCHAIN_CC" ]; then
+		check_c_lib "$1"
+	elif  [ -n "$TOOLCHAIN_CXX" ]; then
+	  check_cpp_lib "$1"
+	fi
 }
 
-printf "detect C compiler... "
-
-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"
+detect_c_compiler()
+{
+  if [ -n "$TOOLCHAIN_CC" ]; then
+    return 0
   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... "
-
-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
+  printf "detect C compiler... "
+  if [ -n "$CC" ]; then
+    if check_c_compiler "$CC"; then
+      TOOLCHAIN_CC=$CC
       TOOLCHAIN_NAME=`"$TEMP_DIR/checkcc"`
-      TOOLCHAIN_CXX=$COMP
-      break
+      echo "$CC"
+      return 0
+    else
+      echo "$CC is not a working C compiler"
+      return 1
     fi
-  done
-  echo ${TOOLCHAIN_CXX:-"not found"}
-fi
+  else
+    for COMP in $C_COMPILERS
+    do
+      if check_c_compiler "$COMP"; then
+        TOOLCHAIN_CC=$COMP
+        TOOLCHAIN_NAME=`"$TEMP_DIR/checkcc"`
+        echo "$COMP"
+        return 0
+      fi
+    done
+    echo "not found"
+    return 1
+  fi
+}
 
-printf "detect linker... "
-TOOLCHAIN_LD=$TOOLCHAIN_CC
-echo "$TOOLCHAIN_LD"
-
-if [ -z "$TOOLCHAIN_NAME" ]; then
-  TOOLCHAIN_ERROR="no build tools detected"
-else
-	cat >> "$TEMP_DIR/config.mk" << __EOF__
+detect_cpp_compiler()
+{
+  if [ -n "$TOOLCHAIN_CXX" ]; then
+    return 0
+  fi
+  printf "detect C++ compiler... "
 
-# toolchain
-__EOF__
-	echo "CC = ${TOOLCHAIN_CC}" >> "$TEMP_DIR/config.mk"
-	if [ -n "$TOOLCHAIN_CXX" ]; then
-		echo "CXX = ${TOOLCHAIN_CXX}" >> "$TEMP_DIR/config.mk"
-	fi
-	echo "LD = ${TOOLCHAIN_LD}" >> "$TEMP_DIR/config.mk"
-	echo >> "$TEMP_DIR/config.mk"
-	
-	if [ -f "make/${TOOLCHAIN_NAME}.mk" ]; then
-		cat "make/${TOOLCHAIN_NAME}.mk" >> "$TEMP_DIR/config.mk"
-	else
-		cat >> "$TEMP_DIR/config.mk" << __EOF__
-CFLAGS =
-DEBUG_FLAGS = -g
-RELEASE_FLAGS = -O3 -DNDEBUG
-LDFLAGS =
+  if [ -n "$CXX" ]; then
+    if check_cpp_compiler "$CXX"; then
+      TOOLCHAIN_CXX=$CXX
+      TOOLCHAIN_NAME=`"$TEMP_DIR/checkcc"`
+      echo "$CXX"
+      return 0
+    else
+      echo "$CXX is not a working C++ compiler"
+      return 1
+    fi
+  else
+    for COMP in $CPP_COMPILERS
+    do
+      if check_cpp_compiler "$COMP"; then
+        TOOLCHAIN_CXX=$COMP
+        TOOLCHAIN_NAME=`"$TEMP_DIR/checkcc"`
+        echo "$COMP"
+        return 0
+      fi
+    done
+    echo "${TOOLCHAIN_CXX:-"not found"}"
+    return 1
+  fi
+}
 
-SHLIB_CFLAGS = -fPIC
-SHLIB_LDFLAGS = -shared
-__EOF__
-	fi
-fi
+write_toolchain_defaults()
+{
+  echo "# toolchain" >> "$1"
+  if [ -n "$TOOLCHAIN_CC" ]; then
+    echo "CC = ${TOOLCHAIN_CC}" >> "$1"
+  fi
+  if [ -n "$TOOLCHAIN_CXX" ]; then
+    echo "CXX = ${TOOLCHAIN_CXX}" >> "$1"
+  fi
+  echo >> "$1"
+  if [ -f "make/${TOOLCHAIN_NAME}.mk" ]; then
+    cat "make/${TOOLCHAIN_NAME}.mk" >> "$1"
+  else
+    echo "!!! WARNING !!! Default toolchain flags not found. Configuration might be incomplete."
+  fi
+}

mercurial