1 | |
---|
2 | # |
---|
3 | # $Id: Makefile 117 2009-05-16 14:42:39Z 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 : all |
---|
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 |
---|
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 | lib : |
---|
191 | @\ |
---|
192 | $(MAKE) --directory=$(ENVIRONMENT_DIR) --makefile=Makefile;\ |
---|
193 | $(MAKE) --directory=$(MORPHEO_DIR) --makefile=Makefile; |
---|
194 | |
---|
195 | soft : |
---|
196 | @\ |
---|
197 | $(MAKE) --directory=$(DIR_SOFT) --makefile=Makefile; |
---|
198 | |
---|
199 | #-----[ Rules ]-------------------------------------------- |
---|
200 | |
---|
201 | $(DIR_OBJ)/%.o : %.cpp |
---|
202 | @\ |
---|
203 | $(ECHO) "Compilation : $*";\ |
---|
204 | $(CXX) $(PLATFORMS_CXX_FLAGS) -c -o $@ $<; |
---|
205 | |
---|
206 | $(DIR_OBJ) $(DIR_BIN) $(DIR_LOGS) : |
---|
207 | @\ |
---|
208 | $(ECHO) "Create directory : $@";\ |
---|
209 | $(MKDIR) $@ |
---|
210 | |
---|
211 | #-----[ Clean + help ]------------------------------------- |
---|
212 | |
---|
213 | clean : |
---|
214 | @\ |
---|
215 | $(ECHO) "Delete temporary files in directory $(PWD)";\ |
---|
216 | $(RM) $(OBJECTS) $(EXEC) $(LOGS) \ |
---|
217 | *~ $(DIR_SRC)/*~ $(DIR_INC)/*~ $(DIR_DATA)/*/*~ *.res *.txt\ |
---|
218 | *core* \ |
---|
219 | tty* \ |
---|
220 | *.vhdl \ |
---|
221 | *.log \ |
---|
222 | *.stat \ |
---|
223 | *.pos \ |
---|
224 | modelsim.ini transcript *wlf* $(WORK_NAME) |
---|
225 | |
---|
226 | clean_all : clean |
---|
227 | @\ |
---|
228 | $(ECHO) "Delete generated files in directory $(PWD)";\ |
---|
229 | $(RM) $(DIR_OBJ) $(DIR_BIN) $(DIR_LOG);\ |
---|
230 | $(MAKE) --directory=$(DIR_SOFT) --makefile=Makefile clean_all; \ |
---|
231 | $(MAKE) --directory=$(ENVIRONMENT_DIR) --makefile=Makefile clean_all; \ |
---|
232 | $(MAKE) --directory=$(MORPHEO_DIR) --makefile=Makefile clean_all; |
---|
233 | |
---|
234 | |
---|
235 | help : |
---|
236 | @\ |
---|
237 | $(ECHO) " -----[ Common ]-------------------------------------";\ |
---|
238 | $(ECHO) "";\ |
---|
239 | $(ECHO) " * all (default rules) : create software";\ |
---|
240 | $(ECHO) " * run : execute platforms with test configuration";\ |
---|
241 | $(ECHO) " set DATA to select a specific directory in $(DIR_DATA) (default : all)";\ |
---|
242 | $(ECHO) " set PRIORITY to nice the execution (default : 0)";\ |
---|
243 | $(ECHO) " example : make run DATA=debug PRIORITY=10";\ |
---|
244 | $(ECHO) " * execute : cf 'make run'";\ |
---|
245 | $(ECHO) " * debug : cf 'make run DATA=debug'";\ |
---|
246 | $(ECHO) " * bench : cf 'make run DATA=bench'";\ |
---|
247 | $(ECHO) " * lib : make library";\ |
---|
248 | $(ECHO) " * soft : make software";\ |
---|
249 | $(ECHO) " * clean : erase temporary files";\ |
---|
250 | $(ECHO) " * clean_all : erase generated files";\ |
---|
251 | $(ECHO) " * help : print this message";\ |
---|
252 | $(ECHO) ""; |
---|
253 | |
---|
254 | include $(MORPHEO_TOPLEVEL)/IPs/systemC/processor/Morpheo/Behavioural/Makefile.Synthesis |
---|
255 | include $(MORPHEO_TOPLEVEL)/IPs/systemC/processor/Morpheo/Makefile.deps |
---|
256 | include $(MORPHEO_TOPLEVEL)/IPs/systemC/Environment/Makefile.deps |
---|