Hi Basil, Thanks for the feedback.
> > +One such propagated value is > > +the value of the Automake-defined variable @code{$(VERSION)}. > > +(There is also the Autoconf-defined variable @code{$(PACKAGE_VERSION)}, > > +but nothing except Automake ought to use it.) > > Why ought nothing else use PACKAGE_VERSION? 1) Because where Autoconf and Automake have competing functionalities for the same purpose, you better use the Automake one and ignore the Autoconf one. For example, the macros $(mkdir_p) and $(MKDIR_P); that was such a mess... If you use $(VERSION) in some places and $(PACKAGE_VERSION) in other places, you make your life hard. 2) Because with the documented approach, $(PACKAGE_VERSION) comes out as empty. I didn't bother assigning to PACKAGE_VERSION the same value as to VERSION. > I understand that projects using Automake can use VERSION in place of > PACKAGE_VERSION, but I'm not aware of anything analogous to other > PACKAGE_* definitions, such as PACKAGE_STRING or PACKAGE_URL. Right. PACKAGE_BUGREPORT, PACKAGE_URL, etc. should be assigned directly, in configure.ac, if you need them. > > +The recommended code pattern is > > +@example > > +AC_INIT > > +AC_CONFIG_SRCDIR([@var{unique-file-in-source-dir}]) > > +AC_CONFIG_AUX_DIR([build-aux]) > > +VERSION_NUMBER=`cd $srcdir \ > > + && build-aux/git-version-gen .tarball-version \ > > + | sed -e 's/dirty$/modified/'` > > +gl_INIT_PACKAGE([@var{package}], [$VERSION_NUMBER]) > > +AM_INIT_AUTOMAKE([@var{options}]) > > +@end example > > AC_INIT is documented as taking two mandatory arguments. ... but when one uses AC_INIT as documented this way, VERSION must already be known at autoconf time. Which is not what we want, because it makes things harder for the maintainer. > The following commentary for Autoconf's AC_INIT definition in > lib/autoconf/general.m4 suggests that one can define the AC_PACKAGE_* > macros before invoking AC_INIT: But the Autoconf documentation says that these AC_PACKAGE_* macros are "defined by AC_INIT". Therefore it sounds hairy to define them in configure.ac. > From reading Gnulib's m4/init-package-version.m4 commentary I can > appreciate that it's a delicate dance Yes, and I hope that once the approach to let 'git-version-gen' be run at configure time (as opposed to autoconf time) is more widely accepted, we can remove some of the hurdles in Autoconf and in Automake that make m4/init-package-version.m4 so delicate. > What was previously: > > src_libfoo_la_LIBADD = $(top_builddir)/lib/libfoo.la > > is now: > > src_libfoo_la_LIBADD = $(top_builddir)/lib/lib.la > > IIUC this is because Gnulib's build-aux/bootstrap looks at AC_INIT > arguments in order to construct the gnulib-tool --lib argument. Thanks for reporting this. Fixed through the patch below. > - The biggest consequence is that 'make' fails after editing > e.g. configure.ac: > > 0. git clean -fdx > 1. export GNULIB_SRCDIR='/dir/of/gnulib' > 2. ./bootstrap --no-git --skip-po > 3. ./configure > 4. echo >> configure.ac > 5. make > > CDPATH="${ZSH_VERSION+.}:" && cd . && /bin/bash > '/home/blc/src/foo/build-aux/missing' aclocal-1.16 > configure.ac:10: error: AC_INIT should be called with package and > version arguments > /usr/share/aclocal-1.16/init.m4:29: AM_INIT_AUTOMAKE is expanded from... > configure.ac:10: the top level > autom4te: error: /usr/bin/m4 failed with exit status: 1 > aclocal-1.16: error: autom4te failed with exit status: 1 > make: *** [Makefile:1116: aclocal.m4] Error 1 Here the cause is a missing -I option to 'aclocal'. It has not found the m4/*.m4 files, thus the error message from AM_INIT_AUTOMAKE. The fix is to add a definition ACLOCAL_AMFLAGS = -I m4 to the top-level Makefile.am. Hmm. configure.ac already contains AC_CONFIG_MACRO_DIRS([m4]) but Automake ignores it. The Automake documentation says that the ACLOCAL_AMFLAGS = -I m4 line is redundant for Automake ≥ 1.13, but that is not the case. > > +The second such old code pattern > > +is to invoke @code{git-version-gen} at @code{autoconf} time: > > +@example > > +AC_INIT([@var{package}], > > + m4_esyscmd([build-aux/git-version-gen .tarball-version \ > > + | sed -e 's/dirty$/modified/'])]) > > +AC_CONFIG_SRCDIR([@var{unique-file-in-source-dir}]) > > +AC_CONFIG_AUX_DIR([build-aux]) > > +AM_INIT_AUTOMAKE([@var{options}]) > > +@end example > > Should the Autoconf manual be updated as well? This pattern is still > described in (info "(autoconf) Initializing configure"). Good point. Thanks for the reminder. This too will need to be discussed with the Autoconf maintainers. Bruno 2025-01-23 Bruno Haible <br...@clisp.org> bootstrap: Make it work with module 'package-version'. Reported by Basil L. Contovounesios <ba...@contovou.net> in <https://lists.gnu.org/archive/html/bug-gnulib/2025-01/msg00195.html>. * top/bootstrap-funclib.sh (normalize_package_name): New variable. (extract_package_name): Don't normalize the package name here. (package): Also look at the first argument of a gl_INIT_PACKAGE invocation. * build-aux/bootstrap: Regenerated. diff --git a/build-aux/bootstrap b/build-aux/bootstrap index f6a6214315..8e15db3bf3 100755 --- a/build-aux/bootstrap +++ b/build-aux/bootstrap @@ -37,7 +37,7 @@ medir=`dirname "$me"` # A library of shell functions for autopull.sh, autogen.sh, and bootstrap. -scriptlibversion=2025-01-09.08; # UTC +scriptlibversion=2025-01-23.20; # UTC # Copyright (C) 2003-2025 Free Software Foundation, Inc. # @@ -152,7 +152,8 @@ po_download_command_format=\ "wget --mirror --level=1 -nd -nv -A.po -P '%s' \ https://translationproject.org/latest/%s/" -# Prefer a non-empty tarname (4th argument of AC_INIT if given), else +# When extracting the package name from an AC_INIT invocation, +# prefer a non-empty tarname (4th argument of AC_INIT if given), else # fall back to the package name (1st argument with munging). extract_package_name=' /^AC_INIT(\[*/{ @@ -164,17 +165,25 @@ extract_package_name=' q } s/[],)].*// - s/^GNU // - y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ - s/[^abcdefghijklmnopqrstuvwxyz0123456789_]/-/g p } ' -package=$(${AUTOCONF:-autoconf} --trace AC_INIT:\$4 configure.ac 2>/dev/null) +normalize_package_name=' + s/^GNU // + y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ + s/[^abcdefghijklmnopqrstuvwxyz0123456789_]/-/g +' +package=$(${AUTOCONF:-autoconf} --trace 'gl_INIT_PACKAGE:$1' configure.ac \ + 2>/dev/null) if test -z "$package"; then - package=$(sed -n "$extract_package_name" configure.ac) \ - || die 'cannot find package name in configure.ac' + package=$(${AUTOCONF:-autoconf} --trace 'AC_INIT:$4' configure.ac \ + 2>/dev/null) + if test -z "$package"; then + package=$(sed -n "$extract_package_name" configure.ac) \ + || die 'cannot find package name in configure.ac' + fi fi +package=$(echo "$package" | sed "$normalize_package_name") gnulib_name=lib$package build_aux=build-aux diff --git a/top/bootstrap-funclib.sh b/top/bootstrap-funclib.sh index a48bd63bb2..1810a5c783 100644 --- a/top/bootstrap-funclib.sh +++ b/top/bootstrap-funclib.sh @@ -1,6 +1,6 @@ # A library of shell functions for autopull.sh, autogen.sh, and bootstrap. -scriptlibversion=2025-01-09.08; # UTC +scriptlibversion=2025-01-23.20; # UTC # Copyright (C) 2003-2025 Free Software Foundation, Inc. # @@ -115,7 +115,8 @@ po_download_command_format=\ "wget --mirror --level=1 -nd -nv -A.po -P '%s' \ https://translationproject.org/latest/%s/" -# Prefer a non-empty tarname (4th argument of AC_INIT if given), else +# When extracting the package name from an AC_INIT invocation, +# prefer a non-empty tarname (4th argument of AC_INIT if given), else # fall back to the package name (1st argument with munging). extract_package_name=' /^AC_INIT(\[*/{ @@ -127,17 +128,25 @@ extract_package_name=' q } s/[],)].*// - s/^GNU // - y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ - s/[^abcdefghijklmnopqrstuvwxyz0123456789_]/-/g p } ' -package=$(${AUTOCONF:-autoconf} --trace AC_INIT:\$4 configure.ac 2>/dev/null) +normalize_package_name=' + s/^GNU // + y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ + s/[^abcdefghijklmnopqrstuvwxyz0123456789_]/-/g +' +package=$(${AUTOCONF:-autoconf} --trace 'gl_INIT_PACKAGE:$1' configure.ac \ + 2>/dev/null) if test -z "$package"; then - package=$(sed -n "$extract_package_name" configure.ac) \ - || die 'cannot find package name in configure.ac' + package=$(${AUTOCONF:-autoconf} --trace 'AC_INIT:$4' configure.ac \ + 2>/dev/null) + if test -z "$package"; then + package=$(sed -n "$extract_package_name" configure.ac) \ + || die 'cannot find package name in configure.ac' + fi fi +package=$(echo "$package" | sed "$normalize_package_name") gnulib_name=lib$package build_aux=build-aux