From 244d8b6654f765e3719fb09048e0f09dec48c374 Mon Sep 17 00:00:00 2001 From: David Forrest Date: Wed, 14 Nov 2012 10:59:18 -0500 Subject: [PATCH] Makefile: add autodependencies for header files. --- .gitignore | 1 + Makefile | 14 ++++++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 8344773..642a72b 100644 --- a/.gitignore +++ b/.gitignore @@ -12,6 +12,7 @@ *.i *.s *~ +.depend temporal.png temporal_data diff --git a/Makefile b/Makefile index f797024..0a1d3aa 100644 --- a/Makefile +++ b/Makefile @@ -130,7 +130,7 @@ endif OBJ = $(patsubst %.c,%.o,${SOURCES}) -.PHONY: all program clean size subdirs doc functionsbysize +.PHONY: all program clean size subdirs doc functionsbysize depend .PRECIOUS: %.o %.elf all: config.h subdirs $(PROGRAM).hex $(PROGRAM).lst $(PROGRAM).sym size @@ -150,7 +150,7 @@ program: $(PROGRAM).hex config.h stty 115200 raw ignbrk -hup -echo ixoff < $(PROGPORT) clean: clean-subdirs - rm -rf *.o *.elf *.lst *.map *.sym *.lss *.eep *.srec *.bin *.hex *.al *.i *.s *~ + rm -rf *.o *.elf *.lst *.map *.sym *.lss *.eep *.srec *.bin *.hex *.al *.i *.s *~ .depend clean-subdirs: @for dir in $(SUBDIRS); do \ @@ -176,6 +176,16 @@ doc: Doxyfile *.c *.h functionsbysize: $(OBJ) @avr-objdump -h $^ | grep '\.text\.' | perl -ne '/\.text\.(\S+)\s+([0-9a-f]+)/ && printf "%u\t%s\n", eval("0x$$2"), $$1;' | sort -n +depend: .depend + @true + +.depend: $(SOURCES) + rm -f .depend + $(CC) $(CFLAGS) -MM $^ > .depend; + +# pull in dependency info +-include .depend + %.o: %.c config.h Makefile @echo " CC $@" @$(CC) -c $(CFLAGS) -Wa,-adhlns=$(<:.c=.al) -o $@ $(subst .o,.c,$@)