[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Multiple rules for same target: what is the order of prerequisites i
From: |
Paul Smith |
Subject: |
Re: Multiple rules for same target: what is the order of prerequisites in $^ and what does $< expand to? |
Date: |
Mon, 02 Oct 2023 14:56:08 -0400 |
User-agent: |
Evolution 3.48.4 (by Flathub.org) |
On Mon, 2023-10-02 at 11:48 -0700, Bahman Movaqar wrote:
> my-target : foo
> my-target :
> @echo 'my-target: $$(<) is $(<)'
This is an unusual way to construct this rule. Normally it would be:
my-target : foo
@echo 'my-target: $$< is $<'
whereupon the value of $< is reliably "foo" regardless of anything else
in the makefile.
> That brings me to the natural question: why would anyone ever use
> `$(<)'? In other words, what is an appropriate usecase for that
> variable?
You have to use automatic variables, including $<, when you write
implicit rules. There is no other option.
I agree that if you're writing a rule with a recipe and you DO NOT
provide at least one prerequisite, it's probably a bad idea to use $<
in the recipe since you have no idea what it will be.