]> sjero.net Git - wget/blob - m4/wget.m4
Do not use macro WGET_SOCKLEN_T.
[wget] / m4 / wget.m4
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.
4
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.
9
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.
14
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/>.
17
18 dnl Additional permission under GNU GPL version 3 section 7
19
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.
28
29 dnl
30 dnl Check for `struct utimbuf'.
31 dnl
32
33 AC_DEFUN([WGET_STRUCT_UTIMBUF], [
34   AC_CHECK_TYPES([struct utimbuf], [], [], [
35 #include <stdio.h>
36 #if HAVE_SYS_TYPES_H
37 # include <sys/types.h>
38 #endif
39 #if HAVE_UTIME_H
40 # include <utime.h>
41 #endif
42   ])
43 ])
44
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.
50
51 AC_DEFUN([WGET_FNMATCH], [
52   AC_MSG_CHECKING([for working fnmatch.h])
53   AC_COMPILE_IFELSE([#include <fnmatch.h>
54                     ], [
55     AC_MSG_RESULT(yes)
56     AC_DEFINE([HAVE_WORKING_FNMATCH_H], 1,
57               [Define if fnmatch.h can be included.])
58   ], [
59     AC_MSG_RESULT(no)
60   ])
61 ])
62
63 dnl Check for nanosleep.  For nanosleep to work on Solaris, we must
64 dnl link with -lrt (recently) or with -lposix4 (older releases).
65
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.])
71       LIBS="-lrt $LIBS"
72     ], [
73       AC_CHECK_LIB(posix4, nanosleep, [
74         AC_DEFINE([HAVE_NANOSLEEP], 1,
75                   [Define if you have the nanosleep function.])
76         LIBS="-lposix4 $LIBS"
77       ])
78     ])
79   ])
80 ])
81
82 AC_DEFUN([WGET_POSIX_CLOCK], [
83   AC_CHECK_FUNCS(clock_gettime, [], [
84     AC_CHECK_LIB(rt, clock_gettime)
85   ])
86 ])
87
88 dnl Check whether we need to link with -lnsl and -lsocket, as is the
89 dnl case on e.g. Solaris.
90
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
101   ])
102   AC_CHECK_FUNCS(inet_ntoa, [], [
103     wget_check_in_nsl=inet_ntoa
104   ])
105   if test $wget_check_in_nsl != NONE; then
106     AC_CHECK_LIB(nsl, $wget_check_in_nsl)
107   fi
108   AC_CHECK_LIB(socket, socket)
109 ])
110
111
112 dnl ************************************************************
113 dnl START OF IPv6 AUTOCONFIGURATION SUPPORT MACROS
114 dnl ************************************************************
115
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
120   ],[
121     wget_have_sockaddr_in6=no
122   ],[
123 #include <sys/types.h>
124 #include <sys/socket.h>
125 #include <netinet/in.h>
126   ])
127
128   if test "X$wget_have_sockaddr_in6" = "Xyes"; then :
129     $1
130   else :
131     $2
132   fi
133 ])
134
135
136 AC_DEFUN([MEMBER_SIN6_SCOPE_ID],[
137   AC_REQUIRE([TYPE_STRUCT_SOCKADDR_IN6])
138
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
143     ],[
144       wget_member_sin6_scope_id=no
145     ],[
146 #include <sys/types.h>
147 #include <sys/socket.h>
148 #include <netinet/in.h>
149     ])
150   fi
151
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])
155     $1
156   else :
157     $2
158   fi
159 ])
160
161
162 AC_DEFUN([PROTO_INET6],[
163   AC_CACHE_CHECK([for INET6 protocol support], [wget_cv_proto_inet6],[
164     AC_TRY_CPP([
165 #include <sys/types.h>
166 #include <sys/socket.h>
167
168 #ifndef PF_INET6
169 #error Missing PF_INET6
170 #endif
171 #ifndef AF_INET6
172 #error Mlssing AF_INET6
173 #endif
174     ],[
175       wget_cv_proto_inet6=yes
176     ],[
177       wget_cv_proto_inet6=no
178     ])
179   ])
180
181   if test "X$wget_cv_proto_inet6" = "Xyes"; then :
182     $1
183   else :
184     $2
185   fi
186 ])
187
188
189 AC_DEFUN([WGET_STRUCT_SOCKADDR_STORAGE],[
190   AC_CHECK_TYPES([struct sockaddr_storage],[], [], [
191 #include <sys/types.h>
192 #include <sys/socket.h>
193   ])
194 ])
195
196 dnl ************************************************************
197 dnl END OF IPv6 AUTOCONFIGURATION SUPPORT MACROS
198 dnl ************************************************************
199 \f
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,
207 [case "[$]$1" in
208   /*)
209   ac_cv_path_$1="[$]$1" # Let the user override the test with a path.
210   ;;
211   *)
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
216       if [$3]; then
217         ac_cv_path_$1="$ac_dir/$ac_word"
218         break
219       fi
220     fi
221   done
222   IFS="$ac_save_ifs"
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"
226 ])dnl
227   ;;
228 esac])dnl
229 $1="$ac_cv_path_$1"
230 if test -n "[$]$1"; then
231   AC_MSG_RESULT([$]$1)
232 else
233   AC_MSG_RESULT(no)
234 fi
235 AC_SUBST($1)dnl
236 ])
237