help-make
[Top][All Lists]
Advanced

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

Re: short followup on vpath/VPATH stuff


From: Robert P. J. Day
Subject: Re: short followup on vpath/VPATH stuff
Date: Mon, 14 Jun 2004 15:48:14 -0400 (EDT)

On Mon, 14 Jun 2004, Paul D. Smith wrote:

> %% "Robert P. J. Day" <address@hidden> writes:
> 
>   rpjd> this can certainly be clearer, methinks.  or, i could just be
>   rpjd> smarter.
> 
> You need to remember that every prerequisite is also a target.  Even if
> you don't list it explicitly as a target, make always treats every
> prerequisite as a target and tries to rebuild it, using implicit rules
> if there is no explicit rule.

ah, i think i'm starting to see the connection.  i'm reading the "How Not 
to Use VPATH" essay and the sample (bad) makefile:

OBJDIR = ../obj
VPATH = $(OBJDIR)

%.o : %.c
        $(COMPILE.c) $< -o $(OBJDIR)/$@

all: foo

foo: foo.o bar.o
        $(LINK.o) $^ $(LDLIBS) -o $(OBJDIR)/$@


if i try to do the "make all" in one step, the prereqs foo.o and bar.o are
found to be based on the source files foo.c and bar.c in the *current*
directory so that, even after the object files are placed in ${OBJDIR},
make has already associated the object files with the current directory
and therefore gets confused in that final link step, right?

  however, if i build the object files in one make invocation, and then
follow that with "make foo", that will work since that second
(independent) "make foo" *will* use VPATH to find the (missing) object
files that already exist in the ${OBJDIR} directory.  so far, so good?

rday




reply via email to

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