makefile - Make 不喜欢 $(addprefix a,b)

标签 makefile build

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/

相关文章:

java - 在没有 NodeJS 的情况下使用 EJS

linux - 未通过目标时打印默认目标

c - 如何制作正确的 C makefile

c++ - 在 Mac OS X 上 boost 生成文件

java - 为什么 maven-assembly-plugin 多次将相同的依赖项放入我的 zip 中?

build - 在 CMake 中处理自定义文件类型依赖项的理想方法是什么?

c++ - gcc soname 无法识别的命令行

c++ - 使用 Makefile 编译失败但在命令行中成功

meteor - 在docker中构建meteor应用程序时出现"You have run Meteor as root"

ios - cordova build ios 不创建 ipa 文件