3 # Copyright 2002,2003, 2004, 2006 Develer S.r.l. (http://www.develer.com/)
6 # Author: Bernardo Innocenti <bernie@develer.com>
7 # Based on: GCC-AVR standard Makefile part 1, Volker Oth 1/2000
12 # see local pgm_config.mk for programmer customization.
13 -include pgm_config.mk
14 DPROG ?= -V -c stk500 -P /dev/ttyS0
16 # Set to 1 to build for embedded devices.
17 # e.g. produce target.elf instead of target and target_nostrip
21 OPTCFLAGS = -ffunction-sections -fdata-sections
22 #OPTCFLAGS = -funsafe-loop-optimizations
25 #DEBUGCFLAGS = -gdwarf-2
31 # define some variables based on the AVR base path in $(AVR)
36 AS = $(CC) -x assembler-with-cpp
51 FLEXCAT = $(top_srcdir)/tools/flexcat/flexcat
53 # For conversion from ELF to COFF for use in debugging / simulating in AVR Studio or VMLAB.
54 COFFCONVERT=$(OBJCOPY) \
56 --change-section-address .data-0x800000 \
57 --change-section-address .bss-0x800000 \
58 --change-section-address .noinit-0x800000 \
59 --change-section-address .eeprom-0x810000
66 # output format can be srec, ihex (avrobj is always created)
70 # Compiler flags for generating dependencies
73 # Compiler flags for generating source listings
74 LIST_FLAGS = -Wa,-anhlmsd=$(@:.o=.lst)
76 # Linker flags for generating map files
77 ifeq ($(EMBEDDED_TARGET), 1)
78 MAP_FLAGS = -Wl,-Map=$(@:%.elf=%.map),--cref
83 # Compiler warning flags for both C and C++
85 -W -Wformat -Wall -Wundef -Wpointer-arith -Wcast-qual \
86 -Wcast-align -Wwrite-strings -Wsign-compare \
88 -Wextra -Wstrict-aliasing=2 \
89 # -Wunsafe-loop-optimizations
91 # Compiler warning flags for C only
93 -Wmissing-prototypes -Wstrict-prototypes
95 # Default C preprocessor flags (for C, C++ and cpp+as)
98 # Default C compiler flags
99 CFLAGS = $(OPTCFLAGS) $(DEBUGCFLAGS) $(WARNFLAGS) $(C_WARNFLAGS) \
100 $(DEP_FLAGS) $(LIST_FLAGS) -std=gnu99
102 # Default C++ compiler flags
103 CXXFLAGS = $(OPTCFLAGS) $(DEBUGCFLAGS) $(WARNFLAGS) \
104 $(DEP_FLAGS) $(LIST_FLAGS)
106 # Default compiler assembly flags
107 CPPAFLAGS = $(DEBUGCFLAGS) -MMD
109 # Default assembler flags
110 ASFLAGS = $(DEBUGCFLAGS)
112 # Default linker flags
113 #LDFLAGS = $(MAP_FLAGS)
115 #bernie: does not complain for missing symbols!
116 LDFLAGS = $(MAP_FLAGS) -Wl,--gc-sections
119 AVRDUDEFLAGS = $(DPROG)