允许覆盖和 "simply expandable" 的变量?

Variable that allows override and "simply expandable"?

我在第 73 行的 GNU Makefile 中有以下内容:

RELEASE ?= $(shell $(UNAME) -r)
IS_FEDORA22_i686 = $(shell echo $(RELEASE) | $(EGREP) -i -c "fc22.i686")

它在 BSD、Linux(Ubuntu 和 Fedora)、OS X 和 Solaris 上运行良好。但是,在 Cygwin 和 MinGW 上,它会生成以下内容 (thanks cxw)。 Cygwin 和 MinGW 使用 Bash shell:

/bin/sh: -c: line 0: syntax error near unexpected token `('
/bin/sh: -c: line 0: `echo 2.0.4(0.287/5/3) | egrep -i -c "fc22.i686"'

根据手册和 6.2 The Two Flavors of Variables,我想我需要一个像这样的变量:

RELEASE ?::= $(shell $(UNAME) -r)

如何使一个变量既是可选的又是 "simply expandable"?

一种方法是:

RELTEXT:=$(<whatever command>)
RELEASE?=$(RELTEXT)

尽管 RELEASE 不能简单地扩展,但您知道它总是会扩展为固定文本。