help-make
[Top][All Lists]
Advanced

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

Re: How to write rule that gets all items referenced in a given makefile


From: Paul Smith
Subject: Re: How to write rule that gets all items referenced in a given makefile
Date: Tue, 05 Jul 2016 15:42:00 -0400

On Tue, 2016-07-05 at 16:50 +0000, Adrian Muresan wrote:
> Is there a built-in function to extract all the prerequisites for
> target in a makefile?

It's not clear exactly what you want to do, but no, there is no built-
in function that provides this information.

Of course, from within a recipe you can use the $^ automatic variable,
which contains all the prerequisites of the current target.

> I could probably make a rule that will parse the makefile as a
> textfile from the shell but since `make` already parses the targets
> and prereqs I'm hoping there's a built-in way.

It's not that simple in all cases: for example, make won't attempt to
resolve suffix and pattern rules until it finds a target that needs to
use that rule to build, and so the complete set of prerequisites can't
be known until that time.

Similarly, new prerequisites could be added to an existing target at
any time, so any list of prerequisites obtained before all makefiles
are parsed will always be suspect.



reply via email to

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