1 | # |
---|
2 | # $Id: Makefile 88 2008-12-10 18:31:39Z rosiere $ |
---|
3 | # |
---|
4 | # [ Description ] |
---|
5 | # |
---|
6 | # Makefile |
---|
7 | # |
---|
8 | |
---|
9 | #---------------------------------------------------------- |
---|
10 | #---------------------------------------------------------- |
---|
11 | #-----[ Environment ]-------------------------------------- |
---|
12 | #---------------------------------------------------------- |
---|
13 | #---------------------------------------------------------- |
---|
14 | ifeq ($(origin MORPHEO_TOPLEVEL), undefined) |
---|
15 | $(error "variable MORPHEO_TOPLEVEL is undefined") |
---|
16 | else |
---|
17 | include $(MORPHEO_TOPLEVEL)/Makefile.tools |
---|
18 | include $(MORPHEO_TOPLEVEL)/Makefile.flags |
---|
19 | endif |
---|
20 | |
---|
21 | ifeq ($(origin MORPHEO_TMP), undefined) |
---|
22 | $(error "variable MORPHEO_TMP is undefined") |
---|
23 | endif |
---|
24 | |
---|
25 | #---------------------------------------------------------- |
---|
26 | #---------------------------------------------------------- |
---|
27 | #-----[ Directory ]---------------------------------------- |
---|
28 | #---------------------------------------------------------- |
---|
29 | #---------------------------------------------------------- |
---|
30 | ENTITY = Test |
---|
31 | |
---|
32 | DIR_TMP = $(MORPHEO_TMP) |
---|
33 | DIR_INC = include |
---|
34 | DIR_SRC = src |
---|
35 | DIR_OBJ = $(DIR_TMP)/obj |
---|
36 | DIR_BIN = $(DIR_TMP)/bin |
---|
37 | DIR_LOG = ./log |
---|
38 | DIR_DATA = ./data |
---|
39 | DIR_SOFT = $(MORPHEO_TOPLEVEL)/Softwares |
---|
40 | |
---|
41 | #MORPHEO - define in $(MORPHEO_TOPLEVEL)/IPs/systemC/processor/Morpheo/Makefile.deps |
---|
42 | #MORPHEO_DIR - define in $(MORPHEO_TOPLEVEL)/IPs/systemC/processor/Morpheo/Makefile.deps |
---|
43 | #MORPHEO_INCDIR - define in $(MORPHEO_TOPLEVEL)/IPs/systemC/processor/Morpheo/Makefile.deps |
---|
44 | #MORPHEO_LIBDIR - define in $(MORPHEO_TOPLEVEL)/IPs/systemC/processor/Morpheo/Makefile.deps |
---|
45 | #MORPHEO_LIBNAME - define in $(MORPHEO_TOPLEVEL)/IPs/systemC/processor/Morpheo/Makefile.deps |
---|
46 | |
---|
47 | #ENVIRONMENT_DIR - define in $(MORPHEO_TOPLEVEL)/IPs/systemC/Environment/Makefile.deps |
---|
48 | #ENVIRONMENT_INCDIR - define in $(MORPHEO_TOPLEVEL)/IPs/systemC/Environment/Makefile.deps |
---|
49 | #ENVIRONMENT_LIBDIR - define in $(MORPHEO_TOPLEVEL)/IPs/systemC/Environment/Makefile.deps |
---|
50 | #ENVIRONMENT_LIBNAME - define in $(MORPHEO_TOPLEVEL)/IPs/systemC/Environment/Makefile.deps |
---|
51 | |
---|
52 | #---------------------------------------------------------- |
---|
53 | #---------------------------------------------------------- |
---|
54 | #-----[ Variables ]---------------------------------------- |
---|
55 | #---------------------------------------------------------- |
---|
56 | #---------------------------------------------------------- |
---|
57 | |
---|
58 | OBJECTS = $(patsubst $(DIR_SRC)/%.cpp,$(DIR_OBJ)/%.o,$(wildcard $(DIR_SRC)/*.cpp)) |
---|
59 | LOGS = $(patsubst $(DIR_DATA)/%.cfg,$(DIR_LOG)/%.log,$(wildcard $(DIR_DATA)/*.cfg)) |
---|
60 | |
---|
61 | EXEC = $(DIR_BIN)/soft.x |
---|
62 | EXEC_PREFIX = |
---|
63 | #$(VALGRIND) |
---|
64 | |
---|
65 | #-----[ Compilation ]-------------------------------------- |
---|
66 | INCDIR = $(SYSTEMC_INCDIR_$(SIMULATOR)) \ |
---|
67 | $(MORPHEO_INCDIR) \ |
---|
68 | $(ENVIRONMENT_INCDIR) \ |
---|
69 | -I$(DIR_INC) |
---|
70 | |
---|
71 | LIBDIR = $(SYSTEMC_LIBDIR_$(SIMULATOR)) \ |
---|
72 | $(ENVIRONMENT_LIBDIR) \ |
---|
73 | $(MORPHEO_LIBDIR) |
---|
74 | |
---|
75 | LIBNAME = $(ENVIRONMENT_LIBNAME) \ |
---|
76 | $(MORPHEO_LIBNAME) \ |
---|
77 | $(SYSTEMC_LIBNAME_$(SIMULATOR)) |
---|
78 | |
---|
79 | FLAGS = $(SYSTEMC_CFLAGS_$(SIMULATOR)) |
---|
80 | |
---|
81 | PLATFORMS_CXX_FLAGS = $(MORPHEO_FLAGS) $(CXX_FLAGS) $(FLAGS) $(INCDIR) |
---|
82 | PLATFORMS_L_FLAGS = $(MORPHEO_FLAGS) $(CXX_FLAGS) $(FLAGS) $(LIBDIR) |
---|
83 | |
---|
84 | #---------------------------------------------------------- |
---|
85 | #---------------------------------------------------------- |
---|
86 | #-----[ Rules ]-------------------------------------------- |
---|
87 | #---------------------------------------------------------- |
---|
88 | #---------------------------------------------------------- |
---|
89 | |
---|
90 | vpath %.h $(DIR_INC) |
---|
91 | vpath %.cpp $(DIR_SRC) |
---|
92 | vpath %.o $(DIR_OBJ) |
---|
93 | vpath %.cfg $(DIR_DATA) |
---|
94 | |
---|
95 | .PRECIOUS : $(DIR_OBJ)/%.o $(DIR_BIN)/%.x $(DIR_LOG)/%.log |
---|
96 | |
---|
97 | all : $(DIR_OBJ) $(DIR_BIN) |
---|
98 | @\ |
---|
99 | $(MAKE) $(EXEC) |
---|
100 | |
---|
101 | $(DIR_BIN)/%.x : $(OBJECTS) |
---|
102 | @\ |
---|
103 | $(ECHO) "Compilation : $*";\ |
---|
104 | $(CXX) $(PLATFORMS_L_FLAGS) -o $@ $^ $(LIBNAME); |
---|
105 | |
---|
106 | run : $(DIR_LOG) all |
---|
107 | @\ |
---|
108 | $(MAKE) $(LOGS); \ |
---|
109 | declare -i have_test_ko=0; \ |
---|
110 | for log in $(LOGS); do \ |
---|
111 | $(GREP) -q "Test OK" $$log; \ |
---|
112 | declare -i test_ok=$$?; \ |
---|
113 | $(GREP) -q "Test KO" $$log; \ |
---|
114 | declare -i test_ko=$$?; \ |
---|
115 | if $(TEST) $$test_ko -eq 0 -o $$test_ok -ne 0; \ |
---|
116 | then have_test_ko=1; \ |
---|
117 | fi; \ |
---|
118 | done; \ |
---|
119 | if $(TEST) $$have_test_ko -ne 0; \ |
---|
120 | then $(ECHO) "-------------------| Test KO"; exit 1; \ |
---|
121 | else $(ECHO) "-------------------| Test OK"; exit 0; \ |
---|
122 | fi; |
---|
123 | |
---|
124 | execute : run |
---|
125 | |
---|
126 | |
---|
127 | $(DIR_LOG)/%.log : %.cfg |
---|
128 | @\ |
---|
129 | file=$$($(BASENAME) $<); \ |
---|
130 | data=$$($(CAT) $<); \ |
---|
131 | log=$@; \ |
---|
132 | $(ECHO) "Run : $$file"; \ |
---|
133 | $(EXEC_PREFIX) $(EXEC) $${data} &> $$log; \ |
---|
134 | $(GREP) -q "Test OK" $$log; \ |
---|
135 | declare -i test_ok=$$?; \ |
---|
136 | $(GREP) -q "Test KO" $$log; \ |
---|
137 | declare -i test_ko=$$?; \ |
---|
138 | declare timing=$$($(GREP) -h "Timing" $$log); \ |
---|
139 | if $(TEST) $$test_ko -ne 0 -a $$test_ok -eq 0; \ |
---|
140 | then $(ECHO) -e " $$file ... OK\t$$timing"; \ |
---|
141 | else $(ECHO) -e " $$file ... KO\t$$timing"; \ |
---|
142 | have_test_ko=1; \ |
---|
143 | fi; \ |
---|
144 | |
---|
145 | |
---|
146 | #-----[ Library + Software ]------------------------------- |
---|
147 | |
---|
148 | lib : |
---|
149 | @\ |
---|
150 | $(MAKE) --directory=$(ENVIRONMENT_DIR) --makefile=Makefile;\ |
---|
151 | $(MAKE) --directory=$(MORPHEO_DIR) --makefile=Makefile; |
---|
152 | |
---|
153 | soft : |
---|
154 | @\ |
---|
155 | $(MAKE) --directory=$(DIR_SOFT) --makefile=Makefile; |
---|
156 | |
---|
157 | #-----[ Rules ]-------------------------------------------- |
---|
158 | |
---|
159 | $(DIR_OBJ)/%.o : %.cpp |
---|
160 | @\ |
---|
161 | $(ECHO) "Compilation : $*";\ |
---|
162 | $(CXX) $(PLATFORMS_CXX_FLAGS) -c -o $@ $<; |
---|
163 | |
---|
164 | $(DIR_OBJ) : |
---|
165 | @\ |
---|
166 | $(ECHO) "Create directory : $@";\ |
---|
167 | $(MKDIR) $@ |
---|
168 | |
---|
169 | $(DIR_BIN) : |
---|
170 | @\ |
---|
171 | $(ECHO) "Create directory : $@";\ |
---|
172 | $(MKDIR) $@ |
---|
173 | |
---|
174 | $(DIR_LOG) : |
---|
175 | @\ |
---|
176 | $(ECHO) "Create directory : $@";\ |
---|
177 | $(MKDIR) $@ |
---|
178 | |
---|
179 | #-----[ Clean + help ]------------------------------------- |
---|
180 | |
---|
181 | clean : |
---|
182 | @\ |
---|
183 | $(ECHO) "Delete temporary files in directory $(PWD)";\ |
---|
184 | $(RM) *~ $(DIR_SRC)/*~ $(DIR_INC)/*~ $(DIR_DATA)/*~ core* tty* \ |
---|
185 | $(DIR_OBJ) $(DIR_BIN) $(DIR_LOG); |
---|
186 | |
---|
187 | clean_all : clean |
---|
188 | @\ |
---|
189 | $(ECHO) "Delete generated files in directory $(PWD)";\ |
---|
190 | $(MAKE) --directory=$(ENVIRONMENT_DIR) --makefile=Makefile clean_all; \ |
---|
191 | $(MAKE) --directory=$(MORPHEO_DIR) --makefile=Makefile clean_all; \ |
---|
192 | $(MAKE) --directory=$(DIR_SOFT) --makefile=Makefile clean_all; |
---|
193 | |
---|
194 | |
---|
195 | help : |
---|
196 | @\ |
---|
197 | $(ECHO) " -----[ Common ]-------------------------------------";\ |
---|
198 | $(ECHO) "";\ |
---|
199 | $(ECHO) " * all (default rules) : create software";\ |
---|
200 | $(ECHO) " * run : execute platforms";\ |
---|
201 | $(ECHO) " * lib : make library";\ |
---|
202 | $(ECHO) " * soft : make software";\ |
---|
203 | $(ECHO) " * execute : cf 'make run'";\ |
---|
204 | $(ECHO) " * clean : erase temporary files";\ |
---|
205 | $(ECHO) " * clean_all : erase generated files";\ |
---|
206 | $(ECHO) " * help : print this message";\ |
---|
207 | $(ECHO) ""; |
---|
208 | |
---|
209 | include $(MORPHEO_TOPLEVEL)/IPs/systemC/processor/Morpheo/Makefile.deps |
---|
210 | include $(MORPHEO_TOPLEVEL)/IPs/systemC/Environment/Makefile.deps |
---|