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 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 Additional permission under GNU GPL version 3 section 7
20 dnl If you modify this program, or any covered work, by linking or
21 dnl combining it with the OpenSSL project's OpenSSL library (or a
22 dnl modified version of that library), containing parts covered by the
23 dnl terms of the OpenSSL or SSLeay licenses, the Free Software Foundation
24 dnl grants you additional permission to convey the resulting work.
25 dnl Corresponding Source for a non-source form of such a combination
26 dnl shall include the source code for the parts of OpenSSL used as well
27 dnl as that of the covered work.
30 dnl Check for `struct utimbuf'.
33 AC_DEFUN([WGET_STRUCT_UTIMBUF], [
34 AC_CHECK_TYPES([struct utimbuf], [], [], [
37 # include <sys/types.h>
45 dnl Check whether fnmatch.h can be included. This doesn't use
46 dnl AC_FUNC_FNMATCH because Wget is already careful to only use
47 dnl fnmatch on certain OS'es. However, fnmatch.h is sometimes broken
48 dnl even on those because Apache installs its own fnmatch.h to
49 dnl /usr/local/include (!), which GCC uses before /usr/include.
51 AC_DEFUN([WGET_FNMATCH], [
52 AC_MSG_CHECKING([for working fnmatch.h])
53 AC_COMPILE_IFELSE([#include <fnmatch.h>
56 AC_DEFINE([HAVE_WORKING_FNMATCH_H], 1,
57 [Define if fnmatch.h can be included.])
63 dnl Check for nanosleep. For nanosleep to work on Solaris, we must
64 dnl link with -lrt (recently) or with -lposix4 (older releases).
66 AC_DEFUN([WGET_NANOSLEEP], [
67 AC_CHECK_FUNCS(nanosleep, [], [
68 AC_CHECK_LIB(rt, nanosleep, [
69 AC_DEFINE([HAVE_NANOSLEEP], 1,
70 [Define if you have the nanosleep function.])
73 AC_CHECK_LIB(posix4, nanosleep, [
74 AC_DEFINE([HAVE_NANOSLEEP], 1,
75 [Define if you have the nanosleep function.])
82 AC_DEFUN([WGET_POSIX_CLOCK], [
83 AC_CHECK_FUNCS(clock_gettime, [], [
84 AC_CHECK_LIB(rt, clock_gettime)
88 dnl Check whether we need to link with -lnsl and -lsocket, as is the
89 dnl case on e.g. Solaris.
91 AC_DEFUN([WGET_NSL_SOCKET], [
92 dnl On Solaris, -lnsl is needed to use gethostbyname. But checking
93 dnl for gethostbyname is not enough because on "NCR MP-RAS 3.0"
94 dnl gethostbyname is in libc, but -lnsl is still needed to use
95 dnl -lsocket, as well as for functions such as inet_ntoa. We look
96 dnl for such known offenders and if one of them is not found, we
97 dnl check if -lnsl is needed.
98 wget_check_in_nsl=NONE
99 AC_CHECK_FUNCS(gethostbyname, [], [
100 wget_check_in_nsl=gethostbyname
102 AC_CHECK_FUNCS(inet_ntoa, [], [
103 wget_check_in_nsl=inet_ntoa
105 if test $wget_check_in_nsl != NONE; then
106 AC_CHECK_LIB(nsl, $wget_check_in_nsl)
108 AC_CHECK_LIB(socket, socket)
112 dnl ************************************************************
113 dnl START OF IPv6 AUTOCONFIGURATION SUPPORT MACROS
114 dnl ************************************************************
116 AC_DEFUN([TYPE_STRUCT_SOCKADDR_IN6],[
117 wget_have_sockaddr_in6=
118 AC_CHECK_TYPES([struct sockaddr_in6],[
119 wget_have_sockaddr_in6=yes
121 wget_have_sockaddr_in6=no
123 #include <sys/types.h>
124 #include <sys/socket.h>
125 #include <netinet/in.h>
128 if test "X$wget_have_sockaddr_in6" = "Xyes"; then :
136 AC_DEFUN([MEMBER_SIN6_SCOPE_ID],[
137 AC_REQUIRE([TYPE_STRUCT_SOCKADDR_IN6])
139 wget_member_sin6_scope_id=
140 if test "X$wget_have_sockaddr_in6" = "Xyes"; then
141 AC_CHECK_MEMBER([struct sockaddr_in6.sin6_scope_id],[
142 wget_member_sin6_scope_id=yes
144 wget_member_sin6_scope_id=no
146 #include <sys/types.h>
147 #include <sys/socket.h>
148 #include <netinet/in.h>
152 if test "X$wget_member_sin6_scope_id" = "Xyes"; then
153 AC_DEFINE([HAVE_SOCKADDR_IN6_SCOPE_ID], 1,
154 [Define if struct sockaddr_in6 has the sin6_scope_id member])
162 AC_DEFUN([PROTO_INET6],[
163 AC_CACHE_CHECK([for INET6 protocol support], [wget_cv_proto_inet6],[
165 #include <sys/types.h>
166 #include <sys/socket.h>
169 #error Missing PF_INET6
172 #error Mlssing AF_INET6
175 wget_cv_proto_inet6=yes
177 wget_cv_proto_inet6=no
181 if test "X$wget_cv_proto_inet6" = "Xyes"; then :
189 AC_DEFUN([WGET_STRUCT_SOCKADDR_STORAGE],[
190 AC_CHECK_TYPES([struct sockaddr_storage],[], [], [
191 #include <sys/types.h>
192 #include <sys/socket.h>
196 dnl ************************************************************
197 dnl END OF IPv6 AUTOCONFIGURATION SUPPORT MACROS
198 dnl ************************************************************
200 dnl AM_PATH_PROG_WITH_TEST(VARIABLE, PROG-TO-CHECK-FOR,
201 dnl TEST-PERFORMED-ON-FOUND_PROGRAM [, VALUE-IF-NOT-FOUND [, PATH]])
202 AC_DEFUN([AM_PATH_PROG_WITH_TEST],
203 [# Extract the first word of "$2", so it can be a program name with args.
204 set dummy $2; ac_word=[$]2
205 AC_MSG_CHECKING([for $ac_word])
206 AC_CACHE_VAL(ac_cv_path_$1,
209 ac_cv_path_$1="[$]$1" # Let the user override the test with a path.
212 IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:"
213 for ac_dir in ifelse([$5], , $PATH, [$5]); do
214 test -z "$ac_dir" && ac_dir=.
215 if test -f $ac_dir/$ac_word; then
217 ac_cv_path_$1="$ac_dir/$ac_word"
223 dnl If no 4th arg is given, leave the cache variable unset,
224 dnl so AC_PATH_PROGS will keep looking.
225 ifelse([$4], , , [ test -z "[$]ac_cv_path_$1" && ac_cv_path_$1="$4"
230 if test -n "[$]$1"; then