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
>       $(COMPILE.cc) $*.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
so:

        %.o: %.cpp
                $(COMPILE.cc) $< -o $@

Hope this helps...

-- 
-------------------------------------------------------------------------------
 Paul D. Smith <psm...@gnu.org>          Find some GNU make tips at:
 http://www.gnu.org                      http://make.mad-scientist.net
 "Please remain calm...I may be mad, but I am a professional." --Mad Scientist


_______________________________________________
Help-make mailing list
Help-make@gnu.org
https://lists.gnu.org/mailman/listinfo/help-make

Reply via email to