Merge from triface.
[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.10  2007/09/18 10:17:00  batt
14 # Merge from triface.
15 #
16 # Revision 1.9  2006/09/20 14:28:42  marco
17 # Add MOC. Changed OPTCFLAGS.
18 #
19 # Revision 1.8  2006/09/19 17:50:56  bernie
20 # Make native build the default.
21 #
22 # Revision 1.7  2006/07/19 12:56:24  bernie
23 # Convert to new Doxygen style.
24 #
25 # Revision 1.6  2006/06/12 22:05:09  marco
26 # Bring back config wrongly commited
27 #
28 # Revision 1.4  2006/05/27 22:41:46  bernie
29 # Tweak optimization flags for loops.
30 #
31 # Revision 1.3  2006/05/18 00:40:10  bernie
32 # Setup for AVR development.
33 #
34 # Revision 1.2  2006/03/27 04:48:33  bernie
35 # Add CXXFLAGS; Add recursive targets.
36 #
37 # Revision 1.1  2006/03/22 09:51:53  bernie
38 # Add build infrastructure.
39 #
40 #
41
42 #
43 # Programmer type
44 # see local pgm_config.mk for programmer customization.
45 -include pgm_config.mk
46 DPROG ?= -V -c stk500 -P /dev/ttyS0
47
48 # AVR ISP dongle that blows up easily
49 #DPROG = -V -c stk500 -P /dev/ttyS0
50 #DPROG = -V -c jtag2slow
51 #-P /dev/ttyUSB0
52
53 # STK200 parallel cable
54 #DPROG = -c stk200 -E noreset
55
56 # JTAG ICE mkII
57 #DPROG = avarice --mkII -j usb -l
58
59 # PonyProg serial programmer
60 #DPROG = -c dasa2
61
62 OPTCFLAGS = -ffunction-sections -fdata-sections
63 #OPTCFLAGS = -funsafe-loop-optimizations
64
65 # For AVRStudio
66 #DEBUGCFLAGS = -gdwarf-2
67
68 # For GDB
69 DEBUGCFLAGS = -ggdb
70
71 #
72 # define some variables based on the AVR base path in $(AVR)
73 #
74 CROSS   = avr-
75 CC      = $(CROSS)gcc
76 CXX     = $(CROSS)g++
77 AS      = $(CC) -x assembler-with-cpp
78 LD      = $(CC)
79 OBJCOPY = $(CROSS)objcopy
80 INSTALL = cp -a
81 RM      = rm -f
82 RM_R    = rm -rf
83 RN      = mv
84 MKDIR_P = mkdir -p
85 MOC     = moc
86
87 # For conversion from ELF to COFF for use in debugging / simulating in AVR Studio or VMLAB.
88 COFFCONVERT=$(OBJCOPY) \
89         --debugging \
90         --change-section-address .data-0x800000 \
91         --change-section-address .bss-0x800000 \
92         --change-section-address .noinit-0x800000 \
93         --change-section-address .eeprom-0x810000
94
95 INCDIR  = -I. -Ihw
96 LIBDIR  = lib
97 OBJDIR  = obj
98 OUTDIR  = images
99 SHELL   = /bin/sh
100 DOXYGEN = doxygen
101 UISP    = uisp
102 AVRDUDE = avrdude
103 FLEXCAT = $(top_srcdir)/tools/flexcat/flexcat
104
105 # output format can be srec, ihex (avrobj is always created)
106 FORMAT = srec
107 #FORMAT = ihex
108
109 # Compiler flags for generating dependencies
110 DEP_FLAGS = -MMD -MP
111
112 # Compiler flags for generating source listings
113 LIST_FLAGS = -Wa,-anhlmsd=$(@:.o=.lst)
114
115 # Linker flags for generating map files
116 #bernie: bogus binutils from Fedora 6 can't cope with this
117 #MAP_FLAGS = -Wl,-Map=$(@:%.elf=%.map),--cref
118
119 # Compiler warning flags for both C and C++
120 WARNFLAGS = \
121         -W -Wformat -Wall -Wundef -Wpointer-arith -Wcast-qual \
122         -Wcast-align -Wwrite-strings -Wsign-compare \
123         -Wmissing-prototypes -Wmissing-noreturn \
124         -Wextra -Wstrict-aliasing=2 \
125 #       -Wunsafe-loop-optimizations
126
127 # Compiler warning flags for C only
128 C_WARNFLAGS = \
129         -Wmissing-prototypes -Wstrict-prototypes
130
131 # Default C preprocessor flags (for C, C++ and cpp+as)
132 CPPFLAGS = $(INCDIR)
133
134 # Default C compiler flags
135 CFLAGS = $(OPTCFLAGS) $(DEBUGCFLAGS) $(WARNFLAGS) $(C_WARNFLAGS) \
136         $(DEP_FLAGS) $(LIST_FLAGS) -std=gnu99
137
138 # Default C++ compiler flags
139 CXXFLAGS = $(OPTCFLAGS) $(DEBUGCFLAGS) $(WARNFLAGS) \
140         $(DEP_FLAGS) $(LIST_FLAGS)
141
142 # Default compiler assembly flags
143 CPPAFLAGS = $(DEBUGCFLAGS) -MMD
144
145 # Default assembler flags
146 ASFLAGS = $(DEBUGCFLAGS)
147
148 # Default linker flags
149 #LDFLAGS = $(MAP_FLAGS)
150
151 #bernie: does not complain for missing symbols!
152 LDFLAGS = $(MAP_FLAGS) -Wl,--gc-sections
153
154 # Flags for avrdude
155 AVRDUDEFLAGS = $(DPROG)
156
157 # additional libs
158 LIB = -lm