relx.mk 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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 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. endif
  20. endif
  21. distclean:: distclean-relx-rel
  22. # Plugin-specific targets.
  23. $(RELX):
  24. $(gen_verbose) $(call core_http_get,$(RELX),$(RELX_URL))
  25. $(verbose) chmod +x $(RELX)
  26. relx-rel: $(RELX) rel-deps app
  27. $(verbose) $(RELX) -c $(RELX_CONFIG) $(RELX_OPTS)
  28. distclean-relx-rel:
  29. $(gen_verbose) rm -rf $(RELX_OUTPUT_DIR)
  30. # Run target.
  31. ifeq ($(wildcard $(RELX_CONFIG)),)
  32. run:
  33. else
  34. define get_relx_release.erl
  35. {ok, Config} = file:consult("$(RELX_CONFIG)"),
  36. {release, {Name, _}, _} = lists:keyfind(release, 1, Config),
  37. io:format("~s", [Name]),
  38. halt(0).
  39. endef
  40. RELX_RELEASE = `$(call erlang,$(get_relx_release.erl))`
  41. run: all
  42. $(verbose) $(RELX_OUTPUT_DIR)/$(RELX_RELEASE)/bin/$(RELX_RELEASE) console
  43. help::
  44. $(verbose) printf "%s\n" "" \
  45. "Relx targets:" \
  46. " run Compile the project, build the release and run it"
  47. endif