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

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