From owner-freebsd-questions@FreeBSD.ORG Wed Apr 8 06:45:07 2009 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 39303106564A for ; Wed, 8 Apr 2009 06:45:07 +0000 (UTC) (envelope-from mel.flynn+fbsd.questions@mailing.thruhere.net) Received: from mailhub.rachie.is-a-geek.net (rachie.is-a-geek.net [66.230.99.27]) by mx1.freebsd.org (Postfix) with ESMTP id C77A98FC15 for ; Wed, 8 Apr 2009 06:45:06 +0000 (UTC) (envelope-from mel.flynn+fbsd.questions@mailing.thruhere.net) Received: from sarevok.dnr.servegame.org (gate.lan.rachie.is-a-geek.net [192.168.2.10]) by mailhub.rachie.is-a-geek.net (Postfix) with ESMTP id C15587E818; Tue, 7 Apr 2009 22:45:05 -0800 (AKDT) From: Mel Flynn To: freebsd-questions@freebsd.org Date: Wed, 8 Apr 2009 08:45:04 +0200 User-Agent: KMail/1.11.0 (FreeBSD/8.0-CURRENT; KDE/4.2.0; i386; ; ) References: <37646522@h30.sp.ipt.ru> In-Reply-To: <37646522@h30.sp.ipt.ru> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200904080845.04576.mel.flynn+fbsd.questions@mailing.thruhere.net> Cc: Boris Samorodov Subject: Re: make, list and M pattern X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 08 Apr 2009 06:45:07 -0000 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 > ----- Doesn't work because the match is not on words of the list but on the full list and you're not using globs. 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 -- Mel