X-Git-Url: http://sraa.de/git/?a=blobdiff_plain;f=dol%2Fsrc%2Fdol%2Fvisitor%2FsystemC%2FMakefileVisitor.java;fp=dol%2Fsrc%2Fdol%2Fvisitor%2FsystemC%2FMakefileVisitor.java;h=c53f58514f158b9e2b424de0724b555509a6b587;hb=8c411cf24ed0eb889191aaeafd8fa1e69081df42;hp=0000000000000000000000000000000000000000;hpb=dea7a4fb1ed110d3ce6e6d9255103d724bd66c0e;p=jump.git diff --git a/dol/src/dol/visitor/systemC/MakefileVisitor.java b/dol/src/dol/visitor/systemC/MakefileVisitor.java new file mode 100644 index 0000000..c53f585 --- /dev/null +++ b/dol/src/dol/visitor/systemC/MakefileVisitor.java @@ -0,0 +1,72 @@ +/* $Id: MakefileVisitor.java 1 2010-02-24 13:03:05Z haidw $ */ +package dol.visitor.systemC; + +import java.io.FileOutputStream; +import java.io.OutputStream; +import java.io.PrintStream; + +import dol.datamodel.pn.ProcessNetwork; +import dol.visitor.PNVisitor; + +/** + * This class is a class for a visitor that is used to generate + * a SystemC package Makefile. + */ +public class MakefileVisitor extends PNVisitor { + + /** + * Constructor. + * + * @param dir path of the Makefile + */ + public MakefileVisitor(String dir) { + _dir = dir; + } + + /** + * Create a Makefile for the given process network. + * + * @param x process network that needs to be rendered. + */ + 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("CC = g++"); + ps.println(); + ps.println("SYSTEMC_INC = -I" + _ui.getSystemCINC()); + ps.println("SYSTEMC_LIB = " + _ui.getSystemCLIB()); + ps.println("MY_LIB_INC = -Ilib -Isc_wrappers -Iprocesses"); + ps.println("VPATH = lib:sc_wrappers:processes"); + ps.println(); + ps.println("CXXFLAGS = -g -O0 -D__DOL_ETHZ_GEN__ $(SYSTEMC_INC) $(MY_LIB_INC)"); + ps.println("CFLAGS = $(CXXFLAGS)"); + ps.println(); + + ps.print("PROCESS_OBJS = dol.o "); + for (String basename : x.getProcessBasenames()) { + ps.print(basename + "_wrapper.o "); + } + ps.println(); + ps.println(); + ps.println("all:" + _name); + ps.println(); + ps.println(_name + ": " + _name + ".o $(PROCESS_OBJS)"); + ps.println("\t$(CXX) $(CXXFLAGS) -o $@ $^ $(SYSTEMC_LIB)"); + ps.println("clean:"); + ps.println("\t-rm -f *.o core core.* *.core " + _name); + + } catch (Exception e) { + System.out.println(" SystemC Makefile Visitor: exception " + + "occured: " + e.getMessage()); + e.printStackTrace(); + } + + } + + protected String _dir = null; + protected String _name = "sc_application"; +}