Makefile 2.7 KB

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