bug-autoconf
[Top][All Lists]
Advanced

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

Re: autoconf 2.61: AC_DEFINE variable with parenthesis


From: Paul Eggert
Subject: Re: autoconf 2.61: AC_DEFINE variable with parenthesis
Date: Fri, 15 Dec 2006 10:35:37 -0800
User-agent: Gnus/5.1008 (Gnus v5.10.8) Emacs/21.4 (gnu/linux)

Andrey Simonenko <address@hidden> writes:

> AC_DEFINE([DEF(x)], [somevalue])

Ouch!  That's not supported, and I'm surprised you got it to work as
well as it did.

First things first: we have to clarify the documentation to make it
clearer that this isn't supposed to work, and add a warning in case
someone tries to do it anyway.  I installed the following.

2006-12-15  Paul Eggert  <address@hidden>

        This change prompted by a problem report by Andrey Simonenko in
        <http://lists.gnu.org/archive/html/bug-autoconf/2006-12/msg00026.html>.
        * doc/autoconf.texi (Defining Symbols): AC_DEFINE works for
        object-like macros only, in the traditional portable character
        set.
        * lib/autoconf/general.m4 (AC_DEFINE_TRACE_LITERAL):
        Warn about attempts to define things that are not identifiers.
        * lib/autoconf/fortran.m4 (_AC_FC_WRAPPERS): Rewrite to avoid
        awful hack that AC_DEFINEd macro names containing parentheses.

Index: doc/autoconf.texi
===================================================================
RCS file: /cvsroot/autoconf/autoconf/doc/autoconf.texi,v
retrieving revision 1.1118
diff -u -r1.1118 autoconf.texi
--- doc/autoconf.texi   12 Dec 2006 17:53:13 -0000      1.1118
+++ doc/autoconf.texi   15 Dec 2006 18:24:47 -0000
@@ -8250,7 +8250,9 @@
 @defmac AC_DEFINE (@var{variable}, @var{value}, @ovar{description})
 @defmacx AC_DEFINE (@var{variable})
 @acindex{DEFINE}
-Define the C preprocessor variable @var{variable} to @var{value} (verbatim).
+Define @var{variable} to @var{value} (verbatim), by defining a C
+object-like macro for @var{variable}.  @var{variable} should be a C
+identifier that contains only letters, digits, and underscores.
 @var{value} should not contain literal newlines, and if you are not
 using @code{AC_CONFIG_HEADERS} it should not contain any @samp{#}
 characters, as @command{make} tends to eat them.  To use a shell variable,
Index: lib/autoconf/general.m4
===================================================================
RCS file: /cvsroot/autoconf/autoconf/lib/autoconf/general.m4,v
retrieving revision 1.942
diff -u -r1.942 general.m4
--- lib/autoconf/general.m4     6 Dec 2006 21:17:48 -0000       1.942
+++ lib/autoconf/general.m4     15 Dec 2006 18:24:47 -0000
@@ -1951,7 +1951,10 @@
 # -------------------------------------------
 # Used by --trace to collect the list of AC_DEFINEd macros.
 m4_define([AC_DEFINE_TRACE_LITERAL],
-[m4_pattern_allow([^$1$])])
+[m4_pattern_allow([^$1$])dnl
+m4_bmatch([$1], ^m4_defn([m4_re_word])$, [],
+  [m4_warn([syntax], [AC_DEFINE: not an identifier: $1])])dnl
+])# AC_DEFINE_TRACE_LITERAL


 # AC_DEFINE_TRACE(CPP-SYMBOL)
