[Top][All Lists]

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

Re: foreach function

From: Paul D. Smith
Subject: Re: foreach function
Date: Fri, 8 Aug 2003 01:02:08 -0400

%% "Shipman, Alister" <address@hidden> writes:

  sa> I think this problem may have been mentioned in relation to bug
  sa> 1517.

It's possible, but you haven't provided any examples of what you're
really trying to do so I can't say.

  sa> I am trying to implement the example shown in section 8.8 of the
  sa> manual.  However when I try and use the foreach function I get
  sa> "missing separator" errors. I can use foreach on its own

  sa> e.g  $(foreach library,$(LIBRARYS), $(warning $(library))) 

  sa> However if I try even a variable assignment in it it has issues 
  sa> e.g: file_list := 
  sa>      $(foreach library,$(LIBRARYS), file_list+=$(library)) 

I don't think this is what you want.  Given a value of LIBRARYS (note
generally spelled "LIBRARIES" :)) like this:

  LIBRARYS = foo bar baz

then your foreach above expands to this:

  file_list+=foo file_list+=bar file_list+=baz

which may not be a syntax error but I daresay is not anything like what
you wanted to do.  On the other hand, this works for me:

  $ cat Makefile

  LIBRARYS := foo bar baz
  file_list :=
  $(foreach lib,$(LIBRARYS),$(eval file_list += $(lib)))
  all: ; @echo $(file_list)

  $ make
  foo bar baz

  sa> The function I have setup to produce my make code, analogous to
  sa> PROGRAM_template, performs fine when I use plain arguments to it
  sa> (i.e I just use $(eval $(call PROGRAM_template, someProgramName)),
  sa> and is fine when I do the same with the function argument as the
  sa> contents of a variable, but place it within a foreach call and it
  sa> has issues too (missing separator issues)

I need to see something that emulates what you're _REALLY_ trying to do,
and gives the same error message you're getting, not something that
doesn't resemble it at all and has very different behavior.

  sa> I'd really like to use this functionality - could you please
  sa> either direct me to a workaround (a different way of looping
  sa> through a set of names),

I don't have any good suggestions.

  sa> a patch if it exists already,

It's attached to the (closed) bug report in Savannah.  Unfortunately, it
seems like looking at bug details in Savannah has been broken since
Tuesday or so.

There was also a prerelease of the next version of GNU make, although
there is still some functionality missing from it, at the alpha site but
due to crackers infiltrating the GNU systems all that content is offline
while they verify that it hasn't been compromised.

  sa> or an indication of when a next release might be....

Sorry, I'm not sure.  I was hoping to get some work done on it in July
but didn't; now I'm hoping to find time near the end of this month to
get a release candidate for 3.81 out.

 Paul D. Smith <address@hidden>          Find some GNU make tips at:            
 "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]