[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: |
Adrian Muresan |
Subject: |
Re: How to write rule that gets all items referenced in a given makefile |
Date: |
Fri, 8 Jul 2016 19:10:00 +0000 |
Someone at stackoverflow gave me the answer:
%:: null
@:
null:
@:
which I pass in like so: `make all MAKEFILES=Dummy.mk`
This captures ALL the files. The double-colon is "terminal rule" (see
https://www.gnu.org/software/make/manual/make#Match_002dAnything-Rules)
When I run this, for every single target I get a statement
:2: update target <target> due to: null
And in the `--print-data-base` section, there is no file that is listed as `#
Not a target`, only the 68 implicit rules.
This solution appears to only work on Windows: someone said they tried this on
Linux and it doesn't work
http://stackoverflow.com/questions/38250056/gnu-make-terminal-rules-and-keyword-null/38252249#comment63925596_38252249
________________________________
From: Tim Murphy <address@hidden>
Sent: Wednesday, July 6, 2016 12:38 AM
To: Adrian Muresan
Cc: address@hidden
Subject: Re: How to write rule that gets all items referenced in a given
makefile
Ok, so you want the state of make just after parsing finishes. Without
patching make or modifying every rule I think your plan for using the printed
database is the best you can manage. The database output is quicker to parse
than your original makefile usually.
If your makefiles use $(shell) then that might possibly cause trouble with this
scheme.
Regards,
Tim
On 6 July 2016 at 07:13, Adrian Muresan <address@hidden<mailto:address@hidden>>
wrote:
Yes, I am using it and yes the info it gives is very useful, parseable and
excellent in general.
The problem is that this information is only outputted by `make` AFTER the
makefile is finished executing whereas I need to access this information - via
some function that apparently doesn't exist - BEFORE the makefile rules start
executing so that I can create rules that act on his information.
As it stands, I'd have to run my build twice: once to get the info and another
time to use the info.
Given my esoteric task, it's not unreasonable for me to do this.
1. Make all
2. Parse output, generate whatever rules I need -> Generated_Rules.mk
3. Make all MAKEFILES=Generated_Rules.mk
> On Jul 5, 2016, at 11:44 PM, Tim Murphy
> <address@hidden<mailto:address@hidden>> wrote:
>
> You might want to use makes -p option (--print-data-base) to print out the
> targets and prereqs that it has read. The format of this output is
> simplified - all variables etc are expanded - so in python it's very easy to
> parse.
>
> Regards,
>
> Tim