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 Free Software Foundation,
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([#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 #include <sys/socket.h>
126 #include <netinet/in.h>
129 if test "X$wget_have_sockaddr_in6" = "Xyes"; then :
137 AC_DEFUN([MEMBER_SIN6_SCOPE_ID],[
138 AC_REQUIRE([TYPE_STRUCT_SOCKADDR_IN6])
140 wget_member_sin6_scope_id=
141 if test "X$wget_have_sockaddr_in6" = "Xyes"; then
142 AC_CHECK_MEMBER([struct sockaddr_in6.sin6_scope_id],[
143 wget_member_sin6_scope_id=yes
145 wget_member_sin6_scope_id=no
147 #include <sys/types.h>
148 #include <sys/socket.h>
149 #include <netinet/in.h>
153 if test "X$wget_member_sin6_scope_id" = "Xyes"; then
154 AC_DEFINE([HAVE_SOCKADDR_IN6_SCOPE_ID], 1,
155 [Define if struct sockaddr_in6 has the sin6_scope_id member])
163 AC_DEFUN([PROTO_INET6],[
164 AC_CACHE_CHECK([for INET6 protocol support], [wget_cv_proto_inet6],[
166 #include <sys/types.h>
167 #include <sys/socket.h>
170 #error Missing PF_INET6
173 #error Mlssing AF_INET6
176 wget_cv_proto_inet6=yes
178 wget_cv_proto_inet6=no
182 if test "X$wget_cv_proto_inet6" = "Xyes"; then :
190 AC_DEFUN([WGET_STRUCT_SOCKADDR_STORAGE],[
191 AC_CHECK_TYPES([struct sockaddr_storage],[], [], [
192 #include <sys/types.h>
193 #include <sys/socket.h>
197 dnl ************************************************************
198 dnl END OF IPv6 AUTOCONFIGURATION SUPPORT MACROS
199 dnl ************************************************************
201 dnl AM_PATH_PROG_WITH_TEST(VARIABLE, PROG-TO-CHECK-FOR,
202 dnl TEST-PERFORMED-ON-FOUND_PROGRAM [, VALUE-IF-NOT-FOUND [, PATH]])
203 AC_DEFUN([AM_PATH_PROG_WITH_TEST],
204 [# Extract the first word of "$2", so it can be a program name with args.
205 set dummy $2; ac_word=[$]2
206 AC_MSG_CHECKING([for $ac_word])
207 AC_CACHE_VAL(ac_cv_path_$1,
210 ac_cv_path_$1="[$]$1" # Let the user override the test with a path.
213 IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:"
214 for ac_dir in ifelse([$5], , $PATH, [$5]); do
215 test -z "$ac_dir" && ac_dir=.
216 if test -f $ac_dir/$ac_word; then
218 ac_cv_path_$1="$ac_dir/$ac_word"
224 dnl If no 4th arg is given, leave the cache variable unset,
225 dnl so AC_PATH_PROGS will keep looking.
226 ifelse([$4], , , [ test -z "[$]ac_cv_path_$1" && ac_cv_path_$1="$4"
231 if test -n "[$]$1"; then