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