dol: initial dol commit
[jump.git] / dol / src / dol / visitor / PipeAndFilter / PipeAndFilterMakefileVisitor.java
1 /* $Id: PipeAndFilterMakefileVisitor.java 1 2010-02-24 13:03:05Z haidw $ */
2 package dol.visitor.PipeAndFilter;
3
4 import java.io.FileOutputStream;
5 import java.io.IOException;
6 import java.io.OutputStream;
7 import java.io.PrintStream;
8
9 import dol.datamodel.pn.ProcessNetwork;
10 import dol.visitor.PNVisitor;
11
12 /**
13  *
14  */
15 public class PipeAndFilterMakefileVisitor extends PNVisitor {
16
17     /**
18      *
19      */
20     public PipeAndFilterMakefileVisitor(String dir) {
21         _dir = dir;
22     }
23
24     /**
25      *
26      */
27     public void visitComponent(ProcessNetwork x) {
28         try {
29             String filename = _dir + _delimiter + "Makefile";
30             OutputStream file = new FileOutputStream(filename);
31             PrintStream ps = new PrintStream(file);
32
33             ps.println("CXX = g++");
34             ps.println("CXXFLAGS = -g -Wall");
35             ps.println("COMPILE = ${CXX} ${CXXFLAGS} -c");
36             ps.println("LINK = ${CXX} -lpthread");
37             ps.println("LIB_INC = -Ilib -Iwrappers -Iprocesses");
38             ps.println();
39             ps.println("src := $(wildcard lib/*.cpp) "
40                     + "$(wildcard wrappers/*.cpp) $(wildcard *.cpp)");
41             ps.println("obj = $(src:.cpp=.o)");
42             ps.println();
43             ps.println("app : ${obj} ${src}");
44             ps.println("\t${LINK} -o " + _name + " $(obj)");
45             ps.println();
46             ps.println("%.o :");
47             ps.println("\t${COMPILE} -o $(*D)/$(*F).o $(*D)/$(*F).cpp $(LIB_INC)");
48             ps.println();
49             ps.println("clean :");
50             ps.println("\trm ${obj}");
51         }
52         catch (IOException e) {
53             System.out.println(" PipeAndFilter Makefile Visitor: exception " +
54                                "occured: " + e.getMessage());
55             e.printStackTrace();
56         }
57     }
58
59     protected String _dir = null;
60     protected String _name = "sc_application";
61
62 }
63