annotate Makefile.avr @ 9:5f21a1c8ca06

Remove $Id$ and add a brief comment.
author Daniel O'Connor <darius@dons.net.au>
date Tue, 12 May 2009 08:44:30 +0930
parents 43d3b2bef999
children 4e10d1eef9a5
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
3879f487b661 Initial commit of routines I copy and paste.
darius@Inchoate
parents:
diff changeset
1 #
9
5f21a1c8ca06 Remove $Id$ and add a brief comment.
Daniel O'Connor <darius@dons.net.au>
parents: 2
diff changeset
2 # Helper makefile to build AVR sources
0
3879f487b661 Initial commit of routines I copy and paste.
darius@Inchoate
parents:
diff changeset
3 #
3879f487b661 Initial commit of routines I copy and paste.
darius@Inchoate
parents:
diff changeset
4
3879f487b661 Initial commit of routines I copy and paste.
darius@Inchoate
parents:
diff changeset
5 .SUFFIXES: .hex .out .c .o .elf .dmp .s
3879f487b661 Initial commit of routines I copy and paste.
darius@Inchoate
parents:
diff changeset
6
3879f487b661 Initial commit of routines I copy and paste.
darius@Inchoate
parents:
diff changeset
7 # Otherwise we get -march=foo
3879f487b661 Initial commit of routines I copy and paste.
darius@Inchoate
parents:
diff changeset
8 NO_CPU_CFLAGS=
3879f487b661 Initial commit of routines I copy and paste.
darius@Inchoate
parents:
diff changeset
9 _CPUCFLAGS=
3879f487b661 Initial commit of routines I copy and paste.
darius@Inchoate
parents:
diff changeset
10
3879f487b661 Initial commit of routines I copy and paste.
darius@Inchoate
parents:
diff changeset
11 # Programs
3879f487b661 Initial commit of routines I copy and paste.
darius@Inchoate
parents:
diff changeset
12 AS=avr-as
3879f487b661 Initial commit of routines I copy and paste.
darius@Inchoate
parents:
diff changeset
13 CC=avr-gcc
3879f487b661 Initial commit of routines I copy and paste.
darius@Inchoate
parents:
diff changeset
14 OBJCOPY=avr-objcopy
3879f487b661 Initial commit of routines I copy and paste.
darius@Inchoate
parents:
diff changeset
15 OBJDUMP=avr-objdump
3879f487b661 Initial commit of routines I copy and paste.
darius@Inchoate
parents:
diff changeset
16
3879f487b661 Initial commit of routines I copy and paste.
darius@Inchoate
parents:
diff changeset
17 # Tell as to generate listings
1
f5022e20d550 Fixup so .lst files end up in the project directory not the library one.
darius@Inchoate
parents: 0
diff changeset
18 CPPFLAGS+=-Wa,-adhlmsn=${<:T:S/.c/.lst/}
0
3879f487b661 Initial commit of routines I copy and paste.
darius@Inchoate
parents:
diff changeset
19
2
43d3b2bef999 Make the programmer code smarter, default to Dragon.
darius@Inchoate
parents: 1
diff changeset
20 MCU?=notset
0
3879f487b661 Initial commit of routines I copy and paste.
darius@Inchoate
parents:
diff changeset
21 CFLAGS+=-mmcu=${MCU}
3879f487b661 Initial commit of routines I copy and paste.
darius@Inchoate
parents:
diff changeset
22
3879f487b661 Initial commit of routines I copy and paste.
darius@Inchoate
parents:
diff changeset
23 LDFLAGS+=-Wl,-Map=${PROG}.map,--cref
3879f487b661 Initial commit of routines I copy and paste.
darius@Inchoate
parents:
diff changeset
24 LDFLAGS+=${LDADD}
3879f487b661 Initial commit of routines I copy and paste.
darius@Inchoate
parents:
diff changeset
25
3879f487b661 Initial commit of routines I copy and paste.
darius@Inchoate
parents:
diff changeset
26 RM=rm -f
3879f487b661 Initial commit of routines I copy and paste.
darius@Inchoate
parents:
diff changeset
27
3879f487b661 Initial commit of routines I copy and paste.
darius@Inchoate
parents:
diff changeset
28 PROGRAMMER=avrdude
2
43d3b2bef999 Make the programmer code smarter, default to Dragon.
darius@Inchoate
parents: 1
diff changeset
29 PROGTYPE?=alf
43d3b2bef999 Make the programmer code smarter, default to Dragon.
darius@Inchoate
parents: 1
diff changeset
30 # Need the -B 1 or it is very slow. For slow clocks (eg factory fused) -B 10 works
43d3b2bef999 Make the programmer code smarter, default to Dragon.
darius@Inchoate
parents: 1
diff changeset
31 PROGEXTRA?=-B 1
43d3b2bef999 Make the programmer code smarter, default to Dragon.
darius@Inchoate
parents: 1
diff changeset
32
43d3b2bef999 Make the programmer code smarter, default to Dragon.
darius@Inchoate
parents: 1
diff changeset
33 .if ${PROGTYPE} != "dragon_isp" && ${PROGTYPE} != "dragon_jtag"
43d3b2bef999 Make the programmer code smarter, default to Dragon.
darius@Inchoate
parents: 1
diff changeset
34 PROGEXITS?=vcc,noreset
43d3b2bef999 Make the programmer code smarter, default to Dragon.
darius@Inchoate
parents: 1
diff changeset
35 .endif
43d3b2bef999 Make the programmer code smarter, default to Dragon.
darius@Inchoate
parents: 1
diff changeset
36
43d3b2bef999 Make the programmer code smarter, default to Dragon.
darius@Inchoate
parents: 1
diff changeset
37 .if defined(PROGEXITS) && ${PROGEXITS} != ""
43d3b2bef999 Make the programmer code smarter, default to Dragon.
darius@Inchoate
parents: 1
diff changeset
38 _PROGEXITS=-E ${PROGEXITS}
43d3b2bef999 Make the programmer code smarter, default to Dragon.
darius@Inchoate
parents: 1
diff changeset
39 .endif
43d3b2bef999 Make the programmer code smarter, default to Dragon.
darius@Inchoate
parents: 1
diff changeset
40 .if defined(PROGPORT) && ${PROGPORT} != ""
43d3b2bef999 Make the programmer code smarter, default to Dragon.
darius@Inchoate
parents: 1
diff changeset
41 _PROGPORT=-P ${PROGPORT}
43d3b2bef999 Make the programmer code smarter, default to Dragon.
darius@Inchoate
parents: 1
diff changeset
42 .endif
43d3b2bef999 Make the programmer code smarter, default to Dragon.
darius@Inchoate
parents: 1
diff changeset
43
43d3b2bef999 Make the programmer code smarter, default to Dragon.
darius@Inchoate
parents: 1
diff changeset
44 PROGOPTS?=-p ${PART} -c ${PROGTYPE} ${_PROGPORT} ${_PROGEXITS} -q ${PROGEXTRA}
0
3879f487b661 Initial commit of routines I copy and paste.
darius@Inchoate
parents:
diff changeset
45
3879f487b661 Initial commit of routines I copy and paste.
darius@Inchoate
parents:
diff changeset
46 .if !defined(SRCS)
3879f487b661 Initial commit of routines I copy and paste.
darius@Inchoate
parents:
diff changeset
47 SRCS= ${PROG}.c
3879f487b661 Initial commit of routines I copy and paste.
darius@Inchoate
parents:
diff changeset
48 .endif
3879f487b661 Initial commit of routines I copy and paste.
darius@Inchoate
parents:
diff changeset
49
3879f487b661 Initial commit of routines I copy and paste.
darius@Inchoate
parents:
diff changeset
50 OBJS+= ${SRCS:N*.h:R:S/$/.o/g}
3879f487b661 Initial commit of routines I copy and paste.
darius@Inchoate
parents:
diff changeset
51
3879f487b661 Initial commit of routines I copy and paste.
darius@Inchoate
parents:
diff changeset
52 all: ${PROG}.hex ${PROG}.dmp
3879f487b661 Initial commit of routines I copy and paste.
darius@Inchoate
parents:
diff changeset
53
3879f487b661 Initial commit of routines I copy and paste.
darius@Inchoate
parents:
diff changeset
54 .c.o:
3879f487b661 Initial commit of routines I copy and paste.
darius@Inchoate
parents:
diff changeset
55 ${CC} ${CFLAGS} ${CPPFLAGS} -c ${.IMPSRC} -o ${.PREFIX}.o
3879f487b661 Initial commit of routines I copy and paste.
darius@Inchoate
parents:
diff changeset
56
3879f487b661 Initial commit of routines I copy and paste.
darius@Inchoate
parents:
diff changeset
57 ${PROG}.elf: ${OBJS}
3879f487b661 Initial commit of routines I copy and paste.
darius@Inchoate
parents:
diff changeset
58 ${CC} ${CFLAGS} ${LDFLAGS} -g ${OBJS} -o ${PROG}.elf ${LDADD}
3879f487b661 Initial commit of routines I copy and paste.
darius@Inchoate
parents:
diff changeset
59
3879f487b661 Initial commit of routines I copy and paste.
darius@Inchoate
parents:
diff changeset
60 .elf.hex:
3879f487b661 Initial commit of routines I copy and paste.
darius@Inchoate
parents:
diff changeset
61 ${OBJCOPY} -j .text -j .data -j .bss -j .noinit -O ihex $> $@
3879f487b661 Initial commit of routines I copy and paste.
darius@Inchoate
parents:
diff changeset
62
3879f487b661 Initial commit of routines I copy and paste.
darius@Inchoate
parents:
diff changeset
63 .elf.dmp:
3879f487b661 Initial commit of routines I copy and paste.
darius@Inchoate
parents:
diff changeset
64 ${OBJDUMP} -S ${.IMPSRC} > ${.PREFIX}.dmp
3879f487b661 Initial commit of routines I copy and paste.
darius@Inchoate
parents:
diff changeset
65
3879f487b661 Initial commit of routines I copy and paste.
darius@Inchoate
parents:
diff changeset
66 clean:
3879f487b661 Initial commit of routines I copy and paste.
darius@Inchoate
parents:
diff changeset
67 ${RM} ${PROG}.hex ${PROG}.out ${PROG}.elf ${PROG}.map ${OBJS} ${OBJS:S/.o/.lst/} ${PROG}.dmp
3879f487b661 Initial commit of routines I copy and paste.
darius@Inchoate
parents:
diff changeset
68
3879f487b661 Initial commit of routines I copy and paste.
darius@Inchoate
parents:
diff changeset
69 prog: all
3879f487b661 Initial commit of routines I copy and paste.
darius@Inchoate
parents:
diff changeset
70 ${PROGRAMMER} -U flash:w:${PROG}.hex ${PROGOPTS}
3879f487b661 Initial commit of routines I copy and paste.
darius@Inchoate
parents:
diff changeset
71
3879f487b661 Initial commit of routines I copy and paste.
darius@Inchoate
parents:
diff changeset
72