]> sjero.net Git - wget/blob - m4/wget.m4
Mass update copyright years.
[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 Free Software Foundation,
4 dnl 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([#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 #include <sys/socket.h>
126 #include <netinet/in.h>
127   ])
128
129   if test "X$wget_have_sockaddr_in6" = "Xyes"; then :
130     $1
131   else :
132     $2
133   fi
134 ])
135
136
137 AC_DEFUN([MEMBER_SIN6_SCOPE_ID],[
138   AC_REQUIRE([TYPE_STRUCT_SOCKADDR_IN6])
139
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
144     ],[
145       wget_member_sin6_scope_id=no
146     ],[
147 #include <sys/types.h>
148 #include <sys/socket.h>
149 #include <netinet/in.h>
150     ])
151   fi
152
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])
156     $1
157   else :
158     $2
159   fi
160 ])
161
162
163 AC_DEFUN([PROTO_INET6],[
164   AC_CACHE_CHECK([for INET6 protocol support], [wget_cv_proto_inet6],[
165     AC_TRY_CPP([
166 #include <sys/types.h>
167 #include <sys/socket.h>
168
169 #ifndef PF_INET6
170 #error Missing PF_INET6
171 #endif
172 #ifndef AF_INET6
173 #error Mlssing AF_INET6
174 #endif
175     ],[
176       wget_cv_proto_inet6=yes
177     ],[
178       wget_cv_proto_inet6=no
179     ])
180   ])
181
182   if test "X$wget_cv_proto_inet6" = "Xyes"; then :
183     $1
184   else :
185     $2
186   fi
187 ])
188
189
190 AC_DEFUN([WGET_STRUCT_SOCKADDR_STORAGE],[
191   AC_CHECK_TYPES([struct sockaddr_storage],[], [], [
192 #include <sys/types.h>
193 #include <sys/socket.h>
194   ])
195 ])
196
197 dnl ************************************************************
198 dnl END OF IPv6 AUTOCONFIGURATION SUPPORT MACROS
199 dnl ************************************************************
200 \f
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,
208 [case "[$]$1" in
209   /*)
210   ac_cv_path_$1="[$]$1" # Let the user override the test with a path.
211   ;;
212   *)
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
217       if [$3]; then
218         ac_cv_path_$1="$ac_dir/$ac_word"
219         break
220       fi
221     fi
222   done
223   IFS="$ac_save_ifs"
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"
227 ])dnl
228   ;;
229 esac])dnl
230 $1="$ac_cv_path_$1"
231 if test -n "[$]$1"; then
232   AC_MSG_RESULT([$]$1)
233 else
234   AC_MSG_RESULT(no)
235 fi
236 AC_SUBST($1)dnl
237 ])
238