$NetBSD: patch-configure,v 1.11 2022/10/22 16:30:49 nia Exp $

* Remove non-portable sort usage.
* Found iconv function in libc. Fix Libs.private=-liconv in sdl2.pc.

--- configure.orig	2022-10-04 23:48:35.000000000 +0000
+++ configure
@@ -17902,59 +17902,6 @@ if  test -z "$AWK" ; then
     as_fn_error $? "*** awk not found, aborting" "$LINENO" 5
 fi
 
-for ac_prog in gsort sort
-do
-  # Extract the first word of "$ac_prog", so it can be a program name with args.
-set dummy $ac_prog; ac_word=$2
-{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-printf %s "checking for $ac_word... " >&6; }
-if test ${ac_cv_prog_SORT+y}
-then :
-  printf %s "(cached) " >&6
-else $as_nop
-  if test -n "$SORT"; then
-  ac_cv_prog_SORT="$SORT" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
-  IFS=$as_save_IFS
-  case $as_dir in #(((
-    '') as_dir=./ ;;
-    */) ;;
-    *) as_dir=$as_dir/ ;;
-  esac
-    for ac_exec_ext in '' $ac_executable_extensions; do
-  if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then
-    ac_cv_prog_SORT="$ac_prog"
-    printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5
-    break 2
-  fi
-done
-  done
-IFS=$as_save_IFS
-
-fi
-fi
-SORT=$ac_cv_prog_SORT
-if test -n "$SORT"; then
-  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $SORT" >&5
-printf "%s\n" "$SORT" >&6; }
-else
-  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5
-printf "%s\n" "no" >&6; }
-fi
-
-
-  test -n "$SORT" && break
-done
-test -n "$SORT" || SORT="false"
-
-if ! "$SORT" -V </dev/null >/dev/null
-then :
-  as_fn_error $? "GNU sort(1) is required" "$LINENO" 5
-fi
-
 # Check whether --enable-largefile was given.
 if test ${enable_largefile+y}
 then :
@@ -18284,7 +18231,7 @@ find_lib()
         host_lib_path="/usr/$base_libdir /usr/local/$base_libdir"
     fi
     for path in $env_lib_path $gcc_bin_path $gcc_lib_path $host_lib_path; do
-        lib=`ls -- $path/$1 2>/dev/null | sed 's,.*/,,' | "$SORT" -V -r | $AWK 'BEGIN{FS="."}{ print NF, $0 }' | "$SORT" -n -s | sed 's,[0-9]* ,,' | head -1`
+        lib=`ls -- $path/$1 2>/dev/null | sed 's,.*/,,' | "$SORT" -r | $AWK 'BEGIN{FS="."}{ print NF, $0 }' | "$SORT" -n -s | sed 's,[0-9]* ,,' | head -1`
         if test x$lib != x; then
             echo $lib
             return
@@ -19883,7 +19830,48 @@ then :
 fi
 
 
-    { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for iconv_open in -liconv" >&5
+    { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for iconv_open in -lc" >&5
+printf %s "checking for iconv_open in -lc... " >&6; }
+if test ${ac_cv_lib_c_iconv_open+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-lc  $LIBS"
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+char iconv_open ();
+int
+main (void)
+{
+return iconv_open ();
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"
+then :
+  ac_cv_lib_c_iconv_open=yes
+else $as_nop
+  ac_cv_lib_c_iconv_open=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.beam \
+    conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_c_iconv_open" >&5
+printf "%s\n" "$ac_cv_lib_c_iconv_open" >&6; }
+if test "x$ac_cv_lib_c_iconv_open" = xyes
+then :
+  found_libc_iconv=yes
+fi
+
+    if test x$found_libc_iconv != xyes; then
+      { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for iconv_open in -liconv" >&5
 printf %s "checking for iconv_open in -liconv... " >&6; }
 if test ${ac_cv_lib_iconv_iconv_open+y}
 then :
@@ -19923,6 +19911,7 @@ then :
   LIBS="$LIBS -liconv"; EXTRA_LDFLAGS="$EXTRA_LDFLAGS -liconv"
 fi
 
+    fi
     ac_fn_c_check_func "$LINENO" "iconv" "ac_cv_func_iconv"
 if test "x$ac_cv_func_iconv" = xyes
 then :
