1 /* $Id: HdsMakefileVisitor.java 1 2010-02-24 13:03:05Z haidw $ */
2 package dol.visitor.hds;
4 import java.io.FileOutputStream;
5 import java.io.OutputStream;
6 import java.io.PrintStream;
8 import dol.datamodel.pn.ProcessNetwork;
9 import dol.datamodel.pn.Configuration;
10 import dol.visitor.PNVisitor;
13 * This class is a class for a visitor that is used to generate
14 * a HdS package Makefile.
16 public class HdsMakefileVisitor extends PNVisitor {
21 * @param dir path of the Makefile
23 public HdsMakefileVisitor(String dir) {
28 * Create a Makefile for the given process network.
30 * @param x process network that needs to be rendered.
32 public void visitComponent(ProcessNetwork x) {
34 String filename = _dir + _delimiter + "Makefile";
35 OutputStream file = new FileOutputStream(filename);
36 PrintStream ps = new PrintStream(file);
38 ps.println("CXX = g++");
39 ps.println("CC = g++");
41 ps.println("PREPROC_MACROS = -D__DOL_ETHZ_GEN__ "
42 + " -DINCLUDE_PROFILER #-DINCLUDE_PERFORMANCE"
43 + " #-DINCLUDE_TRACE");
45 ps.println("SYSTEMC_INC = -I" + _ui.getSystemCINC());
46 ps.println("SYSTEMC_LIB = " + _ui.getSystemCLIB());
47 ps.println("MY_LIB_INC = -Ilib -Isc_wrappers -Iprocesses");
48 ps.println("VPATH = lib:sc_wrappers:processes");
50 ps.println("CXXFLAGS = -g -O0 -Wall $(PREPROC_MACROS) "
51 + "$(SYSTEMC_INC) $(MY_LIB_INC)");
52 ps.println("CFLAGS = $(CXXFLAGS)");
55 ps.print("PROCESS_OBJS = dolSupport.o ProcessWrapper.o "
56 + "Fifo.o WindowedFifo.o ");
58 for (String basename : x.getProcessBasenames()) {
59 ps.print(basename + "_wrapper.o ");
62 for (Configuration conf : x.getCfgList()) {
63 if (conf.getName().equals("EXTERNAL_SRC")) {
64 ps.print(conf.getValue() + " ");
68 ps.println("#xmlParser.o Performance_Extraction.o "
69 + "functional_trace.o");
71 ps.println("all:" + _name);
73 ps.println(_name + ": " + _name + ".o $(PROCESS_OBJS)");
74 ps.print("\t$(CXX) $(CXXFLAGS) -o $@ $^ $(SYSTEMC_LIB) ");
75 for (Configuration conf : x.getCfgList()) {
76 if (conf.getName().equals("DYNAMIC_LINK"))
77 ps.print(conf.getValue() + " ");
79 ps.println("# -lpthread -lX11 -lrt");
81 ps.println("\t-rm -f *.o core core.* *.core *.tga "
82 + "static_characterization.xml " + _name);
84 } catch (Exception e) {
85 System.out.println("HdsMakefileVisitor: exception occured: "
91 protected String _dir = null;
92 protected String _name = "sc_application";