:: commit 9f98cf150aa545161d96af32eb7ed42aebacce53

mintsuki <mintsuki@protonmail.com> — 2024-04-10 13:01

parents: df0d9d48d2

build: Make version gathering similar to timestamps gathering

diff --git a/.gitignore b/.gitignore
index d33a3c1e..5474231c 100644
--- a/.gitignore
+++ b/.gitignore
@@ -31,6 +31,7 @@
 /configure
 /configure.ac.save
 /timestamps
+/version
 /build-aux
 /aclocal.m4
 /*~
diff --git a/GNUmakefile.in b/GNUmakefile.in
index 976d4570..4cd6adcc 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 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 version build-aux *'~' autom4te.cache aclocal.m4 *.tar*
 
 .PHONY: common-uefi-x86-64
 common-uefi-x86-64:
diff --git a/bootstrap b/bootstrap
index ac8fc97e..feb1343c 100755
--- a/bootstrap
+++ b/bootstrap
@@ -2,6 +2,9 @@
 
 set -ex
 
+LC_ALL=C
+export LC_ALL
+
 srcdir="$(dirname "$0")"
 test -z "$srcdir" && srcdir=.
 
@@ -66,7 +69,7 @@ if ! [ -f version ]; then
     rm -f common/lib/stb_image.h.orig
 fi
 
-# Create timestamps file
+# Create timestamps and version file
 if git log -1 >/dev/null 2>&1; then
     cat >timestamps <<EOF
 REGEN_DATE="$(git log -1 --pretty=%cd --date='format:%B %Y')"
@@ -80,6 +83,17 @@ 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 1c8e67bc..13bf228a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1,4 +1,4 @@
-AC_INIT([Limine], [m4_esyscmd([./version.sh])], [https://github.com/limine-bootloader/limine/issues], [limine], [https://limine-bootloader.org/])
+AC_INIT([Limine], [m4_esyscmd([cat version | tr -d \\n])], [https://github.com/limine-bootloader/limine/issues], [limine], [https://limine-bootloader.org/])
 
 AC_PREREQ([2.69])
 
diff --git a/version.sh b/version.sh
deleted file mode 100755
index 511ebe3d..00000000
--- a/version.sh
+++ /dev/null
@@ -1,29 +0,0 @@
-#! /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"
tab: 248 wrap: offon