diff src/configure.ac @ 20713:5ddd4df27068 v8.2.0910

patch 8.2.0910: Vim is not reproducibly buildable Commit: https://github.com/vim/vim/commit/8f1dde5021d9623a951d1ccbc78cf1b1a55ccd7a Author: Bram Moolenaar <Bram@vim.org> Date: Fri Jun 5 23:16:29 2020 +0200 patch 8.2.0910: Vim is not reproducibly buildable Problem: Vim is not reproducibly buildable. Solution: Use the $SOURCE_DATE_EPOCH environment variable in configure. (James McCoy, closes #513) Give a warning about using it.
author Bram Moolenaar <Bram@vim.org>
date Fri, 05 Jun 2020 23:30:04 +0200
parents 4411c2b96af9
children 69055d27e85e
line wrap: on
line diff
--- a/src/configure.ac
+++ b/src/configure.ac
@@ -62,6 +62,18 @@ if test x"$ac_cv_prog_cc_c99" != xno; th
   fi
 fi
 
+dnl If $SOURCE_DATE_EPOCH is present in the environment, use that as the
+dnl "compiled" timestamp in :version's output.  Attempt to get the formatted
+dnl date using GNU date syntax, BSD date syntax, and finally falling back to
+dnl just using the current time.
+if test -n "$SOURCE_DATE_EPOCH"; then
+  DATE_FMT="%b %d %Y %H:%M:%S"
+  BUILD_DATE=$(LC_ALL=C date -u -d "@$SOURCE_DATE_EPOCH" "+$DATE_FMT" 2>/dev/null || LC_ALL=C date -u -r "$SOURCE_DATE_EPOCH" "+$DATE_FMT" 2>/dev/null || LC_ALL=C date -u "+$DATE_FMT")
+  AC_DEFINE_UNQUOTED(BUILD_DATE, ["$BUILD_DATE"])
+  BUILD_DATE_MSG=-"echo -e '=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\nNOTE: build date/time is fixed: $BUILD_DATE\n=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-='"
+  AC_SUBST(BUILD_DATE_MSG)
+fi
+
 dnl Check for the flag that fails if stuff are missing.
 
 AC_MSG_CHECKING(--enable-fail-if-missing argument)