summaryrefslogtreecommitdiff
path: root/configure.ac
diff options
context:
space:
mode:
authorBernhard M. Wiedemann <bwiedemann@suse.de>2017-07-21 13:18:40 (GMT)
committerBernhard M. Wiedemann <bwiedemann@suse.de>2017-07-21 13:21:08 (GMT)
commit349be05ee5cbfd680955d19a9ec2df72966399b4 (patch)
treee6043b0fbf2e095647ea42e66d42e1c568f9fa4a /configure.ac
parentfae66ae34fb6fcade87abb3aa48bcdbf5fead662 (diff)
Allow to override build date
in order to make builds reproducible. See https://reproducible-builds.org/ for why this is good and https://reproducible-builds.org/specs/source-date-epoch/ for the definition of this variable. This date call is designed to work with both GNU date and BSD date.
Diffstat (limited to 'configure.ac')
-rw-r--r--configure.ac10
1 files changed, 7 insertions, 3 deletions
diff --git a/configure.ac b/configure.ac
index 4f7d3d3..010c2e0 100644
--- a/configure.ac
+++ b/configure.ac
@@ -424,9 +424,13 @@ AC_SEARCH_LIBS(
# Lastly, take care of crosstool-NG internal values
#--------------------------------------------------------------------
# Hey! We need the date! :-)
-AC_SUBST(
- [DATE],
- [$(date +%Y%m%d)])
+DATE_FMT="%Y%m%d"
+if test "x$SOURCE_DATE_EPOCH" = "x"; then
+ DATE=$(date "+$DATE_FMT")
+else
+ DATE="$(date -u -d "@$SOURCE_DATE_EPOCH" "+$DATE_FMT" 2>/dev/null || date -u -r "$SOURCE_DATE_EPOCH" "+$DATE_FMT" 2>/dev/null || date -u "+$DATE_FMT")"
+fi
+AC_SUBST([DATE])
# Decorate the version string if needed
AS_IF(