build: prevent excessive re-evaluation of PKG_VERSION
authorFelix Fietkau <nbd@nbd.name>
Tue, 6 Oct 2020 11:39:58 +0000 (13:39 +0200)
committerFelix Fietkau <nbd@nbd.name>
Fri, 16 Oct 2020 19:39:10 +0000 (21:39 +0200)
version_abbrev uses $(shell) and the ?= is causing make to run the command
over and over again, causing a significant build slowdown

Signed-off-by: Felix Fietkau <nbd@nbd.name>
include/download.mk

index 9c8ada052b04a049b1fe4eec1061534b10771906..d393bf390716646bb0140d513c550abff3673616 100644 (file)
@@ -12,9 +12,11 @@ OPENWRT_GIT = $(PROJECT_GIT)
 LEDE_GIT = $(PROJECT_GIT)
 
 ifdef PKG_SOURCE_VERSION
-PKG_VERSION ?= $(if $(PKG_SOURCE_DATE),$(PKG_SOURCE_DATE)-)$(call version_abbrev,$(PKG_SOURCE_VERSION))
-PKG_SOURCE_SUBDIR ?= $(PKG_NAME)-$(PKG_VERSION)
-PKG_SOURCE ?= $(PKG_SOURCE_SUBDIR).tar.xz
+  ifndef PKG_VERSION
+    PKG_VERSION := $(if $(PKG_SOURCE_DATE),$(PKG_SOURCE_DATE)-)$(call version_abbrev,$(PKG_SOURCE_VERSION))
+  endif
+  PKG_SOURCE_SUBDIR ?= $(PKG_NAME)-$(PKG_VERSION)
+  PKG_SOURCE ?= $(PKG_SOURCE_SUBDIR).tar.xz
 endif
 
 DOWNLOAD_RDEP=$(STAMP_PREPARED) $(HOST_STAMP_PREPARED)