Skip to content
Browse files

Use tools.mk Makefile

  • Loading branch information...
1 parent 14fb07e commit 7286f668d5c9e2b3370af061002d2819fd5b8c7b @reiddraper reiddraper committed Jan 22, 2014
Showing with 49 additions and 20 deletions.
  1. +4 −20 Makefile
  2. +45 −0 tools.mk
View
24 Makefile
@@ -2,7 +2,7 @@
all: deps compile
-compile:
+compile: deps
./rebar compile
deps:
@@ -11,27 +11,11 @@ deps:
clean:
./rebar clean
-distclean: clean
+distclean: clean
./rebar delete-deps
-test: all
- ./rebar skip_deps=true eunit
-APPS = kernel stdlib sasl erts eunit ssl tools crypto \
+DIALYZER_APPS = kernel stdlib sasl erts eunit ssl tools crypto \
inets public_key syntax_tools compiler
-COMBO_PLT = $(HOME)/.riak_combo_dialyzer_plt
-
-check_plt: all
- dialyzer --check_plt --plt $(COMBO_PLT) --apps $(APPS) \
- deps/*/ebin
-
-build_plt: all
- dialyzer --build_plt --output_plt $(COMBO_PLT) --apps $(APPS) \
- deps/*/ebin
-
-dialyzer: compile
- @dialyzer --plt $(COMBO_PLT) -Wno_return -c ebin
-
-doc : all
- @./rebar doc skip_deps=true
+include tools.mk
View
45 tools.mk
@@ -0,0 +1,45 @@
+test: compile
+ ./rebar eunit skip_deps=true
+
+docs:
+ ./rebar doc skip_deps=true
+
+PLT ?= $(HOME)/.riak_combo_dialyzer_plt
+LOCAL_PLT = .local_dialyzer_plt
+DIALYZER_FLAGS ?= -Wunmatched_returns
+
+${PLT}: compile
+ifneq (,$(wildcard $(PLT)))
+ dialyzer --check_plt --plt $(PLT) --apps $(DIALYZER_APPS) && \
+ dialyzer --add_to_plt --plt $(PLT) --output_plt $(PLT) --apps $(DIALYZER_APPS) ; test $$? -ne 1
+else
+ dialyzer --build_plt --output_plt $(PLT) --apps $(DIALYZER_APPS); test $$? -ne 1
+endif
+
+${LOCAL_PLT}: compile
+ifneq (,$(wildcard deps/*))
+ifneq (,$(wildcard $(LOCAL_PLT)))
+ dialyzer --check_plt --plt $(LOCAL_PLT) deps/*/ebin && \
+ dialyzer --add_to_plt --plt $(LOCAL_PLT) --output_plt $(LOCAL_PLT) deps/*/ebin ; test $$? -ne 1
+else
+ dialyzer --build_plt --output_plt $(LOCAL_PLT) deps/*/ebin ; test $$? -ne 1
+endif
+endif
+
+dialyzer: ${PLT} ${LOCAL_PLT}
+ @echo "==> $(shell basename $(shell pwd)) (dialyzer)"
+ @if [ -f $(LOCAL_PLT) ]; then \
+ dialyzer $(DIALYZER_FLAGS) --plts $(PLT) $(LOCAL_PLT) -c ebin; \
+ else \
+ dialyzer $(DIALYZER_FLAGS) --plts $(PLT) -c ebin; \
+ fi
+
+cleanplt:
+ @echo
+ @echo "Are you sure? It takes several minutes to re-build."
+ @echo Deleting $(PLT) and $(LOCAL_PLT) in 5 seconds.
+ @echo
+ sleep 5
+ rm $(PLT)
+ rm $(LOCAL_PLT)
+

0 comments on commit 7286f66

Please sign in to comment.
Something went wrong with that request. Please try again.