Makefile: add autodependencies for header files.

This commit is contained in:
David Forrest 2012-11-14 10:59:18 -05:00 committed by Markus Hitter
parent fd24987a9f
commit 244d8b6654
2 changed files with 13 additions and 2 deletions

1
.gitignore vendored
View File

@ -12,6 +12,7 @@
*.i
*.s
*~
.depend
temporal.png
temporal_data

View File

@ -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,$@)