3 # Copyright 2002,2003, 2004, 2006 Develer S.r.l. (http://www.develer.com/)
7 # GCC-AVR standard Makefile part 1
10 # Author: Bernardo Innocenti <bernie@develer.com>
17 # see local pgm_config.mk for programmer customization.
18 -include pgm_config.mk
19 DPROG ?= -V -c stk500 -P /dev/ttyS0
21 # Set to 1 to build for embedded devices.
22 # e.g. produce target.elf instead of target and target_nostrip
26 OPTCFLAGS = -ffunction-sections -fdata-sections
27 #OPTCFLAGS = -funsafe-loop-optimizations
30 #DEBUGCFLAGS = -gdwarf-2
36 # define some variables based on the AVR base path in $(AVR)
41 AS = $(CC) -x assembler-with-cpp
56 FLEXCAT = $(top_srcdir)/tools/flexcat/flexcat
58 # For conversion from ELF to COFF for use in debugging / simulating in AVR Studio or VMLAB.
59 COFFCONVERT=$(OBJCOPY) \
61 --change-section-address .data-0x800000 \
62 --change-section-address .bss-0x800000 \
63 --change-section-address .noinit-0x800000 \
64 --change-section-address .eeprom-0x810000
71 # output format can be srec, ihex (avrobj is always created)
75 # Compiler flags for generating dependencies
78 # Compiler flags for generating source listings
79 LIST_FLAGS = -Wa,-anhlmsd=$(@:.o=.lst)
81 # Linker flags for generating map files
82 ifeq ($(EMBEDDED_TARGET), 1)
83 MAP_FLAGS = -Wl,-Map=$(@:%.elf=%.map),--cref
88 # Compiler warning flags for both C and C++
90 -W -Wformat -Wall -Wundef -Wpointer-arith -Wcast-qual \
91 -Wcast-align -Wwrite-strings -Wsign-compare \
93 -Wextra -Wstrict-aliasing=2 \
94 # -Wunsafe-loop-optimizations
96 # Compiler warning flags for C only
98 -Wmissing-prototypes -Wstrict-prototypes
100 # Default C preprocessor flags (for C, C++ and cpp+as)
103 # Default C compiler flags
104 CFLAGS = $(OPTCFLAGS) $(DEBUGCFLAGS) $(WARNFLAGS) $(C_WARNFLAGS) \
105 $(DEP_FLAGS) $(LIST_FLAGS) -std=gnu99
107 # Default C++ compiler flags
108 CXXFLAGS = $(OPTCFLAGS) $(DEBUGCFLAGS) $(WARNFLAGS) \
109 $(DEP_FLAGS) $(LIST_FLAGS)
111 # Default compiler assembly flags
112 CPPAFLAGS = $(DEBUGCFLAGS) -MMD
114 # Default assembler flags
115 ASFLAGS = $(DEBUGCFLAGS)
117 # Default linker flags
118 #LDFLAGS = $(MAP_FLAGS)
120 #bernie: does not complain for missing symbols!
121 LDFLAGS = $(MAP_FLAGS) -Wl,--gc-sections
124 AVRDUDEFLAGS = $(DPROG)