[erlang-questions] Makefile detecting / downloading rebar

Peter Lemenkov <>
Sun Jul 22 13:17:55 CEST 2012


Hello.

2012/7/22 Gleb Peregud <>:
> Hello all
>
> Just an idea. Do you think this is a good approach to put the
> following into a makefile of an open source library?
>
> all: rebar
>         ./rebar compile
>
> rebar:
>         which rebar && ln -sf `which rebar` || true
>         test -x ./rebar || (wget
> http://cloud.github.com/downloads/basho/rebar/rebar && chmod u+x
> rebar)
>
> This allows user who has rebar installed globally to still use it, but
> for users who prefer local rebar binaries to download it
> automatically. Can this script be improved?

Your script requires wget which isn't installed by default on some
Linux boxes (sad but true). So you need to check for wget first which
adds even more complexity. Why not just to bundle your own rebar copy
and check whether target box has system-wide installed version first?

So my proposal is to simply include your own rebar copy into the
project's source tree and add the following line to the Makefile
(should be topmost line):

REBAR ?= $(shell which rebar 2>/dev/null || which ./rebar)

Also you need to replace all 'rebar' or './rebar' invocations with $(REBAR).

-- 
With best regards, Peter Lemenkov.



More information about the erlang-questions mailing list