如何将字符串与生成文件中的多个文字进行匹配?

ide*_*n42 1 makefile string-comparison

给定以下ifeq语句,如何压缩它以便可以在一个ifeq块中处理字符串检查?

OS:=$(shell uname -s)

ifeq ($(OS), Linux)
    foo
endif
ifeq ($(OS), Darwin)
    bar
endif
ifeq ($(OS), FreeBSD)
    bar
endif
ifeq ($(OS), NetBSD)
    bar
endif
Run Code Online (Sandbox Code Playgroud)

我已经研究过类似的问答,但不确定它如何完全适用于这个问题。


像这样的东西:

ifeq ($(OS), Linux)
    foo
endif
ifeq ($(OS) in (Darwin, FreeBSD, NetBSD))  # <- something like this
    bar
endif
Run Code Online (Sandbox Code Playgroud)

Mad*_*ist 5

您可以为此使用过滤器功能:

ifeq ($(OS), Linux)
    foo
endif
ifneq (,$(filter $(OS),Darwin FreeBSD NetBSD))
    bar
endif
Run Code Online (Sandbox Code Playgroud)