SDL_image: autotools: fix non-pkgconfig path for libavif after commit 8065fd0e484

From 1fc6b34f661ecc3daf4b27b6e7eda2ad61a91b6f Mon Sep 17 00:00:00 2001
From: Ozkan Sezer <[EMAIL REDACTED]>
Date: Fri, 8 Sep 2023 21:11:50 +0300
Subject: [PATCH] autotools: fix non-pkgconfig path for libavif after commit
 8065fd0e484

---
 configure    | 66 +++++++++++++++++++++++++++++++++++++++++++++++-----
 configure.ac | 15 ++++++++----
 2 files changed, 71 insertions(+), 10 deletions(-)

diff --git a/configure b/configure
index 4331dd29..550f3321 100755
--- a/configure
+++ b/configure
@@ -14380,7 +14380,17 @@ fi
 	# Put the nasty error message in config.log where it belongs
 	echo "$LIBAVIF_PKG_ERRORS" >&5
 
-	        cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+	        save_LIBS="$LIBS"
+        LIBS="-lavif"
+        ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+        { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for libavif >= 0.9.3" >&5
+printf %s "checking for libavif >= 0.9.3... " >&6; }
+        cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 
           #include <avif/avif.h>
@@ -14389,11 +14399,16 @@ int
 main (void)
 {
 
+          #if (AVIF_VERSION < 90300)
+          #error libavif too old.
+          #endif
+          return !!avifVersion();
+
   ;
   return 0;
 }
 _ACEOF
-if ac_fn_c_try_compile "$LINENO"
+if ac_fn_c_try_link "$LINENO"
 then :
 
             have_avif_hdr=yes
@@ -14401,13 +14416,35 @@ then :
             LIBAVIF_CFLAGS=""
             LIBAVIF_LIBS="-lavif"
 
+else $as_nop
+  have_avif_lib=no
 fi
-rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext
+rm -f core conftest.err conftest.$ac_objext conftest.beam \
+    conftest$ac_exeext conftest.$ac_ext
+        LIBS="$save_LIBS"
+        ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+        { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $have_avif_lib" >&5
+printf "%s\n" "$have_avif_lib" >&6; }
 
 elif test $pkg_failed = untried; then
         { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5
 printf "%s\n" "no" >&6; }
-	        cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+	        save_LIBS="$LIBS"
+        LIBS="-lavif"
+        ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+        { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for libavif >= 0.9.3" >&5
+printf %s "checking for libavif >= 0.9.3... " >&6; }
+        cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 
           #include <avif/avif.h>
@@ -14416,11 +14453,16 @@ int
 main (void)
 {
 
+          #if (AVIF_VERSION < 90300)
+          #error libavif too old.
+          #endif
+          return !!avifVersion();
+
   ;
   return 0;
 }
 _ACEOF
-if ac_fn_c_try_compile "$LINENO"
+if ac_fn_c_try_link "$LINENO"
 then :
 
             have_avif_hdr=yes
@@ -14428,8 +14470,20 @@ then :
             LIBAVIF_CFLAGS=""
             LIBAVIF_LIBS="-lavif"
 
+else $as_nop
+  have_avif_lib=no
 fi
-rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext
+rm -f core conftest.err conftest.$ac_objext conftest.beam \
+    conftest$ac_exeext conftest.$ac_ext
+        LIBS="$save_LIBS"
+        ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+        { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $have_avif_lib" >&5
+printf "%s\n" "$have_avif_lib" >&6; }
 
 else
 	LIBAVIF_CFLAGS=$pkg_cv_LIBAVIF_CFLAGS
diff --git a/configure.ac b/configure.ac
index b0a7bd2b..021e2a70 100644
--- a/configure.ac
+++ b/configure.ac
@@ -311,19 +311,26 @@ if test x$enable_avif = xyes; then
         have_avif_lib=yes
         have_avif_pc=yes
       ], [dnl
-        AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
+        save_LIBS="$LIBS"
+        LIBS="-lavif"
+        AC_LANG_PUSH([C])
+        AC_MSG_CHECKING([for libavif >= 0.9.3])
+        AC_LINK_IFELSE([AC_LANG_PROGRAM([[
           #include <avif/avif.h>
-        ]],, [[
+        ]], [[
           #if (AVIF_VERSION < 90300)
           #error libavif too old.
           #endif
           return !!avifVersion();
-        ]])], [
+        ]])],[
             have_avif_hdr=yes
             have_avif_lib=yes
             LIBAVIF_CFLAGS=""
             LIBAVIF_LIBS="-lavif"
-        ])
+        ], [have_avif_lib=no])
+        LIBS="$save_LIBS"
+        AC_LANG_POP([C])
+        AC_MSG_RESULT([$have_avif_lib])
       ])
     if test x$have_avif_hdr = xyes -a x$have_avif_lib = xyes; then
         if test x$enable_avif = xyes; then