autoconf-patches
[Top][All Lists]
Advanced

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

Re: Problem with cl and autoconf


From: Paul Eggert
Subject: Re: Problem with cl and autoconf
Date: Wed, 23 Feb 2005 15:27:42 -0800
User-agent: Gnus/5.1006 (Gnus v5.10.6) Emacs/21.4 (gnu/linux)

Alexandre Duret-Lutz <address@hidden> writes:

> Here we go.  Your old patch + doc + trivial test case for the
> syntax in the doc.

Thanks!  I did some minor editing (notably, I renamed AS_STDIN_FD to
AS_ORIGINAL_STDIN_FD) and installed the following patch:

2005-02-23  Paul Eggert  <address@hidden>
            Alexandre Duret-Lutz  <address@hidden>

        * lib/autoconf/general.m4 (_AC_INIT_DEFAULTS): Redirect stdin from
        /dev/null, as "configure" shouldn't read stdin, and this insulates
        us from problems (e.g., when testing for "cl").  Also, do this
        redirection before invoking "hostname" or "uname", and keep the
        original input stream available via...
        (AS_ORIGINAL_STDIN_FD): ... this new macro.
        (_AC_PREPROC_IFELSE, _AC_COMPILE_IFELSE, _AC_LINK_IFELSE): Don't
        bother with "</dev/null" since it's now done at the top of
        'configure'.
        * lib/autoconf/c.m4 (AC_PROG_CC, AC_PROG_CXX): Likewise.
        * lib/autoconf/fortran.m4 (_AC_PROG_FC): Likewise.
        * lib/autoconf/programs.m4 (_AC_PATH_PROG_FLAVOR_GNU): Likewise.
        * doc/autoconf.texi (File Descriptor Macros): New section.
        (Printing Messages): Mention it.
        * tests/base.at (Input/Output): New test.

Index: NEWS
===================================================================
RCS file: /cvsroot/autoconf/autoconf/NEWS,v
retrieving revision 1.336
diff -p -u -r1.336 NEWS
--- NEWS        5 Feb 2005 07:58:43 -0000       1.336
+++ NEWS        23 Feb 2005 23:23:52 -0000
@@ -1,5 +1,11 @@
 * Major changes in Autoconf 2.59c
 
+** The configure command now redirects standard input from /dev/null,
+  to help avoid problems with subsidiary commands that might mistakenly
+  read standard input.  AS_ORIGINAL_STDIN_FD points to the original
+  standard input before this redirection, if you really want configure to
+  read from standard input.
+
 ** Directory variables adjusted to recent changes in the GNU Coding Standards.
   The following directory variables are new:
 
Index: doc/autoconf.texi
===================================================================
RCS file: /cvsroot/autoconf/autoconf/doc/autoconf.texi,v
retrieving revision 1.879
diff -p -u -r1.879 autoconf.texi
--- doc/autoconf.texi   15 Feb 2005 06:40:21 -0000      1.879
+++ doc/autoconf.texi   23 Feb 2005 23:23:53 -0000
@@ -333,7 +333,7 @@ Existing Tests
 * Declarations::                Declarations that may be missing
 * Structures::                  Structures or members that might be missing
 * Types::                       Types that might be missing
-* Compilers and Preprocessors:: Checking for compiling programs
+* Compilers and Preprocessors::  Checking for compiling programs
 * System Services::             Operating system services
 * Posix Variants::              Special kludges for specific Posix variants
 
@@ -418,6 +418,7 @@ Programming in M4
 * Using autom4te::              The Autoconf executables backbone
 * Programming in M4sugar::      Convenient pure M4 macros
 * Programming in M4sh::         Common shell Constructs
+* File Descriptor Macros::      File descriptor macros for input and output
 
 M4 Quotation
 
@@ -2167,7 +2168,7 @@ how to check the results of previous tes
 @ovindex ECHO_C
 @ovindex ECHO_N
 @ovindex ECHO_T
-How does one suppress the trailing newline from @code{echo} for
+How does one suppress the trailing newline from @command{echo} for
 question-answer message pairs?  These variables provide a way:
 
 @example
