なぜmakeはターゲットが最新であると判断するのでしょうか? 質問する

なぜmakeはターゲットが最新であると判断するのでしょうか? 質問する

これは私の Makefile です:

REBAR=./rebar
REBAR_COMPILE=$(REBAR) get-deps compile

all: compile

compile:
    $(REBAR_COMPILE)

test:
    $(REBAR_COMPILE) skip_deps=true eunit

clean:
    -rm -rf deps ebin priv doc/*

docs:
    $(REBAR_COMPILE) doc

ifeq ($(wildcard dialyzer/sqlite3.plt),)
static:
    $(REBAR_COMPILE) build_plt analyze
else
static:
    $(REBAR_COMPILE) analyze
endif

複数回実行しmake compile

aromanov@alexey-desktop:~/workspace/gm-controller/lib/erlang-sqlite$ make compile
./rebar get-deps compile
==> erlang-sqlite (get-deps)
==> erlang-sqlite (compile)

しかし、なぜか走るとmake testいつも

aromanov@alexey-desktop:~/workspace/gm-controller/lib/erlang-sqlite$ make test
make: `test' is up to date.

ファイルがコンパイルされていない場合でも、なぜでしょうか?

同じコマンドを直接実行すると、次のように動作します。

aromanov@alexey-desktop:~/workspace/gm-controller/lib/erlang-sqlite$ ./rebar get-deps compile skip_deps=true eunit
==> erlang-sqlite (get-deps)
==> erlang-sqlite (compile)
Compiled src/sqlite3_lib.erl
Compiled src/sqlite3.erl
==> erlang-sqlite (eunit)
...

ベストアンサー1

ディレクトリ内に、 という名前のファイル/ディレクトリがある可能性がありますtest。このディレクトリが存在し、より新しい依存関係がない場合、このターゲットは再構築されません。

このようなファイルに関連しないターゲットを強制的に再構築するには、次のように偽装する必要があります。

.PHONY: all test clean

すべての偽のターゲットをそこで宣言できることに注意してください。

偽のターゲットは、実際にはファイル名ではなく、明示的な要求を行ったときに実行されるレシピの名前にすぎません。

おすすめ記事