calrissian/resources/make/common.mk

126 lines
3.6 KiB
Makefile
Raw Normal View History

ifeq ($(shell which erl),)
$(error Can't find Erlang executable 'erl')
exit 1
endif
2014-04-24 04:47:45 +00:00
LIB = $(PROJECT)
DEPS = ./deps
BIN_DIR = ./bin
SOURCE_DIR = ./src
OUT_DIR = ./ebin
TEST_DIR = ./test
TEST_OUT_DIR = ./.eunit
SCRIPT_PATH=$(DEPS)/lfe/bin:.:./bin:"$(PATH)":/usr/local/bin
ifeq ($(shell which lfetool),)
LFETOOL=$(BIN_DIR)/lfetool
else
LFETOOL=lfetool
endif
ERL_LIBS=.:..:$(shell pwd):$(shell $(LFETOOL) info erllibs)
OS := $(shell uname -s)
ifeq ($(OS),Linux)
HOST=$(HOSTNAME)
endif
ifeq ($(OS),Darwin)
HOST = $(shell scutil --get ComputerName)
endif
2014-04-24 04:47:45 +00:00
$(BIN_DIR):
mkdir -p $(BIN_DIR)
get-lfetool: $(BIN_DIR)
curl -L -o ./lfetool https://raw.github.com/lfe/lfetool/dev-v1/lfetool && \
2014-04-24 04:47:45 +00:00
chmod 755 ./lfetool && \
mv ./lfetool $(BIN_DIR)
get-version:
@PATH=$(SCRIPT_PATH) $(LFETOOL) info version
@echo "Erlang/OTP, LFE, & library versions:"
@ERL_LIBS=$(ERL_LIBS) PATH=$(SCRIPT_PATH) erl \
-eval "lfe_io:format(\"~p~n\",['$(PROJECT)-util':'get-versions'()])." \
-noshell -s erlang halt
2014-04-24 04:47:45 +00:00
get-deps:
@echo "Getting dependencies ..."
@PATH=$(SCRIPT_PATH) ERL_LIBS=$(ERL_LIBS) $(LFETOOL) download deps
2014-04-24 04:47:45 +00:00
clean-ebin:
@echo "Cleaning ebin dir ..."
@rm -f $(OUT_DIR)/*.beam
clean-eunit:
-@PATH=$(SCRIPT_PATH) $(LFETOOL) tests clean
2014-04-24 04:47:45 +00:00
compile: get-deps clean-ebin
@echo "Compiling project code and dependencies ..."
@which rebar.cmd >/dev/null 2>&1 && \
PATH=$(SCRIPT_PATH) ERL_LIBS=$(ERL_LIBS) rebar.cmd compile || \
PATH=$(SCRIPT_PATH) ERL_LIBS=$(ERL_LIBS) rebar compile
2014-04-24 04:47:45 +00:00
compile-no-deps: clean-ebin
@echo "Compiling only project code ..."
@which rebar.cmd >/dev/null 2>&1 && \
PATH=$(SCRIPT_PATH) ERL_LIBS=$(ERL_LIBS) \
rebar.cmd compile skip_deps=true || \
PATH=$(SCRIPT_PATH) ERL_LIBS=$(ERL_LIBS) rebar compile skip_deps=true
2014-04-24 04:47:45 +00:00
compile-tests: clean-eunit
@PATH=$(SCRIPT_PATH) ERL_LIBS=$(ERL_LIBS) $(LFETOOL) tests build
repl: compile
@which clear >/dev/null 2>&1 && clear || printf "\033c"
@echo "Starting an LFE REPL ..."
@PATH=$(SCRIPT_PATH) ERL_LIBS=$(ERL_LIBS) $(LFETOOL) repl lfe +pc unicode
repl-no-deps: compile-no-deps
@which clear >/dev/null 2>&1 && clear || printf "\033c"
@echo "Starting an LFE REPL ..."
@PATH=$(SCRIPT_PATH) ERL_LIBS=$(ERL_LIBS) $(LFETOOL) repl lfe +pc unicode
2014-04-24 04:47:45 +00:00
shell: compile
@which clear >/dev/null 2>&1 && clear || printf "\033c"
@echo "Starting an Erlang shell ..."
@PATH=$(SCRIPT_PATH) ERL_LIBS=$(ERL_LIBS) erl + pc unicode
2014-04-24 04:47:45 +00:00
shell-no-deps: compile-no-deps
@which clear >/dev/null 2>&1 && clear || printf "\033c"
@echo "Starting an Erlang shell ..."
@PATH=$(SCRIPT_PATH) ERL_LIBS=$(ERL_LIBS) erl + pc unicode
2014-04-24 04:47:45 +00:00
clean: clean-ebin clean-eunit
@which rebar.cmd >/dev/null 2>&1 && rebar.cmd clean || rebar clean
2014-04-24 04:47:45 +00:00
check-unit-only:
@PATH=$(SCRIPT_PATH) ERL_LIBS=$(ERL_LIBS) $(LFETOOL) tests unit
2014-04-24 04:47:45 +00:00
check-integration-only:
@PATH=$(SCRIPT_PATH) ERL_LIBS=$(ERL_LIBS) $(LFETOOL) tests integration
2014-04-24 04:47:45 +00:00
check-system-only:
@PATH=$(SCRIPT_PATH) ERL_LIBS=$(ERL_LIBS) $(LFETOOL) tests system
2014-04-24 04:47:45 +00:00
check-unit-with-deps: get-deps compile compile-tests check-unit-only
check-unit: clean-eunit compile-no-deps check-unit-only
check-integration: clean-eunit compile check-integration-only
check-system: clean-eunit compile check-system-only
check-all-with-deps: clean-eunit compile check-unit-only \
check-integration-only check-system-only clean-eunit
check-all: get-deps clean-eunit compile-no-deps
@PATH=$(SCRIPT_PATH) ERL_LIBS=$(ERL_LIBS) $(LFETOOL) tests all
2014-04-24 04:47:45 +00:00
check: check-unit-with-deps
2015-05-21 23:23:23 +00:00
check-travis: $(BIN_DIR)/lfetool check
2014-04-24 04:47:45 +00:00
push-all:
@echo "Pusing code to github ..."
git push --all
git push upstream --all
git push --tags
git push upstream --tags
install: compile
@echo "Installing lumberjack ..."
2014-04-24 04:47:45 +00:00
@PATH=$(SCRIPT_PATH) lfetool install lfe