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