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 15:13:41 +0000



> %% Dale King <address@hidden> writes:
> 
>   >> You could do one of two things: use the VPATH variable as a
>   >> target-specific (or pattern-specific) variable (I think this will
>   >> work).
> 
>   dk> No, it doesn't appear to work.
> 
> Hm.  I guess VPATH is parsed early and not re-parsed for each target.
> This could be considered a bug, or at least an area for enhancement.

Well given the track record for how many years we have to live with bugs
without getting a new release (3 years this coming Monday), I'm not holding
my breath.

>   >> Or, use a more restrictive pattern for vpath, so instead of:
>   >> 
>   >> vpath %.c ...
>   >> 
>   >> you do something like:
>   >> 
>   >> vpath $(prefix)/%.c ...
>   >> 
>   >> where the prefix variable restricts the values to match the
>   >> "current" location, whatever that is.
> 
>   dk> That doesn't seem to work either.
> 
> It will definitely work, if you can compute the proper value of prefix.
> Which you may not be able to do, depending on your environment.

Then maybe I am misunderstanding you. Here is a fuller example where I have
/foo/a.c that should get built into /obj1/a.o and /bar/a.c that gets built
into /obj2/a.o (I just use copy here).

This gives:

$ make
make: *** No rule to make target `/obj1/a.c', needed by `/obj1/a.o'.  Stop.

Makefile:

all : /obj1/a.o /obj2/a.o

# This comes from one directory's included makefile
objdir := /obj1
srcs := a.c
src-dirs := /foo

# This is the generic rules that cannot be directory specific
objs := $(addprefix $(objdir)/,$(notdir $(srcs:.c=.o)))
vpath $(objdir)/%.c $(src-dirs)

$(objs) : %.o : %.c
        @cp -v $< $@

# This comes from another directory's included makefile
objdir := /obj2
srcs := a.c
src-dirs := /bar

# This is the generic rules that cannot be directory specific
objs := $(addprefix $(objdir)/,$(notdir $(srcs:.c=.o)))
vpath $(objdir)/%.c $(src-dirs)

$(objs) : %.o : %.c
        @cp -v $< $@





reply via email to

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