[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Target-specific variable in subdirectory problem
From: |
Paul Smith |
Subject: |
Re: Target-specific variable in subdirectory problem |
Date: |
Wed, 02 Aug 2017 15:16:46 -0400 |
On Wed, 2017-08-02 at 20:03 +0100, Sven C. Dack wrote:
> Hello,
>
> try it with the following rules:
>
> test-%: $(eval FOO = BAR)
> test-%:
> echo $(FOO)
No, this doesn't do what the OP wants. The eval in the prerequisites
of the pattern is expanded immediately so this is identical to writing:
FOO = BAR
test-%:
test-%:
echo $(FOO)
which clearly explains your output.
> On 02/08/17 11:19, Benjamin Cama wrote:
> > Hi,
> >
> > I may be doing something wrong, but the following Makefile gives me
> > strange results: the target-specific variable does not apply when
> > used
> > for a target in a subdirectory.
> >
> > test-%: FOO = BAR
> > test-%:
> > echo $(FOO)
> >
> > E.g.:
> >
> > $ make test-stem
> > echo BAR
> > BAR
> > $ make subdir/test-stem
> > echo
Pattern rules have a special dispensation for handling patterns with a
directory prefix, described here:
https://www.gnu.org/software/make/manual/html_node/Pattern-Match.html
> When the target pattern does not contain a slash (and it usually does
> not), directory names in the file names are removed from the file
> name before it is compared with the target prefix and suffix. After
> the comparison of the file name to the target pattern, the directory
> names, along with the slash that ends them, are added on to the
> prerequisite file names generated from the pattern rule’s
> prerequisite patterns and the file name.
That's how "subdir/test-stem" can match a pattern "test-%" which you
normally would not expect it to match.
However, pattern-specific variables do not have this special
dispensation. They are simple pattern matches with no special rules
for dealing with directories. So, "subdir/test-stem" doesn't match the
pattern "test-%" for a pattern-specific variable.
It's possible that this is a mis-feature and that pattern-specific
variables should have this special capability as well, but they were
not intended to do so when originally created. You could file an
enhancement request on Savannah if you like:
https://savannah.gnu.org/bugs/?func=additem&group=make
- Re: Target-specific variable in subdirectory problem, (continued)
- Re: Target-specific variable in subdirectory problem, Edward Welbourne, 2017/08/02
- Re: Target-specific variable in subdirectory problem, Sven C. Dack, 2017/08/02
- Re: Target-specific variable in subdirectory problem, Kyle Rose, 2017/08/02
- Re: Target-specific variable in subdirectory problem, Sven C. Dack, 2017/08/02
- Re: Target-specific variable in subdirectory problem, Paul Smith, 2017/08/02
- Re: Target-specific variable in subdirectory problem, Sven C. Dack, 2017/08/02
- Re: Target-specific variable in subdirectory problem, Kyle Rose, 2017/08/02
- Re: Target-specific variable in subdirectory problem, Paul Smith, 2017/08/02
- Re: Target-specific variable in subdirectory problem, Sven C. Dack, 2017/08/02
- Re: Target-specific variable in subdirectory problem, Henrik Carlqvist, 2017/08/02
Re: Target-specific variable in subdirectory problem,
Paul Smith <=
Re: Target-specific variable in subdirectory problem, Benjamin Cama, 2017/08/03
Message not availableRe: Target-specific variable in subdirectory problem, Benjamin Cama, 2017/08/03
Targets directory name concatenation strangeness, Benjamin Cama, 2017/08/03
RE: Targets directory name concatenation strangeness, Martin Dorey, 2017/08/03
Re: Targets directory name concatenation strangeness, Benjamin Cama, 2017/08/03
Re: Targets directory name concatenation strangeness, Kyle Rose, 2017/08/03
Fwd: Re: Target-specific variable in subdirectory problem, Sven C. Dack, 2017/08/03