]> git.ipfire.org Git - thirdparty/autoconf.git/commitdiff
* lib/autoconf/general.m4 (_AC_INIT_DEFAULTS): Redirect stdin from
authorPaul Eggert <eggert@cs.ucla.edu>
Wed, 23 Feb 2005 23:24:49 +0000 (23:24 +0000)
committerPaul Eggert <eggert@cs.ucla.edu>
Wed, 23 Feb 2005 23:24:49 +0000 (23:24 +0000)
/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.

ChangeLog
NEWS
doc/autoconf.texi
lib/autoconf/c.m4
lib/autoconf/fortran.m4
lib/autoconf/general.m4
lib/autoconf/programs.m4
tests/base.at

index c09b5cf1e9f054d0c36d0d8c715f9e3e50c5636e..d2f3c8d7a577d11f30890c0166719900999b5535 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,22 @@
+2005-02-23  Paul Eggert  <eggert@cs.ucla.edu>
+           Alexandre Duret-Lutz  <adl@gnu.org>
+
+       * 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.
+
 2005-02-23  Paul Eggert  <eggert@cs.ucla.edu>
 
        * lib/m4sugar/m4sh.m4 (_AS_ECHO_N_PREPARE): Don't set ECHO_C to
diff --git a/NEWS b/NEWS
index 81cbaebeb72ab3914bf1bd6c2daed07bd60799d3..9112422058ea8e8c7c4c2bb22ac3c7dd6b0c663d 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -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 05c191638216c29c15ae4d5166dc5bfb2976024c..07027398336e3bd842965cd02c04fa5e967b7b43 100644 (file)
@@ -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 tests.
 @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 "$@{ECHO_T@}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 definitions into your program.
 * 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 them get enclosed in shell
 double quotes, so the shell performs variable and back-quote
 substitution on them.
 
-These macros are all wrappers around the @code{echo} shell command.
-@command{configure} 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}).
+@command{configure} 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 future.  As a matter of fact,
 * 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} or @var{file} is @samp{.},
 @end defmac
 
 
+@node File Descriptor Macros
+@section File Descriptor Macros
+@cindex input
+@cindex standard input
+@cindex file descriptors
+@cindex descriptors
+@cindex low-level output
+@cindex output, low-level
+
+The following macros define file descriptors used to output messages
+(or input values) from @file{configure} scripts.
+For example:
+
+@example
+echo "$wombats found" >&AS_MESSAGE_LOG_FD
+echo 'Enter desired kangaroo count:' >&AS_MESSAGE_FD
+read kangaroos <&AS_ORIGINAL_STDIN_FD`
+@end example
+
+@noindent
+However doing so is seldom needed, because Autoconf provides higher
+level macros as described below.
+
+@defmac AS_MESSAGE_FD
+@asindex{MESSAGE_FD}
+The file descriptor for @samp{checking for...}  messages and results.
+Normally this directs messages to the standard output, however when
+@command{configure} is run with the @code{-q} option, messages sent to
+@code{AS_MESSAGE_FD} 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}.
+@end defmac
+
+@defmac AS_MESSAGE_LOG_FD
+@asindex{MESSAGE_LOG_FD}
+
+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.
+@end defmac
+
+@defmac AS_ORIGINAL_STDIN_FD
+@asindex{ORIGINAL_STDIN_FD}
+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}.
+@end defmac
+
 
 @c=================================================== Writing Autoconf Macros.
 
@@ -10823,7 +10889,7 @@ Also please see the discussion of the @command{pwd} command.
 @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{cp -p} has.
 
 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}, you may safely ignore them, but
 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 47942ac7140f1988d4ce785ea864944a4fb977bc..52f31c36a31df17cece4d580f0c0a3116aee58c6 100644 (file)
@@ -476,9 +476,9 @@ test -z "$CC" && AC_MSG_FAILURE([no acceptable C compiler found in \$PATH])
 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 b758d0183bba090562f44e83517b5c4ad8b17157..d5149bbfe6d54beb5f71c647c4715790801b0fba 100644 (file)
@@ -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 7af2f2869d6969fafb5abc79bb2a030a5be10ca4..f50c1967d976f4edc49a8d99a51f0e12de04ef8a 100644 (file)
@@ -358,13 +358,18 @@ gives unlimited permission to copy, distribute and modify it.],
 # ----------------
 # 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 bb208f1a06305ae94cd06cd0eb6d49e10c3bc951..e98ecc40a46b81fa6d777da822fd5408de5f58ca 100644 (file)
@@ -497,7 +497,7 @@ dnl   # for best performing tool in a list breaks down.
 # ----------------------------------------------------------------
 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 2c8ea5ffb26fa8c8b372d2d05777d05032ebf0ed..6f43b73aaaf085d9589007cfe454bf88da2f1b8a 100644 (file)
@@ -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