如何將Make目標標記爲「不可還原」或「不要直接調用此目標」?mark使目標不可直接調用
例如,
common:
touch $(VAR) # VAR is expected to be set
foo: VAR = this
foo: common
bar: VAR = that
bar: common
我不希望用戶執行以下操作:
make common
是否有製作成語來標記common
爲uncallable?
如何將Make目標標記爲「不可還原」或「不要直接調用此目標」?mark使目標不可直接調用
例如,
common:
touch $(VAR) # VAR is expected to be set
foo: VAR = this
foo: common
bar: VAR = that
bar: common
我不希望用戶執行以下操作:
make common
是否有製作成語來標記common
爲uncallable?
下將工作
ifeq ($(MAKECMDGOALS),common)
$(error do not call common directly)
endif
然而,寫ifeq ($(MAKECMDGOALS), ...)
是困難的目標,像
%-$(VERSION).tar:
# create the final .tar file
我希望有更簡潔的東西。類似於可應用於目標的'.PHONY'標籤。例如,可能像'.INDIRECT'這樣的標記目標爲間接可調用(或不能直接調用)。 – JamesThomasMoon1979
沒有什麼類似於.PHONY
,保持目標從通過命令行正在興建。你可以這樣做:
common:
$(if $(VAR),,$(error You must run 'make foo' or 'make bar'))
touch $(VAR)
可能的重複[我如何在GNU中使目標爲「private」僅供內部使用?或:如何最好地執行特定於目標的變量值?](http://stackoverflow.com/questions/26063839/how-can-i-make-a-target-private-in-gnu-make-for-internal -use-only-or-how-to) – Tsyvarev