我的所有服务都有基本 Makefile,在某些情况下我想使用默认的“测试”目标,在其他情况下我想覆盖\添加它。这些是我迄今为止拥有的文件(显然它没有按预期工作......)。
生成文件库
test:
./.../run-tests.sh
Run Code Online (Sandbox Code Playgroud)
生成文件
BASE_FILE := /path/to/MakefileBase
include ${BASE_FILE}
test:
@$(MAKE) -f $(BASE_FILE) test # un/comment this line in order to run the default tests.
# echo "custom test"
Run Code Online (Sandbox Code Playgroud)
当我运行测试并注释掉第一行时,我得到以下结果
Makefile:10: warning: overriding commands for target `test'
/.../MakefileBase:63: warning: ignoring old commands for target `test'
echo "no tests"
no tests
Run Code Online (Sandbox Code Playgroud)
除了警告它按预期工作之外,问题是当我尝试使用父函数时,我收到以下错误:
Makefile:9: warning: overriding commands for target `test'
/.../MakefileBase:63: warning: ignoring old commands for target `test'
make[1]: test: No such file or directory
make[1]: *** No rule to …Run Code Online (Sandbox Code Playgroud)