测试某个功能是否可用或不返回错误

测试某个功能是否可用或不返回错误

让-v返回:

GNU Make 4.2.1
Built for x86_64-pc-linux-gnu
Copyright (C) 1988-2016 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

在一个目录下,一一文件:makefile

ifneq ($(jobserver),T)
$(error This makefile only works with a Make program that supports $$(eval))
endif

通过类型 make 调用 make

makefile:2: *** This makefile only works with a Make program that supports $(eval).  Stop.

即使我尝试

ifneq ($(eval),T)
$(error This makefile only works with a Make program that supports $$(eval))
endif

仍然返回

makefile:2: *** This makefile only works with a Make program that supports $(eval).  Stop.

我遵循教程从网上,这些 makefile 测试 make 中的特性/功能是否可用。它不应该产生错误。

答案1

你错过了使用其中eval在测试之前设置变量:

$(eval eval_available := T)
ifneq ($(eval_available),T)
$(error This makefile only works with a Make program that supports $$(eval))
endif

如果eval可用,第一行将设置eval_availableT;如果不是,就不会。第二行检查是否eval_available设置为T

相关内容