]> sjero.net Git - wget/blob - aclocal.m4
cf93b2bfaac31e6d3c4f183b22fd72034d64a2dc
[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 -lrt (recently) or with -lposix4 (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 AC_DEFUN([WGET_POSIX_CLOCK], [
85   AC_CHECK_FUNCS(clock_gettime, [], [
86     AC_CHECK_LIB(rt, clock_gettime)
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   wget_have_sockaddr_in6=
177   AC_CHECK_TYPES([struct sockaddr_in6],[
178     wget_have_sockaddr_in6=yes
179   ],[
180     wget_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$wget_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   wget_member_sin6_scope_id=
199   if test "X$wget_have_sockaddr_in6" = "Xyes"; then
200     AC_CHECK_MEMBER([struct sockaddr_in6.sin6_scope_id],[
201       wget_member_sin6_scope_id=yes
202     ],[
203       wget_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$wget_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], [wget_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       wget_cv_proto_inet6=yes
235     ],[
236       wget_cv_proto_inet6=no
237     ])
238   ])
239
240   if test "X$wget_cv_proto_inet6" = "Xyes"; then :
241     $1
242   else :
243     $2
244   fi
245 ])
246
247
248 AC_DEFUN([WGET_STRUCT_SOCKADDR_STORAGE],[
249   AC_CHECK_TYPES([struct sockaddr_storage],[], [], [
250 #include <sys/types.h>
251 #include <sys/socket.h>
252   ])
253 ])
254
255 dnl ************************************************************
256 dnl END OF IPv6 AUTOCONFIGURATION SUPPORT MACROS
257 dnl ************************************************************
258 \f
259 # This code originates from Ulrich Drepper's AM_WITH_NLS.
260
261 AC_DEFUN([WGET_WITH_NLS],
262   [AC_MSG_CHECKING([whether NLS is requested])
263     dnl Default is enabled NLS
264     AC_ARG_ENABLE(nls,
265       [  --disable-nls           do not use Native Language Support],
266       HAVE_NLS=$enableval, HAVE_NLS=yes)
267     AC_MSG_RESULT($HAVE_NLS)
268
269     dnl If something goes wrong, we may still decide not to use NLS.
270     dnl For this reason, defer AC_SUBST'ing HAVE_NLS until the very
271     dnl last moment.
272
273     if test x"$HAVE_NLS" = xyes; then
274       dnl If LINGUAS is specified, use only those languages.  In fact,
275       dnl compute an intersection of languages in LINGUAS and
276       dnl ALL_LINGUAS, and use that.
277       if test x"$LINGUAS" != x; then
278         new_linguas=
279         for lang1 in $ALL_LINGUAS; do
280           for lang2 in $LINGUAS; do
281             if test "$lang1" = "$lang2"; then
282               new_linguas="$new_linguas $lang1"
283             fi
284           done
285         done
286         ALL_LINGUAS=$new_linguas
287       fi
288       AC_MSG_NOTICE([language catalogs: $ALL_LINGUAS])
289       AM_PATH_PROG_WITH_TEST(MSGFMT, msgfmt,
290         [test -z "`$ac_dir/$ac_word -h 2>&1 | grep 'dv '`"], msgfmt)
291       AM_PATH_PROG_WITH_TEST(XGETTEXT, xgettext,
292           [test -z "`$ac_dir/$ac_word -h 2>&1 | grep '(HELP)'`"], :)
293       AC_SUBST(MSGFMT)
294       AC_PATH_PROG(GMSGFMT, gmsgfmt, $MSGFMT)
295       CATOBJEXT=.gmo
296       INSTOBJEXT=.mo
297       DATADIRNAME=share
298
299       dnl Test whether we really found GNU xgettext.
300       if test "$XGETTEXT" != ":"; then
301         dnl If it is no GNU xgettext we define it as : so that the
302         dnl Makefiles still can work.
303         if $XGETTEXT --omit-header /dev/null 2> /dev/null; then
304           : ;
305         else
306           AC_MSG_RESULT(
307             [found xgettext programs is not GNU xgettext; ignore it])
308           XGETTEXT=":"
309         fi
310       fi
311
312       AC_CHECK_HEADERS(locale.h libintl.h)
313
314       dnl Prefer gettext found in -lintl to the one in libc.
315       dnl Otherwise it can happen that we include libintl.h from
316       dnl /usr/local/lib, but fail to specify -lintl, which results in
317       dnl link or run-time failures.  (Symptom: libintl_bindtextdomain
318       dnl not found at link-time.)
319
320       AC_CHECK_LIB(intl, gettext, [
321         dnl gettext is in libintl; announce the fact manually.
322         LIBS="-lintl $LIBS"
323         AC_DEFINE([HAVE_GETTEXT], 1,
324                   [Define if you have the gettext function.])
325       ], [
326         AC_CHECK_FUNCS(gettext, [], [
327           AC_MSG_RESULT([gettext not found; disabling NLS])
328           HAVE_NLS=no
329         ])
330       ])
331
332       for lang in $ALL_LINGUAS; do
333         GMOFILES="$GMOFILES $lang.gmo"
334         POFILES="$POFILES $lang.po"
335       done
336       dnl Construct list of names of catalog files to be constructed.
337       for lang in $ALL_LINGUAS; do
338         CATALOGS="$CATALOGS ${lang}${CATOBJEXT}"
339       done
340
341       dnl Make all variables we use known to autoconf.
342       AC_SUBST(CATALOGS)
343       AC_SUBST(CATOBJEXT)
344       AC_SUBST(DATADIRNAME)
345       AC_SUBST(GMOFILES)
346       AC_SUBST(INSTOBJEXT)
347       AC_SUBST(INTLLIBS)
348       AC_SUBST(POFILES)
349     fi
350     AC_SUBST(HAVE_NLS)
351     dnl Some independently maintained files, such as po/Makefile.in,
352     dnl use `USE_NLS', so support it.
353     USE_NLS=$HAVE_NLS
354     AC_SUBST(USE_NLS)
355     if test "x$HAVE_NLS" = xyes; then
356       AC_DEFINE([HAVE_NLS], 1, [Define this if you want the NLS support.])
357     fi
358   ])
359
360 dnl Generate list of files to be processed by xgettext which will
361 dnl be included in po/Makefile.
362 dnl
363 dnl This is not strictly an Autoconf macro, because it is run from
364 dnl within `config.status' rather than from within configure.  This
365 dnl is why special rules must be applied for it.
366 AC_DEFUN(WGET_PROCESS_PO,
367   [
368    dnl I wonder what the following several lines do...
369    if test "x$srcdir" != "x."; then
370      if test "x`echo $srcdir | sed 's@/.*@@'`" = "x"; then
371        posrcprefix="$srcdir/"
372      else
373        posrcprefix="../$srcdir/"
374      fi
375    else
376      posrcprefix="../"
377    fi
378    rm -f po/POTFILES
379    dnl Use `echo' rather than AC_MSG_RESULT, because this is run from
380    dnl `config.status'.
381    echo "generating po/POTFILES from $srcdir/po/POTFILES.in"
382    sed -e "/^#/d" -e "/^\$/d" -e "s,.*, $posrcprefix& \\\\,"  \
383        -e "\$s/\(.*\) \\\\/\1/" \
384         < $srcdir/po/POTFILES.in > po/POTFILES
385    echo "creating po/Makefile"
386    sed -e "/POTFILES =/r po/POTFILES" po/Makefile.in > po/Makefile
387   ])
388
389 # Search path for a program which passes the given test.
390 # Ulrich Drepper <drepper@cygnus.com>, 1996.
391 #
392 # This file may be copied and used freely without restrictions.  It
393 # can be used in projects which are not available under the GNU Public
394 # License but which still want to provide support for the GNU gettext
395 # functionality.  Please note that the actual code is *not* freely
396 # available.
397
398 # serial 1
399
400 dnl AM_PATH_PROG_WITH_TEST(VARIABLE, PROG-TO-CHECK-FOR,
401 dnl   TEST-PERFORMED-ON-FOUND_PROGRAM [, VALUE-IF-NOT-FOUND [, PATH]])
402 AC_DEFUN(AM_PATH_PROG_WITH_TEST,
403 [# Extract the first word of "$2", so it can be a program name with args.
404 set dummy $2; ac_word=[$]2
405 AC_MSG_CHECKING([for $ac_word])
406 AC_CACHE_VAL(ac_cv_path_$1,
407 [case "[$]$1" in
408   /*)
409   ac_cv_path_$1="[$]$1" # Let the user override the test with a path.
410   ;;
411   *)
412   IFS="${IFS=   }"; ac_save_ifs="$IFS"; IFS="${IFS}:"
413   for ac_dir in ifelse([$5], , $PATH, [$5]); do
414     test -z "$ac_dir" && ac_dir=.
415     if test -f $ac_dir/$ac_word; then
416       if [$3]; then
417         ac_cv_path_$1="$ac_dir/$ac_word"
418         break
419       fi
420     fi
421   done
422   IFS="$ac_save_ifs"
423 dnl If no 4th arg is given, leave the cache variable unset,
424 dnl so AC_PATH_PROGS will keep looking.
425 ifelse([$4], , , [  test -z "[$]ac_cv_path_$1" && ac_cv_path_$1="$4"
426 ])dnl
427   ;;
428 esac])dnl
429 $1="$ac_cv_path_$1"
430 if test -n "[$]$1"; then
431   AC_MSG_RESULT([$]$1)
432 else
433   AC_MSG_RESULT(no)
434 fi
435 AC_SUBST($1)dnl
436 ])
437
438 # Include libtool code.
439
440 builtin(include, libtool.m4)dnl