add existing source

Mon, 04 Feb 2019 15:09:39 +0100

author
Olaf Wintermann <olaf.wintermann@gmail.com>
date
Mon, 04 Feb 2019 15:09:39 +0100
changeset 0
38775db5fdf5
child 1
c393cdf57f2e

add existing source

.hgignore file | annotate | diff | comparison | revisions
dist/bin/uwproj file | annotate | diff | comparison | revisions
dist/install.sh file | annotate | diff | comparison | revisions
pom.xml file | annotate | diff | comparison | revisions
src/main/java/de/unixwork/uwproj/Define.java file | annotate | diff | comparison | revisions
src/main/java/de/unixwork/uwproj/Dependency.java file | annotate | diff | comparison | revisions
src/main/java/de/unixwork/uwproj/Feature.java file | annotate | diff | comparison | revisions
src/main/java/de/unixwork/uwproj/Flags.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/NamedDependency.java file | annotate | diff | comparison | revisions
src/main/java/de/unixwork/uwproj/Option.java file | annotate | diff | comparison | revisions
src/main/java/de/unixwork/uwproj/OptionDefault.java file | annotate | diff | comparison | revisions
src/main/java/de/unixwork/uwproj/OptionValue.java file | annotate | diff | comparison | revisions
src/main/java/de/unixwork/uwproj/PkgConfigPackage.java file | annotate | diff | comparison | revisions
src/main/java/de/unixwork/uwproj/Project.java file | annotate | diff | comparison | revisions
src/main/java/de/unixwork/uwproj/Target.java file | annotate | diff | comparison | revisions
src/main/java/de/unixwork/uwproj/TargetData.java file | annotate | diff | comparison | revisions
src/main/java/de/unixwork/uwproj/Xml.java file | annotate | diff | comparison | revisions
test/config.mk file | annotate | diff | comparison | revisions
test/configure 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/project.xml file | annotate | diff | comparison | revisions
test/make/suncc.mk file | annotate | diff | comparison | revisions
test/make/toolchain.sh file | annotate | diff | comparison | revisions
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/.hgignore	Mon Feb 04 15:09:39 2019 +0100
@@ -0,0 +1,2 @@
+^nbactions.xml$
+^target/.*$
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dist/bin/uwproj	Mon Feb 04 15:09:39 2019 +0100
@@ -0,0 +1,5 @@
+#!/bin/sh
+
+PREFIX=/usr
+
+java -jar $PREFIX/lib/uwproj/uwproj-0.1.jar "$@"
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dist/install.sh	Mon Feb 04 15:09:39 2019 +0100
@@ -0,0 +1,11 @@
+#!/bin/sh
+
+echo "mkdir -p /usr/lib/uwproj"
+mkdir -p /usr/lib/uwproj
+
+echo "cp ../target/uwproj-0.1-jar-with-dependencies.jar /usr/lib/uwproj/uwproj-0.1.jar"
+cp ../target/uwproj-0.1-jar-with-dependencies.jar /usr/lib/uwproj/uwproj-0.1.jar
+
+echo "cp bin/uwproj /usr/bin"
+cp bin/uwproj /usr/bin
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/pom.xml	Mon Feb 04 15:09:39 2019 +0100
@@ -0,0 +1,48 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <groupId>de.unixwork</groupId>
+    <artifactId>uwproj</artifactId>
+    <version>0.1</version>
+    <packaging>jar</packaging>
+    <properties>
+        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+        <maven.compiler.source>1.8</maven.compiler.source>
+        <maven.compiler.target>1.8</maven.compiler.target>
+    </properties>
+    <build>
+        <plugins>
+            <plugin>
+            <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-assembly-plugin</artifactId>
+                <executions>
+                    <execution>
+                        <phase>package</phase>
+                        <goals>
+                            <goal>single</goal>
+                        </goals>
+                        <configuration>
+                            <archive>
+                            <manifest>
+                                <mainClass>
+                                    de.unixwork.uwproj.Main
+                                </mainClass>
+                            </manifest>
+                            </archive>
+                            <descriptorRefs>
+                                <descriptorRef>jar-with-dependencies</descriptorRef>
+                            </descriptorRefs>
+                        </configuration>
+                    </execution>
+                </executions>
+            </plugin>
+        </plugins>
+    </build>
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.velocity</groupId>
+            <artifactId>velocity-engine-core</artifactId>
+            <version>2.0</version>
+        </dependency>
+    </dependencies>
+</project>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/java/de/unixwork/uwproj/Define.java	Mon Feb 04 15:09:39 2019 +0100
@@ -0,0 +1,51 @@
+package de.unixwork.uwproj;
+
+/*
+ * 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.
+ */
+
+/**
+ *
+ * @author olaf
+ */
+public class Define {
+    private String name;
+    private String value;
+
+    public Define() {
+        
+    }
+    
+    public Define(String name, String value) {
+        this.name = name;
+        this.value = value;
+    }
+    
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public String getValue() {
+        return value;
+    }
+
+    public void setValue(String value) {
+        this.value = value;
+    }
+    
+    public String toFlags() {
+        if(name == null) {
+            return "";
+        } else if(value == null) {
+            return "-D"+name;
+        } else {
+            return "-D"+name + "=" + value;
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/java/de/unixwork/uwproj/Dependency.java	Mon Feb 04 15:09:39 2019 +0100
@@ -0,0 +1,122 @@
+/*
+ * 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.util.LinkedList;
+import java.util.List;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+/**
+ *
+ * @author olaf
+ */
+public class Dependency {
+    private String name;
+    private String platform;
+    
+    private List<Flags> flags = new LinkedList<>();
+    private List<PkgConfigPackage> pkgconfig = new LinkedList<>();
+    private List<String> tests = new LinkedList<>();
+    
+    private boolean abortOnError = false;
+    
+    private int num = 0;
+    
+    public static Dependency parse(Element element) throws Exception {
+        Dependency d = new Dependency();
+        
+        String name = element.getAttribute("name");
+        String platform = element.getAttribute("platform");
+        if(name.length() > 0) {
+            d.setName(name);
+        }
+        if(platform.length() > 0) {
+            d.setPlatform(platform);
+        }
+        
+        NodeList nodes = element.getChildNodes();
+        for(int i=0;i<nodes.getLength();i++) {
+            Node node = nodes.item(i);
+            if (node.getNodeType() == Node.ELEMENT_NODE) {
+                Element elm = (Element)node;
+                String n = elm.getNodeName();
+                if(n.equals("cflags") || n.equals("ldflags")) {
+                    Flags f = Flags.parse(elm);
+                    d.addFlags(f);
+                } else if(n.equals("pkgconfig")) {
+                    PkgConfigPackage pcp = PkgConfigPackage.parse(elm);
+                    d.addPkgconfig(pcp);
+                } else if(n.equals("test")) {
+                    d.tests.add(Xml.getContent(elm));
+                }
+            }
+        }
+        
+        return d;
+    }
+    
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public String getPlatform() {
+        return platform;
+    }
+    
+    public String getPlatformString() {
+        if(platform == null || platform.length() == 0) {
+            return "";
+        } else {
+            return "platform=\""+platform+'"';
+        }
+    }
+
+    public void setPlatform(String platform) {
+        this.platform = platform;
+    }
+
+    public List<Flags> getFlags() {
+        return flags;
+    }
+
+    public void addFlags(Flags flags) {
+        this.flags.add(flags);
+    }
+
+    public List<PkgConfigPackage> getPkgconfig() {
+        return pkgconfig;
+    }
+
+    public void addPkgconfig(PkgConfigPackage pkgconfig) {
+        this.pkgconfig.add(pkgconfig);
+    }
+
+    public boolean isAbortOnError() {
+        return abortOnError;
+    }
+
+    public void setAbortOnError(boolean abortOnError) {
+        this.abortOnError = abortOnError;
+    }
+    
+    public int getNum() {
+        return num;
+    }
+    
+    public void setNum(int num) {
+        this.num = num;
+    }
+    
+    public List<String> getTests() {
+        return tests;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/java/de/unixwork/uwproj/Feature.java	Mon Feb 04 15:09:39 2019 +0100
@@ -0,0 +1,99 @@
+/*
+ * 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.util.LinkedList;
+import java.util.List;
+import org.w3c.dom.Element;
+
+/**
+ *
+ * @author olaf
+ */
+public class Feature {
+    private String name;
+    private String arg;
+    private boolean def;
+    
+    private TargetData targetData;
+    
+    public static Feature parse(Project project, Element e) throws Exception {
+        Feature feature = new Feature();
+        String name = e.getAttribute("name");
+        String arg = e.getAttribute("arg");
+        String def = e.getAttribute("default");
+        
+        if(name.length() == 0) {
+            throw new Exception("feature element requires name attribute");
+        }
+        
+        String ld = def.toLowerCase();
+        boolean on = ld.equals("on") || ld.equals("true");
+        feature.setName(name);
+        feature.setDefault(on);
+        if(arg.length() == 0) {
+            feature.setArg(name);
+        } else {
+            feature.setArg(arg);
+        }
+        
+        feature.setTargetData(TargetData.parse(e));
+        project.addFeature(feature);
+        return feature;
+    }
+    
+    public String getVarName() {
+        return "FEATURE_"+name.toUpperCase();
+    }
+    
+    public List<String> getDependencies() {
+        return getTargetData().getDependencies();
+    }
+
+    public List<Define> getDefines() {
+        return getTargetData().getDefines();
+    }
+    
+    public String getMake() {
+        return targetData.getMake();
+    }
+    
+    public boolean hasMake() {
+        return targetData.getMake().trim().length() > 0;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public String getArg() {
+        return arg;
+    }
+
+    public void setArg(String arg) {
+        this.arg = arg;
+    }
+
+    public boolean isDefault() {
+        return def;
+    }
+
+    public void setDefault(boolean def) {
+        this.def = def;
+    }
+
+    public TargetData getTargetData() {
+        return targetData;
+    }
+
+    public void setTargetData(TargetData targetData) {
+        this.targetData = targetData;
+    }   
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/java/de/unixwork/uwproj/Flags.java	Mon Feb 04 15:09:39 2019 +0100
@@ -0,0 +1,56 @@
+/*
+ * 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 org.w3c.dom.Element;
+
+/**
+ *
+ * @author olaf
+ */
+public class Flags {
+    private String varName;
+    private String value;
+    private boolean exec = false;
+    
+    public static Flags parse(Element e) {
+        Flags f = new Flags();
+        f.varName = e.getNodeName().toUpperCase();
+        String value = Xml.getContent(e);
+        f.value = value == null ? "" : value;
+        
+        String type = e.getAttribute("type");
+        if(type != null && type.equals("exec")) {
+            f.exec = true;
+        }
+        
+        return f;
+    }
+    
+    public String getVarName() {
+        return varName;
+    }
+
+    public void setVarName(String varName) {
+        this.varName = varName;
+    }
+
+    public String getValue() {
+        return value;
+    }
+
+    public void setValue(String value) {
+        this.value = value;
+    }
+
+    public boolean isExec() {
+        return exec;
+    }
+
+    public void setExec(boolean exec) {
+        this.exec = exec;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/java/de/unixwork/uwproj/Main.java	Mon Feb 04 15:09:39 2019 +0100
@@ -0,0 +1,67 @@
+/*
+ * 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;
+
+/**
+ *
+ * @author olaf
+ */
+public class Main {
+    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);
+        } catch (Exception ex) {
+            Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
+        }
+        if(p == null) {
+            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());
+        
+        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);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/java/de/unixwork/uwproj/NamedDependency.java	Mon Feb 04 15:09:39 2019 +0100
@@ -0,0 +1,33 @@
+/*
+ * 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.util.List;
+
+/**
+ *
+ * @author olaf
+ */
+public class NamedDependency {
+    private String name;
+    private List<Dependency> subdependencies;
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public List<Dependency> getSubdependencies() {
+        return subdependencies;
+    }
+
+    public void setSubdependencies(List<Dependency> subdependency) {
+        this.subdependencies = subdependency;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/java/de/unixwork/uwproj/Option.java	Mon Feb 04 15:09:39 2019 +0100
@@ -0,0 +1,107 @@
+/*
+ * 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.util.LinkedList;
+import java.util.List;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+/**
+ *
+ * @author olaf
+ */
+public class Option {
+    private String arg;
+    
+    LinkedList<OptionValue> values = new LinkedList<>();
+    LinkedList<OptionDefault> defaults = new LinkedList<>();
+    
+    public static Option parse(Project project, Element element) throws Exception {
+        Option opt = new Option();
+        String arg = element.getAttribute("arg");
+        if(arg.length() == 0) {
+            throw new Exception("Option has no argument string");
+        }
+        opt.setArgument(arg);
+        
+        NodeList nodes = element.getChildNodes();
+        for(int i=0;i<nodes.getLength();i++) {
+            Node node = nodes.item(i);
+            if (node.getNodeType() == Node.ELEMENT_NODE) {
+                Element elm = (Element)node;
+                String n = elm.getNodeName();
+                if(n.equals("value")) {
+                    OptionValue value = new OptionValue(opt);
+                    value.setValue(elm.getAttribute("str"));
+                    value.setTargetData(TargetData.parse(elm));
+                    opt.values.add(value);
+                } else if(n.equals("default")) {
+                    String defValue = elm.getAttribute("value");
+                    String defPlatform = elm.getAttribute(("platform"));
+                    OptionDefault def = new OptionDefault(opt);
+                    def.setValueName(defValue);
+                    if(defPlatform.length() > 0) {
+                        def.setPlatform(defPlatform);
+                    }
+                    opt.defaults.add(def);
+                }
+            }
+        }
+        
+        return opt;
+    }
+
+    public String getArgument() {
+        return arg;
+    }
+
+    public void setArgument(String arg) {
+        this.arg = arg;
+    }
+    
+    public String getVarName() {
+        return "OPT_" + arg.toUpperCase();
+    }
+    
+    public String getArgValue() {
+        return "${ARG:"+(3+arg.length())+"}";
+    }
+    
+    public List<OptionValue> getValues() {
+        return values;
+    }
+    
+    public List<OptionDefault> getDefaults() {
+        return defaults;
+    }
+    
+    public String getValueFunc(String value) {
+        return "checkopt_"+arg+"_"+value;
+    }
+    
+    public String getValuesString() {
+        if(values.size() == 0) {
+            return "()";
+        } else if(values.size() == 1) {
+            return values.get(0).getValue();
+        } else {
+            StringBuilder vs = new StringBuilder();
+            vs.append('(');
+            for(int i=0;i<values.size();i++) {
+                if(i < values.size()-1) {
+                    vs.append(values.get(i).getValue());
+                    vs.append('|');
+                } else {
+                    vs.append(values.get(i).getValue());
+                }
+            }
+            vs.append(')');
+            return vs.toString();
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/java/de/unixwork/uwproj/OptionDefault.java	Mon Feb 04 15:09:39 2019 +0100
@@ -0,0 +1,49 @@
+/*
+ * 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;
+
+/**
+ *
+ * @author olaf
+ */
+public class OptionDefault {
+    private Option option;
+    private String value;
+    private String platform;
+
+    public OptionDefault(Option opt) {
+        option = opt;
+    }
+    
+    public String getValueName() {
+        return value;
+    }
+
+    public void setValueName(String value) {
+        this.value = value;
+    }
+
+    public String getPlatform() {
+        return platform;
+    }
+
+    public void setPlatform(String platform) {
+        this.platform = platform;
+    }
+    
+    public String getFunc() {
+        return option.getValueFunc(value);
+    }
+    
+    public OptionValue getValue() {
+        for(OptionValue val : option.getValues()) {
+            if(val.getValue().equals(value)) {
+                return val;
+            }
+        }
+        return null;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/java/de/unixwork/uwproj/OptionValue.java	Mon Feb 04 15:09:39 2019 +0100
@@ -0,0 +1,57 @@
+/*
+ * 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.util.List;
+import java.util.LinkedList;
+
+/**
+ *
+ * @author olaf
+ */
+public class OptionValue {
+    Option option;
+    
+    String value;
+    
+    TargetData targetData = new TargetData();
+    
+    public OptionValue(Option opt) {
+        option = opt;
+    }
+
+    public String getValue() {
+        return value;
+    }
+
+    public void setValue(String value) {
+        this.value = value;
+    }
+
+    public List<String> getDependencies() {
+        return targetData.getDependencies();
+    }
+
+    public List<Define> getDefines() {
+        return targetData.getDefines();
+    }
+    
+    public void setTargetData(TargetData data) {
+        targetData = data;
+    }
+    
+    public String getFunc() {
+        return option.getValueFunc(value);
+    }
+    
+    public String getMake() {
+        return targetData.getMake();
+    }
+    
+    public boolean hasMake() {
+        return targetData.getMake().trim().length() > 0;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/java/de/unixwork/uwproj/PkgConfigPackage.java	Mon Feb 04 15:09:39 2019 +0100
@@ -0,0 +1,57 @@
+/*
+ * 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 org.w3c.dom.Element;
+
+/**
+ *
+ * @author olaf
+ */
+public class PkgConfigPackage {
+    private String name;
+    private String atleast;
+    private String maxVersion;
+
+    public static PkgConfigPackage parse(Element e) throws Exception {
+        PkgConfigPackage p = new PkgConfigPackage();
+        String name = Xml.getContent(e);
+        if(name != null) {
+            p.setName(name);
+        } else {
+            throw new Exception("pkgconfig element: value required");
+        }
+        return p;
+    }
+    
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public String getAtleast() {
+        return atleast;
+    }
+
+    public void setAtleast(String atleast) {
+        this.atleast = atleast;
+    }
+
+    public String getMaxVersion() {
+        return maxVersion;
+    }
+
+    public void setMaxVersion(String maxVersion) {
+        this.maxVersion = maxVersion;
+    }
+    
+    public String getPkgConfigParam() {
+        return name;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/java/de/unixwork/uwproj/Project.java	Mon Feb 04 15:09:39 2019 +0100
@@ -0,0 +1,140 @@
+/*
+ * 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.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.NodeList;
+import org.xml.sax.SAXException;
+
+/**
+ *
+ * @author olaf
+ */
+public class Project {
+    private String path;
+    private Properties properties = new Properties();
+    
+    private HashMap<String,List<Dependency>> namedDependencies = new HashMap<>();
+    private List<Dependency> dependencies = new LinkedList<>();
+    private List<Target> targets = new LinkedList<>();
+    private List<Option> options = new LinkedList<>();
+    private List<Feature> features = new LinkedList<>();
+    
+    public Project(File file) throws ParserConfigurationException, SAXException, IOException, Exception {
+        DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
+        factory.setNamespaceAware(true);
+	DocumentBuilder builder = factory.newDocumentBuilder();
+	Document doc = builder.parse(file);
+        
+        Element root = doc.getDocumentElement();
+        NodeList dependency_nodes = root.getElementsByTagName("dependency");
+        NodeList target_nodes = root.getElementsByTagName("target");
+        NodeList property_nodes = root.getElementsByTagName("property");
+        
+        for(int i=0;i<dependency_nodes.getLength();i++) {
+            addDependency(Dependency.parse((Element)dependency_nodes.item(i)));
+        }
+        for(int i=0;i<target_nodes.getLength();i++) {
+            targets.add(Target.parse(this, (Element)target_nodes.item(i)));
+        }
+        for(int i=0;i<property_nodes.getLength();i++) {
+            Element p = (Element)property_nodes.item(i);
+            String name = p.getAttribute("name");
+            String value = p.getAttribute("value");
+            if(name != null && value != null) {
+                properties.setProperty(name, value);
+            } else {
+                throw new Exception("Missing property name or value");
+            }
+        }
+        
+        if(targets.size() == 0) {
+            createDefaultTarget();
+        }
+    }
+    
+    private void createDefaultTarget() {
+        Target t = new Target();
+        t.setAllDependencies(true);
+        t.setName("default");
+        addTarget(t);
+    }
+    
+    public String getPath() {
+        return path;
+    }
+
+    public void setPath(String path) {
+        this.path = path;
+    }
+    
+    public List<NamedDependency> getNamedDependencies() {
+        List<NamedDependency> ret = new LinkedList<>();
+        
+        for(Map.Entry<String,List<Dependency>> entry : namedDependencies.entrySet()) {
+            NamedDependency d = new NamedDependency();
+            d.setName(entry.getKey());
+            d.setSubdependencies(entry.getValue());
+            ret.add(d);
+        }
+        return ret;
+    }
+    
+    public List<Dependency> getDependencies() {
+        return dependencies;
+    }
+
+    public List<Target> getTargets() {
+        return targets;
+    }
+    
+    public void addDependency(Dependency dependency) {
+        if(dependency.getName() != null) {
+            List<Dependency> l = namedDependencies.get(dependency.getName());
+            if(l == null) {
+                l = new LinkedList<>();
+                namedDependencies.put(dependency.getName(), l);
+            }
+            dependency.setNum(l.size());
+            l.add(dependency);
+        } else {
+            dependencies.add(dependency);
+        }
+    }
+    
+    public void addTarget(Target target) {
+        targets.add(target);
+    }
+    
+    public void addOption(Option o) {
+        options.add(o);
+    }
+    
+    public List<Option> getOptions() {
+        return options;
+    }
+    
+    public void addFeature(Feature feature) {
+        features.add(feature);
+    }
+    
+    public List<Feature> getFeatures() {
+        return features;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/java/de/unixwork/uwproj/Target.java	Mon Feb 04 15:09:39 2019 +0100
@@ -0,0 +1,154 @@
+/*
+ * 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.util.LinkedList;
+import java.util.List;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+/**
+ *
+ * @author olaf
+ */
+public class Target {
+    private String name;
+    private String prefix;
+    
+    private List<String> dependencies = new LinkedList<>();
+    private List<String> optionalDependencies = new LinkedList<>();
+    private List<Define> defines = new LinkedList<>();
+    private List<Feature> features = new LinkedList<>();
+    private List<Option> options = new LinkedList<>();
+    
+    private boolean allDependencies = false;
+    
+    public static Target parse(Project project, Element element) throws Exception {
+        Target target = new Target();
+        
+        String name = element.getAttribute("name");
+        target.setName(name);
+        
+        NodeList nodes = element.getChildNodes();
+        for(int i=0;i<nodes.getLength();i++) {
+            Node node = nodes.item(i);
+            if (node.getNodeType() == Node.ELEMENT_NODE) {
+                Element elm = (Element)node;
+                String n = elm.getNodeName();
+                if(n.equals("feature")) {
+                    Feature feature = Feature.parse(project, elm);
+                    target.addFeature(feature);
+                } else if(n.equals("define")) {
+                    String def = elm.getAttribute("name");
+                    String defval = elm.getAttribute("value");
+                    if(def == null) {
+                        throw new Exception("define element requires name attribute");
+                    }
+                    target.addDefine(def, defval);
+                } else if(n.equals("dependencies")) {
+                    String deps = Xml.getContent(elm);                   
+                    String[] dependencies = deps.split(",");
+                    for(String dependency : dependencies) {
+                        dependency = dependency.trim();
+                        target.addDependency(dependency, false);
+                    }
+                } else if(n.equals("alldependencies")) {
+                    target.setAllDependencies(true);
+                } else if(n.equals("option")) {
+                    Option opt = Option.parse(project, elm);
+                    target.addOption(opt);
+                    project.addOption(opt);
+                }
+            }
+        }
+        
+        if (target.prefix == null) {
+            target.setPrefix(name.toUpperCase());
+        }
+        
+        return target;
+    }
+    
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public String getPrefix() {
+        return prefix;
+    }
+
+    public void setPrefix(String prefix) {
+        this.prefix = prefix;
+    }
+    
+    public String getCFlags() {
+        return prefix == null ? "CFLAGS" : prefix + "_CFLAGS";
+    }
+    
+    public String getLDFlags() {
+        return prefix == null ? "LDFLAGS" : prefix + "_LDFLAGS";
+    }
+    
+    public String getCXXFlags() {
+        return prefix == null ? "CXXFLAGS" : prefix + "_CXXFLAGS";
+    }
+
+    public List<String> getDependencies() {
+        return dependencies;
+    }
+
+    public void addDependency(String dependency, boolean optional) {
+        if(optional) {
+            optionalDependencies.add(dependency);
+        } else {
+            dependencies.add(dependency);
+        }
+    }
+
+    public List<String> getOptionalDependencies() {
+        return optionalDependencies;
+    }
+
+    public boolean isAllDependencies() {
+        return allDependencies;
+    }
+
+    public void setAllDependencies(boolean allDependencies) {
+        this.allDependencies = allDependencies;
+    }
+    
+    public void addDefine(String name, String value) {
+        Define def = new Define();
+        def.setName(name);
+        def.setValue(value);
+        defines.add(def);
+    }
+    
+    public List<Define> getDefines() {
+        return defines;
+    }
+    
+    public void addFeature(Feature f) {
+        features.add(f);
+    }
+    
+    public List<Feature> getFeatures() {
+        return features;
+    }
+    
+    public void addOption(Option o) {
+        options.add(o);
+    }
+    
+    public List<Option> getOptions() {
+        return options;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/java/de/unixwork/uwproj/TargetData.java	Mon Feb 04 15:09:39 2019 +0100
@@ -0,0 +1,80 @@
+/*
+ * 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.util.LinkedList;
+import java.util.List;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+/**
+ *
+ * @author olaf
+ */
+public class TargetData {
+    private List<Define> defines = new LinkedList<>();
+    private List<String> dependencies = new LinkedList<>();
+    private StringBuilder make = new StringBuilder();
+
+    public static TargetData parse(Element element) throws Exception {
+        TargetData data = new TargetData();
+        
+        NodeList nodes = element.getChildNodes();
+        for(int i=0;i<nodes.getLength();i++) {
+            Node node = nodes.item(i);
+            if (node.getNodeType() == Node.ELEMENT_NODE) {
+                Element elm = (Element)node;
+                String n = elm.getNodeName();
+                if(n.equals("define")) {
+                    String def = elm.getAttribute("name");
+                    String defval = elm.getAttribute("value");
+                    if(def == null) {
+                        throw new Exception("define element requires name attribute");
+                    }
+                    data.addDefine(new Define(def, defval));
+                } else if(n.equals("dependencies")) {
+                    String deps = Xml.getContent(elm);
+                    String[] dependencies = deps.split(",");
+                    for(String dependency : dependencies) {
+                        dependency = dependency.trim();
+                        data.addDependency(dependency);
+                    }
+                } else if(n.equals("make")) {
+                    String m = Xml.getContent(elm);
+                    data.addMake(m);
+                }
+            }
+        }
+        
+        return data;
+    }
+    
+    public List<Define> getDefines() {
+        return defines;
+    }
+
+    public List<String> getDependencies() {
+        return dependencies;
+    }
+
+    public String getMake() {
+        return make.toString();
+    }
+    
+    public void addDefine(Define d) {
+        defines.add(d);
+    }
+    
+    public void addDependency(String d) {
+        dependencies.add(d);
+    }
+    
+    public void addMake(String m) {
+        make.append(m.trim());
+        make.append('\n');
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/java/de/unixwork/uwproj/Xml.java	Mon Feb 04 15:09:39 2019 +0100
@@ -0,0 +1,27 @@
+/*
+ * 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 org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+/**
+ *
+ * @author olaf
+ */
+public class Xml {
+    public static String getContent(Element elm) {
+        NodeList nodes = elm.getChildNodes();
+        for(int i=0;i<nodes.getLength();i++) {
+            Node node = nodes.item(i);
+            if (node.getNodeType() == Node.TEXT_NODE) {
+                return node.getTextContent();
+            }
+        }
+        return null;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/config.mk	Mon Feb 04 15:09:39 2019 +0100
@@ -0,0 +1,11 @@
+#
+# config.mk generated by configure
+#
+CC = cc
+LD = cc
+include $(BUILD_ROOT)make/gcc.mk
+
+
+DAV_CFLAGS  +=   -I/usr/include/libxml2 -DTEST -I/usr/include/gtk-2.0 -I/usr/lib64/gtk-2.0/include -I/usr/include/pango-1.0 -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -I/usr/include/cairo -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/libpng16 -I/usr/include/harfbuzz -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/atk-1.0 -pthread 
+DAV_LDFLAGS +=  -lcurl  -lxml2  -lgtk-x11-2.0 -lgdk-x11-2.0 -lpangocairo-1.0 -latk-1.0 -lcairo -lgdk_pixbuf-2.0 -lgio-2.0 -lpangoft2-1.0 -lpango-1.0 -lgobject-2.0 -lglib-2.0 -lfontconfig -lfreetype 
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/configure	Mon Feb 04 15:09:39 2019 +0100
@@ -0,0 +1,588 @@
+#!/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
+    if [[ $ARG == --prefix=* ]]; then
+        PREFIX=${ARG:9}
+    elif [[ $ARG = --exec-prefix=* ]]; then
+    	EPREFIX=${ARG:14}
+    elif [[ $ARG = --bindir=* ]]; then
+    	BINDIR=${ARG:9}
+    elif [[ $ARG = --sbindir=* ]]; then
+    	SBINDIR=${ARG:10}
+    elif [[ $ARG = --libdir=* ]]; then
+    	LIBDIR=${ARG:9}
+    elif [[ $ARG = --libexecdir=* ]]; then
+    	LIBEXECDIR=${ARG:13}
+    elif [[ $ARG = --datadir=* ]]; then
+    	DATADIR=${ARG:10}
+    elif [[ $ARG = --sysconfdir=* ]]; then
+    	SYSCONFDIR=${ARG:13}
+    elif [[ $ARG = --sharedstatedir=* ]]; then
+    	SHAREDSTATEDIR=${ARG:17}
+    elif [[ $ARG = --localstatedir=* ]]; then
+    	LOCALSTATEDIR=${ARG:16}
+    elif [[ $ARG = --includedir=* ]]; then
+    	INCLUDEDIR=${ARG:12}
+    elif [[ $ARG = --infodir=* ]]; then
+    	INFODIR=${ARG:10}
+    elif [[ $ARG = --mandir=* ]]; then
+    	MANDIR=${ARG:9}
+    elif [ $ARG = "--help" ]; then
+		printhelp
+        exit 0	
+    elif [[ $ARG == --toolkit=* ]]; then
+    	OPT_TOOLKIT=${ARG:10}
+    elif [[ $ARG == --enable-db ]]; then
+    	FEATURE_DB=on
+    elif [[ $ARG == --disable-db ]]; then
+    	unset FEATURE_DB
+    elif [[ $ARG == --enable-gui ]]; then
+    	FEATURE_GUI=on
+    elif [[ $ARG == --disable-gui ]]; then
+    	unset FEATURE_GUI
+    fi
+done
+
+# set dir variables
+if [ -z $BINDIR ]; then
+	BINDIR=$EPREFIX/bin
+fi
+if [ -z $SBINDIR ]; then
+	SBINDIR=$EPREFIX/sbin
+fi
+if [ -z $LIBDIR ]; then
+	LIBDIRDIR=$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 [ $? -ne 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 "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
+}
+
+# generate config.mk and config.h
+cat > $TEMP_DIR/config.mk << __EOF__
+#
+# config.mk generated by configure
+#
+__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
+source make/toolchain.sh
+
+# add user specified flags to config.mk
+echo >> $TEMP_DIR/config.mk
+if [[ ! -z ${ENV_CFLAGS} ]]; then
+    echo "CFLAGS += $ENV_CFLAGS" >> $TEMP_DIR/config.mk
+fi
+if [[ ! -z ${ENV_CXXFLAGS} ]]; then
+    echo "CXXFLAGS += $ENV_CXXFLAGS" >> $TEMP_DIR/config.mk
+fi
+if [[ ! -z ${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 ! isplatform "windows"; then
+            break
+        fi
+        CFLAGS+="-I/mingw/include"    
+        LDFLAGS+="-lcurl"    
+        echo yes
+        return 0
+    done
+	
+    # dependency curl platform="macos"
+    while true
+    do
+    	if ! isplatform "macos"; then
+            break
+        fi
+        curl-config --cflags > /dev/null
+        if [ $? -eq 0 ]; then
+            CFLAGS+=" `curl-config --cflags`"
+        else
+            break
+        fi
+        curl-config --ldflags > /dev/null
+        if [ $? -eq 0 ]; then
+            LDFLAGS+=" `curl-config --ldflags`"
+        else
+            break
+        fi
+        echo yes
+        return 0
+    done
+	
+    # dependency curl 
+    while true
+    do
+        if [ -z "PKG_CONFIG" ]; then
+        	break
+        fi
+        if ! pkg-config libcurl ; then
+            break
+        fi
+        CFLAGS+=" `pkg-config --cflags libcurl`"
+        LDFLAGS+=" `pkg-config --libs libcurl`"
+        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
+        if ! pkg-config sqlite3 ; then
+            break
+        fi
+        CFLAGS+=" `pkg-config --cflags sqlite3`"
+        LDFLAGS+=" `pkg-config --libs sqlite3`"
+        echo yes
+        return 0
+    done
+	
+	echo no
+	return 1
+}
+dependency_test()
+{
+    printf "checking for test... "
+    # dependency test 
+    while true
+    do
+        CFLAGS+="-DTEST"    
+        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
+        if ! pkg-config gtk+-2.0 ; then
+            break
+        fi
+        CFLAGS+=" `pkg-config --cflags gtk+-2.0`"
+        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
+        if ! pkg-config gtk+-5.0 ; then
+            break
+        fi
+        CFLAGS+=" `pkg-config --cflags gtk+-5.0`"
+        LDFLAGS+=" `pkg-config --libs gtk+-5.0`"
+        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
+        if ! pkg-config libxml-2.0 ; then
+            break
+        fi
+        CFLAGS+=" `pkg-config --cflags libxml-2.0`"
+        LDFLAGS+=" `pkg-config --libs libxml-2.0`"
+        echo yes
+        return 0
+    done
+	
+	echo no
+	return 1
+}
+
+DEPENDENCIES_FAILED=
+ERROR=0
+
+#
+# OPTION VALUES
+#
+checkopt_toolkit_gtk3()
+{
+	VERR=0
+	dependency_gtk3
+	if [ $? -ne 0 ]; then
+		VERR=1
+	fi
+	if [ $VERR -ne 0 ]; then
+		return 1
+	fi
+		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
+#
+CFLAGS=
+CXXFLAGS=
+LDFLAGS=
+
+# Target: dav
+CFLAGS=
+LDFLAGS=
+CXXFLAGS=
+
+dependency_curl
+if [ $? -ne 0 ]; then
+	DEPENDENCIES_FAILED+="curl "
+	ERROR=1
+fi
+dependency_libxml2
+if [ $? -ne 0 ]; then
+	DEPENDENCIES_FAILED+="libxml2 "
+	ERROR=1
+fi
+dependency_test
+if [ $? -ne 0 ]; then
+	DEPENDENCIES_FAILED+="test "
+	ERROR=1
+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 [[ ! -z ${CFLAGS} ]]; then
+    echo "DAV_CFLAGS  += $CFLAGS" >> $TEMP_DIR/config.mk
+fi
+if [[ ! -z ${CXXFLAGS} ]]; then
+    echo "DAV_CXXFLAGS += $CXXFLAGS" >> $TEMP_DIR/config.mk
+fi
+if [[ ! -z ${LDFLAGS} ]]; then
+    echo "DAV_LDFLAGS += $LDFLAGS" >> $TEMP_DIR/config.mk
+fi
+
+if [ $ERROR -ne 0 ]; then
+	echo
+	echo "Error: Unresolved dependencies"
+	echo $DEPENCIES_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
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/make/clang.mk	Mon Feb 04 15:09:39 2019 +0100
@@ -0,0 +1,9 @@
+#
+# clang toolchain config
+#
+
+CFLAGS = 
+LDFLAGS = 
+
+SHLIB_CFLAGS = -fPIC
+SHLIB_LDFLAGS = -shared
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/make/configure.vm	Mon Feb 04 15:09:39 2019 +0100
@@ -0,0 +1,500 @@
+#!/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
+#foreach( $feature in $features )
+#if( ${feature.isDefault()} )
+${feature.getVarName()}=on
+#end
+#end
+
+# 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]
+
+#if( $options.size() > 0 )
+Options:
+#foreach( $opt in $options )
+  --${opt.getArgument()}=${opt.getValuesString()}
+#end
+
+#end
+#if( $features.size() > 0 )
+Optional Features:
+#foreach( $feature in $features )
+#if( $feature.default )
+  --disable-${feature.arg}
+#else
+  --enable-${feature.arg}
+#end
+#end
+
+#end
+__EOF__
+}
+
+#
+# parse arguments 
+#
+#set( $D = '$' )
+for ARG in $@
+do
+    if [[ $ARG == --prefix=* ]]; then
+        PREFIX=${D}{ARG:9}
+    elif [[ $ARG = --exec-prefix=* ]]; then
+    	EPREFIX=${D}{ARG:14}
+    elif [[ $ARG = --bindir=* ]]; then
+    	BINDIR=${D}{ARG:9}
+    elif [[ $ARG = --sbindir=* ]]; then
+    	SBINDIR=${D}{ARG:10}
+    elif [[ $ARG = --libdir=* ]]; then
+    	LIBDIR=${D}{ARG:9}
+    elif [[ $ARG = --libexecdir=* ]]; then
+    	LIBEXECDIR=${D}{ARG:13}
+    elif [[ $ARG = --datadir=* ]]; then
+    	DATADIR=${D}{ARG:10}
+    elif [[ $ARG = --sysconfdir=* ]]; then
+    	SYSCONFDIR=${D}{ARG:13}
+    elif [[ $ARG = --sharedstatedir=* ]]; then
+    	SHAREDSTATEDIR=${D}{ARG:17}
+    elif [[ $ARG = --localstatedir=* ]]; then
+    	LOCALSTATEDIR=${D}{ARG:16}
+    elif [[ $ARG = --includedir=* ]]; then
+    	INCLUDEDIR=${D}{ARG:12}
+    elif [[ $ARG = --infodir=* ]]; then
+    	INFODIR=${D}{ARG:10}
+    elif [[ $ARG = --mandir=* ]]; then
+    	MANDIR=${D}{ARG:9}
+    elif [ $ARG = "--help" ]; then
+		printhelp
+        exit 0	
+    #foreach( $opt in $options )
+    elif [[ $ARG == --${opt.getArgument()}=* ]]; then
+    	${opt.getVarName()}=${opt.getArgValue()}
+    #end
+    #foreach( $feature in $features )
+    elif [[ $ARG == --enable-${feature.arg} ]]; then
+    	${feature.getVarName()}=on
+    elif [[ $ARG == --disable-${feature.arg} ]]; then
+    	unset ${feature.getVarName()}
+    #end
+    fi
+done
+
+# set dir variables
+if [ -z $BINDIR ]; then
+	BINDIR=$EPREFIX/bin
+fi
+if [ -z $SBINDIR ]; then
+	SBINDIR=$EPREFIX/sbin
+fi
+if [ -z $LIBDIR ]; then
+	LIBDIRDIR=$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 [ $? -ne 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 "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
+}
+
+# generate config.mk and config.h
+cat > $TEMP_DIR/config.mk << __EOF__
+#
+# config.mk generated by configure
+#
+__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
+source make/toolchain.sh
+
+# add user specified flags to config.mk
+echo >> $TEMP_DIR/config.mk
+if [[ ! -z ${ENV_CFLAGS} ]]; then
+    echo "CFLAGS += $ENV_CFLAGS" >> $TEMP_DIR/config.mk
+fi
+if [[ ! -z ${ENV_CXXFLAGS} ]]; then
+    echo "CXXFLAGS += $ENV_CXXFLAGS" >> $TEMP_DIR/config.mk
+fi
+if [[ ! -z ${ENV_LDFLAGS} ]]; then
+    echo "LDFLAGS += $ENV_LDFLAGS" >> $TEMP_DIR/config.mk
+fi
+
+#
+# DEPENDENCIES
+#
+
+#foreach( $dependency in $namedDependencies )
+dependency_${dependency.name}()
+{
+    printf "checking for ${dependency.name}... "
+    #foreach( $sub in $dependency.getSubdependencies() )
+    # dependency $sub.name $sub.getPlatformString()
+    while true
+    do
+    	#if( $sub.platform )
+    	if ! isplatform "${sub.platform}"; then
+            break
+        fi
+    	#end
+        #if( $sub.pkgconfig.size() > 0 )
+        if [ -z "PKG_CONFIG" ]; then
+        	break
+        fi
+        #end
+        #foreach( $pkg in $sub.pkgconfig )
+        if ! pkg-config $pkg.getPkgConfigParam() ; then
+            break
+        fi
+        CFLAGS+=" `pkg-config --cflags $pkg.getPkgConfigParam()`"
+        LDFLAGS+=" `pkg-config --libs $pkg.getPkgConfigParam()`"
+        #end
+        #foreach( $flags in $sub.flags )
+        #if( $flags.exec )
+        $flags.value > /dev/null
+        if [ $? -eq 0 ]; then
+            $flags.varName+=" `$flags.value`"
+        else
+            break
+        fi
+        #else
+        $flags.varName+="$flags.value"    
+        #end
+        #end
+        #foreach( $test in $sub.tests )
+        $test > /dev/null
+        if [ $? -ne 0 ]; then
+        	break
+        fi
+        #end
+        echo yes
+        return 0
+    done
+	
+	#end
+	echo no
+	return 1
+}
+#end
+
+DEPENDENCIES_FAILED=
+ERROR=0
+#if( $dependencies.size() > 0 )
+# general dependencies
+CFLAGS=
+LDFLAGS=
+#foreach( $dependency in $dependencies )
+while true
+do
+	#if( $dependency.platform )
+    if ! isplatform "${sub.platform}"; then
+        break
+    fi
+    #end
+    while true
+    do
+        #if( $dependency.pkgconfig.size() > 0 )
+        if [ -z "PKG_CONFIG" ]; then
+            ERROR=1
+            break
+        fi
+        #end
+        #foreach( $pkg in $dependency.pkgconfig )
+        printf "checking for pkg-config package $pkg.getPkgConfigParam()... "
+        if ! pkg-config $pkg.getPkgConfigParam() ; then
+            echo no
+            ERROR=1
+            break
+        fi
+        echo yes
+        CFLAGS+=" `pkg-config --cflags $pkg.getPkgConfigParam()`"
+        LDFLAGS+=" `pkg-config --libs $pkg.getPkgConfigParam()`"
+        #end
+        
+        #foreach( $flags in $dependency.flags )
+        #if( $flags.exec )
+        $flags.value > /dev/null
+        if [ $? -ne 0 ]; then
+            $flags.varName+=" `$flags.value`"
+        else
+            ERROR=1
+            break
+        fi
+        #else
+        $flags.varName+="$flags.value"    
+        #end
+        #end
+        
+        break
+    done
+    
+    break
+done
+#end
+
+# add general dependency flags to config.mk
+echo >> $TEMP_DIR/config.mk
+if [[ ! -z ${CFLAGS} ]]; then
+    echo "CFLAGS += $CFLAGS" >> $TEMP_DIR/config.mk
+fi
+if [[ ! -z ${CXXFLAGS} ]]; then
+    echo "CXXFLAGS += $CXXFLAGS" >> $TEMP_DIR/config.mk
+fi
+if [[ ! -z ${LDFLAGS} ]]; then
+    echo "LDFLAGS += $LDFLAGS" >> $TEMP_DIR/config.mk
+fi
+#end
+
+#
+# OPTION VALUES
+#
+#foreach( $opt in $options )
+#foreach( $val in $opt.values )
+${val.func}()
+{
+	VERR=0
+	#foreach( $dep in $val.dependencies )
+	dependency_$dep
+	if [ $? -ne 0 ]; then
+		VERR=1
+	fi
+	#end
+	if [ $VERR -ne 0 ]; then
+		return 1
+	fi
+	#foreach( $def in $val.defines )
+		CFLAGS+=" ${def.toFlags()}"
+	#end
+	#if( $val.hasMake() )
+	cat >> $TEMP_DIR/make.mk << __EOF__
+$val.make
+__EOF__
+	#end
+	return 0
+}
+#end
+#end
+
+#
+# TARGETS
+#
+CFLAGS=
+CXXFLAGS=
+LDFLAGS=
+
+#foreach( $target in $targets )
+#if ( $target.name )
+# Target: $target.name
+#else
+# Target
+#end
+CFLAGS=
+LDFLAGS=
+CXXFLAGS=
+
+#foreach( $dependency in $target.dependencies )
+dependency_$dependency
+if [ $? -ne 0 ]; then
+	DEPENDENCIES_FAILED+="${dependency} "
+	ERROR=1
+fi
+#end
+
+#foreach( $opt in $target.options )
+# Option: --${opt.argument}
+if [ -z ${D}${opt.getVarName()} ]; then
+	SAVED_ERROR=$ERROR
+	SAVED_DEPENDENCIES_FAILED=$DEPENDENCIES_FAILED
+	ERROR=0
+	while true
+	do
+		#foreach( $optdef in $opt.defaults )
+		#if( $optdef.platform )
+		if isplatform "$optdef.platform"; then
+		#end
+		$optdef.func
+		if [ $? -eq 0 ]; then
+			echo "  ${opt.argument}: ${optdef.valueName}" >> $TEMP_DIR/options
+			ERROR=0
+			break
+		fi
+		#if( $optdef.platform )
+		fi
+		#end
+		#end
+		break
+	done
+	if [ $ERROR -ne 0 ]; then
+		SAVED_ERROR=1
+	fi
+	ERROR=$SAVED_ERROR
+	DEPENDENCIES_FAILED=$SAVED_DEPENDENCIES_FAILED=
+else
+	if false; then
+		false
+	#foreach( $optval in $opt.values )
+	elif [ ${D}${opt.getVarName()} = "${optval.value}" ]; then
+		echo "  ${opt.argument}: ${D}${opt.getVarName()}" >> $TEMP_DIR/options
+		$optval.func
+		if [ $? -ne 0 ]; then
+			ERROR=1
+		fi
+	#end
+	fi
+fi
+#end
+
+echo >> $TEMP_DIR/config.mk
+if [[ ! -z ${CFLAGS} ]]; then
+    echo "${target.getCFlags()}  += $CFLAGS" >> $TEMP_DIR/config.mk
+fi
+if [[ ! -z ${CXXFLAGS} ]]; then
+    echo "${target.getCXXFlags()} += $CXXFLAGS" >> $TEMP_DIR/config.mk
+fi
+if [[ ! -z ${LDFLAGS} ]]; then
+    echo "${target.getLDFlags()} += $LDFLAGS" >> $TEMP_DIR/config.mk
+fi
+
+#end
+if [ $ERROR -ne 0 ]; then
+	echo
+	echo "Error: Unresolved dependencies"
+	echo $DEPENCIES_FAILED
+	rm -Rf $TEMP_DIR
+	exit 1
+fi
+
+echo "configure finished"
+echo
+echo "Build Config:"
+echo "  PREFIX:    $PREFIX"
+echo "  TOOLCHAIN: $TOOLCHAIN_NAME"
+#if ( $options.size() > 0 )
+echo "Options:"
+cat $TEMP_DIR/options
+#end
+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/test/make/gcc.mk	Mon Feb 04 15:09:39 2019 +0100
@@ -0,0 +1,10 @@
+#
+# gcc toolchain config
+#
+
+CFLAGS = 
+LDFLAGS = 
+
+SHLIB_CFLAGS = -fPIC
+SHLIB_LDFLAGS = -shared
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/make/project.xml	Mon Feb 04 15:09:39 2019 +0100
@@ -0,0 +1,63 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project>
+	<dependency name="curl" platform="windows">
+		<cflags>-I/mingw/include</cflags>
+		<ldflags>-lcurl</ldflags>
+	</dependency>
+	<dependency name="curl" platform="macos">
+		<cflags type="exec">curl-config --cflags</cflags>
+		<ldflags type="exec">curl-config --ldflags</ldflags>
+	</dependency>
+	<dependency name="curl">
+		<pkgconfig>libcurl</pkgconfig>
+	</dependency>
+	<dependency name="libxml2">
+		<pkgconfig>libxml-2.0</pkgconfig>
+	</dependency>
+	<dependency name="sqlite">
+		<pkgconfig>sqlite3</pkgconfig>
+	</dependency>
+	<dependency name="test">
+		<cflags>-DTEST</cflags>
+	</dependency>
+	<dependency name="gtk3">
+		<pkgconfig>gtk+-5.0</pkgconfig>
+	</dependency>
+	<dependency name="gtk2">
+		<pkgconfig>gtk+-2.0</pkgconfig>
+	</dependency>
+	<dependency name="qt4">
+		<test>which qmake-qt4</test>
+	</dependency>
+	<target name="dav">
+		<feature name="db" default="on">
+			<dependencies>sqlite</dependencies>
+			<define name="DATABASE"/>
+		</feature>
+		<feature name="gui">
+			<dependencies>gtk3</dependencies>
+			<define name="UI" value="GTK3" />
+		</feature>
+		<option arg="toolkit">
+			<value str="gtk3">
+				<define name="a" value="b" />
+				<dependencies>gtk3</dependencies>
+				<make>UIOBJ += graphics_cairo.o</make>
+			</value>
+			<value str="cli">
+				<dependencies>curl,test</dependencies>
+			</value>
+			<value str="gtk2">
+				<dependencies>gtk2</dependencies>
+			</value>
+			<value str="wpf">
+				<dependencies>test</dependencies>
+			</value>
+			<default value="wpf" platform="windows" />
+			<default value="gtk3" />
+			<default value="gtk2" />
+		</option>
+		<dependencies>curl,libxml2,test</dependencies>
+	</target>
+</project>
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/make/suncc.mk	Mon Feb 04 15:09:39 2019 +0100
@@ -0,0 +1,10 @@
+#
+# suncc toolchain
+#
+
+CFLAGS = 
+LDFLAGS = 
+
+SHLIB_CFLAGS = -Kpic
+SHLIB_LDFLAGS = -G
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/make/toolchain.sh	Mon Feb 04 15:09:39 2019 +0100
@@ -0,0 +1,68 @@
+#!/bin/sh
+#
+# toolchain detection
+#
+
+COMPILERS="cc gcc clang suncc"
+unset CC_ARG_CHECKED
+unset TOOLCHAIN_DETECTION_ERROR
+unset TOOLCHAIN_NAME
+
+check_compiler()
+{
+    cat > $TEMP_DIR/test.c << __EOF__
+/* test file */
+#include <stdio.h>
+int main(int argc, char **argv) {
+#if defined(__GNUC__)
+    printf("gcc\n");
+#elif defined(__clang__)
+    printf("clang\n");
+#elif defined(__sun)
+    printf("suncc\n");
+#else
+    printf("unknown\n");
+#endif
+    return 0;
+}
+__EOF__
+    rm -f $TEMP_DIR/checkcc
+    $1 -o $TEMP_DIR/checkcc $CFLAGS $LDFLAGS $TEMP_DIR/test.c
+    
+    if [ $? -ne 0 ]; then
+        return 1
+    fi
+    return 0
+}
+
+printf "detect toolchain... "
+
+for COMP in $COMPILERS
+do
+    check_compiler $COMP
+    if [ $? -ne 0 ]; then
+        if [ $COMP = $CC ]; then
+            echo "$CC is not a working C Compiler"
+            TOOLCHAIN_DETECTION_ERROR="error"
+            break
+        fi
+    else
+        TOOLCHAIN_NAME=`$TEMP_DIR/checkcc`
+        TOOLCHAIN_CC=$COMP
+        echo $TOOLCHAIN_NAME
+        break
+    fi
+done
+
+TOOLCHAIN_LD=$TOOLCHAIN_CC
+
+if [ -z TOOLCHAIN_NAME ]; then
+    TOOLCHAIN_DETECTION_ERROR="error"
+else
+    echo "CC = ${TOOLCHAIN_CC}" >> $TEMP_DIR/config.mk
+    echo "LD = ${TOOLCHAIN_LD}" >> $TEMP_DIR/config.mk
+    
+    if [ -e "make/${TOOLCHAIN_NAME}.mk" ]; then 
+        echo "include \$(BUILD_ROOT)make/${TOOLCHAIN_NAME}.mk" >> $TEMP_DIR/config.mk
+    fi
+fi

mercurial