Makefile 3.3 KB

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