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