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