制作:使用正则表达式检测平台 [英] Make: detect platform with regex
问题描述
我正在编写一个查看uname输出的makefile,但是由于某种原因,uname系统名称过于具体,例如它是CYGWIN-NT-1.2.3.我需要将其与正则表达式进行比较.
I'm writing a makefile that looks at the uname output, but for some reason the uname system name is too specific e.g. it is CYGWIN-NT-1.2.3. What I need is to compare that to a regular expression.
当前我只能检测到特定的字符串,例如
Currently I can detect only specific strings e.g.
ifeq (${value},CYGWIN-NT-4.5)
do something
elif
我如何与正则表达式进行比较,例如CYGWIN *?
How can I compare with a regex e.g. CYGWIN*?
推荐答案
您不能在GNU make中使用正则表达式(不使用 shell
或类似的调用处理正则表达式的shell脚本).
You can't use regular expressions in GNU make (without using shell
or similar to invoke a shell script that handles regex's).
但是您不需要正则表达式来进行比较,这只是看值是否以给定的字符串开头.您可以使用过滤器功能:
But you don't need regex's for the comparison you are looking for, which is just to see if the value starts with a given string. You can use the filter function:
ifneq (,$(filter CYGWIN%,$(value)))
...on cygwin...
endif
这篇关于制作:使用正则表达式检测平台的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!