help-make
[Top][All Lists]
Advanced

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

Re: Inconsistent use of vpath


From: normvcr
Subject: Re: Inconsistent use of vpath
Date: Sun, 3 Jun 2012 23:29:31 -0700 (PDT)


Philip Guenther-2 wrote:
> 
> On Sun, Jun 3, 2012 at 8:46 PM, normvcr <address@hidden> wrote:
>> Philip Guenther-2 wrote:
> ...
>>> I believe the most common cause of this is because some makefile rule
>>> builds a file other than address@hidden  In this case, ../src/foo.cpp  
>>> didn't
>>> exist before the first run but did afterwards, but make didn't know
>>> that some rule that it had run had created it.  What was the rule that
>>> generated ../src/foo.cpp?
>>
>> There is, indeed, a target that first creates foo.cpp, but it only
>> overwrites an an old, existing, foo.cpp .  It is as though the creation
>> of
>> the new foo.cpp is changing the rules, as you suggested, above, even
>> though there was already a foo.cpp before invoking make the first time.
>>
>> Any ideas how to work around, that?  Perhaps, if I break up the
>> rule into two rules (first make foo.cpp, then make foo.o),
>> that should simplify things for make, but should such a work-around
>> be necessary?
> 
> No, make does not need that.  The problem is almost certainly that THE
> RULE IS WRONG.  Every rule should create/update *exactly* the path
> "$@".  Not "../src/$@" or "${objdir}/$@", but *just* address@hidden  Is that 
> what
> the current rule does?  Since you don't want to show the rule itself,
> you'll have to look and answer that yourself.
> 

I think you have hit the nail on the head.  I checked and, indeed,
$@ is foo.cpp, but I want to build $(srcdir)/foo.cpp .  The rule has been

%.cpp: %.h
        Do stuff which results in $(srcdir)/foo.cpp

So, I tried 

$(srcdir)/%.cpp: %h
     Do same kind of stuff

but it did not match on this rule.

As you can surmise, I am generating the .cpp file from the .h file,
and I also keep my object code in a different folder than the source 
code, so that is why I am running make not in the source directory,
but in the object directory.

Can you suggest how to construct a rule that would match?

Thank you for your input.  I have not put in the actual rule since it
involves commands with many arguments that would only clutter
the issue.  I hope you are not offended by this.

-- 
View this message in context: 
http://old.nabble.com/Inconsistent-use-of-vpath-tp33951080p33955999.html
Sent from the Gnu - Make - Help mailing list archive at Nabble.com.




reply via email to

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