Skip to content

Instantly share code, notes, and snippets.

@joedevivo
Last active April 27, 2016 14:43
Show Gist options
  • Save joedevivo/1f5448cc73f23cd9619c to your computer and use it in GitHub Desktop.
Save joedevivo/1f5448cc73f23cd9619c to your computer and use it in GitHub Desktop.
rebar3.mk

An easy Makefile for rebar3

Here's an easy makefile for rebar3. All it does is download rebar3 into your project's './rebar3' if you don't have it already on your path. make all just tells rebar to do everything. So even people with no exposure to rebar3 can build your project.

The End.

REBAR3_URL=https://s3.amazonaws.com/rebar3/rebar3
# If there is a rebar in the current directory, use it
ifeq ($(wildcard rebar3),rebar3)
REBAR3 = $(CURDIR)/rebar3
endif
# Fallback to rebar on PATH
REBAR3 ?= $(shell test -e `which rebar3` 2>/dev/null && which rebar3 || echo "./rebar3")
# And finally, prep to download rebar if all else fails
ifeq ($(REBAR3),)
REBAR3 = $(CURDIR)/rebar3
endif
all: $(REBAR3)
@$(REBAR3) do clean, compile, eunit, ct, dialyzer
rel: all
@$(REBAR3) release
$(REBAR3):
curl -Lo rebar3 $(REBAR3_URL) || wget $(REBAR3_URL)
chmod a+x rebar3
@etrepum
Copy link

etrepum commented Jun 13, 2015

👍 Might be cool to do that curl/wget atomically, curl -Lo (or -LO) will definitely write a partial file if the transfer gets truncated, not sure how wget behaves.

@jaredmorrow
Copy link

Here's how you'd fix it for solaris (just replace rebar3 for rebar)

msantos/procket@cc55bb9

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment