我准备了下面的makefile,来自动清理我想要删除的所有临时项目:
.SUFFIXES : bye
# The default action is to
# remove the latest project, i was working at...
byebye :
rm -rf "$(ls -1dt /projects/new_* | head -n1)"
# Remove a specific project.
# Run make from the command-line as 'make new_1_bye' etc.
%_bye :
rm -rf /projects/$*
但是,如果我运行make as:
$ make
我:
make: *** No targets. Stop.
为什么?
.SUFFIXES
线似乎引起了麻烦。后缀通常以点开头(例如.c
)。Make似乎接受后缀bye
,但这意味着byebye:
行标志着后缀规则的开始,%_bye
行也是后缀规则。这意味着在makefile
中没有引用目标,因此出现了错误消息。
如果您使用的是.SUFFIXES : .bye
,那么make
就会对makefile满意。