From: Lasse Collin Date: Mon, 7 Apr 2025 14:38:32 +0000 (+0300) Subject: FIXME *** Build: Add support for git_commit_info.sh X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=689ec5d2c9d968617ab1b69ee9b9d4a48f7a88d6;p=thirdparty%2Fxz.git FIXME *** Build: Add support for git_commit_info.sh Using $(RECURSIVE_TARGETS) might apply to too many targets. At the same time, it isn't enough: Each library/program or file that depends on git_commit_version.h should ensure that the file is up to date without trying to update it in parallel (and then corrupting it). Now if one configures the tree and runs "make -C src", the header isn't generated and the build fails. --- diff --git a/Makefile.am b/Makefile.am index fc54f477..2d3320c3 100644 --- a/Makefile.am +++ b/Makefile.am @@ -53,6 +53,7 @@ EXTRA_DIST = \ PACKAGERS \ TODO \ autogen.sh \ + build-aux/git_commit_info.sh \ build-aux/license-check.sh \ build-aux/manconv.sh \ build-aux/version.sh \ @@ -71,6 +72,22 @@ manfiles = \ src/scripts/xzless.1 \ src/scripts/xzmore.1 + +# When .git dir and the git tool are available, put commit information +# into git_commit_info.h. It is used in version strings. +CLEANFILES = git_commit_info.h + +git_commit_info.h: + $(AM_V_GEN) \ + $(SHELL) $(srcdir)/build-aux/git_commit_info.sh "$(srcdir)" $@ + +.PHONY: git_commit_info.h + +if COND_GIT_COMMIT_INFO +$(RECURSIVE_TARGETS): git_commit_info.h +endif + + # Create ChangeLog using "git log". # Convert the man pages to plain text (ASCII only) format. dist-hook: diff --git a/configure.ac b/configure.ac index 80d6d338..40747e32 100644 --- a/configure.ac +++ b/configure.ac @@ -1362,6 +1362,29 @@ AS_IF([test "$GCC" = yes], [ ]) +############################################################################### +# Conditionally include Git commit version in the version string. +############################################################################### + +# git_commit_info.sh checks that .git and the git tool are available. +# The check below for .git is to keep builds from tarballs slightly cleaner. +AC_ARG_ENABLE([git-commit-info], + AS_HELP_STRING([--disable-git-commit-info], + [Do not include Git commit information in the version string + when building from a Git repository.]), + [], + [AS_IF([test -d "$srcdir/.git"], + [enable_git_commit_info=yes], + [enable_git_commit_info=no])]) + +AS_IF([test "x$enable_git_commit_info" = xyes], + [AC_DEFINE([HAVE_GIT_COMMIT_INFO_H], [1], + [Define to 1 if git_commit_info.h is generated.])]) + +AM_CONDITIONAL([COND_GIT_COMMIT_INFO], + [test "x$enable_git_commit_info" = xyes]) + + ############################################################################### # Create the makefiles and config.h ###############################################################################