Roger Lipscombe
Roger Lipscombe

Reputation: 91925

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

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.

Upvotes: 4

Views: 1353

Answers (2)

fenollp
fenollp

Reputation: 2496

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

Upvotes: 0

kjw0188
kjw0188

Reputation: 3685

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.

Upvotes: 3

Related Questions