bug-autoconf
[Top][All Lists]
Advanced

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

Bug #593838: AX_CFLAGS_GCC_OPTION misuses AS_VAR_PUSHDEF variable


From: Ben Pfaff
Subject: Bug #593838: AX_CFLAGS_GCC_OPTION misuses AS_VAR_PUSHDEF variable
Date: Sat, 25 Sep 2010 11:22:40 -0700
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.2 (gnu/linux)

retitle 593838 AX_CFLAGS_GCC_OPTION misuses AS_VAR_PUSHDEF variable
reassign 593838 autoconf-archive
thanks

Jerome BENOIT <address@hidden> initially reported that
AX_CFLAGS_GCC_OPTION(-std=c99) fails with Autoconf 2.67.  Vincent
Bernat <address@hidden> determined that the bug could be fixed
by replacing a literal shell assignment by AS_VAR_SET.

Just now, I took a closer look.  I was able to reduce the problem
to the following trivial case:

--8<--------------------------cut here-------------------------->8--
AC_DEFUN([MY_MACRO], 
  [AS_VAR_PUSHDEF([VAR],[prefix_$1])

   dnl This is the version used by AX_CFLAGS_GCC_OPTION.
   dnl I believe that it is incorrect.  It does not work on Autoconf >= 2.67.
   VAR=the_value

   dnl This version works.
   dnl AS_VAR_SET([VAR], [the_value])

   AS_VAR_POPDEF([VAR])])

AC_INIT
MY_MACRO([a=b])
--8<--------------------------cut here-------------------------->8--

If I comment out the first version and uncomment the second
version, it works.

The documentation in the Autoconf manual for AS_VAR_PUSHDEF says
this:

 -- Macro: AS_VAR_PUSHDEF (M4-NAME, VALUE)
 -- Macro: AS_VAR_POPDEF (M4-NAME)
     A common M4sh idiom involves composing shell variable names from
     an m4 argument (for example, writing a macro that uses a cache
     variable).  VALUE can be an arbitrary string, which will be
     transliterated into a valid shell name by `AS_TR_SH'.  In order to
     access the composed variable name based on VALUE, it is easier to
     declare a temporary m4 macro M4-NAME with `AS_VAR_PUSHDEF', then
     use that macro as the argument to subsequent `AS_VAR' macros as a
     polymorphic variable name, and finally free the temporary macro
     with `AS_VAR_POPDEF'.  These macros are often followed with `dnl',
     to avoid excess newlines in the output.

     Here is an involved example, that shows the power of writing
     macros that can handle composed shell variable names:

          m4_define([MY_CHECK_HEADER],
          [AS_VAR_PUSHDEF([my_Header], [ac_cv_header_$1])dnl
          AS_VAR_IF([my_Header], [yes], [echo "header $1 available"])dnl
          AS_VAR_POPDEF([my_Header])dnl
          ])
          MY_CHECK_HEADER([stdint.h])
          for header in inttypes.h stdlib.h ; do
            MY_CHECK_HEADER([$header])
          done

This description says one may "use that macro as the argument to
subsequent `AS_VAR' macros as a polymorphic variable name", not
that one may use the M4-NAME literally.  The example that it
gives also shows the specific M4-NAME of my_Header used only as
a polymorphic variable argument, not as a literal shell variable.

On that basis, I infer that one is not supposed to use the
M4-NAME literally, and thus I believe that this is a bug in
AX_CFLAGS_GCC_OPTION.  So, I am reassigning this bug to
autoconf-archive (with this email).

If I am making any bad assumptions here, please correct me.

Thanks,

Ben.
-- 
Ben Pfaff 
http://benpfaff.org



reply via email to

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