%% [EMAIL PROTECTED] 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 <[EMAIL PROTECTED]>          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


_______________________________________________
Help-make mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/help-make

Reply via email to