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