Mercurial > ~darius > hgwebdir.cgi > avr-lib
annotate Makefile.avr @ 14:d8002c716678
- Actually wait after reading like the spec says.
- Add debug item to show a device was found in the search.
- Re-enable test for broken bus.
author | Daniel O'Connor <darius@dons.net.au> |
---|---|
date | Wed, 08 Feb 2012 10:35:13 +1030 |
parents | 4e10d1eef9a5 |
children | bbe75f183cf9 |
rev | line source |
---|---|
0 | 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 | 3 # |
4 | |
12
4e10d1eef9a5
Re-jig programming and add WITH_FUSES= to set fuses automatically if
Daniel O'Connor <darius@dons.net.au>
parents:
9
diff
changeset
|
5 .SUFFIXES: .hex .out .c .o .elf .dmp .s .fuse |
0 | 6 |
7 # Otherwise we get -march=foo | |
8 NO_CPU_CFLAGS= | |
9 _CPUCFLAGS= | |
10 | |
11 # Programs | |
12 AS=avr-as | |
13 CC=avr-gcc | |
14 OBJCOPY=avr-objcopy | |
15 OBJDUMP=avr-objdump | |
12
4e10d1eef9a5
Re-jig programming and add WITH_FUSES= to set fuses automatically if
Daniel O'Connor <darius@dons.net.au>
parents:
9
diff
changeset
|
16 SED=sed |
4e10d1eef9a5
Re-jig programming and add WITH_FUSES= to set fuses automatically if
Daniel O'Connor <darius@dons.net.au>
parents:
9
diff
changeset
|
17 TAIL=tail |
0 | 18 |
19 # 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
|
20 CPPFLAGS+=-Wa,-adhlmsn=${<:T:S/.c/.lst/} |
0 | 21 |
2
43d3b2bef999
Make the programmer code smarter, default to Dragon.
darius@Inchoate
parents:
1
diff
changeset
|
22 MCU?=notset |
0 | 23 CFLAGS+=-mmcu=${MCU} |
24 | |
25 LDFLAGS+=-Wl,-Map=${PROG}.map,--cref | |
26 LDFLAGS+=${LDADD} | |
27 | |
28 RM=rm -f | |
29 | |
30 PROGRAMMER=avrdude | |
2
43d3b2bef999
Make the programmer code smarter, default to Dragon.
darius@Inchoate
parents:
1
diff
changeset
|
31 PROGTYPE?=alf |
12
4e10d1eef9a5
Re-jig programming and add WITH_FUSES= to set fuses automatically if
Daniel O'Connor <darius@dons.net.au>
parents:
9
diff
changeset
|
32 |
2
43d3b2bef999
Make the programmer code smarter, default to Dragon.
darius@Inchoate
parents:
1
diff
changeset
|
33 # Need the -B 1 or it is very slow. For slow clocks (eg factory fused) -B 10 works |
12
4e10d1eef9a5
Re-jig programming and add WITH_FUSES= to set fuses automatically if
Daniel O'Connor <darius@dons.net.au>
parents:
9
diff
changeset
|
34 PROGOPTS+=-B 10 |
4e10d1eef9a5
Re-jig programming and add WITH_FUSES= to set fuses automatically if
Daniel O'Connor <darius@dons.net.au>
parents:
9
diff
changeset
|
35 |
4e10d1eef9a5
Re-jig programming and add WITH_FUSES= to set fuses automatically if
Daniel O'Connor <darius@dons.net.au>
parents:
9
diff
changeset
|
36 .if defined(WITH_FUSES) |
4e10d1eef9a5
Re-jig programming and add WITH_FUSES= to set fuses automatically if
Daniel O'Connor <darius@dons.net.au>
parents:
9
diff
changeset
|
37 FUSEFILE=${PROG}.fuse |
4e10d1eef9a5
Re-jig programming and add WITH_FUSES= to set fuses automatically if
Daniel O'Connor <darius@dons.net.au>
parents:
9
diff
changeset
|
38 PROGOPTS+=`cat ${PROG}.fuse` |
4e10d1eef9a5
Re-jig programming and add WITH_FUSES= to set fuses automatically if
Daniel O'Connor <darius@dons.net.au>
parents:
9
diff
changeset
|
39 .elf.fuse: |
4e10d1eef9a5
Re-jig programming and add WITH_FUSES= to set fuses automatically if
Daniel O'Connor <darius@dons.net.au>
parents:
9
diff
changeset
|
40 ${OBJDUMP} -s -j .fuse ${.IMPSRC} | ${TAIL} -1 | ${SED} -nEe 's, [^ ]+ (..)(..)(..).*,-Ulfuse:w:0x\1:m -Uhfuse:w:0x\2:m -Uefuse:w:0x\3:m,p' >${.TARGET} |
4e10d1eef9a5
Re-jig programming and add WITH_FUSES= to set fuses automatically if
Daniel O'Connor <darius@dons.net.au>
parents:
9
diff
changeset
|
41 .else |
4e10d1eef9a5
Re-jig programming and add WITH_FUSES= to set fuses automatically if
Daniel O'Connor <darius@dons.net.au>
parents:
9
diff
changeset
|
42 FUSEFILE= |
4e10d1eef9a5
Re-jig programming and add WITH_FUSES= to set fuses automatically if
Daniel O'Connor <darius@dons.net.au>
parents:
9
diff
changeset
|
43 .endif |
2
43d3b2bef999
Make the programmer code smarter, default to Dragon.
darius@Inchoate
parents:
1
diff
changeset
|
44 |
43d3b2bef999
Make the programmer code smarter, default to Dragon.
darius@Inchoate
parents:
1
diff
changeset
|
45 .if ${PROGTYPE} != "dragon_isp" && ${PROGTYPE} != "dragon_jtag" |
43d3b2bef999
Make the programmer code smarter, default to Dragon.
darius@Inchoate
parents:
1
diff
changeset
|
46 PROGEXITS?=vcc,noreset |
43d3b2bef999
Make the programmer code smarter, default to Dragon.
darius@Inchoate
parents:
1
diff
changeset
|
47 .endif |
43d3b2bef999
Make the programmer code smarter, default to Dragon.
darius@Inchoate
parents:
1
diff
changeset
|
48 |
43d3b2bef999
Make the programmer code smarter, default to Dragon.
darius@Inchoate
parents:
1
diff
changeset
|
49 .if defined(PROGEXITS) && ${PROGEXITS} != "" |
43d3b2bef999
Make the programmer code smarter, default to Dragon.
darius@Inchoate
parents:
1
diff
changeset
|
50 _PROGEXITS=-E ${PROGEXITS} |
43d3b2bef999
Make the programmer code smarter, default to Dragon.
darius@Inchoate
parents:
1
diff
changeset
|
51 .endif |
43d3b2bef999
Make the programmer code smarter, default to Dragon.
darius@Inchoate
parents:
1
diff
changeset
|
52 .if defined(PROGPORT) && ${PROGPORT} != "" |
43d3b2bef999
Make the programmer code smarter, default to Dragon.
darius@Inchoate
parents:
1
diff
changeset
|
53 _PROGPORT=-P ${PROGPORT} |
43d3b2bef999
Make the programmer code smarter, default to Dragon.
darius@Inchoate
parents:
1
diff
changeset
|
54 .endif |
43d3b2bef999
Make the programmer code smarter, default to Dragon.
darius@Inchoate
parents:
1
diff
changeset
|
55 |
12
4e10d1eef9a5
Re-jig programming and add WITH_FUSES= to set fuses automatically if
Daniel O'Connor <darius@dons.net.au>
parents:
9
diff
changeset
|
56 PROGOPTS+=-p ${PART} -c ${PROGTYPE} ${_PROGPORT} ${_PROGEXITS} -q -U flash:w:${PROG}.hex ${PROGEXTRA} |
0 | 57 |
58 .if !defined(SRCS) | |
59 SRCS= ${PROG}.c | |
60 .endif | |
61 | |
62 OBJS+= ${SRCS:N*.h:R:S/$/.o/g} | |
63 | |
64 all: ${PROG}.hex ${PROG}.dmp | |
65 | |
66 .c.o: | |
67 ${CC} ${CFLAGS} ${CPPFLAGS} -c ${.IMPSRC} -o ${.PREFIX}.o | |
68 | |
69 ${PROG}.elf: ${OBJS} | |
70 ${CC} ${CFLAGS} ${LDFLAGS} -g ${OBJS} -o ${PROG}.elf ${LDADD} | |
71 | |
72 .elf.hex: | |
73 ${OBJCOPY} -j .text -j .data -j .bss -j .noinit -O ihex $> $@ | |
74 | |
75 .elf.dmp: | |
76 ${OBJDUMP} -S ${.IMPSRC} > ${.PREFIX}.dmp | |
77 | |
78 clean: | |
12
4e10d1eef9a5
Re-jig programming and add WITH_FUSES= to set fuses automatically if
Daniel O'Connor <darius@dons.net.au>
parents:
9
diff
changeset
|
79 ${RM} ${PROG}.hex ${PROG}.out ${PROG}.elf ${PROG}.map ${OBJS} ${OBJS:S/.o/.lst/} ${PROG}.dmp ${PROG}.fuse |
4e10d1eef9a5
Re-jig programming and add WITH_FUSES= to set fuses automatically if
Daniel O'Connor <darius@dons.net.au>
parents:
9
diff
changeset
|
80 |
4e10d1eef9a5
Re-jig programming and add WITH_FUSES= to set fuses automatically if
Daniel O'Connor <darius@dons.net.au>
parents:
9
diff
changeset
|
81 prog: ${PROG}.elf ${FUSEFILE} |
4e10d1eef9a5
Re-jig programming and add WITH_FUSES= to set fuses automatically if
Daniel O'Connor <darius@dons.net.au>
parents:
9
diff
changeset
|
82 ${PROGRAMMER} ${PROGOPTS} |
0 | 83 |
12
4e10d1eef9a5
Re-jig programming and add WITH_FUSES= to set fuses automatically if
Daniel O'Connor <darius@dons.net.au>
parents:
9
diff
changeset
|
84 ######################### |
4e10d1eef9a5
Re-jig programming and add WITH_FUSES= to set fuses automatically if
Daniel O'Connor <darius@dons.net.au>
parents:
9
diff
changeset
|
85 #;;; Local Variables: *** |
4e10d1eef9a5
Re-jig programming and add WITH_FUSES= to set fuses automatically if
Daniel O'Connor <darius@dons.net.au>
parents:
9
diff
changeset
|
86 #;;; mode:makefile *** |
4e10d1eef9a5
Re-jig programming and add WITH_FUSES= to set fuses automatically if
Daniel O'Connor <darius@dons.net.au>
parents:
9
diff
changeset
|
87 #;;; End: *** |