Follow-up Comment #4, bug #59399 (project make):

As always I'm ignoring as irrelevant who implemented what first.

Using $< is very trivial.  It always expands to the first prerequisite in the
rule that contains the recipe.  That's true for double-colon rules as well of
course.  For example:


all: foo bar

foo:
foo: blah

foo: biz; : $<

bar:: boz yadda; : $<
bar:: baz yadda; : $<

biz boz baz blah yadda: ;@:


will print:


: biz
: boz
: baz


Using $* is more complicated but the GNU make manual describes it pretty well
I think:

https://www.gnu.org/software/make/manual/html_node/Automatic-Variables.html


     In an explicit rule, there is no stem; so '$*' cannot be determined
     in that way.  Instead, if the target name ends with a recognized
     suffix (*note Old-Fashioned Suffix Rules: Suffix Rules.), '$*' is
     set to the target name minus the suffix.  For example, if the
     target name is 'foo.c', then '$*' is set to 'foo', since '.c' is a
     suffix.  GNU 'make' does this bizarre thing only for compatibility
     with other implementations of 'make'.  You should generally avoid
     using '$*' except in implicit rules or static pattern rules.

     If the target name in an explicit rule does not end with a
     recognized suffix, '$*' is set to the empty string for that rule.


This text has not been changed since Roland's 1992 version of the manual.

    _______________________________________________________

Reply to this item at:

  <https://savannah.gnu.org/bugs/?59399>

_______________________________________________
  Message sent via Savannah
  https://savannah.gnu.org/


Reply via email to