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
|
|
18 CPPFLAGS+=-Wa,-adhlmsn=${<:S/.c/.lst/}
|
|
19
|
|
20 MCU?=at90s8515
|
|
21 CFLAGS+=-mmcu=${MCU}
|
|
22
|
|
23 LDFLAGS+=-Wl,-Map=${PROG}.map,--cref
|
|
24 LDFLAGS+=${LDADD}
|
|
25
|
|
26 RM=rm -f
|
|
27
|
|
28 PROGRAMMER=avrdude
|
|
29 PROGOPTS?=-p ${PART} -c alf -E vcc,noreset -q
|
|
30
|
|
31 .if !defined(SRCS)
|
|
32 SRCS= ${PROG}.c
|
|
33 .endif
|
|
34
|
|
35 OBJS+= ${SRCS:N*.h:R:S/$/.o/g}
|
|
36
|
|
37 all: ${PROG}.hex ${PROG}.dmp
|
|
38
|
|
39 .c.o:
|
|
40 ${CC} ${CFLAGS} ${CPPFLAGS} -c ${.IMPSRC} -o ${.PREFIX}.o
|
|
41
|
|
42 ${PROG}.elf: ${OBJS}
|
|
43 ${CC} ${CFLAGS} ${LDFLAGS} -g ${OBJS} -o ${PROG}.elf ${LDADD}
|
|
44
|
|
45 .elf.hex:
|
|
46 ${OBJCOPY} -j .text -j .data -j .bss -j .noinit -O ihex $> $@
|
|
47
|
|
48 .elf.dmp:
|
|
49 ${OBJDUMP} -S ${.IMPSRC} > ${.PREFIX}.dmp
|
|
50
|
|
51 clean:
|
|
52 ${RM} ${PROG}.hex ${PROG}.out ${PROG}.elf ${PROG}.map ${OBJS} ${OBJS:S/.o/.lst/} ${PROG}.dmp
|
|
53
|
|
54 prog: all
|
|
55 ${PROGRAMMER} -U flash:w:${PROG}.hex ${PROGOPTS}
|
|
56
|
|
57
|