dol: initial dol commit
[jump.git] / dol / src / dol / visitor / PipeAndFilter / PipeAndFilterMakefileVisitor.java
diff --git a/dol/src/dol/visitor/PipeAndFilter/PipeAndFilterMakefileVisitor.java b/dol/src/dol/visitor/PipeAndFilter/PipeAndFilterMakefileVisitor.java
new file mode 100644 (file)
index 0000000..feb3257
--- /dev/null
@@ -0,0 +1,63 @@
+/* $Id: PipeAndFilterMakefileVisitor.java 1 2010-02-24 13:03:05Z haidw $ */
+package dol.visitor.PipeAndFilter;
+
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.PrintStream;
+
+import dol.datamodel.pn.ProcessNetwork;
+import dol.visitor.PNVisitor;
+
+/**
+ *
+ */
+public class PipeAndFilterMakefileVisitor extends PNVisitor {
+
+    /**
+     *
+     */
+    public PipeAndFilterMakefileVisitor(String dir) {
+        _dir = dir;
+    }
+
+    /**
+     *
+     */
+    public void visitComponent(ProcessNetwork x) {
+        try {
+            String filename = _dir + _delimiter + "Makefile";
+            OutputStream file = new FileOutputStream(filename);
+            PrintStream ps = new PrintStream(file);
+
+            ps.println("CXX = g++");
+            ps.println("CXXFLAGS = -g -Wall");
+            ps.println("COMPILE = ${CXX} ${CXXFLAGS} -c");
+            ps.println("LINK = ${CXX} -lpthread");
+            ps.println("LIB_INC = -Ilib -Iwrappers -Iprocesses");
+            ps.println();
+            ps.println("src := $(wildcard lib/*.cpp) "
+                    + "$(wildcard wrappers/*.cpp) $(wildcard *.cpp)");
+            ps.println("obj = $(src:.cpp=.o)");
+            ps.println();
+            ps.println("app : ${obj} ${src}");
+            ps.println("\t${LINK} -o " + _name + " $(obj)");
+            ps.println();
+            ps.println("%.o :");
+            ps.println("\t${COMPILE} -o $(*D)/$(*F).o $(*D)/$(*F).cpp $(LIB_INC)");
+            ps.println();
+            ps.println("clean :");
+            ps.println("\trm ${obj}");
+        }
+        catch (IOException e) {
+            System.out.println(" PipeAndFilter Makefile Visitor: exception " +
+                               "occured: " + e.getMessage());
+            e.printStackTrace();
+        }
+    }
+
+    protected String _dir = null;
+    protected String _name = "sc_application";
+
+}
+