Surely the -MMD solution with -include $(objects:.o=.d) does the trick cleaner than the method mentioned in the manual.
Edward, are you rewriting the Make manual? I hope that you do include an example, besides the explanation below. You guys have been most helpful. Cheers Edward Welbourne <e...@opera.com> 28-04-2010 16:12 Please respond to e...@opera.com To Mike Shal <mar...@gmail.com> cc r...@bang-olufsen.dk, bug-make@gnu.org Subject Re: Shorter and less error-prone rule for automatic prerequisite generation in the GNU Make manual > It's also unnecessary - you don't need a rule for %.d at all. You can > just generate the dependencies as a side-effect of compilation using > -MMD or similar. Well, if a .d file gets deleted while its .o file exists, you do need to regenerate it - or regenerate the .o (which may cause wasteful knock-on actions since it's now newer than it was, even if unchanged). This matters if, for example, you have a make clean-depend rule to purge dependency information. > Then use '-include' to grab all the deps if they exist. better: include only the .d files that correspond to .o files *that exist* - if the .o file doesn't exist, you don't need to know what it depends on, aside from the primary source from which it's compiled (which is indicated by the pattern rule that makes the .o file). > By providing a rule for the .d files you'll cause make to > re-execute itself, so you'll just end up parsing the Makefile twice. Only if you include .d files that aren't really needed (which is common practice). Amendments along these lines are part of the doc-update I keep not finding time to finish up ... Eddy.
_______________________________________________ Bug-make mailing list Bug-make@gnu.org http://lists.gnu.org/mailman/listinfo/bug-make