14
|
1 #
|
|
2 # $Id$
|
|
3 #
|
|
4
|
2
|
5 .SUFFIXES: .hex .out .c .o .elf .dmp .s
|
|
6
|
|
7 # Programs
|
|
8 AS=avr-as
|
|
9 CC=avr-gcc
|
|
10 OBJCOPY=avr-objcopy
|
|
11 OBJDUMP=avr-objdump
|
|
12
|
|
13 CPPFLAGS+=-Wa,-adhlmsn=${<:S/.c/.lst/}
|
|
14
|
|
15 PART?=8515
|
|
16 MCU?=at90s${PART}
|
|
17 CFLAGS+=-mmcu=${MCU}
|
|
18
|
|
19 LDFLAGS+=-Wl,-Map=${PROG}.map,--cref
|
|
20 LDFLAGS+=${LDADD}
|
|
21
|
|
22 RM=rm -f
|
|
23
|
|
24 PROGRAMMER=avrdude
|
|
25 PROGOPTS=-p ${PART} -c alf -E vcc,noreset -q
|
|
26
|
|
27 .if !defined(SRCS)
|
|
28 SRCS= ${PROG}.c
|
|
29 .endif
|
|
30
|
|
31 OBJS+= ${SRCS:N*.h:R:S/$/.o/g}
|
|
32
|
|
33 all: ${PROG}.hex ${PROG}.dmp
|
|
34
|
|
35 .c.o:
|
|
36 ${CC} ${CFLAGS} ${CPPFLAGS} -c ${.IMPSRC} -o ${.PREFIX}.o
|
|
37
|
|
38 ${PROG}.elf: ${OBJS}
|
|
39 ${CC} ${CFLAGS} ${LDFLAGS} -g ${OBJS} -o ${PROG}.elf ${LDADD}
|
|
40
|
|
41 .elf.hex:
|
|
42 ${OBJCOPY} -j .text -O ihex $> $@
|
|
43
|
|
44 .elf.dmp:
|
|
45 ${OBJDUMP} -S ${.IMPSRC} > ${.PREFIX}.dmp
|
|
46
|
|
47 clean:
|
6
|
48 ${RM} ${PROG}.hex ${PROG}.out ${PROG}.elf ${PROG}.map ${OBJS} ${OBJS:S/.o/.lst/} ${PROG}.dmp
|
2
|
49
|
|
50 prog: all
|
|
51 ${PROGRAMMER} -U flash:w:${PROG}.hex ${PROGOPTS}
|
|
52
|
|
53
|