1 dnl Wget-specific Autoconf macros.
2 dnl Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003,
3 dnl 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software
6 dnl This program is free software; you can redistribute it and/or modify
7 dnl it under the terms of the GNU General Public License as published by
8 dnl the Free Software Foundation; either version 3 of the License, or
9 dnl (at your option) any later version.
11 dnl This program is distributed in the hope that it will be useful,
12 dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
13 dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 dnl GNU General Public License for more details.
16 dnl You should have received a copy of the GNU General Public License
17 dnl along with this program. If not, see <http://www.gnu.org/licenses/>.
19 dnl Additional permission under GNU GPL version 3 section 7
21 dnl If you modify this program, or any covered work, by linking or
22 dnl combining it with the OpenSSL project's OpenSSL library (or a
23 dnl modified version of that library), containing parts covered by the
24 dnl terms of the OpenSSL or SSLeay licenses, the Free Software Foundation
25 dnl grants you additional permission to convey the resulting work.
26 dnl Corresponding Source for a non-source form of such a combination
27 dnl shall include the source code for the parts of OpenSSL used as well
28 dnl as that of the covered work.
31 dnl Check for `struct utimbuf'.
34 AC_DEFUN([WGET_STRUCT_UTIMBUF], [
35 AC_CHECK_TYPES([struct utimbuf], [], [], [
38 # include <sys/types.h>
46 dnl Check whether fnmatch.h can be included. This doesn't use
47 dnl AC_FUNC_FNMATCH because Wget is already careful to only use
48 dnl fnmatch on certain OS'es. However, fnmatch.h is sometimes broken
49 dnl even on those because Apache installs its own fnmatch.h to
50 dnl /usr/local/include (!), which GCC uses before /usr/include.
52 AC_DEFUN([WGET_FNMATCH], [
53 AC_MSG_CHECKING([for working fnmatch.h])
54 AC_COMPILE_IFELSE([AC_LANG_SOURCE([#include <fnmatch.h>
57 AC_DEFINE([HAVE_WORKING_FNMATCH_H], 1,
58 [Define if fnmatch.h can be included.])
64 dnl Check for nanosleep. For nanosleep to work on Solaris, we must
65 dnl link with -lrt (recently) or with -lposix4 (older releases).
67 AC_DEFUN([WGET_NANOSLEEP], [
68 AC_CHECK_FUNCS(nanosleep, [], [
69 AC_CHECK_LIB(rt, nanosleep, [
70 AC_DEFINE([HAVE_NANOSLEEP], 1,
71 [Define if you have the nanosleep function.])
74 AC_CHECK_LIB(posix4, nanosleep, [
75 AC_DEFINE([HAVE_NANOSLEEP], 1,
76 [Define if you have the nanosleep function.])
83 AC_DEFUN([WGET_POSIX_CLOCK], [
84 AC_CHECK_FUNCS(clock_gettime, [], [
85 AC_CHECK_LIB(rt, clock_gettime)
89 dnl Check whether we need to link with -lnsl and -lsocket, as is the
90 dnl case on e.g. Solaris.
92 AC_DEFUN([WGET_NSL_SOCKET], [
93 dnl On Solaris, -lnsl is needed to use gethostbyname. But checking
94 dnl for gethostbyname is not enough because on "NCR MP-RAS 3.0"
95 dnl gethostbyname is in libc, but -lnsl is still needed to use
96 dnl -lsocket, as well as for functions such as inet_ntoa. We look
97 dnl for such known offenders and if one of them is not found, we
98 dnl check if -lnsl is needed.
99 wget_check_in_nsl=NONE
100 AC_CHECK_FUNCS(gethostbyname, [], [
101 wget_check_in_nsl=gethostbyname
103 AC_CHECK_FUNCS(inet_ntoa, [], [
104 wget_check_in_nsl=inet_ntoa
106 if test $wget_check_in_nsl != NONE; then
107 AC_CHECK_LIB(nsl, $wget_check_in_nsl)
109 AC_CHECK_LIB(socket, socket)
113 dnl ************************************************************
114 dnl START OF IPv6 AUTOCONFIGURATION SUPPORT MACROS
115 dnl ************************************************************
117 AC_DEFUN([TYPE_STRUCT_SOCKADDR_IN6],[
118 wget_have_sockaddr_in6=
119 AC_CHECK_TYPES([struct sockaddr_in6],[
120 wget_have_sockaddr_in6=yes
122 wget_have_sockaddr_in6=no
124 #include <sys/types.h>
125 #ifdef HAVE_SYS_SOCKET_H
126 #include <sys/socket.h>
128 #ifdef HAVE_NETINET_IN_H
129 #include <netinet/in.h>
131 #ifdef HAVE_WINSOCK2_H
132 #include <winsock2.h>
134 #ifdef HAVE_WS2TCPIP_H
135 #include <ws2tcpip.h>
139 if test "X$wget_have_sockaddr_in6" = "Xyes"; then :
147 AC_DEFUN([MEMBER_SIN6_SCOPE_ID],[
148 AC_REQUIRE([TYPE_STRUCT_SOCKADDR_IN6])
150 wget_member_sin6_scope_id=
151 if test "X$wget_have_sockaddr_in6" = "Xyes"; then
152 AC_CHECK_MEMBER([struct sockaddr_in6.sin6_scope_id],[
153 wget_member_sin6_scope_id=yes
155 wget_member_sin6_scope_id=no
157 #include <sys/types.h>
158 #ifdef HAVE_SYS_SOCKET_H
159 #include <sys/socket.h>
161 #ifdef HAVE_NETINET_IN_H
162 #include <netinet/in.h>
164 #ifdef HAVE_WINSOCK2_H
165 #include <winsock2.h>
167 #ifdef HAVE_WS2TCPIP_H
168 #include <ws2tcpip.h>
173 if test "X$wget_member_sin6_scope_id" = "Xyes"; then
174 AC_DEFINE([HAVE_SOCKADDR_IN6_SCOPE_ID], 1,
175 [Define if struct sockaddr_in6 has the sin6_scope_id member])
183 AC_DEFUN([PROTO_INET6],[
184 AC_CACHE_CHECK([for INET6 protocol support], [wget_cv_proto_inet6],[
186 #include <sys/types.h>
187 #ifdef HAVE_SYS_SOCKET_H
188 #include <sys/socket.h>
190 #ifdef HAVE_NETINET_IN_H
191 #include <netinet/in.h>
193 #ifdef HAVE_WINSOCK2_H
194 #include <winsock2.h>
196 #ifdef HAVE_WS2TCPIP_H
197 #include <ws2tcpip.h>
200 #error Missing PF_INET6
203 #error Missing AF_INET6
206 wget_cv_proto_inet6=yes
208 wget_cv_proto_inet6=no
212 if test "X$wget_cv_proto_inet6" = "Xyes"; then :
220 AC_DEFUN([WGET_STRUCT_SOCKADDR_STORAGE],[
221 AC_CHECK_TYPES([struct sockaddr_storage],[], [], [
222 #include <sys/types.h>
223 #ifdef HAVE_SYS_SOCKET_H
224 #include <sys/socket.h>
226 #ifdef HAVE_WINSOCK2_H
227 #include <winsock2.h>
232 dnl ************************************************************
233 dnl END OF IPv6 AUTOCONFIGURATION SUPPORT MACROS
234 dnl ************************************************************
236 dnl AM_PATH_PROG_WITH_TEST(VARIABLE, PROG-TO-CHECK-FOR,
237 dnl TEST-PERFORMED-ON-FOUND_PROGRAM [, VALUE-IF-NOT-FOUND [, PATH]])
238 AC_DEFUN([AM_PATH_PROG_WITH_TEST],
239 [# Extract the first word of "$2", so it can be a program name with args.
240 set dummy $2; ac_word=[$]2
241 AC_MSG_CHECKING([for $ac_word])
242 AC_CACHE_VAL(ac_cv_path_$1,
245 ac_cv_path_$1="[$]$1" # Let the user override the test with a path.
248 IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:"
249 for ac_dir in ifelse([$5], , $PATH, [$5]); do
250 test -z "$ac_dir" && ac_dir=.
251 if test -f $ac_dir/$ac_word; then
253 ac_cv_path_$1="$ac_dir/$ac_word"
259 dnl If no 4th arg is given, leave the cache variable unset,
260 dnl so AC_PATH_PROGS will keep looking.
261 ifelse([$4], , , [ test -z "[$]ac_cv_path_$1" && ac_cv_path_$1="$4"
266 if test -n "[$]$1"; then