relx.mk 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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_CONFIG ?= $(CURDIR)/relx.config
  6. RELX ?= $(CURDIR)/relx
  7. export RELX
  8. RELX_URL ?= https://github.com/erlware/relx/releases/download/v2.0.0/relx
  9. RELX_OPTS ?=
  10. RELX_OUTPUT_DIR ?= _rel
  11. ifeq ($(firstword $(RELX_OPTS)),-o)
  12. RELX_OUTPUT_DIR = $(word 2,$(RELX_OPTS))
  13. else
  14. RELX_OPTS += -o $(RELX_OUTPUT_DIR)
  15. endif
  16. # Core targets.
  17. ifeq ($(IS_DEP),)
  18. ifneq ($(wildcard $(RELX_CONFIG)),)
  19. rel:: distclean-relx-rel relx-rel
  20. endif
  21. endif
  22. distclean:: distclean-relx-rel distclean-relx
  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)
  28. $(verbose) $(RELX) -c $(RELX_CONFIG) $(RELX_OPTS)
  29. distclean-relx-rel:
  30. $(gen_verbose) rm -rf $(RELX_OUTPUT_DIR)
  31. distclean-relx:
  32. $(gen_verbose) rm -rf $(RELX)
  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, _}, _} = lists:keyfind(release, 1, Config),
  40. io:format("~s", [Name]),
  41. halt(0).
  42. endef
  43. RELX_RELEASE = `$(call erlang,$(get_relx_release.erl))`
  44. run: all
  45. $(verbose) $(RELX_OUTPUT_DIR)/$(RELX_RELEASE)/bin/$(RELX_RELEASE) console
  46. help::
  47. $(verbose) printf "%s\n" "" \
  48. "Relx targets:" \
  49. " run Compile the project, build the release and run it"
  50. endif