Tue 21 Dec 2010 01:45:35 AM UTC, original submission:
Background: A pattern rule '%/' would be useful to mean "any directory". However, this only works when the directory name is a single character.
Buggy behavior:
1. If the directory names are explicit instead of using a pattern rule, everything works, except that trailing slashes disappear in the $@ variable.
2. If a target has prerequisites that is multiple characters followed by a slash, the the target name as given is not searched-for. Instead, the name without the slash is looked-for.
Documentation:
POSIX says:
"Applications shall select target names from the set of characters consisting solely of periods, underscores, digits, and alphabetics from the portable character set (see XBD Portable Character Set). Implementations may allow other characters in target names as extensions."
Any use at all of subdirectories is an extension?
The GNU Make Manual makes it clear that subdirectories work, but never mentions trailing slashes.
Workarounds:
1. Explicitly specify every %/ target as .PHONY : (behavior is not exact)
2. In addition to %/, specify %a/ %A/ %b/ %B/ ... (behavior is as intended)
Incompatibility:
Fixing this behavior would break Makefiles that mixed the use of slashed and nonslashed directories. Such Makefiles are unlikely.
Reproduced on:
make 3.81 (Ubuntu)
make 3.81 (Gentoo)
make 3.82 (vanilla)
Summary of attachment:
%/ %t/: mkdir
a/b : | a/ - OK
xxt/f : | xxt/ - works
yy/zz : | yy/ - broken
Output of attached minimal makefile:
mkdir -p a/
touch a/b
mkdir -p xxt
touch xxt/f
make: *** No rule to make target `yy', needed by `yy/zz'. Stop.
|