[Top][All Lists]

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

Re: substitution vs expansion in

From: John Calcote
Subject: Re: substitution vs expansion in
Date: Wed, 5 Mar 2008 10:39:41 -0700


I believe I understand Harlan's method. My understanding is that make
actually prefixes all targets not found relative to the current
directory with each path (relative or absolute) specified in VPATH,
until it finds the file (or not). To use my original example, here's
my directory structure:

                Makefile <--

The dbg-build directory is one I created from which to build a debug
version of my code. The indicated Makefile contains:


    registrarTest_SOURCES = registrar.c ../common/mySleep.c

Of course, make is able to find registrar.c in project/server because
of the VPATH. It didn't find it in the current directory, so it looked
(effectively) in $(VPATH)/registrar.c. Obviously VPATH is more than
just a variable, but I'm using it in this manner here for the sake of
illustration, because it contains only one component.

But what about mySleep.c? Well it works the same way. It doesn't find
../common/mySleep.c relative to the current directory, so it looks in
$(VPATH)/../common/mySleep.c, which resolves to
../../server/../common/mySleep.c, which finally resolves to


Harlan Stenn wrote:

> > You can use: ../common/mySleep.c in your foo_SOURCES list.

If the sources are in /home/user/src and you go to /home/usr/build
and do "../src/configure" the above will be completely wrong.

The correct way to do it is to use "$(top_srcdir)/common/mySleep.c"
which will work under all circumstances.


On Tue, Mar 4, 2008 at 4:29 PM, Harlan Stenn <address@hidden> wrote:
> John,
>  > Bob, server/Makefile's VPATH only contains the expansion of
>  > @top_srcdir@/server, which in this case is ../../server. This means
>  > that make won't be able to find any sources listed that exist in
>  > directories other than ../../server. So I think I HAVE to use
>  > $(top_srcdir)/common/mySleep.c, don't I, as it's in a different source
>  > directory?
>  You can use: ../common/mySleep.c in your foo_SOURCES list.
>  H

reply via email to

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