aboutsummaryrefslogtreecommitdiff
path: root/Makefile
diff options
context:
space:
mode:
authorGravatar James Byrne <james.byrne@origamienergy.com>2018-04-09 17:08:01 +0100
committerGravatar Thomas Petazzoni <thomas.petazzoni@bootlin.com>2018-04-09 20:59:49 +0200
commit9b47146eb2c33bd83d494a76b1186c3948e0d3ff (patch)
treea8a467c8378b32beeb552cdd4db683170a1d2daa /Makefile
parentf4a4df2084b923f29eca2130976ca10a7aa6b719 (diff)
downloadbuildroot-9b47146eb2c33bd83d494a76b1186c3948e0d3ff.tar.gz
buildroot-9b47146eb2c33bd83d494a76b1186c3948e0d3ff.tar.bz2
Makefile: avoid executing 'git log' each time SOURCE_DATE_EPOCH is used
If SOURCE_DATE_EPOCH is not defined it was given a definition that caused 'git log' to be executed each time the variable is referenced, which is not very efficient given that the answer cannot change. This commit moves the definition of BR2_VERSION_GIT_EPOCH after the inclusion of Makefile.in (so that GIT is defined) and makes it a simply expanded variable so that it is only evaluated once. Signed-off-by: James Byrne <james.byrne@origamienergy.com> Acked-by: "Yann E. MORIN" <yann.morin.1998@free.fr> Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile10
1 files changed, 8 insertions, 2 deletions
diff --git a/Makefile b/Makefile
index 0724f28f45..cd533624ec 100644
--- a/Makefile
+++ b/Makefile
@@ -247,8 +247,6 @@ export TZ = UTC
export LANG = C
export LC_ALL = C
export GZIP = -n
-BR2_VERSION_GIT_EPOCH = $(shell GIT_DIR=$(TOPDIR)/.git $(GIT) log -1 --format=%at)
-export SOURCE_DATE_EPOCH ?= $(if $(wildcard $(TOPDIR)/.git),$(BR2_VERSION_GIT_EPOCH),$(BR2_VERSION_EPOCH))
endif
# To put more focus on warnings, be less verbose as default
@@ -504,6 +502,14 @@ include support/dependencies/dependencies.mk
include $(sort $(wildcard toolchain/*.mk))
include $(sort $(wildcard toolchain/*/*.mk))
+ifeq ($(BR2_REPRODUCIBLE),y)
+# If SOURCE_DATE_EPOCH has not been set then use the commit date, or the last
+# release date if the source tree is not within a Git repository.
+# See: https://reproducible-builds.org/specs/source-date-epoch/
+BR2_VERSION_GIT_EPOCH := $(shell $(GIT) --git-dir=$(TOPDIR)/.git log -1 --format=%at 2> /dev/null)
+export SOURCE_DATE_EPOCH ?= $(or $(BR2_VERSION_GIT_EPOCH),$(BR2_VERSION_EPOCH))
+endif
+
# Include the package override file if one has been provided in the
# configuration.
PACKAGE_OVERRIDE_FILE = $(call qstrip,$(BR2_PACKAGE_OVERRIDE_FILE))