从 makefile 中的字符串中删除前两个字符?

Remove first two chars from string in makefile?

如何从 makefile 中的字符串中删除前两个字符?

在 windows,假设我有:

ROOT_DIR := $(dir $(realpath $(firstword $(MAKEFILE_LIST))))

然后,我有:

WINTOOLS := $(ROOT_DIR)/../../wintools
GOWTOOLS := $(WINTOOLS))/Gow/bin

我的 GOWTOOLS 变量有,例如:"L:/path/to/project/../../wintools/Gow/bin"。现在,如果我尝试从那里 运行 命令,请说:

$(GOWTOOLS)/sed -e xxxxx

我收到错误消息“'L:' 未被识别为内部或外部命令、可运行程序或批处理文件。

如果我手动输入减去 L:. 的路径,它工作正常。如果我翻转斜线,它工作正常。

如何在 Makefile-ese 中从工具目录字符串中删除驱动器说明符?

我想不出一个好的方法来随意删除两个字符,但你可以利用 : 在 Windows 文件 path/name 中不合法的事实,然后做类似于:

GOWTOOLS := $(subst :, ,$(WINTOOLS))/Gow/bin)
GOWTOOLS := $(wordlist 2,$(words $(GOWTOOLS),$(GOWTOOLS))

但如果 If I flip the slashes, it works fine 为真,则可能 simpler/safer 使用(因为 /\ 在路径名中都不合法):

GOWTOOLS := $(subst /,\,$(WINTOOLS))/Gow/bin)