1 | |
---|
2 | # |
---|
3 | # $Id: Makefile 137 2010-02-16 12:35:48Z 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 | |
---|
37 | ifeq ($(flavor CLEAN), undefined) |
---|
38 | CLEAN = 0 |
---|
39 | endif |
---|
40 | |
---|
41 | #---------------------------------------------------------- |
---|
42 | #---------------------------------------------------------- |
---|
43 | #-----[ Directory ]---------------------------------------- |
---|
44 | #---------------------------------------------------------- |
---|
45 | #---------------------------------------------------------- |
---|
46 | ENTITY = Test |
---|
47 | |
---|
48 | PATH_INC = include |
---|
49 | PATH_SRC = src |
---|
50 | PATH_OBJ = $(MORPHEO_TMP)/obj |
---|
51 | PATH_LIB = $(MORPHEO_PREFIX)/lib |
---|
52 | PATH_BIN = $(MORPHEO_PREFIX)/bin |
---|
53 | PATH_LOG = $(MORPHEO_TMP)/log |
---|
54 | PATH_GMON = $(MORPHEO_TMP)/gmon |
---|
55 | PATH_DATA = ./data |
---|
56 | PATH_LOGS = $(patsubst $(PATH_DATA)/%,$(PATH_LOG)/%,$(wildcard $(PATH_DATA)/*)) |
---|
57 | |
---|
58 | PATH_SOFT = $(MORPHEO_TOPLEVEL)/Softwares |
---|
59 | |
---|
60 | #MORPHEO - define in $(MORPHEO_TOPLEVEL)/IPs/systemC/processor/Morpheo/Makefile.deps |
---|
61 | #MORPHEO_DIR - define in $(MORPHEO_TOPLEVEL)/IPs/systemC/processor/Morpheo/Makefile.deps |
---|
62 | #MORPHEO_INCDIR - define in $(MORPHEO_TOPLEVEL)/IPs/systemC/processor/Morpheo/Makefile.deps |
---|
63 | #MORPHEO_LIBDIR - define in $(MORPHEO_TOPLEVEL)/IPs/systemC/processor/Morpheo/Makefile.deps |
---|
64 | #MORPHEO_LIBNAME - define in $(MORPHEO_TOPLEVEL)/IPs/systemC/processor/Morpheo/Makefile.deps |
---|
65 | |
---|
66 | #ENVIRONMENT_DIR - define in $(MORPHEO_TOPLEVEL)/IPs/systemC/Environment/Makefile.deps |
---|
67 | #ENVIRONMENT_INCDIR - define in $(MORPHEO_TOPLEVEL)/IPs/systemC/Environment/Makefile.deps |
---|
68 | #ENVIRONMENT_LIBDIR - define in $(MORPHEO_TOPLEVEL)/IPs/systemC/Environment/Makefile.deps |
---|
69 | #ENVIRONMENT_LIBNAME - define in $(MORPHEO_TOPLEVEL)/IPs/systemC/Environment/Makefile.deps |
---|
70 | |
---|
71 | #---------------------------------------------------------- |
---|
72 | #---------------------------------------------------------- |
---|
73 | #-----[ Variables ]---------------------------------------- |
---|
74 | #---------------------------------------------------------- |
---|
75 | #---------------------------------------------------------- |
---|
76 | SOURCES = $(wildcard $(PATH_SRC)/*.cpp) |
---|
77 | OBJECTS = $(patsubst $(PATH_SRC)/%.cpp,$(PATH_OBJ)/%.o,$(SOURCES)) |
---|
78 | LOGS = $(patsubst $(PATH_DATA)/%.cfg,$(PATH_LOG)/%.log,$(wildcard $(PATH_DATA)/$(DATA)/*.cfg)) |
---|
79 | |
---|
80 | BIN = Platforms_Test.x |
---|
81 | EXEC = $(PATH_BIN)/$(BIN) |
---|
82 | EXEC_PREFIX = $(NICE) -n $(PRIORITY) |
---|
83 | #$(VALGRIND) |
---|
84 | EXEC_PARAMS = $(SYSTEMC_EXEC_PARAMS_$(SIMULATOR_SYSTEMC)) |
---|
85 | |
---|
86 | SCRIPT = make.sh |
---|
87 | |
---|
88 | #-----[ Compilation ]-------------------------------------- |
---|
89 | INCDIR = $(SYSTEMC_INCDIR_$(SIMULATOR_SYSTEMC)) \ |
---|
90 | $(MORPHEO_INCDIR) \ |
---|
91 | $(ENVIRONMENT_INCDIR) \ |
---|
92 | -I$(PATH_INC) |
---|
93 | |
---|
94 | #LIBDIR = $(SYSTEMC_LIBDIR_$(SIMULATOR_SYSTEMC)) \ |
---|
95 | # $(ENVIRONMENT_LIBDIR) \ |
---|
96 | # $(MORPHEO_LIBDIR) |
---|
97 | |
---|
98 | LIBDIR = $(SYSTEMC_LIBDIR_$(SIMULATOR_SYSTEMC)) \ |
---|
99 | -L$(PATH_LIB) |
---|
100 | |
---|
101 | LIBNAME = $(ENVIRONMENT_LIBNAME) \ |
---|
102 | $(MORPHEO_LIBNAME) \ |
---|
103 | $(SYSTEMC_LIBNAME_$(SIMULATOR_SYSTEMC)) |
---|
104 | |
---|
105 | FLAGS = $(SYSTEMC_CFLAGS_$(SIMULATOR_SYSTEMC)) |
---|
106 | |
---|
107 | PLATFORMS_CXX_FLAGS = $(MORPHEO_FLAGS) $(CXX_FLAGS) $(FLAGS) $(INCDIR) |
---|
108 | PLATFORMS_L_FLAGS = $(MORPHEO_FLAGS) $(CXX_FLAGS) $(FLAGS) $(LIBDIR) |
---|
109 | |
---|
110 | #---------------------------------------------------------- |
---|
111 | #---------------------------------------------------------- |
---|
112 | #-----[ Rules ]-------------------------------------------- |
---|
113 | #---------------------------------------------------------- |
---|
114 | #---------------------------------------------------------- |
---|
115 | |
---|
116 | vpath %.h $(PATH_INC) |
---|
117 | vpath %.cpp $(PATH_SRC) |
---|
118 | vpath %.o $(PATH_OBJ) |
---|
119 | vpath %.cfg $(PATH_DATA)/*/ |
---|
120 | |
---|
121 | .PRECIOUS : $(PATH_OBJ)/%.o $(PATH_BIN)/%.x $(PATH_LOG)/%.log |
---|
122 | |
---|
123 | all : $(EXEC) |
---|
124 | |
---|
125 | $(PATH_BIN)/%.x : $(PATH_OBJ) $(PATH_BIN) |
---|
126 | @\ |
---|
127 | $(ECHO) "Linkage : $*";\ |
---|
128 | case "${SIMULATOR_SYSTEMC}" in \ |
---|
129 | "modelsim") \ |
---|
130 | $(MAKE) $(WORK_NAME); \ |
---|
131 | $(MODELTECH_SCCOM) $(PLATFORMS_CXX_FLAGS) $(SOURCES); \ |
---|
132 | $(MODELTECH_SCCOM) -link $(PLATFORMS_L_FLAGS) $(LIBNAME); \ |
---|
133 | $(ECHO) "#!$(SHELL)" > $@; \ |
---|
134 | $(ECHO) "cd $${PWD};" >> $@; \ |
---|
135 | $(ECHO) "$(MODELTECH_VSIM) -sc_arg "'"$${*}"'" $(WORK_NAME).top;" >> $@;\ |
---|
136 | $(ECHO) "cd -;" >> $@; \ |
---|
137 | $(CHMOD) +x $@; \ |
---|
138 | ;; \ |
---|
139 | *) \ |
---|
140 | $(MAKE) $(OBJECTS); \ |
---|
141 | $(CXX) $(PLATFORMS_L_FLAGS) -o $@ $(OBJECTS) $(LIBNAME); \ |
---|
142 | ;; \ |
---|
143 | esac; \ |
---|
144 | |
---|
145 | run : |
---|
146 | @\ |
---|
147 | declare -i clean=$(CLEAN); \ |
---|
148 | if $(TEST) $${clean} -ne 0 -a "$(DATA)" != "$(DATA_ALL)"; then \ |
---|
149 | $(RM) $(PATH_LOG)/$(DATA); \ |
---|
150 | fi; \ |
---|
151 | declare logs="$(LOGS)"; \ |
---|
152 | $(MAKE) $${logs}; \ |
---|
153 | declare -i nb_test=0; \ |
---|
154 | declare -i nb_test_ko=0; \ |
---|
155 | for log in $${logs}; do \ |
---|
156 | $(GREP) -q "Test OK" $$log; \ |
---|
157 | declare -i test_ok=$$?; \ |
---|
158 | $(GREP) -q "Test KO" $$log; \ |
---|
159 | declare -i test_ko=$$?; \ |
---|
160 | if $(TEST) $${test_ko} -eq 0 -o $${test_ok} -ne 0; \ |
---|
161 | then nb_test_ko=$$(($${nb_test_ko} + 1)); \ |
---|
162 | fi; \ |
---|
163 | nb_test=$$(($${nb_test} + 1)); \ |
---|
164 | done; \ |
---|
165 | if $(TEST) $${nb_test_ko} -ne 0; \ |
---|
166 | then $(ECHO) "-------------------| Test KO !!! ($${nb_test_ko}/$${nb_test})"; exit 1; \ |
---|
167 | else $(ECHO) "-------------------| Test OK ($${nb_test})"; exit 0; \ |
---|
168 | fi; |
---|
169 | |
---|
170 | execute : run |
---|
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 "cd $(MORPHEO_TOPLEVEL); source environment.sh; cd -; 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) $*); \ |
---|
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 | #-----[ Library + Software ]------------------------------- |
---|
222 | |
---|
223 | env : soft lib |
---|
224 | @$(MAKE) $(EXEC) |
---|
225 | |
---|
226 | lib : |
---|
227 | @\ |
---|
228 | $(MAKE) --directory=$(ENVIRONMENT_DIR) --makefile=Makefile;\ |
---|
229 | $(MAKE) --directory=$(MORPHEO_DIR) --makefile=Makefile; |
---|
230 | |
---|
231 | soft : |
---|
232 | @\ |
---|
233 | $(MAKE) --directory=$(PATH_SOFT) --makefile=Makefile; |
---|
234 | |
---|
235 | #-----[ Rules ]-------------------------------------------- |
---|
236 | |
---|
237 | $(PATH_OBJ)/%.o : %.cpp |
---|
238 | @\ |
---|
239 | $(ECHO) "Compilation : $*";\ |
---|
240 | $(CXX) $(PLATFORMS_CXX_FLAGS) -c -o $@ $<; |
---|
241 | |
---|
242 | $(PATH_OBJ) $(PATH_BIN) $(PATH_LOGS) $(PATH_GMON) : |
---|
243 | @\ |
---|
244 | $(ECHO) "Create directory : $@";\ |
---|
245 | $(MKDIR) $@ |
---|
246 | |
---|
247 | #-----[ Clean + help ]------------------------------------- |
---|
248 | |
---|
249 | clean : |
---|
250 | @\ |
---|
251 | $(ECHO) "Delete temporary files in directory $(PWD)";\ |
---|
252 | $(RM) $(OBJECTS);\ |
---|
253 | $(RM) $(EXEC);\ |
---|
254 | $(RM) $(PATH_LOGS); \ |
---|
255 | $(RM) $(PATH_GMON); \ |
---|
256 | $(RM) *~ $(PATH_SRC)/*~ $(PATH_INC)/*~ $(PATH_DATA)/*/*~ *.res *.txt\ |
---|
257 | *core* \ |
---|
258 | tty* \ |
---|
259 | *.vhdl \ |
---|
260 | *.log \ |
---|
261 | *.stat \ |
---|
262 | *.pos \ |
---|
263 | modelsim.ini transcript *wlf* $(WORK_NAME) |
---|
264 | |
---|
265 | clean_all : clean |
---|
266 | @\ |
---|
267 | $(ECHO) "Delete generated files in directory $(PWD)";\ |
---|
268 | $(RM) $(PATH_OBJ) $(PATH_BIN) $(PATH_LOG) $(SCRIPT);\ |
---|
269 | $(MAKE) --directory=$(PATH_SOFT) --makefile=Makefile clean_all; \ |
---|
270 | $(MAKE) --directory=$(ENVIRONMENT_DIR) --makefile=Makefile clean_all; \ |
---|
271 | $(MAKE) --directory=$(MORPHEO_DIR) --makefile=Makefile clean_all; |
---|
272 | |
---|
273 | |
---|
274 | help : |
---|
275 | @\ |
---|
276 | $(ECHO) " -----[ Common ]-------------------------------------";\ |
---|
277 | $(ECHO) "";\ |
---|
278 | $(ECHO) " * all (default rules) : create software";\ |
---|
279 | $(ECHO) " * run : execute platforms with test configuration";\ |
---|
280 | $(ECHO) " set DATA to select a specific directory in $(PATH_DATA) (default : all)";\ |
---|
281 | $(ECHO) " set PRIORITY to nice the execution (default : 0)";\ |
---|
282 | $(ECHO) " set CLEAN to remove previous log (default : 0)";\ |
---|
283 | $(ECHO) " example : make run DATA=debug PRIORITY=10 CLEAN";\ |
---|
284 | $(ECHO) " * execute : cf 'make run'";\ |
---|
285 | $(ECHO) " * debug : cf 'make run DATA=debug'";\ |
---|
286 | $(ECHO) " * bench : cf 'make run DATA=bench'";\ |
---|
287 | $(ECHO) " * distexe : Generate an command file to distexe. It's as run command, but just generate an script with all make";\ |
---|
288 | $(ECHO) " * lib : make library";\ |
---|
289 | $(ECHO) " * soft : make software";\ |
---|
290 | $(ECHO) " * clean : erase temporary files";\ |
---|
291 | $(ECHO) " * clean_all : erase generated files";\ |
---|
292 | $(ECHO) " * help : print this message";\ |
---|
293 | $(ECHO) ""; |
---|
294 | |
---|
295 | include $(MORPHEO_TOPLEVEL)/IPs/systemC/processor/Morpheo/Behavioural/Makefile.Synthesis |
---|
296 | include $(MORPHEO_TOPLEVEL)/IPs/systemC/processor/Morpheo/Makefile.deps |
---|
297 | include $(MORPHEO_TOPLEVEL)/IPs/systemC/Environment/Makefile.deps |
---|