relx.mk 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. # Copyright (c) 2013-2015, 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 distclean-relx run
  4. # Configuration.
  5. RELX ?= $(CURDIR)/relx
  6. RELX_CONFIG ?= $(CURDIR)/relx.config
  7. RELX_URL ?= https://github.com/erlware/relx/releases/download/v3.5.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 distclean-relx
  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. distclean-relx:
  31. $(gen_verbose) rm -rf $(RELX)
  32. # Run target.
  33. ifeq ($(wildcard $(RELX_CONFIG)),)
  34. run:
  35. else
  36. define get_relx_release.erl
  37. {ok, Config} = file:consult("$(RELX_CONFIG)"),
  38. {release, {Name, _}, _} = lists:keyfind(release, 1, Config),
  39. io:format("~s", [Name]),
  40. halt(0).
  41. endef
  42. RELX_RELEASE = `$(call erlang,$(get_relx_release.erl))`
  43. run: all
  44. $(verbose) $(RELX_OUTPUT_DIR)/$(RELX_RELEASE)/bin/$(RELX_RELEASE) console
  45. help::
  46. $(verbose) printf "%s\n" "" \
  47. "Relx targets:" \
  48. " run Compile the project, build the release and run it"
  49. endif