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: Paul D. Smith
Subject: Re: Problem with static pattern rules and full path
Date: Wed, 28 Sep 2005 17:51:30 -0400

%% 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.

-- 
-------------------------------------------------------------------------------
 Paul D. Smith <address@hidden>          Find some GNU make tips at:
 http://www.gnu.org                      http://make.paulandlesley.org
 "Please remain calm...I may be mad, but I am a professional." --Mad Scientist




reply via email to

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