|
From: | John Graham-Cumming |
Subject: | Re: strip, non-ordering? |
Date: | Wed, 28 Sep 2005 10:32:15 +0200 |
User-agent: | Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.6) Gecko/20040208 Thunderbird/0.5 Mnenhy/0.6.0.104 |
Shawn Halpenny wrote:
define uniq $(strip $(eval tmp:=)$(foreach i,$1,$(eval tmp+=$(if $(filter $i,$(tmp)),,$i))) $(tmp)) endef
That's using $(eval) which means it'll exclude people on GNU Make 3.79.1 or earlier. It's possible to write the some function without $(eval) like this:
uniq = $(if $1,$(call uniq,$(call chop,$1)) $(if $(filter $(call last,$1),$(call chop,$1)),,$(call last,$1)))
(I used the chop and last functions from my GNU Make Standard Library, http://gmsl.sf.net/ so you need to get that and include gmsl to make that uniq function work).
Since this seems like it might be generally useful to people I've checked it into the GMSL CVS repository with tests and it'll be in the next release (whenever that is).
John. -- John Graham-Cumming address@hidden Home: http://www.jgc.org/ POPFile: http://getpopfile.org/ Sign up for my Spam and Anti-spam Newsletter at http://www.jgc.org/
[Prev in Thread] | Current Thread | [Next in Thread] |