1dnl ==================================================================
2dnl Checks for networking
3dnl ==================================================================
4
5if test "x$PKG_CONFIG" != "x"; then
6  PKG_CHECK_MODULES([LIBCURL], [libcurl], HAVE_LIBCURL=yes, HAVE_LIBCURL=no)
7  if test "x$HAVE_LIBCURL" = xyes; then
8    AC_DEFINE(HAVE_LIBCURL,1,
9      [Define to 1 if you have a functional curl library.])
10  fi
11  CURL=$HAVE_LIBCURL
12else
13  LIBCURL_CHECK_CONFIG([], [], [CURL=yes], [])
14  LIBCURL_LIBS=$LIBCURL
15  AC_SUBST(LIBCURL_LIBS)
16fi
17
18AC_ARG_WITH(ipv6,
19	AS_HELP_STRING([--with-ipv6=DIR],
20				   [Enable IPv6 support.]
21				   [Optional argument specifies location of inet6 libraries.]),
22	[
23	if test "x$withval" = xno ; then
24		NETTYPE_IPV6=no
25	else
26		AC_DEFINE(HAVE_IPV6, 1, [Define this if you want IPv6 support])
27		NETTYPE_IPV6=yes
28		if test "x$withval" != xyes ; then
29			LIBS="$LIBS -L${withval}"
30		fi
31	fi
32	],
33	[NETTYPE_IPV6=no]
34)
35AM_CONDITIONAL(NETTYPE_IPV6, test "x$NETTYPE_IPV6" = "xyes")
36
37if test "x$ac_cv_func_connect" != "xyes"; then
38	AC_CHECK_LIB(socket, connect,
39					NET_LIBS="$NET_LIBS -lsocket"
40					ac_cv_func_connect=yes
41				)
42fi
43if test "x$ac_cv_func_gethostbyname" != "xyes"; then
44	AC_CHECK_LIB(nsl, gethostbyname,
45					NET_LIBS="$NET_LIBS -lnsl"
46					ac_cv_func_gethostbyname=yes
47				)
48fi
49if test "x$ac_cv_func_gethostbyname" != "xyes"; then
50SAVELIBS="$LIBS"
51#FIXME this should be checked too
52LIBS="$LIBS -lsysmodule"
53	AC_CHECK_LIB(net, gethostbyname,
54					NET_LIBS="$NET_LIBS -lnet -lsysmodule"
55					ac_cv_func_gethostbyname=yes
56				)
57LIBS="$SAVELIBS"
58fi
59
60AC_MSG_CHECKING([for connect in -lwsock32])
61SAVELIBS="$LIBS"
62LIBS="$LIBS -lwsock32"
63AC_TRY_LINK([
64#include <winsock.h>
65],
66[
67connect(0, NULL, 42);
68],
69	NET_LIBS="$NET_LIBS -lwsock32 -lwinmm"
70	ac_cv_func_connect=yes
71	ac_cv_func_gethostbyname=yes
72	HAVE_WSOCK=yes
73	AC_MSG_RESULT(yes),
74	AC_MSG_RESULT(no)
75)
76LIBS="$SAVELIBS"
77
78AC_MSG_CHECKING(for UDP support)
79if test "x$ac_cv_func_connect" = "xyes" -a "x$ac_cv_func_gethostbyname" = "xyes"; then
80	HAVE_UDP=yes
81	AC_MSG_RESULT(yes)
82else
83	AC_MSG_RESULT(no)
84fi
85
86if test "x$ac_cv_func_connect" != "xyes"; then
87	AC_MSG_CHECKING([for connect in -lwsock32])
88	SAVELIBS="$LIBS"
89	LIBS="$LIBS -lwsock32"
90	AC_TRY_LINK([
91#include <winsock.h>
92		],
93		[
94connect (0, NULL, 42);
95		],
96	    NET_LIBS="$NET_LIBS -lwsock32 -lwinmm"
97	    AC_MSG_RESULT(yes),
98	    AC_MSG_RESULT(no)
99	)
100	LIBS="$SAVELIBS"
101fi
102AC_SUBST(NET_LIBS)
103
104AC_MSG_CHECKING([for getifaddrs])
105SAVELIBS="$LIBS"
106LIBS="$LIBS $NET_LIBS"
107AC_TRY_LINK([],
108	[
109getifaddrs (0);
110	],
111	AC_DEFINE(HAVE_GETIFADDRS, 1, [Define this if you have getifaddrs()])
112	AC_MSG_RESULT(yes),
113	AC_MSG_RESULT(no)
114)
115LIBS="$SAVELIBS"
116