]> sjero.net Git - wget/blob - aclocal.m4
d71269ac3e0fb84940455392d885901c4d3a1c41
[wget] / aclocal.m4
1 dnl
2 dnl Check for `struct utimbuf'.
3 dnl
4
5 AC_DEFUN([WGET_STRUCT_UTIMBUF], [
6   AC_CHECK_TYPES([struct utimbuf], [], [], [
7 #include <stdio.h>
8 #if HAVE_SYS_TYPES_H
9 # include <sys/types.h>
10 #endif
11 #if HAVE_UTIME_H
12 # include <utime.h>
13 #endif
14   ])
15 ])
16
17
18 dnl Check for socklen_t.  The third argument of accept, getsockname,
19 dnl etc. is int * on some systems, but size_t * on others.  POSIX
20 dnl finally standardized on socklen_t, but older systems don't have
21 dnl it.  If socklen_t exists, we use it, else if accept() accepts
22 dnl size_t *, we use that, else we use int.
23
24 AC_DEFUN([WGET_SOCKLEN_T], [
25   AC_MSG_CHECKING(for socklen_t)
26   AC_COMPILE_IFELSE([
27 #include <sys/types.h>
28 #include <sys/socket.h>
29 socklen_t x;
30   ], [AC_MSG_RESULT(socklen_t)], [
31     AC_COMPILE_IFELSE([
32 #include <sys/types.h>
33 #include <sys/socket.h>
34 int accept (int, struct sockaddr *, size_t *);
35     ], [
36       AC_MSG_RESULT(size_t)
37       AC_DEFINE([socklen_t], [size_t],
38                 [Define to int or size_t on systems without socklen_t.])
39     ], [
40       AC_MSG_RESULT(int)
41       AC_DEFINE([socklen_t], [int],
42                 [Define to int or size_t on systems without socklen_t.])
43     ])
44   ])
45 ])
46
47 dnl Check whether fnmatch.h can be included.  This doesn't use
48 dnl AC_FUNC_FNMATCH because Wget is already careful to only use
49 dnl fnmatch on certain OS'es.  However, fnmatch.h is sometimes broken
50 dnl even on those because Apache installs its own fnmatch.h to
51 dnl /usr/local/include (!), which GCC uses before /usr/include.
52
53 AC_DEFUN([WGET_FNMATCH], [
54   AC_MSG_CHECKING([for working fnmatch.h])
55   AC_COMPILE_IFELSE([#include <fnmatch.h>
56                     ], [
57     AC_MSG_RESULT(yes)
58     AC_DEFINE([HAVE_WORKING_FNMATCH_H], 1,
59               [Define if fnmatch.h can be included.])
60   ], [
61     AC_MSG_RESULT(no)
62   ])
63 ])
64
65 dnl Check for nanosleep.  For nanosleep to work on Solaris, we must
66 dnl link with -lt (recently) or with -lposix (older releases).
67
68 AC_DEFUN([WGET_NANOSLEEP], [
69   AC_CHECK_FUNCS(nanosleep, [], [
70     AC_CHECK_LIB(rt, nanosleep, [
71       AC_DEFINE([HAVE_NANOSLEEP], 1,
72                 [Define if you have the nanosleep function.])
73       LIBS="-lrt $LIBS"
74     ], [
75       AC_CHECK_LIB(posix4, nanosleep, [
76         AC_DEFINE([HAVE_NANOSLEEP], 1,
77                   [Define if you have the nanosleep function.])
78         LIBS="-lposix4 $LIBS"
79       ])
80     ])
81   ])
82 ])
83
84 dnl Check whether we need to link with -lnsl and -lsocket, as is the
85 dnl case on e.g. Solaris.
86
87 AC_DEFUN([WGET_NSL_SOCKET], [
88   dnl On Solaris, -lnsl is needed to use gethostbyname.  But checking
89   dnl for gethostbyname is not enough because on "NCR MP-RAS 3.0"
90   dnl gethostbyname is in libc, but -lnsl is still needed to use
91   dnl -lsocket, as well as for functions such as inet_ntoa.  We look
92   dnl for such known offenders and if one of them is not found, we
93   dnl check if -lnsl is needed.
94   wget_check_in_nsl=NONE
95   AC_CHECK_FUNCS(gethostbyname, [], [
96     wget_check_in_nsl=gethostbyname
97   ])
98   AC_CHECK_FUNCS(inet_ntoa, [], [
99     wget_check_in_nsl=inet_ntoa
100   ])
101   if test $wget_check_in_nsl != NONE; then
102     AC_CHECK_LIB(nsl, $wget_check_in_nsl)
103   fi
104   AC_CHECK_LIB(socket, socket)
105 ])
106
107
108 # serial 1
109
110 # @defmac AC_PROG_CC_STDC
111 # @maindex PROG_CC_STDC
112 # @ovindex CC
113 # If the C compiler in not in ANSI C mode by default, try to add an option
114 # to output variable @code{CC} to make it so.  This macro tries various
115 # options that select ANSI C on some system or another.  It considers the
116 # compiler to be in ANSI C mode if it defines @code{__STDC__} to 1 and
117 # handles function prototypes correctly.
118 #
119 # If you use this macro, you should check after calling it whether the C
120 # compiler has been set to accept ANSI C; if not, the shell variable
121 # @code{am_cv_prog_cc_stdc} is set to @samp{no}.  If you wrote your source
122 # code in ANSI C, you can make an un-ANSIfied copy of it by using the
123 # program @code{ansi2knr}, which comes with Ghostscript.
124 # @end defmac
125
126 AC_DEFUN(AM_PROG_CC_STDC,
127 [AC_REQUIRE([AC_PROG_CC])
128 AC_MSG_CHECKING([for ${CC-cc} option to accept ANSI C])
129 AC_CACHE_VAL(am_cv_prog_cc_stdc,
130 [am_cv_prog_cc_stdc=no
131 ac_save_CC="$CC"
132 # Don't try gcc -ansi; that turns off useful extensions and
133 # breaks some systems' header files.
134 # AIX                   -qlanglvl=ansi
135 # Ultrix and OSF/1      -std1
136 # HP-UX                 -Aa -D_HPUX_SOURCE
137 for ac_arg in "" -qlanglvl=ansi -std1 "-Aa -D_HPUX_SOURCE"
138 do
139   CC="$ac_save_CC $ac_arg"
140   AC_TRY_COMPILE(
141 [#if !defined(__STDC__)
142 choke me
143 #endif
144 /* DYNIX/ptx V4.1.3 can't compile sys/stat.h with -Xc -D__EXTENSIONS__. */
145 #ifdef _SEQUENT_
146 # include <sys/types.h>
147 # include <sys/stat.h>
148 #endif
149 ], [
150 int test (int i, double x);
151 struct s1 {int (*f) (int a);};
152 struct s2 {int (*f) (double a);};],
153 [am_cv_prog_cc_stdc="$ac_arg"; break])
154 done
155 CC="$ac_save_CC"
156 ])
157 AC_MSG_RESULT($am_cv_prog_cc_stdc)
158 case "x$am_cv_prog_cc_stdc" in
159   x|xno) ;;
160   *) CC="$CC $am_cv_prog_cc_stdc" ;;
161 esac
162 ])
163
164
165 dnl ************************************************************
166 dnl START OF IPv6 AUTOCONFIGURATION SUPPORT MACROS
167 dnl ************************************************************
168
169 AC_DEFUN([TYPE_STRUCT_SOCKADDR_IN6],[
170   ds6_have_sockaddr_in6=
171   AC_CHECK_TYPES([struct sockaddr_in6],[
172     ds6_have_sockaddr_in6=yes
173   ],[
174     ds6_have_sockaddr_in6=no
175   ],[
176 #include <sys/types.h>
177 #include <sys/socket.h>
178 #include <netinet/in.h>
179   ])
180
181   if test "X$ds6_have_sockaddr_in6" = "Xyes"; then :
182     $1
183   else :
184     $2
185   fi
186 ])
187
188
189 AC_DEFUN([MEMBER_SIN6_SCOPE_ID],[
190   AC_REQUIRE([TYPE_STRUCT_SOCKADDR_IN6])
191   
192   ds6_member_sin6_scope_id=
193   if test "X$ds6_have_sockaddr_in6" = "Xyes"; then
194     AC_CHECK_MEMBER([struct sockaddr_in6.sin6_scope_id],[
195       ds6_member_sin6_scope_id=yes
196     ],[
197       ds6_member_sin6_scope_id=no
198     ],[
199 #include <sys/types.h>
200 #include <sys/socket.h>
201 #include <netinet/in.h>
202     ])
203   fi
204
205   if test "X$ds6_member_sin6_scope_id" = "Xyes"; then
206     AC_DEFINE([HAVE_SOCKADDR_IN6_SCOPE_ID], 1,
207       [Define if struct sockaddr_in6 has the sin6_scope_id member])
208     $1
209   else :
210     $2
211   fi
212 ])
213
214
215 AC_DEFUN([PROTO_INET6],[
216   AC_CACHE_CHECK([for INET6 protocol support], [ds6_cv_proto_inet6],[
217     AC_TRY_CPP([
218 #include <sys/types.h>
219 #include <sys/socket.h>
220
221 #ifndef PF_INET6
222 #error Missing PF_INET6
223 #endif
224 #ifndef AF_INET6
225 #error Mlssing AF_INET6
226 #endif
227     ],[
228       ds6_cv_proto_inet6=yes
229     ],[
230       ds6_cv_proto_inet6=no
231     ])
232   ])
233
234   if test "X$ds6_cv_proto_inet6" = "Xyes"; then :
235     $1
236   else :
237     $2
238   fi
239 ])
240
241
242 AC_DEFUN([GETADDRINFO_AI_ADDRCONFIG],[
243   AC_CACHE_CHECK([if getaddrinfo supports AI_ADDRCONFIG],
244     [ds6_cv_gai_ai_addrconfig],[
245     AC_TRY_CPP([
246 #include <netdb.h>
247
248 #ifndef AI_ADDRCONFIG
249 #error Missing AI_ADDRCONFIG
250 #endif
251     ],[
252       ds6_cv_gai_ai_addrconfig=yes
253     ],[
254       ds6_cv_gai_ai_addrconfig=no
255     ])
256   ])
257
258   if test "X$ds6_cv_gai_ai_addrconfig" = "Xyes"; then :
259     $1
260   else :
261     $2
262   fi
263 ])
264
265
266 AC_DEFUN([GETADDRINFO_AI_ALL],[
267   AC_CACHE_CHECK([if getaddrinfo supports AI_ALL],[ds6_cv_gai_ai_all],[
268     AC_TRY_CPP([
269 #include <netdb.h>
270
271 #ifndef AI_ALL
272 #error Missing AI_ALL
273 #endif
274     ],[
275       ds6_cv_gai_ai_all=yes
276     ],[
277       ds6_cv_gai_ai_all=no
278     ])
279   ])
280
281   if test "X$ds6_cv_gai_ai_all" = "Xyes"; then :
282     $1
283   else :
284     $2
285   fi
286 ])
287
288
289 AC_DEFUN([GETADDRINFO_AI_V4MAPPED],[
290   AC_CACHE_CHECK([if getaddrinfo supports AI_V4MAPPED],[ds6_cv_gai_ai_v4mapped],[
291     AC_TRY_CPP([
292 #include <netdb.h>
293
294 #ifndef AI_V4MAPPED
295 #error Missing AI_V4MAPPED
296 #endif
297     ],[
298       ds6_cv_gai_ai_v4mapped=yes
299     ],[
300       ds6_cv_gai_ai_v4mapped=no
301     ])
302   ])
303
304   if test "X$ds6_cv_gai_ai_v4mapped" = "Xyes"; then :
305     $1
306   else :
307     $2
308   fi
309 ])
310
311 dnl ************************************************************
312 dnl END OF IPv6 AUTOCONFIGURATION SUPPORT MACROS
313 dnl ************************************************************
314 \f
315 # This code originates from Ulrich Drepper's AM_WITH_NLS.
316
317 AC_DEFUN([WGET_WITH_NLS],
318   [AC_MSG_CHECKING([whether NLS is requested])
319     dnl Default is enabled NLS
320     AC_ARG_ENABLE(nls,
321       [  --disable-nls           do not use Native Language Support],
322       HAVE_NLS=$enableval, HAVE_NLS=yes)
323     AC_MSG_RESULT($HAVE_NLS)
324
325     dnl If something goes wrong, we may still decide not to use NLS.
326     dnl For this reason, defer AC_SUBST'ing HAVE_NLS until the very
327     dnl last moment.
328
329     if test x"$HAVE_NLS" = xyes; then
330       dnl If LINGUAS is specified, use only those languages.  In fact,
331       dnl compute an intersection of languages in LINGUAS and
332       dnl ALL_LINGUAS, and use that.
333       if test x"$LINGUAS" != x; then
334         new_linguas=
335         for lang1 in $ALL_LINGUAS; do
336           for lang2 in $LINGUAS; do
337             if test "$lang1" = "$lang2"; then
338               new_linguas="$new_linguas $lang1"
339             fi
340           done
341         done
342         ALL_LINGUAS=$new_linguas
343       fi
344       AC_MSG_NOTICE([language catalogs: $ALL_LINGUAS])
345       AM_PATH_PROG_WITH_TEST(MSGFMT, msgfmt,
346         [test -z "`$ac_dir/$ac_word -h 2>&1 | grep 'dv '`"], msgfmt)
347       AM_PATH_PROG_WITH_TEST(XGETTEXT, xgettext,
348           [test -z "`$ac_dir/$ac_word -h 2>&1 | grep '(HELP)'`"], :)
349       AC_SUBST(MSGFMT)
350       AC_PATH_PROG(GMSGFMT, gmsgfmt, $MSGFMT)
351       CATOBJEXT=.gmo
352       INSTOBJEXT=.mo
353       DATADIRNAME=share
354
355       dnl Test whether we really found GNU xgettext.
356       if test "$XGETTEXT" != ":"; then
357         dnl If it is no GNU xgettext we define it as : so that the
358         dnl Makefiles still can work.
359         if $XGETTEXT --omit-header /dev/null 2> /dev/null; then
360           : ;
361         else
362           AC_MSG_RESULT(
363             [found xgettext programs is not GNU xgettext; ignore it])
364           XGETTEXT=":"
365         fi
366       fi
367
368       AC_CHECK_HEADERS(locale.h libintl.h)
369
370       dnl Prefer gettext found in -lintl to the one in libc.
371       dnl Otherwise it can happen that we include libintl.h from
372       dnl /usr/local/lib, but fail to specify -lintl, which results in
373       dnl link or run-time failures.  (Symptom: libintl_bindtextdomain
374       dnl not found at link-time.)
375
376       AC_CHECK_LIB(intl, gettext, [
377         dnl gettext is in libintl; announce the fact manually.
378         LIBS="-lintl $LIBS"
379         AC_DEFINE([HAVE_GETTEXT], 1,
380                   [Define if you have the gettext function.])
381       ], [
382         AC_CHECK_FUNCS(gettext, [], [
383           AC_MSG_RESULT([gettext not found; disabling NLS])
384           HAVE_NLS=no
385         ])
386       ])
387
388       for lang in $ALL_LINGUAS; do
389         GMOFILES="$GMOFILES $lang.gmo"
390         POFILES="$POFILES $lang.po"
391       done
392       dnl Construct list of names of catalog files to be constructed.
393       for lang in $ALL_LINGUAS; do
394         CATALOGS="$CATALOGS ${lang}${CATOBJEXT}"
395       done
396
397       dnl Make all variables we use known to autoconf.
398       AC_SUBST(CATALOGS)
399       AC_SUBST(CATOBJEXT)
400       AC_SUBST(DATADIRNAME)
401       AC_SUBST(GMOFILES)
402       AC_SUBST(INSTOBJEXT)
403       AC_SUBST(INTLLIBS)
404       AC_SUBST(POFILES)
405     fi
406     AC_SUBST(HAVE_NLS)
407     dnl Some independently maintained files, such as po/Makefile.in,
408     dnl use `USE_NLS', so support it.
409     USE_NLS=$HAVE_NLS
410     AC_SUBST(USE_NLS)
411     if test "x$HAVE_NLS" = xyes; then
412       AC_DEFINE([HAVE_NLS], 1, [Define this if you want the NLS support.])
413     fi
414   ])
415
416 dnl Generate list of files to be processed by xgettext which will
417 dnl be included in po/Makefile.
418 dnl
419 dnl This is not strictly an Autoconf macro, because it is run from
420 dnl within `config.status' rather than from within configure.  This
421 dnl is why special rules must be applied for it.
422 AC_DEFUN(WGET_PROCESS_PO,
423   [
424    dnl I wonder what the following several lines do...
425    if test "x$srcdir" != "x."; then
426      if test "x`echo $srcdir | sed 's@/.*@@'`" = "x"; then
427        posrcprefix="$srcdir/"
428      else
429        posrcprefix="../$srcdir/"
430      fi
431    else
432      posrcprefix="../"
433    fi
434    rm -f po/POTFILES
435    dnl Use `echo' rather than AC_MSG_RESULT, because this is run from
436    dnl `config.status'.
437    echo "generating po/POTFILES from $srcdir/po/POTFILES.in"
438    sed -e "/^#/d" -e "/^\$/d" -e "s,.*, $posrcprefix& \\\\,"  \
439        -e "\$s/\(.*\) \\\\/\1/" \
440         < $srcdir/po/POTFILES.in > po/POTFILES
441    echo "creating po/Makefile"
442    sed -e "/POTFILES =/r po/POTFILES" po/Makefile.in > po/Makefile
443   ])
444
445 # Search path for a program which passes the given test.
446 # Ulrich Drepper <drepper@cygnus.com>, 1996.
447 #
448 # This file may be copied and used freely without restrictions.  It
449 # can be used in projects which are not available under the GNU Public
450 # License but which still want to provide support for the GNU gettext
451 # functionality.  Please note that the actual code is *not* freely
452 # available.
453
454 # serial 1
455
456 dnl AM_PATH_PROG_WITH_TEST(VARIABLE, PROG-TO-CHECK-FOR,
457 dnl   TEST-PERFORMED-ON-FOUND_PROGRAM [, VALUE-IF-NOT-FOUND [, PATH]])
458 AC_DEFUN(AM_PATH_PROG_WITH_TEST,
459 [# Extract the first word of "$2", so it can be a program name with args.
460 set dummy $2; ac_word=[$]2
461 AC_MSG_CHECKING([for $ac_word])
462 AC_CACHE_VAL(ac_cv_path_$1,
463 [case "[$]$1" in
464   /*)
465   ac_cv_path_$1="[$]$1" # Let the user override the test with a path.
466   ;;
467   *)
468   IFS="${IFS=   }"; ac_save_ifs="$IFS"; IFS="${IFS}:"
469   for ac_dir in ifelse([$5], , $PATH, [$5]); do
470     test -z "$ac_dir" && ac_dir=.
471     if test -f $ac_dir/$ac_word; then
472       if [$3]; then
473         ac_cv_path_$1="$ac_dir/$ac_word"
474         break
475       fi
476     fi
477   done
478   IFS="$ac_save_ifs"
479 dnl If no 4th arg is given, leave the cache variable unset,
480 dnl so AC_PATH_PROGS will keep looking.
481 ifelse([$4], , , [  test -z "[$]ac_cv_path_$1" && ac_cv_path_$1="$4"
482 ])dnl
483   ;;
484 esac])dnl
485 $1="$ac_cv_path_$1"
486 if test -n "[$]$1"; then
487   AC_MSG_RESULT([$]$1)
488 else
489   AC_MSG_RESULT(no)
490 fi
491 AC_SUBST($1)dnl
492 ])
493
494 # Include libtool code.
495
496 builtin(include, libtool.m4)dnl