bug-make
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Shorter and less error-prone rule for automatic prerequisite generat


From: Edward Welbourne
Subject: Re: Shorter and less error-prone rule for automatic prerequisite generation in the GNU Make manual
Date: Wed, 28 Apr 2010 16:12:02 +0200

> 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.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]