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 Free Software Foundation, Inc.
5 dnl This program is free software; you can redistribute it and/or modify
6 dnl it under the terms of the GNU General Public License as published by
7 dnl the Free Software Foundation; either version 3 of the License, or
8 dnl (at your option) any later version.
10 dnl This program is distributed in the hope that it will be useful,
11 dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
12 dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 dnl GNU General Public License for more details.
15 dnl You should have received a copy of the GNU General Public License
16 dnl along with this program. If not, see <http://www.gnu.org/licenses/>.
18 dnl In addition, as a special exception, the Free Software Foundation
19 dnl gives permission to link the code of its release of Wget with the
20 dnl OpenSSL project's "OpenSSL" library (or with modified versions of it
21 dnl that use the same license as the "OpenSSL" library), and distribute
22 dnl the linked executables. You must obey the GNU General Public License
23 dnl in all respects for all of the code used other than "OpenSSL". If you
24 dnl modify this file, you may extend this exception to your version of the
25 dnl file, but you are not obligated to do so. If you do not wish to do
26 dnl so, delete this exception statement from your version.
29 dnl Check for `struct utimbuf'.
32 AC_DEFUN([WGET_STRUCT_UTIMBUF], [
33 AC_CHECK_TYPES([struct utimbuf], [], [], [
36 # include <sys/types.h>
45 dnl Check for socklen_t. The third argument of accept, getsockname,
46 dnl etc. is int * on some systems, but size_t * on others. POSIX
47 dnl finally standardized on socklen_t, but older systems don't have
48 dnl it. If socklen_t exists, we use it, else if accept() accepts
49 dnl size_t *, we use that, else we use int.
51 AC_DEFUN([WGET_SOCKLEN_T], [
52 AC_MSG_CHECKING(for socklen_t)
54 #include <sys/types.h>
55 #include <sys/socket.h>
57 ], [AC_MSG_RESULT(socklen_t)], [
59 #include <sys/types.h>
60 #include <sys/socket.h>
61 int accept (int, struct sockaddr *, size_t *);
64 AC_DEFINE([socklen_t], [size_t],
65 [Define to int or size_t on systems without socklen_t.])
68 AC_DEFINE([socklen_t], [int],
69 [Define to int or size_t on systems without socklen_t.])
74 dnl Check whether fnmatch.h can be included. This doesn't use
75 dnl AC_FUNC_FNMATCH because Wget is already careful to only use
76 dnl fnmatch on certain OS'es. However, fnmatch.h is sometimes broken
77 dnl even on those because Apache installs its own fnmatch.h to
78 dnl /usr/local/include (!), which GCC uses before /usr/include.
80 AC_DEFUN([WGET_FNMATCH], [
81 AC_MSG_CHECKING([for working fnmatch.h])
82 AC_COMPILE_IFELSE([#include <fnmatch.h>
85 AC_DEFINE([HAVE_WORKING_FNMATCH_H], 1,
86 [Define if fnmatch.h can be included.])
92 dnl Check for nanosleep. For nanosleep to work on Solaris, we must
93 dnl link with -lrt (recently) or with -lposix4 (older releases).
95 AC_DEFUN([WGET_NANOSLEEP], [
96 AC_CHECK_FUNCS(nanosleep, [], [
97 AC_CHECK_LIB(rt, nanosleep, [
98 AC_DEFINE([HAVE_NANOSLEEP], 1,
99 [Define if you have the nanosleep function.])
102 AC_CHECK_LIB(posix4, nanosleep, [
103 AC_DEFINE([HAVE_NANOSLEEP], 1,
104 [Define if you have the nanosleep function.])
105 LIBS="-lposix4 $LIBS"
111 AC_DEFUN([WGET_POSIX_CLOCK], [
112 AC_CHECK_FUNCS(clock_gettime, [], [
113 AC_CHECK_LIB(rt, clock_gettime)
117 dnl Check whether we need to link with -lnsl and -lsocket, as is the
118 dnl case on e.g. Solaris.
120 AC_DEFUN([WGET_NSL_SOCKET], [
121 dnl On Solaris, -lnsl is needed to use gethostbyname. But checking
122 dnl for gethostbyname is not enough because on "NCR MP-RAS 3.0"
123 dnl gethostbyname is in libc, but -lnsl is still needed to use
124 dnl -lsocket, as well as for functions such as inet_ntoa. We look
125 dnl for such known offenders and if one of them is not found, we
126 dnl check if -lnsl is needed.
127 wget_check_in_nsl=NONE
128 AC_CHECK_FUNCS(gethostbyname, [], [
129 wget_check_in_nsl=gethostbyname
131 AC_CHECK_FUNCS(inet_ntoa, [], [
132 wget_check_in_nsl=inet_ntoa
134 if test $wget_check_in_nsl != NONE; then
135 AC_CHECK_LIB(nsl, $wget_check_in_nsl)
137 AC_CHECK_LIB(socket, socket)
141 dnl ************************************************************
142 dnl START OF IPv6 AUTOCONFIGURATION SUPPORT MACROS
143 dnl ************************************************************
145 AC_DEFUN([TYPE_STRUCT_SOCKADDR_IN6],[
146 wget_have_sockaddr_in6=
147 AC_CHECK_TYPES([struct sockaddr_in6],[
148 wget_have_sockaddr_in6=yes
150 wget_have_sockaddr_in6=no
152 #include <sys/types.h>
153 #include <sys/socket.h>
154 #include <netinet/in.h>
157 if test "X$wget_have_sockaddr_in6" = "Xyes"; then :
165 AC_DEFUN([MEMBER_SIN6_SCOPE_ID],[
166 AC_REQUIRE([TYPE_STRUCT_SOCKADDR_IN6])
168 wget_member_sin6_scope_id=
169 if test "X$wget_have_sockaddr_in6" = "Xyes"; then
170 AC_CHECK_MEMBER([struct sockaddr_in6.sin6_scope_id],[
171 wget_member_sin6_scope_id=yes
173 wget_member_sin6_scope_id=no
175 #include <sys/types.h>
176 #include <sys/socket.h>
177 #include <netinet/in.h>
181 if test "X$wget_member_sin6_scope_id" = "Xyes"; then
182 AC_DEFINE([HAVE_SOCKADDR_IN6_SCOPE_ID], 1,
183 [Define if struct sockaddr_in6 has the sin6_scope_id member])
191 AC_DEFUN([PROTO_INET6],[
192 AC_CACHE_CHECK([for INET6 protocol support], [wget_cv_proto_inet6],[
194 #include <sys/types.h>
195 #include <sys/socket.h>
198 #error Missing PF_INET6
201 #error Mlssing AF_INET6
204 wget_cv_proto_inet6=yes
206 wget_cv_proto_inet6=no
210 if test "X$wget_cv_proto_inet6" = "Xyes"; then :
218 AC_DEFUN([WGET_STRUCT_SOCKADDR_STORAGE],[
219 AC_CHECK_TYPES([struct sockaddr_storage],[], [], [
220 #include <sys/types.h>
221 #include <sys/socket.h>
225 dnl ************************************************************
226 dnl END OF IPv6 AUTOCONFIGURATION SUPPORT MACROS
227 dnl ************************************************************
229 dnl AM_PATH_PROG_WITH_TEST(VARIABLE, PROG-TO-CHECK-FOR,
230 dnl TEST-PERFORMED-ON-FOUND_PROGRAM [, VALUE-IF-NOT-FOUND [, PATH]])
231 AC_DEFUN([AM_PATH_PROG_WITH_TEST],
232 [# Extract the first word of "$2", so it can be a program name with args.
233 set dummy $2; ac_word=[$]2
234 AC_MSG_CHECKING([for $ac_word])
235 AC_CACHE_VAL(ac_cv_path_$1,
238 ac_cv_path_$1="[$]$1" # Let the user override the test with a path.
241 IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:"
242 for ac_dir in ifelse([$5], , $PATH, [$5]); do
243 test -z "$ac_dir" && ac_dir=.
244 if test -f $ac_dir/$ac_word; then
246 ac_cv_path_$1="$ac_dir/$ac_word"
252 dnl If no 4th arg is given, leave the cache variable unset,
253 dnl so AC_PATH_PROGS will keep looking.
254 ifelse([$4], , , [ test -z "[$]ac_cv_path_$1" && ac_cv_path_$1="$4"
259 if test -n "[$]$1"; then