在Abort makefile if variable not set處接收到建議我試圖使用ifndef
,但它不起作用。Makefile - 如果變量未設置,則發生錯誤
的Makefile:
foo:
ifndef BAR
$(error "Must set BAR")
endif
但make foo BAR=quux
不起作用:
Makfile:2: *** "Must set BAR". Stop.
是怎麼回事?它是否是空白問題?或者我完全誤解了?
(我使用GNU MAKE)
我也試過:
foo:
ifndef BAR
$(error "Must set BAR")
endif
echo $(BAR)
這似乎排序的工作,但還是引起了,如果要調用的ifndef
一個目標在Makefile進一步下跌(不需要設置變量)被調用。