views:

60

answers:

0

I tried to do something similar to http://stackoverflow.com/questions/1894363/how-to-make-two-different-source-directories-in-a-makefile-output-to-one-bin-dire/1895096#1895096, so I have these files (relative to my project root):

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

The problem is that running make test doesn't recompile any modules which are already compiled with make. It seems erl -make doesn't care that they were compiled without TEST defined, it just checks that the modules themselves are older than beam-files. How do I force it to recompile (and avoid recompilation when it isn't needed)?

UPDATE: Strangely, when running make all_test immediately after make clean, it appears that ./Emakefile is used instead of test/Emakefile: I am getting

Recompile: src/tests
Recompile: src/server_protocol_client

etc. and no tests instead of

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

which I get by doing cd test; erl -make manually. Any idea why? Anyway, I've fixed this problem by removing test/Emakefile and replacing all_test in Makefile:

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