Make implicit rules and header files

c, header-files, makefile

Solution

You don't need to write the rule, only the dependencies. Example:

foo.o : foo.h bar.h

The file foo.o will still be generated by the implicit rule, but have the additional dependencies `foo.h` and `bar.h`. This dependency line can also be auto-generated by most compilers.

Problem

Make's implicit rules are supposedly there to make writing Makefiles easier but, if my understanding is correct, if my C files depend on any header files, I need to write the rule, explicitly. Am I right? This seems to serioiusly lower the usefulness of implicit rules, since most C files depend on a couple of header files, so I thought perhaps there's something I'm missing.

Original source