Subject: bug#13524: [PATCH 1/2] preproc: add support for relative names in included fragments

From: Stefano Lattarini <[email-masked]>
Date: Thu, 14 Feb 2013 13:39:41 +0100

On 02/14/2013 01:20 PM, Bert Wesarg wrote:
> Hi,
> 
> On Thu, Feb 14, 2013 at 11:26 AM, Stefano Lattarini wrote:
>
>> diff --git a/NEWS b/NEWS
>> index 6dcce72..e27e0cf 100644
>> --- a/NEWS
>> +++ b/NEWS
>> @@ -100,6 +100,18 @@ New in 1.13.2:
>>      be longer necessary, so we deprecate it with runtime warnings.  It will
>>      likely be removed altogether in Automake 1.14.
>>
>> +* Relative directory in Makefile fragments:
>> +
>> +  - The special Automake-time substitutions '%reldir%' and '%canon_reldir%'
>> +    (and their short versions, '%D%' and '%C%' respectively) can now be used
>> +    in an included Makefile fragment.  The former is substituted with the
>> +    relative directory of the included fragment (compared to the top level
>> +    including Makefile), and the latter with the canonicalized version of
>> +    the same relative directory:
>> +
>> +        bin_PROGRAMS += %reldir%/foo
>> +        %canon_reldir%_foo_SOURCES = {reldir}/bar.c
> 
> the rejected '{reldir}' is still used in this example.
>
Yikes!  Good catch, fixed now.  Thanks.

> Does this substition happens in the whole file, or only in specific
> syntactic constructs?
>
On the whole file, before the automake limited makefile parser is
called.  This is by design.

> What definitily will not work ist something like this, right?
> 
> here = %reldir%
> target = %canon_reldir%/foo
> 
>         bin_PROGRAMS += ${here}/foo
>         ${target}_SOURCES = ${here}/bar.c
>
The ${target}_SOURCES wouldn't work even when no %...% substitution
is used.  As for ${here}, it can work only if that variable is not
redefined in other included fragments.  But the reason behind the
%reldir% introduction is exactly saving the developers from the need
of using this kind of brittle indirections ...
> 
> Speaking of 'here' wouldn't that also an candidate instead of
> 'reldir'?
>
Actually I find the latter clearer and more expressive.  After all,
what we are expanding is exactly the relative directory of the
current makefile fragment w.r.t. the "master" makefile, so the
name 'reldir' sounds really appropriate.

> and %.% as the shortform of %reldir% does sound:
> 
>         bin_PROGRAMS += %.%/foo
>         %canon_here%_foo_SOURCES = %.%/bar.c
>
I find the above rather unreadable; the existing '%D%' shorthand
is good enough IMHO.

Thanks,
  Stefano