> EDIT: I had a theory that the % characters inside the patsubst
> were getting evaluated early, using the stem match (foo), so
> that the patsubst itself was looking something like this:
>
> $(patsubst foo.c,foo.o,bar.c baz.c)
That is what happened. The answer on SO explains how to work around
it.
> To test this theory, I added a file called foo.c to foo_SRCS:
...
> That resulted in something even weirder:
> make: *** No rule to make target `foo.a', needed by `all'. Stop.
Which resulted in Make seeing the line as
%.a: %.o bar.c baz.c
Now, Make will only choose to use a pattern rule if it knows how to
make all of the prerequisites. If Make doesn't know how to make foo.o
(which it wouldn't if you don't have an actual file named foo.c), then
it won't even consider the rule as a possibility to make foo.a.