环境说明
操作系统: macos 12.6.3 (intel)
make版本: GNU make 3.81
执行 make -v
返回如下:
GNU Make 3.81
Copyright (C) 2006 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE.
This program built for i386-apple-darwin11.3.0
复现方式
目录中只有2个文件: Makefile 和 abc.c , 其中 abc.c
文件是空的, 没有任何内容
Makefile内容如下:
test: abc.o
@echo '执行test'
clean:
$(RM) test abc.o
.PHONY: test clean
执行命令: make clean && make test
, 会输出:
rm -f test abc.o
cc -c -o abc.o abc.c
执行test
我的问题是:
- 为什么
make
会自动执行cc -c -o abc.o abc.c
这句话? 我的本意是想在执行 test 的时候, 判断 abc.o 这个文件应该存在, 不存在则报错 - 如果删掉
abc.c
这个文件, 新建一个abc.java
就会按我的预期报错 - 上述的这个自动执行
cc -c -o
是GNU make
默认的行为么? 有没有官方文档说这个事情? 是否有方法或者参数关闭这个默认行为呢? 我不知道这个问题用什么关键字去搜素