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 Mon, 2023-10-02 at 14:56 -0400, Paul Smith wrote:
> 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.

Thanks for the hint re style.  Finding good examples of writing easy-to-
read make files is no easy feat.  That's why I do have these inaccuracies
in my personal style.

> 
> > 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.

That makes sense.  Thanks.

-- 
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.