Makefile 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  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)
  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. # rebar clean
  50. .PHONY: clean $(PROFILES:%=clean-%)
  51. clean: $(PROFILES:%=clean-%)
  52. $(PROFILES:%=clean-%): $(REBAR)
  53. @$(REBAR) as $(@:clean-%=%) clean
  54. @rm -rf apps/emqx_dashboard/priv/www
  55. .PHONY: deps-all
  56. deps-all: $(REBAR) $(PROFILES:%=deps-%)
  57. .PHONY: $(PROFILES:%=deps-%)
  58. $(PROFILES:%=deps-%): $(REBAR) get-dashboard
  59. ifneq ($(shell echo $(@) |grep edge),)
  60. @export EMQX_DESC="$${EMQX_DESC} Edge"
  61. else
  62. @export EMQX_DESC="$${EMQX_DESC} Broker"
  63. endif
  64. @$(REBAR) as $(@:deps-%=%) get-deps
  65. .PHONY: xref
  66. xref: $(REBAR)
  67. @$(REBAR) as check xref
  68. .PHONY: dialyzer
  69. dialyzer: $(REBAR)
  70. @$(REBAR) as check dialyzer
  71. .PHONY: $(REL_PROFILES:%=relup-%)
  72. $(REL_PROFILES:%=relup-%): $(REBAR)
  73. ifneq ($(OS),Windows_NT)
  74. @$(BUILD) $(@:relup-%=%) relup
  75. endif
  76. .PHONY: $(REL_PROFILES:%=%-tar) $(PKG_PROFILES:%=%-tar)
  77. $(REL_PROFILES:%=%-tar) $(PKG_PROFILES:%=%-tar): $(REBAR) get-dashboard
  78. @$(BUILD) $(subst -tar,,$(@)) tar
  79. ## zip targets depend on the corresponding relup and tar artifacts
  80. .PHONY: $(REL_PROFILES:%=%-zip)
  81. define gen-zip-target
  82. $1-zip: relup-$1 $1-tar
  83. @$(BUILD) $1 zip
  84. endef
  85. ALL_ZIPS = $(REL_PROFILES) $(PKG_PROFILES)
  86. $(foreach zt,$(ALL_ZIPS),$(eval $(call gen-zip-target,$(zt))))
  87. ## A pkg target depend on a regular release profile zip to include relup,
  88. ## and also a -pkg suffixed profile tar (without relup) for making deb/rpm package
  89. .PHONY: $(PKG_PROFILES)
  90. define gen-pkg-target
  91. $1: $(subst -pkg,,$1)-zip $1-tar
  92. @$(BUILD) $1 pkg
  93. endef
  94. $(foreach pt,$(PKG_PROFILES),$(eval $(call gen-pkg-target,$(pt))))
  95. include docker.mk