From ae0fef2a50a3e6a0aacfee672cc7994fed367ecf Mon Sep 17 00:00:00 2001 From: "tdjogi010@gmail.com" Date: Mon, 11 Apr 2016 01:24:37 +0530 Subject: [PATCH] Ensure we can actually link with sys_errlist &c. Previously we just checked that the symbol was declared, but the Android NDK declares it without including an implementation in the library, so compilation succeeds but linking fails. As before, we care about both _errlist and _nerr, and we check for both sys_errlist and _sys_errlist variants. (cherry picked from commit 96d31c85c5b2d8d39f18afbe303d540479c6faf0) --- xapian-core/AUTHORS | 1 + xapian-core/configure.ac | 53 +++++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 53 insertions(+), 1 deletion(-) diff --git a/xapian-core/AUTHORS b/xapian-core/AUTHORS index 4badb8455..9f6d5c35a 100644 --- a/xapian-core/AUTHORS +++ b/xapian-core/AUTHORS @@ -212,3 +212,4 @@ Helpful comments, bug reports, small patches: Val Rosca Andreas Vögele Mark Dufour + Tejas Jogi diff --git a/xapian-core/configure.ac b/xapian-core/configure.ac index cb7cd5a60..fc7f847bd 100644 --- a/xapian-core/configure.ac +++ b/xapian-core/configure.ac @@ -745,7 +745,58 @@ dnl Checks for library functions. AC_FUNC_MEMCMP AC_CHECK_FUNCS([hstrerror]) AC_FUNC_STRERROR_R -AC_CHECK_DECLS([sys_errlist, _sys_errlist, sys_nerr, _sys_nerr]) + +AC_CACHE_CHECK([if libc defines sys_errlist], ac_cv_libc_defines_sys_errlist, [ + AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include ]], +[[ printf("%s", sys_errlist[0]);]])], + [ ac_cv_libc_defines_sys_errlist="yes" ], + [ ac_cv_libc_defines_sys_errlist="no" + ]) +]) +if test "x$ac_cv_libc_defines_sys_errlist" = "xyes" ; then + AC_DEFINE([HAVE_DECL_SYS_ERRLIST], [1],[Define if your system defines sys_errlist[]]) +else + AC_DEFINE([HAVE_DECL_SYS_ERRLIST], [0],[Define if your system defines sys_errlist[]]) +fi + +AC_CACHE_CHECK([if libc defines _sys_errlist], ac_cv_libc_defines__sys_errlist, [ + AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include ]], +[[ printf("%s", _sys_errlist[0]);]])], + [ ac_cv_libc_defines__sys_errlist="yes" ], + [ ac_cv_libc_defines__sys_errlist="no" + ]) +]) +if test "x$ac_cv_libc_defines__sys_errlist" = "xyes" ; then + AC_DEFINE([HAVE_DECL__SYS_ERRLIST], [1], [Define if your system defines _sys_errlist[]]) +else + AC_DEFINE([HAVE_DECL__SYS_ERRLIST], [0], [Define if your system defines _sys_errlist[]]) +fi + +AC_CACHE_CHECK([if libc defines sys_nerr], ac_cv_libc_defines_sys_nerr, [ + AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include ]], +[[ printf("%i", sys_nerr);]])], + [ ac_cv_libc_defines_sys_nerr="yes" ], + [ ac_cv_libc_defines_sys_nerr="no" + ]) +]) +if test "x$ac_cv_libc_defines_sys_nerr" = "xyes" ; then + AC_DEFINE([HAVE_DECL_SYS_NERR], [1], [Define if your system defines sys_nerr]) +else + AC_DEFINE([HAVE_DECL_SYS_NERR], [0], [Define if your system defines sys_nerr]) +fi + +AC_CACHE_CHECK([if libc defines _sys_nerr], ac_cv_libc_defines__sys_nerr, [ + AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include ]], +[[ printf("%i", _sys_nerr);]])], + [ ac_cv_libc_defines__sys_nerr="yes" ], + [ ac_cv_libc_defines__sys_nerr="no" + ]) +]) +if test "x$ac_cv_libc_defines__sys_nerr" = "xyes" ; then + AC_DEFINE([HAVE_DECL__SYS_NERR], [1], [Define if your system defines _sys_nerr]) +else + AC_DEFINE([HAVE_DECL__SYS_NERR], [0], [Define if your system defines _sys_nerr]) +fi dnl Check that snprintf actually works as it's meant to. dnl -- 2.11.4.GIT