summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZack Weinberg <zackw@panix.com>2020-09-10 12:10:41 -0400
committerZack Weinberg <zackw@panix.com>2020-09-10 12:10:41 -0400
commitb560f0a657be0ba69417d26589ffd93a26f62573 (patch)
treebccac8c77a244b43e9f165fe7d746ddc6ee925b0
parent14265094af1614d9e359550ca4a4939e590a5dba (diff)
downloadautoconf-b560f0a657be0ba69417d26589ffd93a26f62573.tar.gz
AC_PROG_*CPP: Try ‘cpp’ before ‘/lib/cpp’
All of the AC_PROG_*CPP macros fall back to ‘/lib/cpp’ if invoking the relevant compiler with ‘-E’ doesn’t work. This is an obsolete location to find the C preprocessor. Linux distributions tend to ship a compatibility symlink, as do Solaris and AIX (as of the versions in the GCC compile farm, anyway), but the BSDs no longer do. The tests for this fallback are already expecting ‘cpp’ to be a command findable via $PATH, so make the probe macros do the same thing. (We still try ‘/lib/cpp’ if ‘cpp’ _isn’t_ in $PATH.) * lib/autoconf/c.m4 (AC_PROG_CPP, AC_PROG_CXXCPP, AC_PROG_OBJCPP, AC_PROG_OBJCXXCPP): If $CC / $CXX / $OBJC / $OBJCXX -E (respectively) does not run the preprocessor, look for ‘cpp’ in $PATH before falling back to ‘/lib/cpp’. * doc/autoconf.texi (AC_PROG_CPP, AC_PROG_CXXCPP, AC_PROG_OBJCPP, AC_PROG_OBJCXXCPP): Update to match.
-rw-r--r--doc/autoconf.texi19
-rw-r--r--lib/autoconf/c.m416
2 files changed, 23 insertions, 12 deletions
diff --git a/doc/autoconf.texi b/doc/autoconf.texi
index 43df8f32..4bd6e9e7 100644
--- a/doc/autoconf.texi
+++ b/doc/autoconf.texi
@@ -7371,7 +7371,9 @@ For the compiler @var{compiler}, this macro caches its result in the
@evindex CPP
@ovindex CPP
Set output variable @code{CPP} to a command that runs the
-C preprocessor. If @samp{$CC -E} doesn't work, @file{/lib/cpp} is used.
+C preprocessor. If @samp{$CC -E} doesn't work, tries @code{cpp} and
+@file{/lib/cpp}, in that order.
+
It is only portable to run @code{CPP} on files with a @file{.c}
extension.
@@ -7742,7 +7744,10 @@ C++, the @option{-std=gnu++@var{nn}} options may be used, but not the
@evindex CXXCPP
@ovindex CXXCPP
Set output variable @code{CXXCPP} to a command that runs the C++
-preprocessor. If @samp{$CXX -E} doesn't work, @file{/lib/cpp} is used.
+preprocessor. If @samp{$CXX -E} doesn't work, tries @code{cpp} and
+@file{/lib/cpp}, in that order. Because of this fallback, @code{CXXCPP}
+may or may not set C++-specific predefined macros (such as @code{__cplusplus}).
+
It is portable to run @code{CXXCPP} only on files with a @file{.c},
@file{.C}, @file{.cc}, or @file{.cpp} extension.
@@ -7799,7 +7804,10 @@ compiler (@option{-O2} on systems where the compiler does not accept
@evindex OBJCPP
@ovindex OBJCPP
Set output variable @code{OBJCPP} to a command that runs the Objective C
-preprocessor. If @samp{$OBJC -E} doesn't work, @file{/lib/cpp} is used.
+preprocessor. If @samp{$OBJC -E} doesn't work, tries @code{cpp} and
+@file{/lib/cpp}, in that order. Because of this fallback, @code{CXXCPP}
+may or may not set Objective-C-specific predefined macros (such as
+@code{__OBJC__}).
@end defmac
@@ -7840,7 +7848,10 @@ compiler (@option{-O2} on systems where the compiler does not accept
@evindex OBJCXXCPP
@ovindex OBJCXXCPP
Set output variable @code{OBJCXXCPP} to a command that runs the Objective C++
-preprocessor. If @samp{$OBJCXX -E} doesn't work, @file{/lib/cpp} is used.
+preprocessor. If @samp{$OBJCXX -E} doesn't work, tries @code{cpp} and
+@file{/lib/cpp}, in that order. Because of this fallback, @code{CXXCPP}
+may or may not set Objective-C++-specific predefined macros (such as
+@code{__cplusplus} and @code{__OBJC__}).
@end defmac
diff --git a/lib/autoconf/c.m4 b/lib/autoconf/c.m4
index 5d6e7b71..fe6aa2b6 100644
--- a/lib/autoconf/c.m4
+++ b/lib/autoconf/c.m4
@@ -385,8 +385,8 @@ fi
if test -z "$CPP"; then
AC_CACHE_VAL([ac_cv_prog_CPP],
[dnl
- # Double quotes because CPP needs to be expanded
- for CPP in "$CC -E" "$CC -E -traditional-cpp" "/lib/cpp"
+ # Double quotes because $CC needs to be expanded
+ for CPP in "$CC -E" "$CC -E -traditional-cpp" cpp /lib/cpp
do
_AC_PROG_PREPROC_WORKS_IFELSE([break])
done
@@ -644,8 +644,8 @@ AC_MSG_CHECKING([how to run the C++ preprocessor])
if test -z "$CXXCPP"; then
AC_CACHE_VAL(ac_cv_prog_CXXCPP,
[dnl
- # Double quotes because CXXCPP needs to be expanded
- for CXXCPP in "$CXX -E" "/lib/cpp"
+ # Double quotes because $CXX needs to be expanded
+ for CXXCPP in "$CXX -E" cpp /lib/cpp
do
_AC_PROG_PREPROC_WORKS_IFELSE([break])
done
@@ -837,8 +837,8 @@ AC_MSG_CHECKING([how to run the Objective C preprocessor])
if test -z "$OBJCPP"; then
AC_CACHE_VAL(ac_cv_prog_OBJCPP,
[dnl
- # Double quotes because OBJCPP needs to be expanded
- for OBJCPP in "$OBJC -E" "/lib/cpp"
+ # Double quotes because $OBJC needs to be expanded
+ for OBJCPP in "$OBJC -E" cpp /lib/cpp
do
_AC_PROG_PREPROC_WORKS_IFELSE([break])
done
@@ -976,8 +976,8 @@ AC_MSG_CHECKING([how to run the Objective C++ preprocessor])
if test -z "$OBJCXXCPP"; then
AC_CACHE_VAL(ac_cv_prog_OBJCXXCPP,
[dnl
- # Double quotes because OBJCXXCPP needs to be expanded
- for OBJCXXCPP in "$OBJCXX -E" "/lib/cpp"
+ # Double quotes because $OBJCXX needs to be expanded
+ for OBJCXXCPP in "$OBJCXX -E" cpp /lib/cpp
do
_AC_PROG_PREPROC_WORKS_IFELSE([break])
done