[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: set $*, $@ upon reaching the colon
From: |
Paul Smith |
Subject: |
Re: set $*, $@ upon reaching the colon |
Date: |
Mon, 02 Sep 2024 16:06:20 -0400 |
User-agent: |
Evolution 3.52.4 (by Flathub.org) |
On Thu, 2024-06-13 at 07:55 +0800, Dan Jacobson wrote:
> %.all.kmz: $(addsuffix .kml, $(addsuffix .$*.lines,0 1) $(addsuffix
> .$*.labels,0 1))
> ls $*
> $ make nnn.all.kmz
>
> Here, upon reaching the colon, the make program already has all the
> information it needs to set $* to "nnn".
That is not true.
In fact, make has NO IDEA what $@ or any other automatic variable will
be _when it is parsing the makefile and expanding the prerequisites_.
A pattern rule is a template that is applied not when the makefile is
being parsed, but rather when make is walking the dependency graph
trying to figure out which targets to build and how to build them. At
the time make is parsing this rule it has no idea what target will
match it, so it certainly cannot know that $@ will be nnn.all.kmz (for
example).
If you examine the content here:
https://www.gnu.org/software/make/manual/html_node/Reading-Makefiles.html
you will see in what order expansion happens.
If you want to defer expansion until later, you can use:
https://www.gnu.org/software/make/manual/html_node/Secondary-Expansion.html
--
Paul D. Smith <psmith@gnu.org> Find some GNU Make tips at:
https://www.gnu.org http://make.mad-scientist.net
"Please remain calm...I may be mad, but I am a professional." --Mad
Scientist
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Re: set $*, $@ upon reaching the colon,
Paul Smith <=