]> git.ipfire.org Git - thirdparty/autoconf.git/commitdiff
* acgeneral.m4 (_AC_TRY_CPP): New macro. It runs the preprocessor
authorAkim Demaille <akim@epita.fr>
Tue, 12 Sep 2000 13:02:29 +0000 (13:02 +0000)
committerAkim Demaille <akim@epita.fr>
Tue, 12 Sep 2000 13:02:29 +0000 (13:02 +0000)
and checks whether it produces errors or warnings. Don't put grep
output into a variable, use another grep instead.
(AC_TRY_CPP): Use _AC_TRY_CPP. Copy conftest.err to config.log
if the case of an error.
* aclang.m4 (AC_LANG(C), AC_LANG(C++), AC_LANG(Fortran 77)):
define AC_LANG_ABBREV to the short language name.
(_AC_PROG_CPP_WORKS): New macro. It checks whether the current
preprocessor can be used to check for existance of headers.
Most code taken from ...
(AC_PROG_CPP): ... here. Use _AC_PROG_CPP_WORKS. Use shell
"for" to find working CPP. Use AC_LANG_PUSH(C) and AC_LANG_POP -
it's a macro for C only.
(AC_PROG_CXXCPP): Rewritten using _AC_PROG_CPP_WORKS.

ChangeLog
acgeneral.m4
aclang.m4
lib/autoconf/c.m4
lib/autoconf/fortran.m4
lib/autoconf/general.m4
lib/autoconf/lang.m4

index 263ffcc25e474e05b538d2a094a3d39125d5d369..2c253ebd5ffe97babee285d8a5a81f9c23fc929a 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,20 @@
+2000-09-12  Pavel Roskin  <proski@gnu.org>
+
+       * acgeneral.m4 (_AC_TRY_CPP): New macro. It runs the preprocessor
+       and checks whether it produces errors or warnings. Don't put grep
+       output into a variable, use another grep instead.
+       (AC_TRY_CPP): Use _AC_TRY_CPP. Copy conftest.err to config.log
+       if the case of an error.
+       * aclang.m4 (AC_LANG(C), AC_LANG(C++), AC_LANG(Fortran 77)):
+       define AC_LANG_ABBREV to the short language name.
+       (_AC_PROG_CPP_WORKS): New macro. It checks whether the current
+       preprocessor can be used to check for existance of headers.
+       Most code taken from ...
+       (AC_PROG_CPP): ... here. Use _AC_PROG_CPP_WORKS. Use shell
+       "for" to find working CPP. Use AC_LANG_PUSH(C) and AC_LANG_POP -
+       it's a macro for C only.
+       (AC_PROG_CXXCPP): Rewritten using _AC_PROG_CPP_WORKS.
+
 2000-09-12  Akim Demaille  <akim@epita.fr>
 
        * autoupdate.sh (sed): Look for GNU sed.
index 0917c50bce9cd370377e63c93f2c93efed969964..ebf307b54c998ec4309f191a475b101325c38eea 100644 (file)
@@ -3253,6 +3253,28 @@ popdef([AC_Lib_Name])dnl
 ## ------------------------ ##
 
 
+# _AC_TRY_CPP
+# -----------
+# Run cpp and set ac_cpp_err to "yes" for an error, to
+# "$ac_(c,cxx)_preproc_warn_flag" if there are warnings or to "" if neither
+# warnings nor errors have been detected.
+# eval is necessary to expand ac_cpp.  It may put trace lines to conftest.err
+# when run under sh -x (e.g. when zsh is used), so we filter them out.
+AC_DEFUN([_AC_TRY_CPP],
+[ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.err"
+if AC_TRY_EVAL(ac_try); then
+  if egrep -v '^( *\+|conftest.'"$ac_ext"'$)' conftest.err | grep . >/dev/null
+  then
+    ac_cpp_err=$ac_[]AC_LANG_ABBREV[]_preproc_warn_flag
+  else
+    ac_cpp_err=
+  fi
+else
+  ac_cpp_err=yes
+fi
+])# _AC_TRY_CPP
+
+
 # AC_TRY_CPP(INCLUDES, [ACTION-IF-TRUE], [ACTION-IF-FALSE])
 # ---------------------------------------------------------
 # Capture the stderr of cpp.  eval is necessary to expand ac_cpp.  We
