From owner-freebsd-questions@FreeBSD.ORG Tue Apr 7 21:09:46 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 789AF106564A for ; Tue, 7 Apr 2009 21:09:46 +0000 (UTC) (envelope-from keramida@ceid.upatras.gr) Received: from poseidon.ceid.upatras.gr (poseidon.ceid.upatras.gr [150.140.141.169]) by mx1.freebsd.org (Postfix) with ESMTP id E8AA88FC16 for ; Tue, 7 Apr 2009 21:09:45 +0000 (UTC) (envelope-from keramida@ceid.upatras.gr) Received: from mail.ceid.upatras.gr (unknown [10.1.0.143]) by poseidon.ceid.upatras.gr (Postfix) with ESMTP id 343C9EB53FB; Wed, 8 Apr 2009 00:09:45 +0300 (EEST) Received: from localhost (europa.ceid.upatras.gr [127.0.0.1]) by mail.ceid.upatras.gr (Postfix) with ESMTP id 175C145088; Wed, 8 Apr 2009 00:09:45 +0300 (EEST) X-Virus-Scanned: amavisd-new at ceid.upatras.gr Received: from mail.ceid.upatras.gr ([127.0.0.1]) by localhost (europa.ceid.upatras.gr [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 64vWBtMoCZ6G; Wed, 8 Apr 2009 00:09:44 +0300 (EEST) Received: from kobe.laptop (adsl16-193.kln.forthnet.gr [77.49.143.193]) by mail.ceid.upatras.gr (Postfix) with ESMTP id D86B94503F; Wed, 8 Apr 2009 00:09:44 +0300 (EEST) Received: from kobe.laptop (kobe.laptop [127.0.0.1]) by kobe.laptop (8.14.3/8.14.3) with ESMTP id n37L9iOp063091; Wed, 8 Apr 2009 00:09:44 +0300 (EEST) (envelope-from keramida@ceid.upatras.gr) Received: (from keramida@localhost) by kobe.laptop (8.14.3/8.14.3/Submit) id n37L9hJp063090; Wed, 8 Apr 2009 00:09:43 +0300 (EEST) (envelope-from keramida@ceid.upatras.gr) From: Giorgos Keramidas To: Boris Samorodov References: <37646522@h30.sp.ipt.ru> Date: Wed, 08 Apr 2009 00:09:43 +0300 In-Reply-To: <37646522@h30.sp.ipt.ru> (Boris Samorodov's message of "Tue, 07 Apr 2009 23:54:13 +0400") Message-ID: <871vs49nmw.fsf@kobe.laptop> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.92 (berkeley-unix) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: freebsd-questions@FreeBSD.org 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: Tue, 07 Apr 2009 21:09:46 -0000 On Tue, 07 Apr 2009 23:54:13 +0400, 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 Boris! :) This is not exactly what you asked for, but you can probably loop instead of trying to match regular expressions: keramida@kobe:/tmp$ cat -n Makefile 1 LIST= f8 f9 2 USE_LINUX?= f9 3 4 LINUX_VERSION= ${USE_LINUX:C/[ ]*([^ ]*)[ ]*/\1/} 5 6 .if defined(USE_LINUX) 7 .for item in ${LIST} 8 .if ${USE_LINUX} == ${item} 9 RESULT= ${item} 10 .endif 11 .endfor 12 .endif 13 14 all: 15 .if empty(RESULT) 16 @echo Version ${LINUX_VERSION} is not valid. 17 .else 18 @echo Valid version ${RESULT} selected. 19 .endif keramida@kobe:/tmp$ make Valid version f9 selected. keramida@kobe:/tmp$ make -e USE_LINUX=f10 Version f10 is not valid. keramida@kobe:/tmp$