bug-autoconf
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Names of m4 builtin cannot be safely used in package name in AC_INIT


From: Eric Blake
Subject: Re: Names of m4 builtin cannot be safely used in package name in AC_INIT
Date: Wed, 16 Mar 2011 18:12:14 -0600
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.13) Gecko/20101209 Fedora/3.1.7-0.35.b3pre.fc14 Lightning/1.0b3pre Mnenhy/0.8.3 Thunderbird/3.1.7

On 03/15/2011 03:41 AM, Stefano Lattarini wrote:
> For example:
> 
>  $ echo 'AC_INIT([changequote], [1.0])' > configure.ac
>  $ autoconf --force
>  /usr/bin/m4:configure.ac:1: recursion limit of 1024 exceeded, use -L<N> to 
> change it
>  autom4te: /usr/bin/m4 failed with exit status: 1
> 
> and even:
> 
>  $ echo 'AC_INIT([perl-changequote-helper], [1.0])' > configure.ac
>  $ autoconf --force
>  /usr/bin/m4:configure.ac:1: recursion limit of 1024 exceeded, use -L<N> to 
> change it
>  autom4te: /usr/bin/m4 failed with exit status: 1
> 
> Both have been tested with autoconf 2.68, 2.65 and 2.62: the failures
> above are always present.
> 
> The attached script (to be run in a temporary directory!) should help
> generating a list of all builtins that are problematic in this regards.
> JFTR, this is the result with autoconf 2.68:
> 
>   changecom changequote debugfile define divert divnum errprint eval
>   include index len mkstemp popdef pushdef shift sinclude substr syscmd
>   sysval traceoff traceon undefine undivert

Thanks for the report.  I'm still not finished, but here's what I have
so far (there was definitely some insufficient quoting).  It was enough
to make:

$ echo 'm4_define([aa],[OOPS])AC_INIT([B-aa-B],[1,0])' > configure.ac
$ autoconf --force

produce a configure without any "oops" (so it appears to fix the quoting
problems), but the test is still failing (don't know where I'm going
wrong there, yet).  When it comes to debugging insufficient quoting, it
is much easier to use simple variables (like aa above) than m4 builtins
(with catastrophic consequences) :)

diff --git i/ChangeLog w/ChangeLog
index 30dfced..482e6f5 100644
--- i/ChangeLog
+++ w/ChangeLog
@@ -1,3 +1,15 @@
+2011-03-16  Eric Blake  <address@hidden>
+
+       AC_INIT: properly quote package name containing m4 macro
+       * lib/autoconf/general.m4 (_AC_INIT_PACKAGE): Don't expand $1.
+       (_AC_INIT_NOTICE, _AC_INIT_DEFAULTS, _AC_INIT_HELP)
+       (_AC_INIT_VERSION, _AC_INIT_CONFIG_LOG): Don't expand
+       AC_PACKAGE_*.
+       * lib/autoconf/headers.m4 (_AC_CHECK_HEADER_MONGREL_BODY):
+       Likewise.
+       * lib/autoconf/status.m4 (_AC_OUTPUT_CONFIG_STATUS): Likewise.
+       Reported by Stefano Lattarini.
+
 2011-03-08  Colin Watson  <address@hidden>  (tiny change)
            Ralf Wildenhues  <address@hidden>

