我有一个Makefile变量,如下所示
L_PATH_INCLUDE = c:\dir1\include C:\dir2\include C:\dir3\include
我需要将其移交给其他需要此的工具
tool.exe add-include-dir "c:\dir1\include" "C:\dir2\include" "C:\dir3\include"
我尝试按照以下方式进行操作,但是工具报告错误,即不应有单个字符的变量,并且我使用了 $(space)
$(subst $(space)," ",$(strip $(L_PATH_INCLUDE)))
是否可以通过任何其他方式而不使用$(space)或单个字符变量
放置引号没有问题,它不是解释的符号。但是您需要在L_PATH_INCLUDE中的所有路径周围加上引号,并且要实现这一点,我会这样做:
L_PATH_INCLUDE = c:\dir1\include C:\dir2\include C:\dir3\include all: echo $(addprefix ",$(addsuffix ",$(L_PATH_INCLUDE)))
哪个输出make all
:
回声“ c:\ dir1 \ include”“ C:\ dir2 \ include”“ C:\ dir3 \ include”
c:\ dir1 \ include C:\ dir2 \ include C:\ dir3 \ include
您只需用命令替换echo即可。
基本上,这个想法是使用addprefix和addsuffix在L_PATH_INCLUDE中每个单词的开头和结尾添加引号。
如果您将我的答案复制/粘贴到Makefile中,请注意用适当的表格代替这四个空格。