SDL: configure.ac: manually check immintrin.h with AC_COMPILE_IFELSE().

From 2143534a1cf2c3c66af2b62672bf743cf4872f3c Mon Sep 17 00:00:00 2001
From: Ozkan Sezer <[EMAIL REDACTED]>
Date: Mon, 28 Jun 2021 02:00:24 +0300
Subject: [PATCH] configure.ac: manually check immintrin.h with
 AC_COMPILE_IFELSE().

AC_CHECK_HEADER() emits warnings when configuring for non-x86, because
the preprocessor check is OK but the compile check is not:

configure: WARNING: immintrin.h: present but cannot be compiled
configure: WARNING: immintrin.h:     check for missing prerequisite headers?
configure: WARNING: immintrin.h: see the Autoconf documentation
configure: WARNING: immintrin.h:     section "Present But Cannot Be Compiled"
configure: WARNING: immintrin.h: proceeding with the compiler's result
---
 configure    | 22 +++++++++++++++++-----
 configure.ac |  8 ++++----
 2 files changed, 21 insertions(+), 9 deletions(-)

diff --git a/configure b/configure
index 432a7c821..1f71632c5 100755
--- a/configure
+++ b/configure
@@ -17826,14 +17826,27 @@ $as_echo "$have_gcc_sse3" >&6; }
         fi
     fi
 
-    ac_fn_c_check_header_mongrel "$LINENO" "immintrin.h" "ac_cv_header_immintrin_h" "$ac_includes_default"
-if test "x$ac_cv_header_immintrin_h" = xyes; then :
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for immintrin.h" >&5
+$as_echo_n "checking for immintrin.h... " >&6; }
+    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <immintrin.h>
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
   have_immintrin_h_hdr=yes
 else
   have_immintrin_h_hdr=no
 fi
-
-
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+    { $as_echo "$as_me:${as_lineno-$LINENO}: result: $have_immintrin_h_hdr" >&5
+$as_echo "$have_immintrin_h_hdr" >&6; }
     if test x$have_immintrin_h_hdr = xyes; then
 
 $as_echo "#define HAVE_IMMINTRIN_H 1" >>confdefs.h
@@ -26104,7 +26117,6 @@ if test x$WARN_ABOUT_ARM_SIMD_ASM_MIT = xyes; then
     SUMMARY="${SUMMARY}configure script with:\n"
     SUMMARY="${SUMMARY}\n    --disable-arm-simd\n"
 fi
-
 if test x$WARN_ABOUT_ARM_NEON_ASM_MIT = xyes; then
     SUMMARY="${SUMMARY}\nSDL is being built with ARM NEON optimizations, which\n"
     SUMMARY="${SUMMARY}uses code licensed under the MIT license. If this is a\n"
diff --git a/configure.ac b/configure.ac
index 275dcbb44..f54202ad0 100644
--- a/configure.ac
+++ b/configure.ac
@@ -729,9 +729,10 @@ if test x$enable_assembly = xyes; then
         fi
     fi
 
-    AC_CHECK_HEADER(immintrin.h,
-                    have_immintrin_h_hdr=yes,
-                    have_immintrin_h_hdr=no)
+    AC_MSG_CHECKING(for immintrin.h)
+    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <immintrin.h>]])],
+       [have_immintrin_h_hdr=yes],[have_immintrin_h_hdr=no])
+    AC_MSG_RESULT($have_immintrin_h_hdr)
     if test x$have_immintrin_h_hdr = xyes; then
         AC_DEFINE(HAVE_IMMINTRIN_H, 1, [ ])
     fi
@@ -4520,7 +4521,6 @@ if test x$WARN_ABOUT_ARM_SIMD_ASM_MIT = xyes; then
     SUMMARY="${SUMMARY}configure script with:\n"
     SUMMARY="${SUMMARY}\n    --disable-arm-simd\n"
 fi
-
 if test x$WARN_ABOUT_ARM_NEON_ASM_MIT = xyes; then
     SUMMARY="${SUMMARY}\nSDL is being built with ARM NEON optimizations, which\n"
     SUMMARY="${SUMMARY}uses code licensed under the MIT license. If this is a\n"