[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: VPATH problem
From: |
Philip Guenther |
Subject: |
Re: VPATH problem |
Date: |
Sun, 19 Feb 2012 14:16:57 -0800 |
On Sat, Feb 18, 2012 at 8:26 AM, Bgh Ello <address@hidden> wrote:
> Greetings. I am unable to get the simplest VPATH example working
> and could use some help. I have a hello world program, hello.cpp in the
> src directory, and I can't reach it with VPATH. Here is the makefile
...
> hello.o : hello.cpp
> $(CC) $(OPTS) hello.cpp
In the GNU make docs, the page about VPATH has a link to another page
titled "Writing Recipes with Directory Search". That page start with
this:
------
When a prerequisite is found in another directory through directory
search, this cannot change the recipe of the rule; they will execute as
written. Therefore, you must write the recipe with care so that it
will look for the prerequisite in the directory where `make' finds it.
This is done with the "automatic variables" such as `$^' (*note
Automatic Variables::). For instance, the value of `$^' is a list of
all the prerequisites of the rule, including the names of the
directories in which they were found, and the value of `$@' is the
target. Thus:
foo.o : foo.c
cc -c $(CFLAGS) $^ -o $@
------
There's more there, including an example for a .o target.
Philip Guenther