diff --git i/lib/autoconf/general.m4 w/lib/autoconf/general.m4
index dd20e71..687c6e7 100644
--- i/lib/autoconf/general.m4
+++ w/lib/autoconf/general.m4
@@ -241,12 +241,10 @@ _AC_INIT_LITERAL([$3])
 m4_ifndef([AC_PACKAGE_NAME],
          [m4_define([AC_PACKAGE_NAME],     [$1])])
 m4_ifndef([AC_PACKAGE_TARNAME],
-         [m4_define([AC_PACKAGE_TARNAME],
-                    m4_default([$4],
-                               [m4_bpatsubst(m4_tolower(m4_bpatsubst([[$1]],
-                                                                    [GNU ])),
-                                [[^_abcdefghijklmnopqrstuvwxyz0123456789]],
-                                [-])]))])
+  [m4_define([AC_PACKAGE_TARNAME],
+    m4_if([$4], [],
+      [m4_translit(_AS_TR_SH_LITERAL(m4_bpatsubst([[[$1]]],
+       [^\(..\)GNU ], [\1])), [_A-Z], [-a-z])], [[$4]]))])
 m4_ifndef([AC_PACKAGE_VERSION],
          [m4_define([AC_PACKAGE_VERSION],   [$2])])
 m4_ifndef([AC_PACKAGE_STRING],
@@ -341,12 +339,12 @@ m4_define([_AC_INIT_NOTICE],
 [m4_divert_text([HEADER-COMMENT],
 address@hidden:@ Guess values for system-dependent variables and create 
Makefiles.
 @%:@ Generated by m4_PACKAGE_STRING[]dnl
-m4_ifset([AC_PACKAGE_STRING], [ for AC_PACKAGE_STRING]).])
+m4_ifset([AC_PACKAGE_STRING], [ for m4_defn([AC_PACKAGE_STRING])]).])

 m4_ifset([AC_PACKAGE_BUGREPORT],
         [m4_divert_text([HEADER-COMMENT],
                         address@hidden:@
address@hidden:@ Report bugs to <AC_PACKAGE_BUGREPORT>.])])
address@hidden:@ Report bugs to <m4_defn([AC_PACKAGE_BUGREPORT])>.])])
 ])


