[PATCH] Fix build: don't recompile all C++ every time

Linus Torvalds torvalds at linux-foundation.org
Sat Oct 5 11:09:26 UTC 2013


On Sat, Oct 5, 2013 at 10:41 AM, Thiago Macieira <thiago at macieira.org> wrote:
>
> Make knows that it needs to run COMMAND to create foo.o if foo.cpp exists.
> According to the manual, you can add extra dependencies:
>
> %.o: %.cpp foo.h ; COMMAND

No you can not. Well, you can - syntactically the above is correct
Makefile syntax - but it really acts completely differently. In
particular, if "foo.h" doesn't exist or cannot be made, that simply
*disables* that pattern, because it cannot be matched. And then you'll
no pattern at all, or another pattern. That's very different from a
normal dependency, which if you cannot make it, make will talk about
how it cannot do so. See?

So don't add dependencies to rule patterns.  They are *not* normal
dependencies, they are "pattern matches". Really. Don't do it. It's
confusing, as shown by this whole thread. You've proven just *how*
confusing they are by showing that you don't understand them.

To recap: in a pattern, the "dependencies" aren't dependencies at all.
They are pattern matches, and while there are similarities, they are
not the same thing. DO NOT DO IT.

Do what I told you to do. Seriously. If you want a dependency, use a
dependency. Not a pattern. Like I showed in the earlier email.

Make is subtle and confusing, and it gets *more* subtle and *more*
confusing if you mix up these kinds of concepts.

               Linus


More information about the subsurface mailing list