强制erl -make在宏更改时重新编译文件

时间:2010-10-07 11:07:58

标签: erlang makefile

我尝试做类似How to make two different source directories in a Makefile output to one bin directory?的事情,所以我有这些文件(相对于我的项目根目录):

Emakefile:
% EMakefile
% -*- mode: erlang -*-
{["src/*", "src/*/*", "src/*/*/*"],
 [{i, "include"}, {outdir, "ebin"}, debug_info]}.

test/Emakefile:
% EMakefile
% -*- mode: erlang -*-
{["../src/*", "../src/*/*", "../src/*/*/*"],
 [{i, "../include"}, {outdir, "../ebin"}, debug_info, {d, 'TEST'}]}.

Makefile:
EPATH=-pa ebin

all: before_compile
    erl -make

all_test: before_compile
    cd test
    erl -make
    cd ..

before_compile: mk_ebin copy_sqlite create_db copy_config copy_dot_app

test: all_test
    erl -noshell $(EPATH) \
        -s tests run \
        -s init stop
    rm -f ct.db

clean:
    rm -fv ebin/*

... dependencies of before_compile

问题是运行make test不会重新编译已使用make编译的任何模块。似乎erl -make并不关心它们是在没有定义TEST的情况下编译的,它只是检查模块本身是否比beam-files更旧。如何强制它重新编译(并避免在不需要时重新编译)?

更新:奇怪的是,在make all_test之后立即运行make clean时,似乎使用./Emakefile代替test/Emakefile:我正在获取

Recompile: src/tests
Recompile: src/server_protocol_client

等。没有测试而不是

Recompile: ../src/tests
Recompile: ../src/server_protocol_client

我手动执行cd test; erl -make。知道为什么吗?无论如何,我已通过删除test/Emakefile并替换all_test中的Makefile来解决此问题:

all_test: before_compile
    erl -noshell -eval "make:all([{d, 'TEST'}])." -s init stop

1 个答案:

答案 0 :(得分:3)

all_test: before_compile
    cd test
    erl -make
    cd ..

这是不正确的。每一行都有自己的流程。这样做:

all_test: before_compile
    cd test; \
    erl -make