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