diff mbox series

Make find_cxx_header compatible with current clang output.

Message ID 20210823191831.597883-1-galibert@pobox.com
State Superseded
Headers show
Series Make find_cxx_header compatible with current clang output. | expand

Checks

Context Check Description
dj/TryBot-apply_patch success Patch applied to master at the time it was sent
dj/TryBot-32bit success Build for i686

Commit Message

Olivier Galibert Aug. 23, 2021, 7:18 p.m. UTC
For some reason clang does not put the main header in the descendant
lists in -M -MP, so sed doesn't pick it up.  Use awk to find the
correct header in the depedencies lists instead.

Signed-off-by: Olivier Galibert <galibert@pobox.com>
---
 configure    | 3 ++-
 configure.ac | 3 ++-
 2 files changed, 4 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/configure b/configure
index 23f5e69445..0f476763b2 100755
--- a/configure
+++ b/configure
@@ -5521,7 +5521,8 @@  fi
 if test -n "$CXX"; then
   find_cxx_header () {
     echo "#include <$1>" | $CXX -M -MP -x c++ - 2>/dev/null \
-	 | sed -n "\,$1:,{s/:\$//;p}"
+	 | awk -vp=$1 '{ for(i=1;i<=NF;i++) if(substr($i, length($i)-length(p)+1) == p) print $i }' \
+	 | head -n 1
   }
   CXX_CSTDLIB_HEADER="$(find_cxx_header cstdlib)"
   CXX_CMATH_HEADER="$(find_cxx_header cmath)"
diff --git a/configure.ac b/configure.ac
index 53462290a0..1180411a95 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1115,7 +1115,8 @@  AC_SUBST(CXX_SYSINCLUDES)
 if test -n "$CXX"; then
   find_cxx_header () {
     echo "#include <$1>" | $CXX -M -MP -x c++ - 2>/dev/null \
-	 | sed -n "\,$1:,{s/:\$//;p}"
+	 | awk -vp=$1 '{ for(i=1;i<=NF;i++) if(substr($i, length($i)-length(p)+1) == p) print $i }' \
+	 | head -n 1
   }
   CXX_CSTDLIB_HEADER="$(find_cxx_header cstdlib)"
   CXX_CMATH_HEADER="$(find_cxx_header cmath)"