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