build: Use timestamps file based on last commit date instead of host date
diff --git a/.gitignore b/.gitignore
index 15d152c6..d33a3c1e 100644
--- a/.gitignore
+++ b/.gitignore
@@ -30,6 +30,7 @@
!/common/font.bin
/configure
/configure.ac.save
+/timestamps
/build-aux
/aclocal.m4
/*~
diff --git a/GNUmakefile.in b/GNUmakefile.in
index ca336eea..976d4570 100644
--- a/GNUmakefile.in
+++ b/GNUmakefile.in
@@ -335,7 +335,7 @@ distclean: clean
.PHONY: maintainer-clean
maintainer-clean: distclean
- cd '$(call SHESCAPE,$(SRCDIR))' && rm -rf common/flanterm common/lib/stb_image.h decompressor/tinf tinf stb freestanding-headers common/cc-runtime decompressor/cc-runtime limine-efi configure build-aux *'~' autom4te.cache aclocal.m4 *.tar*
+ cd '$(call SHESCAPE,$(SRCDIR))' && rm -rf common/flanterm common/lib/stb_image.h decompressor/tinf tinf stb freestanding-headers common/cc-runtime decompressor/cc-runtime limine-efi configure timestamps build-aux *'~' autom4te.cache aclocal.m4 *.tar*
.PHONY: common-uefi-x86-64
common-uefi-x86-64:
diff --git a/bootstrap b/bootstrap
index 46530f0f..c64ef705 100755
--- a/bootstrap
+++ b/bootstrap
@@ -66,6 +66,20 @@ if ! [ -f version ]; then
rm -f common/lib/stb_image.h.orig
fi
+# Create timestamps file
+if git log -1 >/dev/null 2>&1; then
+ cat >timestamps <<EOF
+REGEN_DATE="$(git log -1 --pretty=%cd --date='format:%B %Y')"
+SOURCE_DATE_EPOCH="$(git log -1 --pretty=%ct)"
+SOURCE_DATE_EPOCH_TOUCH="$(git log -1 --pretty=%cI | sed 's/-//g;s/T//g;s/://g;s/[0-9][0-9]+.*//g')"
+EOF
+fi
+
+if ! test -f timestamps; then
+ echo "error: Not a Git repository and 'timestamps' file missing."
+ exit 1
+fi
+
for auxfile in $AUXFILES; do
rm -f build-aux/$auxfile
done
diff --git a/configure.ac b/configure.ac
index 355f779a..1c8e67bc 100644
--- a/configure.ac
+++ b/configure.ac
@@ -10,13 +10,10 @@ BUILDDIR="$(pwd -P)"
AC_SUBST([SRCDIR])
AC_SUBST([BUILDDIR])
-REGEN_DATE="m4_esyscmd([date '+%B %Y' | tr -d '\n'])"
-AC_SUBST([REGEN_DATE])
+. "$SRCDIR"/timestamps
-SOURCE_DATE_EPOCH="m4_esyscmd([if git log -1 >/dev/null 2>&1; then git log -1 --pretty=%ct | tr -d '\n'; else printf 1546300800; fi])"
+AC_SUBST([REGEN_DATE])
AC_SUBST([SOURCE_DATE_EPOCH])
-
-SOURCE_DATE_EPOCH_TOUCH="m4_esyscmd([if git log -1 >/dev/null 2>&1; then git log -1 --pretty=%cI | sed 's/-//g;s/T//g;s/://g;s/[0-9][0-9]+.*//g' | tr -d '\n'; else printf 201901010000; fi])"
AC_SUBST([SOURCE_DATE_EPOCH_TOUCH])
AC_CANONICAL_HOST
