help-make
[Top][All Lists]
Advanced

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

Re: Expanding variables as part of function arguments


From: Paul Smith
Subject: Re: Expanding variables as part of function arguments
Date: Wed, 09 Jun 2010 02:30:29 -0400

On Wed, 2010-06-09 at 00:05 -0400, Anthony Penniston wrote:
> Hello,
> I need to expand a variable as an argument to patsubst, as in the following 
> code snippet:
> 
> SRC := src
> SRCEXT := .c .cpp
> OBJEXT := .o .o
> comma := ,
> SUB = $(join $(addsuffix $(comma),$(addprefix %%,$(SRCEXT))),$(addprefix 
> %%,$(OBJEXT)))
> OBJ = $(patsubst $(SUB),$(wildcard $(addprefix $(SRC)/*,$(SRCEXT))))

Commas have to be "top-level" tokens.  The arguments to a function are
parsed BEFORE they are expanded, so the comma separating an argument
cannot appear inside a variable.

Assuming the suffix is always the same (.o), why not just use:

        SRCFILES := foo.c bar.c baz.cpp
        OBJFILES := $(addsuffix .o,$(basename $(SRCFILES))

-- 
-------------------------------------------------------------------------------
 Paul D. Smith <address@hidden>          Find some GNU make tips at:
 http://www.gnu.org                      http://make.mad-scientist.net
 "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]