Re: Multiple rules for same target: what is the order of prerequisites in $^ and what does $< expand to?

Bahman Movaqar <[email protected]>
Newsgroups gmane.comp.gnu.make.general
Message-ID <[email protected]>
On Wed, 2023-09-27 at 16:50 +0200, Renaud Pacalet wrote:

> %.a: %.b
> 
> a.a: a.c
>      echo $^
> 
> I would not say that the pattern rule and the explicit rule are
> equivalent because they have different prerequisite lists, the former
> has no recipe, the latter has one. Yet, running 'touch a.c a.b; make -s
> a.a' prints only 'a.c', which shows that the pattern rule is ignored.

To my mind, it makes sense b/c `a.a' is more specific than `%.a' and as
such the prerequisites declared by the pattern rule do not apply.

To add a little twist here, the following snippet produces `foo a.c' 🙂

🙶
%.a : X = foo
%.a: %.b

a.a: a.c
	@echo $(X) $(^)
🙸

-- 
Bahman

Join the chatter on Matrix:
         🌐 https://matrix.to/#/#.mk:matrix.org
      
Subscribe to the Lemmy community:
         🌐 https://lemmy.ml/c/makefile
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.