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: Rick Flower
Subject: Re: Why doesn't this work properly?
Date: Fri, 31 Aug 2007 16:16:56 -0700 (PDT)
User-agent: SquirrelMail/1.4.10a

On Fri, August 31, 2007 3:47 pm, Philip Guenther wrote:

> 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.

I was starting to think that the "build_teststubs" target was really
screwing things up.. It had several unwanted side effects.. Your method is
MUCH cleaner!

> $(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

You've completely solved my problem except for one minor issue --  what if
some of these stubs live in multiple directories?:

${TOP_DIR}/teststubs/common/src/
${TOP_DIR}/teststubs/hardware/src/
etc

Ideally, I'm specifying the full paths in my Makefile as I indicated in my
initial email.. However, I was simplifying things for simplicity.. Is there
any easy way to extend this for multiple directories as well?  I tried
reading up on static pattern rules in the GNU Make help and it indicates
that I can use multiple "dep-patterns".. However, when I tried it didn't
seem to find things anymore :

$(notdir $(TESTSTUB_SOURCES)): %: ${TOP_DIR}/teststubs/hardware/src/% \
                                  ${TOP_DIR}/teststubs/common/src/%
        ln -sf $< $@

In this case, I specifically put the hardware directory up front to make
sure that Make has to work a bit harder to find the actual location of
"foo.cc" which is in "common/src"..  I tried putting a colon between each
dep-patterns, but no change.. Any ideas?  Many thanks again for digging me
out of my hole.. I feel like I'm 99% there!










reply via email to

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