fifo.mk 3.63 KB
Newer Older
Heinz N. Gies's avatar
Heinz N. Gies committed
1
REBAR = $(shell pwd)/rebar3
Heinz N. Gies's avatar
Heinz N. Gies committed
2
REBAR_VSN = $(shell erl -noshell -eval '{ok, F} = file:consult("rebar.config"), [{release, {_, Vsn}, _}] = [O || {relx, [O | _]} <- F], io:format("~s", [Vsn]), init:stop().')
Heinz N. Gies's avatar
Heinz N. Gies committed
3 4
VARS_VSN = $(shell grep 'bugsnag_app_version' rel/vars.config | sed -e 's/.*,//' -e 's/[^0-9.p]//g' -e 's/[.]$$//')
APP_VSN = $(shell grep vsn apps/$(APP)/src/$(APP).app.src | sed 's/[^0-9.p]//g')
Heinz N. Gies's avatar
Heinz N. Gies committed
5

Heinz N. Gies's avatar
Heinz N. Gies committed
6 7
include config.mk

Heinz N. Gies's avatar
Heinz N. Gies committed
8 9 10 11
compile: $(REBAR) .git/hooks/pre-commit
	$(REBAR) compile

.git/hooks/pre-commit: hooks/pre-commit
Heinz N. Gies's avatar
Heinz N. Gies committed
12
	[ -f  .git/hooks ] && cp hooks/pre-commit .git/hooks || true
Heinz N. Gies's avatar
Heinz N. Gies committed
13

Heinz N. Gies's avatar
Heinz N. Gies committed
14
pre-commit: test-scripts test-vsn lint xref dialyzer test
Heinz N. Gies's avatar
Heinz N. Gies committed
15 16 17 18 19 20 21

dialyzer: $(REBAR)
	$(REBAR) dialyzer

xref: $(REBAR)
	$(REBAR) xref

Heinz N. Gies's avatar
Heinz N. Gies committed
22 23 24
test-scripts:
	for i in rel/files/*; do (head -1 $$i | grep -v sh > /dev/null) || bash -n $$i || exit 1; done;

Heinz N. Gies's avatar
Heinz N. Gies committed
25 26 27 28 29 30 31 32 33 34
test: $(REBAR)
	$(REBAR) eunit

lint: $(REBAR)
	$(REBAR) as lint lint

$(REBAR):
	cp `which rebar3` $(REBAR)

upgrade: $(REBAR)
Heinz N. Gies's avatar
Heinz N. Gies committed
35 36
	$(REBAR) upgrade
	$(MAKE) tree
Heinz N. Gies's avatar
Heinz N. Gies committed
37 38 39 40

update: $(REBAR)
	$(REBAR) update

Heinz N. Gies's avatar
Heinz N. Gies committed
41 42 43 44
rebar.lock: rebar.config $(REBAR)
	$(REBAR) compile

tree: $(REBAR) rebar.lock
Heinz N. Gies's avatar
Heinz N. Gies committed
45 46 47 48 49
	$(REBAR) tree | grep -v '=' | sed 's/ (.*//' > tree

tree-diff: tree
	git diff test -- tree

Heinz N. Gies's avatar
Heinz N. Gies committed
50
update-fifo.mk:
Heinz N. Gies's avatar
Heinz N. Gies committed
51
	cp _build/default/lib/fifo_utils/priv/fifo.mk .
Heinz N. Gies's avatar
Heinz N. Gies committed
52

Heinz N. Gies's avatar
Heinz N. Gies committed
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110
###
### Packaging
###

uname_S := $(shell sh -c 'uname -s 2>/dev/null || echo not')
uname_V6 := $(shell sh -c 'uname -v 2>/dev/null | cut -c-6 || echo not')

ifeq ($(uname_S),Darwin)
	PLATFORM = darwin
	REBARPROFILE = darwin
	export REBARPROFILE
endif
ifeq ($(uname_S),FreeBSD)
	PLATFORM = freebsd
	REBARPROFILE = freebsd
	export REBARPROFILE
endif
ifeq ($(uname_V6),joyent)
	PLATFORM = smartos
	REBARPROFILE = smartos
	export REBARPROFILE
endif

dist: ${PLATFORM} ;

generic/rel: version_header
	$(REBAR) as ${REBARPROFILE} compile
	$(REBAR) as ${REBARPROFILE} release

freebsd: ${PLATFORM}/rel
	$(MAKE) -C rel/pkgng package

smartos:  ${PLATFORM}/rel
	$(MAKE) -C rel/pkg package

darwin:  ${PLATFORM}/rel

freebsd/rel: generic/rel

smartos/rel: generic/rel

darwin/rel: generic/rel

dist-help:
	@echo "FiFo dist tool"
	@echo "You are running this on: ${PLATFORM}"
	@echo
	@echo "Currently supported platforms are: FreeBSD, SmartOS, Darwin/OSX"
	@echo
	@echo "SmartOS:"
	@echo " rebar profile: smartos $(shell if grep profiles -A12 rebar.config | grep smartos > /dev/null; then echo OK; else echo MISSING; fi)"
	@echo " packaging makefile: rel/pkg/Makefile $(shell if [ -f rel/pkg/Makefile ]; then echo OK; else echo MISSING; fi)"
	@echo "FreeBSD:"
	@echo " rebar profile: freebsd $(shell if grep profiles -A12 rebar.config | grep freebsd > /dev/null; then echo OK; else echo MISSING; fi)"
	@echo " packaging makefile: rel/pkgng/Makefile $(shell if [ -f rel/pkgng/Makefile ]; then echo OK; else echo MISSING; fi)"
	@echo "Darwin:"
	@echo " rebar profile: darwin $(shell if grep profiles -A12 rebar.config | grep darwin > /dev/null; then echo OK; else echo MISSING; fi)"
	@echo " packaging makefile: - no packaing -"
Heinz N. Gies's avatar
Heinz N. Gies committed
111

Heinz N. Gies's avatar
Heinz N. Gies committed
112 113 114 115 116 117
###
### Docs
###
docs:
	$(REBAR) edoc

Heinz N. Gies's avatar
Heinz N. Gies committed
118 119 120 121
###
### Version
###

Heinz N. Gies's avatar
Heinz N. Gies committed
122 123 124
build-vsn:
	@echo "$(REBAR_VSN)"
vsn:
Heinz N. Gies's avatar
Heinz N. Gies committed
125 126
	@echo "## Config:"
	@echo "$(VERSION)"
Heinz N. Gies's avatar
Heinz N. Gies committed
127 128 129 130 131 132 133 134
	@echo "## apps/$(APP)/src/$(APP).app.src"
	@echo "$(APP_VSN)"
	@echo "## rebar.config"
	@echo "$(REBAR_VSN)"
	@echo "## rel/vars.config"
	@echo "$(VARS_VSN)"

test-vsn:
Heinz N. Gies's avatar
Heinz N. Gies committed
135
	@echo "Testing against package version: $(VERSION)"
Heinz N. Gies's avatar
Heinz N. Gies committed
136 137 138
	@[ "$(VERSION)" = "$(APP_VSN)" ]   && echo " - App version ok:   $(APP_VSN)"   || (echo "App version out of date" && false)
	@[ "$(VERSION)" = "$(REBAR_VSN)" ] && echo " - Rebar version ok: $(REBAR_VSN)" || (echo "Package version out of date" && false)
	@[ "$(VERSION)" = "$(VARS_VSN)" ]  && echo " - Vars version ok:  $(VARS_VSN)"  || (echo "Vars version out of date" && false)