autoconf-patches
[Top][All Lists]
Advanced

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

AC_DEFINE_UNQUOTED doc update


From: Ralf Wildenhues
Subject: AC_DEFINE_UNQUOTED doc update
Date: Fri, 29 Apr 2005 11:50:44 +0200
User-agent: Mutt/1.4.1i

This patch was prompted by a bug report against libltdl.  It's not the
first or second time m4-underquoted arguments lead to really weird
failures.  

If you ask me for a personal opinion, this text in autoconf docs
(node: Autoconf Language):

|    When calling macros that take arguments, there must not be any blank
| space between the macro name and the open parenthesis.  Arguments should
| be enclosed within the M4 quote characters `[' and `]', and be
| separated by commas.  Any leading spaces in arguments are ignored,
| unless they are quoted.  You may safely leave out the quotes when the
| argument is simple text, but _always_ quote complex arguments such as
| other macro calls.

together with this example:

|      AC_CHECK_HEADER([stdio.h],
|                      [AC_DEFINE([HAVE_STDIO_H], [1],
|                         [Define to 1 if you have <stdio.h>.])],
|                      [AC_MSG_ERROR([Sorry, can't do anything for you])])
| 
| is quoted properly.  You may safely simplify its quotation to:
| 
|      AC_CHECK_HEADER(stdio.h,
|                      [AC_DEFINE(HAVE_STDIO_H, 1,
|                         Define to 1 if you have <stdio.h>.)],
|                      [AC_MSG_ERROR([Sorry, can't do anything for you])])

still strikes me as misleading and possible cause for a maintenance
nightmare, even with the good explanations afterwards.  The text does
not specify exactly what `simple text' in m4 context is, and I just
don't understand the reason against telling users to quote every
argument at least once.
/end personal opinion.


My patch does not contain the solution for the other AC_DEFINE_UNQUOTED
problem: the variable may not contain `[' or `]'.  I mean,

| foo='['
| AC_DEFINE_UNQUOTED([bar], ["$foo"], [bla])

will simply fail at autoconf time.  Matching brackets may be placed
there after doubling like this

| foo='bla [[blubb]]'
| AC_DEFINE_UNQUOTED([bar], [["$foo"]], [bla])

Can this be fixed (both the need for doubling in $foo removed and the
error with unbalanced quotes removed)?  If so, then the documentation
should also mention the need for double-m4-quoted second argument in
order to achieve this.

Regards,
Ralf

        * doc/autoconf.texi (Installation Directory Variables,
        Defining Symbols): M4-quote the second argument consistently.
        (External Software): No need for AC_DEFINE_UNQUOTED here.
        From bug reported against libtool by Dalibor Topic <address@hidden>.

Index: doc/autoconf.texi
===================================================================
RCS file: /cvsroot/autoconf/autoconf/doc/autoconf.texi,v
retrieving revision 1.888
diff -u -r1.888 autoconf.texi
--- doc/autoconf.texi   22 Apr 2005 06:37:25 -0000      1.888
+++ doc/autoconf.texi   29 Apr 2005 09:25:30 -0000
@@ -2424,7 +2424,7 @@
 A corollary is that you should not use these variables except in
 Makefiles.  For instance, instead of trying to evaluate @code{datadir}
 in @file{configure} and hard-coding it in Makefiles using
-e.g., @samp{AC_DEFINE_UNQUOTED(DATADIR, "$datadir", [Data directory.])},
+e.g., @samp{AC_DEFINE_UNQUOTED(DATADIR, ["$datadir"], [Data directory.])},
 you should add
 @samp{-DDATADIR="$(datadir)"} to your @code{CPPFLAGS}.
 
@@ -7242,14 +7242,15 @@
 (@samp{$}), command substitution (@samp{`}), and backslash escaping
 (@samp{\}).  Single and double quote characters in the value have no
 special meaning.  Use this macro instead of @code{AC_DEFINE} when
address@hidden or @var{value} is a shell variable.  Examples:
address@hidden or @var{value} is a shell variable, and make sure to
+m4-quote @var{value}.  Examples:
 
 @example
-AC_DEFINE_UNQUOTED(config_machfile, "$machfile",
+AC_DEFINE_UNQUOTED(config_machfile, ["$machfile"],
   [Configuration machine file.])
-AC_DEFINE_UNQUOTED(GETGROUPS_T, $ac_cv_type_getgroups,
+AC_DEFINE_UNQUOTED(GETGROUPS_T, [$ac_cv_type_getgroups],
   [getgroups return type.])
-AC_DEFINE_UNQUOTED($ac_tr_hdr, 1,
+AC_DEFINE_UNQUOTED([$ac_tr_hdr], 1,
   [Translated header name.])
 @end example
 @end defmac
@@ -13331,7 +13332,7 @@
 AS_IF([test "x$with_readline" != xno],
   [AC_CHECK_LIB(readline, main,
     [AC_SUBST(LIBREADLINE, "-lreadline -lncurses")
-     AC_DEFINE_UNQUOTED(HAVE_LIBREADLINE, 1, [Define if you have libreadline])
+     AC_DEFINE(HAVE_LIBREADLINE, 1, [Define if you have libreadline])
     ],
     [if test "x$with_readline" != xcheck; then
        AC_MSG_FAILURE([--with-readline was given, but test for readline 
failed])




reply via email to

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