From 8a9917270c9c0120623bae52a739f4e60582e72b Mon Sep 17 00:00:00 2001 From: Kevin Easton Date: Thu, 24 May 2012 13:02:44 +0000 Subject: [PATCH] Alter method of finding resolver library name, to hopefully work on OSX. Now uses AC_LINK_IFELSE() to link a program that calls res_mkquery(), after defining BIND_8_COMPAT / BIND_4_COMPAT as per misc.c. git-svn-id: svn://svn.code.sf.net/p/bitchx/code/trunk@193 13b04d17-f746-0410-82c6-800466cd88b0 --- configure.in | 50 ++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 48 insertions(+), 2 deletions(-) diff --git a/configure.in b/configure.in index e2a98d5..962e535 100644 --- a/configure.in +++ b/configure.in @@ -57,8 +57,6 @@ AC_CHECK_LIB(sun, getpwnam, LIBS="-lsun $LIBS",) AC_CHECK_LIB(dgc, inet_addr, LIBS="-ldgc $LIBS",) AC_CHECK_LIB(crypt, crypt, LIBS="-lcrypt $LIBS"; AC_DEFINE(HAVE_CRYPT, 1, Define this if you have a crypt implementation in -lcrypt),) AC_CHECK_LIB(m, pow, LIBS="-lm $LIBS",) -AC_SEARCH_LIBS([res_mkquery], [resolv], AC_DEFINE(HAVE_RESOLV, 1, Define this if you have the resolv library.), -[AC_SEARCH_LIBS([__res_mkquery], [resolv], AC_DEFINE(HAVE_RESOLV, 1, Define this if you have the resolv library.), [], [])], []) dnl Checks for header files. AC_HEADER_DIRENT @@ -119,6 +117,54 @@ else fi fi +dnl Check for resolver library (used by /NSLOOKUP) +AC_CACHE_CHECK([library required for resolver functions], [bx_cv_lib_resolver], +[ +OLDLIBS="$LIBS" +bx_cv_lib_resolver="not found" +for reslib in '' '-lresolv' '-lbind' '-lsocket' +do + LIBS="$reslib $OLDLIBS" + AC_LINK_IFELSE([ + #if defined( __APPLE__ ) && !defined( BIND_8_COMPAT ) + #define BIND_8_COMPAT + #endif + #if defined( __OpenBSD__ ) && !defined( BIND_4_COMPAT ) + #define BIND_4_COMPAT + #endif + AC_INCLUDES_DEFAULT + #ifdef HAVE_NETINET_IN_H + #include + #endif + #ifdef HAVE_ARPA_NAMESER_H + #include + #endif + #ifdef HAVE_RESOLV_H + #include + #endif + + int main() + { + return res_mkquery(0, 0, 0, 0, 0, 0, 0, 0, 0); + }], [ + if test x"$reslib" != x; then + bx_cv_lib_resolver="$reslib" + else + bx_cv_lib_resolver="none required" + fi + break], []) +done +LIBS="$OLDLIBS" +]) +if test x"$bx_cv_lib_resolver" != x"not found"; then + AC_DEFINE(HAVE_RESOLV, 1, Define this if you have the resolv library.) + if test x"$bx_cv_lib_resolver" != x"none required"; then + LIBS="$bx_cv_lib_resolver $LIBS" + fi +else + AC_MSG_WARN([No resolver library found, /nslookup will be disabled.]) +fi + dnl Checks for library functions. AC_FUNC_ALLOCA if test x"$cross_compiling" != x"yes"; then