help-make
[Top][All Lists]
Advanced

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

Re: behavior on Win depends on whether \ or / is used??


From: Paul Smith
Subject: Re: behavior on Win depends on whether \ or / is used??
Date: Mon, 4 Jan 2010 17:32:20 -0500

On Mon, 2010-01-04 at 20:40 +0200, Eli Zaretskii wrote:
> > > > vpath %.s foobar0 foobar1
> > > > %.o: %.s
> > > >           echo $<
> > > > foobar0/foobar.s:
> > > > 
> > > > (and as always, foobar.s only in foobar1, not in foobar0).  
> > > > 
> > > > 
> > > > Here, the current behavior of make is 
> > > > 
> > > > C:\tmp>make foobar.o
> > > > echo foobar0/foobar.s

> > I guess I'm not sure what comment I should make... you have described
> > the answer yourself.  If there is a target with no prerequisites or
> > recipe, make treats it as if it was created when make runs (so it's new,
> > every time).
> 
> Make needs to build foobar.o, so is looking for foobar.s, right?  And,
> as Mark points out, in this little experiment, foobar.s exists _only_
> in foobar1, not in foobar0.  So why does make pick up foobar0/foobar.s
> (which does not exist), rather than foobar1/foobar.s?

Because of the explicit definition of the target "foobar0/foobar.s:", as
I said above: since that target was defined in the makefile, make
imagines that it exists, so when vpath searches go looking for targets,
this one is found.  vpath searches the same directory caches that make
uses to see if targets exist.

One might consider this incorrect behavior, and say that vpath searches
should ONLY match real files that really exist and ignore "implied"
targets such as this.  It's hard to know whether this will simply
replace this problem with some other problem; if there are makefiles
that rely on the current behavior and will break if it's changed.

> By the way, if you switch the order of foobar0 and foobar1 in vpath,
> Make does TRT, AFAIR, and picks up foobar1/foobar.s.  This
> inconsistency is in itself a problem, I'd say, no? 

Maybe; it depends on what order you think make should follow if a target
cannot be located via a vpath rule.  Should make search all vpath
directories first and only if the target cannot be found in any of them
should it THEN proceed to see if each one can be made via implicit
rules?  If so, then you're right, there's a problem here.

If, on the other hand, you think make should look for the first
vpath-expanded file and if it doesn't exist see if it can be made via
imiplicit rules, and only then, if it cannot be made, should it look at
the next directory in vpath to see if the file exists (and then see if
that target can be made), then the behavior you see is as expected.

It doesn't appear that the manual is specific about how this algorithm
works, but I personally don't think the current behavior is wrong.





reply via email to

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