Date: Wed, 08 Apr 2009 00:09:43 +0300 From: Giorgos Keramidas <keramida@ceid.upatras.gr> To: Boris Samorodov <bsam@ipt.ru> Cc: freebsd-questions@FreeBSD.org Subject: Re: make, list and M pattern Message-ID: <871vs49nmw.fsf@kobe.laptop> In-Reply-To: <37646522@h30.sp.ipt.ru> (Boris Samorodov's message of "Tue, 07 Apr 2009 23:54:13 %2B0400") References: <37646522@h30.sp.ipt.ru>
next in thread | previous in thread | raw e-mail | index | archive | help
On Tue, 07 Apr 2009 23:54:13 +0400, Boris Samorodov <bsam@ipt.ru> 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$
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?871vs49nmw.fsf>