nmake附加到变量 [英] nmake appending to variables
问题描述
- 实用程序:NMake
- 平台:Windows 7
我有以下Makefile
I have the following Makefile
FILE = $(shell) *.c
FILE += $(shell) *.cpp
exec:
@echo $(FILE)
这与make完美配合.这会引发以下 nmake 错误
This works perfectly fine with make. This throws up the following error with nmake
makefile(2) : fatal error U1036: syntax error : too many names to left of '='
Stop.
可能是什么原因?
没有一行
FILE += $(shell) *.cpp
nmake可以正常工作.
nmake works perfectly fine.
推荐答案
The +=
syntax is a GNU Make extension that was pioneered in Sun's make
in the late 80s. It is not part of the syntax for POSIX standard make
, or the original AT&T make
.
如果使用扩展名,则在切换到不支持扩展名的系统时会被抓住.您要么需要重做一些事情,要么必须坚持原来的系统.
If you use extensions, you get caught when you switch to a system that doesn't support them. You either have to rework things (hard) or stick with the original system.
一种修改文件以使其与 nmake
一起使用的方法可能是:
One way to modify the file to work with nmake
is probably:
FILE1 = $(shell) *.c
FILE2 = $(shell) *.cpp
FILE = $(FILE1) $(FILE2)
exec:
@echo $(FILE)
或者,假设未定义宏 shell
,甚至:
Or, given that the macro shell
is not defined, even:
FILE1 = *.c
FILE2 = *.cpp
FILE = $(FILE1) $(FILE2)
exec:
@echo $(FILE)
这篇关于nmake附加到变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!