I have the following Makefile to create my erlang project:
.SUFFIXES: .erl .beam .yrl
ERL_SRC := $(wildcard src/*.erl)
ERL_OBJ := $(patsubst src/%.erl,ebin/%.beam,${ERL_SRC})
all: main
main: ${ERL_OBJ}
ebin/%.beam: src/%.erl
erlc +debug_info -W -o ebin $<
clean:
rm -fr ebin/*.beam
I am trying to update this to also create my eunit tests in the test / eunit folder and get output to the same ebin folder as src like this:
.SUFFIXES: .erl .beam .yrl
ERL_SRC := $(wildcard src/*.erl)
ERL_OBJ := $(patsubst src/%.erl,ebin/%.beam,${ERL_SRC})
EUNIT_SRC := $(wildcard test/eunit/*.erl)
EUNIT_OBJ := $(patsubst test/eunit/%.erl,ebin/%.beam,${EUNIT_SRC})
all: main
main: ${ERL_OBJ}
ebin/%.beam: src/%.erl test/eunit/%.erl
erlc +debug_info -W -o ebin $<
clean:
rm -fr ebin/*.beam
eunit: ${EUNIT_OBJ}
test: main eunit
Make the main work great, but if I try to run the test, it will not work with:
make: *** No rule to make target `ebin/data_eunit.beam', needed by `eunit'. Stop.
The test_eunit.erl module is in the / eunit test. The problem seems to be related to the ebin /% target value. If I change src /%. Erl on test / eunit /%. Erl, then I can build tests, but not src. How can I build from two source folders and output the output to one output folder?
source
share