]> git.sur5r.net Git - freertos/blob - FreeRTOS/Demo/CORTEX_ATSAM3S-EK2_Atmel_Studio/src/asf/sam/utils/make/Makefile.in
Add demo for SAM3S-EK2.
[freertos] / FreeRTOS / Demo / CORTEX_ATSAM3S-EK2_Atmel_Studio / src / asf / sam / utils / make / Makefile.in
1 # List of available make goals:\r
2 #\r
3 # all                     Default target, builds the project\r
4 # clean                   Clean up the project\r
5 # rebuild                 Rebuild the project\r
6 # debug_flash             Builds the project and debug in flash\r
7 # debug_sram              Builds the project and debug in sram\r
8 #\r
9 # doc                     Build the documentation\r
10 # cleandoc                Clean up the documentation\r
11 # rebuilddoc              Rebuild the documentation\r
12 #\r
13 # \file\r
14 #\r
15 # Copyright (c) 2011 - 2012 Atmel Corporation. All rights reserved.\r
16 #\r
17 # \asf_license_start\r
18 #\r
19 # \page License\r
20 #\r
21 # Redistribution and use in source and binary forms, with or without\r
22 # modification, are permitted provided that the following conditions are met:\r
23 #\r
24 # 1. Redistributions of source code must retain the above copyright notice,\r
25 #    this list of conditions and the following disclaimer.\r
26 #\r
27 # 2. Redistributions in binary form must reproduce the above copyright notice,\r
28 #    this list of conditions and the following disclaimer in the documentation\r
29 #    and/or other materials provided with the distribution.\r
30 #\r
31 # 3. The name of Atmel may not be used to endorse or promote products derived\r
32 #    from this software without specific prior written permission.\r
33 #\r
34 # 4. This software may only be redistributed and used in connection with an\r
35 #    Atmel microcontroller product.\r
36 #\r
37 # THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED\r
38 # WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\r
39 # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE\r
40 # EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR\r
41 # ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\r
42 # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\r
43 # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\r
44 # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,\r
45 # STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN\r
46 # ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE\r
47 # POSSIBILITY OF SUCH DAMAGE.\r
48 #\r
49 # \asf_license_stop\r
50 #\r
51 \r
52 # Include the config.mk file from the current working path, e.g., where the\r
53 # user called make.\r
54 include config.mk\r
55 \r
56 # Tool to use to generate documentation from the source code\r
57 DOCGEN          ?= doxygen\r
58 \r
59 # Look for source files relative to the top-level source directory\r
60 VPATH           := $(PRJ_PATH)\r
61 \r
62 # Output target file\r
63 project_type    := $(PROJECT_TYPE)\r
64 \r
65 # Output target file\r
66 ifeq ($(project_type),flash)\r
67 target          := $(TARGET_FLASH)\r
68 linker_script   := $(PRJ_PATH)/$(LINKER_SCRIPT_FLASH)\r
69 debug_script    := $(PRJ_PATH)/$(DEBUG_SCRIPT_FLASH)\r
70 else\r
71 target          := $(TARGET_SRAM)\r
72 linker_script   := $(PRJ_PATH)/$(LINKER_SCRIPT_SRAM)\r
73 debug_script    := $(PRJ_PATH)/$(DEBUG_SCRIPT_SRAM)\r
74 endif\r
75 \r
76 # Output project name (target name minus suffix)\r
77 project         := $(basename $(target))\r
78 \r
79 # Output target file (typically ELF or static library)\r
80 ifeq ($(suffix $(target)),.a)\r
81 target_type     := lib\r
82 else\r
83 ifeq ($(suffix $(target)),.elf)\r
84 target_type     := elf\r
85 else\r
86 $(error "Target type $(target_type) is not supported")\r
87 endif\r
88 endif\r
89 \r
90 # Allow override of operating system detection. The user can add OS=Linux or\r
91 # OS=Windows on the command line to explicit set the host OS.\r
92 #\r
93 # This allows to work around broken uname utility on certain systems.\r
94 ifdef OS\r
95   ifeq ($(strip $(OS)), Linux)\r
96     os_type     := Linux\r
97   endif\r
98         ifeq (Windows,$(findstring Windows,$(OS)))\r
99     os_type     := windows32_64\r
100   endif\r
101 endif\r
102 \r
103 #os_type         ?= $(strip $(shell uname))\r
104 \r
105 #ifeq ($(os_type),windows32)\r
106 #os              := Windows\r
107 #else\r
108 #ifeq ($(os_type),windows64)\r
109 #os              := Windows\r
110 #else\r
111 #ifeq ($(os_type),)\r
112 #os              := Windows\r
113 #else\r
114 ## Default to Linux style operating system. Both Cygwin and mingw are fully\r
115 ## compatible (for this Makefile) with Linux.\r
116 #os              := Linux\r
117 #endif\r
118 #endif\r
119 #endif\r
120 \r
121 ifeq ($(os_type),windows32_64)\r
122 os              := Windows\r
123 else\r
124 ifeq ($(os_type),Linux)\r
125 os              := Linux\r
126 else\r
127 os              := Linux\r
128 endif\r
129 endif\r
130 \r
131 # Output documentation directory and configuration file.\r
132 docdir          := ../doxygen/html\r
133 doccfg          := ../doxygen/doxyfile.doxygen\r
134 \r
135 CROSS           ?= arm-none-eabi-\r
136 AR              := $(CROSS)ar\r
137 AS              := $(CROSS)as\r
138 CC              := $(CROSS)gcc\r
139 CPP             := $(CROSS)gcc -E\r
140 CXX             := $(CROSS)g++\r
141 LD              := $(CROSS)g++\r
142 NM              := $(CROSS)nm\r
143 OBJCOPY         := $(CROSS)objcopy\r
144 OBJDUMP         := $(CROSS)objdump\r
145 SIZE            := $(CROSS)size\r
146 GDB             := $(CROSS)gdb\r
147 \r
148 RM              := cs-rm -f\r
149 ifeq ($(os),Windows)\r
150 #RMDIR           := rmdir /S /Q\r
151 RMDIR           := cs-rm  -rf\r
152 else\r
153 RMDIR           := rmdir -p --ignore-fail-on-non-empty\r
154 endif\r
155 \r
156 # Strings for beautifying output\r
157 MSG_CLEAN_FILES         = "RM      *.o *.d"\r
158 MSG_CLEAN_DIRS          = "RMDIR   $(strip $(clean-dirs))"\r
159 MSG_CLEAN_DOC           = "RMDIR   $(docdir)"\r
160 MSG_MKDIR               = "MKDIR   $(dir $@)"\r
161 \r
162 MSG_INFO                = "INFO    "\r
163 \r
164 MSG_ARCHIVING           = "AR      $@"\r
165 MSG_ASSEMBLING          = "AS      $@"\r
166 MSG_BINARY_IMAGE        = "OBJCOPY $@"\r
167 MSG_COMPILING           = "CC      $@"\r
168 MSG_COMPILING_CXX       = "CXX     $@"\r
169 MSG_EXTENDED_LISTING    = "OBJDUMP $@"\r
170 MSG_IHEX_IMAGE          = "OBJCOPY $@"\r
171 MSG_LINKING             = "LN      $@"\r
172 MSG_PREPROCESSING       = "CPP     $@"\r
173 MSG_SIZE                = "SIZE    $@"\r
174 MSG_SYMBOL_TABLE        = "NM      $@"\r
175 \r
176 MSG_GENERATING_DOC      = "DOXYGEN $(docdir)"\r
177 \r
178 # Don't use make's built-in rules and variables\r
179 MAKEFLAGS       += -rR\r
180 \r
181 # Don't print 'Entering directory ...'\r
182 MAKEFLAGS       += --no-print-directory\r
183 \r
184 # Function for reversing the order of a list\r
185 reverse = $(if $(1),$(call reverse,$(wordlist 2,$(words $(1)),$(1)))) $(firstword $(1))\r
186 \r
187 # Hide command output by default, but allow the user to override this\r
188 # by adding V=1 on the command line.\r
189 #\r
190 # This is inspired by the Kbuild system used by the Linux kernel.\r
191 ifdef V\r
192   ifeq ("$(origin V)", "command line")\r
193     VERBOSE = $(V)\r
194   endif\r
195 endif\r
196 ifndef VERBOSE\r
197   VERBOSE = 0\r
198 endif\r
199 \r
200 ifeq ($(VERBOSE), 1)\r
201   Q =\r
202 else\r
203 #  Q = @\r
204   Q =\r
205 endif\r
206 \r
207 arflags-gnu-y           := $(ARFLAGS)\r
208 asflags-gnu-y           := $(ASFLAGS)\r
209 cflags-gnu-y            := $(CFLAGS)\r
210 cxxflags-gnu-y          := $(CXXFLAGS)\r
211 cppflags-gnu-y          := $(CPPFLAGS)\r
212 cpuflags-gnu-y          :=\r
213 dbgflags-gnu-y          := $(DBGFLAGS)\r
214 libflags-gnu-y          := $(foreach LIB,$(LIBS),-l$(LIB))\r
215 ldflags-gnu-y           := $(LDFLAGS)\r
216 flashflags-gnu-y        :=\r
217 clean-files             :=\r
218 clean-dirs              :=\r
219 \r
220 clean-files             += $(wildcard $(target) $(project).map)\r
221 clean-files             += $(wildcard $(project).hex $(project).bin)\r
222 clean-files             += $(wildcard $(project).lss $(project).sym)\r
223 clean-files             += $(wildcard $(build))\r
224 \r
225 # Use pipes instead of temporary files for communication between processes\r
226 cflags-gnu-y    += -pipe\r
227 asflags-gnu-y   += -pipe\r
228 ldflags-gnu-y   += -pipe\r
229 \r
230 # Archiver flags.\r
231 arflags-gnu-y   += rcs\r
232 \r
233 # Always enable warnings. And be very careful about implicit\r
234 # declarations.\r
235 cflags-gnu-y    += -Wall -Wstrict-prototypes -Wmissing-prototypes\r
236 cflags-gnu-y    += -Werror-implicit-function-declaration\r
237 cxxflags-gnu-y  += -Wall\r
238 # IAR doesn't allow arithmetic on void pointers, so warn about that.\r
239 cflags-gnu-y    += -Wpointer-arith\r
240 cxxflags-gnu-y  += -Wpointer-arith\r
241 \r
242 # Preprocessor flags.\r
243 cppflags-gnu-y  += $(foreach INC,$(addprefix $(PRJ_PATH)/,$(INC_PATH)),-I$(INC))\r
244 asflags-gnu-y   += $(foreach INC,$(addprefix $(PRJ_PATH)/,$(INC_PATH)),'-Wa,-I$(INC)')\r
245 \r
246 # CPU specific flags.\r
247 cpuflags-gnu-y  += -mcpu=$(ARCH) -mthumb -D=__$(PART)__\r
248 \r
249 # Dependency file flags.\r
250 depflags        = -MD -MP -MQ $@\r
251 \r
252 # Debug specific flags.\r
253 ifdef BUILD_DEBUG_LEVEL\r
254 dbgflags-gnu-y  += -g$(BUILD_DEBUG_LEVEL)\r
255 else\r
256 dbgflags-gnu-y  += -g3\r
257 endif\r
258 \r
259 # Optimization specific flags.\r
260 ifdef BUILD_OPTIMIZATION\r
261 optflags-gnu-y  = -O$(BUILD_OPTIMIZATION)\r
262 else\r
263 optflags-gnu-y  = $(OPTIMIZATION)\r
264 endif\r
265 \r
266 # Always preprocess assembler files.\r
267 asflags-gnu-y   += -x assembler-with-cpp\r
268 # Compile C files using the GNU99 standard.\r
269 cflags-gnu-y    += -std=gnu99\r
270 # Compile C++ files using the GNU++98 standard.\r
271 cxxflags-gnu-y  += -std=gnu++98\r
272 \r
273 \r
274 # Separate each function and data into its own separate section to allow\r
275 # garbage collection of unused sections.\r
276 cflags-gnu-y    += -ffunction-sections -fdata-sections\r
277 cxxflags-gnu-y  += -ffunction-sections -fdata-sections\r
278 \r
279 # Various cflags.\r
280 cflags-gnu-y += -Wchar-subscripts -Wcomment -Wformat=2 -Wimplicit-int\r
281 cflags-gnu-y += -Wmain -Wparentheses\r
282 cflags-gnu-y += -Wsequence-point -Wreturn-type -Wswitch -Wtrigraphs -Wunused\r
283 cflags-gnu-y += -Wuninitialized -Wunknown-pragmas -Wfloat-equal -Wundef\r
284 cflags-gnu-y += -Wshadow -Wbad-function-cast -Wwrite-strings\r
285 cflags-gnu-y += -Wsign-compare -Waggregate-return \r
286 cflags-gnu-y += -Wmissing-declarations\r
287 cflags-gnu-y += -Wformat -Wmissing-format-attribute -Wno-deprecated-declarations\r
288 cflags-gnu-y += -Wpacked -Wredundant-decls -Wnested-externs -Winline -Wlong-long\r
289 cflags-gnu-y += -Wunreachable-code\r
290 cflags-gnu-y += -Wcast-align\r
291 cflags-gnu-y += --param max-inline-insns-single=500\r
292 \r
293 # To reduce application size use only integer printf function.\r
294 cflags-gnu-y += -Dprintf=iprintf\r
295 \r
296 # Garbage collect unreferred sections when linking.\r
297 ldflags-gnu-y   += -Wl,--gc-sections\r
298 \r
299 # Use the linker script if provided by the project.\r
300 ifneq ($(strip $(linker_script)),)\r
301 ldflags-gnu-y   += -Wl,-T $(linker_script)\r
302 endif\r
303 \r
304 # Output a link map file and a cross reference table\r
305 ldflags-gnu-y   += -Wl,-Map=$(project).map,--cref\r
306 \r
307 # Add library search paths relative to the top level directory.\r
308 ldflags-gnu-y   += $(foreach _LIB_PATH,$(addprefix $(PRJ_PATH)/,$(LIB_PATH)),-L$(_LIB_PATH))\r
309 \r
310 a_flags  = $(cpuflags-gnu-y) $(depflags) $(cppflags-gnu-y) $(asflags-gnu-y) -D__ASSEMBLY__\r
311 c_flags  = $(cpuflags-gnu-y) $(dbgflags-gnu-y) $(depflags) $(optflags-gnu-y) $(cppflags-gnu-y) $(cflags-gnu-y)\r
312 cxx_flags= $(cpuflags-gnu-y) $(dbgflags-gnu-y) $(depflags) $(optflags-gnu-y) $(cppflags-gnu-y) $(cxxflags-gnu-y)\r
313 l_flags  = -Wl,--entry=Reset_Handler -Wl,--cref $(cpuflags-gnu-y) $(optflags-gnu-y) $(ldflags-gnu-y)\r
314 ar_flags = $(arflags-gnu-y)\r
315 \r
316 # Source files list and part informations must already be included before\r
317 # running this makefile\r
318 \r
319 # If a custom build directory is specified, use it -- force trailing / in directory name.\r
320 ifdef BUILD_DIR\r
321         build-dir       := $(dir $(BUILD_DIR))$(if $(notdir $(BUILD_DIR)),$(notdir $(BUILD_DIR))/)\r
322 else\r
323         build-dir        =\r
324 endif\r
325 \r
326 # Create object files list from source files list.\r
327 obj-y                   := $(addprefix $(build-dir), $(addsuffix .o,$(basename $(CSRCS) $(ASSRCS))))\r
328 # Create dependency files list from source files list.\r
329 dep-files               := $(wildcard $(foreach f,$(obj-y),$(basename $(f)).d))\r
330 \r
331 clean-files             += $(wildcard $(obj-y))\r
332 clean-files             += $(dep-files)\r
333 \r
334 clean-dirs              += $(call reverse,$(sort $(wildcard $(dir $(obj-y)))))\r
335 \r
336 .PHONY: all\r
337 \r
338 # Default target.\r
339 .PHONY: all\r
340 ifeq ($(project_type),all)\r
341 all:\r
342         $(MAKE) all PROJECT_TYPE=flash\r
343         $(MAKE) all PROJECT_TYPE=sram\r
344 else\r
345 ifeq ($(target_type),lib)\r
346 all: $(target) $(project).lss $(project).sym\r
347 else\r
348 ifeq ($(target_type),elf)\r
349 all: $(target) $(project).lss $(project).sym $(project).hex $(project).bin\r
350 endif\r
351 endif\r
352 endif\r
353 \r
354 # Default target.\r
355 .PHONY: os\r
356 os:\r
357         @echo OS '$(OS)'\r
358         @echo os type '$(os_type)'\r
359         @echo os '$(os)'\r
360         @echo '$(findstring Windows,$(OS))'\r
361 \r
362 # Clean up the project.\r
363 .PHONY: clean\r
364 clean:\r
365         @$(if $(strip $(clean-files)),echo $(MSG_CLEAN_FILES))\r
366         $(if $(strip $(clean-files)),$(Q)$(RM) $(clean-files),)\r
367         @$(if $(strip $(clean-dirs)),echo $(MSG_CLEAN_DIRS))\r
368 # Remove created directories, and make sure we only remove existing\r
369 # directories, since recursive rmdir might help us a bit on the way.\r
370 ifeq ($(os),Windows)\r
371         $(Q)$(if $(strip $(clean-dirs)),                        \\r
372                         $(RMDIR) $(strip $(subst /,\,$(clean-dirs))))\r
373 else\r
374         $(Q)$(if $(strip $(clean-dirs)),                        \\r
375                 for directory in $(strip $(clean-dirs)); do     \\r
376                         if [ -d "$$directory" ]; then           \\r
377                                 $(RMDIR) $$directory;           \\r
378                         fi                                      \\r
379                 done                                            \\r
380         )\r
381 endif\r
382 \r
383 # Rebuild the project.\r
384 .PHONY: rebuild\r
385 rebuild: clean all\r
386 \r
387 # Debug the project in flash.\r
388 .PHONY: debug_flash\r
389 debug_flash: all\r
390         $(GDB) -x "$(PRJ_PATH)/$(DEBUG_SCRIPT_FLASH)" -ex "reset" -readnow -se $(TARGET_FLASH)\r
391 \r
392 # Debug the project in sram.\r
393 .PHONY: debug_sram\r
394 debug_sram: all\r
395         $(GDB) -x "$(PRJ_PATH)/$(DEBUG_SCRIPT_SRAM)" -ex "reset" -readnow -se $(TARGET_SRAM)\r
396 \r
397 .PHONY: objfiles\r
398 objfiles: $(obj-y)\r
399 \r
400 # Create object files from C source files.\r
401 $(build-dir)%.o: %.c $(PRJ_PATH)/sam/utils/make/Makefile.in config.mk\r
402         @echo $(MSG_MKDIR)\r
403 ifeq ($(os),Windows)\r
404         -mkdir $(subst /,\,$(dir $@))\r
405 else\r
406         -mkdir -p $(dir $@)\r
407 endif\r
408         @echo $(MSG_COMPILING)\r
409         $(Q)$(CC) $(c_flags) -c $< -o $@\r
410 \r
411 # Create object files from C++ source files.\r
412 $(build-dir)%.o: %.cpp $(PRJ_PATH)/sam/utils/make/Makefile.in config.mk\r
413         @echo $(MSG_MKDIR)\r
414 ifeq ($(os),Windows)\r
415         -mkdir $(subst /,\,$(dir $@))\r
416 else\r
417         -mkdir -p $(dir $@)\r
418 endif\r
419         @echo $(MSG_COMPILING_CXX)\r
420         $(Q)$(CXX) $(cxx_flags) -c $< -o $@\r
421 \r
422 # Preprocess and assemble: create object files from assembler source files.\r
423 $(build-dir)%.o: %.S $(PRJ_PATH)/sam/utils/make/Makefile.in config.mk\r
424         @echo $(MSG_MKDIR)\r
425 ifeq ($(os),Windows)\r
426         -mkdir $(subst /,\,$(dir $@))\r
427 else\r
428         -mkdir -p $(dir $@)\r
429 endif\r
430         @echo $(MSG_ASSEMBLING)\r
431         $(Q)$(CC) $(a_flags) -c $< -o $@\r
432 \r
433 # Include all dependency files to add depedency to all header files in use.\r
434 include $(dep-files)\r
435 \r
436 ifeq ($(target_type),lib)\r
437 # Archive object files into an archive\r
438 $(target): $(PRJ_PATH)/sam/utils/make/Makefile.in config.mk $(obj-y)\r
439         @echo $(MSG_ARCHIVING)\r
440         $(Q)$(AR) $(ar_flags) $@ $(obj-y)\r
441         @echo $(MSG_SIZE)\r
442         $(Q)$(SIZE) -Bxt $@\r
443 else\r
444 ifeq ($(target_type),elf)\r
445 # Link the object files into an ELF file. Also make sure the target is rebuilt\r
446 # if the common Makefile.in or project config.mk is changed.\r
447 $(target): $(linker_script) $(PRJ_PATH)/sam/utils/make/Makefile.in config.mk $(obj-y)\r
448         @echo $(MSG_LINKING)\r
449         @echo $(Q)$(LD) $(l_flags) $(obj-y) $(libflags-gnu-y) -o $@\r
450         $(Q)$(LD) $(l_flags) $(obj-y) $(libflags-gnu-y) -o $@\r
451         @echo $(MSG_SIZE)\r
452         $(Q)$(SIZE) -Ax $@\r
453         $(Q)$(SIZE) -Bx $@\r
454 endif\r
455 endif\r
456 \r
457 # Create extended function listing from target output file.\r
458 %.lss: $(target)\r
459         @echo $(MSG_EXTENDED_LISTING)\r
460         $(Q)$(OBJDUMP) -h -S $< > $@\r
461 \r
462 # Create symbol table from target output file.\r
463 %.sym: $(target)\r
464         @echo $(MSG_SYMBOL_TABLE)\r
465         $(Q)$(NM) -n $< > $@\r
466 \r
467 # Create Intel HEX image from ELF output file.\r
468 %.hex: $(target)\r
469         @echo $(MSG_IHEX_IMAGE)\r
470         $(Q)$(OBJCOPY) -O ihex $(flashflags-gnu-y)  $< $@\r
471 \r
472 # Create binary image from ELF output file.\r
473 %.bin: $(target)\r
474         @echo $(MSG_BINARY_IMAGE)\r
475         $(Q)$(OBJCOPY) -O binary $< $@\r
476 \r
477 # Provide information about the detected host operating system.\r
478 .SECONDARY: info-os\r
479 info-os:\r
480         @echo $(MSG_INFO)$(os) build host detected\r
481 \r
482 # Build Doxygen generated documentation.\r
483 .PHONY: doc\r
484 doc:\r
485         @echo $(MSG_GENERATING_DOC)\r
486         $(Q)cd $(dir $(doccfg)) && $(DOCGEN) $(notdir $(doccfg))\r
487 \r
488 # Clean Doxygen generated documentation.\r
489 .PHONY: cleandoc\r
490 cleandoc:\r
491         @$(if $(wildcard $(docdir)),echo $(MSG_CLEAN_DOC))\r
492         $(Q)$(if $(wildcard $(docdir)),$(RM) --recursive $(docdir))\r
493 \r
494 # Rebuild the Doxygen generated documentation.\r
495 .PHONY: rebuilddoc\r
496 rebuilddoc: cleandoc doc\r