Debian Codegraph @

platforms_examples/armcc/AT91SAM7A3/Makefile

raw symbols SCIP
1 .SILENT:
2
3 #We don't need to clean up when we're making these targets
4 NODEPS = clean
5
6 # CPU architecture. Passing to armcc.exe. For list: armcc --cpu list
7 ifndef CPU
8 CPU = ARM7TDMI
9 endif
10
11 # ARM/THUMB mode. Passing to armcc.exe. May be 'thumb' or 'arm'
12 ifndef CPU_MODE
13 CPU_MODE = thumb
14 endif
15
16 TARGET_PLATFORM =armcc_$(CPU)_$(CPU_MODE)
17
18 # Need to use only relative path! Path with logical letters does not working.
19 CPPUTEST_HOME = ../../..
20
21 COMPONENT_NAME = app
22
23 CPPUTEST_OBJS_DIR = objs
24
25 # directory for appication library
26 CPPUTEST_LIB_DIR = lib
27
28 CPPUTEST_USE_MEM_LEAK_DETECTION = N
29 CPPUTEST_USE_STD_CPP_LIB = Y
30 CPPUTEST_USE_VPATH = Y
31 CPPUTEST_USE_STD_C_LIB = Y
32 CPPUTEST_ENABLE_DEBUG = Y
33 CPPUTEST_USE_EXTENSIONS = N
34
35 SRC_DIRS = \
36
37 SRC_FILES = $(CPPUTEST_HOME)/examples/ApplicationLib/CircularBuffer.cpp \
38 $(CPPUTEST_HOME)/examples/ApplicationLib/Printer.cpp
39
40 TEST_SRC_DIRS = \
41 tests \
42
43 TEST_FILES = $(CPPUTEST_HOME)/examples/AllTests/CircularBufferTest.cpp
44
45
46 # directory with CppUTest and startup libraries
47 CPPUTEST_LIB_LINK_DIR = $(CPPUTEST_HOME)/lib/$(TARGET_PLATFORM)
48
49 INCLUDE_DIRS = \
50 $(CPPUTEST_HOME)/include \
51 $(SRC_DIRS) \
52 $(CPPUTEST_HOME)/examples/ApplicationLib \
53
54 # name of extension of output file. Default Keil MDK-ARM extension is .axf which is elf format
55 # .axf will be .elf for eclipse debug
56 OUTFILE_EXT = elf
57
58 # output filename, mapfile (.map), hexfile (.mot)
59 OUTNAME = $(COMPONENT_NAME)
60 OUTFILE = $(OUTNAME).$(OUTFILE_EXT)
61 HEXFILE = $(OUTNAME).mot
62 MAPFILE = $(OUTNAME).map
63
64 # CYGWIN path
65 CYGWIN =C:/CYGWIN/bin
66 MKDIR =$(CYGWIN)/mkdir
67 RM =$(CYGWIN)/rm
68 TOUCH =$(CYGWIN)/touch
69 ECHO =$(CYGWIN)/echo
70
71 KEIL_DIR=D:/Keil/ARM/ARMCC
72 CC=$(KEIL_DIR)/bin/armcc.exe
73 AS=$(KEIL_DIR)/bin/armasm.exe
74 AR=$(KEIL_DIR)/bin/armar.exe
75 LD=$(KEIL_DIR)/bin/armlink.exe
76 FROMELF=$(KEIL_DIR)/bin/fromelf.exe
77 # armcc system include path
78 SYS_INCLUDE_DIRS =$(KEIL_DIR)/include
79
80 JFLASH ="C:/Program Files (x86)/SEGGER/JLink_V490b/JFlash.exe"
81 JFLASHPRJ =AT91SAM7A3.jflash
82 LDSCRIPT = ROM.sct
83
84 CPUFLAGS =--cpu=$(CPU)
85 ifeq ($(CPU_MODE), thumb)
86 CPUFLAGS +=--apcs=/interwork
87 endif
88 DEPFLAGS =-M \
89 $(INCLUDES) \
90 --depend_format=unix_escaped \
91 --depend_single_line \
92 --no_depend_system_headers
93
94 OPTFLAGS =-O3
95
96 CPPUTEST_CPPFLAGS =$(CPUFLAGS) \
97 $(OPTFLAGS) \
98 -c \
99 -g \
100 $(INCLUDES) \
101 --$(CPU_MODE) \
102 --exceptions \
103 -D__CLK_TCK=1000 \
104
105 CPPUTEST_LDFLAGS =$(CPUFLAGS) \
106 --strict \
107 --entry=Reset_Handler \
108 --summary_stderr \
109 --map \
110 --callgraph \
111 --info=summarysizes \
112 --info=sizes \
113 --info=totals \
114 --info=veneers\
115 --load_addr_map_info \
116 --library_type=standardlib \
117 --remove \
118 --debug \
119
120 ARFLAGS = --debug_symbols
121
122
123 # new and delete for memory leak detection on by default
124 ifndef CPPUTEST_USE_MEM_LEAK_DETECTION
125 CPPUTEST_USE_MEM_LEAK_DETECTION = Y
126 endif
127
128 # Use the standard C library
129 ifndef CPPUTEST_USE_STD_C_LIB
130 CPPUTEST_USE_STD_C_LIB = Y
131 endif
132
133 # Use the standard C++ library
134 ifndef CPPUTEST_USE_STD_CPP_LIB
135 CPPUTEST_USE_STD_CPP_LIB = Y
136 endif
137
138 # No extentions is default
139 ifndef CPPUTEST_USE_EXTENSIONS
140 CPPUTEST_USE_EXTENSIONS = N
141 endif
142
143 # No VPATH is default
144 ifndef CPPUTEST_USE_VPATH
145 CPPUTEST_USE_VPATH = N
146 endif
147 # Make empty, instead of 'N', for usage in $(if ) conditionals
148 ifneq ($(CPPUTEST_USE_VPATH), Y)
149 CPPUTEST_USE_VPATH =
150 endif
151
152 # Without the C library, we'll need to disable the C++ library and ...
153 ifeq ($(CPPUTEST_USE_STD_C_LIB), N)
154 CPPUTEST_USE_STD_CPP_LIB = N
155 CPPUTEST_USE_MEM_LEAK_DETECTION = N
156 CPPUTEST_CPPFLAGS += -DCPPUTEST_STD_C_LIB_DISABLED
157 CPPUTEST_LDFLAGS +=--no_scanlib
158 else
159 INCLUDE_DIRS +=$(SYS_INCLUDE_DIRS)
160 endif
161
162
163 ifeq ($(CPPUTEST_USE_MEM_LEAK_DETECTION), N)
164 CPPUTEST_CPPFLAGS += -DCPPUTEST_MEM_LEAK_DETECTION_DISABLED
165 else
166 ifndef CPPUTEST_MEMLEAK_DETECTOR_NEW_MACRO_FILE
167 CPPUTEST_MEMLEAK_DETECTOR_NEW_MACRO_FILE = -include $(CPPUTEST_HOME)/include/CppUTest/MemoryLeakDetectorNewMacros.h
168 endif
169 ifndef CPPUTEST_MEMLEAK_DETECTOR_MALLOC_MACRO_FILE
170 CPPUTEST_MEMLEAK_DETECTOR_MALLOC_MACRO_FILE = -include $(CPPUTEST_HOME)/include/CppUTest/MemoryLeakDetectorMallocMacros.h
171 endif
172 endif
173
174
175 ifeq ($(CPPUTEST_USE_STD_CPP_LIB), N)
176 CPPUTEST_CPPFLAGS += -DCPPUTEST_STD_CPP_LIB_DISABLED
177 endif
178
179 # Link with CppUTest lib
180 CPPUTEST_LIB = $(CPPUTEST_LIB_LINK_DIR)/libCppUTest.a
181
182 # Link with startup lib
183 CPPUTEST_LIB += $(CPPUTEST_LIB_LINK_DIR)/libStartup_AT91SAM7A3.a
184
185 # Link with CppUTestExt lib
186 ifeq ($(CPPUTEST_USE_EXTENSIONS), Y)
187 CPPUTEST_LIB += $(CPPUTEST_LIB_LINK_DIR)/libCppUTestExt.a
188 endif
189
190 TARGET_LIB = \
191 $(CPPUTEST_LIB_DIR)/lib$(COMPONENT_NAME).a
192
193 ifndef TEST_TARGET
194 ifndef TARGET_PLATFORM
195 TEST_TARGET = $(COMPONENT_NAME)_tests
196 else
197 TEST_TARGET = $(COMPONENT_NAME)_$(TARGET_PLATFORM)_tests
198 endif
199 endif
200
201 #Helper Functions
202 get_src_from_dir = $(wildcard $1/*.cpp) $(wildcard $1/*.cc) $(wildcard $1/*.c) $(wildcard $1/*.asm)
203 get_src_from_dir_list = $(foreach dir, $1, $(call get_src_from_dir,$(dir)))
204 __src_to = $(subst .c,$1, $(subst .cc,$1, $(subst .cpp,$1, $(if $(CPPUTEST_USE_VPATH),$(notdir $2),$2))))
205 src_to = $(addprefix $3/,$(call __src_to,$1,$2))
206 src_to_o = $(call src_to,.o,$1,$2)
207 src_to_d = $(call src_to,.d,$1,$2)
208 time = $(shell date +%s)
209 delta_t = $(eval minus, $1, $2)
210 debug_print_list = $(foreach word,$1,echo " $(word)";) echo
211
212 # исходники программных модулей
213 SRC = $(call get_src_from_dir_list, $(SRC_DIRS)) $(SRC_FILES)
214 OBJ = $(call src_to_o,$(SRC),$(CPPUTEST_OBJS_DIR))
215 # исходники тестов
216 TEST_SRC = $(call get_src_from_dir_list, $(TEST_SRC_DIRS)) $(TEST_FILES)
217 TEST_OBJ = $(call src_to_o,$(TEST_SRC),$(CPPUTEST_OBJS_DIR))
218
219 # If we're using VPATH
220 ALL_SRC = $(SRC) $(TEST_SRC)
221 ifeq ($(CPPUTEST_USE_VPATH), Y)
222 # gather all the source directories and add them
223 VPATH += $(sort $(dir $(ALL_SRC)))
224 # Add the component name to the objs dir path, to differentiate between same-name objects
225 CPPUTEST_OBJS_DIR := $(addsuffix /$(COMPONENT_NAME),$(CPPUTEST_OBJS_DIR))
226 endif
227
228 # for building application library
229 INCLUDES += $(foreach dir, $(INCLUDE_DIRS), -I$(dir))
230 DEP_FILES = $(call src_to_d, $(SRC), $(CPPUTEST_OBJS_DIR))
231 DEP_TEST_FILES = $(call src_to_d, $(TEST_SRC), $(CPPUTEST_OBJS_DIR))
232 STUFF_TO_CLEAN = $(OBJ) $(TEST_OBJ) $(DEP_FILES) $(DEP_TEST_FILES) $(TARGET_LIB)
233
234 #Don't create CRT dependencies when we're cleaning, for instance
235 ifeq (0, $(words $(findstring $(MAKECMDGOALS), $(NODEPS))))
236 -include $(DEP_FILES)
237 endif
238
239 STUFF_TO_CLEAN += $(OUTFILE) $(MAPFILE)
240
241
242 all: $(CPPUTEST_OBJS_DIR)/$(OUTFILE)
243 echo Done!
244
245 $(TARGET_LIB): $(OBJ) | $(CPPUTEST_LIB_DIR)
246 echo Building application library $@
247 $(AR) $(ARFLAGS) --create $@ $^
248
249 $(CPPUTEST_OBJS_DIR)/$(OUTFILE): $(TEST_OBJ) $(CPPUTEST_LIB) $(TARGET_LIB) | ROM.sct Makefile
250 echo Linking!
251 $(LD) $(CPPUTEST_LDFLAGS) $^ --scatter $(LDSCRIPT) --list $(MAPFILE) -o $@
252
253
254 .PHONY: prog
255 prog: $(CPPUTEST_OBJS_DIR)/$(HEXFILE)
256 $(JFLASH) -openprj$(JFLASHPRJ) -open$< -auto -exit
257
258 $(CPPUTEST_OBJS_DIR)/$(HEXFILE): $(CPPUTEST_OBJS_DIR)/$(OUTFILE)
259 echo Converting to Motorola S19
260 $(FROMELF) --m32 --output=$@ $<
261
262 debug:
263 echo
264 echo "Target Source files:"
265 $(call debug_print_list,$(SRC))
266 echo "Target Object files:"
267 $(call debug_print_list,$(OBJ))
268 echo "All Input Dependency files:"
269 $(call debug_print_list,$(DEP_FILES))
270 echo Stuff to clean:
271 $(call debug_print_list,$(STUFF_TO_CLEAN))
272 echo Includes:
273 $(call debug_print_list,$(INCLUDES))
274 echo Directories to create:
275 $(call debug_print_list,$(OBJS_DIRS))
276 echo Directories of CppUTest object files:
277 $(call debug_print_list,$(OBJS_DIR))
278
279 #Don't create dependencies when we're cleaning, for instance
280 ifeq (0, $(words $(findstring $(MAKECMDGOALS), $(NODEPS))))
281 -include $(DEP_FILES)
282 endif
283
284 OBJS_DIRS =$(sort $(dir $(STUFF_TO_CLEAN)))
285
286 $(LIB_DIR) $(OBJS_DIRS):
287 echo Updating directory $@
288 $(MKDIR) -p $@
289
290 #This is the rule for creating the dependency files
291 $(CPPUTEST_OBJS_DIR)/%.d: %.c Makefile | $(OBJS_DIRS)
292 echo Compiling C file $< for dependency. Out file $@.
293 $(CC) $(DEPFLAGS) $< --depend=$@ --depend_target='$(patsubst %.d,%.o,$@)'
294
295 $(CPPUTEST_OBJS_DIR)/%.d: %.cpp Makefile | $(OBJS_DIRS)
296 echo Compiling C++ file $< for dependency. Out file $@.
297 $(CC) $(DEPFLAGS) $< --depend=$@ --depend_target='$(patsubst %.d,%.o,$@)'
298
299 $(CPPUTEST_OBJS_DIR)/%.d: %.cc Makefile | $(OBJS_DIRS)
300 echo Compiling CC++ file $< for dependency. Out file $@.
301 $(CC) $(DEPFLAGS) $< --depend=$@ --depend_target='$(patsubst %.d,%.o,$@)'
302
303 #This rule does the compilation C++ files
304 $(CPPUTEST_OBJS_DIR)/%.o: %.cpp $(CPPUTEST_OBJS_DIR)/%.d
305 echo Compiling C++ file $<. Out file $@
306 $(CC) $(CPPUTEST_CPPFLAGS) $< -o $@
307
308 #This rule does the compilation CC++ files
309 $(CPPUTEST_OBJS_DIR)/%.o: %.cc $(CPPUTEST_OBJS_DIR)/%.d
310 echo Compiling CC++ file $<. Out file $@
311 $(CC) $(CPPUTEST_CPPFLAGS) $< -o $@
312
313 #This rule does the compilation C files
314 $(CPPUTEST_OBJS_DIR)/%.o: %.c $(CPPUTEST_OBJS_DIR)/%.d
315 echo Compiling C file $<. Out file $@
316 $(CC) $(CPPUTEST_CPPFLAGS) $< -o $@
317
318 clean:
319 $(RM) -f $(STUFF_TO_CLEAN)
320
321