changeset 2:288d801a47ff

Use nicer build framework.
author darius
date Sun, 11 Jul 2004 22:06:14 +0930
parents ffeab3c04e83
children ee3c9a16099e
files Makefile Makefile.avr
diffstat 2 files changed, 53 insertions(+), 28 deletions(-) [+]
line wrap: on
line diff
--- a/Makefile	Sun Jul 11 00:45:50 2004 +0930
+++ b/Makefile	Sun Jul 11 22:06:14 2004 +0930
@@ -1,30 +1,6 @@
-# Programs
-PROG=avrdude
-CC=avr-gcc
-OBJCOPY=avr-objcopy
-
-# Options
-PART=8515
-MCU=at90s${PART}
-CFLAGS=-Os -g -mmcu=${MCU} -Wa,-adhlmsn=$(<:.c=.lst) -Wall
-LDFLAGS=
-LDADD=
-RM=rm -f
-
-all: testavr.hex
+PROG=testavr
+SRCS=1wire.c testavr.c
 
-testavr.hex: testavr.out
-	${OBJCOPY} -j .text -j .data -j .bss -O ihex $> $@
-#	${OBJCOPY} -j .text -O ihex $> $@
-
-testavr.out: testavr.o 1wire.o
-	${CC} ${LDFLAGS} -g -mmcu=${MCU} -o $@ $>
+CFLAGS=-Os -g
 
-.c.o:
-	${CC} ${CFLAGS} -c $> -o $@
-
-clean:
-	${RM} testavr.hex testavr.out testavr.o
-
-prog: testavr.hex
-	${PROG} -U flash:w:$> -p ${PART} -c alf -E vcc,noreset -q
+.include "Makefile.avr"
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Makefile.avr	Sun Jul 11 22:06:14 2004 +0930
@@ -0,0 +1,49 @@
+.SUFFIXES: .hex .out .c .o .elf .dmp .s
+
+# Programs
+AS=avr-as
+CC=avr-gcc
+OBJCOPY=avr-objcopy
+OBJDUMP=avr-objdump
+
+CPPFLAGS+=-Wa,-adhlmsn=${<:S/.c/.lst/}
+
+PART?=8515
+MCU?=at90s${PART}
+CFLAGS+=-mmcu=${MCU}
+
+LDFLAGS+=-Wl,-Map=${PROG}.map,--cref
+LDFLAGS+=${LDADD}
+
+RM=rm -f
+
+PROGRAMMER=avrdude
+PROGOPTS=-p ${PART} -c alf -E vcc,noreset -q
+
+.if !defined(SRCS)
+SRCS=	${PROG}.c
+.endif
+
+OBJS+=  ${SRCS:N*.h:R:S/$/.o/g}
+
+all: ${PROG}.hex ${PROG}.dmp
+
+.c.o:
+	${CC} ${CFLAGS} ${CPPFLAGS} -c ${.IMPSRC} -o ${.PREFIX}.o
+
+${PROG}.elf: ${OBJS}
+	${CC} ${CFLAGS} ${LDFLAGS} -g ${OBJS} -o ${PROG}.elf ${LDADD}
+
+.elf.hex:
+	${OBJCOPY} -j .text -O ihex $> $@
+
+.elf.dmp:
+	${OBJDUMP} -S ${.IMPSRC} > ${.PREFIX}.dmp
+
+clean:
+	${RM} ${PROG}.s19 ${PROG}.out ${PROG}.elf ${PROG}.map ${OBJS} ${OBJS:S/.o/.lst/} ${PROG}.dmp
+
+prog: all
+	${PROGRAMMER} -U flash:w:${PROG}.hex ${PROGOPTS}
+
+