如何将字符串与makefile中的多个文本进行匹配?
给定以下ifeq语句,如何将其压缩,以便在一个ifeq块中处理字符串检查 我已经研究过了,但不确定它将如何准确地应用于这个问题 大概是这样的:如何将字符串与makefile中的多个文本进行匹配?,makefile,string-comparison,Makefile,String Comparison,给定以下ifeq语句,如何将其压缩,以便在一个ifeq块中处理字符串检查 我已经研究过了,但不确定它将如何准确地应用于这个问题 大概是这样的: ifeq ($(OS), Linux) foo endif ifeq ($(OS) in (Darwin, FreeBSD, NetBSD)) # <- something like this bar endif include gmtt.mk OS := $(shell uname -s) # define a gmtt
ifeq ($(OS), Linux)
foo
endif
ifeq ($(OS) in (Darwin, FreeBSD, NetBSD)) # <- something like this
bar
endif
include gmtt.mk
OS := $(shell uname -s)
# define a gmtt table with 2 columns
define os-table :=
2
Linux foo
Windows bar
Darwin baz
FreeBSD bof
NetBSD baf
CYGWIN foobar
endef
my-var := $(call select,$(os-table),2,$$(call str-match,$$(OS),$$1%))
$(info I'm on $(OS) and I selected >$(my-var)<)
您可以将此功能用于:
ifeq ($(OS), Linux)
foo
endif
ifneq (,$(filter $(OS),Darwin FreeBSD NetBSD))
bar
endif
您可以将此功能用于:
ifeq ($(OS), Linux)
foo
endif
ifneq (,$(filter $(OS),Darwin FreeBSD NetBSD))
bar
endif
您也可以使用它,尽管它仍然是测试版。您的代码如下所示:
ifeq ($(OS), Linux)
foo
endif
ifeq ($(OS) in (Darwin, FreeBSD, NetBSD)) # <- something like this
bar
endif
include gmtt.mk
OS := $(shell uname -s)
# define a gmtt table with 2 columns
define os-table :=
2
Linux foo
Windows bar
Darwin baz
FreeBSD bof
NetBSD baf
CYGWIN foobar
endef
my-var := $(call select,$(os-table),2,$$(call str-match,$$(OS),$$1%))
$(info I'm on $(OS) and I selected >$(my-var)<)
您也可以使用它,尽管它仍然是测试版。您的代码如下所示:
ifeq ($(OS), Linux)
foo
endif
ifeq ($(OS) in (Darwin, FreeBSD, NetBSD)) # <- something like this
bar
endif
include gmtt.mk
OS := $(shell uname -s)
# define a gmtt table with 2 columns
define os-table :=
2
Linux foo
Windows bar
Darwin baz
FreeBSD bof
NetBSD baf
CYGWIN foobar
endef
my-var := $(call select,$(os-table),2,$$(call str-match,$$(OS),$$1%))
$(info I'm on $(OS) and I selected >$(my-var)<)