]> sjero.net Git - wget/blob - m4/wget.m4
NEWS: cite --start-pos
[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, 2010, 2011 Free Software
4 dnl Foundation, Inc.
5
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.
10
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.
15
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/>.
18
19 dnl Additional permission under GNU GPL version 3 section 7
20
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.
29
30 dnl
31 dnl Check for `struct utimbuf'.
32 dnl
33
34 AC_DEFUN([WGET_STRUCT_UTIMBUF], [
35   AC_CHECK_TYPES([struct utimbuf], [], [], [
36 #include <stdio.h>
37 #if HAVE_SYS_TYPES_H
38 # include <sys/types.h>
39 #endif
40 #if HAVE_UTIME_H
41 # include <utime.h>
42 #endif
43   ])
44 ])
45
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.
51
52 AC_DEFUN([WGET_FNMATCH], [
53   AC_MSG_CHECKING([for working fnmatch.h])
54   AC_COMPILE_IFELSE([AC_LANG_SOURCE([#include <fnmatch.h>
55                     ])], [
56     AC_MSG_RESULT(yes)
57     AC_DEFINE([HAVE_WORKING_FNMATCH_H], 1,
58               [Define if fnmatch.h can be included.])
59   ], [
60     AC_MSG_RESULT(no)
61   ])
62 ])
63
64 dnl Check for nanosleep.  For nanosleep to work on Solaris, we must
65 dnl link with -lrt (recently) or with -lposix4 (older releases).
66
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.])
72       LIBS="-lrt $LIBS"
73     ], [
74       AC_CHECK_LIB(posix4, nanosleep, [
75         AC_DEFINE([HAVE_NANOSLEEP], 1,
76                   [Define if you have the nanosleep function.])
77         LIBS="-lposix4 $LIBS"
78       ])
79     ])
80   ])
81 ])
82
83 AC_DEFUN([WGET_POSIX_CLOCK], [
84   AC_CHECK_FUNCS(clock_gettime, [], [
85     AC_CHECK_LIB(rt, clock_gettime)
86   ])
87 ])
88
89 dnl Check whether we need to link with -lnsl and -lsocket, as is the
90 dnl case on e.g. Solaris.
91
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
102   ])
103   AC_CHECK_FUNCS(inet_ntoa, [], [
104     wget_check_in_nsl=inet_ntoa
105   ])
106   if test $wget_check_in_nsl != NONE; then
107     AC_CHECK_LIB(nsl, $wget_check_in_nsl)
108   fi
109   AC_CHECK_LIB(socket, socket)
110 ])
111
112
113 dnl ************************************************************
114 dnl START OF IPv6 AUTOCONFIGURATION SUPPORT MACROS
115 dnl ************************************************************
116
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
121   ],[
122     wget_have_sockaddr_in6=no
123   ],[
124 #include <sys/types.h>
125 #ifdef HAVE_SYS_SOCKET_H
126 #include <sys/socket.h>
127 #endif
128 #ifdef HAVE_NETINET_IN_H
129 #include <netinet/in.h>
130 #endif
131 #ifdef HAVE_WINSOCK2_H
132 #include <winsock2.h>
133 #endif
134 #ifdef HAVE_WS2TCPIP_H
135 #include <ws2tcpip.h>
136 #endif
137   ])
138
139   if test "X$wget_have_sockaddr_in6" = "Xyes"; then :
140     $1
141   else :
142     $2
143   fi
144 ])
145
146
147 AC_DEFUN([MEMBER_SIN6_SCOPE_ID],[
148   AC_REQUIRE([TYPE_STRUCT_SOCKADDR_IN6])
149
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
154     ],[
155       wget_member_sin6_scope_id=no
156     ],[
157 #include <sys/types.h>
158 #ifdef HAVE_SYS_SOCKET_H
159 #include <sys/socket.h>
160 #endif
161 #ifdef HAVE_NETINET_IN_H
162 #include <netinet/in.h>
163 #endif
164 #ifdef HAVE_WINSOCK2_H
165 #include <winsock2.h>
166 #endif
167 #ifdef HAVE_WS2TCPIP_H
168 #include <ws2tcpip.h>
169 #endif
170     ])
171   fi
172
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])
176     $1
177   else :
178     $2
179   fi
180 ])
181
182
183 AC_DEFUN([PROTO_INET6],[
184   AC_CACHE_CHECK([for INET6 protocol support], [wget_cv_proto_inet6],[
185     AC_TRY_CPP([
186 #include <sys/types.h>
187 #ifdef HAVE_SYS_SOCKET_H
188 #include <sys/socket.h>
189 #endif
190 #ifdef HAVE_NETINET_IN_H
191 #include <netinet/in.h>
192 #endif
193 #ifdef HAVE_WINSOCK2_H
194 #include <winsock2.h>
195 #endif
196 #ifdef HAVE_WS2TCPIP_H
197 #include <ws2tcpip.h>
198 #endif
199 #ifndef PF_INET6
200 #error Missing PF_INET6
201 #endif
202 #ifndef AF_INET6
203 #error Missing AF_INET6
204 #endif
205     ],[
206       wget_cv_proto_inet6=yes
207     ],[
208       wget_cv_proto_inet6=no
209     ])
210   ])
211
212   if test "X$wget_cv_proto_inet6" = "Xyes"; then :
213     $1
214   else :
215     $2
216   fi
217 ])
218
219
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>
225 #endif
226 #ifdef HAVE_WINSOCK2_H
227 #include <winsock2.h>
228 #endif
229 ])
230 ])
231
232 dnl ************************************************************
233 dnl END OF IPv6 AUTOCONFIGURATION SUPPORT MACROS
234 dnl ************************************************************
235 \f
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,
243 [case "[$]$1" in
244   /*)
245   ac_cv_path_$1="[$]$1" # Let the user override the test with a path.
246   ;;
247   *)
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
252       if [$3]; then
253         ac_cv_path_$1="$ac_dir/$ac_word"
254         break
255       fi
256     fi
257   done
258   IFS="$ac_save_ifs"
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"
262 ])dnl
263   ;;
264 esac])dnl
265 $1="$ac_cv_path_$1"
266 if test -n "[$]$1"; then
267   AC_MSG_RESULT([$]$1)
268 else
269   AC_MSG_RESULT(no)
270 fi
271 AC_SUBST($1)dnl
272 ])
273