Discussion:
Automake Digest, Vol 175, Issue 3
Kip Warner
2017-09-05 22:25:18 UTC
Permalink
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
Nick Bowler
2017-09-05 22:57:55 UTC
Permalink
On 2017-09-05, Kip Warner <***@thevertigo.com> wrote:
[...]
Post by Kip Warner
Hey Thomas. Good question. It could well be that no hackery at all is
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
Thomas Jahns
2017-09-07 08:22:50 UTC
Permalink
Hello,
Post by Nick Bowler
[...]
Post by Kip Warner
Hey Thomas. Good question. It could well be that no hackery at all is
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.
% cat >Makefile <<'EOF'
FOO = a b/c d/e/f
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.
Post by Nick Bowler
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
Kip Warner
2017-09-08 01:25:57 UTC
Permalink
Post by Thomas Jahns
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.
Post by Thomas Jahns
Post by Nick Bowler
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
Václav Haisman
2017-09-08 11:40:53 UTC
Permalink
Post by Kip Warner
Post by Thomas Jahns
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.
Post by Thomas Jahns
Post by Nick Bowler
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
Kip Warner
2017-09-08 19:43:46 UTC
Permalink
Post by Václav Haisman
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
Kip Warner
2017-09-08 01:23:55 UTC
Permalink
Post by Nick Bowler
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.
Post by Nick Bowler
  % cat >Makefile <<'EOF'
  FOO = a b/c d/e/f
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
Loading...