I'd like to thank everyone who responded to my questions regarding substitution vs expansion. I think I have a good handle on this issue now. To summarize:
1. Use make variables everywhere you can in makefiles, as opposed to autoconf substitution variables because doing so gives you more flexibility on the make command line. 2. Don't use either autoconf or make variables in automake file lists because it may confuse dependency management code - VPATH is your friend here. Thanks again! John On Wed, Mar 5, 2008 at 10:39 AM, John Calcote <[EMAIL PROTECTED]> wrote: > Erik, > > 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: > > project > common > mySleep.c > server > registrar.c > dbg-build > common > server > Makefile <-- > > The dbg-build directory is one I created from which to build a debug > version of my code. The indicated Makefile contains: > > VPATH=../../server > > 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 > ../../common/mySleep.c. > > hth > John > > > > 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. > > Erik > > > > On Tue, Mar 4, 2008 at 4:29 PM, Harlan Stenn <[EMAIL PROTECTED]> 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 > > >
