c0473a157967ec98b33fce8a110ccac7b1277eba
[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 # Set to 1 to build for embedded devices.
69 # e.g. produce target.elf instead of target and target_nostrip
70 EMBEDDED_TARGET = 1
71 #EMBEDDED_TARGET = 0
72
73 OPTCFLAGS = -ffunction-sections -fdata-sections
74 #OPTCFLAGS = -funsafe-loop-optimizations
75
76 # For AVRStudio
77 #DEBUGCFLAGS = -gdwarf-2
78
79 # For GDB
80 DEBUGCFLAGS = -ggdb
81
82 #
83 # define some variables based on the AVR base path in $(AVR)
84 #
85 CROSS   = arm-elf-
86 CC      = $(CROSS)gcc
87 CXX     = $(CROSS)g++
88 AS      = $(CC) -x assembler-with-cpp
89 LD      = $(CC)
90 OBJCOPY = $(CROSS)objcopy
91 STRIP   = $(CROSS)strip
92 INSTALL = cp -a
93 RM      = rm -f
94 RM_R    = rm -rf
95 RN      = mv
96 MKDIR_P = mkdir -p
97 SHELL   = /bin/sh
98 CHECKER = sparse
99 DOXYGEN = doxygen
100 AVRDUDE = avrdude
101 FLEXCAT = $(top_srcdir)/tools/flexcat/flexcat
102
103 # For conversion from ELF to COFF for use in debugging / simulating in AVR Studio or VMLAB.
104 COFFCONVERT=$(OBJCOPY) \
105         --debugging \
106         --change-section-address .data-0x800000 \
107         --change-section-address .bss-0x800000 \
108         --change-section-address .noinit-0x800000 \
109         --change-section-address .eeprom-0x810000
110
111 INCDIR  = -I. -Ihw
112 LIBDIR  = lib
113 OBJDIR  = obj
114 OUTDIR  = images
115
116 # output format can be srec, ihex (avrobj is always created)
117 FORMAT = srec
118 #FORMAT = ihex
119
120 # Compiler flags for generating dependencies
121 DEP_FLAGS = -MMD -MP
122
123 # Compiler flags for generating source listings
124 LIST_FLAGS = -Wa,-anhlmsd=$(@:.o=.lst)
125
126 # Linker flags for generating map files
127 ifeq ($(EMBEDDED_TARGET), 1)
128 MAP_FLAGS = -Wl,-Map=$(@:%.elf=%.map),--cref
129 else
130 MAP_FLAGS = 
131 endif
132
133 # Compiler warning flags for both C and C++
134 WARNFLAGS = \
135         -W -Wformat -Wall -Wundef -Wpointer-arith -Wcast-qual \
136         -Wcast-align -Wwrite-strings -Wsign-compare \
137         -Wmissing-noreturn \
138         -Wextra -Wstrict-aliasing=2 \
139 #       -Wunsafe-loop-optimizations
140
141 # Compiler warning flags for C only
142 C_WARNFLAGS = \
143         -Wmissing-prototypes -Wstrict-prototypes
144
145 # Default C preprocessor flags (for C, C++ and cpp+as)
146 CPPFLAGS = $(INCDIR)
147
148 # Default C compiler flags
149 CFLAGS = $(OPTCFLAGS) $(DEBUGCFLAGS) $(WARNFLAGS) $(C_WARNFLAGS) \
150         $(DEP_FLAGS) $(LIST_FLAGS) -std=gnu99
151
152 # Default C++ compiler flags
153 CXXFLAGS = $(OPTCFLAGS) $(DEBUGCFLAGS) $(WARNFLAGS) \
154         $(DEP_FLAGS) $(LIST_FLAGS)
155
156 # Default compiler assembly flags
157 CPPAFLAGS = $(DEBUGCFLAGS) -MMD
158
159 # Default assembler flags
160 ASFLAGS = $(DEBUGCFLAGS)
161
162 # Default linker flags
163 #LDFLAGS = $(MAP_FLAGS)
164
165 #bernie: does not complain for missing symbols!
166 LDFLAGS = $(MAP_FLAGS) -Wl,--gc-sections
167
168 # Flags for avrdude
169 AVRDUDEFLAGS = $(DPROG)
170
171 # additional libs
172 LIB = -lm