makefile - 简单检查现有文件时 Makefile 出错

标签 makefile syntax-error file-exists

在生成文件中,我需要检查文件是否存在。关于这个answer from holms ,我是这样试的:

all:
    ifeq ("","$(wildcard testFile)")
       echo "File exists"
    else
       echo "File is missing"
    endif

然而我得到这个错误:

ifeq ("","")
/bin/sh: 1: Syntax error: word unexpected (expecting ")")
Makefile:3: recipe for target 'all' failed
make: *** [all] Error 2

我的错误在哪里以及如何解释此语法错误消息?

最佳答案

您已经标记了 make 语法行,因此 make 将它们传递给您的 shell,去掉制表符(也反转条件并删除引号)

all:
ifeq (,$(wildcard testFile))
    echo File is missing
else
    echo File exists
endif

关于makefile - 简单检查现有文件时 Makefile 出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40926931/

相关文章:

Python 语法错误 : EOF while scanning triple-quoted string literal

c# - SSIS脚本任务检查文件是否存在于文件夹中

VBScript 使用通配符移动文件(如果存在)

linux - Make 无法看到除 gcc 之外的命令(配方)

c - make—我可以抑制格式截断错误吗?

linux - 如何读取和打印 makefile 目标中的文件内容(某些设置)?

compiler-errors - 在我的Triangle类中找不到符号错误

syntax-error - 语法错误和解析错误之间的区别

java - 如何修改 File 对象的 .isFile() 或 .exists() 方法检查所述文件的位置?

c - 使用 "$**"在 Makefile 中直接输入文件