How to get rebar to run 'make' for a dependency?

1.3k Views Asked by At

One of my dependencies doesn't use rebar -- it uses a Makefile. How do I get rebar to run this Makefile, rather than attempting to compile the source itself?

Note that I'd like to continue using rebar for everything else.

2

There are 2 best solutions below

0
On

If you use rebar through make, you can add this kind of code to your Makefile:

    @if [[ -f $@/Makefile ]]; \
    then echo 'make -C $@ all' ; \
               make -C $@ all  ; \
    else echo 'cd $@ && rebar get-deps compile && cd ../..' ; \
               cd $@ && rebar get-deps compile && cd ../..  ; fi

It checks if $@ has a Makefile then decides whether to use make or rebar.

This snippet is from erl.mk https://github.com/fenollp/erl-mk/blob/master/erl.mk#L17-L21

0
On

Looking at the rebar.config example file, you could mark the dependency as raw, meaning it's not compiled by rebar. Then you could add either a pre or post compile hook to run make in that dependency directory. The rebar generate command should still be able to pick up any Erlang apps built there, assuming they have OTP file structure.