Date: Wed, 08 Apr 2009 11:10:08 +0400 From: Boris Samorodov <bsam@ipt.ru> To: Mel Flynn <mel.flynn+fbsd.questions@mailing.thruhere.net> Cc: freebsd-questions@freebsd.org Subject: Re: make, list and M pattern Message-ID: <37630079@bb.ipt.ru> In-Reply-To: <200904080845.04576.mel.flynn%2Bfbsd.questions@mailing.thruhere.net> (Mel Flynn's message of "Wed\, 8 Apr 2009 08\:45\:04 %2B0200") References: <37646522@h30.sp.ipt.ru> <200904080845.04576.mel.flynn%2Bfbsd.questions@mailing.thruhere.net>
next in thread | previous in thread | raw e-mail | index | archive | help
On Wed, 8 Apr 2009 08:45:04 +0200 Mel Flynn wrote:
> On Tuesday 07 April 2009 21:54:13 Boris Samorodov wrote:
> > Hello List,
> >
> >
> > I need to create a list with some valid values and check an input
> > value. Should this makefile work?
> > -----
> > LIST=f8 f9
> >
> > all:
> > @echo USE_LINUX=${USE_LINUX}, LIST=${LIST}
> > .if empty(LIST:M${USE_LINUX})
> > @echo The value is invalid
> > .else
> > @echo The value is valid
> > .endif
> > -----
> > % make USE_LINUX=f8
> > USE_LINUX=f8, LIST=f8 f9
> > The value is invalid
> > -----
Hi Mel!
> Doesn't work because the match is not on words of the list but on the full
> list and you're not using globs.
You are ringht, but not for the case. The case here seems to exist
because variables are not guaranteed to be expanded for M modifier.
I.e. even with globs the result will not be as expected.
> Aside from Giorgos' method, one might consider:
> LIST=f8 f9
> LINUX_VER=invalid
> .for _VERSION in ${LIST}
> .if (${USE_LINUX} == "${_VERSION}")
> LINUX_VER=${_VERSION}
> .endif
> .endfor
> all:
> .if !empty(LINUX_VER:Minvalid)
> @echo "Invalid linux version: ${USE_LINUX}"
> .else
> @echo "Using linux version ${LINUX_VER}"
> .endif
Works. Thanks!
WBR
--
Boris Samorodov (bsam)
Research Engineer, http://www.ipt.ru Telephone & Internet SP
FreeBSD Committer, http://www.FreeBSD.org The Power To Serve
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?37630079>
