relx.mk 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. # Copyright (c) 2013-2016, Loïc Hoguin <essen@ninenines.eu>
  2. # This file is part of erlang.mk and subject to the terms of the ISC License.
  3. .PHONY: relx-rel relx-relup distclean-relx-rel run
  4. # Configuration.
  5. RELX ?= $(ERLANG_MK_TMP)/relx
  6. RELX_CONFIG ?= $(CURDIR)/relx.config
  7. RELX_URL ?= https://github.com/erlware/relx/releases/download/v3.19.0/relx
  8. RELX_OPTS ?=
  9. RELX_OUTPUT_DIR ?= _rel
  10. ifeq ($(firstword $(RELX_OPTS)),-o)
  11. RELX_OUTPUT_DIR = $(word 2,$(RELX_OPTS))
  12. else
  13. RELX_OPTS += -o $(RELX_OUTPUT_DIR)
  14. endif
  15. # Core targets.
  16. ifeq ($(IS_DEP),)
  17. ifneq ($(wildcard $(RELX_CONFIG)),)
  18. rel:: relx-rel
  19. relup:: relx-relup
  20. endif
  21. endif
  22. distclean:: distclean-relx-rel
  23. # Plugin-specific targets.
  24. $(RELX):
  25. $(gen_verbose) $(call core_http_get,$(RELX),$(RELX_URL))
  26. $(verbose) chmod +x $(RELX)
  27. relx-rel: $(RELX) rel-deps app
  28. $(verbose) $(RELX) -c $(RELX_CONFIG) $(RELX_OPTS) release tar
  29. relx-relup: $(RELX) rel-deps app
  30. $(verbose) $(RELX) -c $(RELX_CONFIG) $(RELX_OPTS) release relup tar
  31. distclean-relx-rel:
  32. $(gen_verbose) rm -rf $(RELX_OUTPUT_DIR)
  33. # Run target.
  34. ifeq ($(wildcard $(RELX_CONFIG)),)
  35. run:
  36. else
  37. define get_relx_release.erl
  38. {ok, Config} = file:consult("$(RELX_CONFIG)"),
  39. {release, {Name, Vsn}, _} = lists:keyfind(release, 1, Config),
  40. io:format("~s ~s", [Name, Vsn]),
  41. halt(0).
  42. endef
  43. RELX_REL := $(shell $(call erlang,$(get_relx_release.erl)))
  44. RELX_REL_NAME := $(word 1,$(RELX_REL))
  45. RELX_REL_VSN := $(word 2,$(RELX_REL))
  46. run: all
  47. $(verbose) $(RELX_OUTPUT_DIR)/$(RELX_REL_NAME)/bin/$(RELX_REL_NAME) console
  48. help::
  49. $(verbose) printf "%s\n" "" \
  50. "Relx targets:" \
  51. " run Compile the project, build the release and run it"
  52. endif