Mercurial > ~darius > hgwebdir.cgi > avr-lib
annotate Makefile.avr @ 18:0876867347de
Remove CVS tags
author | Daniel O'Connor <darius@dons.net.au> |
---|---|
date | Sat, 31 Jan 2015 23:26:21 +1030 |
parents | bbe75f183cf9 |
children | b5e4591b6570 |
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 | |
17
bbe75f183cf9
Allow path to toolchain to be specified.
Daniel O'Connor <darius@dons.net.au>
parents:
12
diff
changeset
|
12 TPREFIX?= |
bbe75f183cf9
Allow path to toolchain to be specified.
Daniel O'Connor <darius@dons.net.au>
parents:
12
diff
changeset
|
13 AS=${TPREFIX}/avr-as |
bbe75f183cf9
Allow path to toolchain to be specified.
Daniel O'Connor <darius@dons.net.au>
parents:
12
diff
changeset
|
14 CC=${TPREFIX}/avr-gcc |
bbe75f183cf9
Allow path to toolchain to be specified.
Daniel O'Connor <darius@dons.net.au>
parents:
12
diff
changeset
|
15 OBJCOPY=${TPREFIX}/avr-objcopy |
bbe75f183cf9
Allow path to toolchain to be specified.
Daniel O'Connor <darius@dons.net.au>
parents:
12
diff
changeset
|
16 OBJDUMP=${TPREFIX}/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
|
17 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
|
18 TAIL=tail |
0 | 19 |
20 # 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
|
21 CPPFLAGS+=-Wa,-adhlmsn=${<:T:S/.c/.lst/} |
0 | 22 |
2
43d3b2bef999
Make the programmer code smarter, default to Dragon.
darius@Inchoate
parents:
1
diff
changeset
|
23 MCU?=notset |
0 | 24 CFLAGS+=-mmcu=${MCU} |
25 | |
26 LDFLAGS+=-Wl,-Map=${PROG}.map,--cref | |
27 LDFLAGS+=${LDADD} | |
28 | |
29 RM=rm -f | |
30 | |
31 PROGRAMMER=avrdude | |
2
43d3b2bef999
Make the programmer code smarter, default to Dragon.
darius@Inchoate
parents:
1
diff
changeset
|
32 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
|
33 |
2
43d3b2bef999
Make the programmer code smarter, default to Dragon.
darius@Inchoate
parents:
1
diff
changeset
|
34 # Need the -B 1 or it is very slow. For slow clocks (eg factory fused) -B 10 works |
17
bbe75f183cf9
Allow path to toolchain to be specified.
Daniel O'Connor <darius@dons.net.au>
parents:
12
diff
changeset
|
35 # For BP programming this is intolerably slow |
bbe75f183cf9
Allow path to toolchain to be specified.
Daniel O'Connor <darius@dons.net.au>
parents:
12
diff
changeset
|
36 #PROGOPTS+=-B 1 |
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
|
37 |
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 .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
|
39 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
|
40 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
|
41 .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
|
42 ${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
|
43 .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
|
44 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
|
45 .endif |
2
43d3b2bef999
Make the programmer code smarter, default to Dragon.
darius@Inchoate
parents:
1
diff
changeset
|
46 |
43d3b2bef999
Make the programmer code smarter, default to Dragon.
darius@Inchoate
parents:
1
diff
changeset
|
47 .if ${PROGTYPE} != "dragon_isp" && ${PROGTYPE} != "dragon_jtag" |
43d3b2bef999
Make the programmer code smarter, default to Dragon.
darius@Inchoate
parents:
1
diff
changeset
|
48 PROGEXITS?=vcc,noreset |
43d3b2bef999
Make the programmer code smarter, default to Dragon.
darius@Inchoate
parents:
1
diff
changeset
|
49 .endif |
43d3b2bef999
Make the programmer code smarter, default to Dragon.
darius@Inchoate
parents:
1
diff
changeset
|
50 |
43d3b2bef999
Make the programmer code smarter, default to Dragon.
darius@Inchoate
parents:
1
diff
changeset
|
51 .if defined(PROGEXITS) && ${PROGEXITS} != "" |
43d3b2bef999
Make the programmer code smarter, default to Dragon.
darius@Inchoate
parents:
1
diff
changeset
|
52 _PROGEXITS=-E ${PROGEXITS} |
43d3b2bef999
Make the programmer code smarter, default to Dragon.
darius@Inchoate
parents:
1
diff
changeset
|
53 .endif |
43d3b2bef999
Make the programmer code smarter, default to Dragon.
darius@Inchoate
parents:
1
diff
changeset
|
54 .if defined(PROGPORT) && ${PROGPORT} != "" |
43d3b2bef999
Make the programmer code smarter, default to Dragon.
darius@Inchoate
parents:
1
diff
changeset
|
55 _PROGPORT=-P ${PROGPORT} |
43d3b2bef999
Make the programmer code smarter, default to Dragon.
darius@Inchoate
parents:
1
diff
changeset
|
56 .endif |
43d3b2bef999
Make the programmer code smarter, default to Dragon.
darius@Inchoate
parents:
1
diff
changeset
|
57 |
17
bbe75f183cf9
Allow path to toolchain to be specified.
Daniel O'Connor <darius@dons.net.au>
parents:
12
diff
changeset
|
58 PROGPART?=${PART} |
bbe75f183cf9
Allow path to toolchain to be specified.
Daniel O'Connor <darius@dons.net.au>
parents:
12
diff
changeset
|
59 |
bbe75f183cf9
Allow path to toolchain to be specified.
Daniel O'Connor <darius@dons.net.au>
parents:
12
diff
changeset
|
60 PROGOPTS+=-p ${PROGPART} -c ${PROGTYPE} ${_PROGPORT} ${_PROGEXITS} -U flash:w:${PROG}.hex ${PROGEXTRA} |
0 | 61 |
62 .if !defined(SRCS) | |
63 SRCS= ${PROG}.c | |
64 .endif | |
65 | |
66 OBJS+= ${SRCS:N*.h:R:S/$/.o/g} | |
67 | |
68 all: ${PROG}.hex ${PROG}.dmp | |
69 | |
70 .c.o: | |
71 ${CC} ${CFLAGS} ${CPPFLAGS} -c ${.IMPSRC} -o ${.PREFIX}.o | |
72 | |
73 ${PROG}.elf: ${OBJS} | |
74 ${CC} ${CFLAGS} ${LDFLAGS} -g ${OBJS} -o ${PROG}.elf ${LDADD} | |
75 | |
76 .elf.hex: | |
77 ${OBJCOPY} -j .text -j .data -j .bss -j .noinit -O ihex $> $@ | |
78 | |
79 .elf.dmp: | |
80 ${OBJDUMP} -S ${.IMPSRC} > ${.PREFIX}.dmp | |
81 | |
82 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
|
83 ${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
|
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 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
|
86 ${PROGRAMMER} ${PROGOPTS} |
0 | 87 |
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
|
88 ######################### |
4e10d1eef9a5
Re-jig programming and add WITH_FUSES= to set fuses automatically if
Daniel O'Connor <darius@dons.net.au>
parents:
9
diff
changeset
|
89 #;;; 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
|
90 #;;; 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
|
91 #;;; End: *** |