簡體   English   中英

Makefile匹配任何規則作為中間

[英]Makefile match anything rule as intermediate

考慮一下這個簡單的Makefile:

%.one: %.two
    echo one
%.two: %.three
    echo two
%.three: %.four
    echo three

all: hi.one

如預期的那樣, make all將產生:

echo three
three
echo two
two
echo one
one

但是,如果我制定了沒有任何前綴/后綴的中間規則:

%.one: %
    echo one
%: %.three
    echo one
%.three: %.four
    echo one

all: hi.one

make會失敗,因為沒有規則可以使hi.one 使用Make完全不可能嗎?

不,這是不可能的,因為模式規則的依賴性,非終結符匹配任何規則都會被忽略。

手冊中實際上並未提到這一點,但是在make源文件中的以下注釋( implicit.c:321 )使其清晰可見

      /* Rules that can match any filename and are not terminal
         are ignored if we're recursing, so that they cannot be
         intermediate files.  */

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM