在 gnu make 中 subst 是如何工作的?

问题描述 投票:0回答:1

请向我解释一下这行 make 的作用(

subst
部分)?

TRACK_CFLAGS = $(CC):$(subst ','\'',$(ALL_CFLAGS)):$(USE_GETTEXT_SCHEME)
c makefile gnu
1个回答
0
投票

我认为应该用 \' 替换单引号字符。

这将解释:

$ cat Makefile
in := 'aa'bb'
out_wrong := $(subst ','\'',$(in))
out_right := $(subst ',\',$(in))
$(info in=[$(in)])
$(info $$(subst ','\'',$$(in)) = [$(out_wrong)] (wrong))
$(info $$(subst ',\',$$(in)) = [$(out_right)] (right))

all:

$ make
in=['aa'bb']
$(subst ','\'',$(in)) = ['\''aa'\''bb'\''] (wrong)
$(subst ',\',$(in)) = [\'aa\'bb\'] (right)
make: Nothing to be done for 'all'.
© www.soinside.com 2019 - 2024. All rights reserved.