Blame SOURCES/autofs-5.0.7-workaround-missing-GNU-versionsort-extension.patch

304803
autofs-5.0.7 - workaround missing GNU versionsort extension
304803
304803
From: Chris Packham <chris.packham@alliedtelesis.co.nz>
304803
304803
alphasort() and scandir() are specified in POSIX.1-2008, versionsort()
304803
is a GNU extension. When versionsort isn't available fallback to using
304803
alphasort.
304803
---
304803
304803
 CHANGELOG            |    1 +
304803
 configure            |   62 ++++++++++++++++++++++++++++++++++++++++++++++++++
304803
 configure.in         |    6 +++++
304803
 include/config.h.in  |    3 ++
304803
 modules/lookup_dir.c |    5 ++++
304803
 5 files changed, 77 insertions(+), 0 deletions(-)
304803
304803
304803
diff --git a/CHANGELOG b/CHANGELOG
304803
index 4eaa9f9..39388a5 100644
304803
--- a/CHANGELOG
304803
+++ b/CHANGELOG
304803
@@ -27,6 +27,7 @@
304803
 - lib/defaults.c: use WITH_LDAP conditional around LDAP types.
304803
 - make yellow pages support optional.
304803
 - modules/replicated.c: use sin6_addr.s6_addr32.
304803
+- workaround missing GNU versionsort extension.
304803
 
304803
 25/07/2012 autofs-5.0.7
304803
 =======================
304803
diff --git a/configure b/configure
304803
index cf6428c..c1423d8 100755
304803
--- a/configure
304803
+++ b/configure
304803
@@ -4010,6 +4010,68 @@ $as_echo "yes" >&6; }
304803
   KRB5_FLAGS=`$KRB5_CONFIG --cflags`
304803
 fi
304803
 
304803
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing versionsort" >&5
304803
+$as_echo_n "checking for library containing versionsort... " >&6; }
304803
+if ${ac_cv_search_versionsort+:} false; then :
304803
+  $as_echo_n "(cached) " >&6
304803
+else
304803
+  ac_func_search_save_LIBS=$LIBS
304803
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
304803
+/* end confdefs.h.  */
304803
+
304803
+/* Override any GCC internal prototype to avoid an error.
304803
+   Use char because int might match the return type of a GCC
304803
+   builtin and then its argument prototype would still apply.  */
304803
+#ifdef __cplusplus
304803
+extern "C"
304803
+#endif
304803
+char versionsort ();
304803
+int
304803
+main ()
304803
+{
304803
+return versionsort ();
304803
+  ;
304803
+  return 0;
304803
+}
304803
+_ACEOF
304803
+for ac_lib in '' ; do
304803
+  if test -z "$ac_lib"; then
304803
+    ac_res="none required"
304803
+  else
304803
+    ac_res=-l$ac_lib
304803
+    LIBS="-l$ac_lib  $ac_func_search_save_LIBS"
304803
+  fi
304803
+  if ac_fn_c_try_link "$LINENO"; then :
304803
+  ac_cv_search_versionsort=$ac_res
304803
+fi
304803
+rm -f core conftest.err conftest.$ac_objext \
304803
+    conftest$ac_exeext
304803
+  if ${ac_cv_search_versionsort+:} false; then :
304803
+  break
304803
+fi
304803
+done
304803
+if ${ac_cv_search_versionsort+:} false; then :
304803
+
304803
+else
304803
+  ac_cv_search_versionsort=no
304803
+fi
304803
+rm conftest.$ac_ext
304803
+LIBS=$ac_func_search_save_LIBS
304803
+fi
304803
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_versionsort" >&5
304803
+$as_echo "$ac_cv_search_versionsort" >&6; }
304803
+ac_res=$ac_cv_search_versionsort
304803
+if test "$ac_res" != no; then :
304803
+  test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
304803
+
304803
+fi
304803
+
304803
+if test "$ac_cv_search_versionsort" = "no"; then
304803
+
304803
+$as_echo "#define WITHOUT_VERSIONSORT 1" >>confdefs.h
304803
+
304803
+fi
304803
+
304803
 #
304803
 # glibc/libc 6 new libraries
304803
 #
304803
diff --git a/configure.in b/configure.in
304803
index 363c376..4029375 100644
304803
--- a/configure.in
304803
+++ b/configure.in
304803
@@ -163,6 +163,12 @@ AF_SLOPPY_MOUNT()
304803
 AF_CHECK_LIBXML()
304803
 AF_CHECK_KRB5()
304803
 
304803
+AC_SEARCH_LIBS([versionsort],[])
304803
+if test "$ac_cv_search_versionsort" = "no"; then
304803
+	AC_DEFINE(WITHOUT_VERSIONSORT, 1,
304803
+		[Define if your C library does not provide versionsort])
304803
+fi
304803
+
304803
 #
304803
 # glibc/libc 6 new libraries
304803
 #
304803
diff --git a/include/config.h.in b/include/config.h.in
304803
index 7f1c5b5..a2a05a8 100644
304803
--- a/include/config.h.in
304803
+++ b/include/config.h.in
304803
@@ -135,6 +135,9 @@
304803
 /* Define to 1 to use the libtirpc tsd usage workaround */
304803
 #undef TIRPC_WORKAROUND
304803
 
304803
+/* Define if your C library does not provide versionsort */
304803
+#undef WITHOUT_VERSIONSORT
304803
+
304803
 /* Define if using the dmalloc debugging malloc package */
304803
 #undef WITH_DMALLOC
304803
 
304803
diff --git a/modules/lookup_dir.c b/modules/lookup_dir.c
304803
index 33901c0..07471b7 100644
304803
--- a/modules/lookup_dir.c
304803
+++ b/modules/lookup_dir.c
304803
@@ -39,6 +39,11 @@
304803
 #define AUTOFS_DIR_EXT ".autofs"
304803
 #define AUTOFS_DIR_EXTSIZ (sizeof(AUTOFS_DIR_EXT) - 1)
304803
 
304803
+/* Work around non-GNU systems that don't provide versionsort */
304803
+#ifdef WITHOUT_VERSIONSORT
304803
+#define versionsort alphasort
304803
+#endif
304803
+
304803
 struct lookup_context {
304803
   const char *mapname;
304803
 };