假设我有以下生成文件:
TARGETS = a b c
all: $(TARGETS)
@echo Done.
%.o: %.cpp
@echo Compiling $@...
touch $@
%: %.o
@echo Building $@...
touch $@
我希望这应该没有问题运行:该all
规则将触发%
, 规则,该规则将触发该%.o
规则,生成a.o
,b.o
和c.o
文件,然后最终生成a
,b
和文件。c
但是,运行make
会导致以下输出:
ghb@Nemo:~/Downloads$ make
g++ a.cpp -o a
/usr/lib/x86_64-linux-gnu/gcc/x86_64-linux-gnu/4.5.2/../../../crt1.o: In function `_start':
(.text+0x20): undefined reference to `main'
collect2: ld returned 1 exit status
make: *** [a] Error 1
g++
为什么我突然想跑?我对此没有任何规定。此外,运行make a.o
后跟make a
运行正常,但运行make a
会导致上述行为。
我能做些什么来防止make
试图“想出”它认为适合目标的命令?