add platform attributes to config element

Tue, 24 Sep 2024 21:49:50 +0200

author
Mike Becker <universe@uap-core.de>
date
Tue, 24 Sep 2024 21:49:50 +0200
changeset 116
41981a23aff8
parent 115
36e4aedd5663
child 117
bc096357e324

add platform attributes to config element

fixes #427

src/main/java/de/unixwork/uwproj/Config.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/main/resources/make/configure.vm file | annotate | diff | comparison | revisions
src/main/resources/make/uwproj.xsd file | annotate | diff | comparison | revisions
test/configure file | annotate | diff | comparison | revisions
test/configure2 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/uwproj.xsd file | annotate | diff | comparison | revisions
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/java/de/unixwork/uwproj/Config.java	Tue Sep 24 21:49:50 2024 +0200
@@ -0,0 +1,43 @@
+package de.unixwork.uwproj;
+
+import org.w3c.dom.Element;
+
+import java.util.Arrays;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.function.Predicate;
+import java.util.stream.Collectors;
+
+public final class Config {
+    private final String platform;
+    private final String not;
+
+    private final List<ConfigVar> vars = new LinkedList<>();
+
+    public Config(Element element) {
+        platform = element.getAttribute("platform");
+        not = element.getAttribute("not");
+
+        Util.getChildElements(element).forEach(elm -> {
+            if (elm.getNodeName().equals("var")) {
+                vars.add(new ConfigVar(elm));
+            }
+        });
+    }
+
+
+    public String getPlatform() {
+        return platform;
+    }
+
+    public List<String> getNotList() {
+        return Arrays.stream(not.split(","))
+                .map(String::trim)
+                .filter(Predicate.not(String::isEmpty))
+                .collect(Collectors.toList());
+    }
+
+    public List<ConfigVar> getVars() {
+        return vars;
+    }
+}
--- a/src/main/java/de/unixwork/uwproj/Main.java	Mon Sep 23 22:52:48 2024 +0200
+++ b/src/main/java/de/unixwork/uwproj/Main.java	Tue Sep 24 21:49:50 2024 +0200
@@ -61,7 +61,7 @@
         context.put("options", project.getOptions());
         context.put("features", project.getFeatures());
         context.put("project", project);
-        context.put("vars", project.getVars());
+        context.put("config", project.getConfig());
         context.put("languages", project.getLang());
         new VelocityEngine().getTemplate(tplFileName).merge(context, out);
     }
--- a/src/main/java/de/unixwork/uwproj/Project.java	Mon Sep 23 22:52:48 2024 +0200
+++ b/src/main/java/de/unixwork/uwproj/Project.java	Tue Sep 24 21:49:50 2024 +0200
@@ -11,18 +11,14 @@
     private final List<Option> options = new LinkedList<>();
     private final List<Feature> features = new LinkedList<>();
 
