1 /* $Id: MakefileVisitor.java 1 2010-02-24 13:03:05Z haidw $ */
2 package dol.visitor.systemC;
4 import java.io.FileOutputStream;
5 import java.io.OutputStream;
6 import java.io.PrintStream;
8 import dol.datamodel.pn.ProcessNetwork;
9 import dol.visitor.PNVisitor;
12 * This class is a class for a visitor that is used to generate
13 * a SystemC package Makefile.
15 public class MakefileVisitor extends PNVisitor {
20 * @param dir path of the Makefile
22 public MakefileVisitor(String dir) {
27 * Create a Makefile for the given process network.
29 * @param x process network that needs to be rendered.
31 public void visitComponent(ProcessNetwork x) {
33 String filename = _dir + _delimiter + "Makefile";
34 OutputStream file = new FileOutputStream(filename);
35 PrintStream ps = new PrintStream(file);
37 ps.println("CXX = g++");
38 ps.println("CC = g++");
40 ps.println("SYSTEMC_INC = -I" + _ui.getSystemCINC());
41 ps.println("SYSTEMC_LIB = " + _ui.getSystemCLIB());
42 ps.println("MY_LIB_INC = -Ilib -Isc_wrappers -Iprocesses");
43 ps.println("VPATH = lib:sc_wrappers:processes");
45 ps.println("CXXFLAGS = -g -O0 -D__DOL_ETHZ_GEN__ $(SYSTEMC_INC) $(MY_LIB_INC)");
46 ps.println("CFLAGS = $(CXXFLAGS)");
49 ps.print("PROCESS_OBJS = dol.o ");
50 for (String basename : x.getProcessBasenames()) {
51 ps.print(basename + "_wrapper.o ");
55 ps.println("all:" + _name);
57 ps.println(_name + ": " + _name + ".o $(PROCESS_OBJS)");
58 ps.println("\t$(CXX) $(CXXFLAGS) -o $@ $^ $(SYSTEMC_LIB)");
60 ps.println("\t-rm -f *.o core core.* *.core " + _name);
62 } catch (Exception e) {
63 System.out.println(" SystemC Makefile Visitor: exception " +
64 "occured: " + e.getMessage());
70 protected String _dir = null;
71 protected String _name = "sc_application";