autotools: choose correct library for res_query()

See #72 for further information.
This commit is contained in:
Dmitry Podgorny
2016-02-05 23:30:32 +00:00
parent fc82aaeef2
commit a7c18ba6c7
2 changed files with 35 additions and 14 deletions

View File

@@ -9,6 +9,8 @@ PARSER_LIBS=@PARSER_LIBS@
SSL_CFLAGS = @openssl_CFLAGS@ SSL_CFLAGS = @openssl_CFLAGS@
SSL_LIBS = @openssl_LIBS@ SSL_LIBS = @openssl_LIBS@
DIST_LIBS = @DIST_LIBS@
STROPHE_FLAGS = -I$(top_srcdir) STROPHE_FLAGS = -I$(top_srcdir)
STROPHE_LIBS = libstrophe.la STROPHE_LIBS = libstrophe.la
@@ -16,7 +18,7 @@ STROPHE_LIBS = libstrophe.la
lib_LTLIBRARIES = libstrophe.la lib_LTLIBRARIES = libstrophe.la
libstrophe_la_CFLAGS = $(SSL_CFLAGS) $(STROPHE_FLAGS) $(PARSER_CFLAGS) libstrophe_la_CFLAGS = $(SSL_CFLAGS) $(STROPHE_FLAGS) $(PARSER_CFLAGS)
libstrophe_la_LDFLAGS = $(SSL_LIBS) $(PARSER_LIBS) -no-undefined libstrophe_la_LDFLAGS = $(SSL_LIBS) $(PARSER_LIBS) $(DIST_LIBS) -no-undefined
# Export only public API # Export only public API
libstrophe_la_LDFLAGS += -export-symbols-regex '^xmpp_' libstrophe_la_LDFLAGS += -export-symbols-regex '^xmpp_'
libstrophe_la_SOURCES = src/auth.c src/conn.c src/ctx.c \ libstrophe_la_SOURCES = src/auth.c src/conn.c src/ctx.c \

View File

@@ -9,8 +9,12 @@ PKG_PROG_PKG_CONFIG
AC_CANONICAL_HOST AC_CANONICAL_HOST
AS_CASE([$host_os], AS_CASE([$host_os],
[freebsd*], [PLATFORM="freebsd"], [freebsd*], [PLATFORM="bsd"],
[PLATFORM="nix"]) [openbsd*], [PLATFORM="bsd"],
[netbsd*], [PLATFORM="bsd"],
[*nto*|*qnx*], [PLATFORM="qnx"],
[*solaris*], [PLATFORM="solaris"],
[PLATFORM="nix"])
PKG_CHECK_MODULES([openssl], [openssl], [PC_REQUIRES="openssl ${PC_REQUIRES}"], PKG_CHECK_MODULES([openssl], [openssl], [PC_REQUIRES="openssl ${PC_REQUIRES}"],
[AC_CHECK_HEADER([openssl/ssl.h], [AC_CHECK_HEADER([openssl/ssl.h],
@@ -62,12 +66,10 @@ fi
if test "x$with_libxml2" = xyes; then if test "x$with_libxml2" = xyes; then
with_parser=libxml2 with_parser=libxml2
PARSER_NAME=libxml2
PARSER_CFLAGS=$libxml2_CFLAGS PARSER_CFLAGS=$libxml2_CFLAGS
PARSER_LIBS=$libxml2_LIBS PARSER_LIBS=$libxml2_LIBS
else else
with_parser=expat with_parser=expat
PARSER_NAME=expat
PARSER_CFLAGS=$expat_CFLAGS PARSER_CFLAGS=$expat_CFLAGS
PARSER_LIBS=$expat_LIBS PARSER_LIBS=$expat_LIBS
fi fi
@@ -75,14 +77,31 @@ fi
AC_MSG_NOTICE([libstrophe will use the $with_parser XML parser]) AC_MSG_NOTICE([libstrophe will use the $with_parser XML parser])
AC_SEARCH_LIBS([socket], [socket]) AC_SEARCH_LIBS([socket], [socket])
if test "x$PLATFORM" != xfreebsd; then DIST_LIBS=""
AC_CHECK_LIB([resolv], [res_query], [], AS_CASE([$PLATFORM],
[AC_CHECK_LIB([resolv], [__res_query], [], [bsd], [DIST_LIBS="${DIST_LIBS}"],
[AC_MSG_ERROR([libresolv not found; libresolv required.])])]) [qnx], [DIST_LIBS="-lsocket ${DIST_LIBS}"],
PC_LIBS="-lresolv ${PC_LIBS}" [solaris], [DIST_LIBS="-lresolv -lsocket -lnsl ${DIST_LIBS}"],
else [DIST_LIBS="-lresolv ${DIST_LIBS}"])
AC_MSG_NOTICE([skipping libresolv checks for freebsd])
fi LIBS_TMP="${LIBS}"
LIBS="${DIST_LIBS}"
AC_LINK_IFELSE([AC_LANG_SOURCE([
#include <sys/types.h>
#include <netinet/in.h>
#include <arpa/nameser.h>
#include <resolv.h>
#include <netdb.h>
int main() {
(void)res_query(NULL, 0, 0, NULL, 0);
return 0;
}
])],
[],
[AC_MSG_ERROR([res_query() not found with LIBS="${LIBS}"])])
LIBS="${LIBS_TMP}"
PC_LIBS="${DIST_LIBS} ${PC_LIBS}"
AC_CHECK_HEADERS([arpa/nameser_compat.h]) AC_CHECK_HEADERS([arpa/nameser_compat.h])
@@ -100,8 +119,8 @@ AC_SUBST([PC_REQUIRES], [${PC_REQUIRES}])
AC_SUBST([PC_CFLAGS], [${PC_CFLAGS}]) AC_SUBST([PC_CFLAGS], [${PC_CFLAGS}])
AC_SUBST([PC_LIBS], [${PC_LIBS}]) AC_SUBST([PC_LIBS], [${PC_LIBS}])
AC_SUBST(PARSER_NAME)
AC_SUBST(PARSER_CFLAGS) AC_SUBST(PARSER_CFLAGS)
AC_SUBST(PARSER_LIBS) AC_SUBST(PARSER_LIBS)
AC_SUBST(DIST_LIBS)
AC_CONFIG_FILES([Makefile libstrophe.pc]) AC_CONFIG_FILES([Makefile libstrophe.pc])
AC_OUTPUT AC_OUTPUT