@@ -2177,7 +2178,7 @@ echo "address@hidden@}dead."
 @end example
 
 @noindent
-Some old and uncommon @code{echo} implementations offer no means to
+Some old and uncommon @command{echo} implementations offer no means to
 achieve this, in which case @code{ECHO_T} is set to tab.  You might not
 want to use it.
 @end defvar
@@ -3143,7 +3144,7 @@ Symbols}, for how to get those symbol de
 * Types::                       Types that might be missing
 * Compilers and Preprocessors::  Checking for compiling programs
 * System Services::             Operating system services
-* Posix Variants::               Special kludges for specific Posix variants
+* Posix Variants::              Special kludges for specific Posix variants
 @end menu
 
 @node Common Behavior
@@ -7650,11 +7651,13 @@ for each kind.  The arguments to all of 
 double quotes, so the shell performs variable and back-quote
 substitution on them.
 
-These macros are all wrappers around the @code{echo} shell command.
address@hidden scripts should rarely need to run @code{echo} directly
+These macros are all wrappers around the @command{echo} shell command,
+and will direct output to the appropriate file descriptor (@pxref{File
+Descriptor Macros}).
address@hidden scripts should rarely need to run @command{echo} directly
 to print messages for the user.  Using these macros makes it easy to
 change how and when each kind of message is printed; such changes need
-only be made to the macro definitions and all of the callers will change
+only be made to the macro definitions and all the callers will change
 automatically.
 
 To diagnose static issues, i.e., when @command{autoconf} is run, see
@@ -7752,6 +7755,7 @@ and their interface might change in the 
 * Using autom4te::              The Autoconf executables backbone
 * Programming in M4sugar::      Convenient pure M4 macros
 * Programming in M4sh::         Common shell Constructs
+* File Descriptor Macros::      File descriptor macros for input and output
 @end menu
 
 @node M4 Quotation
