On Mon, Feb 28, 2005 at 01:10:25PM -0600, Manoj Srivastava wrote:
> The problem lies in your use of the function wildcard.
Ick, thank you for pointing this out.
> $(wildcard PATTERN...)
>
> This string, used anywhere in a makefile, is replaced by a
> space-separated list of names of existing files that match one of the
> given file name patterns. If no existing file name matches a pattern,
> then that pattern is omitted from the output of the `wildcard'
> function. Note that this is different from how unmatched wildcards
> behave in rules, where they are used verbatim rather than ignored
> (*note Wildcard Pitfall::).
This last sentence is slightly inaccurate (or perhaps ambiguous,
depending on the meaning of "unmatched"). If ~/foo (where foo does not
exist) is used in a rule, it _is_ expanded to /home/andrew/foo (rather
than used verbatim). Consider the static pattern rule:
~/foo/bar: ~/foo/%: %
This gives the error "target `/home/andrew/foo' doesn't match the target
pattern", because ~/foo was expanded in the target, but not in the
target pattern. I thought I could fix this by pre-expanding ~foo:
dest := $(wildcard ~/foo)
$(dest)/foo: $(dest)/%: %
but this runs afoul of the rule you point out. (In the real code, ~/foo
is a parameter that might be set by the user, so I wanted to support ~
expansion.)
I would suggest that ~ expansion be excepted from the "no existing file
name" rule, since that rule seems to have been written with * and ?
wildcards in mind. However, I have not looked at whether this is
feasible. I think what this really indicates is that ~ and * expansion
are different.
As a second alternative, I would suggest reading the last sentence cited
strictly, and not expanding ~/foo in rules when that file doesn't exist.
This would make my first example work. However, I consider this
inferior to the first suggestion, because it is inconsistent with the
shell and less intuitive.
For now, I'll probably just go with
dest := $(shell echo ~/foo)
Andrew
--
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]