compile error

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


On Sat, Oct 5, 2013 at 3:02 AM, Cristian Ionescu-Idbohrn
<cristian.ionescu-idbohrn at axis.com> wrote:
> On Sat, 5 Oct 2013, Cristian Ionescu-Idbohrn wrote:
>>
>> This may help you get to the bottom:
>>
>> -%.o: %.cpp $(UIC_HEADERS)
>> +%.o: %.cpp $(uicables)

Ahh. You should *not* add dependencies to static rules. It might work
in some situations, but it's wrong.

Even the fixed version is still wrong:

> -%.o: %.cpp $(UIC_HEADERS)
> +%.o: %.cpp uicables

No, just do it as

   %.o: %.cpp

to declare the fixed rule for how to generate object files from cpp
files. No dependencies at that stage at at all.

You can make pattern rules be true for just certain patterns, and then
the syntax is

    file-list: %.o: %.cpp

but that is a different thing - that's a restriction on the when the
pattern is used (only for file-list), not a dependency.

To add dependencies, you need to do it separately. So you could do
something like

  %.o: %.cpp
        pattern-commands

   cpp-files := $(wildcard *.cpp)
   $(cpp-files): $(UIC_HEADERS)

as two different rules: the first one is the pattern that (re-)defines
the implicit rule in what make should do, and the second rule makes it
clear that all *.cpp files depend on the files listed in UIC_HEADERS.

Does that get things working better for you guys?

                   Linus


More information about the subsurface mailing list