add RegressionTest - fixes #264

Wed, 06 Sep 2023 21:08:04 +0200

author
Mike Becker <universe@uap-core.de>
date
Wed, 06 Sep 2023 21:08:04 +0200
changeset 39
3ca85da78515
parent 38
02b000e40e5e
child 40
b42bfc9e9983

add RegressionTest - fixes #264

pom.xml file | annotate | diff | comparison | revisions
src/main/java/de/unixwork/uwproj/Dependency.java file | annotate | diff | comparison | revisions
src/main/java/de/unixwork/uwproj/Main.java file | annotate | diff | comparison | revisions
src/main/java/de/unixwork/uwproj/Project.java file | annotate | diff | comparison | revisions
src/test/java/de/unixwork/uwproj/RegressionTest.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/make/configure.vm file | annotate | diff | comparison | revisions
--- a/pom.xml	Sun Sep 03 12:43:44 2023 +0200
+++ b/pom.xml	Wed Sep 06 21:08:04 2023 +0200
@@ -15,6 +15,12 @@
             <artifactId>velocity-engine-core</artifactId>
             <version>2.3</version>
         </dependency>
+        <dependency>
+            <groupId>org.junit.jupiter</groupId>
+            <artifactId>junit-jupiter</artifactId>
+            <version>5.10.0</version>
+            <scope>test</scope>
+        </dependency>
     </dependencies>
     <build>
         <plugins>
--- a/src/main/java/de/unixwork/uwproj/Dependency.java	Sun Sep 03 12:43:44 2023 +0200
+++ b/src/main/java/de/unixwork/uwproj/Dependency.java	Wed Sep 06 21:08:04 2023 +0200
@@ -5,12 +5,13 @@
  */
 package de.unixwork.uwproj;
 
-import java.util.LinkedList;
-import java.util.List;
 import org.w3c.dom.Element;
 import org.w3c.dom.Node;
 import org.w3c.dom.NodeList;
 
+import java.util.LinkedList;
+import java.util.List;
+
 /**
  *
  * @author olaf
@@ -85,11 +86,11 @@
         return platform;
     }
     
-    public String getPlatformString() {
+    public String getFullName() {
         if(platform == null || platform.length() == 0) {
-            return "";
+            return name;
         } else {
-            return "platform=\""+platform+'"';
+            return name+" platform=\""+platform+'"';
         }
     }
     
--- a/src/main/java/de/unixwork/uwproj/Main.java	Sun Sep 03 12:43:44 2023 +0200
+++ b/src/main/java/de/unixwork/uwproj/Main.java	Wed Sep 06 21:08:04 2023 +0200
@@ -1,69 +1,44 @@
-/*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
 package de.unixwork.uwproj;
 
-import java.io.BufferedWriter;
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.OutputStreamWriter;
-import java.io.StringWriter;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-import org.apache.velocity.Template;
 import org.apache.velocity.VelocityContext;
 import org.apache.velocity.app.VelocityEngine;
-import org.xml.sax.SAXException;
+
+import java.io.*;
+
+public class Main {
+
+    static Project loadProjectFile(String fileName) {
+        try {
+            return new Project(new File(fileName));
+        } catch (Exception e) {
+            throw new RuntimeException(e);
+        }
+    }
 
-/**
- *
- * @author olaf
- */
-public class Main {
+    static void writeConfigureScript(Writer out, String tplFileName, Project project) {
+        var context = new VelocityContext();
+        context.put("targets", project.getTargets());
+        context.put("namedDependencies", project.getNamedDependencies());
+        context.put("dependencies", project.getDependencies());
+        context.put("options", project.getOptions());
+        context.put("features", project.getFeatures());
+        context.put("project", project);
+        context.put("vars", project.getVars());
+        new VelocityEngine().getTemplate(tplFileName).merge(context, out);
+    }
+
     public static void main(String[] args){
-        File f = new File("make/project.xml");
-        Project p = null;
-        try {
-            p = new Project(f);
-        } catch (SAXException ex) {
-            Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
-        } catch (IOException ex) {
-            Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
+        final var inFileName = "make/project.xml";
+        final var tplFileName = "make/configure.vm";
+        final var outFileName = "configure";
+
+        try (var out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(outFileName)))) {
+            writeConfigureScript(out, tplFileName, loadProjectFile(inFileName));
         } catch (Exception ex) {
-            Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
-        }
-        if(p == null) {
+            ex.printStackTrace();
             System.exit(1);
         }
-        
-        VelocityEngine ve = new VelocityEngine();
-        Template t = ve.getTemplate("make/configure.vm");
-        VelocityContext context = new VelocityContext();
-        context.put("targets", p.getTargets());
-        context.put("namedDependencies", p.getNamedDependencies());
-        context.put("dependencies", p.getDependencies());
-        context.put("options", p.getOptions());
-        context.put("features", p.getFeatures());
-        context.put("project", p);
-        context.put("vars", p.getVars());
-        
-        int ret = 1;
-        try {
-            FileOutputStream fout = new FileOutputStream(new File("configure"));
-            BufferedWriter out = new BufferedWriter(new OutputStreamWriter(fout));
-            t.merge(context, out);
-            out.close();
-            ret = 0;
-            System.out.println("Out: configure");
-        } catch (FileNotFoundException ex) {
-            Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
-        } catch (IOException ex) {
-            Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
-        }
-        System.exit(ret);
+
+        System.out.println("Out: "+outFileName);
     }
 }
