diff --git a/Makefile b/Makefile index d2abae1a..7cba4462 100644 --- a/Makefile +++ b/Makefile @@ -22,20 +22,17 @@ INSTALL_DATA = ${INSTALL} -m 444 INSTALL_MANUAL = ${INSTALL_DATA} -OBJS = avr.o fileio.o main.o ppi.o term.o LIBS = -lreadline -all : ${TARGET} +.include "Makefile.inc" + +all : + make depend + make ${TARGET} ${TARGET} : ${OBJS} ${CC} ${LDFLAGS} -o ${TARGET} ${OBJS} ${LIBS} -main.o : avr.h fileio.h ppi.h term.h pindefs.h -avr.o : avr.h ppi.h pindefs.h -fileio.o : fileio.h avr.h -ppi.o : ppi.h -term.o : term.h avr.h pindefs.h ppi.h - clean : rm -f *~ *.core ${TARGET} *.o diff --git a/Makefile.inc b/Makefile.inc new file mode 100644 index 00000000..e22d5242 --- /dev/null +++ b/Makefile.inc @@ -0,0 +1,39 @@ + +.SUFFIXES: .o .c + +first_rule : all + + +.depend : .PHONY + @echo "# dependencies generated `date +'%D %T'`" > .depend + @echo >> .depend + @echo "# SUBDIR=`pwd`" >> .depend + @echo >> .depend + @echo >> .depend + @echo "SRCS = \\" >> .depend + @for i in *.S *.c; do \ + if [ -f "$$i" ]; then \ + echo " $$i \\" >> .depend; \ + fi ; \ + done + @echo >> .depend + @echo "OBJS = \\" >> .depend + @for i in *.S *.c; do \ + if [ -f "$$i" ]; then \ + echo " $${i%%.*}.o \\" >> .depend; \ + fi ; \ + done + @echo >> .depend + @for i in *.S *.c; do \ + if [ -f "$$i" ]; then \ + $(CC) -E $(CFLAGS) -M $$i >> .depend; \ + fi ; \ + done + @echo >> .depend + +.if exists(.depend) +.include ".depend" +.endif + +depend : .depend +