@@ -3264,18 +3286,17 @@ popdef([AC_Lib_Name])dnl
 AC_DEFUN([AC_TRY_CPP],
 [AC_REQUIRE_CPP()dnl
 AC_LANG_CONFTEST([AC_LANG_SOURCE([[$1]])])
-ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-AC_TRY_EVAL(ac_try)
-ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.$ac_ext\$"`
-if test -z "$ac_err"; then
+_AC_TRY_CPP()
+if test -z "$ac_cpp_err"; then
   m4_default([$2], :)
 else
-  echo "$ac_err" >&AC_FD_LOG
+  cat conftest.err >&AC_FD_LOG
   echo "configure: failed program was:" >&AC_FD_LOG
   cat conftest.$ac_ext >&AC_FD_LOG
   $3
 fi
-rm -f conftest*])
+rm -f conftest*
+])# AC_TRY_CPP
 
 
 # AC_EGREP_HEADER(PATTERN, HEADER-FILE,
index 351cb84f3c223cbb2a6ec67fc1a9e51c8fc49652..2cc134e734d3f538999fc5bc7deed8849060d341 100644 (file)
--- a/aclang.m4
+++ b/aclang.m4
@@ -170,6 +170,7 @@ ac_cpp='$CPP $CPPFLAGS'
 ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&AC_FD_LOG'
 ac_link='${CC-cc} -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&AC_FD_LOG'
 ac_gnu_compiler=$ac_cv_prog_gcc
+define([AC_LANG_ABBREV], [c])dnl
 ])
 
 
@@ -193,6 +194,7 @@ ac_cpp='$CXXCPP $CPPFLAGS'
 ac_compile='${CXX-g++} -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&AC_FD_LOG'
 ac_link='${CXX-g++} -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&AC_FD_LOG'
 ac_gnu_compiler=$ac_cv_prog_gxx
+define([AC_LANG_ABBREV], [cxx])dnl
 ])
 
 
@@ -214,6 +216,7 @@ define([AC_LANG(Fortran 77)],
 ac_compile='${F77-f77} -c $FFLAGS conftest.$ac_ext >&AC_FD_LOG'
 ac_link='${F77-f77} -o conftest$ac_exeext $FFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&AC_FD_LOG'
 ac_gnu_compiler=$ac_cv_prog_g77
+define([AC_LANG_ABBREV], [f77])dnl
 ])
 
 
@@ -546,38 +549,79 @@ AC_DIVERT_POP()dnl
 # -------------------- #
 
 
