otp.mk 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. empty :=
  2. ROOTS := apps deps
  3. space := $(empty) $(empty)
  4. comma := $(empty),$(empty)
  5. VSN := $(shell git rev-parse HEAD | cut -c 1-6)
  6. DATE := $(shell git show -s --format="%ci" HEAD | sed -e 's/\+/Z/g' -e 's/-/./g' -e 's/ /-/g' -e 's/:/./g')
  7. ERL_LIBS := $(subst $(space),:,$(ROOTS))
  8. relx := "{release,{$(RELEASE),\"$(VER)\"},[$(subst $(space),$(comma),$(APPS))]}.\\n{include_erts,true}.\
  9. \\n{extended_start_script,true}.\\n{generate_start_script,true}.\\n{sys_config,\"$(SYS)\"}.\
  10. \\n{vm_args,\"$(VM)\"}.\\n{overlay,[{mkdir,\"log/sasl\"}]}."
  11. ifeq "$(NODEPS)" "1"
  12. rebar_skip_deps=skip_deps=true
  13. endif
  14. test: ct
  15. compile: get-deps static-link
  16. delete-deps get-deps compile clean update-deps:
  17. rebar $(rebar_skip_deps) $(REBAR_D) $@
  18. .applist:
  19. ./depman.erl $(APPS) > $@
  20. $(RUN_DIR) $(LOG_DIR):
  21. mkdir -p $(RUN_DIR) & mkdir -p $(LOG_DIR)
  22. console: .applist
  23. ERL_LIBS=$(ERL_LIBS) erl $(ERL_ARGS) -eval \
  24. '[ok = application:ensure_started(A, permanent) || A <- $(shell cat .applist)]'
  25. start: $(RUN_DIR) $(LOG_DIR) .applist
  26. RUN_ERL_LOG_GENERATIONS=1000 RUN_ERL_LOG_MAXSIZE=20000000 \
  27. ERL_LIBS=$(ERL_LIBS) run_erl -daemon $(RUN_DIR)/ $(LOG_DIR)/ "exec $(MAKE) console"
  28. attach:
  29. to_erl $(RUN_DIR)/
  30. release:
  31. echo $(shell echo $(relx) > relx.config) & relx
  32. stop:
  33. kill -9 `ps ax -o pid= -o command=|grep $(RELEASE)|grep $(COOKIE)|awk '{print $1}'`
  34. $(PLT_NAME):
  35. ERL_LIBS=deps dialyzer --build_plt --output_plt $(PLT_NAME) --apps $(APPS) || true
  36. dialyze: $(PLT_NAME) compile
  37. dialyzer deps/*/ebin --plt $(PLT_NAME) --no_native -Werror_handling -Wunderspecs -Wrace_conditions
  38. tar:
  39. tar zcvf $(RELEASE)-$(VSN)-$(DATE).tar.gz _rel/lib/*/ebin _rel/lib/*/priv _rel/bin _rel/releases
  40. eunit:
  41. rebar eunit skip_deps=true
  42. ct:
  43. rebar ct skip_deps=true verbose=1
  44. .PHONY: delete-deps get-deps compile clean console start attach release update-deps dialyze ct eunit tar