1 | # |
---|
2 | # $Id: Makefile 113 2009-04-14 18:39:12Z rosiere $ |
---|
3 | # |
---|
4 | # [ Description ] |
---|
5 | # |
---|
6 | # Makefile |
---|
7 | # |
---|
8 | |
---|
9 | #---------------------------------------------------------- |
---|
10 | #---------------------------------------------------------- |
---|
11 | #-----[ Environment ]-------------------------------------- |
---|
12 | #---------------------------------------------------------- |
---|
13 | #---------------------------------------------------------- |
---|
14 | ifeq ($(origin MORPHEO_TOPLEVEL), undefined) |
---|
15 | $(error "variable MORPHEO_TOPLEVEL is undefined") |
---|
16 | else |
---|
17 | include $(MORPHEO_TOPLEVEL)/Makefile.tools |
---|
18 | include $(MORPHEO_TOPLEVEL)/Makefile.flags |
---|
19 | endif |
---|
20 | |
---|
21 | ifeq ($(origin MORPHEO_TMP), undefined) |
---|
22 | $(error "variable MORPHEO_TMP is undefined") |
---|
23 | endif |
---|
24 | |
---|
25 | #---------------------------------------------------------- |
---|
26 | #---------------------------------------------------------- |
---|
27 | #-----[ Directory ]---------------------------------------- |
---|
28 | #---------------------------------------------------------- |
---|
29 | #---------------------------------------------------------- |
---|
30 | ENTITY = Test |
---|
31 | SIMULATOR = modelsim |
---|
32 | |
---|
33 | DIR_TMP = $(MORPHEO_TMP) |
---|
34 | DIR_INC = include |
---|
35 | DIR_SRC = src |
---|
36 | DIR_OBJ = $(DIR_TMP)/obj |
---|
37 | DIR_LIB = $(DIR_TMP)/lib |
---|
38 | DIR_BIN = $(DIR_TMP)/bin |
---|
39 | DIR_LOG = $(DIR_TMP)/log |
---|
40 | DIR_DATA_TEST = ./data_test |
---|
41 | DIR_DATA_BENCH = ./data_bench |
---|
42 | DIR_SOFT = $(MORPHEO_TOPLEVEL)/Softwares |
---|
43 | |
---|
44 | #MORPHEO - define in $(MORPHEO_TOPLEVEL)/IPs/systemC/processor/Morpheo/Makefile.deps |
---|
45 | #MORPHEO_DIR - define in $(MORPHEO_TOPLEVEL)/IPs/systemC/processor/Morpheo/Makefile.deps |
---|
46 | #MORPHEO_INCDIR - define in $(MORPHEO_TOPLEVEL)/IPs/systemC/processor/Morpheo/Makefile.deps |
---|
47 | #MORPHEO_LIBDIR - define in $(MORPHEO_TOPLEVEL)/IPs/systemC/processor/Morpheo/Makefile.deps |
---|
48 | #MORPHEO_LIBNAME - define in $(MORPHEO_TOPLEVEL)/IPs/systemC/processor/Morpheo/Makefile.deps |
---|
49 | |
---|
50 | #ENVIRONMENT_DIR - define in $(MORPHEO_TOPLEVEL)/IPs/systemC/Environment/Makefile.deps |
---|
51 | #ENVIRONMENT_INCDIR - define in $(MORPHEO_TOPLEVEL)/IPs/systemC/Environment/Makefile.deps |
---|
52 | #ENVIRONMENT_LIBDIR - define in $(MORPHEO_TOPLEVEL)/IPs/systemC/Environment/Makefile.deps |
---|
53 | #ENVIRONMENT_LIBNAME - define in $(MORPHEO_TOPLEVEL)/IPs/systemC/Environment/Makefile.deps |
---|
54 | |
---|
55 | #---------------------------------------------------------- |
---|
56 | #---------------------------------------------------------- |
---|
57 | #-----[ Variables ]---------------------------------------- |
---|
58 | #---------------------------------------------------------- |
---|
59 | #---------------------------------------------------------- |
---|
60 | |
---|
61 | SOURCES = $(wildcard $(DIR_SRC)/*.cpp) |
---|
62 | OBJECTS = $(patsubst $(DIR_SRC)/%.cpp,$(DIR_OBJ)/%.o,$(SOURCES)) |
---|
63 | LOGS = $(patsubst $(DIR_DATA_TEST)/%.cfg,$(DIR_LOG)/%.log,$(wildcard $(DIR_DATA_TEST)/*.cfg)) |
---|
64 | BENCHS = $(patsubst $(DIR_DATA_BENCH)/%.cfg,$(DIR_LOG)/%.log,$(wildcard $(DIR_DATA_BENCH)/*.cfg)) |
---|
65 | DEBUG_CFG = $(DIR_DATA_TEST)/debug.cfg |
---|
66 | DEBUG_LOG = $(DIR_LOG)/debug.log |
---|
67 | |
---|
68 | EXEC = $(DIR_BIN)/soft.x |
---|
69 | EXEC_PREFIX = |
---|
70 | #$(VALGRIND) |
---|
71 | |
---|
72 | #-----[ Compilation ]-------------------------------------- |
---|
73 | INCDIR = $(SYSTEMC_INCDIR_$(SIMULATOR)) \ |
---|
74 | $(MORPHEO_INCDIR) \ |
---|
75 | $(ENVIRONMENT_INCDIR) \ |
---|
76 | -I$(DIR_INC) |
---|
77 | |
---|
78 | #LIBDIR = $(SYSTEMC_LIBDIR_$(SIMULATOR)) \ |
---|
79 | # $(ENVIRONMENT_LIBDIR) \ |
---|
80 | # $(MORPHEO_LIBDIR) |
---|
81 | |
---|
82 | # FIXME !!! |
---|
83 | LIBDIR = $(SYSTEMC_LIBDIR_$(SIMULATOR)) \ |
---|
84 | -L$(DIR_LIB) |
---|
85 | |
---|
86 | LIBNAME = $(ENVIRONMENT_LIBNAME) \ |
---|
87 | $(MORPHEO_LIBNAME) \ |
---|
88 | $(SYSTEMC_LIBNAME_$(SIMULATOR)) |
---|
89 | |
---|
90 | FLAGS = $(SYSTEMC_CFLAGS_$(SIMULATOR)) |
---|
91 | |
---|
92 | PLATFORMS_CXX_FLAGS = $(MORPHEO_FLAGS) $(CXX_FLAGS) $(FLAGS) $(INCDIR) |
---|
93 | PLATFORMS_L_FLAGS = $(MORPHEO_FLAGS) $(CXX_FLAGS) $(FLAGS) $(LIBDIR) |
---|
94 | |
---|
95 | #---------------------------------------------------------- |
---|
96 | #---------------------------------------------------------- |
---|
97 | #-----[ Rules ]-------------------------------------------- |
---|
98 | #---------------------------------------------------------- |
---|
99 | #---------------------------------------------------------- |
---|
100 | |
---|
101 | vpath %.h $(DIR_INC) |
---|
102 | vpath %.cpp $(DIR_SRC) |
---|
103 | vpath %.o $(DIR_OBJ) |
---|
104 | vpath %.cfg $(DIR_DATA_TEST) $(DIR_DATA_BENCH) |
---|
105 | |
---|
106 | .PRECIOUS : $(DIR_OBJ)/%.o $(DIR_BIN)/%.x $(DIR_LOG)/%.log |
---|
107 | |
---|
108 | all : $(EXEC) |
---|
109 | |
---|
110 | $(DIR_BIN)/%.x : $(DIR_OBJ) $(DIR_BIN) |
---|
111 | @\ |
---|
112 | $(ECHO) "Linkage : $*";\ |
---|
113 | case "${SIMULATOR}" in \ |
---|
114 | "modelsim") \ |
---|
115 | $(MAKE) $(WORK_NAME); \ |
---|
116 | $(MODELTECH_SCCOM) $(PLATFORMS_CXX_FLAGS) $(SOURCES); \ |
---|
117 | $(MODELTECH_SCCOM) -link $(PLATFORMS_L_FLAGS) $(LIBNAME); \ |
---|
118 | $(ECHO) "#!$(SHELL)" > $@; \ |
---|
119 | $(ECHO) "cd $${PWD};" >> $@; \ |
---|
120 | $(ECHO) "$(MODELTECH_VSIM) -sc_arg "'"$${*}"'" $(WORK_NAME).top;" >> $@;\ |
---|
121 | $(ECHO) "cd -;" >> $@; \ |
---|
122 | $(CHMOD) +x $@; \ |
---|
123 | ;; \ |
---|
124 | *) \ |
---|
125 | $(MAKE) $(OBJECTS); \ |
---|
126 | $(CXX) $(PLATFORMS_L_FLAGS) -o $@ $(OBJECTS) $(LIBNAME); \ |
---|
127 | ;; \ |
---|
128 | esac; \ |
---|
129 | |
---|
130 | |
---|
131 | test : $(DIR_LOG) all |
---|
132 | @\ |
---|
133 | declare logs; \ |
---|
134 | if $(TEST) -f "$(DEBUG_CFG)"; then \ |
---|
135 | logs="$(DEBUG_LOG)"; \ |
---|
136 | else \ |
---|
137 | logs="$(LOGS)"; \ |
---|
138 | fi; \ |
---|
139 | $(MAKE) $$logs; \ |
---|
140 | declare -i nb_test=0; \ |
---|
141 | declare -i nb_test_ko=0; \ |
---|
142 | for log in $$logs; do \ |
---|
143 | $(GREP) -q "Test OK" $$log; \ |
---|
144 | declare -i test_ok=$$?; \ |
---|
145 | $(GREP) -q "Test KO" $$log; \ |
---|
146 | declare -i test_ko=$$?; \ |
---|
147 | if $(TEST) $$test_ko -eq 0 -o $$test_ok -ne 0; \ |
---|
148 | then nb_test_ko=$$(($${nb_test_ko} + 1)); \ |
---|
149 | fi; \ |
---|
150 | nb_test=$$(($${nb_test} + 1)); \ |
---|
151 | done; \ |
---|
152 | if $(TEST) $${nb_test_ko} -ne 0; \ |
---|
153 | then $(ECHO) "-------------------| Test KO !!! ($${nb_test_ko}/$${nb_test})"; exit 1; \ |
---|
154 | else $(ECHO) "-------------------| Test OK"; exit 0; \ |
---|
155 | fi; |
---|
156 | |
---|
157 | bench : $(DIR_LOG) all |
---|
158 | @\ |
---|
159 | declare logs="$(BENCHS)"; \ |
---|
160 | $(MAKE) $$logs; |
---|
161 | |
---|
162 | execute : bench |
---|
163 | |
---|
164 | # $(ECHO) $${data} | $(EXEC_PREFIX) $(EXEC) &> $$log; \ |
---|
165 | |
---|
166 | $(DIR_LOG)/%.log : %.cfg |
---|
167 | @\ |
---|
168 | file=$$($(BASENAME) $<); \ |
---|
169 | data=$$($(CAT) $<); \ |
---|
170 | log=$@; \ |
---|
171 | $(ECHO) "Run : $$file"; \ |
---|
172 | $(EXEC_PREFIX) $(EXEC) $${data} &> $$log; \ |
---|
173 | $(GREP) -q "Test OK" $$log; \ |
---|
174 | declare -i test_ok=$$?; \ |
---|
175 | $(GREP) -q "Test KO" $$log; \ |
---|
176 | declare -i test_ko=$$?; \ |
---|
177 | declare timing=$$($(GREP) -h "Timing" $$log); \ |
---|
178 | if $(TEST) $$test_ko -ne 0 -a $$test_ok -eq 0; \ |
---|
179 | then $(ECHO) -e " $$file ... OK \t$$timing"; \ |
---|
180 | else $(ECHO) -e " $$file ... KO !!!\t$$timing"; \ |
---|
181 | fi; \ |
---|
182 | |
---|
183 | #-----[ Library + Software ]------------------------------- |
---|
184 | |
---|
185 | lib : |
---|
186 | @\ |
---|
187 | $(MAKE) --directory=$(ENVIRONMENT_DIR) --makefile=Makefile;\ |
---|
188 | $(MAKE) --directory=$(MORPHEO_DIR) --makefile=Makefile; |
---|
189 | |
---|
190 | soft : |
---|
191 | @\ |
---|
192 | $(MAKE) --directory=$(DIR_SOFT) --makefile=Makefile; |
---|
193 | |
---|
194 | #-----[ Rules ]-------------------------------------------- |
---|
195 | |
---|
196 | $(DIR_OBJ)/%.o : %.cpp |
---|
197 | @\ |
---|
198 | $(ECHO) "Compilation : $*";\ |
---|
199 | $(CXX) $(PLATFORMS_CXX_FLAGS) -c -o $@ $<; |
---|
200 | |
---|
201 | $(DIR_OBJ) $(DIR_BIN) $(DIR_LOG) : |
---|
202 | @\ |
---|
203 | $(ECHO) "Create directory : $@";\ |
---|
204 | $(MKDIR) $@ |
---|
205 | |
---|
206 | #-----[ Clean + help ]------------------------------------- |
---|
207 | |
---|
208 | clean : |
---|
209 | @\ |
---|
210 | $(ECHO) "Delete temporary files in directory $(PWD)";\ |
---|
211 | $(RM) $(OBJECTS) $(EXEC) \ |
---|
212 | *~ $(DIR_SRC)/*~ $(DIR_INC)/*~ $(DIR_DATA_TEST)/*~ $(DIR_DATA_BENCH)/*~ \ |
---|
213 | *core* \ |
---|
214 | tty* \ |
---|
215 | *.vhdl \ |
---|
216 | *.log \ |
---|
217 | *.stat \ |
---|
218 | *.pos \ |
---|
219 | modelsim.ini transcript *wlf* $(WORK_NAME) |
---|
220 | |
---|
221 | clean_all : clean |
---|
222 | @\ |
---|
223 | $(ECHO) "Delete generated files in directory $(PWD)";\ |
---|
224 | $(RM) $(DIR_OBJ) $(DIR_BIN) $(DIR_LOG);\ |
---|
225 | $(MAKE) --directory=$(DIR_SOFT) --makefile=Makefile clean_all; \ |
---|
226 | $(MAKE) --directory=$(ENVIRONMENT_DIR) --makefile=Makefile clean_all; \ |
---|
227 | $(MAKE) --directory=$(MORPHEO_DIR) --makefile=Makefile clean_all; |
---|
228 | |
---|
229 | |
---|
230 | help : |
---|
231 | @\ |
---|
232 | $(ECHO) " -----[ Common ]-------------------------------------";\ |
---|
233 | $(ECHO) "";\ |
---|
234 | $(ECHO) " * all (default rules) : create software";\ |
---|
235 | $(ECHO) " * test : execute platforms with test configuration";\ |
---|
236 | $(ECHO) " * bench : execute platforms with bench configuration";\ |
---|
237 | $(ECHO) " * lib : make library";\ |
---|
238 | $(ECHO) " * soft : make software";\ |
---|
239 | $(ECHO) " * execute : cf 'make bench'";\ |
---|
240 | $(ECHO) " * clean : erase temporary files";\ |
---|
241 | $(ECHO) " * clean_all : erase generated files";\ |
---|
242 | $(ECHO) " * help : print this message";\ |
---|
243 | $(ECHO) ""; |
---|
244 | |
---|
245 | include $(MORPHEO_TOPLEVEL)/IPs/systemC/processor/Morpheo/Behavioural/Makefile.Synthesis |
---|
246 | include $(MORPHEO_TOPLEVEL)/IPs/systemC/processor/Morpheo/Makefile.deps |
---|
247 | include $(MORPHEO_TOPLEVEL)/IPs/systemC/Environment/Makefile.deps |
---|