8a25551266f1a09ce721f7db197e1422bbf5ba6b
[jump.git] / Makefile
1 # Makefile to generate a DOL program
2
3 # Type 'make help' to get a list of targets.
4
5 # program to generate
6 PROGRAM = AESA
7
8 # code generator to use
9 # use '-C' (SystemC) or '-H' (HdS)
10 CODEGEN = -C
11
12 # change according to your system
13 DOLPATH     = $(HOME)/jump/dol/jars
14 SYSTEMC_INC = $(HOME)/systemc/include
15 SYSTEMC_LIB = $(HOME)/systemc/lib-linux64/libsystemc.a
16
17 # list of programs
18 JAVA    ?= java
19 JAVAC   ?= javac
20 DOTTY   ?= dotty
21 ECHO    ?= echo
22 SED     ?= sed
23 CP      ?= cp
24 RM      ?= rm
25
26 # don't change anything below
27 # ===========================================================================
28
29 SRCPATH   = generated
30 CLASSPATH = $(DOLPATH)/dol.jar:$(DOLPATH)/jdom.jar:$(DOLPATH)/xercesImpl.jar
31 .PHONY : help all run codegen dotty clean
32
33 help:
34         @$(ECHO) "Target List:\n" \
35                 "\thelp    -- show this help [default]\n" \
36                 "\tall     -- generate '$(PROGRAM)'\n" \
37                 "\trun     -- generate and run '$(PROGRAM)'\n" \
38                 "\tcodegen -- generate code, but do not compile\n" \
39                 "\tdotty   -- show flattened process network using DOTTY\n" \
40                 "\tclean   -- clean generated files\n"
41
42 all: $(PROGRAM)
43
44 codegen: $(SRCPATH)/src/Makefile.new
45
46 run: $(PROGRAM)
47         @$(ECHO) "\t[RUN]\t$^"
48         @./$(PROGRAM)
49
50 clean:
51         @$(ECHO) "\t[CLEAN]"
52         @$(RM) -rf $(PROGRAM) $(SRCPATH)/ $(PROGRAM)_flattened.xml \
53                 $(PROGRAM)_Generator.java $(PROGRAM)_Generator.class \
54                 $(PROGRAM).dot profile.txt output.txt
55
56 $(PROGRAM): $(SRCPATH)/src/sc_application
57         @$(ECHO) "\t[COPY]\t$@"
58         @$(CP) $^ $@
59
60 $(SRCPATH)/src/sc_application: $(SRCPATH)/src/Makefile.new
61         @$(ECHO) "\t[MAKE]\t$<"
62         @$(MAKE) -f Makefile.new -C $(SRCPATH)/src
63
64 $(SRCPATH)/src/Makefile.new: $(SRCPATH)/src/Makefile
65         @$(ECHO) "\t[GEN]\t$@"
66         @$(SED) -e 's@^SYSTEMC_INC.*@SYSTEMC_INC = -I$(SYSTEMC_INC)@' \
67                 -e 's@^SYSTEMC_LIB.*@SYSTEMC_LIB = $(SYSTEMC_LIB)@' \
68                 -e 's@^MY_LIB_INC.*@& -lpthread@' \
69                 $(SRCPATH)/src/Makefile > $(SRCPATH)/src/Makefile.new
70
71 $(SRCPATH)/src/Makefile: $(PROGRAM)_flattened.xml
72         @$(ECHO) "\t[GEN]\t$@"
73         @$(JAVA) -cp $(CLASSPATH) dol.main.Main -P $(PROGRAM)_flattened.xml \
74                 $(CODEGEN) $(SRCPATH) -c >/dev/null
75
76 $(PROGRAM)_flattened.xml: $(PROGRAM).xml
77         @$(ECHO) "\t[FLAT]\t$^"
78         @$(JAVA) -cp $(CLASSPATH) dol.helper.flattener.XMLFlattener \
79                 $(PROGRAM).xml $(PROGRAM)_Generator >/dev/null
80         @$(JAVAC) $(PROGRAM)_Generator.java
81         @$(JAVA) $(PROGRAM)_Generator > $(PROGRAM)_flattened.xml
82
83 $(PROGRAM).dot: $(PROGRAM)_flattened.xml
84         @$(ECHO) "\t[GEN]\t$@"
85         @$(JAVA) -cp $(CLASSPATH) dol.main.Main -P $(PROGRAM)_flattened.xml \
86                 -D $(PROGRAM).dot -c >/dev/null
87
88 dotty: $(PROGRAM).dot
89         @$(ECHO) "\t[RUN]\t$(DOTTY) $(PROGRAM).dot"
90         @$(DOTTY) $(PROGRAM).dot
91