help-make
[Top][All Lists]
Advanced

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

Re: Problem with static pattern rules and full path


From: dalewking
Subject: Re: Problem with static pattern rules and full path
Date: Thu, 29 Sep 2005 00:23:07 +0000



> > %% address@hidden writes:
> > 
> >   d> So let's say I have:
> > 
> >   d> srcs := /foo/a.c /bar/b.c
> >   d> objs := $(addprefix $(objdir)/,$(notdir $(srcs:.c=.o)))
> > 
> >   d> Based on that variable, I want to generate $(objdir)/a.o and
> >   d> $(objdir)/b.o.  Realize that the makefile code that does this has
> >   d> no control over the contents of the variable. It may have one file
> >   d> or perhaps 50 and the paths could be anywhere.
> > 
> > This should work:
> > 
> >     vpath %.c $(sort $(dir $(srcs)))
> > 
> >     $(objdir)/%.o : %.c
> >             @cc ...
> > 
> > I used $(sort ...) here to make things faster on the assumption that
> > many sources will appear in the same directory (sort also uniq's).  This
> > should be safe since a basic restriction of the environment you are
> > implementing is that there cannot be two source files with the same name
> > (technically, the same stem) ANYWHERE in the tree.
> > 
> > Given that, the search order shouldn't matter.
> 
> But what I didn't mention is that this occurs many times throughout my entire
> tree. I am doing a non-recursive make system and this can occur in any 
> directory
> and the use in one directory should not interfere with another directory. So
> basically, I would want to set the vpath for one rule and then clear it out.
> 
> So would this work? I'll have to try it out:
> 
>      vpath %.c $(sort $(dir $(srcs)))
>  
>      $(objdir)/%.o : %.c
>              @cc ...
> 
>      # Clear out the vpath
>      vpath %.c

To answer my own question, it doesn't work. Vpath is a global thing. You can't 
change it dynamically on the fly to get different vpaths for different rules.

So I'm back with no answer to the problem.




reply via email to

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