-    private final List<ConfigVar> configVarsList = new LinkedList<>();
+    private final List<Config> configList = new LinkedList<>();
     
     private final Set<String> lang = new HashSet<>();
 
     public Project(Element root) {
         Util.getChildElements(root).forEach(element -> {
             switch (element.getNodeName()) {
-                case "config" -> Util.getChildElements(element).forEach(v -> {
-                    if (v.getNodeName().equals("var")) {
-                        configVarsList.add(new ConfigVar(v));
-                    }
-                });
+                case "config" -> configList.add(new Config(element));
                 case "dependency" -> {
                     final var dependency = new Dependency(element);
                     lang.addAll(dependency.getLang());
@@ -75,8 +71,8 @@
         return features;
     }
 
-    public List<ConfigVar> getVars() {
-        return configVarsList;
+    public List<Config> getConfig() {
+        return configList;
     }
     
     public Collection<String> getLang() {
--- a/src/main/resources/make/configure.vm	Mon Sep 23 22:52:48 2024 +0200
+++ b/src/main/resources/make/configure.vm	Tue Sep 24 21:49:50 2024 +0200
@@ -1,53 +1,48 @@
 #!/bin/sh
 
 #set( $D = '$' )
-# create temporary directory
-TEMP_DIR=".tmp-`uname -n`"
-rm -Rf "$TEMP_DIR"
-if mkdir -p "$TEMP_DIR"; then
-    :
-else
-    echo "Cannot create tmp dir $TEMP_DIR"
-    echo "Abort"
-    exit 1
-fi
-touch "$TEMP_DIR/options"
-touch "$TEMP_DIR/features"
-
-# define standard variables
-# also define standard prefix (this is where we will search for config.site)
-prefix=/usr
-exec_prefix=
-bindir=
-sbindir=
-libdir=
-libexecdir=
-datarootdir=
-datadir=
-sysconfdir=
-sharedstatedir=
-localstatedir=
-runstatedir=
-includedir=
-infodir=
-localedir=
-mandir=
-
-# custom variables
-#foreach( $var in $vars )
-#if( $var.exec )
-${var.varName}=`${var.value}`
-#else
-${var.varName}="${var.value}"
-#end
-#end
-
-# features
-#foreach( $feature in $features )
-#if( ${feature.auto} )
-${feature.varName}=auto
-#end
-#end
+#[[
+# some utility functions
+isplatform()
+{
+    for p in $PLATFORM
+    do
+        if [ "$p" = "$1" ]; then
+            return 0
+        fi
+    done
+    return 1
+}
+notisplatform()
+{
+    for p in $PLATFORM
+    do
+        if [ "$p" = "$1" ]; then
+            return 1
+        fi
+    done
+    return 0
+}
+istoolchain()
+{
+    for t in $TOOLCHAIN
+    do
+        if [ "$t" = "$1" ]; then
+            return 0
+        fi
+    done
+    return 1
+}
+notistoolchain()
+{
+    for t in $TOOLCHAIN
+    do
+        if [ "$t" = "$1" ]; then
+            return 1
+        fi
+    done
+    return 0
+}
 
 # clean abort
 abort_configure()
@@ -56,6 +51,36 @@
     exit 1
 }
 
+# Test for availability of pkg-config
+PKG_CONFIG=`command -v 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"
+elif [ "$OS" = "Linux" ]; then
+    PLATFORM="linux unix"
+elif [ "$OS" = "FreeBSD" ]; then
+    PLATFORM="freebsd bsd unix"
+elif [ "$OS" = "OpenBSD" ]; then
+    PLATFORM="openbsd bsd unix"
+elif [ "$OS" = "NetBSD" ]; then
+    PLATFORM="netbsd bsd unix"
+elif [ "$OS" = "Darwin" ]; then
+    PLATFORM="macos osx bsd unix"
+elif echo "$OS" | grep -i "MINGW" > /dev/null; then
+    PLATFORM="windows mingw"
+fi
+: ${PLATFORM:="unix"}
+
+PLATFORM_NAME=`echo "$PLATFORM" | cut -f1 -d' ' -`
+echo "$PLATFORM_NAME"
+]]#
+
 # help text
 printhelp()
 {
@@ -101,6 +126,65 @@
 __EOF__
 }
 
+# create temporary directory
+TEMP_DIR=".tmp-`uname -n`"
+rm -Rf "$TEMP_DIR"
+if mkdir -p "$TEMP_DIR"; then
+    :
+else
+    echo "Cannot create tmp dir $TEMP_DIR"
+    echo "Abort"
+    exit 1
+fi
+touch "$TEMP_DIR/options"
+touch "$TEMP_DIR/features"
+
+# define standard variables
+# also define standard prefix (this is where we will search for config.site)
+prefix=/usr
+exec_prefix=
+bindir=
+sbindir=
+libdir=
+libexecdir=
+datarootdir=
+datadir=
+sysconfdir=
+sharedstatedir=
+localstatedir=
+runstatedir=
+includedir=
+infodir=
+localedir=
+mandir=
+
+# custom variables
+#foreach( $cfg in $config )
+if true \
+#if( $cfg.platform )
+    && isplatform "${cfg.platform}" \
+#end
+#foreach( $np in $cfg.notList )
+      && notisplatform "${np}" \
+#end
+      ; then
+    #foreach( $var in $cfg.vars )
+    #if( $var.exec )
+    ${var.varName}=`${var.value}`
+    #else
+    ${var.varName}="${var.value}"
+    #end
+    #end
+fi
+#end
+
+# features
+#foreach( $feature in $features )
+#if( ${feature.auto} )
+${feature.varName}=auto
+#end
+#end
+
 #
 # parse arguments
 #
@@ -174,76 +258,6 @@
     . "$prefix/etc/config.site"
     echo ok
 fi
-
-# Test for availability of pkg-config
-PKG_CONFIG=`command -v 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"
-elif [ "$OS" = "Linux" ]; then
-    PLATFORM="linux unix"
-elif [ "$OS" = "FreeBSD" ]; then
-    PLATFORM="freebsd bsd unix"
-elif [ "$OS" = "OpenBSD" ]; then
-    PLATFORM="openbsd bsd unix"
-elif [ "$OS" = "NetBSD" ]; then
-    PLATFORM="netbsd bsd unix"
-elif [ "$OS" = "Darwin" ]; then
-    PLATFORM="macos osx bsd unix"
-elif echo "$OS" | grep -i "MINGW" > /dev/null; then
-    PLATFORM="windows mingw"
-fi
-: ${PLATFORM:="unix"}
-
-PLATFORM_NAME=`echo "$PLATFORM" | cut -f1 -d' ' -`
-echo "$PLATFORM_NAME"
-
-isplatform()
-{
-    for p in $PLATFORM
-    do
-        if [ "$p" = "$1" ]; then
-            return 0
-        fi
-    done
-    return 1
-}
-notisplatform()
-{
-    for p in $PLATFORM
-    do
-        if [ "$p" = "$1" ]; then
-            return 1
-        fi
-    done
-    return 0
-}
-istoolchain()
-{
-    for t in $TOOLCHAIN
-    do
-        if [ "$t" = "$1" ]; then
-            return 0
-        fi
-    done
-    return 1
-}
-notistoolchain()
-{
-    for t in $TOOLCHAIN
-    do
-        if [ "$t" = "$1" ]; then
-            return 1
-        fi
-    done
-    return 0
-}
 ]]#
 ## End of unparsed content **
 
--- a/src/main/resources/make/uwproj.xsd	Mon Sep 23 22:52:48 2024 +0200
+++ b/src/main/resources/make/uwproj.xsd	Tue Sep 24 21:49:50 2024 +0200
@@ -17,7 +17,7 @@
             </xs:documentation>
         </xs:annotation>
         <xs:sequence>
-            <xs:element name="config" type="ConfigType" minOccurs="0"/>
+            <xs:element name="config" type="ConfigType" minOccurs="0" maxOccurs="unbounded"/>
             <xs:element name="dependency" type="DependencyType" minOccurs="0" maxOccurs="unbounded"/>
             <xs:element name="target" type="TargetType" minOccurs="0" maxOccurs="unbounded"/>
         </xs:sequence>
@@ -26,13 +26,23 @@
     <xs:complexType name="ConfigType">
         <xs:annotation>
             <xs:documentation>
-                The configuration section.
-                Consists of an arbitrary number of <code>var</code> elements.
+                <p>
+                    The configuration section.
+                    Consists of an arbitrary number of <code>var</code> elements.
+                </p>
+                <p>
+                    The optional <code>platform</code> attribute may specify a <em>single</em> platform identifier and
+                    the optional <code>not</code> attribute may specify a comma-separated list of platform identifiers.
+                    The configure script shall skip this config declaration if the detected platform is not matching
+                    the filter specification of these attributes.
+                </p>
             </xs:documentation>
         </xs:annotation>
         <xs:sequence>
             <xs:element name="var" type="ConfigVarType" minOccurs="0" maxOccurs="unbounded"/>
         </xs:sequence>
+        <xs:attribute name="platform" type="xs:string"/>
+        <xs:attribute name="not" type="xs:string"/>
     </xs:complexType>
 
     <xs:complexType name="ConfigVarType">
--- a/test/configure	Mon Sep 23 22:52:48 2024 +0200
+++ b/test/configure	Tue Sep 24 21:49:50 2024 +0200
@@ -1,5 +1,117 @@
 #!/bin/sh
 
+
+# some utility functions
+isplatform()
+{
+    for p in $PLATFORM
+    do
+        if [ "$p" = "$1" ]; then
+            return 0
+        fi
+    done
+    return 1
+}
+notisplatform()
+{
+    for p in $PLATFORM
+    do
+        if [ "$p" = "$1" ]; then
+            return 1
+        fi
+    done
+    return 0
+}
+istoolchain()
+{
+    for t in $TOOLCHAIN
+    do
+        if [ "$t" = "$1" ]; then
+            return 0
+        fi
+    done
+    return 1
+}
+notistoolchain()
+{
+    for t in $TOOLCHAIN
+    do
+        if [ "$t" = "$1" ]; then
+            return 1
+        fi
+    done
+    return 0
+}
+
+# clean abort
+abort_configure()
+{
+    rm -Rf "$TEMP_DIR"
+    exit 1
+}
+
+# Test for availability of pkg-config
+PKG_CONFIG=`command -v 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"
+elif [ "$OS" = "Linux" ]; then
+    PLATFORM="linux unix"
+elif [ "$OS" = "FreeBSD" ]; then
+    PLATFORM="freebsd bsd unix"
+elif [ "$OS" = "OpenBSD" ]; then
+    PLATFORM="openbsd bsd unix"
+elif [ "$OS" = "NetBSD" ]; then
+    PLATFORM="netbsd bsd unix"
+elif [ "$OS" = "Darwin" ]; then
+    PLATFORM="macos osx bsd unix"
+elif echo "$OS" | grep -i "MINGW" > /dev/null; then
+    PLATFORM="windows mingw"
+fi
+: ${PLATFORM:="unix"}
+
+PLATFORM_NAME=`echo "$PLATFORM" | cut -f1 -d' ' -`
+echo "$PLATFORM_NAME"
+
+
+# help text
+printhelp()
+{
+    echo "Usage: $0 [OPTIONS]..."
+    cat << __EOF__
+Installation directories:
+  --prefix=PREFIX         path prefix for architecture-independent files
+                          [$prefix]
+  --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]
+  --runstatedir=DIR       run-time variable data [LOCALSTATEDIR/run]
+  --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]
+  --localedir=DIR         locale-dependent data [DATAROOTDIR/locale]
+
+Optional Features:
+  --disable-pg
+
+__EOF__
+}
+
 # create temporary directory
 TEMP_DIR=".tmp-`uname -n`"
 rm -Rf "$TEMP_DIR"
@@ -33,52 +145,25 @@
 mandir=
 
 # custom variables
-HOST=`uname -n`
-prefix="`pwd`/work"
-install_dir="$prefix"
+if true \
+      && notisplatform "mingw" \
+      ; then
+    prefix="`pwd`/work"
+fi
+if true \
+    && isplatform "mingw" \
+      ; then
+    prefix="`pwd -W`/work"
+fi
+if true \
+      ; then
+    HOST=`uname -n`
+    install_dir="$prefix"
+fi
 
 # features
 FEATURE_PG=auto
 
-# clean abort
-abort_configure()
-{
-    rm -Rf "$TEMP_DIR"
-    exit 1
-}
-
-# help text
-printhelp()
-{
-    echo "Usage: $0 [OPTIONS]..."
-    cat << __EOF__
-Installation directories:
-  --prefix=PREFIX         path prefix for architecture-independent files
-                          [$prefix]
-  --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]
-  --runstatedir=DIR       run-time variable data [LOCALSTATEDIR/run]
-  --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]
-  --localedir=DIR         locale-dependent data [DATAROOTDIR/locale]
-
-Optional Features:
-  --disable-pg
-
-__EOF__
-}
-
 #
 # parse arguments
 #
@@ -147,76 +232,6 @@
     echo ok
 fi
 
-# Test for availability of pkg-config
-PKG_CONFIG=`command -v 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"
-elif [ "$OS" = "Linux" ]; then
-    PLATFORM="linux unix"
-elif [ "$OS" = "FreeBSD" ]; then
-    PLATFORM="freebsd bsd unix"
-elif [ "$OS" = "OpenBSD" ]; then
-    PLATFORM="openbsd bsd unix"
-elif [ "$OS" = "NetBSD" ]; then
-    PLATFORM="netbsd bsd unix"
-elif [ "$OS" = "Darwin" ]; then
-    PLATFORM="macos osx bsd unix"
-elif echo "$OS" | grep -i "MINGW" > /dev/null; then
-    PLATFORM="windows mingw"
-fi
-: ${PLATFORM:="unix"}
-
-PLATFORM_NAME=`echo "$PLATFORM" | cut -f1 -d' ' -`
-echo "$PLATFORM_NAME"
-
-isplatform()
-{
-    for p in $PLATFORM
-    do
-        if [ "$p" = "$1" ]; then
-            return 0
-        fi
-    done
-    return 1
-}
-notisplatform()
-{
-    for p in $PLATFORM
-    do
-        if [ "$p" = "$1" ]; then
-            return 1
-        fi
-    done
-    return 0
-}
-istoolchain()
-{
-    for t in $TOOLCHAIN
-    do
-        if [ "$t" = "$1" ]; then
-            return 0
-        fi
-    done
-    return 1
-}
-notistoolchain()
-{
-    for t in $TOOLCHAIN
-    do
-        if [ "$t" = "$1" ]; then
-            return 1
-        fi
-    done
-    return 0
-}
-
 
 # generate vars.mk
 cat > "$TEMP_DIR/vars.mk" << __EOF__
@@ -236,9 +251,6 @@
 infodir=$infodir
 mandir=$mandir
 localedir=$localedir
-HOST=$HOST
-prefix=$prefix
-install_dir=$install_dir
 __EOF__
 
 # toolchain detection utilities
--- a/test/configure2	Mon Sep 23 22:52:48 2024 +0200
+++ b/test/configure2	Tue Sep 24 21:49:50 2024 +0200
@@ -1,41 +1,47 @@
 #!/bin/sh
 
-# create temporary directory
-TEMP_DIR=".tmp-`uname -n`"
-rm -Rf "$TEMP_DIR"
-if mkdir -p "$TEMP_DIR"; then
-    :
-else
-    echo "Cannot create tmp dir $TEMP_DIR"
-    echo "Abort"
-    exit 1
-fi
-touch "$TEMP_DIR/options"
-touch "$TEMP_DIR/features"
 
-# define standard variables
-# also define standard prefix (this is where we will search for config.site)
-prefix=/usr
-exec_prefix=
-bindir=
-sbindir=
-libdir=
-libexecdir=
-datarootdir=
-datadir=
-sysconfdir=
-sharedstatedir=
-localstatedir=
-runstatedir=
-includedir=
-infodir=
-localedir=
-mandir=
-
-# custom variables
-
-# features
-FEATURE_DB=auto
+# some utility functions
+isplatform()
+{
+    for p in $PLATFORM
+    do
+        if [ "$p" = "$1" ]; then
+            return 0
+        fi
+    done
+    return 1
+}
+notisplatform()
+{
+    for p in $PLATFORM
+    do
+        if [ "$p" = "$1" ]; then
+            return 1
+        fi
+    done
+    return 0
+}
+istoolchain()
+{
+    for t in $TOOLCHAIN
+    do
+        if [ "$t" = "$1" ]; then
+            return 0
+        fi
+    done
+    return 1
+}
+notistoolchain()
+{
+    for t in $TOOLCHAIN
+    do
+        if [ "$t" = "$1" ]; then
+            return 1
+        fi
+    done
+    return 0
+}
 
 # clean abort
 abort_configure()
@@ -44,6 +50,36 @@
     exit 1
 }
 
+# Test for availability of pkg-config
+PKG_CONFIG=`command -v 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"
+elif [ "$OS" = "Linux" ]; then
+    PLATFORM="linux unix"
+elif [ "$OS" = "FreeBSD" ]; then
+    PLATFORM="freebsd bsd unix"
+elif [ "$OS" = "OpenBSD" ]; then
+    PLATFORM="openbsd bsd unix"
+elif [ "$OS" = "NetBSD" ]; then
+    PLATFORM="netbsd bsd unix"
+elif [ "$OS" = "Darwin" ]; then
+    PLATFORM="macos osx bsd unix"
+elif echo "$OS" | grep -i "MINGW" > /dev/null; then
+    PLATFORM="windows mingw"
+fi
+: ${PLATFORM:="unix"}
+
+PLATFORM_NAME=`echo "$PLATFORM" | cut -f1 -d' ' -`
+echo "$PLATFORM_NAME"
+
+
 # help text
 printhelp()
 {
@@ -86,6 +122,43 @@
 __EOF__
 }
 
+# create temporary directory
+TEMP_DIR=".tmp-`uname -n`"
+rm -Rf "$TEMP_DIR"
+if mkdir -p "$TEMP_DIR"; then
+    :
+else
+    echo "Cannot create tmp dir $TEMP_DIR"
+    echo "Abort"
+    exit 1
+fi
+touch "$TEMP_DIR/options"
+touch "$TEMP_DIR/features"
+
+# define standard variables
+# also define standard prefix (this is where we will search for config.site)
+prefix=/usr
+exec_prefix=
+bindir=
+sbindir=
+libdir=
+libexecdir=
+datarootdir=
+datadir=
+sysconfdir=
+sharedstatedir=
+localstatedir=
+runstatedir=
+includedir=
+infodir=
+localedir=
+mandir=
+
+# custom variables
+
+# features
+FEATURE_DB=auto
+
 #
 # parse arguments
 #
@@ -157,76 +230,6 @@
     echo ok
 fi
 
-# Test for availability of pkg-config
-PKG_CONFIG=`command -v 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"
-elif [ "$OS" = "Linux" ]; then
-    PLATFORM="linux unix"
-elif [ "$OS" = "FreeBSD" ]; then
-    PLATFORM="freebsd bsd unix"
-elif [ "$OS" = "OpenBSD" ]; then
-    PLATFORM="openbsd bsd unix"
-elif [ "$OS" = "NetBSD" ]; then
-    PLATFORM="netbsd bsd unix"
-elif [ "$OS" = "Darwin" ]; then
-    PLATFORM="macos osx bsd unix"
-elif echo "$OS" | grep -i "MINGW" > /dev/null; then
-    PLATFORM="windows mingw"
-fi
-: ${PLATFORM:="unix"}
-
-PLATFORM_NAME=`echo "$PLATFORM" | cut -f1 -d' ' -`
-echo "$PLATFORM_NAME"
-
-isplatform()
-{
-    for p in $PLATFORM
-    do
-        if [ "$p" = "$1" ]; then
-            return 0
-        fi
-    done
-    return 1
-}
-notisplatform()
-{
-    for p in $PLATFORM
-    do
-        if [ "$p" = "$1" ]; then
-            return 1
-        fi
-    done
-    return 0
-}
-istoolchain()
-{
-    for t in $TOOLCHAIN
-    do
-        if [ "$t" = "$1" ]; then
-            return 0
-        fi
-    done
-    return 1
-}
-notistoolchain()
-{
-    for t in $TOOLCHAIN
-    do
-        if [ "$t" = "$1" ]; then
-            return 1
-        fi
-    done
-    return 0
-}
-
 
 # generate vars.mk
 cat > "$TEMP_DIR/vars.mk" << __EOF__
--- a/test/make/configure.vm	Mon Sep 23 22:52:48 2024 +0200
+++ b/test/make/configure.vm	Tue Sep 24 21:49:50 2024 +0200
@@ -1,53 +1,48 @@
 #!/bin/sh
 
 #set( $D = '$' )
-# create temporary directory
-TEMP_DIR=".tmp-`uname -n`"
-rm -Rf "$TEMP_DIR"
-if mkdir -p "$TEMP_DIR"; then
-    :
-else
-    echo "Cannot create tmp dir $TEMP_DIR"
-    echo "Abort"
-    exit 1
-fi
-touch "$TEMP_DIR/options"
-touch "$TEMP_DIR/features"
-
-# define standard variables
-# also define standard prefix (this is where we will search for config.site)
-prefix=/usr
-exec_prefix=
-bindir=
-sbindir=
-libdir=
-libexecdir=
-datarootdir=
-datadir=
-sysconfdir=
-sharedstatedir=
-localstatedir=
-runstatedir=
-includedir=
-infodir=
-localedir=
-mandir=
-
-# custom variables
-#foreach( $var in $vars )
-#if( $var.exec )
-${var.varName}=`${var.value}`
-#else
-${var.varName}="${var.value}"
-#end
-#end
-
-# features
-#foreach( $feature in $features )
-#if( ${feature.auto} )
-${feature.varName}=auto
-#end
-#end
+#[[
+# some utility functions
+isplatform()
+{
+    for p in $PLATFORM
+    do
+        if [ "$p" = "$1" ]; then
+            return 0
+        fi
+    done
+    return 1
+}
+notisplatform()
+{
+    for p in $PLATFORM
+    do
+        if [ "$p" = "$1" ]; then
+            return 1
+        fi
+    done
+    return 0
+}
+istoolchain()
+{
+    for t in $TOOLCHAIN
+    do
+        if [ "$t" = "$1" ]; then
+            return 0
+        fi
+    done
+    return 1
+}
+notistoolchain()
+{
+    for t in $TOOLCHAIN
+    do
+        if [ "$t" = "$1" ]; then
+            return 1
+        fi
+    done
+    return 0
+}
 
 # clean abort
 abort_configure()
@@ -56,6 +51,36 @@
     exit 1
 }
 
+# Test for availability of pkg-config
+PKG_CONFIG=`command -v 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"
+elif [ "$OS" = "Linux" ]; then
+    PLATFORM="linux unix"
+elif [ "$OS" = "FreeBSD" ]; then
+    PLATFORM="freebsd bsd unix"
+elif [ "$OS" = "OpenBSD" ]; then
+    PLATFORM="openbsd bsd unix"
+elif [ "$OS" = "NetBSD" ]; then
+    PLATFORM="netbsd bsd unix"
+elif [ "$OS" = "Darwin" ]; then
+    PLATFORM="macos osx bsd unix"
+elif echo "$OS" | grep -i "MINGW" > /dev/null; then
+    PLATFORM="windows mingw"
+fi
+: ${PLATFORM:="unix"}
+
+PLATFORM_NAME=`echo "$PLATFORM" | cut -f1 -d' ' -`
+echo "$PLATFORM_NAME"
+]]#
+
 # help text
 printhelp()
 {
@@ -101,6 +126,65 @@
 __EOF__
 }
 
+# create temporary directory
+TEMP_DIR=".tmp-`uname -n`"
+rm -Rf "$TEMP_DIR"
+if mkdir -p "$TEMP_DIR"; then
+    :
+else
+    echo "Cannot create tmp dir $TEMP_DIR"
+    echo "Abort"
+    exit 1
+fi
+touch "$TEMP_DIR/options"
+touch "$TEMP_DIR/features"
+
+# define standard variables
+# also define standard prefix (this is where we will search for config.site)
+prefix=/usr
+exec_prefix=
+bindir=
+sbindir=
+libdir=
+libexecdir=
+datarootdir=
+datadir=
+sysconfdir=
+sharedstatedir=
+localstatedir=
+runstatedir=
+includedir=
+infodir=
+localedir=
+mandir=
+
+# custom variables
+#foreach( $cfg in $config )
+if true \
+#if( $cfg.platform )
+    && isplatform "${cfg.platform}" \
+#end
+#foreach( $np in $cfg.notList )
+      && notisplatform "${np}" \
+#end
+      ; then
+    #foreach( $var in $cfg.vars )
+    #if( $var.exec )
+    ${var.varName}=`${var.value}`
+    #else
+    ${var.varName}="${var.value}"
+    #end
+    #end
+fi
+#end
+
+# features
+#foreach( $feature in $features )
+#if( ${feature.auto} )
+${feature.varName}=auto
+#end
+#end
+
 #
 # parse arguments
 #
@@ -174,76 +258,6 @@
     . "$prefix/etc/config.site"
     echo ok
 fi
-
-# Test for availability of pkg-config
-PKG_CONFIG=`command -v 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"
-elif [ "$OS" = "Linux" ]; then
-    PLATFORM="linux unix"
-elif [ "$OS" = "FreeBSD" ]; then
-    PLATFORM="freebsd bsd unix"
-elif [ "$OS" = "OpenBSD" ]; then
-    PLATFORM="openbsd bsd unix"
-elif [ "$OS" = "NetBSD" ]; then
-    PLATFORM="netbsd bsd unix"
-elif [ "$OS" = "Darwin" ]; then
-    PLATFORM="macos osx bsd unix"
-elif echo "$OS" | grep -i "MINGW" > /dev/null; then
-    PLATFORM="windows mingw"
-fi
-: ${PLATFORM:="unix"}
-
-PLATFORM_NAME=`echo "$PLATFORM" | cut -f1 -d' ' -`
-echo "$PLATFORM_NAME"
-
-isplatform()
-{
-    for p in $PLATFORM
-    do
-        if [ "$p" = "$1" ]; then
-            return 0
-        fi
-    done
-    return 1
-}
-notisplatform()
-{
-    for p in $PLATFORM
-    do
-        if [ "$p" = "$1" ]; then
-            return 1
-        fi
-    done
-    return 0
-}
-istoolchain()
-{
-    for t in $TOOLCHAIN
-    do
-        if [ "$t" = "$1" ]; then
-            return 0
-        fi
-    done
-    return 1
-}
-notistoolchain()
-{
-    for t in $TOOLCHAIN
-    do
-        if [ "$t" = "$1" ]; then
-            return 1
-        fi
-    done
-    return 0
-}
 ]]#
 ## End of unparsed content **
 
