>> define my_broken_rule=
>> name::=${1}
>> ${name:.in=.txt}: ${1}
>>         $${my_test_command} $$< > $$@
>> endef
>>
>> $(eval $(call my_broken_rule,MOTD.in))
> 
> Yes, this will not work.

Thanks for your quick answer.


It might also be expected that this simple example just can not work
as intended because of a special typo (one dollar sign missing).


Corrected example:

my_test_command?=cat

define my_rule_demo=
name::=${1}
$${name:.in=.txt}: ${1}
        $${my_test_command} $$< > $$@
endef

$(eval $(call my_rule_demo,MOTD.in))



> Generally I recommend that people DO NOT try to create local variables

It can look a bit easier to understand when a numbered temporary
variable gets a reasonable alphabetic name as an alias.


> inside define'd makefile sections and instead just write out the
> reference you want each time.

I switched to an alphabetic variable name because of an unclear
aspect with “substitution references” and the impression that something
did not work as expected for the notation “${1}” at one place
while I was using the correct double dollar signs for the other variable.


> It's more verbose, but has many fewer side-effects.

Customised make functions trigger their own special development challenges
because of the risk to miscount dollar signs there.


How would you like to clarify remaining details from other requests?

Regards,
Markus

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

Reply via email to