onsdag den 15 augusti 2012 klockan 12:44 skrev Mats Erik Andersson detta: > onsdag den 15 augusti 2012 klockan 11:58 skrev Mats Erik Andersson detta: > > fredag den 10 augusti 2012 klockan 09:47 skrev Simon Josefsson detta: > > > Mats, could you please re-try whether -lresolv detection works on BSDs? > > > I have changed it to use AC_LIB_HAVE_LINKFLAGS instead which should be > > > more reliable and flexible. What I'm uncertain about is: doesn't BSDs > > > provide libresolv at all? > > > > Answer, first installment for convenience: > > > > DragonflyBSD, FreeBSD, and OpenBSD > > > > * do not provide libresolv at all; > > Second installment: > > Suffice it to test FreeBSD: > > * res_query() is not detected.
The following patch is able to detect and link correctly on GNU/Linux, OpenSolaris, FreeBSD, and NetBSD in order that res_query() be available to shishi_resolv(). There has been an error in thinking at the code of "lib/resolv.c": * The C source should have no business whatsoever to care for WITH_LIBRESOLV. What it should do is instead * Build a rich, non-trivial shishi_resolv() if res_query() is defined, however it be so. I.e., build an interesting shishi_resolv() whenever WITH_RES_QUERY happens to be defined. The patch achieves this goal by first investigation whether res_query() happens to be available in libc. That failing it proceeds to invoke AS_LIB_HAVE_LINKFLAGS as a means of detecting libresolv. This last step has for a long time been implemented as a contrived mechanism to claim the presence of res_query(), so that outcome is backported as AC_DEFINE([WITH_RES_QUERY]). Some details are needed, but the above is the essential message. Best regards, Mats Erik Andersson
>From 6b0fdb1d1bb064265da442abc609f6081402eba3 Mon Sep 17 00:00:00 2001 From: Mats Erik Andersson <g...@gisladisker.se> Date: Wed, 22 Aug 2012 20:13:15 +0200 Subject: [PATCH 1/2] Locate res_query and libresolv. For portability res_query must be searched in libc, and in libresolv. The latter need not even exist on systems such as BSD. --- configure.ac | 31 +++++++++++++++++++++++++------ lib/resolv.c | 12 ++++++++---- 2 files changed, 33 insertions(+), 10 deletions(-) diff --git a/configure.ac b/configure.ac index 7c38731..919fcfc 100644 --- a/configure.ac +++ b/configure.ac @@ -42,6 +42,12 @@ gl2_EARLY gl3_EARLY AC_HEADER_STDC AC_CHECK_HEADERS(termios.h pwd.h syslog.h arpa/nameser.h netinet/in6.h) +AC_CHECK_HEADERS(resolv.h, , , [#include <sys/types.h> + #include <netinet/in.h> + #ifdef HAVE_ARPA_NAMESER_H + # include <arpa/nameser.h> + #endif +]) # Used when creating libshishi-XX.def. SOVERSION=`expr ${LT_CURRENT} - ${LT_AGE}` @@ -81,14 +87,27 @@ if test "$ac_cv_libgcrypt" != yes; then fi # Checks for library functions. -AC_CHECK_FUNCS(signal select ngettext gethostbyname getpwnam getuid) +AC_CHECK_FUNCS(signal select ngettext gethostbyname getpwnam getuid res_query) AC_SEARCH_LIBS(socket, socket) AC_SEARCH_LIBS(gethostbyname, nsl) -AC_LIB_HAVE_LINKFLAGS(resolv,, [ - #include <netinet/in.h> - #include <arpa/nameser.h> - #include <resolv.h> -], [res_query (0, 0, 0, 0, 0);]) + +# BSD systems deliver res_query in libc. +# Most of them do not even offer libresolv. +if test "$ac_cv_func_res_query" != yes; then + AC_LIB_HAVE_LINKFLAGS(resolv,, [ + #include <netinet/in.h> + #include <arpa/nameser.h> + #include <resolv.h> + ], [res_query (0, 0, 0, 0, 0);]) + # Check again, with newly acquired knowledge. + if test "$ac_cv_libresolv" = yes; then + AC_DEFINE([HAVE_RES_QUERY], 1, + [Define to 1 if you have the res_query function.]) + fi +fi +dnl Declare LIBRESOLV and LTLIBRESOLV in all cases. +AC_SUBST(LIBRESOLV) +AC_SUBST(LTLIBRESOLV) # Shishid needs a logging mechanism, and right now there is no # alternative to syslog. A 'fprintf(stderr,...)' mechanism may be diff --git a/lib/resolv.c b/lib/resolv.c index 57d4824..599d5b4 100644 --- a/lib/resolv.c +++ b/lib/resolv.c @@ -30,11 +30,15 @@ #include "internal.h" -#ifdef HAVE_LIBRESOLV +#ifdef HAVE_RES_QUERY #include <netinet/in.h> -#include <arpa/nameser.h> -#include <resolv.h> +# ifdef HAVE_ARPA_NAMESER_H +# include <arpa/nameser.h> +# endif +# ifdef HAVE_RESOLV_H +# include <resolv.h> +# endif /* the largest packet we'll send and receive */ #if PACKETSZ > 1024 @@ -263,7 +267,7 @@ shishi_resolv (const char *zone, uint16_t querytype) return first; } -#else +#else /* !HAVE_RES_QUERY */ Shishi_dns shishi_resolv (const char *zone, uint16_t querytype) -- 1.7.2.5
_______________________________________________ Help-shishi mailing list Help-shishi@gnu.org https://lists.gnu.org/mailman/listinfo/help-shishi