1 | |
---|
2 | # |
---|
3 | # $Id: Makefile 146 2011-02-01 20:57:54Z rosiere $ |
---|
4 | # |
---|
5 | # [ Description ] |
---|
6 | # |
---|
7 | # Makefile |
---|
8 | # |
---|
9 | |
---|
10 | #---------------------------------------------------------- |
---|
11 | #---------------------------------------------------------- |
---|
12 | #-----[ Environment ]-------------------------------------- |
---|
13 | #---------------------------------------------------------- |
---|
14 | #---------------------------------------------------------- |
---|
15 | ifeq ($(origin MORPHEO_TOPLEVEL), undefined) |
---|
16 | $(error "variable MORPHEO_TOPLEVEL is undefined") |
---|
17 | else |
---|
18 | include $(MORPHEO_TOPLEVEL)/Makefile.tools |
---|
19 | include $(MORPHEO_TOPLEVEL)/Makefile.flags |
---|
20 | endif |
---|
21 | |
---|
22 | ifeq ($(origin MORPHEO_TMP), undefined) |
---|
23 | $(error "variable MORPHEO_TMP is undefined") |
---|
24 | endif |
---|
25 | ifeq ($(origin MORPHEO_PREFIX), undefined) |
---|
26 | $(error "variable MORPHEO_PREFIX is undefined") |
---|
27 | endif |
---|
28 | |
---|
29 | DATA_ALL = * |
---|
30 | ifeq ($(origin DATA), undefined) |
---|
31 | DATA = $(DATA_ALL) |
---|
32 | endif |
---|
33 | ifeq ($(origin PRIORITY), undefined) |
---|
34 | PRIORITY = 0 |
---|
35 | endif |
---|
36 | ifeq ($(flavor CLEAN), undefined) |
---|
37 | CLEAN = 0 |
---|
38 | endif |
---|
39 | |
---|
40 | #---------------------------------------------------------- |
---|
41 | #---------------------------------------------------------- |
---|
42 | #-----[ Directory ]---------------------------------------- |
---|
43 | #---------------------------------------------------------- |
---|
44 | #---------------------------------------------------------- |
---|
45 | ENTITY = Test |
---|
46 | |
---|
47 | PATH_INC = include |
---|
48 | PATH_SRC = src |
---|
49 | PATH_OBJ = $(MORPHEO_TMP)/obj/$(MORPHEO_TYPE) |
---|
50 | PATH_LIB = $(MORPHEO_PREFIX)/lib/$(MORPHEO_TYPE) |
---|
51 | PATH_BIN = $(MORPHEO_PREFIX)/bin/$(MORPHEO_TYPE) |
---|
52 | PATH_LOG = $(MORPHEO_TMP)/log |
---|
53 | PATH_GMON = $(MORPHEO_TMP)/gmon |
---|
54 | PATH_DATA = ./data |
---|
55 | PATH_DATA_CFG = $(PATH_DATA)/cfg |
---|
56 | PATH_LOGS = $(patsubst $(PATH_DATA)/%,$(PATH_LOG)/%,$(wildcard $(PATH_DATA)/*)) |
---|
57 | PATH_CFG_SUFFIX = IPs/systemC/processor/Morpheo/Files |
---|
58 | PATH_CFG = $(MORPHEO_TOPLEVEL)/$(PATH_CFG_SUFFIX) |
---|
59 | |
---|
60 | PATH_SOFT = $(MORPHEO_TOPLEVEL)/Softwares |
---|
61 | |
---|
62 | #MORPHEO - define in $(MORPHEO_TOPLEVEL)/IPs/systemC/processor/Morpheo/Makefile.deps |
---|
63 | #MORPHEO_DIR - define in $(MORPHEO_TOPLEVEL)/IPs/systemC/processor/Morpheo/Makefile.deps |
---|
64 | #MORPHEO_INCDIR - define in $(MORPHEO_TOPLEVEL)/IPs/systemC/processor/Morpheo/Makefile.deps |
---|
65 | #MORPHEO_LIBDIR - define in $(MORPHEO_TOPLEVEL)/IPs/systemC/processor/Morpheo/Makefile.deps |
---|
66 | #MORPHEO_LIBNAME - define in $(MORPHEO_TOPLEVEL)/IPs/systemC/processor/Morpheo/Makefile.deps |
---|
67 | |
---|
68 | #ENVIRONMENT_DIR - define in $(MORPHEO_TOPLEVEL)/IPs/systemC/Environment/Makefile.deps |
---|
69 | #ENVIRONMENT_INCDIR - define in $(MORPHEO_TOPLEVEL)/IPs/systemC/Environment/Makefile.deps |
---|
70 | #ENVIRONMENT_LIBDIR - define in $(MORPHEO_TOPLEVEL)/IPs/systemC/Environment/Makefile.deps |
---|
71 | #ENVIRONMENT_LIBNAME - define in $(MORPHEO_TOPLEVEL)/IPs/systemC/Environment/Makefile.deps |
---|
72 | |
---|
73 | #---------------------------------------------------------- |
---|
74 | #---------------------------------------------------------- |
---|
75 | #-----[ Variables ]---------------------------------------- |
---|
76 | #---------------------------------------------------------- |
---|
77 | #---------------------------------------------------------- |
---|
78 | SOURCES = $(wildcard $(PATH_SRC)/*.cpp) |
---|
79 | OBJECTS = $(patsubst $(PATH_SRC)/%.cpp,$(PATH_OBJ)/%.o,$(SOURCES)) |
---|
80 | LOGS = $(patsubst $(PATH_DATA)/%.cfg,$(PATH_LOG)/%.log,$(wildcard $(PATH_DATA)/$(DATA)/*.cfg)) |
---|
81 | |
---|
82 | BIN = Platforms_Test.x |
---|
83 | EXEC = $(PATH_BIN)/$(BIN) |
---|
84 | EXEC_PREFIX = $(NICE) -n $(PRIORITY) |
---|
85 | #$(VALGRIND) |
---|
86 | EXEC_PARAMS = $(SYSTEMC_EXEC_PARAMS_$(SIMULATOR_SYSTEMC)) |
---|
87 | |
---|
88 | SCRIPT = make.sh |
---|
89 | |
---|
90 | #-----[ Compilation ]-------------------------------------- |
---|
91 | INCDIR = $(SYSTEMC_INCDIR_$(SIMULATOR_SYSTEMC)) \ |
---|
92 | $(MORPHEO_INCDIR) \ |
---|
93 | $(ENVIRONMENT_INCDIR) \ |
---|
94 | -I$(PATH_INC) |
---|
95 | |
---|
96 | #LIBDIR = $(SYSTEMC_LIBDIR_$(SIMULATOR_SYSTEMC)) \ |
---|
97 | # $(ENVIRONMENT_LIBDIR) \ |
---|
98 | # $(MORPHEO_LIBDIR) |
---|
99 | |
---|
100 | LIBDIR = $(SYSTEMC_LIBDIR_$(SIMULATOR_SYSTEMC)) \ |
---|
101 | -L$(PATH_LIB) |
---|
102 | |
---|
103 | LIBNAME = $(ENVIRONMENT_LIBNAME) \ |
---|
104 | $(MORPHEO_LIBNAME) \ |
---|
105 | $(SYSTEMC_LIBNAME_$(SIMULATOR_SYSTEMC)) |
---|
106 | |
---|
107 | FLAGS = $(SYSTEMC_CFLAGS_$(SIMULATOR_SYSTEMC)) |
---|
108 | |
---|
109 | PLATFORMS_CXX_FLAGS = $(MORPHEO_FLAGS) $(CXX_FLAGS) $(FLAGS) $(INCDIR) |
---|
110 | PLATFORMS_L_FLAGS = $(MORPHEO_FLAGS) $(CXX_FLAGS) $(FLAGS) $(LIBDIR) |
---|
111 | |
---|
112 | #---------------------------------------------------------- |
---|
113 | #---------------------------------------------------------- |
---|
114 | #-----[ Rules ]-------------------------------------------- |
---|
115 | #---------------------------------------------------------- |
---|
116 | #---------------------------------------------------------- |
---|
117 | |
---|
118 | vpath %.h $(PATH_INC) |
---|
119 | vpath %.cpp $(PATH_SRC) |
---|
120 | vpath %.o $(PATH_OBJ) |
---|
121 | vpath %.cfg $(PATH_DATA)/*/ |
---|
122 | |
---|
123 | .PRECIOUS : $(PATH_OBJ)/%.o $(PATH_BIN)/%.x $(PATH_LOG)/%.log |
---|
124 | |
---|
125 | all : $(EXEC) |
---|
126 | |
---|
127 | $(PATH_BIN)/%.x : $(PATH_OBJ) $(PATH_BIN) |
---|
128 | @\ |
---|
129 | case "${SIMULATOR_SYSTEMC}" in \ |
---|
130 | "modelsim") \ |
---|
131 | $(MAKE) $(WORK_NAME); \ |
---|
132 | $(MODELTECH_SCCOM) $(PLATFORMS_CXX_FLAGS) $(SOURCES); \ |
---|
133 | $(MODELTECH_SCCOM) -link $(PLATFORMS_L_FLAGS) $(LIBNAME); \ |
---|
134 | $(ECHO) "#!$(SHELL)" > $@; \ |
---|
135 | $(ECHO) "cd $${PWD};" >> $@; \ |
---|
136 | $(ECHO) "$(MODELTECH_VSIM) -sc_arg "'"$${*}"'" $(WORK_NAME).top;" >> $@;\ |
---|
137 | $(ECHO) "cd -;" >> $@; \ |
---|
138 | $(CHMOD) +x $@; \ |
---|
139 | ;; \ |
---|
140 | *) \ |
---|
141 | $(MAKE) $(OBJECTS); \ |
---|
142 | $(ECHO) "Linkage : $*"; \ |
---|
143 | $(CXX) $(PLATFORMS_L_FLAGS) -o $@ $(OBJECTS) $(LIBNAME); \ |
---|
144 | ;; \ |
---|
145 | esac; \ |
---|
146 | |
---|
147 | run : |
---|
148 | @\ |
---|
149 | declare -i clean=$(CLEAN); \ |
---|
150 | if $(TEST) $${clean} -ne 0 -a "$(DATA)" != "$(DATA_ALL)"; then \ |
---|
151 | $(RM) $(PATH_LOG)/$(DATA); \ |
---|
152 | fi; \ |
---|
153 | declare -a logs=($(LOGS)); \ |
---|
154 | declare -i nb_test=$${#logs[*]}; \ |
---|
155 | $(ECHO) "-------------------| Run $${nb_test} test(s)"; \ |
---|
156 | $(MAKE) $${logs[*]}; \ |
---|
157 | declare -i nb_test_ko=0; \ |
---|
158 | for log in $${logs[*]}; do \ |
---|
159 | $(GREP) -q "Test OK" $$log; \ |
---|
160 | declare -i test_ok=$$?; \ |
---|
161 | $(GREP) -q "Test KO" $$log; \ |
---|
162 | declare -i test_ko=$$?; \ |
---|
163 | if $(TEST) $${test_ko} -eq 0 -o $${test_ok} -ne 0; \ |
---|
164 | then nb_test_ko=$$(($${nb_test_ko} + 1)); \ |
---|
165 | fi; \ |
---|
166 | done; \ |
---|
167 | if $(TEST) $${nb_test_ko} -ne 0; \ |
---|
168 | then $(ECHO) "-------------------| Test KO !!! ($${nb_test_ko}/$${nb_test})"; exit 1; \ |
---|
169 | else $(ECHO) "-------------------| Test OK ($${nb_test})"; exit 0; \ |
---|
170 | fi; |
---|
171 | |
---|
172 | debug : |
---|
173 | @\ |
---|
174 | $(MAKE) run DATA=debug CLEAN=1; |
---|
175 | |
---|
176 | bench : |
---|
177 | @\ |
---|
178 | $(MAKE) run DATA=bench; |
---|
179 | |
---|
180 | distexe : |
---|
181 | @\ |
---|
182 | $(ECHO) -n "Generate : $(SCRIPT) ";\ |
---|
183 | $(RM) $(SCRIPT); \ |
---|
184 | for log in $(LOGS); do \ |
---|
185 | $(ECHO) -n "."; \ |
---|
186 | $(ECHO) -n "source $(MORPHEO_TOPLEVEL)/environment.sh -l $(MORPHEO_LOCALIZATION) -t $(MORPHEO_TYPE); path=\"${PWD}\"; " >> $(SCRIPT);\ |
---|
187 | if $(TEST) $(CLEAN) -ne 0; then \ |
---|
188 | $(ECHO) -n "$(RM) $${log}; " >> $(SCRIPT); \ |
---|
189 | fi; \ |
---|
190 | $(ECHO) "$(MAKE) -C "'$${path}'" $${log} PRIORITY=$(PRIORITY);" >> $(SCRIPT); \ |
---|
191 | done; \ |
---|
192 | $(CHMOD) +x $(SCRIPT); \ |
---|
193 | $(ECHO) " done"; |
---|
194 | |
---|
195 | |
---|
196 | $(PATH_LOG)/%.log : $(PATH_DATA)/%.cfg $(EXEC) $(PATH_LOGS) $(PATH_GMON) |
---|
197 | @\ |
---|
198 | file=$$($(BASENAME) $<); \ |
---|
199 | data=$$(eval echo $$($(CAT) $<)); \ |
---|
200 | log=$@; \ |
---|
201 | $(ECHO) "Run : $*"; \ |
---|
202 | \ |
---|
203 | file_gmon="$$($(BASENAME) $*)-$$($(DATE))"; \ |
---|
204 | dir_gmon="$$($(DIRNAME) $*)"; \ |
---|
205 | $(MKDIR) $(PATH_GMON)/$$dir_gmon; \ |
---|
206 | export GMON_OUT_PREFIX=$(PATH_GMON)/$$dir_gmon/$$file_gmon;\ |
---|
207 | \ |
---|
208 | $(EXEC_PREFIX) $(EXEC) $(EXEC_PARAMS) $${data} &> $$log;\ |
---|
209 | $(GREP) -q "Test OK" $$log; \ |
---|
210 | declare -i test_ok=$$?; \ |
---|
211 | $(GREP) -q "Test KO" $$log; \ |
---|
212 | declare -i test_ko=$$?; \ |
---|
213 | declare timing=$$($(GREP) -h "Timing" $$log); \ |
---|
214 | if $(TEST) $${test_ko} -ne 0 -a $${test_ok} -eq 0; \ |
---|
215 | then test="... OK "; \ |
---|
216 | else test="... KO !!!"; \ |
---|
217 | fi; \ |
---|
218 | $(ECHO) -e " $* $${test}\t$${timing}";\ |
---|
219 | echo "{$$($(date))} $* $${test} $${timing}" >> $$($(DIRNAME) $*).res;\ |
---|
220 | |
---|
221 | cfg : $(PATH_DATA_CFG) |
---|
222 | @\ |
---|
223 | $(ECHO) "Create configuration file"; \ |
---|
224 | for file_cfg in $(PATH_CFG)/*.cfg; do \ |
---|
225 | file_data=$(PATH_DATA_CFG)/$$($(BASENAME) $${file_cfg}); \ |
---|
226 | $(ECHO) " * $${file_data}"; \ |
---|
227 | $(ECHO) '$${MORPHEO_TOPLEVEL}'"/$(PATH_CFG_SUFFIX)/debug.sim" > $${file_data}; \ |
---|
228 | $(ECHO) '$${MORPHEO_TOPLEVEL}'"/$(PATH_CFG_SUFFIX)/Morpheo.gen" >> $${file_data}; \ |
---|
229 | $(ECHO) '$${MORPHEO_TOPLEVEL}'"/$(PATH_CFG_SUFFIX)/$$($(BASENAME) $${file_cfg})" >> $${file_data}; \ |
---|
230 | $(ECHO) '$${MORPHEO_TOPLEVEL}'"/Softwares/Test/Test_x000/bin/soft_NEWLIB_MORPHEO.x" >> $${file_data}; \ |
---|
231 | $(ECHO) "0" >> $${file_data}; \ |
---|
232 | $(ECHO) "0" >> $${file_data}; \ |
---|
233 | $(ECHO) "4096" >> $${file_data}; \ |
---|
234 | $(ECHO) "2" >> $${file_data}; \ |
---|
235 | done; |
---|
236 | |
---|
237 | #-----[ Library + Software ]------------------------------- |
---|
238 | |
---|
239 | env : soft lib |
---|
240 | @$(MAKE) $(EXEC) |
---|
241 | |
---|
242 | env_lib : lib |
---|
243 | @$(MAKE) $(EXEC) |
---|
244 | |
---|
245 | lib : |
---|
246 | @\ |
---|
247 | $(MAKE) --directory=$(ENVIRONMENT_DIR) --makefile=Makefile;\ |
---|
248 | $(MAKE) --directory=$(MORPHEO_DIR) --makefile=Makefile; |
---|
249 | |
---|
250 | soft : |
---|
251 | @\ |
---|
252 | $(MAKE) --directory=$(PATH_SOFT) --makefile=Makefile; |
---|
253 | |
---|
254 | #-----[ Rules ]-------------------------------------------- |
---|
255 | |
---|
256 | $(PATH_OBJ)/%.o : %.cpp |
---|
257 | @\ |
---|
258 | $(ECHO) "Compilation : $*";\ |
---|
259 | $(CXX) $(PLATFORMS_CXX_FLAGS) -c -o $@ $<; |
---|
260 | |
---|
261 | $(PATH_OBJ) $(PATH_BIN) $(PATH_LOGS) $(PATH_GMON) $(PATH_DATA_CFG) : |
---|
262 | @\ |
---|
263 | $(ECHO) "Create directory : $@";\ |
---|
264 | $(MKDIR) $@ |
---|
265 | |
---|
266 | #-----[ Clean + help ]------------------------------------- |
---|
267 | |
---|
268 | clean : |
---|
269 | @\ |
---|
270 | $(ECHO) "Delete temporary files in directory $(PWD)";\ |
---|
271 | $(RM) $(OBJECTS);\ |
---|
272 | $(RM) $(PATH_LOGS); \ |
---|
273 | $(RM) $(PATH_GMON); \ |
---|
274 | $(RM) *~ $(PATH_SRC)/*~ $(PATH_INC)/*~ $(PATH_DATA)/*/*~ *.res *.txt\ |
---|
275 | *core* \ |
---|
276 | tty* \ |
---|
277 | *.vhdl \ |
---|
278 | *.log \ |
---|
279 | *.stat \ |
---|
280 | *.pos \ |
---|
281 | modelsim.ini transcript *wlf* $(WORK_NAME) |
---|
282 | |
---|
283 | clean_all : clean |
---|
284 | @\ |
---|
285 | $(ECHO) "Delete generated files in directory $(PWD)";\ |
---|
286 | $(RM) $(PATH_OBJ) $(PATH_BIN) $(PATH_LOG) $(SCRIPT);\ |
---|
287 | $(MAKE) --directory=$(PATH_SOFT) --makefile=Makefile clean_all; \ |
---|
288 | $(MAKE) --directory=$(ENVIRONMENT_DIR) --makefile=Makefile clean_all; \ |
---|
289 | $(MAKE) --directory=$(MORPHEO_DIR) --makefile=Makefile clean_all; |
---|
290 | |
---|
291 | |
---|
292 | help : |
---|
293 | @\ |
---|
294 | $(ECHO) " -----[ Common ]-------------------------------------";\ |
---|
295 | $(ECHO) "";\ |
---|
296 | $(ECHO) " * all (default rules) : create software";\ |
---|
297 | $(ECHO) " * run : execute platforms with test configuration";\ |
---|
298 | $(ECHO) " set DATA to select a specific directory in $(PATH_DATA) (default : all)";\ |
---|
299 | $(ECHO) " set PRIORITY to nice the execution (default : 0)";\ |
---|
300 | $(ECHO) " set CLEAN to remove previous log (default : 0)";\ |
---|
301 | $(ECHO) " example : make run DATA=debug PRIORITY=10 CLEAN";\ |
---|
302 | $(ECHO) " * debug : cf 'make run DATA=debug'";\ |
---|
303 | $(ECHO) " * bench : cf 'make run DATA=bench'";\ |
---|
304 | $(ECHO) " * distexe : Generate an command file to distexe (\"$(SCRIPT)\").";\ |
---|
305 | $(ECHO) " This file can be use with distexe or just run in local machine.";\ |
---|
306 | $(ECHO) " * cfg : For each configuration in \"${PATH_CFG}\", create basic test";\ |
---|
307 | $(ECHO) " * lib : make library";\ |
---|
308 | $(ECHO) " * soft : make software";\ |
---|
309 | $(ECHO) " * env : execute rule \"lib\" and \"soft\"";\ |
---|
310 | $(ECHO) " * clean : erase temporary files";\ |
---|
311 | $(ECHO) " * clean_all : erase generated files";\ |
---|
312 | $(ECHO) " * help : print this message";\ |
---|
313 | $(ECHO) ""; \ |
---|
314 | $(ECHO) "In the compilation, set MORPHEO_TYPE for set/unset flags"; \ |
---|
315 | $(ECHO) "MORPHEO_TYPE can be set at $(MORPHEO_TYPE_LIST)"; \ |
---|
316 | $(ECHO) "Actual MORPHEO_TYPE is \"$(MORPHEO_TYPE)\""; \ |
---|
317 | $(ECHO) ""; |
---|
318 | |
---|
319 | include $(MORPHEO_TOPLEVEL)/IPs/systemC/processor/Morpheo/Behavioural/Makefile.Synthesis |
---|
320 | include $(MORPHEO_TOPLEVEL)/IPs/systemC/processor/Morpheo/Makefile.deps |
---|
321 | include $(MORPHEO_TOPLEVEL)/IPs/systemC/Environment/Makefile.deps |
---|