Index: lib/autoconf/fortran.m4
===================================================================
RCS file: /cvsroot/autoconf/autoconf/lib/autoconf/fortran.m4,v
retrieving revision 1.214
retrieving revision 1.216
diff -p -u -r1.214 -r1.216
--- lib/autoconf/fortran.m4     17 Nov 2006 21:04:54 -0000      1.214
+++ lib/autoconf/fortran.m4     15 Dec 2006 18:34:20 -0000      1.216
@@ -1033,40 +1033,82 @@ AC_LANG_POP(Fortran)dnl
 # scheme used by the Fortran compiler.
 AC_DEFUN([_AC_FC_WRAPPERS],
 [_AC_FORTRAN_ASSERT()dnl
-AH_TEMPLATE(_AC_FC[_FUNC],
-    [Define to a macro mangling the given C identifier (in lower and upper
-     case), which must not contain underscores, for linking with Fortran.])dnl
-AH_TEMPLATE(_AC_FC[_FUNC_],
-    [As ]_AC_FC[_FUNC, but for C identifiers containing underscores.])dnl
 case $ac_cv_[]_AC_LANG_ABBREV[]_mangling in
-  "lower case, no underscore, no extra underscore")
-          AC_DEFINE(_AC_FC[_FUNC(name,NAME)],  [name])
-          AC_DEFINE(_AC_FC[_FUNC_(name,NAME)], [name]) ;;
-  "lower case, no underscore, extra underscore")
-          AC_DEFINE(_AC_FC[_FUNC(name,NAME)],  [name])
-          AC_DEFINE(_AC_FC[_FUNC_(name,NAME)], [name ## _]) ;;
-  "lower case, underscore, no extra underscore")
-          AC_DEFINE(_AC_FC[_FUNC(name,NAME)],  [name ## _])
-          AC_DEFINE(_AC_FC[_FUNC_(name,NAME)], [name ## _]) ;;
-  "lower case, underscore, extra underscore")
-          AC_DEFINE(_AC_FC[_FUNC(name,NAME)],  [name ## _])
-          AC_DEFINE(_AC_FC[_FUNC_(name,NAME)], [name ## __]) ;;
-  "upper case, no underscore, no extra underscore")
-          AC_DEFINE(_AC_FC[_FUNC(name,NAME)],  [NAME])
-          AC_DEFINE(_AC_FC[_FUNC_(name,NAME)], [NAME]) ;;
-  "upper case, no underscore, extra underscore")
-          AC_DEFINE(_AC_FC[_FUNC(name,NAME)],  [NAME])
-          AC_DEFINE(_AC_FC[_FUNC_(name,NAME)], [NAME ## _]) ;;
-  "upper case, underscore, no extra underscore")
-          AC_DEFINE(_AC_FC[_FUNC(name,NAME)],  [NAME ## _])
-          AC_DEFINE(_AC_FC[_FUNC_(name,NAME)], [NAME ## _]) ;;
-  "upper case, underscore, extra underscore")
-          AC_DEFINE(_AC_FC[_FUNC(name,NAME)],  [NAME ## _])
-          AC_DEFINE(_AC_FC[_FUNC_(name,NAME)], [NAME ## __]) ;;
+  'lower case, no underscore, extra underscore' | \
+  'lower case, underscore, no extra underscore' | \
+  'lower case, underscore, extra underscore' | \
+  'upper case, no underscore, no extra underscore' | \
+  'upper case, no underscore, extra underscore' | \
+  'upper case, underscore, no extra underscore' | \
+  'upper case, underscore, extra underscore') ;;
   *)
           AC_MSG_WARN([unknown Fortran name-mangling scheme])
           ;;
 esac
+case $ac_cv_[]_AC_LANG_ABBREV[]_mangling in #(
+  'upper case',*,)
+     AC_DEFINE(_AC_FC[_UPPER_CASE], 1,
+       [Define to 1 if upper case spelling should be used.]);;
+esac
+case $ac_cv_[]_AC_LANG_ABBREV[]_mangling in #(
+  *,' underscore',*)
+     AC_DEFINE(_AC_FC[_UNDERSCORE], 1,
+       [Define to 1 if an underscore should be appended.]);;
+esac
+case $ac_cv_[]_AC_LANG_ABBREV[]_mangling in #(
+  *,*,' extra underscore')
+     AC_DEFINE(_AC_FC[_EXTRA_UNDERSCORE], 1,
+       [Define to 1 if an extra underscore should be appended.]);;
+esac
+AH_VERBATIM(_AC_FC[_FUNC],
+[/* Define to 1 if upper case spelling should be used. */
+#undef ]_AC_FC[_UPPER_CASE
+
+/* Define to 1 if an underscore should be appended. */
+#undef ]_AC_FC[_UNDERSCORE
+
+/* Define to 1 if an extra underscore should be appended. */
+#undef ]_AC_FC[_EXTRA_UNDERSCORE
+
+/* Define to a macro mangling the given C identifier (in lower and upper
+   case), which must not contain underscores, for linking with Fortran.  */
+#ifdef ]_AC_FC[_UPPER_CASE
+# ifdef ]_AC_FC[_UNDERSCORE
+#  ifdef ]_AC_FC[_EXTRA_UNDERSCORE
+#   define ]_AC_FC[_FUNC(name, NAME)   NAME ## _
+#   define ]_AC_FC[_FUNC_(name, NAME)  NAME ## __
+#  else
+#   define ]_AC_FC[_FUNC(name, NAME)   NAME ## _
+#   define ]_AC_FC[_FUNC_(name, NAME)  NAME ## _
+#  endif
+# else
+#  ifdef ]_AC_FC[_EXTRA_UNDERSCORE
+#   define ]_AC_FC[_FUNC(name, NAME)   NAME
+#   define ]_AC_FC[_FUNC_(name, NAME)  NAME ## _
+#  else
+#   define ]_AC_FC[_FUNC(name, NAME)   NAME
+#   define ]_AC_FC[_FUNC_(name, NAME)  NAME
+#  endif
+# endif
+#else
+# ifdef ]_AC_FC[_UNDERSCORE
+#  ifdef ]_AC_FC[_EXTRA_UNDERSCORE
+#   define ]_AC_FC[_FUNC(name, NAME)   name ## _
+#   define ]_AC_FC[_FUNC_(name, NAME)  name ## __
+#  else
+#   define ]_AC_FC[_FUNC(name, NAME)   name ## _
+#   define ]_AC_FC[_FUNC_(name, NAME)  name ## _
+#  endif
+# else
+#  ifdef ]_AC_FC[_EXTRA_UNDERSCORE
+#   define ]_AC_FC[_FUNC(name, NAME)   name
+#   define ]_AC_FC[_FUNC_(name, NAME)  name ## _
+#  else
+#   define ]_AC_FC[_FUNC(name, NAME)   name
+#   define ]_AC_FC[_FUNC_(name, NAME)  name
+#  endif
+# endif
+#endif])
 ])# _AC_FC_WRAPPERS
 
 




reply via email to

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