@@ -8901,6 +8905,68 @@ optimizing the common cases (@var{dir} o
 @end defmac
 
 
address@hidden File Descriptor Macros
address@hidden File Descriptor Macros
address@hidden input
address@hidden standard input
address@hidden file descriptors
address@hidden descriptors
address@hidden low-level output
address@hidden output, low-level
+
+The following macros define file descriptors used to output messages
+(or input values) from @file{configure} scripts.
+For example:
+
address@hidden
+echo "$wombats found" >&AS_MESSAGE_LOG_FD
+echo 'Enter desired kangaroo count:' >&AS_MESSAGE_FD
+read kangaroos <&AS_ORIGINAL_STDIN_FD`
address@hidden example
+
address@hidden
+However doing so is seldom needed, because Autoconf provides higher
+level macros as described below.
+
address@hidden AS_MESSAGE_FD
address@hidden
+The file descriptor for @samp{checking for...}  messages and results.
+Normally this directs messages to the standard output, however when
address@hidden is run with the @code{-q} option, messages sent to
address@hidden will be discarded.
+
+If you want to display some messages, consider using one of the printing
+macros (@pxref{Printing Messages}) instead.  Copies of messages output
+via these macros will additionally be recorded in @file{config.log}.
address@hidden defmac
+
address@hidden AS_MESSAGE_LOG_FD
address@hidden
+
+The file descriptor for messages logged to @file{config.log}.  Macros
+that run tools, like @code{AC_COMPILE_IFELSE} (@pxref{Running the
+Compiler}), redirect all output to this descriptor.  You may want to do
+so if you develop such a low-level macro.
address@hidden defmac
+
address@hidden AS_ORIGINAL_STDIN_FD
address@hidden
+The file descriptor for the original standard input.
+
+When @command{configure} runs, it may accidentally execute an
+interactive command that has the same name as the non-interactive meant
+to be used or checked.  If the standard input was the terminal, such
+interactive programs would cause @command{configure} to stop, pending
+some user input.  Therefore @command{configure} redirects its standard
+input from @file{/dev/null} during its initialization.  This is not
+normally a problem, since @command{configure} normally does not need
+user input.
+
+In the extreme case where your @file{configure} script really needs to
+obtain some values from the original standard input, you can read them
+explicitly from @code{AS_ORIGINAL_STDIN_FD}.
address@hidden defmac
+
 
 @c=================================================== Writing Autoconf Macros.
 
@@ -10823,7 +10889,7 @@ Also please see the discussion of the @c
 @item @command{echo}
 @c -----------------
 @prindex @command{echo}
-The simple @code{echo} is probably the most surprising source of
+The simple @command{echo} is probably the most surprising source of
 portability troubles.  It is not possible to use @samp{echo} portably
 unless both options and escape sequences are omitted.  New applications
 which are not aiming at portability should use @samp{printf} instead of
@@ -12081,7 +12147,7 @@ timestamp truncation problems that @samp
 
 On some old @acronym{BSD} systems, @command{touch} or any command that
 results in an empty file does not update the timestamps, so use a
-command like @code{echo} as a workaround.
+command like @command{echo} as a workaround.
 
 @acronym{GNU} @command{touch} 3.16r (and presumably all before that)
 fails to work on SunOS 4.1.3 when the empty file is on an
@@ -14866,7 +14932,7 @@ macros while running @command{autoconf},
 your @command{configure} script will generally work better if you follow
 the advice that is printed about what to replace the obsolete macros with.  In
 particular, the mechanism for reporting the results of tests has
-changed.  If you were using @code{echo} or @code{AC_VERBOSE} (perhaps
+changed.  If you were using @command{echo} or @code{AC_VERBOSE} (perhaps
 via @code{AC_COMPILE_CHECK}), your @command{configure} script's output will
 look better if you switch to @code{AC_MSG_CHECKING} and
 @code{AC_MSG_RESULT}.  @xref{Printing Messages}.  Those macros work best
Index: lib/autoconf/c.m4
===================================================================
RCS file: /cvsroot/autoconf/autoconf/lib/autoconf/c.m4,v
retrieving revision 1.196
diff -p -u -r1.196 c.m4
--- lib/autoconf/c.m4   13 Feb 2005 07:38:32 -0000      1.196
+++ lib/autoconf/c.m4   23 Feb 2005 23:23:53 -0000
@@ -476,9 +476,9 @@ test -z "$CC" && AC_MSG_FAILURE([no acce
 echo "$as_me:$LINENO:" \
      "checking for _AC_LANG compiler version" >&AS_MESSAGE_LOG_FD
 ac_compiler=`set X $ac_compile; echo $[2]`
-_AC_EVAL([$ac_compiler --version </dev/null >&AS_MESSAGE_LOG_FD])
-_AC_EVAL([$ac_compiler -v </dev/null >&AS_MESSAGE_LOG_FD])
-_AC_EVAL([$ac_compiler -V </dev/null >&AS_MESSAGE_LOG_FD])
+_AC_EVAL([$ac_compiler --version >&AS_MESSAGE_LOG_FD])
+_AC_EVAL([$ac_compiler -v >&AS_MESSAGE_LOG_FD])
+_AC_EVAL([$ac_compiler -V >&AS_MESSAGE_LOG_FD])
 
 m4_expand_once([_AC_COMPILER_EXEEXT])[]dnl
 m4_expand_once([_AC_COMPILER_OBJEXT])[]dnl
@@ -705,9 +705,9 @@ AC_CHECK_TOOLS(CXX,
 echo "$as_me:$LINENO:" \
      "checking for _AC_LANG compiler version" >&AS_MESSAGE_LOG_FD
 ac_compiler=`set X $ac_compile; echo $[2]`
-_AC_EVAL([$ac_compiler --version </dev/null >&AS_MESSAGE_LOG_FD])
-_AC_EVAL([$ac_compiler -v </dev/null >&AS_MESSAGE_LOG_FD])
-_AC_EVAL([$ac_compiler -V </dev/null >&AS_MESSAGE_LOG_FD])
+_AC_EVAL([$ac_compiler --version >&AS_MESSAGE_LOG_FD])
+_AC_EVAL([$ac_compiler -v >&AS_MESSAGE_LOG_FD])
+_AC_EVAL([$ac_compiler -V >&AS_MESSAGE_LOG_FD])
 
 m4_expand_once([_AC_COMPILER_EXEEXT])[]dnl
 m4_expand_once([_AC_COMPILER_OBJEXT])[]dnl
Index: lib/autoconf/fortran.m4
===================================================================
RCS file: /cvsroot/autoconf/autoconf/lib/autoconf/fortran.m4,v
retrieving revision 1.187
diff -p -u -r1.187 fortran.m4
--- lib/autoconf/fortran.m4     13 Feb 2005 07:38:32 -0000      1.187
+++ lib/autoconf/fortran.m4     23 Feb 2005 23:23:53 -0000
@@ -364,9 +364,9 @@ AC_CHECK_TOOLS([]_AC_FC[],
 echo "$as_me:__oline__:" \
      "checking for _AC_LANG compiler version" >&AS_MESSAGE_LOG_FD
 ac_compiler=`set X $ac_compile; echo $[2]`
-_AC_EVAL([$ac_compiler --version </dev/null >&AS_MESSAGE_LOG_FD])
-_AC_EVAL([$ac_compiler -v </dev/null >&AS_MESSAGE_LOG_FD])
-_AC_EVAL([$ac_compiler -V </dev/null >&AS_MESSAGE_LOG_FD])
+_AC_EVAL([$ac_compiler --version >&AS_MESSAGE_LOG_FD])
+_AC_EVAL([$ac_compiler -v >&AS_MESSAGE_LOG_FD])
+_AC_EVAL([$ac_compiler -V >&AS_MESSAGE_LOG_FD])
 rm -f a.out
 
 m4_expand_once([_AC_COMPILER_EXEEXT])[]dnl
Index: lib/autoconf/general.m4
===================================================================
RCS file: /cvsroot/autoconf/autoconf/lib/autoconf/general.m4,v
retrieving revision 1.846
diff -p -u -r1.846 general.m4
--- lib/autoconf/general.m4     13 Feb 2005 07:38:32 -0000      1.846
+++ lib/autoconf/general.m4     23 Feb 2005 23:23:53 -0000
@@ -358,13 +358,18 @@ gives unlimited permission to copy, dist
 # ----------------
 # Set up the file descriptors used by `configure'.
 # File descriptor usage:
-# 0 standard input
+# 0 standard input (/dev/null)
 # 1 file creation
 # 2 errors and warnings
 # AS_MESSAGE_LOG_FD compiler messages saved in config.log
 # AS_MESSAGE_FD checking for... messages and results
-
+# AS_ORIGINAL_STDIN_FD original standard input (still open)
+#
+# stdin is /dev/null because checks that run programs may
+# inadvertently run interactive ones, which would stop configuration
+# until someone typed an EOF.
 m4_define([AS_MESSAGE_FD], 6)
+m4_define([AS_ORIGINAL_STDIN_FD], 7)
 # That's how they used to be named.
 AU_ALIAS([AC_FD_CC],  [AS_MESSAGE_LOG_FD])
 AU_ALIAS([AC_FD_MSG], [AS_MESSAGE_FD])
@@ -377,13 +382,13 @@ AU_ALIAS([AC_FD_MSG], [AS_MESSAGE_FD])
 m4_define([_AC_INIT_DEFAULTS],
 [m4_divert_push([DEFAULTS])dnl
 
+exec AS_ORIGINAL_STDIN_FD<&0 </dev/null AS_MESSAGE_FD>&1
+
 # Name of the host.
 # hostname on some systems (SVR3.2, Linux) returns a bogus exit status,
 # so uname gets run too.
 ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q`
 
-exec AS_MESSAGE_FD>&1
-
 #
 # Initializations.
 #
@@ -2133,7 +2138,7 @@ AC_DEFUN([AC_RUN_LOG],
 # to expand ac_cpp.
 AC_DEFUN([_AC_PREPROC_IFELSE],
 [m4_ifvaln([$1], [AC_LANG_CONFTEST([$1])])dnl
-if _AC_EVAL_STDERR([$ac_cpp conftest.$ac_ext]) </dev/null >/dev/null; then
+if _AC_EVAL_STDERR([$ac_cpp conftest.$ac_ext]) >/dev/null; then
   if test -s conftest.err; then
     ac_cpp_err=$ac_[]_AC_LANG_ABBREV[]_preproc_warn_flag
     ac_cpp_err=$ac_cpp_err$ac_[]_AC_LANG_ABBREV[]_werror_flag
@@ -2218,7 +2223,7 @@ AC_DEFUN([AC_EGREP_HEADER],
 m4_define([_AC_COMPILE_IFELSE],
 [m4_ifvaln([$1], [AC_LANG_CONFTEST([$1])])dnl
 rm -f conftest.$ac_objext
-AS_IF([_AC_EVAL_STDERR($ac_compile) </dev/null &&
+AS_IF([_AC_EVAL_STDERR($ac_compile) &&
         AC_TRY_COMMAND([test -z "$ac_[]_AC_LANG_ABBREV[]_werror_flag"
                         || test ! -s conftest.err]) &&
         AC_TRY_COMMAND([test -s conftest.$ac_objext])],
@@ -2259,7 +2264,7 @@ AU_DEFUN([AC_TRY_COMPILE],
 m4_define([_AC_LINK_IFELSE],
 [m4_ifvaln([$1], [AC_LANG_CONFTEST([$1])])dnl
 rm -f conftest.$ac_objext conftest$ac_exeext
-AS_IF([_AC_EVAL_STDERR($ac_link) </dev/null &&
+AS_IF([_AC_EVAL_STDERR($ac_link) &&
         AC_TRY_COMMAND([test -z "$ac_[]_AC_LANG_ABBREV[]_werror_flag"
                         || test ! -s conftest.err]) &&
         AC_TRY_COMMAND([test -s conftest$ac_exeext])],
Index: lib/autoconf/programs.m4
===================================================================
RCS file: /cvsroot/autoconf/autoconf/lib/autoconf/programs.m4,v
retrieving revision 1.42
diff -p -u -r1.42 programs.m4
--- lib/autoconf/programs.m4    13 Feb 2005 07:38:32 -0000      1.42
+++ lib/autoconf/programs.m4    23 Feb 2005 23:23:53 -0000
@@ -497,7 +497,7 @@ dnl   # for best performing tool in a li
 # ----------------------------------------------------------------
 m4_define([_AC_PATH_PROG_FLAVOR_GNU],
 [# Check for GNU $1
-case `"$1" --version </dev/null 2>&1` in
+case `"$1" --version 2>&1` in
 *GNU*)
   $2;;
 m4_ifval([$3],
Index: tests/base.at
===================================================================
RCS file: /cvsroot/autoconf/autoconf/tests/base.at,v
retrieving revision 1.32
diff -p -u -r1.32 base.at
--- tests/base.at       23 Jun 2003 11:11:42 -0000      1.32
+++ tests/base.at       23 Feb 2005 23:23:53 -0000
@@ -2,7 +2,7 @@
 
 AT_BANNER([Autoconf base layer.])
 
-# Copyright (C) 2000, 2001, 2003 Free Software Foundation, Inc.
+# Copyright (C) 2000, 2001, 2003, 2005 Free Software Foundation, Inc.
 #
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -230,3 +230,22 @@ AT_CHECK_AUTOCONF
 AT_CHECK_CONFIGURE([-q])
 
 AT_CLEANUP
+
+
+## ------------ ##
+## Input/Output ##
+## ------------ ##
+
+AT_SETUP([Input/Output])
+
+m4_pattern_allow([^AS_(MESSAGE|ORIGINAL_STDIN)_FD$])
+AT_DATA([configure.ac],
+[[AC_INIT
+cat <&AS_ORIGINAL_STDIN_FD >&AS_MESSAGE_FD
+]])
+AT_CHECK_AUTOCONF
+AT_CHECK([echo Hello | top_srcdir=$abs_top_srcdir ./configure],, [Hello
+])
+AT_CHECK([echo Hello | top_srcdir=$abs_top_srcdir ./configure --silent])
+
+AT_CLEANUP




reply via email to

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