$(error ...)
如果不满足某些先决条件,我想用它来中止我的制作过程。fails_to_work
失败时目标应该test -d /foobar
中止。
坏的.mk
all: this_works fails_to_work
this_works:
@echo echo works...
@test -d ~ || echo ~ is not a directory
@test -d /foobar || echo /foobar is not a directory
fails_to_work:
@echo error does not work...
@test -d ~ || $(error ~ is not a directory)
@test -d /foobar || $(error /foobar is not a directory)
$ make -f BAD.mk
echo works...
/foobar is not a directory
BAD.mk:9: *** ~ is not a directory. Stop.
如您所见,甚至“错误不起作用......”都不会回显到屏幕上。fails_to_work
在它开始之前失败的秘诀。我该如何解决这个问题?我的用例之一是@test -d $(MY_ENV_VAR)
,但我认为这与示例中给出的硬编码路径没有什么不同。
更新(版本信息)
$ 制作--版本
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 x86_64-pc-linux-gnu