1 /* $Id: ProtothreadMakefileVisitor.java 1 2010-02-24 13:03:05Z haidw $ */
2 package dol.visitor.protothread;
4 import java.io.FileOutputStream;
5 import java.io.IOException;
6 import java.io.OutputStream;
7 import java.io.PrintStream;
9 import dol.datamodel.pn.ProcessNetwork;
10 import dol.visitor.PNVisitor;
15 public class ProtothreadMakefileVisitor extends PNVisitor {
20 public ProtothreadMakefileVisitor(String dir) {
27 public void visitComponent(ProcessNetwork x) {
29 String filename = _dir + _delimiter + "Makefile";
30 OutputStream file = new FileOutputStream(filename);
31 PrintStream ps = new PrintStream(file);
33 ps.println("CXX = g++");
34 ps.println("CXXFLAGS = -g -Wall");
35 ps.println("COMPILE = ${CXX} ${CXXFLAGS} -c");
36 ps.println("LINK = ${CXX}");
37 ps.println("LIB_INC = -Ilib -Iwrappers");
39 ps.println("src := $(wildcard lib/*.cpp) "
40 + "$(wildcard wrappers/*.cpp) $(wildcard *.cpp)");
41 ps.println("obj = $(src:.cpp=.o)");
43 ps.println("app : ${obj} ${src}");
44 ps.println("\t${LINK} -o " + _name + " $(obj)");
47 ps.println("\t${COMPILE} -o $(*D)/$(*F).o $(*D)/$(*F).cpp "
50 ps.println("clean :");
51 ps.println("\trm ${obj}");
53 catch (IOException e) {
54 System.out.println(" Protothread Makefile Visitor: "
55 + "exception occured: " + e.getMessage());
60 protected String _dir = null;
61 protected String _name = "sc_application";