+# _AC_PROG_CPP_WORKS
+# ------------------
+# Check if $ac_cpp is a working preprocessor that can flag absent
+# includes either by the exit status or by warnings
+# Set ac_cpp_err to a non-empty value if the preprocessor failed
+# This macro is for all languages, not only C
+AC_DEFUN([_AC_PROG_CPP_WORKS],
+[AC_REQUIRE_CPP()dnl
+# Use a header file that comes with gcc, so configuring glibc
+# with a fresh cross-compiler works.
+# On the NeXT, cc -E runs the code through the compiler's parser,
+# not just through cpp. "Syntax error" is here to catch this case.
+AC_LANG_CONFTEST([AC_LANG_SOURCE([[#include <assert.h>
+Syntax error]])])
+ac_[]AC_LANG_ABBREV[]_preproc_warn_flag=maybe
+_AC_TRY_CPP()
+# Now check whether non-existent headers can be detected and how
+# Skip if ac_cpp_err is not empty - ac_cpp is broken
+if test -z "$ac_cpp_err"; then
+  AC_LANG_CONFTEST([AC_LANG_SOURCE([[#include <ac_nonexistent.h>]])])
+  _AC_TRY_CPP()
+  if test -z "$ac_cpp_err"; then
+    # cannot detect missing includes at all
+    ac_cpp_err=yes
+  else
+    if test "x$ac_cpp_err" = xmaybe; then
+      ac_[]AC_LANG_ABBREV[]_preproc_warn_flag=yes
+    else
+      ac_[]AC_LANG_ABBREV[]_preproc_warn_flag=
+    fi
+    ac_cpp_err=
+  fi
+fi
+rm -f conftest*
+])# _AC_PROG_CPP_WORKS
+
+
 # AC_PROG_CPP
 # -----------
+# Find a working C preprocessor
 AC_DEFUN([AC_PROG_CPP],
 [AC_MSG_CHECKING(how to run the C preprocessor)
+AC_LANG_PUSH(C)dnl
 # On Suns, sometimes $CPP names a directory.
 if test -n "$CPP" && test -d "$CPP"; then
   CPP=
 fi
 if test -z "$CPP"; then
-AC_CACHE_VAL(ac_cv_prog_CPP,
-[  # This must be in double quotes, not single quotes, because CPP may get
-  # substituted into the Makefile and "${CC-cc}" will confuse make.
-  CPP="${CC-cc} -E"
-  # On the NeXT, cc -E runs the code through the compiler's parser,
-  # not just through cpp.
-  # Use a header file that comes with gcc, so configuring glibc
-  # with a fresh cross-compiler works.
-  AC_TRY_CPP([#include <assert.h>
-Syntax Error], ,
-  CPP="${CC-cc} -E -traditional-cpp"
-  AC_TRY_CPP([#include <assert.h>
-Syntax Error], ,
-  CPP="${CC-cc} -nologo -E"
-  AC_TRY_CPP([#include <assert.h>
-Syntax Error], , CPP=/lib/cpp)))
-  ac_cv_prog_CPP=$CPP])dnl
+  AC_CACHE_VAL(ac_cv_prog_CPP,
+  [dnl
+    for ac_tmp_cpp in '${CC-cc} -E' '${CC-cc} -E -traditional-cpp' \
+                      '${CC-cc} -nologo -E' '/lib/cpp'
+    do
+      # CPP needs to be expanded
+      eval "CPP=\"$ac_tmp_cpp\""
+      _AC_PROG_CPP_WORKS()
+      if test -z "$ac_cpp_err"; then
+        break
+      fi
+    done
+    ac_cv_prog_CPP=$CPP
+  ])dnl
   CPP=$ac_cv_prog_CPP
 else
+  _AC_PROG_CPP_WORKS()
   ac_cv_prog_CPP=$CPP
 fi
 AC_MSG_RESULT($CPP)
+if test -n "$ac_cpp_err"; then
+  AC_MSG_ERROR([C preprocessor "$CPP" fails sanity check])
+fi
 AC_SUBST(CPP)dnl
+AC_LANG_POP()dnl
 ])# AC_PROG_CPP
 
 
@@ -760,22 +804,36 @@ fi
 
 # AC_PROG_CXXCPP
 # --------------
+# Find a working C++ preprocessor
 AC_DEFUN([AC_PROG_CXXCPP],
 [AC_MSG_CHECKING(how to run the C++ preprocessor)
+AC_LANG_PUSH(C++)dnl
 if test -z "$CXXCPP"; then
-AC_CACHE_VAL(ac_cv_prog_CXXCPP,
-[AC_LANG_PUSH(C++)
-  CXXCPP="${CXX-g++} -E"
-  AC_TRY_CPP([#include <stdlib.h>], , CXXCPP=/lib/cpp)
+  AC_CACHE_VAL(ac_cv_prog_CXXCPP,
+  [dnl
+    for ac_tmp_cxxcpp in '${CXX-g++} -E' '/lib/cpp'
+    do
+      # CXXCPP needs to be expanded
+      eval "CXXCPP=\"$ac_tmp_cxxcpp\""
+      _AC_PROG_CPP_WORKS()
+      if test -z "$ac_cpp_err"; then
+        break
+      fi
+    done
+    ac_cv_prog_CXXCPP=$CXXCPP
+  ])dnl
+  CXXCPP=$ac_cv_prog_CXXCPP
+else
+  _AC_PROG_CPP_WORKS()
   ac_cv_prog_CXXCPP=$CXXCPP
-AC_LANG_POP()dnl
-])dnl
-CXXCPP=$ac_cv_prog_CXXCPP
 fi
 AC_MSG_RESULT($CXXCPP)
+if test -n "$ac_cpp_err"; then
+  AC_MSG_ERROR([C++ preprocessor "$CXXCPP" fails sanity check])
+fi
 AC_SUBST(CXXCPP)dnl
-])
-# AC_PROG_CXXCPP
+AC_LANG_POP()dnl
+])# AC_PROG_CXXCPP
 
 
 # AC_PROG_CXX([LIST-OF-COMPILERS])
index 351cb84f3c223cbb2a6ec67fc1a9e51c8fc49652..2cc134e734d3f538999fc5bc7deed8849060d341 100644 (file)
@@ -170,6 +170,7 @@ ac_cpp='$CPP $CPPFLAGS'
 ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&AC_FD_LOG'
 ac_link='${CC-cc} -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&AC_FD_LOG'
 ac_gnu_compiler=$ac_cv_prog_gcc
+define([AC_LANG_ABBREV], [c])dnl
 ])
 
 
@@ -193,6 +194,7 @@ ac_cpp='$CXXCPP $CPPFLAGS'
 ac_compile='${CXX-g++} -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&AC_FD_LOG'
 ac_link='${CXX-g++} -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&AC_FD_LOG'
 ac_gnu_compiler=$ac_cv_prog_gxx
+define([AC_LANG_ABBREV], [cxx])dnl
 ])
 
 
@@ -214,6 +216,7 @@ define([AC_LANG(Fortran 77)],
 ac_compile='${F77-f77} -c $FFLAGS conftest.$ac_ext >&AC_FD_LOG'
 ac_link='${F77-f77} -o conftest$ac_exeext $FFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&AC_FD_LOG'
 ac_gnu_compiler=$ac_cv_prog_g77
+define([AC_LANG_ABBREV], [f77])dnl
 ])
 
 
@@ -546,38 +549,79 @@ AC_DIVERT_POP()dnl
 # -------------------- #
 
 
+# _AC_PROG_CPP_WORKS
+# ------------------
+# Check if $ac_cpp is a working preprocessor that can flag absent
+# includes either by the exit status or by warnings
+# Set ac_cpp_err to a non-empty value if the preprocessor failed
+# This macro is for all languages, not only C
+AC_DEFUN([_AC_PROG_CPP_WORKS],
+[AC_REQUIRE_CPP()dnl
+# Use a header file that comes with gcc, so configuring glibc
+# with a fresh cross-compiler works.
+# On the NeXT, cc -E runs the code through the compiler's parser,
+# not just through cpp. "Syntax error" is here to catch this case.
+AC_LANG_CONFTEST([AC_LANG_SOURCE([[#include <assert.h>
+Syntax error]])])
+ac_[]AC_LANG_ABBREV[]_preproc_warn_flag=maybe
+_AC_TRY_CPP()
+# Now check whether non-existent headers can be detected and how
+# Skip if ac_cpp_err is not empty - ac_cpp is broken
+if test -z "$ac_cpp_err"; then
+  AC_LANG_CONFTEST([AC_LANG_SOURCE([[#include <ac_nonexistent.h>]])])
+  _AC_TRY_CPP()
+  if test -z "$ac_cpp_err"; then
+    # cannot detect missing includes at all
+    ac_cpp_err=yes
+  else
+    if test "x$ac_cpp_err" = xmaybe; then
+      ac_[]AC_LANG_ABBREV[]_preproc_warn_flag=yes
+    else
+      ac_[]AC_LANG_ABBREV[]_preproc_warn_flag=
+    fi
+    ac_cpp_err=
+  fi
+fi
+rm -f conftest*
+])# _AC_PROG_CPP_WORKS
+
+
 # AC_PROG_CPP
 # -----------
+# Find a working C preprocessor
 AC_DEFUN([AC_PROG_CPP],
 [AC_MSG_CHECKING(how to run the C preprocessor)
+AC_LANG_PUSH(C)dnl
 # On Suns, sometimes $CPP names a directory.
 if test -n "$CPP" && test -d "$CPP"; then
   CPP=
 fi
 if test -z "$CPP"; then
-AC_CACHE_VAL(ac_cv_prog_CPP,
-[  # This must be in double quotes, not single quotes, because CPP may get
-  # substituted into the Makefile and "${CC-cc}" will confuse make.
-  CPP="${CC-cc} -E"
-  # On the NeXT, cc -E runs the code through the compiler's parser,
-  # not just through cpp.
-  # Use a header file that comes with gcc, so configuring glibc
-  # with a fresh cross-compiler works.
-  AC_TRY_CPP([#include <assert.h>
-Syntax Error], ,
-  CPP="${CC-cc} -E -traditional-cpp"
-  AC_TRY_CPP([#include <assert.h>
-Syntax Error], ,
-  CPP="${CC-cc} -nologo -E"
-  AC_TRY_CPP([#include <assert.h>
-Syntax Error], , CPP=/lib/cpp)))
-  ac_cv_prog_CPP=$CPP])dnl
+  AC_CACHE_VAL(ac_cv_prog_CPP,
+  [dnl
+    for ac_tmp_cpp in '${CC-cc} -E' '${CC-cc} -E -traditional-cpp' \
+                      '${CC-cc} -nologo -E' '/lib/cpp'
+    do
+      # CPP needs to be expanded
+      eval "CPP=\"$ac_tmp_cpp\""
+      _AC_PROG_CPP_WORKS()
+      if test -z "$ac_cpp_err"; then
+        break
+      fi
+    done
+    ac_cv_prog_CPP=$CPP
+  ])dnl
   CPP=$ac_cv_prog_CPP
 else
+  _AC_PROG_CPP_WORKS()
   ac_cv_prog_CPP=$CPP
 fi
 AC_MSG_RESULT($CPP)
+if test -n "$ac_cpp_err"; then
+  AC_MSG_ERROR([C preprocessor "$CPP" fails sanity check])
+fi
 AC_SUBST(CPP)dnl
+AC_LANG_POP()dnl
 ])# AC_PROG_CPP
 
 
@@ -760,22 +804,36 @@ fi
 
 # AC_PROG_CXXCPP
 # --------------
+# Find a working C++ preprocessor
 AC_DEFUN([AC_PROG_CXXCPP],
 [AC_MSG_CHECKING(how to run the C++ preprocessor)
+AC_LANG_PUSH(C++)dnl
 if test -z "$CXXCPP"; then
-AC_CACHE_VAL(ac_cv_prog_CXXCPP,
-[AC_LANG_PUSH(C++)
-  CXXCPP="${CXX-g++} -E"
-  AC_TRY_CPP([#include <stdlib.h>], , CXXCPP=/lib/cpp)
+  AC_CACHE_VAL(ac_cv_prog_CXXCPP,
+  [dnl
+    for ac_tmp_cxxcpp in '${CXX-g++} -E' '/lib/cpp'
+    do
+      # CXXCPP needs to be expanded
+      eval "CXXCPP=\"$ac_tmp_cxxcpp\""
+      _AC_PROG_CPP_WORKS()
+      if test -z "$ac_cpp_err"; then
+        break
+      fi
+    done
+    ac_cv_prog_CXXCPP=$CXXCPP
+  ])dnl
+  CXXCPP=$ac_cv_prog_CXXCPP
+else
+  _AC_PROG_CPP_WORKS()
   ac_cv_prog_CXXCPP=$CXXCPP
-AC_LANG_POP()dnl
-])dnl
-CXXCPP=$ac_cv_prog_CXXCPP
 fi
 AC_MSG_RESULT($CXXCPP)
+if test -n "$ac_cpp_err"; then
+  AC_MSG_ERROR([C++ preprocessor "$CXXCPP" fails sanity check])
+fi
 AC_SUBST(CXXCPP)dnl
-])
-# AC_PROG_CXXCPP
+AC_LANG_POP()dnl
+])# AC_PROG_CXXCPP
 
 
 # AC_PROG_CXX([LIST-OF-COMPILERS])
index 351cb84f3c223cbb2a6ec67fc1a9e51c8fc49652..2cc134e734d3f538999fc5bc7deed8849060d341 100644 (file)
@@ -170,6 +170,7 @@ ac_cpp='$CPP $CPPFLAGS'
 ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&AC_FD_LOG'
 ac_link='${CC-cc} -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&AC_FD_LOG'
 ac_gnu_compiler=$ac_cv_prog_gcc
+define([AC_LANG_ABBREV], [c])dnl
 ])
 
 
@@ -193,6 +194,7 @@ ac_cpp='$CXXCPP $CPPFLAGS'
 ac_compile='${CXX-g++} -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&AC_FD_LOG'
 ac_link='${CXX-g++} -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&AC_FD_LOG'
 ac_gnu_compiler=$ac_cv_prog_gxx
+define([AC_LANG_ABBREV], [cxx])dnl
 ])
 
 
@@ -214,6 +216,7 @@ define([AC_LANG(Fortran 77)],
 ac_compile='${F77-f77} -c $FFLAGS conftest.$ac_ext >&AC_FD_LOG'
 ac_link='${F77-f77} -o conftest$ac_exeext $FFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&AC_FD_LOG'
 ac_gnu_compiler=$ac_cv_prog_g77
+define([AC_LANG_ABBREV], [f77])dnl
 ])
 
 
