學習make,在下面的Makefile中,如何定義%.tar.bz2
的依賴性爲somefile.tar.bz2
?make:在依賴性中的文本函數
這將是這樣的: %.tar.bz2: $(function_to_cut_from_end_till_/ %.tar.bz2)
但我找不到如何做到這一點的man make
。
我從錯誤的一面接近這個嗎?
source=http://example.net/somefile.tar.bz2
source:=$(subst :,\:,$(source))
.PHONY: download
download: $(source)
%.tar.bz2:
@wget "[email protected]"
:1.你在一個模式規則的先決條件使用任何功能都只有一次評估,*前*'%'佔位符被替換爲其他任何內容,並且2.即使忽略它,我也看不到'%.tar.bz2:$(function_to_cut_from_end_till_ /%.tar.bz2)'是一個有用的事情。你能解釋你試圖達到的結果嗎? – slowdog
只是想用make,而不是shell來獲取文件名 - 你說得對,把它當作依賴是沒有任何意義的。我將在規則中使用'notdir'。 你會介意發佈它作爲答案,所以我可以接受它嗎? –