[Top][All Lists]

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

Re: VPATH/vpath and Pattern Rules

From: Paul Smith
Subject: Re: VPATH/vpath and Pattern Rules
Date: Sat, 14 Jan 2012 09:09:57 -0500

On Sat, 2012-01-14 at 13:46 +0100, Michael Ludwig wrote:
> How can you convince Make to honour the VPATH/vpath when using a Pattern
> Rule defined in my Makefile (as opposed to the built-in pattern rule)?

It does already: no need for convincing.

> # Pattern Rule
> %.o: %.cpp
>       $( $*.cpp -o $*.o

This is not right.  The $* variable matches the stem of the pattern.
The stem of the pattern here is something like "Employee", the stem is
NOT "emp/Employee".  You can see this easily be changing your rule to
print out the values of the various automatic variables.

If you want this to work you need to use the $@ and $< variables, like

        %.o: %.cpp
                $( $< -o $@

Hope this helps...

 Paul D. Smith <address@hidden>          Find some GNU make tips at:            
 "Please remain calm...I may be mad, but I am a professional." --Mad Scientist

reply via email to

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