On Sat, Feb 18, 2012 at 8:26 AM, Bgh Ello <[email protected]> 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
_______________________________________________
Help-make mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/help-make