为什么make认为目标是最新的?

时间:2010-10-14 09:19:11

标签: makefile

这是我的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)
...

4 个答案:

答案 0 :(得分:363)

也许你在目录中有一个名为test的文件/目录。如果此目录存在,并且没有更新的依赖项,则不会重建此目标。

要在这些与文件无关的目标上强制重建,你应该按照以下方式使它们变得虚假:

.PHONY: all test clean

请注意,您可以在那里声明所有虚假目标。

答案 1 :(得分:17)

编辑:这仅适用于某些版本的make - 您应该查看您的手册页。

您也可以将-B标记传递给make。根据手册页,这样做:

  

-B, --always-make无条件地制作所有目标。

如果您处于不想编辑make -B test或更改测试文件夹名称的情况,Makefile可以解决您的问题。

答案 2 :(得分:8)

在存在Makefile的目录中具有与Makefile目标名称相同名称的文件时,就会发生这种情况。

enter image description here

答案 3 :(得分:0)

我的错误是使目标名称为“ filename.c:”,而不仅仅是“ filename:”

相关问题