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: Alexandre Duret-Lutz
Subject: Re: Problem with cl and autoconf
Date: Wed, 23 Feb 2005 20:54:34 +0100
User-agent: Gnus/5.110003 (No Gnus v0.3) Emacs/21.3.50 (gnu/linux)

>>> "Paul" == Paul Eggert <address@hidden> writes:
 Paul> Perhaps you could code it up?  (The hard part is writing the
 Paul> documentation and NEWS entry.  :-)

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

I was not sure were to document these files descriptors.  Either
near the description of the AC_MSG_* macros (node Printing
Messages), or near the other AS_* macros.  I did the latter just
because I had to pick one place.

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_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 (I/Os): 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 -u -r1.336 NEWS
--- NEWS        5 Feb 2005 07:58:43 -0000       1.336
+++ NEWS        23 Feb 2005 19:53:31 -0000
@@ -1,5 +1,10 @@
 * Major changes in Autoconf 2.59c
 
+** The standard input is closed while configure runs.
+  Doing so helps to cope with interactive commands that configure might
+  mistakenly run.  (The original standard input is still available
+  via AS_STDIN_FD, see the manual.)
+
 ** 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 -u -r1.879 autoconf.texi
--- doc/autoconf.texi   15 Feb 2005 06:40:21 -0000      1.879
+++ doc/autoconf.texi   23 Feb 2005 19:53:34 -0000
@@ -333,7 +333,7 @@
 * 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 @@
 * Using autom4te::              The Autoconf executables backbone
 * Programming in M4sugar::      Convenient pure M4 macros
 * Programming in M4sh::         Common shell Constructs
+* I/Os::                        File descriptors for input and output
 
 M4 Quotation
 
@@ -3143,7 +3144,7 @@
 * 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,12 +7651,13 @@
 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
-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
-automatically.
+These macros are all wrappers around the @code{echo} shell command, and
+will direct message to the appropriate file descriptor (@pxref{I/Os}).
address@hidden scripts should rarely need to run @code{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 automatically.
 
 To diagnose static issues, i.e., when @command{autoconf} is run, see
 @ref{Reporting Messages}.
@@ -7752,6 +7754,7 @@
 * Using autom4te::              The Autoconf executables backbone
 * Programming in M4sugar::      Convenient pure M4 macros
 * Programming in M4sh::         Common shell Constructs
+* I/Os::                        File descriptors for input and output
 @end menu
 
 @node M4 Quotation
@@ -8901,6 +8904,67 @@
 @end defmac
 
 
address@hidden I/Os
address@hidden Inputs and Outputs
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 the file descriptors used to output messages
+(or input values) from @file{configure} scripts.
+They are meant to be used as in
+
address@hidden
+echo message >&AS_MESSAGE_FD
+echo log message >&AS_MESSAGE_LOG_FD
+read val <&AS_STDIN_FD
address@hidden example
+
address@hidden
+However doing so is seldom needed, because Autoconf provides higher
+level macros to output messages.
+
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_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 not closed, such
+interactive programs would cause @command{configure} to stop, pending
+some user input.  Therefore @command{configure} closes its standard
+input during its initialization.  Because @command{configure} does not
+need any user input while it runs this is not a problem.
+
+In the extreme case where your @file{configure} script really needs to
+obtain some values from the original standard input, you should read
+them explicitly from @code{AS_STDIN_FD}.
address@hidden defmac
+
 
 @c=================================================== Writing Autoconf Macros.
 
Index: lib/autoconf/c.m4
===================================================================
RCS file: /cvsroot/autoconf/autoconf/lib/autoconf/c.m4,v
retrieving revision 1.196
diff -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 19:53:34 -0000
@@ -476,9 +476,9 @@
 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 @@
 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 -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 19:53:34 -0000
@@ -364,9 +364,9 @@
 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 -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 19:53:34 -0000
@@ -358,13 +358,19 @@
 # ----------------
 # Set up the file descriptors used by `configure'.
 # File descriptor usage:
-# 0 standard input
+# 0 standard input (closed)
 # 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_STDIN_FD original standard input (still open)
+#
+# The reason stdin is closed is that checks that runs programs may
+# inadvertently run interactive programs.  In this case ./configure
+# would be stopped until someone hit ^D.  Closing stdin fixes all
+# these problems.
 m4_define([AS_MESSAGE_FD], 6)
+m4_define([AS_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 +383,13 @@
 m4_define([_AC_INIT_DEFAULTS],
 [m4_divert_push([DEFAULTS])dnl
 
+exec AS_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 +2139,7 @@
 # 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 +2224,7 @@
 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 +2265,7 @@
 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 -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 19:53:34 -0000
@@ -497,7 +497,7 @@
 # ----------------------------------------------------------------
 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 -u -r1.32 base.at
--- tests/base.at       23 Jun 2003 11:11:42 -0000      1.32
+++ tests/base.at       23 Feb 2005 19:53:34 -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_CONFIGURE([-q])
 
 AT_CLEANUP
+
+
+## ------------ ##
+## Input/Output ##
+## ------------ ##
+
+AT_SETUP([Input/Output])
+
+m4_pattern_allow([^AS_(MESSAGE|STDIN)_FD$])
+AT_DATA([configure.ac],
+[[AC_INIT
+cat <&AS_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
-- 
Alexandre Duret-Lutz





reply via email to

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