我尝试做类似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
答案 0 :(得分:3)
all_test: before_compile
cd test
erl -make
cd ..
这是不正确的。每一行都有自己的流程。这样做:
all_test: before_compile
cd test; \
erl -make