Skip to content

Instantly share code, notes, and snippets.

@bortzmeyer
Created December 19, 2010 21:42
Show Gist options
  • Save bortzmeyer/747718 to your computer and use it in GitHub Desktop.
Save bortzmeyer/747718 to your computer and use it in GitHub Desktop.
Testing if -lresolv is necessary or not
AC_CHECK_FUNC(res_mkquery, ,
[AC_CHECK_LIB(bind, res_mkquery, ,
[AC_CHECK_LIB(resolv, res_mkquery, ,
[ saved_LIBS="$LIBS"
LIBS="$LIBS -lresolv"
AC_MSG_CHECKING(for res_mkquery in -lresolv again)
AC_LINK_IFELSE([[
#include <resolv.h>
int main()
{
res_mkquery (0, 0, 0, 0, 0, 0, 0, 0, 0);
return 0;
}]],
LIBS="$saved_LIBS -lresolv"; AC_MSG_RESULT(yes),
LIBS="$saved_LIBS"; AC_MSG_RESULT(no)
[AC_MSG_ERROR([No DNS resolver development environment found])])])])])
dnl in the Makefile.in:
dnl LDFLAGS=@LIBS@
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment