`maybe' strategy: first try cpp's exit status, then its stderr.
(AC_PROG_CPP, AC_PROG_CXXCPP): Adjust.
* tests/compile.at (AC_PROG_CPP via CC): Simplify mycc.
Remove unrelated code.
+2001-05-11 Akim Demaille <akim@epita.fr>
+
+ * aclang.m4 (_AC_PROG_PREPROC_WORKS_IFELSE): No longer use the
+ `maybe' strategy: first try cpp's exit status, then its stderr.
+ (AC_PROG_CPP, AC_PROG_CXXCPP): Adjust.
+ * tests/compile.at (AC_PROG_CPP via CC): Simplify mycc.
+ Remove unrelated code.
+
2001-05-10 Akim Demaille <akim@epita.fr>
* tests/compile.at (AC_PROG_CPP via CC): New.
# 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_PREPROC_WORKS_IFELSE],
-[# We don't know yet if stderr is the criterion (vs exit status).
-ac_[]_AC_LANG_ABBREV[]_preproc_warn_flag=maybe
-
-# 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_PREPROC_IFELSE([AC_LANG_SOURCE([[@%:@include <assert.h>
-Syntax error]])],
-[# OK, works on sane cases. Now check whether non-existent headers can
-# be detected and how.
-_AC_PREPROC_IFELSE([AC_LANG_SOURCE([[@%:@include <ac_nonexistent.h>]])],
-[# Broken: cannot detect missing includes.
-m4_default([$2], :)],
-[# OK, detects failures. How?
-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
-$1])],
- [# Broken: fails on valid input.
-m4_default([$2], :)])])# _AC_PROG_PREPROC_WORKS_IFELSE
+[ac_preproc_ok=false
+for ac_[]_AC_LANG_ABBREV[]_preproc_warn_flag in '' yes
+do
+ # 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_PREPROC_IFELSE([AC_LANG_SOURCE([[@%:@include <assert.h>
+ Syntax error]])],
+ [],
+ [# Broken: fails on valid input.
+continue])
+
+ # OK, works on sane cases. Now check whether non-existent headers
+ # can be detected and how.
+ _AC_PREPROC_IFELSE([AC_LANG_SOURCE([[@%:@include <ac_nonexistent.h>]])],
+ [# Broken: success on invalid input.
+continue],
+ [# Passes both tests.
+ac_preproc_ok=:
+break])
+
+done
+# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped.
+rm -f conftest.err conftest.$ac_ext
+AS_IF([$ac_preproc_ok], [$1], [$2])])# _AC_PROG_PREPROC_WORKS_IFELSE
# AC_PROG_CPP
# Double quotes because CPP needs to be expanded
for CPP in "$CC -E" "$CC -E -traditional-cpp" "/lib/cpp"
do
- _AC_PROG_PREPROC_WORKS_IFELSE([break])
+ # break 2 since there is a loop in there.
+ _AC_PROG_PREPROC_WORKS_IFELSE([break 2])
done
ac_cv_prog_CPP=$CPP
])dnl
# Double quotes because CXXCPP needs to be expanded
for CXXCPP in "$CXX -E" "/lib/cpp"
do
- _AC_PROG_PREPROC_WORKS_IFELSE([break])
+ # break 2 since there is a loop in there.
+ _AC_PROG_PREPROC_WORKS_IFELSE([break 2])
done
ac_cv_prog_CXXCPP=$CXXCPP
])dnl
# 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_PREPROC_WORKS_IFELSE],
-[# We don't know yet if stderr is the criterion (vs exit status).
-ac_[]_AC_LANG_ABBREV[]_preproc_warn_flag=maybe
-
-# 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_PREPROC_IFELSE([AC_LANG_SOURCE([[@%:@include <assert.h>
-Syntax error]])],
-[# OK, works on sane cases. Now check whether non-existent headers can
-# be detected and how.
-_AC_PREPROC_IFELSE([AC_LANG_SOURCE([[@%:@include <ac_nonexistent.h>]])],
-[# Broken: cannot detect missing includes.
-m4_default([$2], :)],
-[# OK, detects failures. How?
-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
-$1])],
- [# Broken: fails on valid input.
-m4_default([$2], :)])])# _AC_PROG_PREPROC_WORKS_IFELSE
+[ac_preproc_ok=false
+for ac_[]_AC_LANG_ABBREV[]_preproc_warn_flag in '' yes
+do
+ # 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_PREPROC_IFELSE([AC_LANG_SOURCE([[@%:@include <assert.h>
+ Syntax error]])],
+ [],
+ [# Broken: fails on valid input.
+continue])
+
+ # OK, works on sane cases. Now check whether non-existent headers
+ # can be detected and how.
+ _AC_PREPROC_IFELSE([AC_LANG_SOURCE([[@%:@include <ac_nonexistent.h>]])],
+ [# Broken: success on invalid input.
+continue],
+ [# Passes both tests.
+ac_preproc_ok=:
+break])
+
+done
+# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped.
+rm -f conftest.err conftest.$ac_ext
+AS_IF([$ac_preproc_ok], [$1], [$2])])# _AC_PROG_PREPROC_WORKS_IFELSE
# AC_PROG_CPP
# Double quotes because CPP needs to be expanded
for CPP in "$CC -E" "$CC -E -traditional-cpp" "/lib/cpp"
do
- _AC_PROG_PREPROC_WORKS_IFELSE([break])
+ # break 2 since there is a loop in there.
+ _AC_PROG_PREPROC_WORKS_IFELSE([break 2])
done
ac_cv_prog_CPP=$CPP
])dnl
# Double quotes because CXXCPP needs to be expanded
for CXXCPP in "$CXX -E" "/lib/cpp"
do
- _AC_PROG_PREPROC_WORKS_IFELSE([break])
+ # break 2 since there is a loop in there.
+ _AC_PROG_PREPROC_WORKS_IFELSE([break 2])
done
ac_cv_prog_CXXCPP=$CXXCPP
])dnl
# 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_PREPROC_WORKS_IFELSE],
-[# We don't know yet if stderr is the criterion (vs exit status).
-ac_[]_AC_LANG_ABBREV[]_preproc_warn_flag=maybe
-
-# 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_PREPROC_IFELSE([AC_LANG_SOURCE([[@%:@include <assert.h>
-Syntax error]])],
-[# OK, works on sane cases. Now check whether non-existent headers can
-# be detected and how.
-_AC_PREPROC_IFELSE([AC_LANG_SOURCE([[@%:@include <ac_nonexistent.h>]])],
-[# Broken: cannot detect missing includes.
-m4_default([$2], :)],
-[# OK, detects failures. How?
-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
-$1])],
- [# Broken: fails on valid input.
-m4_default([$2], :)])])# _AC_PROG_PREPROC_WORKS_IFELSE
+[ac_preproc_ok=false
+for ac_[]_AC_LANG_ABBREV[]_preproc_warn_flag in '' yes
+do
+ # 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_PREPROC_IFELSE([AC_LANG_SOURCE([[@%:@include <assert.h>
+ Syntax error]])],
+ [],
+ [# Broken: fails on valid input.
+continue])
+
+ # OK, works on sane cases. Now check whether non-existent headers
+ # can be detected and how.
+ _AC_PREPROC_IFELSE([AC_LANG_SOURCE([[@%:@include <ac_nonexistent.h>]])],
+ [# Broken: success on invalid input.
+continue],
+ [# Passes both tests.
+ac_preproc_ok=:
+break])
+
+done
+# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped.
+rm -f conftest.err conftest.$ac_ext
+AS_IF([$ac_preproc_ok], [$1], [$2])])# _AC_PROG_PREPROC_WORKS_IFELSE
# AC_PROG_CPP
# Double quotes because CPP needs to be expanded
for CPP in "$CC -E" "$CC -E -traditional-cpp" "/lib/cpp"
do
- _AC_PROG_PREPROC_WORKS_IFELSE([break])
+ # break 2 since there is a loop in there.
+ _AC_PROG_PREPROC_WORKS_IFELSE([break 2])
done
ac_cv_prog_CPP=$CPP
])dnl
# Double quotes because CXXCPP needs to be expanded
for CXXCPP in "$CXX -E" "/lib/cpp"
do
- _AC_PROG_PREPROC_WORKS_IFELSE([break])
+ # break 2 since there is a loop in there.
+ _AC_PROG_PREPROC_WORKS_IFELSE([break 2])
done
ac_cv_prog_CXXCPP=$CXXCPP
])dnl
# 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_PREPROC_WORKS_IFELSE],
-[# We don't know yet if stderr is the criterion (vs exit status).
-ac_[]_AC_LANG_ABBREV[]_preproc_warn_flag=maybe
-
-# 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_PREPROC_IFELSE([AC_LANG_SOURCE([[@%:@include <assert.h>
-Syntax error]])],
-[# OK, works on sane cases. Now check whether non-existent headers can
-# be detected and how.
-_AC_PREPROC_IFELSE([AC_LANG_SOURCE([[@%:@include <ac_nonexistent.h>]])],
-[# Broken: cannot detect missing includes.
-m4_default([$2], :)],
-[# OK, detects failures. How?
-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
-$1])],
- [# Broken: fails on valid input.
-m4_default([$2], :)])])# _AC_PROG_PREPROC_WORKS_IFELSE
+[ac_preproc_ok=false
+for ac_[]_AC_LANG_ABBREV[]_preproc_warn_flag in '' yes
+do
+ # 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_PREPROC_IFELSE([AC_LANG_SOURCE([[@%:@include <assert.h>
+ Syntax error]])],
+ [],
+ [# Broken: fails on valid input.
+continue])
+
+ # OK, works on sane cases. Now check whether non-existent headers
+ # can be detected and how.
+ _AC_PREPROC_IFELSE([AC_LANG_SOURCE([[@%:@include <ac_nonexistent.h>]])],
+ [# Broken: success on invalid input.
+continue],
+ [# Passes both tests.
+ac_preproc_ok=:
+break])
+
+done
+# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped.
+rm -f conftest.err conftest.$ac_ext
+AS_IF([$ac_preproc_ok], [$1], [$2])])# _AC_PROG_PREPROC_WORKS_IFELSE
# AC_PROG_CPP
# Double quotes because CPP needs to be expanded
for CPP in "$CC -E" "$CC -E -traditional-cpp" "/lib/cpp"
do
- _AC_PROG_PREPROC_WORKS_IFELSE([break])
+ # break 2 since there is a loop in there.
+ _AC_PROG_PREPROC_WORKS_IFELSE([break 2])
done
ac_cv_prog_CPP=$CPP
])dnl
# Double quotes because CXXCPP needs to be expanded
for CXXCPP in "$CXX -E" "/lib/cpp"
do
- _AC_PROG_PREPROC_WORKS_IFELSE([break])
+ # break 2 since there is a loop in there.
+ _AC_PROG_PREPROC_WORKS_IFELSE([break 2])
done
ac_cv_prog_CXXCPP=$CXXCPP
])dnl
# Ignore if /lib/cpp doesn't work
AT_CHECK([/lib/cpp </dev/null || exit 77], [], [ignore], [ignore])
+# A cpp which exit status is meaningless.
AT_DATA([mycpp],
[[#! /bin/sh
/lib/cpp ${1+"$@"}
echo "Annoying copyright message" >&2
if test "$1" != "-E"; then
exec cc $*
+elif test "$2" = "-traditional-cpp"; then
+ exec cc $*
else
- if test "$2" = "-traditional-cpp"; then
- exec cc $*
- else
- exec /lib/cpp ${1+"$@"}
- fi
+ exec /lib/cpp ${1+"$@"}
fi
]])
chmod +x mycc
+# We go through the following contortions, in order to have the
+# configure script go down the same codepaths as it would during a
+# normal CPP selection check. If we explicitly set CPP, it goes down
+# a different codepath.
_AT_CHECK_AC_MACRO(
-[[# We go through the following contortions, in order to
-# have the configure script go down the same codepaths
-# as it would during a normal CPP selection check. If
-# we explicitly set CPP, it goes down a different codepath.
-CC=mycc
+[[CC=./mycc
AC_PROG_CPP
# The test $CC compiler should have been selected.
-test "$CPP" != "mycc -E" &&
+test "$CPP" != "$CC -E" &&
AC_MSG_ERROR([error messages on stderr cause the preprocessor selection to fail])
-# If the preprocessor is not strict, just ignore
-test "x$ac_c_preproc_warn_flag" = xyes &&
- AC_MSG_ERROR([preprocessor has no warning option], 77)
+
+# Exercise CPP.
AC_CHECK_HEADERS(stdio.h autoconf_io.h)]])
AT_CHECK_DEFINES(