From: Vincent Bernat Date: Fri, 12 Jul 2013 22:07:16 +0000 (+0200) Subject: configure: check for `res_init()` before trying other forms. X-Git-Tag: 0.7.7~51 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=d0a033727caad9731e4d7628eaba3c02b9ba8b47;p=thirdparty%2Flldpd.git configure: check for `res_init()` before trying other forms. On OSX, `res_init()` is a symbol of `libsystem_info` (a dependency of `libSystem`). So, AC_SEARCH_LIBS directly finds this symbol without an additional library. However, once you include `resolv.h`, this becomes a macro to `res_9_init` which is a symbol of `libresolv`. So you need to link to `libresolv`. This is why we test first for `res_9_init` and only after for `res_init`. See more info about this here: http://blog.achernya.com/2013/03/os-x-has-silly-libsystem.html However, on other systems, this will link to libbind while this is not needed because `res_9_init` is a symbol of libbind while `res_init` is correctly defined in `libc` and no odd redefinition. So, the solution is to force `AC_SEARCH_LIBS` to include `resolv.h` and only test for `res_init` (as a symbol or a macro, we don't care). This is done by redefining `AC_LANG_CALL(C)` to include `resolv.h`. --- diff --git a/configure.ac b/configure.ac index 948dfdc8..0cb80791 100644 --- a/configure.ac +++ b/configure.ac @@ -106,9 +106,15 @@ case " $LIBS " in ;; esac -AC_SEARCH_LIBS([__res_init], resolv bind, AC_DEFINE([HAVE_RES_INIT], 1, [Define to indicate that res_init() exists]), -AC_SEARCH_LIBS([res_9_init], resolv bind, AC_DEFINE([HAVE_RES_INIT], 1, [Define to indicate that res_init() exists]), -AC_SEARCH_LIBS([res_init], resolv bind, AC_DEFINE([HAVE_RES_INIT], 1, [Define to indicate that res_init() exists])))) +# Check for res_init. On OSX, res_init is a symbol in libsystem_info +# and a macro in resolv.h. We need to ensure we test with resolv.h. +m4_pushdef([AC_LANG_CALL(C)], [ + AC_LANG_PROGRAM([$1 +@%:@include ], [return $2 ();])]) +AC_SEARCH_LIBS([res_init], resolv bind, + AC_DEFINE([HAVE_RES_INIT], 1, + [Define to indicate that res_init() exists])) +m4_popdef([AC_LANG_CALL(C)]) AC_CACHE_SAVE diff --git a/src/daemon/priv.c b/src/daemon/priv.c index 904b87be..6b65e911 100644 --- a/src/daemon/priv.c +++ b/src/daemon/priv.c @@ -57,7 +57,9 @@ #ifdef HAVE_NETDB_H # include #endif -#include +#ifdef HAVE_RESOLV_H +# include +#endif static int monitored = -1; /* Child */