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

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