Fix autopoint version detection again. Both copies of the autopoint version detector (one in autoreconf and one in tests/local.at) should now correctly recognize autopoint 0.2[34].(>=2) as supporting AM_GNU_GETTEXT without a version requirement, as well as 0.25.1 and up. The logic has been revised again for even greater explicitness and transparency. In Perl it is straightforward to break the version number into components and do arithmetic on them, so that’s what we do. In shell that would be tedious, so we are still using a case statement, but a lot of the visual clutter has been factored out. Also make the testsuite log the version of libtoolize, intltoolize, gtkdocize, and autopoint, and whether it thinks autopoint supports AM_GNU_GETTEXT without a version requirement. Also add tests for autoreconf running autopoint under several different conditions, and of autoreconf being directed *not* to run autopoint.
diff --git a/bin/autoreconf.in b/bin/autoreconf.in index a7fe83e..b703dd0 100644 --- a/bin/autoreconf.in +++ b/bin/autoreconf.in
@@ -568,7 +568,7 @@ # '^AM_GNU_GETTEXT_(REQUIRE_)?VERSION('. We did this above, while # scanning configure.ac. - # Older autopoint versions fail if $configure.ac contains no + # Older autopoint versions fail if $configure_ac contains no # AM_GNU_GETTEXT_VERSION or AM_GNU_GETTEXT_REQUIRE_VERSION # invocation. These variables are set here and used far below. my $autopoint_is_available = 0; @@ -583,27 +583,42 @@ # # This doesn't use xqx because we don't want to *fail* if # there's no autopoint, we just want to not run it. Written - # this way, Perl won't invoke a subshell. + # this way, Perl should only invoke a subshell if $C{autopoint} + # contains shell metacharacters, which hopefully it does not + # (weaning all these tools off scalar exec is a "hopefully + # someday" project). eval { no warnings 'exec'; - my @autopoint_version_output = qx/$C{autopoint} --version/; - if ($? == 0 && scalar @autopoint_version_output >= 1) + my @ap_ver = qx/$C{autopoint} --version/; + + if ($? == 0 && scalar @ap_ver >= 1) { $autopoint_is_available = 1; - # Extract the version from - # "PROGRAM_NAME (GNU PACKAGE_NAME) VERSION". - my $autopoint_version = $autopoint_version_output[0]; - $autopoint_version =~ s/^.*?\)\s+//; - $autopoint_version =~ s/\s+\z//; - # The first version of autopoint that can handle AM_GNU_GETTEXT - # without the version requirement macros is 0.25.1. This regex - # matches every released version up to and including 0.25.0. - $autopoint_works_without_gtver = ($autopoint_version !~ /\A - 0\. (?: 25 (?: \.0 )? - | (?: 2[0-4] | 1[0-9] | [0-9] ) (?: \. [0-9][0-9.]* )? - )\z/x); + # The first line of autopoint --version output should + # have the form + # "PROGRAM_NAME (GNU PACKAGE_NAME) MAJ.MIN[.PTC][ETC]" + # where MAJ, MIN, and PTC are sequences of digits, + # and [...] indicates an optional component. + if ($ap_ver[0] =~ /^ .*?\) \s+ (\d+) \. (\d+) (?:\.(\d+)) /x) + { + my $maj = $1; + my $min = $2; + my $ptc = ($3 || 0); + + # The autopoint versions that can handle AM_GNU_GETTEXT + # without the version requirement macros are: + # - 0.23.x, x >= 2 + # - 0.24.x, x >= 2 + # - 0.25.x, x >= 1 + # - 0.26(.0) and up. + $autopoint_works_without_gtver = + $maj >= 1 + || $min >= 26 + || ($min == 25 && $ptc >= 1) + || ($min >= 23 && $ptc >= 2); + } } }; @@ -625,7 +640,7 @@ $uses_gettext ? "Gettext" : $uses_iconv ? "AM_ICONV" : $uses_liblink ? "AC_LIB_LINKFLAGS" : - die ("impossible: one of \$uses_gettext, $uses_iconv, or" + die ("impossible: one of \$uses_gettext, \$uses_iconv, or" . " \$uses_liblink should have been true"); $invoked_autopoint = 1;
diff --git a/tests/local.at b/tests/local.at index 266a023..296dee9 100644 --- a/tests/local.at +++ b/tests/local.at
@@ -54,7 +54,7 @@ # This also weeds out broken wrapper scripts; in the past some vendors # have shipped an 'automake' that didn't work without user configuration. : "${AUTOMAKE=automake}" -at_automake_version="`$AUTOMAKE --version 2>&1 || echo not found`" +at_automake_version="`$AUTOMAKE --version 2>&1 || :`" at_automake_version_1="`AS_ECHO(["$at_automake_version"]) | sed 1q`" AS_CASE([$at_automake_version_1], [[*GNU*\)\ [1-9]\.[0-9]*]], [], @@ -78,7 +78,7 @@ # The same Perl and wrapper issues exist with aclocal. Also, we # require a version that understands --system-acdir and configure.ac. : "${ACLOCAL=aclocal}" -at_aclocal_version="`$ACLOCAL --version 2>&1 || echo not found`" +at_aclocal_version="`$ACLOCAL --version 2>&1 || :`" at_aclocal_version_1="`AS_ECHO(["$at_aclocal_version"]) | sed 1q`" AS_CASE([$at_aclocal_version_1], [[*GNU*\)\ [1-9]\.[0-9]*]], @@ -101,7 +101,7 @@ # Similarly for the add-on programs that autoreconf can run: # libtoolize, intltoolize, gtkdocize, and autopoint. : "${LIBTOOLIZE=libtoolize}" -at_libtoolize_version="`$LIBTOOLIZE --version 2>&1 || echo not found`" +at_libtoolize_version="`$LIBTOOLIZE --version 2>&1 || :`" at_libtoolize_version_1="`AS_ECHO(["$at_libtoolize_version"]) | sed 1q`" AS_CASE([$at_libtoolize_version_1], [[*GNU*\)\ [1-9]\.[0-9]*]], [], @@ -109,7 +109,7 @@ export LIBTOOLIZE : "${INTLTOOLIZE=intltoolize}" -at_intltoolize_version="`$INTLTOOLIZE --version 2>&1 || echo not found`" +at_intltoolize_version="`$INTLTOOLIZE --version 2>&1 || :`" at_intltoolize_version_1="`AS_ECHO(["$at_intltoolize_version"]) | sed 1q`" AS_CASE([$at_intltoolize_version_1], [[*GNU*\)\ [0-9]\.[0-9]*]], [], @@ -117,34 +117,40 @@ export INTLTOOLIZE : "${GTKDOCIZE=gtkdocize}" -at_gtkdocize_version="`$GTKDOCIZE --version 2>&1 || echo not found`" +at_gtkdocize_version="`$GTKDOCIZE --version 2>&1 || :`" at_gtkdocize_version_1="`AS_ECHO(["$at_gtkdocize_version"]) | sed 1q`" AS_CASE([$at_gtkdocize_version_1], [[*gtk-doc*\)\ [1-9]\.[0-9]*]], [], [GTKDOCIZE=false]) export GTKDOCIZE -# Autopoint < 0.25.1 does not understand configure.ac with no -# AM_GNU_GETTEXT_VERSION or AM_GNU_GETTEXT_REQUIRE_VERSION. Keep these -# shell globs in sync with the regex for $autopoint_works_without_gtver -# in bin/autoreconf.in. : "${AUTOPOINT=autopoint}" -at_autopoint_version="`$AUTOPOINT --version 2>&1 || echo not found`" +at_autopoint_version="`$AUTOPOINT --version 2>&1 || :`" at_autopoint_version_1="`AS_ECHO(["$at_autopoint_version"]) | sed 1q`" AS_CASE([$at_autopoint_version_1], - [[*GNU*\)\ [1-9]*\.[0-9]* | \ - *GNU*\)\ 0.26.[0-9]* | \ - *GNU*\)\ 0.26 | \ - *GNU*\)\ 0.25.[1-9]* ]], - [at_autopoint_modern=:], - [[*GNU*\)\ 0.25 | *GNU*\)\ 0.25.0 | \ - *GNU*\)\ 0.2[0-4] | *GNU*\)\ 0.2[0-4].[0-9]* | \ - *GNU*\)\ 0.1[0-9] | *GNU*\)\ 0.1[0-9].[0-9]* | \ - *GNU*\)\ 0.[0-9] | *GNU*\)\ 0.[0-9].[0-9]*]], - [at_autopoint_modern=false], - [AUTOPOINT=false at_autopoint_modern=false]) + [[*GNU*\)\ [0-9]\.[0-9]*]], [], + [AUTOPOINT=false]) export AUTOPOINT +# Older versions of autopoint cannot handle a configure.ac that has +# AM_GNU_GETTEXT but doesn't have one of AM_GNU_GETTEXT_VERSION or +# AM_GNU_GETTEXT_REQUIRE_VERSION. The versions that *do* handle +# this correctly are +# - 0.23.x, x >= 2 +# - 0.24.x, x >= 2 +# - 0.25.x, x >= 1 +# - 0.26(.0) and up. +# This logic needs to agree with the logic for $autopoint_works_without_gtver +# in bin/autoreconf.in. +AS_CASE(["`AS_ECHO(["$at_autopoint_version_1"]) | sed 's/^.*) *//'`"], + [[ [1-9][.0-9]* | \ + 0.[3-9][0-9]* | \ + 0.2[6-9] | \ + 0.2[6-9][.0-9]* | \ + 0.25.[1-9]* | \ + 0.2[34].[2-9]* ]], + [at_autopoint_modern=:], + [at_autopoint_modern=false]) # Determine how long we need to delay in between operations that might # modify autom4te.cache. This depends on three factors: whether the @@ -223,7 +229,11 @@ "r sh ${CONFIG_SHELL-$SHELL}" \ "r make $MAKE" \ "o automake $AUTOMAKE" \ - "o aclocal $ACLOCAL" + "o aclocal $ACLOCAL" \ + "o libtoolize $LIBTOOLIZE" \ + "o intltoolize $INTLTOOLIZE" \ + "o gtkdocize $GTKDOCIZE" \ + "o autopoint $AUTOPOINT" do # The first three words of $at_program are a code for whether # it's required (r) or optional (o); the conventional name of the @@ -261,6 +271,16 @@ done AS_ECHO(["$at_srcdir/AT_LINE: using ${at_ts_resolution}s as mtime resolution"]) + +if test x"$AUTOPOINT" != xfalse; then + if $at_autopoint_modern; then + at_autopoint_status="supports AM_GNU_GETTEXT by itself" + else + at_autopoint_status="does not support AM_GNU_GETTEXT by itself" + fi + AS_ECHO(["$at_srcdir/AT_LINE: $AUTOPOINT $at_autopoint_status"]) +fi + echo exit $status ) >&AS_MESSAGE_LOG_FD 2>&1
diff --git a/tests/torture.at b/tests/torture.at index 20ac941..8891583 100644 --- a/tests/torture.at +++ b/tests/torture.at
@@ -2079,6 +2079,222 @@ AT_CLEANUP +## -------------------- ## +## Running autopoint. ## +## -------------------- ## + +AT_SETUP([Package requiring autopoint (AM_GNU_GETTEXT + _VERSION)]) +AT_KEYWORDS([autoreconf autopoint]) + +AT_REQUIRE_AUTOMAKE +AT_REQUIRE_ACLOCAL +AT_REQUIRE_AUTOPOINT + +AT_DATA([configure.ac], +[[AC_INIT(GNU foo, 1.0) +AC_CONFIG_MACRO_DIRS([m4]) +AM_INIT_AUTOMAKE +AM_GNU_GETTEXT([external]) +# This is the oldest version of gettext.m4 that defines the +# AM_GNU_GETTEXT_VERSION macro. +AM_GNU_GETTEXT_VERSION([0.11.4]) + +AC_CONFIG_FILES([Makefile po/Makefile.in]) +AC_OUTPUT +]]) + +AT_DATA([Makefile.am], +[[AUTOMAKE_OPTIONS = foreign +ACLOCAL_AMFLAGS = -I m4 +SUBDIRS = po +]]) + +# autoreconf runs autopoint before aclocal, so we don't need to +# worry about the m4 files being unavailable as we do for libtool. +AT_CHECK([autoreconf -Wall -v -i], 0, [ignore], [stderr]) +AT_CHECK([$EGREP 'running: autopoint' stderr], 0, [ignore], [ignore]) + +AT_CHECK_CONFIGURE([--no-create]) + +# Because we're intentionally calling for very old gettext infrastructure, +# config.status will cough up a warning about po/Makefile.in.in but +# should otherwise run fine. +AT_CHECK([./config.status], [0], +[[config.status: creating Makefile +config.status: creating po/Makefile.in +config.status: executing default-1 commands +config.status: executing depfiles commands +]], +[[config.status: WARNING: 'po/Makefile.in.in' seems to ignore the --datarootdir setting +]]) + +AT_CLEANUP + + +AT_SETUP([Package requiring autopoint (AM_GNU_GETTEXT + _REQUIRE_VERSION)]) +AT_KEYWORDS([autoreconf autopoint]) + +AT_REQUIRE_AUTOMAKE +AT_REQUIRE_ACLOCAL +AT_REQUIRE_AUTOPOINT + +AT_DATA([configure.ac], +[[AC_INIT(GNU foo, 1.0) +AC_CONFIG_MACRO_DIRS([m4]) +AM_INIT_AUTOMAKE +AM_GNU_GETTEXT([external]) +# This is the oldest version of gettext.m4 that defines the +# AM_GNU_GETTEXT_REQUIRE_VERSION macro. +AM_GNU_GETTEXT_REQUIRE_VERSION([0.19.6]) + +AC_CONFIG_FILES([Makefile po/Makefile.in]) +AC_OUTPUT +]]) + +AT_DATA([Makefile.am], +[[AUTOMAKE_OPTIONS = foreign +ACLOCAL_AMFLAGS = -I m4 +SUBDIRS = po +]]) + +# autoreconf runs autopoint before aclocal, so we don't need to +# worry about the m4 files being unavailable as we do for libtool. +AT_CHECK([autoreconf -Wall -v -i], 0, [ignore], [stderr]) +AT_CHECK([$EGREP 'running: autopoint' stderr], 0, [ignore], [ignore]) + +# The requested version of gettext.m4 is new enough that its +# po/Makefile.in.in does not provoke warnings from config.status. +AT_CHECK_CONFIGURE + +AT_CLEANUP + + +AT_SETUP([Package requiring autopoint (AM_GNU_GETTEXT alone)]) +AT_KEYWORDS([autoreconf autopoint]) + +AT_REQUIRE_AUTOMAKE +AT_REQUIRE_ACLOCAL +AT_REQUIRE_AUTOPOINT + +AT_DATA([configure.ac], +[[AC_INIT(GNU foo, 1.0) +AC_CONFIG_MACRO_DIRS([m4]) +AM_INIT_AUTOMAKE +AM_GNU_GETTEXT([external]) + +AC_CONFIG_FILES([Makefile po/Makefile.in]) +AC_OUTPUT +]]) + +AT_DATA([Makefile.am], +[[AUTOMAKE_OPTIONS = foreign +ACLOCAL_AMFLAGS = -I m4 +SUBDIRS = po +]]) + +# autoreconf runs autopoint before aclocal, so we don't need to +# worry about the m4 files being unavailable as we do for libtool. +AT_CHECK([autoreconf -Wall -v -i], 0, [ignore], [stderr]) + +# autoreconf should have completed successfully regardless of what +# version of autopoint is available; however, if we have an old +# autopoint, it will not have run autopoint, and the generated +# configure script will not work. + +AS_IF([$at_autopoint_modern], [ + AT_CHECK([$EGREP 'running: autopoint' stderr], 0, [ignore], [ignore]) + AT_CHECK_CONFIGURE +], [ + AT_CHECK([$EGREP 'not running autopoint because it is too old' stderr], + 0, [ignore], [ignore]) +]) + +AT_CLEANUP + + +AT_SETUP([Package requiring autopoint (AM_ICONV alone)]) +AT_KEYWORDS([autoreconf autopoint]) + +AT_REQUIRE_AUTOMAKE +AT_REQUIRE_ACLOCAL +AT_REQUIRE_AUTOPOINT + +AT_DATA([configure.ac], +[[AC_INIT(GNU foo, 1.0) +AC_CONFIG_MACRO_DIRS([m4]) +AM_INIT_AUTOMAKE +AM_ICONV + +AC_CONFIG_FILES([Makefile]) +AC_OUTPUT +]]) + +AT_DATA([Makefile.am], +[[AUTOMAKE_OPTIONS = foreign +ACLOCAL_AMFLAGS = -I m4 +]]) + +# autoreconf runs autopoint before aclocal, so we don't need to +# worry about the m4 files being unavailable as we do for libtool. +AT_CHECK([autoreconf -Wall -v -i], 0, [ignore], [stderr]) + +# autoreconf should have completed successfully regardless of what +# version of autopoint is available; however, if we have an old +# autopoint, it will not have run autopoint, and the generated +# configure script will not work. + +AS_IF([$at_autopoint_modern], [ + AT_CHECK([$EGREP 'running: autopoint' stderr], 0, [ignore], [ignore]) + AT_CHECK_CONFIGURE +], [ + AT_CHECK([$EGREP 'not running autopoint because it is too old' stderr], + 0, [ignore], [ignore]) +]) + +AT_CLEANUP + + +AT_SETUP([Package requiring autopoint (AC_LIB_LINKFLAGS alone)]) +AT_KEYWORDS([autoreconf autopoint]) + +AT_REQUIRE_AUTOMAKE +AT_REQUIRE_ACLOCAL +AT_REQUIRE_AUTOPOINT + +AT_DATA([configure.ac], +[[AC_INIT(GNU foo, 1.0) +AC_CONFIG_MACRO_DIRS([m4]) +AM_INIT_AUTOMAKE +AC_LIB_LINKFLAGS + +AC_CONFIG_FILES([Makefile]) +AC_OUTPUT +]]) + +AT_DATA([Makefile.am], +[[AUTOMAKE_OPTIONS = foreign +ACLOCAL_AMFLAGS = -I m4 +]]) + +# autoreconf runs autopoint before aclocal, so we don't need to +# worry about the m4 files being unavailable as we do for libtool. +AT_CHECK([autoreconf -Wall -v -i], 0, [ignore], [stderr]) + +# autoreconf should have completed successfully regardless of what +# version of autopoint is available; however, if we have an old +# autopoint, it will not have run autopoint, and the generated +# configure script will not work. + +AS_IF([$at_autopoint_modern], [ + AT_CHECK([$EGREP 'running: autopoint' stderr], 0, [ignore], [ignore]) + AT_CHECK_CONFIGURE +], [ + AT_CHECK([$EGREP 'not running autopoint because it is too old' stderr], + 0, [ignore], [ignore]) +]) + +AT_CLEANUP + ## ---------------------------------------------------- ## ## autoreconf --exclude (aclocal, automake, autoconf). ## @@ -2158,6 +2374,9 @@ AT_REQUIRE_ACLOCAL AT_REQUIRE_LIBTOOL +# This test needs autoreconf to *think* it needs to run libtoolize, +# otherwise the --exclude option won't have any effect. + AT_DATA([configure.ac], [[AC_INIT(GNU foo, 1.0) AC_CONFIG_MACRO_DIRS([m4]) @@ -2172,9 +2391,7 @@ ACLOCAL_AMFLAGS = -I m4 ]]) -# This test needs autoreconf to *think* it needs to run libtoolize. -# otherwise the --exclude option won't have any effect. See -# commentary in the 'Package requiring libtool' test for further +# See commentary in the 'Package requiring libtool' test for further # explanation of what this does. mkdir m4 @@ -2207,6 +2424,75 @@ AT_CLEANUP +## ----------------------------------- ## +## autoreconf --exclude (libtoolize). ## +## ----------------------------------- ## + +AT_SETUP([autoreconf --exclude (autopoint)]) +AT_KEYWORDS([autoreconf]) + +AT_REQUIRE_AUTOMAKE +AT_REQUIRE_ACLOCAL +AT_REQUIRE_AUTOPOINT + +# This test needs autoreconf to *think* it needs to run autopoint, +# otherwise the --exclude option won't have any effect. + +AT_DATA([configure.ac], +[[AC_INIT(GNU foo, 1.0) +AC_CONFIG_MACRO_DIRS([m4]) +AM_INIT_AUTOMAKE +AM_GNU_GETTEXT([external]) +# This is the oldest version of gettext.m4 that defines the +# AM_GNU_GETTEXT_VERSION macro. +AM_GNU_GETTEXT_VERSION([0.11.4]) + +AC_CONFIG_FILES([Makefile po/Makefile.in]) +AC_OUTPUT +]]) + + +AT_DATA([Makefile.am], +[[AUTOMAKE_OPTIONS = foreign +ACLOCAL_AMFLAGS = -I m4 +SUBDIRS = po +]]) + +mkdir m4 + +# This run will fail at the autoconf stage because there won't be any +# definition of AM_GNU_GETTEXT nor AM_GNU_GETTEXT_VERSION available. +AT_CHECK([autoreconf -Wall -v -i --exclude autopoint], 1, [ignore], [stderr]) +AT_CHECK([$EGREP 'not running autopoint' stderr], 0, [ignore], [ignore]) +AT_CHECK( + [$EGREP 'undefined or overquoted macro: AM_GNU_GETTEXT' stderr], + 0, [ignore], [ignore]) +AT_CHECK( + [$EGREP 'undefined or overquoted macro: AM_GNU_GETTEXT_VERSION' stderr], + 0, [ignore], [ignore]) + +# Create a fake gettext.m4 to get past the above failures. +AT_DATA([m4/gettext_stub.m4], +[[AC@&t@_DEFUN([AM_GNU_GETTEXT]) +AC@&t@_DEFUN([AM_GNU_GETTEXT_VERSION]) +]]) + +# Also create a fake po/Makefile.in.in. +mkdir po +AT_DATA([po/Makefile.in.in], +[[# stub +]]) + +# This run of autoreconf should succeed. +AT_CHECK([autoreconf -Wall -v -i --exclude autopoint], 0, [ignore], [stderr]) +AT_CHECK([$EGREP 'not running autopoint' stderr], 0, [ignore], [ignore]) + +# The stubbed-out macros should permit configure to run to completion. +AT_CHECK_CONFIGURE + +AT_CLEANUP + + ## ------------------------------ ## ## Specific warnings options. ## ## ------------------------------ ##