]> sjero.net Git - wget/blob - m4/wget.m4
Updated licensing exception for OpenSSL from the SFLC.
[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 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
46 dnl Check for socklen_t.  The third argument of accept, getsockname,
47 dnl etc. is int * on some systems, but size_t * on others.  POSIX
48 dnl finally standardized on socklen_t, but older systems don't have
49 dnl it.  If socklen_t exists, we use it, else if accept() accepts
50 dnl size_t *, we use that, else we use int.
51
52 AC_DEFUN([WGET_SOCKLEN_T], [
53   AC_MSG_CHECKING(for socklen_t)
54   AC_COMPILE_IFELSE([
55 #include <sys/types.h>
56 #include <sys/socket.h>
57 socklen_t x;
58   ], [AC_MSG_RESULT(socklen_t)], [
59     AC_COMPILE_IFELSE([
60 #include <sys/types.h>
61 #include <sys/socket.h>
62 int accept (int, struct sockaddr *, size_t *);
63     ], [
64       AC_MSG_RESULT(size_t)
65       AC_DEFINE([socklen_t], [size_t],
66                 [Define to int or size_t on systems without socklen_t.])
67     ], [
68       AC_MSG_RESULT(int)
69       AC_DEFINE([socklen_t], [int],
70                 [Define to int or size_t on systems without socklen_t.])
71     ])
72   ])
73 ])
74
75 dnl Check whether fnmatch.h can be included.  This doesn't use
76 dnl AC_FUNC_FNMATCH because Wget is already careful to only use
77 dnl fnmatch on certain OS'es.  However, fnmatch.h is sometimes broken
78 dnl even on those because Apache installs its own fnmatch.h to
79 dnl /usr/local/include (!), which GCC uses before /usr/include.
80
81 AC_DEFUN([WGET_FNMATCH], [
82   AC_MSG_CHECKING([for working fnmatch.h])
83   AC_COMPILE_IFELSE([#include <fnmatch.h>
84                     ], [
85     AC_MSG_RESULT(yes)
86     AC_DEFINE([HAVE_WORKING_FNMATCH_H], 1,
87               [Define if fnmatch.h can be included.])
88   ], [
89     AC_MSG_RESULT(no)
90   ])
91 ])
92
93 dnl Check for nanosleep.  For nanosleep to work on Solaris, we must
94 dnl link with -lrt (recently) or with -lposix4 (older releases).
95
96 AC_DEFUN([WGET_NANOSLEEP], [
97   AC_CHECK_FUNCS(nanosleep, [], [
98     AC_CHECK_LIB(rt, nanosleep, [
99       AC_DEFINE([HAVE_NANOSLEEP], 1,
100                 [Define if you have the nanosleep function.])
101       LIBS="-lrt $LIBS"
102     ], [
103       AC_CHECK_LIB(posix4, nanosleep, [
104         AC_DEFINE([HAVE_NANOSLEEP], 1,
105                   [Define if you have the nanosleep function.])
106         LIBS="-lposix4 $LIBS"
107       ])
108     ])
109   ])
110 ])
111
112 AC_DEFUN([WGET_POSIX_CLOCK], [
113   AC_CHECK_FUNCS(clock_gettime, [], [
114     AC_CHECK_LIB(rt, clock_gettime)
115   ])
116 ])
117
118 dnl Check whether we need to link with -lnsl and -lsocket, as is the
119 dnl case on e.g. Solaris.
120
121 AC_DEFUN([WGET_NSL_SOCKET], [
122   dnl On Solaris, -lnsl is needed to use gethostbyname.  But checking
123   dnl for gethostbyname is not enough because on "NCR MP-RAS 3.0"
124   dnl gethostbyname is in libc, but -lnsl is still needed to use
125   dnl -lsocket, as well as for functions such as inet_ntoa.  We look
126   dnl for such known offenders and if one of them is not found, we
127   dnl check if -lnsl is needed.
128   wget_check_in_nsl=NONE
129   AC_CHECK_FUNCS(gethostbyname, [], [
130     wget_check_in_nsl=gethostbyname
131   ])
132   AC_CHECK_FUNCS(inet_ntoa, [], [
133     wget_check_in_nsl=inet_ntoa
134   ])
135   if test $wget_check_in_nsl != NONE; then
136     AC_CHECK_LIB(nsl, $wget_check_in_nsl)
137   fi
138   AC_CHECK_LIB(socket, socket)
139 ])
140
141
142 dnl ************************************************************
143 dnl START OF IPv6 AUTOCONFIGURATION SUPPORT MACROS
144 dnl ************************************************************
145
146 AC_DEFUN([TYPE_STRUCT_SOCKADDR_IN6],[
147   wget_have_sockaddr_in6=
148   AC_CHECK_TYPES([struct sockaddr_in6],[
149     wget_have_sockaddr_in6=yes
150   ],[
151     wget_have_sockaddr_in6=no
152   ],[
153 #include <sys/types.h>
154 #include <sys/socket.h>
155 #include <netinet/in.h>
156   ])
157
158   if test "X$wget_have_sockaddr_in6" = "Xyes"; then :
159     $1
160   else :
161     $2
162   fi
163 ])
164
165
166 AC_DEFUN([MEMBER_SIN6_SCOPE_ID],[
167   AC_REQUIRE([TYPE_STRUCT_SOCKADDR_IN6])
168   
169   wget_member_sin6_scope_id=
170   if test "X$wget_have_sockaddr_in6" = "Xyes"; then
171     AC_CHECK_MEMBER([struct sockaddr_in6.sin6_scope_id],[
172       wget_member_sin6_scope_id=yes
173     ],[
174       wget_member_sin6_scope_id=no
175     ],[
176 #include <sys/types.h>
177 #include <sys/socket.h>
178 #include <netinet/in.h>
179     ])
180   fi
181
182   if test "X$wget_member_sin6_scope_id" = "Xyes"; then
183     AC_DEFINE([HAVE_SOCKADDR_IN6_SCOPE_ID], 1,
184       [Define if struct sockaddr_in6 has the sin6_scope_id member])
185     $1
186   else :
187     $2
188   fi
189 ])
190
191
192 AC_DEFUN([PROTO_INET6],[
193   AC_CACHE_CHECK([for INET6 protocol support], [wget_cv_proto_inet6],[
194     AC_TRY_CPP([
195 #include <sys/types.h>
196 #include <sys/socket.h>
197
198 #ifndef PF_INET6
199 #error Missing PF_INET6
200 #endif
201 #ifndef AF_INET6
202 #error Mlssing AF_INET6
203 #endif
204     ],[
205       wget_cv_proto_inet6=yes
206     ],[
207       wget_cv_proto_inet6=no
208     ])
209   ])
210
211   if test "X$wget_cv_proto_inet6" = "Xyes"; then :
212     $1
213   else :
214     $2
215   fi
216 ])
217
218
219 AC_DEFUN([WGET_STRUCT_SOCKADDR_STORAGE],[
220   AC_CHECK_TYPES([struct sockaddr_storage],[], [], [
221 #include <sys/types.h>
222 #include <sys/socket.h>
223   ])
224 ])
225
226 dnl ************************************************************
227 dnl END OF IPv6 AUTOCONFIGURATION SUPPORT MACROS
228 dnl ************************************************************
229 \f
230 # This code originates from Ulrich Drepper's AM_WITH_NLS.
231
232 AC_DEFUN([WGET_WITH_NLS],
233   [AC_MSG_CHECKING([whether NLS is requested])
234     dnl Default is enabled NLS
235     AC_ARG_ENABLE(nls,
236       [  --disable-nls           do not use Native Language Support],
237       HAVE_NLS=$enableval, HAVE_NLS=yes)
238     AC_MSG_RESULT($HAVE_NLS)
239
240     dnl If something goes wrong, we may still decide not to use NLS.
241     dnl For this reason, defer AC_SUBST'ing HAVE_NLS until the very
242     dnl last moment.
243
244     if test x"$HAVE_NLS" = xyes; then
245       dnl If LINGUAS is specified, use only those languages.  In fact,
246       dnl compute an intersection of languages in LINGUAS and
247       dnl ALL_LINGUAS, and use that.
248       if test x"$LINGUAS" != x; then
249         new_linguas=
250         for lang1 in $ALL_LINGUAS; do
251           for lang2 in $LINGUAS; do
252             if test "$lang1" = "$lang2"; then
253               new_linguas="$new_linguas $lang1"
254             fi
255           done
256         done
257         ALL_LINGUAS=$new_linguas
258       fi
259       AC_MSG_NOTICE([language catalogs: $ALL_LINGUAS])
260       AM_PATH_PROG_WITH_TEST(MSGFMT, msgfmt,
261         [test -z "`$ac_dir/$ac_word -h 2>&1 | grep 'dv '`"], msgfmt)
262       AM_PATH_PROG_WITH_TEST(XGETTEXT, xgettext,
263           [test -z "`$ac_dir/$ac_word -h 2>&1 | grep '(HELP)'`"], :)
264       AC_SUBST(MSGFMT)
265       AC_PATH_PROG(GMSGFMT, gmsgfmt, $MSGFMT)
266       CATOBJEXT=.gmo
267       INSTOBJEXT=.mo
268       DATADIRNAME=share
269
270       dnl Test whether we really found GNU xgettext.
271       if test "$XGETTEXT" != ":"; then
272         dnl If it is no GNU xgettext we define it as : so that the
273         dnl Makefiles still can work.
274         if $XGETTEXT --omit-header /dev/null 2> /dev/null; then
275           : ;
276         else
277           AC_MSG_RESULT(
278             [found xgettext programs is not GNU xgettext; ignore it])
279           XGETTEXT=":"
280         fi
281       fi
282
283       AC_CHECK_HEADERS(libintl.h)
284
285       dnl Prefer gettext found in -lintl to the one in libc.
286       dnl Otherwise it can happen that we include libintl.h from
287       dnl /usr/local/lib, but fail to specify -lintl, which results in
288       dnl link or run-time failures.  (Symptom: libintl_bindtextdomain
289       dnl not found at link-time.)
290
291       AC_CHECK_LIB(intl, gettext, [
292         dnl gettext is in libintl; announce the fact manually.
293         LIBS="-lintl $LIBS"
294         AC_DEFINE([HAVE_GETTEXT], 1,
295                   [Define if you have the gettext function.])
296       ], [
297         AC_CHECK_FUNCS(gettext, [], [
298           AC_MSG_RESULT([gettext not found; disabling NLS])
299           HAVE_NLS=no
300         ])
301       ])
302
303       for lang in $ALL_LINGUAS; do
304         GMOFILES="$GMOFILES $lang.gmo"
305         POFILES="$POFILES $lang.po"
306       done
307       dnl Construct list of names of catalog files to be constructed.
308       for lang in $ALL_LINGUAS; do
309         CATALOGS="$CATALOGS ${lang}${CATOBJEXT}"
310       done
311
312       dnl Make all variables we use known to autoconf.
313       AC_SUBST(CATALOGS)
314       AC_SUBST(CATOBJEXT)
315       AC_SUBST(DATADIRNAME)
316       AC_SUBST(GMOFILES)
317       AC_SUBST(INSTOBJEXT)
318       AC_SUBST(INTLLIBS)
319       AC_SUBST(POFILES)
320     fi
321     AC_SUBST(HAVE_NLS)
322     dnl Some independently maintained files, such as po/Makefile.in,
323     dnl use `USE_NLS', so support it.
324     USE_NLS=$HAVE_NLS
325     AC_SUBST(USE_NLS)
326     if test "x$HAVE_NLS" = xyes; then
327       AC_DEFINE([HAVE_NLS], 1, [Define this if you want the NLS support.])
328     fi
329   ])
330
331 dnl Generate list of files to be processed by xgettext which will
332 dnl be included in po/Makefile.
333 dnl
334 dnl This is not strictly an Autoconf macro, because it is run from
335 dnl within `config.status' rather than from within configure.  This
336 dnl is why special rules must be applied for it.
337 AC_DEFUN([WGET_PROCESS_PO],
338   [
339    dnl I wonder what the following several lines do...
340    if test "x$srcdir" != "x."; then
341      if test "x`echo $srcdir | sed 's@/.*@@'`" = "x"; then
342        posrcprefix="$srcdir/"
343      else
344        posrcprefix="../$srcdir/"
345      fi
346    else
347      posrcprefix="../"
348    fi
349    rm -f po/POTFILES
350    dnl Use `echo' rather than AC_MSG_RESULT, because this is run from
351    dnl `config.status'.
352    echo "generating po/POTFILES from $srcdir/po/POTFILES.in"
353    sed -e "/^#/d" -e "/^\$/d" -e "s,.*, $posrcprefix& \\\\,"  \
354        -e "\$s/\(.*\) \\\\/\1/" \
355         < $srcdir/po/POTFILES.in > po/POTFILES
356    echo "creating po/Makefile"
357    sed -e "/POTFILES =/r po/POTFILES" po/Makefile.in > po/Makefile
358   ])
359
360 # Search path for a program which passes the given test.
361 # Ulrich Drepper <drepper@cygnus.com>, 1996.
362 #
363 # This file may be copied and used freely without restrictions.  It
364 # can be used in projects which are not available under the GNU Public
365 # License but which still want to provide support for the GNU gettext
366 # functionality.  Please note that the actual code is *not* freely
367 # available.
368
369 dnl AM_PATH_PROG_WITH_TEST(VARIABLE, PROG-TO-CHECK-FOR,
370 dnl   TEST-PERFORMED-ON-FOUND_PROGRAM [, VALUE-IF-NOT-FOUND [, PATH]])
371 AC_DEFUN([AM_PATH_PROG_WITH_TEST],
372 [# Extract the first word of "$2", so it can be a program name with args.
373 set dummy $2; ac_word=[$]2
374 AC_MSG_CHECKING([for $ac_word])
375 AC_CACHE_VAL(ac_cv_path_$1,
376 [case "[$]$1" in
377   /*)
378   ac_cv_path_$1="[$]$1" # Let the user override the test with a path.
379   ;;
380   *)
381   IFS="${IFS=   }"; ac_save_ifs="$IFS"; IFS="${IFS}:"
382   for ac_dir in ifelse([$5], , $PATH, [$5]); do
383     test -z "$ac_dir" && ac_dir=.
384     if test -f $ac_dir/$ac_word; then
385       if [$3]; then
386         ac_cv_path_$1="$ac_dir/$ac_word"
387         break
388       fi
389     fi
390   done
391   IFS="$ac_save_ifs"
392 dnl If no 4th arg is given, leave the cache variable unset,
393 dnl so AC_PATH_PROGS will keep looking.
394 ifelse([$4], , , [  test -z "[$]ac_cv_path_$1" && ac_cv_path_$1="$4"
395 ])dnl
396   ;;
397 esac])dnl
398 $1="$ac_cv_path_$1"
399 if test -n "[$]$1"; then
400   AC_MSG_RESULT([$]$1)
401 else
402   AC_MSG_RESULT(no)
403 fi
404 AC_SUBST($1)dnl
405 ])
406