5ace0dbdf4c0f90ac29b5b1553ecadb5ca9090d4
[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 # Author: Bernardo Innocenti <bernie@develer.com>
7 # Based on: GCC-AVR standard Makefile part 1, Volker Oth 1/2000
8 #
9
10 #
11 # Programmer type
12 # see local pgm_config.mk for programmer customization.
13 -include pgm_config.mk
14 DPROG ?= -V -c stk500 -P /dev/ttyS0
15
16 # Set to 1 to build for embedded devices.
17 # e.g. produce target.elf instead of target and target_nostrip
18 EMBEDDED_TARGET = 1
19 #EMBEDDED_TARGET = 0
20
21 OPTCFLAGS = -ffunction-sections -fdata-sections
22 #OPTCFLAGS = -funsafe-loop-optimizations
23
24 # For AVRStudio
25 #DEBUGCFLAGS = -gdwarf-2
26
27 # For GDB
28 DEBUGCFLAGS = -ggdb
29
30 #
31 # define some variables based on the AVR base path in $(AVR)
32 #
33 #CROSS   = avr-
34 CC      = gcc
35 CXX     = g++
36 AS      = $(CC) -x assembler-with-cpp
37 LD      = $(CC)
38 LDXX    = $(CXX)
39 OBJCOPY = objcopy
40 STRIP   = strip
41 INSTALL = cp -a
42 RM      = rm -f
43 RM_R    = rm -rf
44 RN      = mv
45 MKDIR_P = mkdir -p
46 SHELL   = /bin/sh
47 CHECKER = sparse
48 DOXYGEN = doxygen
49 AVRDUDE = avrdude
50 MOC     = moc-qt4
51 FLEXCAT = $(top_srcdir)/tools/flexcat/flexcat
52
53 # For conversion from ELF to COFF for use in debugging / simulating in AVR Studio or VMLAB.
54 COFFCONVERT=$(OBJCOPY) \
55         --debugging \
56         --change-section-address .data-0x800000 \
57         --change-section-address .bss-0x800000 \
58         --change-section-address .noinit-0x800000 \
59         --change-section-address .eeprom-0x810000
60
61 INCDIR  = -I. -Ihw
62 LIBDIR  = lib
63 OBJDIR  = obj
64 OUTDIR  = images
65
66 # output format can be srec, ihex (avrobj is always created)
67 FORMAT = srec
68 #FORMAT = ihex
69
70 # Compiler flags for generating dependencies
71 DEP_FLAGS = -MMD -MP
72
73 # Compiler flags for generating source listings
74 LIST_FLAGS = -Wa,-anhlmsd=$(@:.o=.lst)
75
76 # Linker flags for generating map files
77 ifeq ($(EMBEDDED_TARGET), 1)
78 MAP_FLAGS = -Wl,-Map=$(@:%.elf=%.map),--cref
79 else
80 MAP_FLAGS =
81 endif
82
83 # Compiler warning flags for both C and C++
84 WARNFLAGS = \
85         -W -Wformat -Wall -Wundef -Wpointer-arith -Wcast-qual \
86         -Wcast-align -Wwrite-strings -Wsign-compare \
87         -Wmissing-noreturn \
88         -Wextra -Wstrict-aliasing=2 \
89 #       -Wunsafe-loop-optimizations
90
91 # Compiler warning flags for C only
92 C_WARNFLAGS = \
93         -Wmissing-prototypes -Wstrict-prototypes
94
95 # Default C preprocessor flags (for C, C++ and cpp+as)
96 CPPFLAGS = $(INCDIR)
97
98 # Default C compiler flags
99 CFLAGS = $(OPTCFLAGS) $(DEBUGCFLAGS) $(WARNFLAGS) $(C_WARNFLAGS) \
100         $(DEP_FLAGS) $(LIST_FLAGS) -std=gnu99
101
102 # Default C++ compiler flags
103 CXXFLAGS = $(OPTCFLAGS) $(DEBUGCFLAGS) $(WARNFLAGS) \
104         $(DEP_FLAGS) $(LIST_FLAGS)
105
106 # Default compiler assembly flags
107 CPPAFLAGS = $(DEBUGCFLAGS) -MMD
108
109 # Default assembler flags
110 ASFLAGS = $(DEBUGCFLAGS)
111
112 # Default linker flags
113 #LDFLAGS = $(MAP_FLAGS)
114
115 #bernie: does not complain for missing symbols!
116 LDFLAGS = $(MAP_FLAGS) -Wl,--gc-sections
117
118 # Flags for avrdude
119 AVRDUDEFLAGS = $(DPROG)
120
121 # additional libs
122 LIB = -lm