2 dnl Wget-specific Autoconf macros.
6 dnl Check for `struct utimbuf'.
9 AC_DEFUN([WGET_STRUCT_UTIMBUF], [
10 AC_CHECK_TYPES([struct utimbuf], [], [], [
13 # include <sys/types.h>
22 dnl Check for socklen_t. The third argument of accept, getsockname,
23 dnl etc. is int * on some systems, but size_t * on others. POSIX
24 dnl finally standardized on socklen_t, but older systems don't have
25 dnl it. If socklen_t exists, we use it, else if accept() accepts
26 dnl size_t *, we use that, else we use int.
28 AC_DEFUN([WGET_SOCKLEN_T], [
29 AC_MSG_CHECKING(for socklen_t)
31 #include <sys/types.h>
32 #include <sys/socket.h>
34 ], [AC_MSG_RESULT(socklen_t)], [
36 #include <sys/types.h>
37 #include <sys/socket.h>
38 int accept (int, struct sockaddr *, size_t *);
41 AC_DEFINE([socklen_t], [size_t],
42 [Define to int or size_t on systems without socklen_t.])
45 AC_DEFINE([socklen_t], [int],
46 [Define to int or size_t on systems without socklen_t.])
51 dnl Check whether fnmatch.h can be included. This doesn't use
52 dnl AC_FUNC_FNMATCH because Wget is already careful to only use
53 dnl fnmatch on certain OS'es. However, fnmatch.h is sometimes broken
54 dnl even on those because Apache installs its own fnmatch.h to
55 dnl /usr/local/include (!), which GCC uses before /usr/include.
57 AC_DEFUN([WGET_FNMATCH], [
58 AC_MSG_CHECKING([for working fnmatch.h])
59 AC_COMPILE_IFELSE([#include <fnmatch.h>
62 AC_DEFINE([HAVE_WORKING_FNMATCH_H], 1,
63 [Define if fnmatch.h can be included.])
69 dnl Check for nanosleep. For nanosleep to work on Solaris, we must
70 dnl link with -lrt (recently) or with -lposix4 (older releases).
72 AC_DEFUN([WGET_NANOSLEEP], [
73 AC_CHECK_FUNCS(nanosleep, [], [
74 AC_CHECK_LIB(rt, nanosleep, [
75 AC_DEFINE([HAVE_NANOSLEEP], 1,
76 [Define if you have the nanosleep function.])
79 AC_CHECK_LIB(posix4, nanosleep, [
80 AC_DEFINE([HAVE_NANOSLEEP], 1,
81 [Define if you have the nanosleep function.])
88 AC_DEFUN([WGET_POSIX_CLOCK], [
89 AC_CHECK_FUNCS(clock_gettime, [], [
90 AC_CHECK_LIB(rt, clock_gettime)
94 dnl Check whether we need to link with -lnsl and -lsocket, as is the
95 dnl case on e.g. Solaris.
97 AC_DEFUN([WGET_NSL_SOCKET], [
98 dnl On Solaris, -lnsl is needed to use gethostbyname. But checking
99 dnl for gethostbyname is not enough because on "NCR MP-RAS 3.0"
100 dnl gethostbyname is in libc, but -lnsl is still needed to use
101 dnl -lsocket, as well as for functions such as inet_ntoa. We look
102 dnl for such known offenders and if one of them is not found, we
103 dnl check if -lnsl is needed.
104 wget_check_in_nsl=NONE
105 AC_CHECK_FUNCS(gethostbyname, [], [
106 wget_check_in_nsl=gethostbyname
108 AC_CHECK_FUNCS(inet_ntoa, [], [
109 wget_check_in_nsl=inet_ntoa
111 if test $wget_check_in_nsl != NONE; then
112 AC_CHECK_LIB(nsl, $wget_check_in_nsl)
114 AC_CHECK_LIB(socket, socket)
118 dnl ************************************************************
119 dnl START OF IPv6 AUTOCONFIGURATION SUPPORT MACROS
120 dnl ************************************************************
122 AC_DEFUN([TYPE_STRUCT_SOCKADDR_IN6],[
123 wget_have_sockaddr_in6=
124 AC_CHECK_TYPES([struct sockaddr_in6],[
125 wget_have_sockaddr_in6=yes
127 wget_have_sockaddr_in6=no
129 #include <sys/types.h>
130 #include <sys/socket.h>
131 #include <netinet/in.h>
134 if test "X$wget_have_sockaddr_in6" = "Xyes"; then :
142 AC_DEFUN([MEMBER_SIN6_SCOPE_ID],[
143 AC_REQUIRE([TYPE_STRUCT_SOCKADDR_IN6])
145 wget_member_sin6_scope_id=
146 if test "X$wget_have_sockaddr_in6" = "Xyes"; then
147 AC_CHECK_MEMBER([struct sockaddr_in6.sin6_scope_id],[
148 wget_member_sin6_scope_id=yes
150 wget_member_sin6_scope_id=no
152 #include <sys/types.h>
153 #include <sys/socket.h>
154 #include <netinet/in.h>
158 if test "X$wget_member_sin6_scope_id" = "Xyes"; then
159 AC_DEFINE([HAVE_SOCKADDR_IN6_SCOPE_ID], 1,
160 [Define if struct sockaddr_in6 has the sin6_scope_id member])
168 AC_DEFUN([PROTO_INET6],[
169 AC_CACHE_CHECK([for INET6 protocol support], [wget_cv_proto_inet6],[
171 #include <sys/types.h>
172 #include <sys/socket.h>
175 #error Missing PF_INET6
178 #error Mlssing AF_INET6
181 wget_cv_proto_inet6=yes
183 wget_cv_proto_inet6=no
187 if test "X$wget_cv_proto_inet6" = "Xyes"; then :
195 AC_DEFUN([WGET_STRUCT_SOCKADDR_STORAGE],[
196 AC_CHECK_TYPES([struct sockaddr_storage],[], [], [
197 #include <sys/types.h>
198 #include <sys/socket.h>
202 dnl ************************************************************
203 dnl END OF IPv6 AUTOCONFIGURATION SUPPORT MACROS
204 dnl ************************************************************
206 # This code originates from Ulrich Drepper's AM_WITH_NLS.
208 AC_DEFUN([WGET_WITH_NLS],
209 [AC_MSG_CHECKING([whether NLS is requested])
210 dnl Default is enabled NLS
212 [ --disable-nls do not use Native Language Support],
213 HAVE_NLS=$enableval, HAVE_NLS=yes)
214 AC_MSG_RESULT($HAVE_NLS)
216 dnl If something goes wrong, we may still decide not to use NLS.
217 dnl For this reason, defer AC_SUBST'ing HAVE_NLS until the very
220 if test x"$HAVE_NLS" = xyes; then
221 dnl If LINGUAS is specified, use only those languages. In fact,
222 dnl compute an intersection of languages in LINGUAS and
223 dnl ALL_LINGUAS, and use that.
224 if test x"$LINGUAS" != x; then
226 for lang1 in $ALL_LINGUAS; do
227 for lang2 in $LINGUAS; do
228 if test "$lang1" = "$lang2"; then
229 new_linguas="$new_linguas $lang1"
233 ALL_LINGUAS=$new_linguas
235 AC_MSG_NOTICE([language catalogs: $ALL_LINGUAS])
236 AM_PATH_PROG_WITH_TEST(MSGFMT, msgfmt,
237 [test -z "`$ac_dir/$ac_word -h 2>&1 | grep 'dv '`"], msgfmt)
238 AM_PATH_PROG_WITH_TEST(XGETTEXT, xgettext,
239 [test -z "`$ac_dir/$ac_word -h 2>&1 | grep '(HELP)'`"], :)
241 AC_PATH_PROG(GMSGFMT, gmsgfmt, $MSGFMT)
246 dnl Test whether we really found GNU xgettext.
247 if test "$XGETTEXT" != ":"; then
248 dnl If it is no GNU xgettext we define it as : so that the
249 dnl Makefiles still can work.
250 if $XGETTEXT --omit-header /dev/null 2> /dev/null; then
254 [found xgettext programs is not GNU xgettext; ignore it])
259 AC_CHECK_HEADERS(locale.h libintl.h)
261 dnl Prefer gettext found in -lintl to the one in libc.
262 dnl Otherwise it can happen that we include libintl.h from
263 dnl /usr/local/lib, but fail to specify -lintl, which results in
264 dnl link or run-time failures. (Symptom: libintl_bindtextdomain
265 dnl not found at link-time.)
267 AC_CHECK_LIB(intl, gettext, [
268 dnl gettext is in libintl; announce the fact manually.
270 AC_DEFINE([HAVE_GETTEXT], 1,
271 [Define if you have the gettext function.])
273 AC_CHECK_FUNCS(gettext, [], [
274 AC_MSG_RESULT([gettext not found; disabling NLS])
279 for lang in $ALL_LINGUAS; do
280 GMOFILES="$GMOFILES $lang.gmo"
281 POFILES="$POFILES $lang.po"
283 dnl Construct list of names of catalog files to be constructed.
284 for lang in $ALL_LINGUAS; do
285 CATALOGS="$CATALOGS ${lang}${CATOBJEXT}"
288 dnl Make all variables we use known to autoconf.
291 AC_SUBST(DATADIRNAME)
298 dnl Some independently maintained files, such as po/Makefile.in,
299 dnl use `USE_NLS', so support it.
302 if test "x$HAVE_NLS" = xyes; then
303 AC_DEFINE([HAVE_NLS], 1, [Define this if you want the NLS support.])
307 dnl Generate list of files to be processed by xgettext which will
308 dnl be included in po/Makefile.
310 dnl This is not strictly an Autoconf macro, because it is run from
311 dnl within `config.status' rather than from within configure. This
312 dnl is why special rules must be applied for it.
313 AC_DEFUN(WGET_PROCESS_PO,
315 dnl I wonder what the following several lines do...
316 if test "x$srcdir" != "x."; then
317 if test "x`echo $srcdir | sed 's@/.*@@'`" = "x"; then
318 posrcprefix="$srcdir/"
320 posrcprefix="../$srcdir/"
326 dnl Use `echo' rather than AC_MSG_RESULT, because this is run from
328 echo "generating po/POTFILES from $srcdir/po/POTFILES.in"
329 sed -e "/^#/d" -e "/^\$/d" -e "s,.*, $posrcprefix& \\\\," \
330 -e "\$s/\(.*\) \\\\/\1/" \
331 < $srcdir/po/POTFILES.in > po/POTFILES
332 echo "creating po/Makefile"
333 sed -e "/POTFILES =/r po/POTFILES" po/Makefile.in > po/Makefile
336 # Search path for a program which passes the given test.
337 # Ulrich Drepper <drepper@cygnus.com>, 1996.
339 # This file may be copied and used freely without restrictions. It
340 # can be used in projects which are not available under the GNU Public
341 # License but which still want to provide support for the GNU gettext
342 # functionality. Please note that the actual code is *not* freely
347 dnl AM_PATH_PROG_WITH_TEST(VARIABLE, PROG-TO-CHECK-FOR,
348 dnl TEST-PERFORMED-ON-FOUND_PROGRAM [, VALUE-IF-NOT-FOUND [, PATH]])
349 AC_DEFUN(AM_PATH_PROG_WITH_TEST,
350 [# Extract the first word of "$2", so it can be a program name with args.
351 set dummy $2; ac_word=[$]2
352 AC_MSG_CHECKING([for $ac_word])
353 AC_CACHE_VAL(ac_cv_path_$1,
356 ac_cv_path_$1="[$]$1" # Let the user override the test with a path.
359 IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:"
360 for ac_dir in ifelse([$5], , $PATH, [$5]); do
361 test -z "$ac_dir" && ac_dir=.
362 if test -f $ac_dir/$ac_word; then
364 ac_cv_path_$1="$ac_dir/$ac_word"
370 dnl If no 4th arg is given, leave the cache variable unset,
371 dnl so AC_PATH_PROGS will keep looking.
372 ifelse([$4], , , [ test -z "[$]ac_cv_path_$1" && ac_cv_path_$1="$4"
377 if test -n "[$]$1"; then