On Mon, 2023-10-02 at 09:08 -0400, Paul Smith wrote:
> The behavior is straightforward: when make parses a rule _without_ a
> recipe, it will append new prerequisites to the END of its targets'
> list of prerequisites.
> 
> When make parses an explicit rule that _has_ a recipe, then those
> prerequisites are added to the BEGINNING of the target's list of
> prerequisites.
> 
> For implicit rules, the prerequisites on the matching rule are added to
> the BEGINNING of the target's list of prerequisites when it matches.

That's an excellent summary!  

> I'm not sure what you mean by "reliability"

I think the important bit is that since the prerequisite list can be
modified in other parts of the same make file or even in other files,
relying on its value is quite a game of dice.

For example, in the following snippet, it's not immediately visible
what's the value of `$(<)' w/o reading all make files and becoming
intimate w/ them.  It's also made more confusing b/c its value of depends
on the order of `include's.

———————————————————————————————————————————————————————
##########
# bar.mk

.PHONY : bar

bar :
        @echo bar

my-target : bar

##########
# baz.mk

.PHONY : baz

baz :
        @echo baz

my-target : baz


##########
# foo.mk

.PHONY : foo

foo :
        @echo foo

#########
# Makefile

include foo.mk
include baz.mk
include bar.mk

.PHONY : my-target

my-target : foo
my-target :
        @echo 'my-target: $$(<) is $(<)'


#########

$ make my-target
baz
bar
foo
my-target: $(<) is baz
———————————————————————————————————————————————————————


That brings me to the natural question:  why would anyone ever use
`$(<)'?  In other words, what is an appropriate usecase for that
variable?

-- 
Bahman

Join the chatter on Matrix:
         🌐 https://matrix.to/#/#.mk:matrix.org
      
Subscribe to the Lemmy community:
         🌐 https://lemmy.ml/c/makefile



Reply via email to