]> Savannah Git Hosting - gnulib.git/commitdiff
package-version: Simplify its use.
authorBruno Haible <bruno@clisp.org>
Fri, 24 Jan 2025 21:03:29 +0000 (22:03 +0100)
committerBruno Haible <bruno@clisp.org>
Fri, 24 Jan 2025 21:35:54 +0000 (22:35 +0100)
Reported by Basil L. Contovounesios <basil@contovou.net> in
<https://lists.gnu.org/archive/html/bug-gnulib/2025-01/msg00195.html>.

* doc/package-version.texi (Propagating the package version): Recommend
to pass the usual arguments to AC_INIT.
* m4/init-package-version.m4: Likewise.
(gl_INIT_PACKAGE): Define PACKAGE_VERSION and PACKAGE_STRING as needed.
(gl_RPL_INIT_AUTOMAKE): Improve quoting.

ChangeLog
doc/package-version.texi
m4/init-package-version.m4

index ea015f81cada18f4797e6aa845c6caecd5d7bfc3..f7f26982311f29563bba160a2a9717108ff0138d 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2025-01-24  Bruno Haible  <bruno@clisp.org>
+
+       package-version: Simplify its use.
+       Reported by Basil L. Contovounesios <basil@contovou.net> in
+       <https://lists.gnu.org/archive/html/bug-gnulib/2025-01/msg00195.html>.
+       * doc/package-version.texi (Propagating the package version): Recommend
+       to pass the usual arguments to AC_INIT.
+       * m4/init-package-version.m4: Likewise.
+       (gl_INIT_PACKAGE): Define PACKAGE_VERSION and PACKAGE_STRING as needed.
+       (gl_RPL_INIT_AUTOMAKE): Improve quoting.
+
 2025-01-24  Bruno Haible  <bruno@clisp.org>
 
        tests: Fix a few compilation errors on Solaris 11 OmniOS with gcc 14.
index fb050a8fcfd7f862ecc6235643e0ac101f3dc92a..4075b98d03b1f7fe2c1a4ac3b2df1ece41210dfb 100644 (file)
@@ -118,7 +118,7 @@ a few lines are needed in @code{configure.ac}.
 
 The recommended code pattern is
 @example
-AC_INIT
+AC_INIT([@var{package}], [dummy])
 AC_CONFIG_SRCDIR([@var{unique-file-in-source-dir}])
 AC_CONFIG_AUX_DIR([build-aux])
 VERSION_NUMBER=`cd $srcdir \
index 525dfe5bf54852ae03a035d38d48b510f378f2d8..69f7764892bc235839835899c98a55fa318ebf25 100644 (file)
@@ -1,5 +1,5 @@
 # init-package-version.m4
-# serial 3
+# serial 4
 dnl Copyright (C) 1992-2025 Free Software Foundation, Inc.
 dnl This file is free software, distributed under the terms of the GNU
 dnl General Public License.  As a special exception to the GNU General
@@ -57,7 +57,7 @@ dnl the same distribution terms as the rest of that program.
 #
 # With the macro defined in this file, the approach can be coded like this:
 #
-#   AC_INIT
+#   AC_INIT(PACKAGE, [dummy], [MORE OPTIONS])
 #   AC_CONFIG_SRCDIR(WITNESS)
 #   . $srcdir/../version.sh
 #   gl_INIT_PACKAGE(PACKAGE, $VERSION_NUMBER)
@@ -102,8 +102,16 @@ AC_DEFUN([gl_INIT_PACKAGE],
               [AC_PACKAGE_NAME], [gl_INIT_DUMMY])),
           [AC_PACKAGE_TARNAME], [gl_INIT_EMPTY])),
       [AC_PACKAGE_VERSION], [gl_INIT_DUMMY])
-    [AC_SUBST([PACKAGE], [$1])
-     AC_SUBST([VERSION], [$2])
+    [dnl Set variables documented in Automake.
+     AC_SUBST([PACKAGE], [$1])
+     AC_SUBST([VERSION], ["$2"])
+     dnl Set variables documented in Autoconf.
+     AC_SUBST([PACKAGE_VERSION], ["$2"])
+     AC_SUBST([PACKAGE_STRING], ["$1 $2"])
+     AC_DEFINE_UNQUOTED([PACKAGE_VERSION], ["$2"],
+       [Define to the version of this package.])
+     AC_DEFINE_UNQUOTED([PACKAGE_STRING], ["$1 $2"],
+       [Define to the full name and version of this package.])
     ])
   m4_define([AM_INIT_AUTOMAKE],
     m4_defn([gl_RPL_INIT_AUTOMAKE]))
@@ -118,7 +126,7 @@ AC_DEFUN([gl_RPL_INIT_AUTOMAKE], [
     [m4_fatal([After gl_INIT_PACKAGE, the two-argument form of AM_INIT_AUTOMAKE cannot be used.])])
   gl_AM_INIT_AUTOMAKE([$1 no-define])
   m4_if(m4_index([ $1 ], [ no-define ]), [-1],
-    [AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE", [Name of package])
-     AC_DEFINE_UNQUOTED(VERSION, "$VERSION", [Version number of package])
+    [AC_DEFINE_UNQUOTED([PACKAGE], ["$PACKAGE"], [Name of package])
+     AC_DEFINE_UNQUOTED([VERSION], ["$VERSION"], [Version number of package])
     ])
 ])