help-make
[Top][All Lists]
Advanced

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

Problem with static pattern rules and full path


From: DaleWKing
Subject: Problem with static pattern rules and full path
Date: Wed, 28 Sep 2005 21:31:49 +0000

The dilemna is that I have a variable that contains a list of source files with
the full path and I want rules to build them into another directory that does
not necessarily share any relationship to the output directory.

So let's say I have:

srcs := /foo/a.c /bar/b.c
objs := $(addprefix $(objdir)/,$(notdir $(srcs:.c=.o)))

Based on that variable, I want to generate $(objdir)/a.o and $(objdir)/b.o.
Realize that the makefile code that does this has no control over the contents
of the variable. It may have one file or perhaps 50 and the paths could be 
anywhere.

I thought that a static pattern rule would be in order, but that doesn't really
work. I can have it generate the targets of the rule but there doesn't seem to
be anyway to generate the prerequisites:

$(objs) : %.o : %.c
    @cc ...

This will generate rules like this:

$(objdir)foo.o : $(objdir)foo.c

which is not correct. There doesn't seem to be a good way to inject the src path
in here.

I'm sure someone will suggest using eval but eval is still broken 3 years after
initial bugs were found with it. Anything I try with it suffers from the virtual
memory exhausted bug or the problem that eval does not work well inside an if.

Does anybody see any easy way to get this. My only work around is to actually
have the hierarchy from the source file within $(objdir) so that /foo/a.c
actually generates $(objdir)/foo/a.o.

-- 
 Dale King




reply via email to

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