configparms ;; esac-6ren">
gpt4 book ai didi

regex - Makefile 'if' 条件与正则表达式

转载 作者:行者123 更新时间:2023-12-04 16:12:01 26 4
gpt4 key购买 nike

我需要做这样的事情:

case `uname -m` in
i?86) echo "CFLAGS += -march=i486 -mtune=native" > configparms ;;
esac

但是我需要在特定目标的 makefile 中执行此操作。我还没有找到用正则表达式创建 if 条件的方法。

我试过这个:
ifeq ($(shell uname -m), i*86)

但它不起作用。
甚至
ifeq ($(shell uname -m), i686)

不起作用。

最佳答案

使用 Makefile 内置条件(与 Ωmega's Bash solution 相反)

ifeq ($(shell uname -m | egrep "i.86"),) # empty result from egrep
@echo "No match"
else
@echo "Match"
endif

请参阅此处使用此方法验证 Git 标签 https://gist.github.com/jesugmz/a155b4a6686c4172048fabc6836c59e1 .

关于regex - Makefile 'if' 条件与正则表达式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11328428/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com