Makefile 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. REBAR_VERSION = 3.14.3-emqx-4
  2. DASHBOARD_VERSION = v4.3.0-beta.1
  3. REBAR = $(CURDIR)/rebar3
  4. BUILD = $(CURDIR)/build
  5. SCRIPTS = $(CURDIR)/scripts
  6. export PKG_VSN ?= $(shell $(CURDIR)/pkg-vsn.sh)
  7. PROFILE ?= emqx
  8. REL_PROFILES := emqx emqx-edge
  9. PKG_PROFILES := emqx-pkg emqx-edge-pkg
  10. PROFILES := $(REL_PROFILES) $(PKG_PROFILES)
  11. export REBAR_GIT_CLONE_OPTIONS += --depth=1
  12. .PHONY: default
  13. default: $(REBAR) $(PROFILE)
  14. .PHONY: all
  15. all: $(REBAR) $(PROFILES)
  16. .PHONY: ensure-rebar3
  17. ensure-rebar3:
  18. @$(SCRIPTS)/fail-on-old-otp-version.escript
  19. @$(SCRIPTS)/ensure-rebar3.sh $(REBAR_VERSION)
  20. $(REBAR): ensure-rebar3
  21. .PHONY: get-dashboard
  22. get-dashboard:
  23. @$(SCRIPTS)/get-dashboard.sh $(DASHBOARD_VERSION)
  24. .PHONY: eunit
  25. eunit: $(REBAR)
  26. @$(REBAR) eunit -v -c
  27. .PHONY: proper
  28. proper: $(REBAR)
  29. @$(REBAR) as test proper -d test/props -c
  30. .PHONY: ct
  31. ct: $(REBAR)
  32. @$(REBAR) ct --name 'test@127.0.0.1' -c -v
  33. .PHONY: cover
  34. cover: $(REBAR)
  35. @$(REBAR) cover
  36. .PHONY: coveralls
  37. coveralls: $(REBAR)
  38. @$(REBAR) as test coveralls send
  39. .PHONY: $(REL_PROFILES)
  40. $(REL_PROFILES:%=%): $(REBAR) get-dashboard
  41. ifneq ($(shell echo $(@) |grep edge),)
  42. @export EMQX_DESC="EMQ X Edge"
  43. else
  44. @export EMQX_DESC="EMQ X Broker"
  45. endif
  46. @$(REBAR) as $(@) release
  47. # rebar clean
  48. .PHONY: clean $(PROFILES:%=clean-%)
  49. clean: $(PROFILES:%=clean-%)
  50. $(PROFILES:%=clean-%): $(REBAR)
  51. @$(REBAR) as $(@:clean-%=%) clean
  52. @rm -rf apps/emqx_dashboard/priv/www
  53. .PHONY: deps-all
  54. deps-all: $(REBAR) $(PROFILES:%=deps-%)
  55. .PHONY: $(PROFILES:%=deps-%)
  56. $(PROFILES:%=deps-%): $(REBAR) get-dashboard
  57. ifneq ($(shell echo $(@) |grep edge),)
  58. @export EMQX_DESC="EMQ X Edge"
  59. else
  60. @export EMQX_DESC="EMQ X Broker"
  61. endif
  62. @$(REBAR) as $(@:deps-%=%) get-deps
  63. .PHONY: xref
  64. xref: $(REBAR)
  65. @$(REBAR) as check xref
  66. .PHONY: dialyzer
  67. dialyzer: $(REBAR)
  68. @$(REBAR) as check dialyzer
  69. .PHONY: $(REL_PROFILES:%=relup-%)
  70. $(REL_PROFILES:%=relup-%): $(REBAR)
  71. ifneq ($(OS),Windows_NT)
  72. @$(BUILD) $(@:relup-%=%) relup
  73. endif
  74. .PHONY: $(REL_PROFILES:%=%-tar) $(PKG_PROFILES:%=%-tar)
  75. $(REL_PROFILES:%=%-tar) $(PKG_PROFILES:%=%-tar): $(REBAR) get-dashboard
  76. @$(BUILD) $(subst -tar,,$(@)) tar
  77. ## zip targets depend on the corresponding relup and tar artifacts
  78. .PHONY: $(REL_PROFILES:%=%-zip)
  79. define gen-zip-target
  80. $1-zip: relup-$1 $1-tar
  81. @$(BUILD) $1 zip
  82. endef
  83. ALL_ZIPS = $(REL_PROFILES) $(PKG_PROFILES)
  84. $(foreach zt,$(ALL_ZIPS),$(eval $(call gen-zip-target,$(zt))))
  85. ## A pkg target depend on a regular release profile zip to include relup,
  86. ## and also a -pkg suffixed profile tar (without relup) for making deb/rpm package
  87. .PHONY: $(PKG_PROFILES)
  88. define gen-pkg-target
  89. $1: $(subst -pkg,,$1)-zip $1-tar
  90. @$(BUILD) $1 pkg
  91. endef
  92. $(foreach pt,$(PKG_PROFILES),$(eval $(call gen-pkg-target,$(pt))))
  93. include docker.mk