--- a/src/main/java/de/unixwork/uwproj/Project.java	Sun Sep 03 12:43:44 2023 +0200
+++ b/src/main/java/de/unixwork/uwproj/Project.java	Wed Sep 06 21:08:04 2023 +0200
@@ -5,23 +5,15 @@
  */
 package de.unixwork.uwproj;
 
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.util.HashMap;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-import java.util.Properties;
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.parsers.ParserConfigurationException;
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
 import org.w3c.dom.Node;
 import org.w3c.dom.NodeList;
-import org.xml.sax.SAXException;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import java.io.File;
+import java.util.*;
 
 /**
  *
@@ -40,7 +32,7 @@
     private HashMap<String,ConfigVar> configVars = new HashMap<>();
     private List<ConfigVar> configVarsList = new LinkedList<>();
        
-    public Project(File file) throws ParserConfigurationException, SAXException, IOException, Exception {
+    public Project(File file) throws Exception {
         DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
         factory.setNamespaceAware(true);
 	DocumentBuilder builder = factory.newDocumentBuilder();
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/test/java/de/unixwork/uwproj/RegressionTest.java	Wed Sep 06 21:08:04 2023 +0200
@@ -0,0 +1,39 @@
+package de.unixwork.uwproj;
+
+import org.junit.jupiter.api.Test;
+
+import java.io.BufferedWriter;
+import java.io.ByteArrayOutputStream;
+import java.io.OutputStreamWriter;
+import java.nio.charset.StandardCharsets;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.Objects;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+public class RegressionTest {
+
+    private void goldenSampleTest(String xml, String gs) throws Exception {
+        final var contents = new ByteArrayOutputStream();
+        try (var out = new BufferedWriter(new OutputStreamWriter(contents))) {
+            Main.writeConfigureScript(out, "test/make/configure.vm", Main.loadProjectFile("test/make/" + xml));
+        }
+        assertEquals(
+                Files.readString(Path.of(
+                        Objects.requireNonNull(RegressionTest.class.getClassLoader().getResource("golden-sample/" + gs)).toURI()
+                )),
+                contents.toString(StandardCharsets.UTF_8)
+        );
+    }
+
+    @Test
+    void projectXmlOutput() throws Exception {
+        goldenSampleTest("project.xml", "configure");
+    }
+
+    @Test
+    void project2XmlOutput() throws Exception {
+        goldenSampleTest("project2.xml", "configure2");
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/test/resources/golden-sample/configure	Wed Sep 06 21:08:04 2023 +0200
@@ -0,0 +1,436 @@
+#!/bin/sh
+
+HOST=`uname -n`
+PREFIX=`pwd`/work
+INSTALL_DIR=$PREFIX
+
+EPREFIX=$PREFIX
+
+BINDIR=
+SBINDIR=
+LIBDIR=
+LIBEXECDIR=
+DATADIR=
+SYSCONFDIR=
+SHAREDSTATEDIR=
+LOCALSTATEDIR=
+INCLUDEDIR=
+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"
+
+# features
+
+# help text
+printhelp()
+{
+    echo "Usage: $0 [OPTIONS]..."
+    cat << __EOF__
+Installation directories:
+  --prefix=PREFIX         path prefix for architecture-independent files
+                          [/usr]
+  --exec-prefix=EPREFIX   path prefix for architecture-dependent files
+                          [PREFIX]
+
+  --bindir=DIR            user executables [EPREFIX/bin]
+  --sbindir=DIR           system admin executables [EPREFIX/sbin]
+  --libexecdir=DIR        program executables [EPREFIX/libexec]
+  --sysconfdir=DIR        system configuration files [PREFIX/etc]
+  --sharedstatedir=DIR    modifiable architecture-independent data [PREFIX/com]
+  --localstatedir=DIR     modifiable single-machine data [PREFIX/var]
+  --libdir=DIR            object code libraries [EPREFIX/lib]
+  --includedir=DIR        C header files [PREFIX/include]
+  --datarootdir=DIR       read-only arch.-independent data root [PREFIX/share]
+  --datadir=DIR           read-only architecture-independent data [DATAROOTDIR]
+  --infodir=DIR           info documentation [DATAROOTDIR/info]
+  --mandir=DIR            man documentation [DATAROOTDIR/man]
+
+Optional Features:
+  --enable-pg
+
+__EOF__
+}
+
+#
+# parse arguments
+#
+for ARG in "$@"
+do
+    case "$ARG" in
+        "--prefix="*)         PREFIX=${ARG#--prefix=} ;;
+        "--exec-prefix="*)    EPREFIX=${ARG#--exec-prefix=} ;;
+        "--bindir="*)         BINDIR=${ARG#----bindir=} ;;
+        "--sbindir="*)        SBINDIR=${ARG#--sbindir=} ;;
+        "--libdir="*)         LIBDIR=${ARG#--libdir=} ;;
+        "--libexecdir="*)     LIBEXECDIR=${ARG#--libexecdir=} ;;
+        "--datadir="*)        DATADIR=${ARG#--datadir=} ;;
+        "--sysconfdir="*)     SYSCONFDIR=${ARG#--sysconfdir=} ;;
+        "--sharedstatedir="*) SHAREDSTATEDIR=${ARG#--sharedstatedir=} ;;
+        "--localstatedir="*)  LOCALSTATEDIR=${ARG#--localstatedir=} ;;
+        "--includedir="*)     INCLUDEDIR=${ARG#--includedir=} ;;
+        "--infodir="*)        INFODIR=${ARG#--infodir=} ;;
+        "--mandir"*)          MANDIR=${ARG#--mandir} ;;
+        "--help"*) printhelp; rm -Rf "$TEMP_DIR"; exit 1 ;;
+        "--enable-pg") FEATURE_PG=on ;;
+        "--disable-pg") unset FEATURE_PG ;;
+        "-"*) echo "unknown option: $ARG"; rm -Rf "$TEMP_DIR"; exit 1 ;;
+    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
+
+which pkg-config > /dev/null
+if [ $? -eq 0 ]; then
+    PKG_CONFIG=pkg-config
+else
+    PKG_CONFIG=false
+fi
+
+# Simple uname based platform detection
+# $PLATFORM is used for platform dependent dependency selection
+printf "detect platform... "
+if [ "$OS" = "SunOS" ]; then
+    PLATFORM="solaris sunos unix svr4"
+fi
+if [ "$OS" = "Linux" ]; then
+    PLATFORM="linux unix"
+fi
+if [ "$OS" = "FreeBSD" ]; then
+    PLATFORM="freebsd bsd unix"
+fi
+if [ "$OS" = "Darwin" ]; then
+    PLATFORM="macos osx bsd unix"
+fi
+echo "$OS" | grep -i "MINGW" > /dev/null
+if [ $? -eq 0 ]; then
+    PLATFORM="windows mingw"
+fi
+
+if [ -z "$PLATFORM" ]; then
+    PLATFORM="unix"
+fi
+
+for p in $PLATFORM
+do
+    PLATFORM_NAME=$p
+    break
+done
+echo $PLATFORM_NAME
+
+isplatform()
+{
+    for p in $PLATFORM
+    do
+        if [ "$p" = "$1" ]; then
+            return 0
+        fi
+    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
+PREFIX=$PREFIX
+INSTALL_DIR=$INSTALL_DIR
+
+EPREFIX=$EPREFIX
+
+BINDIR=$BINDIR
+SBINDIR=$SBINDIR
+LIBDIR=$LIBDIR
+LIBEXECDIR=$LIBEXECDIR
+DATADIR=$DATADIR
+SYSCONFDIR=$SYSCONFDIR
+SHAREDSTATEDIR=$SHAREDSTATEDIR
+LOCALSTATEDIR=$LOCALSTATEDIR
+INCLUDEDIR=$INCLUDEDIR
+INFODIR=$INFODIR
+MANDIR=$MANDIR
+
+__EOF__
+
+echo > "$TEMP_DIR/make.mk"
+
+ENV_CFLAGS=$CFLAGS
+ENV_LDFLAGS=$LDFLAGS
+ENV_CXXFLAGS=$CXXFLAGS
+
+# 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"
+fi
+
+#
+# DEPENDENCIES
+#
+
+dependency_libpq()
+{
+    printf "checking for libpq... "
+    # dependency libpq
+    while true
+    do
+        if [ -z "$PKG_CONFIG" ]; then
+            break
+        fi
+        $PKG_CONFIG libpq
+        if [ $? -ne 0 ] ; then
+            break
+        fi
+        TEMP_CFLAGS="$TEMP_CFLAGS `$PKG_CONFIG --cflags libpq`"
+        TEMP_LDFLAGS="$TEMP_LDFLAGS `$PKG_CONFIG --libs libpq`"
+        echo yes
+        return 0
+    done
+
+    echo no
+    return 1
+}
+dependency_openssl()
+{
+    printf "checking for openssl... "
+    # dependency openssl
+    while true
+    do
+        if [ -z "$PKG_CONFIG" ]; then
+            break
+        fi
+        $PKG_CONFIG openssl
+        if [ $? -ne 0 ] ; then
+            break
+        fi
+        TEMP_CFLAGS="$TEMP_CFLAGS `$PKG_CONFIG --cflags openssl`"
+        TEMP_LDFLAGS="$TEMP_LDFLAGS `$PKG_CONFIG --libs openssl`"
+        echo yes
+        return 0
+    done
+
+    # dependency openssl platform="bsd"
+    while true
+    do
+        if isnotplatform "bsd"; then
+            break
+        fi
+        TEMP_LDFLAGS="$TEMP_LDFLAGS -lssl -lcrypto"
+        echo yes
+        return 0
+    done
+
+    echo no
+    return 1
+}
+dependency_libxml2()
+{
+    printf "checking for libxml2... "
+    # dependency libxml2 platform="macos"
+    while true
+    do
+        if isnotplatform "macos"; then
+            break
+        fi
+        xml2-config --cflags > /dev/null
+        if [ $? -eq 0 ]; then
+            TEMP_CFLAGS="$TEMP_CFLAGS `xml2-config --cflags`"
+        else
+            break
+        fi
+        xml2-config --libs > /dev/null
+        if [ $? -eq 0 ]; then
+            TEMP_LDFLAGS="$TEMP_LDFLAGS `xml2-config --libs`"
+        else
+            break
+        fi
+        echo yes
+        return 0
+    done
+
+    # dependency libxml2
+    while true
+    do
+        if [ -z "$PKG_CONFIG" ]; then
+            break
+        fi
+        $PKG_CONFIG libxml-2.0
+        if [ $? -ne 0 ] ; then
+            break
+        fi
+        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
+
+    echo no
+    return 1
+}
+
+DEPENDENCIES_FAILED=
+ERROR=0
+# general dependencies
+TEMP_CFLAGS=
+TEMP_LDFLAGS=
+while true
+do
+    while true
+    do
+
+
+        break
+    done
+
+    break
+done
+
+# add general 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
+fi
+if [ -n "${TEMP_LDFLAGS}" ]; then
+    echo "LDFLAGS += $TEMP_LDFLAGS" >> $TEMP_DIR/config.mk
+fi
+
+#
+# OPTION VALUES
+#
+
+#
+# TARGETS
+#
+TEMP_CFLAGS=
+TEMP_CXXFLAGS=
+TEMP_LDFLAGS=
+
+# Target
+TEMP_CFLAGS=
+TEMP_LDFLAGS=
+TEMP_CXXFLAGS=
+
+dependency_libxml2
+if [ $? -ne 0 ]; then
+    DEPENDENCIES_FAILED="$DEPENDENCIES_FAILED libxml2 "
+    ERROR=1
+fi
+dependency_openssl
+if [ $? -ne 0 ]; then
+    DEPENDENCIES_FAILED="$DEPENDENCIES_FAILED openssl "
+    ERROR=1
+fi
+
+# Features
+if [ -n "$FEATURE_PG" ]; then
+    # check dependency
+    dependency_libpq
+    if [ $? -ne 0 ]; then
+        # "auto" features can fail and are just disabled in this case
+        if [ "$FEATURE_PG" != "auto" ]; then
+            DEPENDENCIES_FAILED="$DEPENDENCIES_FAILED libpq "
+            ERROR=1
+        fi
+    fi
+fi
+
+
+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"
+fi
+if [ -n "${TEMP_LDFLAGS}" ]; then
+    echo "LDFLAGS += $TEMP_LDFLAGS" >> "$TEMP_DIR/config.mk"
+fi
+
+if [ $ERROR -ne 0 ]; then
+    echo
+    echo "Error: Unresolved dependencies"
+    echo "$DEPENDENCIES_FAILED"
+    rm -Rf "$TEMP_DIR"
+    exit 1
+fi
+
+echo "configure finished"
+echo
+echo "Build Config:"
+echo "  PREFIX:    $PREFIX"
+echo "  TOOLCHAIN: $TOOLCHAIN_NAME"
+echo
+cat "$TEMP_DIR/config.mk" "$TEMP_DIR/make.mk" > config.mk
+rm -Rf "$TEMP_DIR"
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/test/resources/golden-sample/configure2	Wed Sep 06 21:08:04 2023 +0200
@@ -0,0 +1,717 @@
+#!/bin/sh
+
+
+PREFIX=/usr
+EPREFIX=$PREFIX
+
+BINDIR=
+SBINDIR=
+LIBDIR=
+LIBEXECDIR=
+DATADIR=
+SYSCONFDIR=
+SHAREDSTATEDIR=
+LOCALSTATEDIR=
+INCLUDEDIR=
+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"
+
+# features
+FEATURE_DB=on
+
+# help text
+printhelp()
+{
+    echo "Usage: $0 [OPTIONS]..."
+    cat << __EOF__
+Installation directories:
+  --prefix=PREFIX         path prefix for architecture-independent files
+                          [/usr]
+  --exec-prefix=EPREFIX   path prefix for architecture-dependent files
+                          [PREFIX]
+
+  --bindir=DIR            user executables [EPREFIX/bin]
+  --sbindir=DIR           system admin executables [EPREFIX/sbin]
+  --libexecdir=DIR        program executables [EPREFIX/libexec]
+  --sysconfdir=DIR        system configuration files [PREFIX/etc]
+  --sharedstatedir=DIR    modifiable architecture-independent data [PREFIX/com]
+  --localstatedir=DIR     modifiable single-machine data [PREFIX/var]
+  --libdir=DIR            object code libraries [EPREFIX/lib]
+  --includedir=DIR        C header files [PREFIX/include]
+  --datarootdir=DIR       read-only arch.-independent data root [PREFIX/share]
+  --datadir=DIR           read-only architecture-independent data [DATAROOTDIR]
+  --infodir=DIR           info documentation [DATAROOTDIR/info]
+  --mandir=DIR            man documentation [DATAROOTDIR/man]
+
+Options:
+  --toolkit=(gtk3|cli|gtk2|wpf)
+
+Optional Features:
+  --disable-db
+  --enable-gui
+
+__EOF__
+}
+
+#
+# parse arguments
+#
+for ARG in "$@"
+do
+    case "$ARG" in
+        "--prefix="*)         PREFIX=${ARG#--prefix=} ;;
+        "--exec-prefix="*)    EPREFIX=${ARG#--exec-prefix=} ;;
+        "--bindir="*)         BINDIR=${ARG#----bindir=} ;;
+        "--sbindir="*)        SBINDIR=${ARG#--sbindir=} ;;
+        "--libdir="*)         LIBDIR=${ARG#--libdir=} ;;
+        "--libexecdir="*)     LIBEXECDIR=${ARG#--libexecdir=} ;;
+        "--datadir="*)        DATADIR=${ARG#--datadir=} ;;
+        "--sysconfdir="*)     SYSCONFDIR=${ARG#--sysconfdir=} ;;
+        "--sharedstatedir="*) SHAREDSTATEDIR=${ARG#--sharedstatedir=} ;;
+        "--localstatedir="*)  LOCALSTATEDIR=${ARG#--localstatedir=} ;;
+        "--includedir="*)     INCLUDEDIR=${ARG#--includedir=} ;;
+        "--infodir="*)        INFODIR=${ARG#--infodir=} ;;
+        "--mandir"*)          MANDIR=${ARG#--mandir} ;;
+        "--help"*) printhelp; rm -Rf "$TEMP_DIR"; exit 1 ;;
+        "--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"; rm -Rf "$TEMP_DIR"; exit 1 ;;
+    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
+
+which pkg-config > /dev/null
+if [ $? -eq 0 ]; then
+    PKG_CONFIG=pkg-config
+else
+    PKG_CONFIG=false
+fi
+
+# Simple uname based platform detection
+# $PLATFORM is used for platform dependent dependency selection
+printf "detect platform... "
+if [ "$OS" = "SunOS" ]; then
+    PLATFORM="solaris sunos unix svr4"
+fi
+if [ "$OS" = "Linux" ]; then
+    PLATFORM="linux unix"
+fi
+if [ "$OS" = "FreeBSD" ]; then
+    PLATFORM="freebsd bsd unix"
+fi
+if [ "$OS" = "Darwin" ]; then
+    PLATFORM="macos osx bsd unix"
+fi
+echo "$OS" | grep -i "MINGW" > /dev/null
+if [ $? -eq 0 ]; then
+    PLATFORM="windows mingw"
+fi
+
+if [ -z "$PLATFORM" ]; then
+    PLATFORM="unix"
+fi
+
+for p in $PLATFORM
+do
+    PLATFORM_NAME=$p
+    break
+done
+echo $PLATFORM_NAME
+
+isplatform()
+{
+    for p in $PLATFORM
+    do
+        if [ "$p" = "$1" ]; then
+            return 0
+        fi
+    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
+
+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
+
+__EOF__
+
+echo > "$TEMP_DIR/make.mk"
+
+ENV_CFLAGS=$CFLAGS
+ENV_LDFLAGS=$LDFLAGS
+ENV_CXXFLAGS=$CXXFLAGS
+
+# 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"
+fi
+
+#
+# DEPENDENCIES
+#
+
+dependency_qt4()
+{
+    printf "checking for qt4... "
+    # dependency qt4
+    while true
+    do
+        which qmake-qt4 > /dev/null
+        if [ $? -ne 0 ]; then
+        break
+        fi
+        echo yes
+        return 0
+    done
+
+    echo no
+    return 1
+}
+dependency_curl()
+{
+    printf "checking for curl... "
+    # dependency curl platform="windows"
+    while true
+    do
+        if isnotplatform "windows"; then
+            break
+        fi
+        TEMP_CFLAGS="$TEMP_CFLAGS -I/mingw/include"
+        TEMP_LDFLAGS="$TEMP_LDFLAGS -lcurl"
+        echo yes
+        return 0
+    done
+
+    # dependency curl platform="macos"
+    while true
+    do
+        if isnotplatform "macos"; then
+            break
+        fi
+        curl-config --cflags > /dev/null
+        if [ $? -eq 0 ]; then
+            TEMP_CFLAGS="$TEMP_CFLAGS `curl-config --cflags`"
+        else
+            break
+        fi
+        curl-config --ldflags > /dev/null
+        if [ $? -eq 0 ]; then
+            TEMP_LDFLAGS="$TEMP_LDFLAGS `curl-config --ldflags`"
+        else
+            break
+        fi
+        echo yes
+        return 0
+    done
+
+    # dependency curl
+    while true
+    do
+        if [ -z "$PKG_CONFIG" ]; then
+            break
+        fi
+        $PKG_CONFIG libcurl
+        if [ $? -ne 0 ] ; then
+            break
+        fi
+        TEMP_CFLAGS="$TEMP_CFLAGS `$PKG_CONFIG --cflags libcurl`"
+        TEMP_LDFLAGS="$TEMP_LDFLAGS `$PKG_CONFIG --libs libcurl`"
+        echo yes
+        return 0
+    done
+
+    echo no
+    return 1
+}
+dependency_test()
+{
+    printf "checking for test... "
+    # dependency test platform="bsd"
+    while true
+    do
+        if isnotplatform "bsd"; then
+            break
+        fi
+        if isplatform "macos"; then
+            break
+        fi
+        TEMP_CFLAGS="$TEMP_CFLAGS -DBSD"
+        echo yes
+        return 0
+    done
+
+    # dependency test
+    while true
+    do
+        TEMP_CFLAGS="$TEMP_CFLAGS -DTEST"
+        echo yes
+        return 0
+    done
+
+    echo no
+    return 1
+}
+dependency_sqlite()
+{
+    printf "checking for sqlite... "
+    # dependency sqlite
+    while true
+    do
+        if [ -z "$PKG_CONFIG" ]; then
+            break
+        fi
+        $PKG_CONFIG sqlite3
+        if [ $? -ne 0 ] ; then
+            break
+        fi
+        TEMP_CFLAGS="$TEMP_CFLAGS `$PKG_CONFIG --cflags sqlite3`"
+        TEMP_LDFLAGS="$TEMP_LDFLAGS `$PKG_CONFIG --libs sqlite3`"
+        echo yes
+        return 0
+    done
+
+    echo no
+    return 1
+}
+dependency_gtk2()
+{
+    printf "checking for gtk2... "
+    # dependency gtk2
+    while true
+    do
+        if [ -z "$PKG_CONFIG" ]; then
+            break
+        fi
+        $PKG_CONFIG gtk+-2.0
+        if [ $? -ne 0 ] ; then
+            break
+        fi
+        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
+
+    echo no
+    return 1
+}
+dependency_gtk3()
+{
+    printf "checking for gtk3... "
+    # dependency gtk3
+    while true
+    do
+        if [ -z "$PKG_CONFIG" ]; then
+            break
+        fi
+        $PKG_CONFIG gtk+-5.0
+        if [ $? -ne 0 ] ; then
+            break
+        fi
+        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
+
+    echo no
+    return 1
+}
+dependency_deptest()
+{
+    printf "checking for deptest... "
+    # dependency deptest
+    while true
+    do
+        TEMP_CFLAGS="$TEMP_CFLAGS -DDEPTEST"
+        echo yes
+        return 0
+    done
+
+    echo no
+    return 1
+}
+dependency_libxml2()
+{
+    printf "checking for libxml2... "
+    # dependency libxml2
+    while true
+    do
+        if [ -z "$PKG_CONFIG" ]; then
+            break
+        fi
+        $PKG_CONFIG libxml-2.0
+        if [ $? -ne 0 ] ; then
+            break
+        fi
+        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
+
+__EOF__
+        echo yes
+        return 0
+    done
+
+    echo no
+    return 1
+}
+
+DEPENDENCIES_FAILED=
+ERROR=0
+# general dependencies
+TEMP_CFLAGS=
+TEMP_LDFLAGS=
+while true
+do
+    while true
+    do
+
+        cat >> "$TEMP_DIR/make.mk" << __EOF__
+MVAR = 123
+MVAR += 123
+
+__EOF__
+
+        break
+    done
+
+    break
+done
+
+# add general 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
+fi
+if [ -n "${TEMP_LDFLAGS}" ]; then
+    echo "LDFLAGS += $TEMP_LDFLAGS" >> $TEMP_DIR/config.mk
+fi
+
+#
+# OPTION VALUES
+#
+checkopt_toolkit_gtk3()
+{
+    VERR=0
+    dependency_gtk3
+    if [ $? -ne 0 ]; then
+        VERR=1
+    fi
+    if [ $VERR -ne 0 ]; then
+        return 1
+    fi
+        TEMP_CFLAGS="$TEMP_CFLAGS -Da=b"
+    cat >> "$TEMP_DIR/make.mk" << __EOF__
+UIOBJ += graphics_cairo.o
+
+__EOF__
+    return 0
+}
+checkopt_toolkit_cli()
+{
+    VERR=0
+    dependency_curl
+    if [ $? -ne 0 ]; then
+        VERR=1
+    fi
+    dependency_test
+    if [ $? -ne 0 ]; then
+        VERR=1
+    fi
+    if [ $VERR -ne 0 ]; then
+        return 1
+    fi
+    return 0
+}
+checkopt_toolkit_gtk2()
+{
+    VERR=0
+    dependency_gtk2
+    if [ $? -ne 0 ]; then
+        VERR=1
+    fi
+    if [ $VERR -ne 0 ]; then
+        return 1
+    fi
+    return 0
+}
+checkopt_toolkit_wpf()
+{
+    VERR=0
+    dependency_test
+    if [ $? -ne 0 ]; then
+        VERR=1
+    fi
+    if [ $VERR -ne 0 ]; then
+        return 1
+    fi
+    return 0
+}
+
+#
+# TARGETS
+#
+TEMP_CFLAGS=
+TEMP_CXXFLAGS=
+TEMP_LDFLAGS=
+
+# Target: dav
+TEMP_CFLAGS=
+TEMP_LDFLAGS=
+TEMP_CXXFLAGS=
+
+dependency_curl
+if [ $? -ne 0 ]; then
+    DEPENDENCIES_FAILED="$DEPENDENCIES_FAILED curl "
+    ERROR=1
+fi
+dependency_libxml2
+if [ $? -ne 0 ]; then
+    DEPENDENCIES_FAILED="$DEPENDENCIES_FAILED libxml2 "
+    ERROR=1
+fi
+dependency_test
+if [ $? -ne 0 ]; then
+    DEPENDENCIES_FAILED="$DEPENDENCIES_FAILED test "
+    ERROR=1
+fi
+
+# Features
+if [ -n "$FEATURE_DB" ]; then
+    # check dependency
+    dependency_sqlite
+    if [ $? -ne 0 ]; then
+        # "auto" features can fail and are just disabled in this case
+        if [ "$FEATURE_DB" != "auto" ]; then
+            DEPENDENCIES_FAILED="$DEPENDENCIES_FAILED sqlite "
+            ERROR=1
+        fi
+    fi
+fi
+if [ -n "$FEATURE_GUI" ]; then
+    # check dependency
+    dependency_gtk3
+    if [ $? -ne 0 ]; then
+        # "auto" features can fail and are just disabled in this case
+        if [ "$FEATURE_GUI" != "auto" ]; then
+            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=0
+    while true
+    do
+        if isplatform "windows"; then
+        checkopt_toolkit_wpf
+        if [ $? -eq 0 ]; then
+            echo "  toolkit: wpf" >> "$TEMP_DIR/options"
+            ERROR=0
+            break
+        fi
+        fi
+        checkopt_toolkit_gtk3
+        if [ $? -eq 0 ]; then
+            echo "  toolkit: gtk3" >> "$TEMP_DIR/options"
+            ERROR=0
+            break
+        fi
+        checkopt_toolkit_gtk2
+        if [ $? -eq 0 ]; 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
+        checkopt_toolkit_gtk3
+        if [ $? -ne 0 ]; then
+            ERROR=1
+        fi
+    elif [ "$OPT_TOOLKIT" = "cli" ]; then
+        echo "  toolkit: $OPT_TOOLKIT" >> $TEMP_DIR/options
+        checkopt_toolkit_cli
+        if [ $? -ne 0 ]; then
+            ERROR=1
+        fi
+    elif [ "$OPT_TOOLKIT" = "gtk2" ]; then
+        echo "  toolkit: $OPT_TOOLKIT" >> $TEMP_DIR/options
+        checkopt_toolkit_gtk2
+        if [ $? -ne 0 ]; then
+            ERROR=1
+        fi
+    elif [ "$OPT_TOOLKIT" = "wpf" ]; then
+        echo "  toolkit: $OPT_TOOLKIT" >> $TEMP_DIR/options
+        checkopt_toolkit_wpf
+        if [ $? -ne 0 ]; then
+            ERROR=1
+        fi
+    fi
+fi
+
+echo >> "$TEMP_DIR/config.mk"
+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 [ -n "${TEMP_LDFLAGS}" ]; then
+    echo "DAV_LDFLAGS += $TEMP_LDFLAGS" >> "$TEMP_DIR/config.mk"
+fi
+
+# Target
+TEMP_CFLAGS=
+TEMP_LDFLAGS=
+TEMP_CXXFLAGS=
+
+dependency_deptest
+if [ $? -ne 0 ]; then
+    DEPENDENCIES_FAILED="$DEPENDENCIES_FAILED deptest "
+    ERROR=1
+fi
+
+# Features
+
+
+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"
+fi
+if [ -n "${TEMP_LDFLAGS}" ]; then
+    echo "LDFLAGS += $TEMP_LDFLAGS" >> "$TEMP_DIR/config.mk"
+fi
+
+if [ $ERROR -ne 0 ]; then
+    echo
+    echo "Error: Unresolved dependencies"
+    echo "$DEPENDENCIES_FAILED"
+    rm -Rf "$TEMP_DIR"
+    exit 1
+fi
+
+echo "configure finished"
+echo
+echo "Build Config:"
+echo "  PREFIX:    $PREFIX"
+echo "  TOOLCHAIN: $TOOLCHAIN_NAME"
+echo "Options:"
+cat "$TEMP_DIR/options"
+echo
+cat "$TEMP_DIR/config.mk" "$TEMP_DIR/make.mk" > config.mk
+rm -Rf "$TEMP_DIR"
+
+
--- a/test/make/configure.vm	Sun Sep 03 12:43:44 2023 +0200
+++ b/test/make/configure.vm	Wed Sep 06 21:08:04 2023 +0200
@@ -324,7 +324,7 @@
 {
     printf "checking for ${dependency.name}... "
     #foreach( $sub in $dependency.getSubdependencies() )
-    # dependency $sub.name $sub.getPlatformString()
+    # dependency $sub.getFullName()
     while true
     do
         #if( $sub.platform )

mercurial