You have convinced me.
Another benefit to keeping the generated cpp file in the
object tree is, if I should want to manually tweak the cpp file,
I will do that with a copy in the source directory, which will
not be overwritten by any auto-generated cpp file.

Thank you.


Philip Guenther-2 wrote:
> 
> On Sun, Jun 3, 2012 at 11:29 PM, normvcr <[email protected]> wrote:
> ...
>> 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?
> 
> Why do you want to put a generated file in the source tree instead of
> the object tree?  The "source" file in this case is the .h file; the
> .cpp file is an object file as much as the .o file that is generated
> from the .cpp, which will itself be Just Another Input to generating
> the executable or library.
> 
> So, keep the rule as "%.cpp: %.h", but fix it to write to $@.  Then
> change any $(srcdir)/foo.cpp references to just foo.cpp
> 
> 
> 
> Philip Guenther
> 
> _______________________________________________
> Help-make mailing list
> [email protected]
> https://lists.gnu.org/mailman/listinfo/help-make
> 
> 

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


_______________________________________________
Help-make mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/help-make

Reply via email to