diff --git a/Makefile b/Makefile index 3afe7406..acb5dad2 100644 --- a/Makefile +++ b/Makefile @@ -62,6 +62,9 @@ endif .PHONY: all clean install version package +# Make all the default rule +all:: + # Include all makefiles for sub-modules include $(patsubst %,%/Module.mk,$(MODULES)) @@ -73,6 +76,12 @@ install:: clean:: $(RM) lm_sensors-* +# Create a dependency file. Tricky. +%.d: %.c + gcc -M -MG $(CFLAGS) $< | \ + sed -e 's@ /[^ ]*@@g' -e 's@^\(.*\)\.o:@\1.d \1.o:@' > $@ + + # This is tricky, but it works like a charm. It needs lots of utilities # though: cut, find, gzip, ln, tail and tar. package: version clean diff --git a/i2c/Module.mk b/i2c/Module.mk index c67855d7..080aed1c 100644 --- a/i2c/Module.mk +++ b/i2c/Module.mk @@ -7,6 +7,9 @@ TARGETS := $(MODULE_DIR)/i2c-core.o $(MODULE_DIR)/algo-bit.o \ $(MODULE_DIR)/i2c-dev.o $(MODULE_DIR)/bit-lp.o \ $(MODULE_DIR)/bit-velle.o $(MODULE_DIR)/bit-mb.o +# Include all dependency files +include $(TARGETS:.o=.d) + all :: $(TARGETS) install :: $(TARGETS) @@ -14,4 +17,4 @@ install :: $(TARGETS) install -o root -g root -m 644 $(MODDIR) $(TARGETS) clean :: - $(RM) $(TARGETS) + $(RM) $(TARGETS) $(TARGETS:.o=.d)