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