--- a/test/make/project.xml	Mon Sep 23 22:52:48 2024 +0200
+++ b/test/make/project.xml	Tue Sep 24 21:49:50 2024 +0200
@@ -1,9 +1,14 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <project xmlns="http://unixwork.de/uwproj">
 	<!-- makefile config -->
+	<config not="mingw">
+		<var name="prefix">`pwd`/work</var>
+	</config>
+	<config platform="mingw">
+		<var name="prefix">`pwd -W`/work</var>
+	</config>
 	<config>
 		<var name="HOST" exec="true">uname -n</var>
-		<var name="prefix">`pwd`/work</var>
 		<var name="install_dir">$prefix</var>
 	</config>
 	
--- a/test/make/uwproj.xsd	Mon Sep 23 22:52:48 2024 +0200
+++ b/test/make/uwproj.xsd	Tue Sep 24 21:49:50 2024 +0200
@@ -17,7 +17,7 @@
             </xs:documentation>
         </xs:annotation>
         <xs:sequence>
-            <xs:element name="config" type="ConfigType" minOccurs="0"/>
+            <xs:element name="config" type="ConfigType" minOccurs="0" maxOccurs="unbounded"/>
             <xs:element name="dependency" type="DependencyType" minOccurs="0" maxOccurs="unbounded"/>
             <xs:element name="target" type="TargetType" minOccurs="0" maxOccurs="unbounded"/>
         </xs:sequence>
