Skip to content

Instantly share code, notes, and snippets.

@sntran
Last active December 12, 2015 09:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sntran/4752811 to your computer and use it in GitHub Desktop.
Save sntran/4752811 to your computer and use it in GitHub Desktop.
Makefile for Erlang projects based on Rebar
REBAR=$(shell which rebar || echo ./rebar)
REBAR_URL=https://github.com/rebar/rebar/wiki/rebar
.PHONY: all test deps clean
all: $(REBAR) deps compile start
start:
./start.sh
app: $(REBAR)
mkdir -p apps/${name}
cd apps/${name} && ../../rebar create-app appid=${name}
compile: $(REBAR)
$(REBAR) compile
deps: $(REBAR)
$(REBAR) get-deps
clean: $(REBAR) testclean
$(REBAR) clean
distclean: $(REBAR) clean relclean
$(REBAR) delete-deps
rm -f ./rebar
TEST_LOG_FILE := eunit.log
testclean:
@rm -f $(TEST_LOG_FILE)
# Test each dependency individually in its own VM
test: $(REBAR) deps compile testclean
# @$(foreach dep, \
# $(wildcard deps/*), \
# (cd $(dep) && ../../rebar eunit deps_dir=.. skip_deps=true) \
# || echo "Eunit: $(notdir $(dep)) FAILED" >> $(TEST_LOG_FILE);)
$(REBAR) eunit skip_deps=true
@if test -s $(TEST_LOG_FILE) ; then \
cat $(TEST_LOG_FILE) && \
exit `wc -l < $(TEST_LOG_FILE)`; \
fi
##
## Release targets
##
rel: $(REBAR) deps
$(REBAR) compile generate
relclean:
rm -rf rel/eggs
./rebar:
erl -noshell -s inets -s ssl \
-eval 'httpc:request(get, {"$(REBAR_URL)", []}, [], [{stream, "./rebar"}])' \
-s init stop
chmod +x ./rebar
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment