Makefile 2.4 KB

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