@@ -546,38 +549,79 @@ AC_DIVERT_POP()dnl
 # -------------------- #
 
 
+# _AC_PROG_CPP_WORKS
+# ------------------
+# Check if $ac_cpp is a working preprocessor that can flag absent
+# includes either by the exit status or by warnings
+# Set ac_cpp_err to a non-empty value if the preprocessor failed
+# This macro is for all languages, not only C
+AC_DEFUN([_AC_PROG_CPP_WORKS],
+[AC_REQUIRE_CPP()dnl
+# Use a header file that comes with gcc, so configuring glibc
+# with a fresh cross-compiler works.
+# On the NeXT, cc -E runs the code through the compiler's parser,
+# not just through cpp. "Syntax error" is here to catch this case.
+AC_LANG_CONFTEST([AC_LANG_SOURCE([[#include <assert.h>
+Syntax error]])])
+ac_[]AC_LANG_ABBREV[]_preproc_warn_flag=maybe
+_AC_TRY_CPP()
+# Now check whether non-existent headers can be detected and how
+# Skip if ac_cpp_err is not empty - ac_cpp is broken
+if test -z "$ac_cpp_err"; then
+  AC_LANG_CONFTEST([AC_LANG_SOURCE([[#include <ac_nonexistent.h>]])])
+  _AC_TRY_CPP()
+  if test -z "$ac_cpp_err"; then
+    # cannot detect missing includes at all
+    ac_cpp_err=yes
+  else
+    if test "x$ac_cpp_err" = xmaybe; then
+      ac_[]AC_LANG_ABBREV[]_preproc_warn_flag=yes
+    else
+      ac_[]AC_LANG_ABBREV[]_preproc_warn_flag=
+    fi
+    ac_cpp_err=
+  fi
+fi
+rm -f conftest*
+])# _AC_PROG_CPP_WORKS
+
+
 # AC_PROG_CPP
 # -----------
+# Find a working C preprocessor
 AC_DEFUN([AC_PROG_CPP],
 [AC_MSG_CHECKING(how to run the C preprocessor)
+AC_LANG_PUSH(C)dnl
 # On Suns, sometimes $CPP names a directory.
 if test -n "$CPP" && test -d "$CPP"; then
   CPP=
 fi
 if test -z "$CPP"; then
-AC_CACHE_VAL(ac_cv_prog_CPP,
-[  # This must be in double quotes, not single quotes, because CPP may get
-  # substituted into the Makefile and "${CC-cc}" will confuse make.
-  CPP="${CC-cc} -E"
-  # On the NeXT, cc -E runs the code through the compiler's parser,
-  # not just through cpp.
-  # Use a header file that comes with gcc, so configuring glibc
-  # with a fresh cross-compiler works.
-  AC_TRY_CPP([#include <assert.h>
-Syntax Error], ,
-  CPP="${CC-cc} -E -traditional-cpp"
-  AC_TRY_CPP([#include <assert.h>
-Syntax Error], ,
-  CPP="${CC-cc} -nologo -E"
-  AC_TRY_CPP([#include <assert.h>
-Syntax Error], , CPP=/lib/cpp)))
-  ac_cv_prog_CPP=$CPP])dnl
+  AC_CACHE_VAL(ac_cv_prog_CPP,
+  [dnl
+    for ac_tmp_cpp in '${CC-cc} -E' '${CC-cc} -E -traditional-cpp' \
+                      '${CC-cc} -nologo -E' '/lib/cpp'
+    do
+      # CPP needs to be expanded
+      eval "CPP=\"$ac_tmp_cpp\""
+      _AC_PROG_CPP_WORKS()
+      if test -z "$ac_cpp_err"; then
+        break
+      fi
+    done
+    ac_cv_prog_CPP=$CPP
+  ])dnl
   CPP=$ac_cv_prog_CPP
 else
+  _AC_PROG_CPP_WORKS()
   ac_cv_prog_CPP=$CPP
 fi
 AC_MSG_RESULT($CPP)
+if test -n "$ac_cpp_err"; then
+  AC_MSG_ERROR([C preprocessor "$CPP" fails sanity check])
+fi
 AC_SUBST(CPP)dnl
+AC_LANG_POP()dnl
 ])# AC_PROG_CPP
 
 
@@ -760,22 +804,36 @@ fi
 
 # AC_PROG_CXXCPP
 # --------------
+# Find a working C++ preprocessor
 AC_DEFUN([AC_PROG_CXXCPP],
 [AC_MSG_CHECKING(how to run the C++ preprocessor)
+AC_LANG_PUSH(C++)dnl
 if test -z "$CXXCPP"; then
-AC_CACHE_VAL(ac_cv_prog_CXXCPP,
-[AC_LANG_PUSH(C++)
-  CXXCPP="${CXX-g++} -E"
-  AC_TRY_CPP([#include <stdlib.h>], , CXXCPP=/lib/cpp)
+  AC_CACHE_VAL(ac_cv_prog_CXXCPP,
+  [dnl
+    for ac_tmp_cxxcpp in '${CXX-g++} -E' '/lib/cpp'
+    do
+      # CXXCPP needs to be expanded
+      eval "CXXCPP=\"$ac_tmp_cxxcpp\""
+      _AC_PROG_CPP_WORKS()
+      if test -z "$ac_cpp_err"; then
+        break
+      fi
+    done
+    ac_cv_prog_CXXCPP=$CXXCPP
+  ])dnl
+  CXXCPP=$ac_cv_prog_CXXCPP
+else
+  _AC_PROG_CPP_WORKS()
   ac_cv_prog_CXXCPP=$CXXCPP
-AC_LANG_POP()dnl
-])dnl
-CXXCPP=$ac_cv_prog_CXXCPP
 fi
 AC_MSG_RESULT($CXXCPP)
+if test -n "$ac_cpp_err"; then
+  AC_MSG_ERROR([C++ preprocessor "$CXXCPP" fails sanity check])
+fi
 AC_SUBST(CXXCPP)dnl
-])
-# AC_PROG_CXXCPP
+AC_LANG_POP()dnl
+])# AC_PROG_CXXCPP
 
 
 # AC_PROG_CXX([LIST-OF-COMPILERS])
index 0917c50bce9cd370377e63c93f2c93efed969964..ebf307b54c998ec4309f191a475b101325c38eea 100644 (file)
@@ -3253,6 +3253,28 @@ popdef([AC_Lib_Name])dnl
 ## ------------------------ ##
 
 
+# _AC_TRY_CPP
+# -----------
+# Run cpp and set ac_cpp_err to "yes" for an error, to
+# "$ac_(c,cxx)_preproc_warn_flag" if there are warnings or to "" if neither
+# warnings nor errors have been detected.
+# eval is necessary to expand ac_cpp.  It may put trace lines to conftest.err
+# when run under sh -x (e.g. when zsh is used), so we filter them out.
+AC_DEFUN([_AC_TRY_CPP],
+[ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.err"
+if AC_TRY_EVAL(ac_try); then
+  if egrep -v '^( *\+|conftest.'"$ac_ext"'$)' conftest.err | grep . >/dev/null
+  then
+    ac_cpp_err=$ac_[]AC_LANG_ABBREV[]_preproc_warn_flag
+  else
+    ac_cpp_err=
+  fi
+else
+  ac_cpp_err=yes
+fi
+])# _AC_TRY_CPP
+
+
 # AC_TRY_CPP(INCLUDES, [ACTION-IF-TRUE], [ACTION-IF-FALSE])
 # ---------------------------------------------------------
 # Capture the stderr of cpp.  eval is necessary to expand ac_cpp.  We
@@ -3264,18 +3286,17 @@ popdef([AC_Lib_Name])dnl
 AC_DEFUN([AC_TRY_CPP],
 [AC_REQUIRE_CPP()dnl
 AC_LANG_CONFTEST([AC_LANG_SOURCE([[$1]])])
-ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-AC_TRY_EVAL(ac_try)
-ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.$ac_ext\$"`
-if test -z "$ac_err"; then
+_AC_TRY_CPP()
+if test -z "$ac_cpp_err"; then
   m4_default([$2], :)
 else
-  echo "$ac_err" >&AC_FD_LOG
+  cat conftest.err >&AC_FD_LOG
   echo "configure: failed program was:" >&AC_FD_LOG
   cat conftest.$ac_ext >&AC_FD_LOG
   $3
 fi
-rm -f conftest*])
+rm -f conftest*
+])# AC_TRY_CPP
 
 
 # AC_EGREP_HEADER(PATTERN, HEADER-FILE,
index 351cb84f3c223cbb2a6ec67fc1a9e51c8fc49652..2cc134e734d3f538999fc5bc7deed8849060d341 100644 (file)
@@ -170,6 +170,7 @@ ac_cpp='$CPP $CPPFLAGS'
 ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&AC_FD_LOG'
 ac_link='${CC-cc} -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&AC_FD_LOG'
 ac_gnu_compiler=$ac_cv_prog_gcc
+define([AC_LANG_ABBREV], [c])dnl
 ])
 
 
@@ -193,6 +194,7 @@ ac_cpp='$CXXCPP $CPPFLAGS'
 ac_compile='${CXX-g++} -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&AC_FD_LOG'
 ac_link='${CXX-g++} -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&AC_FD_LOG'
 ac_gnu_compiler=$ac_cv_prog_gxx
+define([AC_LANG_ABBREV], [cxx])dnl
 ])
 
 
