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 _______________________________________________ Bug-make mailing list Bug-make@gnu.org https://lists.gnu.org/mailman/listinfo/bug-make