[erlang-questions] Makefile detecting / downloading rebar
Michael Santos
michael.santos@REDACTED
Sun Jul 22 14:17:07 CEST 2012
On Sun, Jul 22, 2012 at 01:08:15PM +0200, Gleb Peregud wrote:
> 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?
You could download rebar using erlang rather than wget:
# shell is GNU makefile only syntax
REBAR=$(shell which rebar || echo ./rebar)
./rebar:
erl -noshell -s inets start -s ssl start \
-eval 'httpc:request(get, {"https://github.com/downloads/basho/rebar/rebar", []}, [], [{stream, "./rebar"}])' \
-s inets stop -s init stop
chmod +x ./rebar
More information about the erlang-questions
mailing list