#!/bin/sh
# Print a version string.
-scriptversion=2024-07-04.10; # UTC
+scriptversion=2024-12-27.09; # UTC
# Copyright (C) 2007-2024 Free Software Foundation, Inc.
#
# along with this program. If not, see <https://www.gnu.org/licenses/>.
# This script is derived from GIT-VERSION-GEN from GIT: https://git-scm.com/.
-# It may be run two ways:
+
+# It may be run in the following ways, presuming the script is invoked
+# like "./git-version-gen .tarball-version":
+#
# - from a git repository in which the "git describe" command below
# produces useful output (thus requiring at least one signed tag)
-# - from a non-git-repo directory containing a .tarball-version file, which
-# presumes this script is invoked like "./git-version-gen .tarball-version".
+#
+# - from a "make dist" non-git-repo directory containing a
+# .tarball-version file
+#
+# - from a "git archive" non-git-repo directory containing a
+# .tarball-version-git file
-# In order to use intra-version strings in your project, you will need two
+# In order to use intra-version strings in your project, you will need some
# separate generated version string files:
#
# .tarball-version - present only in a distribution tarball, and not in
# hooks to force a reconfigure at distribution time to get the value
# correct, without penalizing normal development with extra reconfigures.
#
+# .tarball-version-git - a file committed to git containing a single
+# line with the string $Format:%(describe)$ and that the file is
+# marked in .gitattributes with ".tarball-version-git export-subst".
+# If the file doesn't exist or the export-subst keyword wasn't
+# effective, the file is ignored.
+#
# .version - present in a checked-out repository and in a distribution
# tarball. Usable in dependencies, particularly for files that don't
# want to depend on config.h but do want to track version changes.
# mv $@-t $@
# dist-hook:
# echo '$(VERSION)' > $(distdir)/.tarball-version
-
+#
+# To setup support for "git archive" tarballs, use the following:
+#
+# echo '$Format:%(describe)$' > .tarball-version-git
+# echo '.tarball-version-git export-subst' >> .gitattributes
+# git commit -a -m "Add .tarball-version-git for git-version-gen."
me=$0
v=$fallback
fi
+if test "x$v" = xUNKNOWN \
+ && test -f ${tarball_version_file}-git \
+ && head -1 ${tarball_version_file}-git \
+ | grep -v '^$Format' > /dev/null 2>&1; then
+ v=$(head -1 ${tarball_version_file}-git)
+fi
+
v=`echo "$v" |sed "s/^$prefix//"`
# Test whether to append the "-dirty" suffix only if the version