@@ -415,17 +413,17 @@ AC_SUBST([PATH_SEPARATOR])dnl

 # Identity of this package.
 AC_SUBST([PACKAGE_NAME],
-        [m4_ifdef([AC_PACKAGE_NAME],      ['AC_PACKAGE_NAME'])])dnl
+  [m4_ifdef([AC_PACKAGE_NAME],      ['m4_defn([AC_PACKAGE_NAME])'])])dnl
 AC_SUBST([PACKAGE_TARNAME],
-        [m4_ifdef([AC_PACKAGE_TARNAME],   ['AC_PACKAGE_TARNAME'])])dnl
+  [m4_ifdef([AC_PACKAGE_TARNAME],   ['m4_defn([AC_PACKAGE_TARNAME])'])])dnl
 AC_SUBST([PACKAGE_VERSION],
-        [m4_ifdef([AC_PACKAGE_VERSION],   ['AC_PACKAGE_VERSION'])])dnl
+  [m4_ifdef([AC_PACKAGE_VERSION],   ['m4_defn([AC_PACKAGE_VERSION])'])])dnl
 AC_SUBST([PACKAGE_STRING],
-        [m4_ifdef([AC_PACKAGE_STRING],    ['AC_PACKAGE_STRING'])])dnl
+  [m4_ifdef([AC_PACKAGE_STRING],    ['m4_defn([AC_PACKAGE_STRING])'])])dnl
 AC_SUBST([PACKAGE_BUGREPORT],
-        [m4_ifdef([AC_PACKAGE_BUGREPORT], ['AC_PACKAGE_BUGREPORT'])])dnl
+  [m4_ifdef([AC_PACKAGE_BUGREPORT],
['m4_defn([AC_PACKAGE_BUGREPORT])'])])dnl
 AC_SUBST([PACKAGE_URL],
-        [m4_ifdef([AC_PACKAGE_URL],       ['AC_PACKAGE_URL'])])dnl
+  [m4_ifdef([AC_PACKAGE_URL],       ['m4_defn([AC_PACKAGE_URL])'])])dnl

 m4_divert_pop([DEFAULTS])dnl
 m4_wrap_lifo([m4_divert_text([DEFAULTS],
@@ -1019,7 +1017,7 @@ if test "$ac_init_help" = "long"; then
   # This message is too long to be a string in the A/UX 3.1 sh.
   cat <<_ACEOF
 \`configure' configures m4_ifset([AC_PACKAGE_STRING],
-                       [AC_PACKAGE_STRING],
+                       [m4_defn([AC_PACKAGE_STRING])],
                        [this package]) to adapt to many kinds of systems.

 Usage: $[0] [[OPTION]]... [[VAR=VALUE]]...
@@ -1070,7 +1068,7 @@ Fine tuning of the installation directories:
   --mandir=DIR            man documentation [DATAROOTDIR/man]
 ]AS_HELP_STRING([--docdir=DIR],
   [documentation root ]@<:@DATAROOTDIR/doc/m4_ifset([AC_PACKAGE_TARNAME],
-    [AC_PACKAGE_TARNAME], [PACKAGE])@:>@)[
+    [m4_defn([AC_PACKAGE_TARNAME])], [PACKAGE])@:>@)[
   --htmldir=DIR           html documentation [DOCDIR]
   --dvidir=DIR            dvi documentation [DOCDIR]
   --pdfdir=DIR            pdf documentation [DOCDIR]
@@ -1108,16 +1106,17 @@ fi
 if test -n "$ac_init_help"; then
 m4_ifset([AC_PACKAGE_STRING],
 [  case $ac_init_help in
-     short | recursive ) echo "Configuration of AC_PACKAGE_STRING:";;
+     short | recursive ) echo "Configuration of
m4_defn([AC_PACKAGE_STRING]):";;
    esac])
   cat <<\_ACEOF
 m4_divert_pop([HELP_ENABLE])dnl
 m4_divert_push([HELP_END])dnl

-Report bugs to m4_ifset([AC_PACKAGE_BUGREPORT], [<AC_PACKAGE_BUGREPORT>],
+Report bugs to m4_ifset([AC_PACKAGE_BUGREPORT],
+  [<m4_defn([AC_PACKAGE_BUGREPORT])>],
   [the package provider]).dnl
 m4_ifdef([AC_PACKAGE_NAME], [m4_ifset([AC_PACKAGE_URL], [
-AC_PACKAGE_NAME home page: <AC_PACKAGE_URL>.])dnl
+m4_defn([AC_PACKAGE_NAME]) home page: <m4_defn([AC_PACKAGE_URL])>.])dnl
 m4_if(m4_index(m4_defn([AC_PACKAGE_NAME]), [GNU ]), [0], [
 General help using GNU software: <http://www.gnu.org/gethelp/>.])])
 _ACEOF
@@ -1158,8 +1157,8 @@ m4_define([_AC_INIT_VERSION],
 [m4_divert_text([VERSION_BEGIN],
 [if $ac_init_version; then
   cat <<\_ACEOF
-m4_ifset([AC_PACKAGE_NAME], [AC_PACKAGE_NAME ])configure[]dnl
-m4_ifset([AC_PACKAGE_VERSION], [ AC_PACKAGE_VERSION])
+m4_ifset([AC_PACKAGE_NAME], [m4_defn([AC_PACKAGE_NAME]) ])configure[]dnl
+m4_ifset([AC_PACKAGE_VERSION], [ m4_defn([AC_PACKAGE_VERSION])])
 generated by m4_PACKAGE_STRING])
 m4_divert_text([VERSION_END],
 [_ACEOF
@@ -1178,8 +1177,9 @@ cat >config.log <<_ACEOF
 This file contains any messages produced by compilers while
 running configure, to aid debugging if configure makes a mistake.

-It was created by m4_ifset([AC_PACKAGE_NAME], [AC_PACKAGE_NAME ])dnl
-$as_me[]m4_ifset([AC_PACKAGE_VERSION], [ AC_PACKAGE_VERSION]), which was
+It was created by m4_ifset([AC_PACKAGE_NAME],
[m4_defn([AC_PACKAGE_NAME]) ])dnl
+$as_me[]m4_ifset([AC_PACKAGE_VERSION],
+ [ m4_defn([AC_PACKAGE_VERSION])]), which was
 generated by m4_PACKAGE_STRING.  Invocation command line was

   $ $[0] address@hidden
diff --git i/lib/autoconf/headers.m4 w/lib/autoconf/headers.m4
index 4b02832..5e315ae 100644
--- i/lib/autoconf/headers.m4
+++ w/lib/autoconf/headers.m4
@@ -107,7 +107,7 @@ case
$ac_header_compiler:$ac_header_preproc:$ac_[]_AC_LANG_ABBREV[]_preproc_warn
     AC_MSG_WARN([$[]2:     section "Present But Cannot Be Compiled"])
     AC_MSG_WARN([$[]2: proceeding with the compiler's result])
 m4_ifset([AC_PACKAGE_BUGREPORT],
-[m4_n([( AS_BOX([Report this to ]AC_PACKAGE_BUGREPORT)
+[m4_n([( AS_BOX([Report this to ]m4_defn([AC_PACKAGE_BUGREPORT]))
      ) | sed "s/^/$as_me: WARNING:     /" >&2])])dnl
     ;;
 esac
diff --git i/lib/autoconf/status.m4 w/lib/autoconf/status.m4
index 46a0341..46155bd 100644
--- i/lib/autoconf/status.m4
+++ w/lib/autoconf/status.m4
@@ -1335,8 +1335,9 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
 # report actual input values of CONFIG_FILES etc. instead of their
 # values after options handling.
 ac_log="
-This file was extended by m4_ifset([AC_PACKAGE_NAME], [AC_PACKAGE_NAME
])dnl
-$as_me[]m4_ifset([AC_PACKAGE_VERSION], [ AC_PACKAGE_VERSION]), which was
+This file was extended by m4_ifset([AC_PACKAGE_NAME],
+ [m4_defn([AC_PACKAGE_NAME]) ])$as_me[]m4_ifset([AC_PACKAGE_VERSION],
+ [ m4_defn([AC_PACKAGE_VERSION])]), which was
 generated by m4_PACKAGE_STRING.  Invocation command line was

   CONFIG_FILES    = $CONFIG_FILES
@@ -1423,10 +1424,11 @@ m4_ifdef([_AC_SEEN_CONFIG(COMMANDS)],
 $config_commands

 ])dnl
-Report bugs to m4_ifset([AC_PACKAGE_BUGREPORT], [<AC_PACKAGE_BUGREPORT>],
+Report bugs to m4_ifset([AC_PACKAGE_BUGREPORT],
+  [<m4_defn([AC_PACKAGE_BUGREPORT])>],
   [the package provider]).dnl
 m4_ifdef([AC_PACKAGE_NAME], [m4_ifset([AC_PACKAGE_URL], [
-AC_PACKAGE_NAME home page: <AC_PACKAGE_URL>.])dnl
+m4_defn([AC_PACKAGE_NAME]) home page: <m4_defn([AC_PACKAGE_URL])>.])dnl
 m4_if(m4_index(m4_defn([AC_PACKAGE_NAME]), [GNU ]), [0], [
 General help using GNU software: <http://www.gnu.org/gethelp/>.])])"

@@ -1434,8 +1436,8 @@ _ACEOF
 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
 ac_cs_config="`AS_ECHO(["$ac_configure_args"]) | sed 's/^ //;
s/[[\\""\`\$]]/\\\\&/g'`"
 ac_cs_version="\\
-m4_ifset([AC_PACKAGE_NAME], [AC_PACKAGE_NAME ])config.status[]dnl
-m4_ifset([AC_PACKAGE_VERSION], [ AC_PACKAGE_VERSION])
+m4_ifset([AC_PACKAGE_NAME], [m4_defn([AC_PACKAGE_NAME])
])config.status[]dnl
+m4_ifset([AC_PACKAGE_VERSION], [ m4_defn([AC_PACKAGE_VERSION])])
 configured by $[0], generated by m4_PACKAGE_STRING,
   with options \\"\$ac_cs_config\\"

diff --git i/tests/tools.at w/tests/tools.at
index 0ccb387..1e57bd4 100644
--- i/tests/tools.at
+++ w/tests/tools.at
@@ -1335,3 +1335,16 @@ END
 done

 AT_CLEANUP
+
+# package with m4 macro in name
+# -----------------------------
+
+AT_SETUP([package with m4 macro in name])
+
+AT_DATA_M4SH([configure.ac],
+[[AC_INIT([perl-changequote-helper], [1.0])
+]])
+
+AT_CHECK_AUTOCONF
+
+AT_CLEANUP



-- 
Eric Blake   address@hidden    +1-801-349-2682
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]