]> git.ipfire.org Git - thirdparty/lldpd.git/commitdiff
configure: check for `res_init()` before trying other forms.
authorVincent Bernat <bernat@luffy.cx>
Fri, 12 Jul 2013 22:07:16 +0000 (00:07 +0200)
committerVincent Bernat <bernat@luffy.cx>
Sat, 13 Jul 2013 00:21:18 +0000 (02:21 +0200)
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`.

configure.ac
src/daemon/priv.c

index 948dfdc87eae2b87625990b4a734e82d3fe4b61a..0cb8079187409bc6ac6a51a2454d2c67761542b9 100644 (file)
@@ -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 <resolv.h>], [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
 
index 904b87bec082e3969e867726398d610e636c25e6..6b65e9110f44064d4c7c42659e445b75428d81f8 100644 (file)
@@ -57,7 +57,9 @@
 #ifdef HAVE_NETDB_H
 #  include <netdb.h>
 #endif
-#include <resolv.h>
+#ifdef HAVE_RESOLV_H
+#  include <resolv.h>
+#endif
 
 static int monitored = -1;             /* Child */