annotate Makefile.avr @ 35:fed32b382de2

Tidy up, hide details behind macros to make it more obvious what we talk to do do things. Convert constants to my preferred format.
author darius
date Tue, 23 Oct 2007 10:54:01 +0930
parents 2b8278ec5adb
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
14
a9d493261c6c - Add $Id$
darius
parents: 6
diff changeset
1 #
a9d493261c6c - Add $Id$
darius
parents: 6
diff changeset
2 # $Id$
a9d493261c6c - Add $Id$
darius
parents: 6
diff changeset
3 #
a9d493261c6c - Add $Id$
darius
parents: 6
diff changeset
4
2
288d801a47ff Use nicer build framework.
darius
parents:
diff changeset
5 .SUFFIXES: .hex .out .c .o .elf .dmp .s
288d801a47ff Use nicer build framework.
darius
parents:
diff changeset
6
34
2b8278ec5adb Work around FreeBSD setting CPU flags based on architectures
darius
parents: 20
diff changeset
7 # Otherwise we get -march=foo
2b8278ec5adb Work around FreeBSD setting CPU flags based on architectures
darius
parents: 20
diff changeset
8 NO_CPU_CFLAGS=
2b8278ec5adb Work around FreeBSD setting CPU flags based on architectures
darius
parents: 20
diff changeset
9 _CPUCFLAGS=
2b8278ec5adb Work around FreeBSD setting CPU flags based on architectures
darius
parents: 20
diff changeset
10
2
288d801a47ff Use nicer build framework.
darius
parents:
diff changeset
11 # Programs
288d801a47ff Use nicer build framework.
darius
parents:
diff changeset
12 AS=avr-as
288d801a47ff Use nicer build framework.
darius
parents:
diff changeset
13 CC=avr-gcc
288d801a47ff Use nicer build framework.
darius
parents:
diff changeset
14 OBJCOPY=avr-objcopy
288d801a47ff Use nicer build framework.
darius
parents:
diff changeset
15 OBJDUMP=avr-objdump
288d801a47ff Use nicer build framework.
darius
parents:
diff changeset
16
288d801a47ff Use nicer build framework.
darius
parents:
diff changeset
17 CPPFLAGS+=-Wa,-adhlmsn=${<:S/.c/.lst/}
288d801a47ff Use nicer build framework.
darius
parents:
diff changeset
18
18
108a703c39e6 Covert to a later version of avr-libc. Stuff like not using inb/outb,
darius
parents: 14
diff changeset
19 MCU?=at90s8515
2
288d801a47ff Use nicer build framework.
darius
parents:
diff changeset
20 CFLAGS+=-mmcu=${MCU}
288d801a47ff Use nicer build framework.
darius
parents:
diff changeset
21
288d801a47ff Use nicer build framework.
darius
parents:
diff changeset
22 LDFLAGS+=-Wl,-Map=${PROG}.map,--cref
288d801a47ff Use nicer build framework.
darius
parents:
diff changeset
23 LDFLAGS+=${LDADD}
288d801a47ff Use nicer build framework.
darius
parents:
diff changeset
24
288d801a47ff Use nicer build framework.
darius
parents:
diff changeset
25 RM=rm -f
288d801a47ff Use nicer build framework.
darius
parents:
diff changeset
26
288d801a47ff Use nicer build framework.
darius
parents:
diff changeset
27 PROGRAMMER=avrdude
34
2b8278ec5adb Work around FreeBSD setting CPU flags based on architectures
darius
parents: 20
diff changeset
28 PROGOPTS?=-p ${PART} -c alf -E vcc,noreset -q
2
288d801a47ff Use nicer build framework.
darius
parents:
diff changeset
29
288d801a47ff Use nicer build framework.
darius
parents:
diff changeset
30 .if !defined(SRCS)
288d801a47ff Use nicer build framework.
darius
parents:
diff changeset
31 SRCS= ${PROG}.c
288d801a47ff Use nicer build framework.
darius
parents:
diff changeset
32 .endif
288d801a47ff Use nicer build framework.
darius
parents:
diff changeset
33
288d801a47ff Use nicer build framework.
darius
parents:
diff changeset
34 OBJS+= ${SRCS:N*.h:R:S/$/.o/g}
288d801a47ff Use nicer build framework.
darius
parents:
diff changeset
35
288d801a47ff Use nicer build framework.
darius
parents:
diff changeset
36 all: ${PROG}.hex ${PROG}.dmp
288d801a47ff Use nicer build framework.
darius
parents:
diff changeset
37
288d801a47ff Use nicer build framework.
darius
parents:
diff changeset
38 .c.o:
288d801a47ff Use nicer build framework.
darius
parents:
diff changeset
39 ${CC} ${CFLAGS} ${CPPFLAGS} -c ${.IMPSRC} -o ${.PREFIX}.o
288d801a47ff Use nicer build framework.
darius
parents:
diff changeset
40
288d801a47ff Use nicer build framework.
darius
parents:
diff changeset
41 ${PROG}.elf: ${OBJS}
288d801a47ff Use nicer build framework.
darius
parents:
diff changeset
42 ${CC} ${CFLAGS} ${LDFLAGS} -g ${OBJS} -o ${PROG}.elf ${LDADD}
288d801a47ff Use nicer build framework.
darius
parents:
diff changeset
43
288d801a47ff Use nicer build framework.
darius
parents:
diff changeset
44 .elf.hex:
20
59c7fcf10ea0 Copy the correct segments into the flash image otherwise pre-declared
darius
parents: 18
diff changeset
45 ${OBJCOPY} -j .text -j .data -j .bss -j .noinit -O ihex $> $@
2
288d801a47ff Use nicer build framework.
darius
parents:
diff changeset
46
288d801a47ff Use nicer build framework.
darius
parents:
diff changeset
47 .elf.dmp:
288d801a47ff Use nicer build framework.
darius
parents:
diff changeset
48 ${OBJDUMP} -S ${.IMPSRC} > ${.PREFIX}.dmp
288d801a47ff Use nicer build framework.
darius
parents:
diff changeset
49
288d801a47ff Use nicer build framework.
darius
parents:
diff changeset
50 clean:
6
0da70b744078 Clean the right files.
darius
parents: 2
diff changeset
51 ${RM} ${PROG}.hex ${PROG}.out ${PROG}.elf ${PROG}.map ${OBJS} ${OBJS:S/.o/.lst/} ${PROG}.dmp
2
288d801a47ff Use nicer build framework.
darius
parents:
diff changeset
52
288d801a47ff Use nicer build framework.
darius
parents:
diff changeset
53 prog: all
288d801a47ff Use nicer build framework.
darius
parents:
diff changeset
54 ${PROGRAMMER} -U flash:w:${PROG}.hex ${PROGOPTS}
288d801a47ff Use nicer build framework.
darius
parents:
diff changeset
55
288d801a47ff Use nicer build framework.
darius
parents:
diff changeset
56