Setup for AVR development.
[bertos.git] / config.mk
1 #
2 # $Id$
3 # Copyright 2002,2003, 2004, 2006 Develer S.r.l. (http://www.develer.com/)
4 # All rights reserved.
5 #
6 # Based on:
7 #   GCC-AVR standard Makefile part 1
8 #   Volker Oth 1/2000
9 #
10 # Author: Bernardo Innocenti <bernie@develer.com>
11 #
12 # $Log$
13 # Revision 1.3  2006/05/18 00:40:10  bernie
14 # Setup for AVR development.
15 #
16 # Revision 1.2  2006/03/27 04:48:33  bernie
17 # Add CXXFLAGS; Add recursive targets.
18 #
19 # Revision 1.1  2006/03/22 09:51:53  bernie
20 # Add build infrastructure.
21 #
22 #
23
24 #
25 # Programmer type
26 #
27 # AVR ISP dongle that blows up easily
28 DPROG = -V -c stk500 -P /dev/ttyS0
29
30 # STK200 parallel cable
31 #DPROG = -c stk200 -E noreset
32
33 # PonyProg serial programmer
34 #DPROG = -c dasa2
35
36 #OPTCFLAGS = -O3 # DANGER - DO NOT USE - DOESN'T WORK WITH 3.4.1 & 3.5 (HEAD)
37 OPTCFLAGS = -ffunction-sections -fdata-sections 
38
39 # For AVRStudio
40 #DEBUGCFLAGS = -gdwarf-2
41
42 # For GDB
43 #DEBUGCFLAGS = -g
44
45 #
46 # define some variables based on the AVR base path in $(AVR)
47 #
48 CROSS   = avr-
49 CC      = $(CROSS)gcc
50 AS      = $(CC) -x assembler-with-cpp
51 LD      = $(CC)
52 OBJCOPY = $(CROSS)objcopy
53 INSTALL = cp -a
54 RM      = rm -f
55 RM_R    = rm -rf
56 RN      = mv
57 MKDIR_P = mkdir -p
58
59 # For conversion from ELF to COFF for use in debugging / simulating in AVR Studio or VMLAB.
60 COFFCONVERT=$(OBJCOPY) \
61         --debugging \
62         --change-section-address .data-0x800000 \
63         --change-section-address .bss-0x800000 \
64         --change-section-address .noinit-0x800000 \
65         --change-section-address .eeprom-0x810000
66
67 INCDIR  = -I. -Ihw
68 LIBDIR  = lib
69 OBJDIR  = obj
70 OUTDIR  = images
71 SHELL   = /bin/sh
72 DOXYGEN = doxygen
73 UISP    = uisp
74 AVRDUDE = avrdude
75 FLEXCAT = $(top_srcdir)/tools/flexcat/flexcat
76
77 # output format can be srec, ihex (avrobj is always created)
78 FORMAT = srec
79 #FORMAT = ihex
80
81 # Compiler flags for generating dependencies
82 DEP_FLAGS = -MMD -MP
83
84 # Compiler flags for generating source listings
85 LIST_FLAGS = -Wa,-anhlmsd=$(@:.o=.lst)
86
87 # Linker flags for generating map files
88 MAP_FLAGS = -Wl,-Map=$(@:%.elf=%.map),--cref
89
90 # Compiler warning flags for both C and C++
91 WARNFLAGS = \
92         -W -Wformat -Wall -Wundef -Wpointer-arith -Wcast-qual \
93         -Wcast-align -Wwrite-strings -Wsign-compare \
94         -Wmissing-prototypes -Wmissing-noreturn \
95         -Wextra -Wstrict-aliasing=2
96
97 # Compiler warning flags for C only
98 C_WARNFLAGS = \
99         -Wmissing-prototypes -Wstrict-prototypes
100
101 # Default C compiler flags
102 CFLAGS = $(INCDIR) $(OPTCFLAGS) $(DEBUGCFLAGS) $(WARNFLAGS) $(C_WARNFLAGS) \
103         $(DEP_FLAGS) $(LIST_FLAGS) -std=gnu99
104
105 # Default C++ compiler flags
106 CXXFLAGS = $(INCDIR) $(OPTCFLAGS) $(DEBUGCFLAGS) $(WARNFLAGS) \
107         $(DEP_FLAGS) $(LIST_FLAGS)
108
109 # Default compiler assembly flags
110 CPPAFLAGS = $(DEBUGCFLAGS) -MMD
111
112 # Default assembler flags
113 ASFLAGS = $(DEBUGCFLAGS)
114
115 # Default linker flags
116 #LDFLAGS = $(MAP_FLAGS)
117
118 #bernie: does not complain for missing symbols!
119 #LDFLAGS = $(MAP_FLAGS) -Wl,--gc-sections
120
121 # Flags for avrdude
122 AVRDUDEFLAGS = $(DPROG)
123
124 # additional libs
125 LIB = -lm