Revert "build: Make version gathering similar to timestamps gathering"
This reverts commit 9f98cf150aa545161d96af32eb7ed42aebacce53.
diff --git a/.gitignore b/.gitignore
index 5474231c..d33a3c1e 100644
--- a/.gitignore
+++ b/.gitignore
@@ -31,7 +31,6 @@
/configure
/configure.ac.save
/timestamps
-/version
/build-aux
/aclocal.m4
/*~
diff --git a/GNUmakefile.in b/GNUmakefile.in
index 4cd6adcc..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 timestamps version 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 feb1343c..ac8fc97e 100755
--- a/bootstrap
+++ b/bootstrap
@@ -2,9 +2,6 @@
set -ex
-LC_ALL=C
-export LC_ALL
-
srcdir="$(dirname "$0")"
test -z "$srcdir" && srcdir=.
@@ -69,7 +66,7 @@ if ! [ -f version ]; then
rm -f common/lib/stb_image.h.orig
fi
-# Create timestamps and version file
+# 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')"
@@ -83,17 +80,6 @@ if ! test -f timestamps; then
exit 1
fi
-if git describe --exact-match --tags $(git log -n1 --pretty='%h') >/dev/null 2>&1; then
- git describe --exact-match --tags $(git log -n1 --pretty='%h') | sed 's/^v//g' >version
-elif git log -n1 --pretty='%h' >/dev/null 2>&1; then
- echo g$(git log -n1 --pretty='%h') >version
-fi
-
-if ! test -f version; then
- echo "error: Not a Git repository and 'version' 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 13bf228a..1c8e67bc 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1,4 +1,4 @@
-AC_INIT([Limine], [m4_esyscmd([cat version | tr -d \\n])], [https://github.com/limine-bootloader/limine/issues], [limine], [https://limine-bootloader.org/])
+AC_INIT([Limine], [m4_esyscmd([./version.sh])], [https://github.com/limine-bootloader/limine/issues], [limine], [https://limine-bootloader.org/])
AC_PREREQ([2.69])
diff --git a/version.sh b/version.sh
new file mode 100755
index 00000000..511ebe3d
--- /dev/null
+++ b/version.sh
@@ -0,0 +1,29 @@
+#! /bin/sh
+
+LC_ALL=C
+export LC_ALL
+
+srcdir="$(dirname "$0")"
+test -z "$srcdir" && srcdir=.
+
+cd "$srcdir"
+
+if [ -f version ]; then
+ printf '%s' "$(cat version)"
+ exit 0
+fi
+
+if ! [ -d .git ] || ! git log -n1 --pretty='%h' >/dev/null 2>&1; then
+ printf 'UNVERSIONED'
+ exit 0
+fi
+
+tmpfile="$(mktemp)"
+
+if ! git describe --exact-match --tags $(git log -n1 --pretty='%h') >"$tmpfile" 2>/dev/null; then
+ echo g$(git log -n1 --pretty='%h') >"$tmpfile"
+fi
+
+printf '%s' "$(sed 's/^v//g' <"$tmpfile")"
+
+rm -f "$tmpfile"
