Make

使測試功能可用或不返回錯誤

  • July 12, 2022

使 -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 中的功能/功能是否可用。它不應該產生錯誤。

你錯過了使用whicheval在測試之前設置變數:

$(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.

引用自:https://unix.stackexchange.com/questions/709576