automake
[Top][All Lists]
Advanced

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

Re: Automake Digest, Vol 175, Issue 3


From: Nick Bowler
Subject: Re: Automake Digest, Vol 175, Issue 3
Date: Tue, 5 Sep 2017 18:57:55 -0400

On 2017-09-05, Kip Warner <address@hidden> 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 via email to

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