Makefile 如何将值中带有空格的变量作为单个参数传递给GNU make函数?

Makefile 如何将值中带有空格的变量作为单个参数传递给GNU make函数?,makefile,gnu-make,Makefile,Gnu Make,这是我的Makefile MYPATH = /dir 1/file 1.txt test1: echo $(notdir $(MYPATH)) test2: echo $(notdir "$(MYPATH)") test3: echo TODO 我的目的是从中获取路径的文件1.txt部分 /dir1/file 1.txt。是的,这是一条有空格的路径 我无法得到想要的结果 $ make test1 echo dir file 1.txt dir file 1.txt

这是我的Makefile

MYPATH = /dir 1/file 1.txt

test1:
    echo $(notdir $(MYPATH))

test2:
    echo $(notdir "$(MYPATH)")

test3:
    echo TODO
我的目的是从中获取路径的
文件1.txt
部分
/dir1/file 1.txt
。是的,这是一条有空格的路径

我无法得到想要的结果

$ make test1
echo dir file 1.txt
dir file 1.txt
在上述输出中,
notdir
似乎提供了三个独立的 参数:
/dir
1/file
1.txt
,因此它们的
notdir
返回的部分有:
dir
file
1.txt

以下这些根本不起作用

$ make test2
echo dir file 1.txt"
/bin/sh: 1: Syntax error: Unterminated quoted string
Makefile:7: recipe for target 'test2' failed
make: *** [test2] Error 2
为什么它会抱怨“未终止的引用字符串”

解决问题的正确方法是什么。我想要一个像 跟着

$ make test3
echo file 1.txt
file 1.txt

可能重复的您还需要这个问题的答案吗?