help-make
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Why doesn't this work properly?


From: Philip Guenther
Subject: Re: Why doesn't this work properly?
Date: Fri, 31 Aug 2007 16:47:21 -0600

On 8/31/07, Rick Flower <address@hidden> wrote:
...
> I believe this is because by the time I've recomputed the object lists,
> Make has already got its head made up about the entire list of objects..

Nah, it's just because you didn't give make enough information.


...
>   Successfully remade target file `../obj/regularFile.o'.
>   Considering target file `../obj/foo.o'.
>    File `../obj/foo.o' does not exist.
>    Looking for an implicit rule for `../obj/foo.o'.
>    Trying pattern rule with stem `foo'.
>    Trying implicit prerequisite `foo.cc'.
>    Trying pattern rule with stem `foo'.
>    Trying implicit prerequisite `foo.c'.
>    Trying pattern rule with stem `foo'.
>    Trying implicit prerequisite `../obj/foo.c'.
>    Trying pattern rule with stem `foo'.
>
> Ideally it should have found it with the ".cc" version above..  Any ideas?

You never told make how to build foo.cc.  It so happens that foo.cc is
created by some completely unrelated target, but make has no way of
knowing that.  If you want make to know how to create/update a file,
you must use that *exact* filename as a target.

This rule from your original message violates that:

build_teststubs: $(TESTSTUB_SOURCES)
       $(foreach srcfile, $(TESTSTUB_SOURCES), ln -s $(srcfile) .)

IMHO, the correct way to do that is to eliminate the "build_teststubs"
target completely and make each stub its own target.  If they're all
in the same directory than this is most simply done using a static
pattern rule.

$(notdir $(TESTSTUB_SOURCES)): %: ${TOP_DIR}/teststubs/src/%
        rm -f $@; ln -s $< $@

Poof, now make knows that foo.cc can be 'built' by running
   "rm -f foo.cc; ln -s ${TOP_DIR}/teststubs/src/foo.cc foo.cc"

and it can thus visualize how to generate foo.o from
${TOP_DIR}/teststubs/src/foo.cc


Philip Guenther




reply via email to

[Prev in Thread] Current Thread [Next in Thread]