--- /dev/null
+/* $Id: HdsMakefileVisitor.java 1 2010-02-24 13:03:05Z haidw $ */
+package dol.visitor.hds;
+
+import java.io.FileOutputStream;
+import java.io.OutputStream;
+import java.io.PrintStream;
+
+import dol.datamodel.pn.ProcessNetwork;
+import dol.datamodel.pn.Configuration;
+import dol.visitor.PNVisitor;
+
+/**
+ * This class is a class for a visitor that is used to generate
+ * a HdS package Makefile.
+ */
+public class HdsMakefileVisitor extends PNVisitor {
+
+ /**
+ * Constructor.
+ *
+ * @param dir path of the Makefile
+ */
+ public HdsMakefileVisitor(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("PREPROC_MACROS = -D__DOL_ETHZ_GEN__ "
+ + " -DINCLUDE_PROFILER #-DINCLUDE_PERFORMANCE"
+ + " #-DINCLUDE_TRACE");
+ 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 -Wall $(PREPROC_MACROS) "
+ + "$(SYSTEMC_INC) $(MY_LIB_INC)");
+ ps.println("CFLAGS = $(CXXFLAGS)");
+ ps.println();
+
+ ps.print("PROCESS_OBJS = dolSupport.o ProcessWrapper.o "
+ + "Fifo.o WindowedFifo.o ");
+
+ for (String basename : x.getProcessBasenames()) {
+ ps.print(basename + "_wrapper.o ");
+ }
+
+ for (Configuration conf : x.getCfgList()) {
+ if (conf.getName().equals("EXTERNAL_SRC")) {
+ ps.print(conf.getValue() + " ");
+ }
+ }
+
+ ps.println("#xmlParser.o Performance_Extraction.o "
+ + "functional_trace.o");
+ ps.println();
+ ps.println("all:" + _name);
+ ps.println();
+ ps.println(_name + ": " + _name + ".o $(PROCESS_OBJS)");
+ ps.print("\t$(CXX) $(CXXFLAGS) -o $@ $^ $(SYSTEMC_LIB) ");
+ for (Configuration conf : x.getCfgList()) {
+ if (conf.getName().equals("DYNAMIC_LINK"))
+ ps.print(conf.getValue() + " ");
+ }
+ ps.println("# -lpthread -lX11 -lrt");
+ ps.println("clean:");
+ ps.println("\t-rm -f *.o core core.* *.core *.tga "
+ + "static_characterization.xml " + _name);
+
+ } catch (Exception e) {
+ System.out.println("HdsMakefileVisitor: exception occured: "
+ + e.getMessage());
+ e.printStackTrace();
+ }
+ }
+
+ protected String _dir = null;
+ protected String _name = "sc_application";
+}