What about the name of the second prerequisite?

2019-06-14 Thread Dan Jacobson
(info "(make) Automatic Variables") has

'$<' The name of the first prerequisite...
'$?' The names of all the prerequisites that are newer than the target...
'$^' The names of all the prerequisites, with spaces between them...
'$+' This is like '$^', but prerequisites listed more than once are...
'$|' The names of all the order-only prerequisites...

OK, OK, OK, OK, OK!

But it really should also mention the official recommended way to (drum
roll)...

Get the name of the second prerequisite.

OK, the first born son inherits the throne. But at least document the
workaround for accessing the second born son. Thanks. P.S., third born
too. And how about last born also.

I'm not asking for code changes, just officially documenting the proper
way to access them.

___
Bug-make mailing list
Bug-make@gnu.org
https://lists.gnu.org/mailman/listinfo/bug-make


Re: What about the name of the second prerequisite?

2019-06-14 Thread Sam Kendall
Can be done with functions, e.g., the second prereq is $(word 2,$+). Given
that it’s straightforward composition of documented features, you’d want to
document it only if it were very commonly needed. Which it isn’t. That’s my
two cents, anyway.

Sam

On Fri, Jun 14, 2019 at 11:29 PM Dan Jacobson  wrote:

> (info "(make) Automatic Variables") has
>
> '$<' The name of the first prerequisite...
> '$?' The names of all the prerequisites that are newer than the target...
> '$^' The names of all the prerequisites, with spaces between them...
> '$+' This is like '$^', but prerequisites listed more than once are...
> '$|' The names of all the order-only prerequisites...
>
> OK, OK, OK, OK, OK!
>
> But it really should also mention the official recommended way to (drum
> roll)...
>
> Get the name of the second prerequisite.
>
> OK, the first born son inherits the throne. But at least document the
> workaround for accessing the second born son. Thanks. P.S., third born
> too. And how about last born also.
>
> I'm not asking for code changes, just officially documenting the proper
> way to access them.
>
> ___
> Bug-make mailing list
> Bug-make@gnu.org
> https://lists.gnu.org/mailman/listinfo/bug-make
>
___
Bug-make mailing list
Bug-make@gnu.org
https://lists.gnu.org/mailman/listinfo/bug-make


Re: What about the name of the second prerequisite?

2019-06-15 Thread Henrik Carlqvist
On Sat, 15 Jun 2019 08:35:13 +0800
Dan Jacobson  wrote:

> (info "(make) Automatic Variables") has
> 
> '$<' The name of the first prerequisite...
> '$?' The names of all the prerequisites that are newer than the
> target...'$^' The names of all the prerequisites, with spaces between
> them...'$+' This is like '$^', but prerequisites listed more than once
> are...'$|' The names of all the order-only prerequisites...
> 
> OK, OK, OK, OK, OK!
> 
> But it really should also mention the official recommended way to (drum
> roll)...
> 
> Get the name of the second prerequisite.

I would use the function word for that:

-8<--
all: dummy

dummy: dummy1 dummy2 dummy3
echo first: $< second: $(word 2, $^) third: $(word 3, $^)

dummy%:
touch $@
-8<--

regards Henrik

___
Bug-make mailing list
Bug-make@gnu.org
https://lists.gnu.org/mailman/listinfo/bug-make


Re: What about the name of the second prerequisite?

2019-06-15 Thread 積丹尼 Dan Jacobson
OK, on (info "(make) Automatic Variables") has
after
'$<'
 The name of the first prerequisite.  If the target got its recipe
 from an implicit rule, this will be the first prerequisite added by
 the implicit rule (*note Implicit Rules::).
add:
 To get the name of the second etc. prerequisite, use e.g., $(word 2,$+).

Thanks Sam. We would have never guessed (that is was safe to recommend.)
(Maybe elaborate if it is safe to use other than $+ too.)

___
Bug-make mailing list
Bug-make@gnu.org
https://lists.gnu.org/mailman/listinfo/bug-make