Make 给了我错误:
make/sources.make:16: *** missing separator. Stop.
The terminal process terminated with exit code: 2
生成此错误的代码是:
$(addprefix a,b)
我检查了空格,但没有找到任何东西。
如果我将其注释掉,则不会给出任何错误。我已经将范围缩小到这一行,但我无法弄清楚。 'a' 和 'b' 可以替换为任何内容,但仍然不起作用。但是,如果您删除它的所有参数,例如 $(addprefix ,)
,则不会给出任何错误。
这是怎么回事?
包含错误的 makefile 的完整代码:
# sources.make - source files
# path of source files
SOURCEPATH=src
# build list of source files
# categorize source files
SOURCE_MAIN=main.c
# add categories to SOURCES as needed
SOURCES+=$(SOURCE_MAIN)
# add the SOURCEPATH to each source file
#$(addprefix $(SOURCEPATH),$(SOURCES)) <------ This is the true error code
$(addprefix a,b)
# extra files to remove
TRASHFILES = stdout.txt stderr.txt
# extra directories to remove
TRASHDIRS = junkdir
# build target
TARGET = $(PROG)$(EXT)
# generate object files
OBJECTS = $(patsubst %.c,%.o,$(SOURCES))
# generate dependency files
DEPENDS = $(patsubst %.c,%.d,$(SOURCES))
最佳答案
有问题的行被解释为规则,而不是指令。它应该改为:
SOURCES := $(addprefix $(SOURCEPATH)/,$(SOURCES))
关于makefile - Make 不喜欢 $(addprefix a,b),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51776779/