From 16d3e8b23941664fd6aaffb952ea2eeb3a2b5b74 Mon Sep 17 00:00:00 2001 From: Nick Wellnhofer Date: Wed, 7 Sep 2022 18:10:03 +0200 Subject: [PATCH] autotools: Only add network libraries if HTTP/FTP enabled --- configure.ac | 128 ++++++++++++++++++++++++++------------------------- 1 file changed, 65 insertions(+), 63 deletions(-) diff --git a/configure.ac b/configure.ac index abdc6729..5df1e7bb 100644 --- a/configure.ac +++ b/configure.ac @@ -348,74 +348,76 @@ va_list ap1, ap2; a(&ap1); ap2 = (va_list) ap1],[ dnl dnl Checks for inet libraries dnl -_libs=$LIBS -AC_SEARCH_LIBS(gethostbyname, [nsl ws2_32], [ - if test "$ac_cv_search_gethostbyname" != "none required"; then - NET_LIBS="$NET_LIBS $ac_cv_search_gethostbyname" - fi], [:], [$NET_LIBS]) -AC_SEARCH_LIBS(connect, [bsd socket inet ws2_32], [ - if test "$ac_cv_search_connect" != "none required"; then - NET_LIBS="$NET_LIBS $ac_cv_search_connect" - fi], [:], [$NET_LIBS]) -LIBS=$_libs +if test "$with_http" != "no" || test "with_ftp" = "yes"; then + _libs=$LIBS + AC_SEARCH_LIBS(gethostbyname, [nsl ws2_32], [ + if test "$ac_cv_search_gethostbyname" != "none required"; then + NET_LIBS="$NET_LIBS $ac_cv_search_gethostbyname" + fi], [:], [$NET_LIBS]) + AC_SEARCH_LIBS(connect, [bsd socket inet ws2_32], [ + if test "$ac_cv_search_connect" != "none required"; then + NET_LIBS="$NET_LIBS $ac_cv_search_connect" + fi], [:], [$NET_LIBS]) + LIBS=$_libs -dnl Determine what socket length (socklen_t) data type is -AC_MSG_CHECKING([for type of socket length (socklen_t)]) -AC_TRY_COMPILE2([ -#include -#ifdef _WIN32 - #include -#else - #include -#endif],[ -(void)getsockopt (1, 1, 1, NULL, (socklen_t *)NULL)],[ - AC_MSG_RESULT(socklen_t *) - XML_SOCKLEN_T=socklen_t],[ - AC_TRY_COMPILE2([ -#include -#include ],[ -(void)getsockopt (1, 1, 1, NULL, (size_t *)NULL)],[ - AC_MSG_RESULT(size_t *) - XML_SOCKLEN_T=size_t],[ + dnl Determine what socket length (socklen_t) data type is + AC_MSG_CHECKING([for type of socket length (socklen_t)]) AC_TRY_COMPILE2([ -#include -#include ],[ -(void)getsockopt (1, 1, 1, NULL, (int *)NULL)],[ - AC_MSG_RESULT(int *) - XML_SOCKLEN_T=int],[ - AC_MSG_WARN(could not determine) - XML_SOCKLEN_T="int"])])]) -AC_DEFINE_UNQUOTED(XML_SOCKLEN_T, $XML_SOCKLEN_T, [Determine what socket length (socklen_t) data type is]) - -dnl -dnl Checking for availability of IPv6 -dnl -AC_ARG_ENABLE(ipv6, [ --enable-ipv6[[=yes/no]] enables compilation of IPv6 code [[default=yes]]],, enable_ipv6=yes) -if test "$with_minimum" = "yes" -then - enable_ipv6=no -fi -if test $enable_ipv6 = yes; then - AC_MSG_CHECKING([whether to enable IPv6]) - AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ + #include #ifdef _WIN32 - #include + #include #else #include - #ifdef HAVE_NETDB_H - #include - #endif - #endif - ]], [[ - struct sockaddr_storage ss; - socket(AF_INET6, SOCK_STREAM, 0); - getaddrinfo(0, 0, 0, 0); - ]])], [ - AC_DEFINE([SUPPORT_IP6], [], [Support for IPv6]) - AC_MSG_RESULT([yes])], [ - AC_MSG_RESULT([no])] - ) -fi + #endif],[ + (void)getsockopt (1, 1, 1, NULL, (socklen_t *)NULL)],[ + AC_MSG_RESULT(socklen_t *) + XML_SOCKLEN_T=socklen_t],[ + AC_TRY_COMPILE2([ + #include + #include ],[ + (void)getsockopt (1, 1, 1, NULL, (size_t *)NULL)],[ + AC_MSG_RESULT(size_t *) + XML_SOCKLEN_T=size_t],[ + AC_TRY_COMPILE2([ + #include + #include ],[ + (void)getsockopt (1, 1, 1, NULL, (int *)NULL)],[ + AC_MSG_RESULT(int *) + XML_SOCKLEN_T=int],[ + AC_MSG_WARN(could not determine) + XML_SOCKLEN_T="int"])])]) + AC_DEFINE_UNQUOTED(XML_SOCKLEN_T, $XML_SOCKLEN_T, [Determine what socket length (socklen_t) data type is]) + + dnl + dnl Checking for availability of IPv6 + dnl + AC_ARG_ENABLE(ipv6, [ --enable-ipv6[[=yes/no]] enables compilation of IPv6 code [[default=yes]]],, enable_ipv6=yes) + if test "$with_minimum" = "yes" + then + enable_ipv6=no + fi + if test $enable_ipv6 = yes; then + AC_MSG_CHECKING([whether to enable IPv6]) + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ + #ifdef _WIN32 + #include + #else + #include + #ifdef HAVE_NETDB_H + #include + #endif + #endif + ]], [[ + struct sockaddr_storage ss; + socket(AF_INET6, SOCK_STREAM, 0); + getaddrinfo(0, 0, 0, 0); + ]])], [ + AC_DEFINE([SUPPORT_IP6], [], [Support for IPv6]) + AC_MSG_RESULT([yes])], [ + AC_MSG_RESULT([no])] + ) + fi +fi dnl dnl Extra flags