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