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 # AVR ISP dongle that blows up easily
22 #DPROG = -V -c stk500 -P /dev/ttyS0
23 #DPROG = -V -c jtag2slow
26 # STK200 parallel cable
27 #DPROG = -c stk200 -E noreset
30 #DPROG = avarice --mkII -j usb -l
32 # PonyProg serial programmer
35 # Set to 1 to build for embedded devices.
36 # e.g. produce target.elf instead of target and target_nostrip
40 OPTCFLAGS = -ffunction-sections -fdata-sections
41 #OPTCFLAGS = -funsafe-loop-optimizations
44 #DEBUGCFLAGS = -gdwarf-2
50 # define some variables based on the AVR base path in $(AVR)
55 AS = $(CC) -x assembler-with-cpp
70 FLEXCAT = $(top_srcdir)/tools/flexcat/flexcat
72 # For conversion from ELF to COFF for use in debugging / simulating in AVR Studio or VMLAB.
73 COFFCONVERT=$(OBJCOPY) \
75 --change-section-address .data-0x800000 \
76 --change-section-address .bss-0x800000 \
77 --change-section-address .noinit-0x800000 \
78 --change-section-address .eeprom-0x810000
85 # output format can be srec, ihex (avrobj is always created)
89 # Compiler flags for generating dependencies
92 # Compiler flags for generating source listings
93 LIST_FLAGS = -Wa,-anhlmsd=$(@:.o=.lst)
95 # Linker flags for generating map files
96 ifeq ($(EMBEDDED_TARGET), 1)
97 MAP_FLAGS = -Wl,-Map=$(@:%.elf=%.map),--cref
102 # Compiler warning flags for both C and C++
104 -W -Wformat -Wall -Wundef -Wpointer-arith -Wcast-qual \
105 -Wcast-align -Wwrite-strings -Wsign-compare \
107 -Wextra -Wstrict-aliasing=2 \
108 # -Wunsafe-loop-optimizations
110 # Compiler warning flags for C only
112 -Wmissing-prototypes -Wstrict-prototypes
114 # Default C preprocessor flags (for C, C++ and cpp+as)
117 # Default C compiler flags
118 CFLAGS = $(OPTCFLAGS) $(DEBUGCFLAGS) $(WARNFLAGS) $(C_WARNFLAGS) \
119 $(DEP_FLAGS) $(LIST_FLAGS) -std=gnu99
121 # Default C++ compiler flags
122 CXXFLAGS = $(OPTCFLAGS) $(DEBUGCFLAGS) $(WARNFLAGS) \
123 $(DEP_FLAGS) $(LIST_FLAGS)
125 # Default compiler assembly flags
126 CPPAFLAGS = $(DEBUGCFLAGS) -MMD
128 # Default assembler flags
129 ASFLAGS = $(DEBUGCFLAGS)
131 # Default linker flags
132 #LDFLAGS = $(MAP_FLAGS)
134 #bernie: does not complain for missing symbols!
135 LDFLAGS = $(MAP_FLAGS) -Wl,--gc-sections
138 AVRDUDEFLAGS = $(DPROG)