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