@@ -214,6 +216,7 @@ define([AC_LANG(Fortran 77)],
 ac_compile='${F77-f77} -c $FFLAGS conftest.$ac_ext >&AC_FD_LOG'
 ac_link='${F77-f77} -o conftest$ac_exeext $FFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&AC_FD_LOG'
 ac_gnu_compiler=$ac_cv_prog_g77
+define([AC_LANG_ABBREV], [f77])dnl
 ])
 
 
@@ -546,38 +549,79 @@ AC_DIVERT_POP()dnl
 # -------------------- #
 
 
+# _AC_PROG_CPP_WORKS
+# ------------------
+# Check if $ac_cpp is a working preprocessor that can flag absent
+# includes either by the exit status or by warnings
+# Set ac_cpp_err to a non-empty value if the preprocessor failed
+# This macro is for all languages, not only C
+AC_DEFUN([_AC_PROG_CPP_WORKS],
+[AC_REQUIRE_CPP()dnl
+# Use a header file that comes with gcc, so configuring glibc
+# with a fresh cross-compiler works.
+# On the NeXT, cc -E runs the code through the compiler's parser,
+# not just through cpp. "Syntax error" is here to catch this case.
+AC_LANG_CONFTEST([AC_LANG_SOURCE([[#include <assert.h>
+Syntax error]])])
+ac_[]AC_LANG_ABBREV[]_preproc_warn_flag=maybe
+_AC_TRY_CPP()
+# Now check whether non-existent headers can be detected and how
+# Skip if ac_cpp_err is not empty - ac_cpp is broken
+if test -z "$ac_cpp_err"; then
+  AC_LANG_CONFTEST([AC_LANG_SOURCE([[#include <ac_nonexistent.h>]])])
+  _AC_TRY_CPP()
+  if test -z "$ac_cpp_err"; then
+    # cannot detect missing includes at all
+    ac_cpp_err=yes
+  else
+    if test "x$ac_cpp_err" = xmaybe; then
+      ac_[]AC_LANG_ABBREV[]_preproc_warn_flag=yes
+    else
+      ac_[]AC_LANG_ABBREV[]_preproc_warn_flag=
+    fi
+    ac_cpp_err=
+  fi
+fi
+rm -f conftest*
+])# _AC_PROG_CPP_WORKS
+
+
 # AC_PROG_CPP
 # -----------
+# Find a working C preprocessor
 AC_DEFUN([AC_PROG_CPP],
 [AC_MSG_CHECKING(how to run the C preprocessor)
+AC_LANG_PUSH(C)dnl
 # On Suns, sometimes $CPP names a directory.
 if test -n "$CPP" && test -d "$CPP"; then
   CPP=
 fi
 if test -z "$CPP"; then
-AC_CACHE_VAL(ac_cv_prog_CPP,
-[  # This must be in double quotes, not single quotes, because CPP may get
-  # substituted into the Makefile and "${CC-cc}" will confuse make.
-  CPP="${CC-cc} -E"
-  # On the NeXT, cc -E runs the code through the compiler's parser,
-  # not just through cpp.
-  # Use a header file that comes with gcc, so configuring glibc
-  # with a fresh cross-compiler works.
-  AC_TRY_CPP([#include <assert.h>
-Syntax Error], ,
-  CPP="${CC-cc} -E -traditional-cpp"
-  AC_TRY_CPP([#include <assert.h>
-Syntax Error], ,
-  CPP="${CC-cc} -nologo -E"
-  AC_TRY_CPP([#include <assert.h>
-Syntax Error], , CPP=/lib/cpp)))
-  ac_cv_prog_CPP=$CPP])dnl
+  AC_CACHE_VAL(ac_cv_prog_CPP,
+  [dnl
+    for ac_tmp_cpp in '${CC-cc} -E' '${CC-cc} -E -traditional-cpp' \
+                      '${CC-cc} -nologo -E' '/lib/cpp'
+    do
+      # CPP needs to be expanded
+      eval "CPP=\"$ac_tmp_cpp\""
+      _AC_PROG_CPP_WORKS()
+      if test -z "$ac_cpp_err"; then
+        break
+      fi
+    done
+    ac_cv_prog_CPP=$CPP
+  ])dnl
   CPP=$ac_cv_prog_CPP
 else
+  _AC_PROG_CPP_WORKS()
   ac_cv_prog_CPP=$CPP
 fi
 AC_MSG_RESULT($CPP)
+if test -n "$ac_cpp_err"; then
+  AC_MSG_ERROR([C preprocessor "$CPP" fails sanity check])
+fi
 AC_SUBST(CPP)dnl
+AC_LANG_POP()dnl
 ])# AC_PROG_CPP
 
 
@@ -760,22 +804,36 @@ fi
 
 # AC_PROG_CXXCPP
 # --------------
+# Find a working C++ preprocessor
 AC_DEFUN([AC_PROG_CXXCPP],
 [AC_MSG_CHECKING(how to run the C++ preprocessor)
+AC_LANG_PUSH(C++)dnl
 if test -z "$CXXCPP"; then
-AC_CACHE_VAL(ac_cv_prog_CXXCPP,
-[AC_LANG_PUSH(C++)
-  CXXCPP="${CXX-g++} -E"
-  AC_TRY_CPP([#include <stdlib.h>], , CXXCPP=/lib/cpp)
+  AC_CACHE_VAL(ac_cv_prog_CXXCPP,
+  [dnl
+    for ac_tmp_cxxcpp in '${CXX-g++} -E' '/lib/cpp'
+    do
+      # CXXCPP needs to be expanded
+      eval "CXXCPP=\"$ac_tmp_cxxcpp\""
+      _AC_PROG_CPP_WORKS()
+      if test -z "$ac_cpp_err"; then
+        break
+      fi
+    done
+    ac_cv_prog_CXXCPP=$CXXCPP
+  ])dnl
+  CXXCPP=$ac_cv_prog_CXXCPP
+else
+  _AC_PROG_CPP_WORKS()
   ac_cv_prog_CXXCPP=$CXXCPP
-AC_LANG_POP()dnl
-])dnl
-CXXCPP=$ac_cv_prog_CXXCPP
 fi
 AC_MSG_RESULT($CXXCPP)
+if test -n "$ac_cpp_err"; then
+  AC_MSG_ERROR([C++ preprocessor "$CXXCPP" fails sanity check])
+fi
 AC_SUBST(CXXCPP)dnl
-])
-# AC_PROG_CXXCPP
+AC_LANG_POP()dnl
+])# AC_PROG_CXXCPP
 
 
 # AC_PROG_CXX([LIST-OF-COMPILERS])