@@ -26,13 +26,23 @@
     <xs:complexType name="ConfigType">
         <xs:annotation>
             <xs:documentation>
-                The configuration section.
-                Consists of an arbitrary number of <code>var</code> elements.
+                <p>
+                    The configuration section.
+                    Consists of an arbitrary number of <code>var</code> elements.
+                </p>
+                <p>
+                    The optional <code>platform</code> attribute may specify a <em>single</em> platform identifier and
+                    the optional <code>not</code> attribute may specify a comma-separated list of platform identifiers.
+                    The configure script shall skip this config declaration if the detected platform is not matching
+                    the filter specification of these attributes.
+                </p>
             </xs:documentation>
         </xs:annotation>
         <xs:sequence>
             <xs:element name="var" type="ConfigVarType" minOccurs="0" maxOccurs="unbounded"/>
         </xs:sequence>
+        <xs:attribute name="platform" type="xs:string"/>
+        <xs:attribute name="not" type="xs:string"/>
     </xs:complexType>
 
     <xs:complexType name="ConfigVarType">
@@ -195,11 +205,11 @@
         </xs:annotation>
         <xs:choice minOccurs="0" maxOccurs="unbounded">
             <xs:group ref="TargetDataGroup"/>
+            <xs:element name="desc" type="xs:string"/>
         </xs:choice>
         <xs:attribute name="name" type="xs:string" use="required"/>
         <xs:attribute name="arg" type="xs:string"/>
         <xs:attribute name="default" type="xs:boolean" default="false"/>
-        <xs:element name="desc" type="xs:string"/>
     </xs:complexType>
 
     <xs:complexType name="OptionType">

mercurial