1 dnl Wget-specific Autoconf macros.
2 dnl Copyright (C) 1996-2005, 2007 Free Software Foundation, Inc.
4 dnl This program is free software; you can redistribute it and/or modify
5 dnl it under the terms of the GNU General Public License as published by
6 dnl the Free Software Foundation; either version 3 of the License, or
7 dnl (at your option) any later version.
9 dnl This program is distributed in the hope that it will be useful,
10 dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
11 dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 dnl GNU General Public License for more details.
14 dnl You should have received a copy of the GNU General Public License
15 dnl along with this program. If not, see <http://www.gnu.org/licenses/>.
17 dnl In addition, as a special exception, the Free Software Foundation
18 dnl gives permission to link the code of its release of Wget with the
19 dnl OpenSSL project's "OpenSSL" library (or with modified versions of it
20 dnl that use the same license as the "OpenSSL" library), and distribute
21 dnl the linked executables. You must obey the GNU General Public License
22 dnl in all respects for all of the code used other than "OpenSSL". If you
23 dnl modify this file, you may extend this exception to your version of the
24 dnl file, but you are not obligated to do so. If you do not wish to do
25 dnl so, delete this exception statement from your version.
28 dnl Check for `struct utimbuf'.
31 AC_DEFUN([WGET_STRUCT_UTIMBUF], [
32 AC_CHECK_TYPES([struct utimbuf], [], [], [
35 # include <sys/types.h>
44 dnl Check for socklen_t. The third argument of accept, getsockname,
45 dnl etc. is int * on some systems, but size_t * on others. POSIX
46 dnl finally standardized on socklen_t, but older systems don't have
47 dnl it. If socklen_t exists, we use it, else if accept() accepts
48 dnl size_t *, we use that, else we use int.
50 AC_DEFUN([WGET_SOCKLEN_T], [
51 AC_MSG_CHECKING(for socklen_t)
53 #include <sys/types.h>
54 #include <sys/socket.h>
56 ], [AC_MSG_RESULT(socklen_t)], [
58 #include <sys/types.h>
59 #include <sys/socket.h>
60 int accept (int, struct sockaddr *, size_t *);
63 AC_DEFINE([socklen_t], [size_t],
64 [Define to int or size_t on systems without socklen_t.])
67 AC_DEFINE([socklen_t], [int],
68 [Define to int or size_t on systems without socklen_t.])
73 dnl Check whether fnmatch.h can be included. This doesn't use
74 dnl AC_FUNC_FNMATCH because Wget is already careful to only use
75 dnl fnmatch on certain OS'es. However, fnmatch.h is sometimes broken
76 dnl even on those because Apache installs its own fnmatch.h to
77 dnl /usr/local/include (!), which GCC uses before /usr/include.
79 AC_DEFUN([WGET_FNMATCH], [
80 AC_MSG_CHECKING([for working fnmatch.h])
81 AC_COMPILE_IFELSE([#include <fnmatch.h>
84 AC_DEFINE([HAVE_WORKING_FNMATCH_H], 1,
85 [Define if fnmatch.h can be included.])
91 dnl Check for nanosleep. For nanosleep to work on Solaris, we must
92 dnl link with -lrt (recently) or with -lposix4 (older releases).
94 AC_DEFUN([WGET_NANOSLEEP], [
95 AC_CHECK_FUNCS(nanosleep, [], [
96 AC_CHECK_LIB(rt, nanosleep, [
97 AC_DEFINE([HAVE_NANOSLEEP], 1,
98 [Define if you have the nanosleep function.])
101 AC_CHECK_LIB(posix4, nanosleep, [
102 AC_DEFINE([HAVE_NANOSLEEP], 1,
103 [Define if you have the nanosleep function.])
104 LIBS="-lposix4 $LIBS"
110 AC_DEFUN([WGET_POSIX_CLOCK], [
111 AC_CHECK_FUNCS(clock_gettime, [], [
112 AC_CHECK_LIB(rt, clock_gettime)
116 dnl Check whether we need to link with -lnsl and -lsocket, as is the
117 dnl case on e.g. Solaris.
119 AC_DEFUN([WGET_NSL_SOCKET], [
120 dnl On Solaris, -lnsl is needed to use gethostbyname. But checking
121 dnl for gethostbyname is not enough because on "NCR MP-RAS 3.0"
122 dnl gethostbyname is in libc, but -lnsl is still needed to use
123 dnl -lsocket, as well as for functions such as inet_ntoa. We look
124 dnl for such known offenders and if one of them is not found, we
125 dnl check if -lnsl is needed.
126 wget_check_in_nsl=NONE
127 AC_CHECK_FUNCS(gethostbyname, [], [
128 wget_check_in_nsl=gethostbyname
130 AC_CHECK_FUNCS(inet_ntoa, [], [
131 wget_check_in_nsl=inet_ntoa
133 if test $wget_check_in_nsl != NONE; then
134 AC_CHECK_LIB(nsl, $wget_check_in_nsl)
136 AC_CHECK_LIB(socket, socket)
140 dnl ************************************************************
141 dnl START OF IPv6 AUTOCONFIGURATION SUPPORT MACROS
142 dnl ************************************************************
144 AC_DEFUN([TYPE_STRUCT_SOCKADDR_IN6],[
145 wget_have_sockaddr_in6=
146 AC_CHECK_TYPES([struct sockaddr_in6],[
147 wget_have_sockaddr_in6=yes
149 wget_have_sockaddr_in6=no
151 #include <sys/types.h>
152 #include <sys/socket.h>
153 #include <netinet/in.h>
156 if test "X$wget_have_sockaddr_in6" = "Xyes"; then :
164 AC_DEFUN([MEMBER_SIN6_SCOPE_ID],[
165 AC_REQUIRE([TYPE_STRUCT_SOCKADDR_IN6])
167 wget_member_sin6_scope_id=
168 if test "X$wget_have_sockaddr_in6" = "Xyes"; then
169 AC_CHECK_MEMBER([struct sockaddr_in6.sin6_scope_id],[
170 wget_member_sin6_scope_id=yes
172 wget_member_sin6_scope_id=no
174 #include <sys/types.h>
175 #include <sys/socket.h>
176 #include <netinet/in.h>
180 if test "X$wget_member_sin6_scope_id" = "Xyes"; then
181 AC_DEFINE([HAVE_SOCKADDR_IN6_SCOPE_ID], 1,
182 [Define if struct sockaddr_in6 has the sin6_scope_id member])
190 AC_DEFUN([PROTO_INET6],[
191 AC_CACHE_CHECK([for INET6 protocol support], [wget_cv_proto_inet6],[
193 #include <sys/types.h>
194 #include <sys/socket.h>
197 #error Missing PF_INET6
200 #error Mlssing AF_INET6
203 wget_cv_proto_inet6=yes
205 wget_cv_proto_inet6=no
209 if test "X$wget_cv_proto_inet6" = "Xyes"; then :
217 AC_DEFUN([WGET_STRUCT_SOCKADDR_STORAGE],[
218 AC_CHECK_TYPES([struct sockaddr_storage],[], [], [
219 #include <sys/types.h>
220 #include <sys/socket.h>
224 dnl ************************************************************
225 dnl END OF IPv6 AUTOCONFIGURATION SUPPORT MACROS
226 dnl ************************************************************
228 # This code originates from Ulrich Drepper's AM_WITH_NLS.
230 AC_DEFUN([WGET_WITH_NLS],
231 [AC_MSG_CHECKING([whether NLS is requested])
232 dnl Default is enabled NLS
234 [ --disable-nls do not use Native Language Support],
235 HAVE_NLS=$enableval, HAVE_NLS=yes)
236 AC_MSG_RESULT($HAVE_NLS)
238 dnl If something goes wrong, we may still decide not to use NLS.
239 dnl For this reason, defer AC_SUBST'ing HAVE_NLS until the very
242 if test x"$HAVE_NLS" = xyes; then
243 dnl If LINGUAS is specified, use only those languages. In fact,
244 dnl compute an intersection of languages in LINGUAS and
245 dnl ALL_LINGUAS, and use that.
246 if test x"$LINGUAS" != x; then
248 for lang1 in $ALL_LINGUAS; do
249 for lang2 in $LINGUAS; do
250 if test "$lang1" = "$lang2"; then
251 new_linguas="$new_linguas $lang1"
255 ALL_LINGUAS=$new_linguas
257 AC_MSG_NOTICE([language catalogs: $ALL_LINGUAS])
258 AM_PATH_PROG_WITH_TEST(MSGFMT, msgfmt,
259 [test -z "`$ac_dir/$ac_word -h 2>&1 | grep 'dv '`"], msgfmt)
260 AM_PATH_PROG_WITH_TEST(XGETTEXT, xgettext,
261 [test -z "`$ac_dir/$ac_word -h 2>&1 | grep '(HELP)'`"], :)
263 AC_PATH_PROG(GMSGFMT, gmsgfmt, $MSGFMT)
268 dnl Test whether we really found GNU xgettext.
269 if test "$XGETTEXT" != ":"; then
270 dnl If it is no GNU xgettext we define it as : so that the
271 dnl Makefiles still can work.
272 if $XGETTEXT --omit-header /dev/null 2> /dev/null; then
276 [found xgettext programs is not GNU xgettext; ignore it])
281 AC_CHECK_HEADERS(libintl.h)
283 dnl Prefer gettext found in -lintl to the one in libc.
284 dnl Otherwise it can happen that we include libintl.h from
285 dnl /usr/local/lib, but fail to specify -lintl, which results in
286 dnl link or run-time failures. (Symptom: libintl_bindtextdomain
287 dnl not found at link-time.)
289 AC_CHECK_LIB(intl, gettext, [
290 dnl gettext is in libintl; announce the fact manually.
292 AC_DEFINE([HAVE_GETTEXT], 1,
293 [Define if you have the gettext function.])
295 AC_CHECK_FUNCS(gettext, [], [
296 AC_MSG_RESULT([gettext not found; disabling NLS])
301 for lang in $ALL_LINGUAS; do
302 GMOFILES="$GMOFILES $lang.gmo"
303 POFILES="$POFILES $lang.po"
305 dnl Construct list of names of catalog files to be constructed.
306 for lang in $ALL_LINGUAS; do
307 CATALOGS="$CATALOGS ${lang}${CATOBJEXT}"
310 dnl Make all variables we use known to autoconf.
313 AC_SUBST(DATADIRNAME)
320 dnl Some independently maintained files, such as po/Makefile.in,
321 dnl use `USE_NLS', so support it.
324 if test "x$HAVE_NLS" = xyes; then
325 AC_DEFINE([HAVE_NLS], 1, [Define this if you want the NLS support.])
329 dnl Generate list of files to be processed by xgettext which will
330 dnl be included in po/Makefile.
332 dnl This is not strictly an Autoconf macro, because it is run from
333 dnl within `config.status' rather than from within configure. This
334 dnl is why special rules must be applied for it.
335 AC_DEFUN([WGET_PROCESS_PO],
337 dnl I wonder what the following several lines do...
338 if test "x$srcdir" != "x."; then
339 if test "x`echo $srcdir | sed 's@/.*@@'`" = "x"; then
340 posrcprefix="$srcdir/"
342 posrcprefix="../$srcdir/"
348 dnl Use `echo' rather than AC_MSG_RESULT, because this is run from
350 echo "generating po/POTFILES from $srcdir/po/POTFILES.in"
351 sed -e "/^#/d" -e "/^\$/d" -e "s,.*, $posrcprefix& \\\\," \
352 -e "\$s/\(.*\) \\\\/\1/" \
353 < $srcdir/po/POTFILES.in > po/POTFILES
354 echo "creating po/Makefile"
355 sed -e "/POTFILES =/r po/POTFILES" po/Makefile.in > po/Makefile
358 # Search path for a program which passes the given test.
359 # Ulrich Drepper <drepper@cygnus.com>, 1996.
361 # This file may be copied and used freely without restrictions. It
362 # can be used in projects which are not available under the GNU Public
363 # License but which still want to provide support for the GNU gettext
364 # functionality. Please note that the actual code is *not* freely
367 dnl AM_PATH_PROG_WITH_TEST(VARIABLE, PROG-TO-CHECK-FOR,
368 dnl TEST-PERFORMED-ON-FOUND_PROGRAM [, VALUE-IF-NOT-FOUND [, PATH]])
369 AC_DEFUN([AM_PATH_PROG_WITH_TEST],
370 [# Extract the first word of "$2", so it can be a program name with args.
371 set dummy $2; ac_word=[$]2
372 AC_MSG_CHECKING([for $ac_word])
373 AC_CACHE_VAL(ac_cv_path_$1,
376 ac_cv_path_$1="[$]$1" # Let the user override the test with a path.
379 IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:"
380 for ac_dir in ifelse([$5], , $PATH, [$5]); do
381 test -z "$ac_dir" && ac_dir=.
382 if test -f $ac_dir/$ac_word; then
384 ac_cv_path_$1="$ac_dir/$ac_word"
390 dnl If no 4th arg is given, leave the cache variable unset,
391 dnl so AC_PATH_PROGS will keep looking.
392 ifelse([$4], , , [ test -z "[$]ac_cv_path_$1" && ac_cv_path_$1="$4"
397 if test -n "[$]$1"; then