[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Checking alternatives for a dynamic make rule construction

From: SF Markus Elfring
Subject: Re: Checking alternatives for a dynamic make rule construction
Date: Sat, 17 Jun 2017 17:00:38 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.0

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


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

$(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?


reply via email to

[Prev in Thread] Current Thread [Next in Thread]