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
38 OBJCOPY = $(CROSS)objcopy
50 FLEXCAT = $(top_srcdir)/tools/flexcat/flexcat
52 # For conversion from ELF to COFF for use in debugging / simulating in AVR Studio or VMLAB.
53 COFFCONVERT=$(OBJCOPY) \
55 --change-section-address .data-0x800000 \
56 --change-section-address .bss-0x800000 \
57 --change-section-address .noinit-0x800000 \
58 --change-section-address .eeprom-0x810000
65 # output format can be srec, ihex (avrobj is always created)
69 # Compiler flags for generating dependencies
72 # Compiler flags for generating source listings
73 LIST_FLAGS = -Wa,-anhlmsd=$(@:.o=.lst)
75 # Linker flags for generating map files
76 ifeq ($(EMBEDDED_TARGET), 1)
77 MAP_FLAGS = -Wl,-Map=$(@:%.elf=%.map),--cref
82 # Compiler warning flags for both C and C++
84 -W -Wformat -Wall -Wundef -Wpointer-arith -Wcast-qual \
85 -Wcast-align -Wwrite-strings -Wsign-compare \
86 -Wmissing-prototypes -Wmissing-noreturn \
87 -Wextra -Wstrict-aliasing=2 \
88 # -Wunsafe-loop-optimizations
90 # Compiler warning flags for C only
92 -Wmissing-prototypes -Wstrict-prototypes
94 # Default C preprocessor flags (for C, C++ and cpp+as)
97 # Default C compiler flags
98 CFLAGS = $(OPTCFLAGS) $(DEBUGCFLAGS) $(WARNFLAGS) $(C_WARNFLAGS) \
99 $(DEP_FLAGS) $(LIST_FLAGS) -std=gnu99
101 # Default C++ compiler flags
102 CXXFLAGS = $(OPTCFLAGS) $(DEBUGCFLAGS) $(WARNFLAGS) \
103 $(DEP_FLAGS) $(LIST_FLAGS)
105 # Default compiler assembly flags
106 CPPAFLAGS = $(DEBUGCFLAGS) -MMD
108 # Default assembler flags
109 ASFLAGS = $(DEBUGCFLAGS)
111 # Default linker flags
112 #LDFLAGS = $(MAP_FLAGS)
114 #bernie: does not complain for missing symbols!
115 LDFLAGS = $(MAP_FLAGS) -Wl,--gc-sections
118 AVRDUDEFLAGS = $(DPROG)