Add build infrastructure.
[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.1  2006/03/22 09:51:53  bernie
14 # Add build infrastructure.
15 #
16 #
17
18 #
19 # Programmer type
20 #
21 # AVR ISP dongle that blows up easily
22 DPROG = -V -c stk500 -P /dev/ttyS0
23
24 # STK200 parallel cable
25 #DPROG = -c stk200 -E noreset
26
27 # PonyProg serial programmer
28 #DPROG = -c dasa2
29
30 #OPTCFLAGS = -O3 # DANGER - DO NOT USE - DOESN'T WORK WITH 3.4.1 & 3.5 (HEAD)
31 OPTCFLAGS = -ffunction-sections -fdata-sections 
32
33 # For AVRStudio
34 #DEBUGCFLAGS = -gdwarf-2
35
36 # For GDB
37 DEBUGCFLAGS = -g
38
39 #
40 # define some variables based on the AVR base path in $(AVR)
41 #
42 CROSS   = 
43 CC      = $(CROSS)gcc
44 AS      = $(CROSS)$(CC) -x assembler-with-cpp
45 LD      = $(CROSS)$(CC)
46 OBJCOPY = $(CROSS)objcopy
47 INSTALL = cp -a
48 RM      = rm -f
49 RM_R    = rm -rf
50 RN      = mv
51 MKDIR_P = mkdir -p
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 SHELL   = /bin/sh
66 DOXYGEN = doxygen
67 UISP    = uisp
68 AVRDUDE = avrdude
69
70 # output format can be srec, ihex (avrobj is always created)
71 FORMAT = srec
72 #FORMAT = ihex
73
74 WARNFLAGS = \
75         -W -Wformat -Wall -Wundef -Wpointer-arith -Wcast-qual \
76         -Wcast-align -Wwrite-strings -Wsign-compare -Wstrict-prototypes \
77         -Wmissing-prototypes -Wmissing-noreturn
78
79 # default compiler flags
80 CFLAGS = $(INCDIR) $(OPTCFLAGS) $(DEBUGCFLAGS) $(WARNFLAGS) \
81         -MMD -MP -Wa,-anhlmsd=$(@:.o=.lst) -std=gnu99
82
83 # default compiler assembly flags
84 CPPAFLAGS = $(DEBUGCFLAGS) -MMD
85
86 # default assembler flags
87 ASFLAGS = $(DEBUGCFLAGS)
88
89 # default linker flags
90 #LDFLAGS        = -Wl,-Map=$(@:%.elf=%.map),--cref -Wl,--reduce-memory-overheads
91 LDFLAGS = -Wl,-Map=$(@:%.elf=%.map),--cref -Wl,--gc-sections
92
93 # flags for avrdude
94 AVRDUDEFLAGS = $(DPROG)
95
96 # additional libs
97 LIB = -lm