1 | |
---|
2 | # |
---|
3 | # $Id: Makefile 134 2009-07-15 08:41:01Z 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_DATA = ./data |
---|
55 | PATH_LOGS = $(patsubst $(PATH_DATA)/%,$(PATH_LOG)/%,$(wildcard $(PATH_DATA)/*)) |
---|
56 | |
---|
57 | PATH_SOFT = $(MORPHEO_TOPLEVEL)/Softwares |
---|
58 | |
---|
59 | #MORPHEO - define in $(MORPHEO_TOPLEVEL)/IPs/systemC/processor/Morpheo/Makefile.deps |
---|
60 | #MORPHEO_DIR - define in $(MORPHEO_TOPLEVEL)/IPs/systemC/processor/Morpheo/Makefile.deps |
---|
61 | #MORPHEO_INCDIR - define in $(MORPHEO_TOPLEVEL)/IPs/systemC/processor/Morpheo/Makefile.deps |
---|
62 | #MORPHEO_LIBDIR - define in $(MORPHEO_TOPLEVEL)/IPs/systemC/processor/Morpheo/Makefile.deps |
---|
63 | #MORPHEO_LIBNAME - define in $(MORPHEO_TOPLEVEL)/IPs/systemC/processor/Morpheo/Makefile.deps |
---|
64 | |
---|
65 | #ENVIRONMENT_DIR - define in $(MORPHEO_TOPLEVEL)/IPs/systemC/Environment/Makefile.deps |
---|
66 | #ENVIRONMENT_INCDIR - define in $(MORPHEO_TOPLEVEL)/IPs/systemC/Environment/Makefile.deps |
---|
67 | #ENVIRONMENT_LIBDIR - define in $(MORPHEO_TOPLEVEL)/IPs/systemC/Environment/Makefile.deps |
---|
68 | #ENVIRONMENT_LIBNAME - define in $(MORPHEO_TOPLEVEL)/IPs/systemC/Environment/Makefile.deps |
---|
69 | |
---|
70 | #---------------------------------------------------------- |
---|
71 | #---------------------------------------------------------- |
---|
72 | #-----[ Variables ]---------------------------------------- |
---|
73 | #---------------------------------------------------------- |
---|
74 | #---------------------------------------------------------- |
---|
75 | SOURCES = $(wildcard $(PATH_SRC)/*.cpp) |
---|
76 | OBJECTS = $(patsubst $(PATH_SRC)/%.cpp,$(PATH_OBJ)/%.o,$(SOURCES)) |
---|
77 | LOGS = $(patsubst $(PATH_DATA)/%.cfg,$(PATH_LOG)/%.log,$(wildcard $(PATH_DATA)/$(DATA)/*.cfg)) |
---|
78 | |
---|
79 | BIN = Platforms_Test.x |
---|
80 | EXEC = $(PATH_BIN)/$(BIN) |
---|
81 | EXEC_PREFIX = $(NICE) -n $(PRIORITY) |
---|
82 | # $(VALGRIND) |
---|
83 | EXEC_PARAMS = $(SYSTEMC_EXEC_PARAMS_$(SIMULATOR_SYSTEMC)) |
---|
84 | |
---|
85 | SCRIPT = make.sh |
---|
86 | |
---|
87 | #-----[ Compilation ]-------------------------------------- |
---|
88 | INCDIR = $(SYSTEMC_INCDIR_$(SIMULATOR_SYSTEMC)) \ |
---|
89 | $(MORPHEO_INCDIR) \ |
---|
90 | $(ENVIRONMENT_INCDIR) \ |
---|
91 | -I$(PATH_INC) |
---|
92 | |
---|
93 | #LIBDIR = $(SYSTEMC_LIBDIR_$(SIMULATOR_SYSTEMC)) \ |
---|
94 | # $(ENVIRONMENT_LIBDIR) \ |
---|
95 | # $(MORPHEO_LIBDIR) |
---|
96 | |
---|
97 | LIBDIR = $(SYSTEMC_LIBDIR_$(SIMULATOR_SYSTEMC)) \ |
---|
98 | -L$(PATH_LIB) |
---|
99 | |
---|
100 | LIBNAME = $(ENVIRONMENT_LIBNAME) \ |
---|
101 | $(MORPHEO_LIBNAME) \ |
---|
102 | $(SYSTEMC_LIBNAME_$(SIMULATOR_SYSTEMC)) |
---|
103 | |
---|
104 | FLAGS = $(SYSTEMC_CFLAGS_$(SIMULATOR_SYSTEMC)) |
---|
105 | |
---|
106 | PLATFORMS_CXX_FLAGS = $(MORPHEO_FLAGS) $(CXX_FLAGS) $(FLAGS) $(INCDIR) |
---|
107 | PLATFORMS_L_FLAGS = $(MORPHEO_FLAGS) $(CXX_FLAGS) $(FLAGS) $(LIBDIR) |
---|
108 | |
---|
109 | #---------------------------------------------------------- |
---|
110 | #---------------------------------------------------------- |
---|
111 | #-----[ Rules ]-------------------------------------------- |
---|
112 | #---------------------------------------------------------- |
---|
113 | #---------------------------------------------------------- |
---|
114 | |
---|
115 | vpath %.h $(PATH_INC) |
---|
116 | vpath %.cpp $(PATH_SRC) |
---|
117 | vpath %.o $(PATH_OBJ) |
---|
118 | vpath %.cfg $(PATH_DATA)/*/ |
---|
119 | |
---|
120 | .PRECIOUS : $(PATH_OBJ)/%.o $(PATH_BIN)/%.x $(PATH_LOG)/%.log |
---|
121 | |
---|
122 | all : $(EXEC) |
---|
123 | |
---|
124 | $(PATH_BIN)/%.x : $(PATH_OBJ) $(PATH_BIN) |
---|
125 | @\ |
---|
126 | $(ECHO) "Linkage : $*";\ |
---|
127 | case "${SIMULATOR_SYSTEMC}" in \ |
---|
128 | "modelsim") \ |
---|
129 | $(MAKE) $(WORK_NAME); \ |
---|
130 | $(MODELTECH_SCCOM) $(PLATFORMS_CXX_FLAGS) $(SOURCES); \ |
---|
131 | $(MODELTECH_SCCOM) -link $(PLATFORMS_L_FLAGS) $(LIBNAME); \ |
---|
132 | $(ECHO) "#!$(SHELL)" > $@; \ |
---|
133 | $(ECHO) "cd $${PWD};" >> $@; \ |
---|
134 | $(ECHO) "$(MODELTECH_VSIM) -sc_arg "'"$${*}"'" $(WORK_NAME).top;" >> $@;\ |
---|
135 | $(ECHO) "cd -;" >> $@; \ |
---|
136 | $(CHMOD) +x $@; \ |
---|
137 | ;; \ |
---|
138 | *) \ |
---|
139 | $(MAKE) $(OBJECTS); \ |
---|
140 | $(CXX) $(PLATFORMS_L_FLAGS) -o $@ $(OBJECTS) $(LIBNAME); \ |
---|
141 | ;; \ |
---|
142 | esac; \ |
---|
143 | |
---|
144 | run : |
---|
145 | @\ |
---|
146 | declare -i clean=$(CLEAN); \ |
---|
147 | if $(TEST) $${clean} -ne 0 -a "$(DATA)" != "$(DATA_ALL)"; then \ |
---|
148 | $(RM) $(PATH_LOG)/$(DATA); \ |
---|
149 | fi; \ |
---|
150 | declare logs="$(LOGS)"; \ |
---|
151 | $(MAKE) $${logs}; \ |
---|
152 | declare -i nb_test=0; \ |
---|
153 | declare -i nb_test_ko=0; \ |
---|
154 | for log in $${logs}; do \ |
---|
155 | $(GREP) -q "Test OK" $$log; \ |
---|
156 | declare -i test_ok=$$?; \ |
---|
157 | $(GREP) -q "Test KO" $$log; \ |
---|
158 | declare -i test_ko=$$?; \ |
---|
159 | if $(TEST) $${test_ko} -eq 0 -o $${test_ok} -ne 0; \ |
---|
160 | then nb_test_ko=$$(($${nb_test_ko} + 1)); \ |
---|
161 | fi; \ |
---|
162 | nb_test=$$(($${nb_test} + 1)); \ |
---|
163 | done; \ |
---|
164 | if $(TEST) $${nb_test_ko} -ne 0; \ |
---|
165 | then $(ECHO) "-------------------| Test KO !!! ($${nb_test_ko}/$${nb_test})"; exit 1; \ |
---|
166 | else $(ECHO) "-------------------| Test OK ($${nb_test})"; exit 0; \ |
---|
167 | fi; |
---|
168 | |
---|
169 | execute : run |
---|
170 | |
---|
171 | debug : |
---|
172 | @\ |
---|
173 | $(MAKE) run DATA=debug CLEAN=1; |
---|
174 | |
---|
175 | bench : |
---|
176 | @\ |
---|
177 | $(MAKE) run DATA=bench; |
---|
178 | |
---|
179 | distexe : |
---|
180 | @\ |
---|
181 | $(ECHO) -n "Generate : $(SCRIPT) ";\ |
---|
182 | $(RM) $(SCRIPT); \ |
---|
183 | for log in $(LOGS); do \ |
---|
184 | $(ECHO) -n "."; \ |
---|
185 | $(ECHO) -n "cd $(MORPHEO_TOPLEVEL); source environment.sh; cd -; path=\"${PWD}\"; " >> $(SCRIPT);\ |
---|
186 | if $(TEST) $(CLEAN) -ne 0; then \ |
---|
187 | $(ECHO) -n "$(RM) $${log}; " >> $(SCRIPT); \ |
---|
188 | fi; \ |
---|
189 | $(ECHO) "$(MAKE) -C "'$${path}'" $${log} PRIORITY=$(PRIORITY);" >> $(SCRIPT); \ |
---|
190 | done; \ |
---|
191 | $(CHMOD) +x $(SCRIPT); \ |
---|
192 | $(ECHO) " done"; |
---|
193 | |
---|
194 | |
---|
195 | $(PATH_LOG)/%.log : $(PATH_DATA)/%.cfg $(EXEC) $(PATH_LOGS) |
---|
196 | @\ |
---|
197 | file=$$($(BASENAME) $<); \ |
---|
198 | data=$$(eval echo $$($(CAT) $<)); \ |
---|
199 | log=$@; \ |
---|
200 | $(ECHO) "Run : $*"; \ |
---|
201 | $(EXEC_PREFIX) $(EXEC) $(EXEC_PARAMS) $${data} &> $$log; \ |
---|
202 | $(GREP) -q "Test OK" $$log; \ |
---|
203 | declare -i test_ok=$$?; \ |
---|
204 | $(GREP) -q "Test KO" $$log; \ |
---|
205 | declare -i test_ko=$$?; \ |
---|
206 | declare timing=$$($(GREP) -h "Timing" $$log); \ |
---|
207 | if $(TEST) $${test_ko} -ne 0 -a $${test_ok} -eq 0; \ |
---|
208 | then test="... OK "; \ |
---|
209 | else test="... KO !!!"; \ |
---|
210 | fi; \ |
---|
211 | $(ECHO) -e " $* $${test}\t$${timing}";\ |
---|
212 | echo "{$$($(date))} $* $${test} $${timing}" >> $$($(DIRNAME) $*).res;\ |
---|
213 | |
---|
214 | #-----[ Library + Software ]------------------------------- |
---|
215 | |
---|
216 | env : soft lib |
---|
217 | @$(MAKE) $(EXEC) |
---|
218 | |
---|
219 | lib : |
---|
220 | @\ |
---|
221 | $(MAKE) --directory=$(ENVIRONMENT_DIR) --makefile=Makefile;\ |
---|
222 | $(MAKE) --directory=$(MORPHEO_DIR) --makefile=Makefile; |
---|
223 | |
---|
224 | soft : |
---|
225 | @\ |
---|
226 | $(MAKE) --directory=$(PATH_SOFT) --makefile=Makefile; |
---|
227 | |
---|
228 | #-----[ Rules ]-------------------------------------------- |
---|
229 | |
---|
230 | $(PATH_OBJ)/%.o : %.cpp |
---|
231 | @\ |
---|
232 | $(ECHO) "Compilation : $*";\ |
---|
233 | $(CXX) $(PLATFORMS_CXX_FLAGS) -c -o $@ $<; |
---|
234 | |
---|
235 | $(PATH_OBJ) $(PATH_BIN) $(PATH_LOGS) : |
---|
236 | @\ |
---|
237 | $(ECHO) "Create directory : $@";\ |
---|
238 | $(MKDIR) $@ |
---|
239 | |
---|
240 | #-----[ Clean + help ]------------------------------------- |
---|
241 | |
---|
242 | clean : |
---|
243 | @\ |
---|
244 | $(ECHO) "Delete temporary files in directory $(PWD)";\ |
---|
245 | $(RM) $(OBJECTS) $(EXEC) $(LOGS) \ |
---|
246 | *~ $(PATH_SRC)/*~ $(PATH_INC)/*~ $(PATH_DATA)/*/*~ *.res *.txt\ |
---|
247 | *core* \ |
---|
248 | tty* \ |
---|
249 | *.vhdl \ |
---|
250 | *.log \ |
---|
251 | *.stat \ |
---|
252 | *.pos \ |
---|
253 | modelsim.ini transcript *wlf* $(WORK_NAME) |
---|
254 | |
---|
255 | clean_all : clean |
---|
256 | @\ |
---|
257 | $(ECHO) "Delete generated files in directory $(PWD)";\ |
---|
258 | $(RM) $(PATH_OBJ) $(PATH_BIN) $(PATH_LOG) $(SCRIPT);\ |
---|
259 | $(MAKE) --directory=$(PATH_SOFT) --makefile=Makefile clean_all; \ |
---|
260 | $(MAKE) --directory=$(ENVIRONMENT_DIR) --makefile=Makefile clean_all; \ |
---|
261 | $(MAKE) --directory=$(MORPHEO_DIR) --makefile=Makefile clean_all; |
---|
262 | |
---|
263 | |
---|
264 | help : |
---|
265 | @\ |
---|
266 | $(ECHO) " -----[ Common ]-------------------------------------";\ |
---|
267 | $(ECHO) "";\ |
---|
268 | $(ECHO) " * all (default rules) : create software";\ |
---|
269 | $(ECHO) " * run : execute platforms with test configuration";\ |
---|
270 | $(ECHO) " set DATA to select a specific directory in $(PATH_DATA) (default : all)";\ |
---|
271 | $(ECHO) " set PRIORITY to nice the execution (default : 0)";\ |
---|
272 | $(ECHO) " set CLEAN to remove previous log (default : 0)";\ |
---|
273 | $(ECHO) " example : make run DATA=debug PRIORITY=10 CLEAN";\ |
---|
274 | $(ECHO) " * execute : cf 'make run'";\ |
---|
275 | $(ECHO) " * debug : cf 'make run DATA=debug'";\ |
---|
276 | $(ECHO) " * bench : cf 'make run DATA=bench'";\ |
---|
277 | $(ECHO) " * distexe : Generate an command file to distexe. It's as run command, but just generate an script with all make";\ |
---|
278 | $(ECHO) " * lib : make library";\ |
---|
279 | $(ECHO) " * soft : make software";\ |
---|
280 | $(ECHO) " * clean : erase temporary files";\ |
---|
281 | $(ECHO) " * clean_all : erase generated files";\ |
---|
282 | $(ECHO) " * help : print this message";\ |
---|
283 | $(ECHO) ""; |
---|
284 | |
---|
285 | include $(MORPHEO_TOPLEVEL)/IPs/systemC/processor/Morpheo/Behavioural/Makefile.Synthesis |
---|
286 | include $(MORPHEO_TOPLEVEL)/IPs/systemC/processor/Morpheo/Makefile.deps |
---|
287 | include $(MORPHEO_TOPLEVEL)/IPs/systemC/Environment/Makefile.deps |
---|