简介:
我在类似unix的系统上使用GNU Make(3.81)而且我遇到了一个问题,即$(wildcard, pattern)函数无法找到由(可能/显然?)先前执行的配方生成的文件,而其他程序(例如ls)能够验证其存在.我想知道为什么通配符函数没有返回任何东西,当它被扩展(到空字符串),以及我如何获得它来查找生成的文件.
测试用例:
以下测试用例说明了问题.
Makefile内容:
.PHONY: build clean
test:
@echo "Creating test file 'test'."
@echo "this is a test file" > test
build: test
@echo "Directory contents:"
@ls
@echo "Test file contents:"
@cat test
@echo "Wildcard output:"
@echo $(wildcard test)
clean:
@rm -f test
Run Code Online (Sandbox Code Playgroud)
运行makefile两次(然后清理)显示只有在第二次运行时它才会检测到创建的文件.
输出:
Creating test file 'test'.
Directory contents:
makefile test
Test file contents:
this is a test file
Wildcard output:
Directory contents:
makefile test
Test file contents:
this is a test file
Wildcard …Run Code Online (Sandbox Code Playgroud)