Makefile 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. $(shell scripts/git-hooks-init.sh)
  2. REBAR_VERSION = 3.14.3-emqx-4
  3. REBAR = $(CURDIR)/rebar3
  4. BUILD = $(CURDIR)/build
  5. SCRIPTS = $(CURDIR)/scripts
  6. export PKG_VSN ?= $(shell $(CURDIR)/pkg-vsn.sh)
  7. export EMQX_DESC ?= EMQ X
  8. export EMQX_CE_DASHBOARD_VERSION ?= v4.3.0-beta.1
  9. PROFILE ?= emqx
  10. REL_PROFILES := emqx emqx-edge
  11. PKG_PROFILES := emqx-pkg emqx-edge-pkg
  12. PROFILES := $(REL_PROFILES) $(PKG_PROFILES) default
  13. export REBAR_GIT_CLONE_OPTIONS += --depth=1
  14. .PHONY: default
  15. default: $(REBAR) $(PROFILE)
  16. .PHONY: all
  17. all: $(REBAR) $(PROFILES)
  18. .PHONY: ensure-rebar3
  19. ensure-rebar3:
  20. @$(SCRIPTS)/fail-on-old-otp-version.escript
  21. @$(SCRIPTS)/ensure-rebar3.sh $(REBAR_VERSION)
  22. $(REBAR): ensure-rebar3
  23. .PHONY: get-dashboard
  24. get-dashboard:
  25. @$(SCRIPTS)/get-dashboard.sh
  26. .PHONY: eunit
  27. eunit: $(REBAR)
  28. @$(REBAR) eunit -v -c
  29. .PHONY: proper
  30. proper: $(REBAR)
  31. @$(REBAR) as test proper -d test/props -c
  32. .PHONY: ct
  33. ct: $(REBAR)
  34. @$(REBAR) ct --name 'test@127.0.0.1' -c -v
  35. .PHONY: cover
  36. cover: $(REBAR)
  37. @$(REBAR) cover
  38. .PHONY: coveralls
  39. coveralls: $(REBAR)
  40. @$(REBAR) as test coveralls send
  41. .PHONY: $(REL_PROFILES)
  42. $(REL_PROFILES:%=%): $(REBAR) get-dashboard
  43. ifneq ($(shell echo $(@) |grep edge),)
  44. @export EMQX_DESC="$${EMQX_DESC} Edge"
  45. else
  46. @export EMQX_DESC="$${EMQX_DESC} Broker"
  47. endif
  48. @$(REBAR) as $(@) release
  49. ## Not calling rebar3 clean because
  50. ## 1. rebar3 clean relies on rebar3, meaning it reads config, fetches dependencies etc.
  51. ## 2. it's slow
  52. ## NOTE: this does not force rebar3 to fetch new version dependencies
  53. ## make clean-all to delete all fetched dependencies for a fresh start-over
  54. .PHONY: clean $(PROFILES:%=clean-%)
  55. clean: $(PROFILES:%=clean-%)
  56. $(PROFILES:%=clean-%):
  57. @if [ -d _build/$(@:clean-%=%) ]; then \
  58. rm -rf _build/$(@:clean-%=%)/rel; \
  59. find _build/$(@:clean-%=%) -name '*.beam' -o -name '*.so' -o -name '*.app' -o -name '*.appup' -type f | xargs rm -f; \
  60. fi
  61. .PHONY: clean-all
  62. clean-all:
  63. @rm -rf _build
  64. .PHONY: deps-all
  65. deps-all: $(REBAR) $(PROFILES:%=deps-%)
  66. .PHONY: $(PROFILES:%=deps-%)
  67. $(PROFILES:%=deps-%): $(REBAR) get-dashboard
  68. ifneq ($(shell echo $(@) |grep edge),)
  69. @export EMQX_DESC="$${EMQX_DESC} Edge"
  70. else
  71. @export EMQX_DESC="$${EMQX_DESC} Broker"
  72. endif
  73. @$(REBAR) as $(@:deps-%=%) get-deps
  74. .PHONY: xref
  75. xref: $(REBAR)
  76. @$(REBAR) as check xref
  77. .PHONY: dialyzer
  78. dialyzer: $(REBAR)
  79. @$(REBAR) as check dialyzer
  80. .PHONY: $(REL_PROFILES:%=relup-%)
  81. $(REL_PROFILES:%=relup-%): $(REBAR)
  82. ifneq ($(OS),Windows_NT)
  83. @$(BUILD) $(@:relup-%=%) relup
  84. endif
  85. .PHONY: $(REL_PROFILES:%=%-tar) $(PKG_PROFILES:%=%-tar)
  86. $(REL_PROFILES:%=%-tar) $(PKG_PROFILES:%=%-tar): $(REBAR) get-dashboard
  87. @$(BUILD) $(subst -tar,,$(@)) tar
  88. ## zip targets depend on the corresponding relup and tar artifacts
  89. .PHONY: $(REL_PROFILES:%=%-zip)
  90. define gen-zip-target
  91. $1-zip: relup-$1 $1-tar
  92. @$(BUILD) $1 zip
  93. endef
  94. ALL_ZIPS = $(REL_PROFILES) $(PKG_PROFILES)
  95. $(foreach zt,$(ALL_ZIPS),$(eval $(call gen-zip-target,$(zt))))
  96. ## A pkg target depend on a regular release profile zip to include relup,
  97. ## and also a -pkg suffixed profile tar (without relup) for making deb/rpm package
  98. .PHONY: $(PKG_PROFILES)
  99. define gen-pkg-target
  100. $1: $(subst -pkg,,$1)-zip $1-tar
  101. @$(BUILD) $1 pkg
  102. endef
  103. $(foreach pt,$(PKG_PROFILES),$(eval $(call gen-pkg-target,$(pt))))
  104. include docker.mk