Re: Automake Digest, Vol 175, Issue 3

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

Re: Automake Digest, Vol 175, Issue 3

Kip Warner
On Mon, 2017-09-04 at 12:00 -0400, [hidden email] wrote:
> Can you give more context why you need to substitute on the left-
> hand-side here? 
> It's after all simply a Makefile-Variable, so I don't exactly see
> what's the 
> purpose.

Hey Thomas. Good question. It could well be that no hackery at all is
required with this. Here is my Makefile.am:

https://github.com/cartesiantheatre/narayan-designer/blob/master/Source/Makefile.am

See parser_clobbered_source_full_paths as an example. This variant
containing the full path is used in BUILT_SOURCES, nodist_..._SOURCES,
CLEANFILES, and as a target.

The parser_clobbered_source_files_only variant containing the file
names only is used on line 150 as a workaround for where bisonc++(1)
emits its files.

If you can see a more elegant way of solving the same problem I'm
trying to, I'm all ears.

--
Kip Warner | Senior Software Engineer
OpenPGP signed/encrypted mail preferred
http://www.thevertigo.com

signature.asc (169 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Automake Digest, Vol 175, Issue 3

Nick Bowler
On 2017-09-05, Kip Warner <[hidden email]> wrote:
[...]

> Hey Thomas. Good question. It could well be that no hackery at all is
> required with this. Here is my Makefile.am:
>
> https://github.com/cartesiantheatre/narayan-designer/blob/master/Source/Makefile.am
>
> See parser_clobbered_source_full_paths as an example. This variant
> containing the full path is used in BUILT_SOURCES, nodist_..._SOURCES,
> CLEANFILES, and as a target.
>
> The parser_clobbered_source_files_only variant containing the file
> names only is used on line 150 as a workaround for where bisonc++(1)
> emits its files.
>
> If you can see a more elegant way of solving the same problem I'm
> trying to, I'm all ears.

If your only uses of the directoryless-filenames are in rules, then
just write the names including directories in the make variables,
then strip off the directory components inside the rule.  In rules
you can use the much more powerful shell constructs.

Example:

  % cat >Makefile <<'EOF'
  FOO = a b/c d/e/f

  my_rule:
        for i in $(FOO); do \
          case $$i in */*) i=`expr "$$i" : '.*/\(.*\)'`; esac; \
          printf '%s\n' "$$i"; \
        done
EOF
  % make my_rule
  a
  c
  f

If you assume a reasonably-POSIXish shell, you can use something like
$${i##*/} to strip directory parts instead (I think this form will fail
on at least Solaris /bin/sh).

Cheers,
  Nick

Reply | Threaded
Open this post in threaded view
|

Re: Automake Digest, Vol 175, Issue 3

Thomas Jahns
Hello,

On 09/06/17 00:57, Nick Bowler wrote:

> On 2017-09-05, Kip Warner <[hidden email]> wrote:
> [...]
>> Hey Thomas. Good question. It could well be that no hackery at all is
>> required with this. Here is my Makefile.am:
>>
>> https://github.com/cartesiantheatre/narayan-designer/blob/master/Source/Makefile.am
>>
>> See parser_clobbered_source_full_paths as an example. This variant
>> containing the full path is used in BUILT_SOURCES, nodist_..._SOURCES,
>> CLEANFILES, and as a target.
>>
>> The parser_clobbered_source_files_only variant containing the file
>> names only is used on line 150 as a workaround for where bisonc++(1)
>> emits its files.
>>
>> If you can see a more elegant way of solving the same problem I'm
>> trying to, I'm all ears.
>
> If your only uses of the directoryless-filenames are in rules, then
> just write the names including directories in the make variables,
> then strip off the directory components inside the rule.  In rules
> you can use the much more powerful shell constructs.
>
> Example:
>
>    % cat >Makefile <<'EOF'
>    FOO = a b/c d/e/f
>
>    my_rule:
> for i in $(FOO); do \
>  case $$i in */*) i=`expr "$$i" : '.*/\(.*\)'`; esac; \
>  printf '%s\n' "$$i"; \
> done
> EOF
>    % make my_rule
>    a
>    c
>    f
Really the only part, where names need to be included verbatim is in so-called
automake primaries. Those need the names for the make dist rules. In other
words, files that are not distributed don't need to be spelled out, the name can
be computed instead. If you want to add or remove the directory part is then
more a question of whether the files with or without need to go into the
distribution tar.xz.

> If you assume a reasonably-POSIXish shell, you can use something like
> $${i##*/} to strip directory parts instead (I think this form will fail
> on at least Solaris /bin/sh).

That's an argument in favor of adding the directory part since no comparable
portability headache applies to

"dir/$$i"

Regards, Thomas


smime.p7s (6K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Automake Digest, Vol 175, Issue 3

Kip Warner
In reply to this post by Nick Bowler
On Tue, 2017-09-05 at 18:57 -0400, Nick Bowler wrote:
> If your only uses of the directoryless-filenames are in rules, then
> just write the names including directories in the make variables,
> then strip off the directory components inside the rule.  In rules
> you can use the much more powerful shell constructs.

Hey Nick.

> Example:
>
>   % cat >Makefile <<'EOF'
>   FOO = a b/c d/e/f
>
>   my_rule:
> for i in $(FOO); do \
>   case $$i in */*) i=`expr "$$i" : '.*/\(.*\)'`; esac; \
>   printf '%s\n' "$$i"; \
> done
> EOF
>   % make my_rule
>   a
>   c
>   f
This would work beautifully, except the short version of the file names
has to be computed in advance for the _SOURCES Automake primary as
Thomas hinted at. I'm not sure how Automake parses those variables, but
I'm assuming they have to be computed in advance if you're also using
them outside of a rule.

--
Kip Warner | Senior Software Engineer
OpenPGP signed/encrypted mail preferred
http://www.thevertigo.com

signature.asc (169 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Automake Digest, Vol 175, Issue 3

Kip Warner
In reply to this post by Thomas Jahns
On Thu, 2017-09-07 at 10:22 +0200, Thomas Jahns wrote:
> Really the only part, where names need to be included verbatim is in
> so-called automake primaries.

Exactly. And since the full paths are necessary to populate the
_SOURCES primary in order to have the various build and dist rules
function correctly, I think Nick's solution won't work in this
scenario.

> > If you assume a reasonably-POSIXish shell, you can use something
> > like $${i##*/} to strip directory parts instead (I think this form
> > will fail on at least Solaris /bin/sh).
>
> That's an argument in favor of adding the directory part since no
> comparable portability headache applies to
>
> "dir/$$i"

Good call Thomas. It would have been no problem to keep the trailing
slash, and personally I prefer it.

--
Kip Warner | Senior Software Engineer
OpenPGP signed/encrypted mail preferred
http://www.thevertigo.com

signature.asc (169 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Automake Digest, Vol 175, Issue 3

Václav Zeman
On 8 September 2017 at 03:25, Kip Warner <[hidden email]> wrote:

> On Thu, 2017-09-07 at 10:22 +0200, Thomas Jahns wrote:
> > Really the only part, where names need to be included verbatim is in
> > so-called automake primaries.
>
> Exactly. And since the full paths are necessary to populate the
> _SOURCES primary in order to have the various build and dist rules
> function correctly, I think Nick's solution won't work in this
> scenario.
>
> > > If you assume a reasonably-POSIXish shell, you can use something
> > > like $${i##*/} to strip directory parts instead (I think this form
> > > will fail on at least Solaris /bin/sh).
> >
> > That's an argument in favor of adding the directory part since no
> > comparable portability headache applies to
> >
> > "dir/$$i"
>
> Good call Thomas. It would have been no problem to keep the trailing
> slash, and personally I prefer it.
>
> ​
You might want to look at AutoGen (https://www.gnu.org/software/autogen/)
and use that to create the Makefile.am contents.


--
VH
Reply | Threaded
Open this post in threaded view
|

Re: Automake Digest, Vol 175, Issue 3

Kip Warner
On Fri, 2017-09-08 at 13:40 +0200, Václav Haisman wrote:
> You might want to look at AutoGen
> (https://www.gnu.org/software/autogen/) and use that to create the
> Makefile.am contents.

Thanks Václav.

--
Kip Warner | Senior Software Engineer
OpenPGP signed/encrypted mail preferred
http://www.thevertigo.com

signature.asc (169 bytes) Download Attachment