Function 我无法理解生成文件中patsubst的输出

Function 我无法理解生成文件中patsubst的输出,function,makefile,output,gnu-make,substitution,Function,Makefile,Output,Gnu Make,Substitution,这是一个文件: $ cat -n example.mak 1 define this 2 $(patsubst $(1)/%.o,%.o,why_this_does/that.o) 3 $(patsubst butnot/%.o,%.o, butnot/but_not_that.o) 4 endef 5 6 why: 7 $(info $(call this, why

这是一个文件:

$ cat -n example.mak
     1  define this
     2          $(patsubst $(1)/%.o,%.o,why_this_does/that.o)
     3          $(patsubst butnot/%.o,%.o, butnot/but_not_that.o)
     4  endef
     5
     6  why:
     7          $(info $(call this, why_this_does) ?)
这是我的问题:

$ make -f example.mak 
        why_this_does/that.o
        but_not_that.o ?
make: 'why' is up to date.

根本原因不在
patsubst
中,而在
call
中。有一个注释:

最后一个警告:在要调用的参数中添加空格时要小心。与其他函数一样,保留第二个和后续参数中包含的任何空格;这可能会造成奇怪的效果。在提供要调用的参数时,通常最安全的做法是删除所有无关的空白

事实上,如果你替换

$(info $(call this, why_this_does) ?)


你可以得到你想要的。

@Dadam42,makefile中的空格总是很棘手的。它们通常是分词器,当你想在某个地方留个位置,然后它们不知从何而来,击中你时,这可能会让你感到痛苦。
$(info $(call this,why_this_does) ?)