From 9424d4bfb78cbe3d7b1f839d8c6d9551f3b4ab66 Mon Sep 17 00:00:00 2001 From: JimMoen Date: Wed, 10 May 2023 15:32:28 +0800 Subject: [PATCH] build: compatibility to make 4.4+ --- Makefile | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index c38ab9ea2..1461204f5 100644 --- a/Makefile +++ b/Makefile @@ -5,8 +5,6 @@ SCRIPTS = $(CURDIR)/scripts export EMQX_RELUP ?= true export EMQX_DEFAULT_BUILDER = ghcr.io/emqx/emqx-builder/4.4-20:24.3.4.2-1-alpine3.15.1 export EMQX_DEFAULT_RUNNER = alpine:3.15.1 -export OTP_VSN ?= $(shell $(CURDIR)/scripts/get-otp-vsn.sh) -export PKG_VSN ?= $(shell $(CURDIR)/pkg-vsn.sh) export DOCKERFILE := deploy/docker/Dockerfile export DOCKERFILE_TESTING := deploy/docker/Dockerfile.testing ifeq ($(OS),Windows_NT) @@ -16,6 +14,17 @@ else FIND=find endif +# `:=` should be used here, otherwise the `$(shell ...)` will be executed every time when the variable is used +# In make 4.4+, for backward-compatibility the value from the original environment is used. +# so the shell script will be executed tons of times. +ifeq ($(strip $(OTP_VSN)),) + export OTP_VSN := $(shell $(SCRIPTS)/get-otp-vsn.sh) +endif +ifeq ($(strip $(PKG_VSN)),) + export PKG_VSN := $(shell $(CURDIR)/pkg-vsn.sh) +endif + + PROFILE ?= emqx REL_PROFILES := emqx emqx-edge PKG_PROFILES := emqx-pkg emqx-edge-pkg