Mercurial > ~darius > hgwebdir.cgi > avr-lib
annotate Makefile.avr @ 4:095216e8453d
Hide register name abstraction in a separate file.
author | darius@Inchoate |
---|---|
date | Thu, 12 Mar 2009 16:30:47 +1030 |
parents | 43d3b2bef999 |
children | 5f21a1c8ca06 |
rev | line source |
---|---|
0 | 1 # |
2 # $Id$ | |
3 # | |
4 | |
5 .SUFFIXES: .hex .out .c .o .elf .dmp .s | |
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 | |
16 | |
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 | 19 |
2
43d3b2bef999
Make the programmer code smarter, default to Dragon.
darius@Inchoate
parents:
1
diff
changeset
|
20 MCU?=notset |
0 | 21 CFLAGS+=-mmcu=${MCU} |
22 | |
23 LDFLAGS+=-Wl,-Map=${PROG}.map,--cref | |
24 LDFLAGS+=${LDADD} | |
25 | |
26 RM=rm -f | |
27 | |
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 | 45 |
46 .if !defined(SRCS) | |
47 SRCS= ${PROG}.c | |
48 .endif | |
49 | |
50 OBJS+= ${SRCS:N*.h:R:S/$/.o/g} | |
51 | |
52 all: ${PROG}.hex ${PROG}.dmp | |
53 | |
54 .c.o: | |
55 ${CC} ${CFLAGS} ${CPPFLAGS} -c ${.IMPSRC} -o ${.PREFIX}.o | |
56 | |
57 ${PROG}.elf: ${OBJS} | |
58 ${CC} ${CFLAGS} ${LDFLAGS} -g ${OBJS} -o ${PROG}.elf ${LDADD} | |
59 | |
60 .elf.hex: | |
61 ${OBJCOPY} -j .text -j .data -j .bss -j .noinit -O ihex $> $@ | |
62 | |
63 .elf.dmp: | |
64 ${OBJDUMP} -S ${.IMPSRC} > ${.PREFIX}.dmp | |
65 | |
66 clean: | |
67 ${RM} ${PROG}.hex ${PROG}.out ${PROG}.elf ${PROG}.map ${OBJS} ${OBJS:S/.o/.lst/} ${PROG}.dmp | |
68 | |
69 prog: all | |
70 ${PROGRAMMER} -U flash:w:${PROG}.hex ${PROGOPTS} | |
71 | |
72 |