On 25.02.2013 14:57, Brian J. Murrell wrote:
> Hi,
>
> I have run into something I find strange with GNU Make 3.81 (yes, I know
> 3.82 is latest but since it's not in EL6, my target platform, I cannot
> depend on it's features).
>
> I would think that given the following set of rules:
>
> /tmp/%.foo: %.foo
> echo "foo rule 1"
> touch $@
>
> %.foo:
> echo "foo rule 2"
> touch $@
>
> /tmp/%.bar:
> make $*.bar
> echo "bar rule 1"
> touch $@
>
> %.bar:
> echo "bar rule 2"
> touch $@
>
> [..]
>
> $ make /tmp/a.foo
> echo "foo rule 2"
> foo rule 2
> touch /tmp/a.foo
> $ make /tmp/a.bar
> make a.bar
> make[1]: Entering directory `/home/brian/chroma/deps/lustre/test'
> echo "bar rule 2"
> bar rule 2
> touch a.bar
> make[1]: Leaving directory `/home/brian/chroma/deps/lustre/test'
> echo "bar rule 1"
> bar rule 1
> touch /tmp/a.bar
>
> It would seem that for the /tmp/a.foo, the "/tmp/%.foo" pattern rule is
> not being chosen but for /tmp/a.bar" the "/tmp/%.bar" pattern rule is
> being chosen. The only difference in those choices I can see is that
> the "/tmp/%.foo" pattern rule has a prerequisite and the "/tmp/%.bar"
> one doesn't.
Confirming the same behavior for make 3.82.
It seems like normally GNU make walks the path of the most specific
match in case of ambiguities. I wonder if that's specified/documented
anywhere. For this Makefile
xxx%:
@echo '$@ --> xxx%'
x%:
@echo '$@ --> x%'
xx%:
@echo '$@ --> xx%'
the most specific rule is chosen one might expect:
# make x1 xx2 xxx3 xxxx4
x1 --> x%
xx2 --> xx%
xxx3 --> xxx%
xxxx4 --> xxx%
Side notes on the above Makefile:
- "make $*.bar" in there does not seem to be relevant.
After removing that line, the file still reproduces your case.
- "make $*.bar" should be "$(MAKE) $*.bar", use $(MAKE)
to invoke make to not run into parallel build issues
- To reduce output noise, you can use lines like
@echo "foo rule 1"
^
instead of
echo "foo rule 1"
> So the question is, why does a prerequisite change the behavior of
> pattern match rules?
Good question.
Best,
Sebastian
_______________________________________________
Bug-make mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/bug-make