]> sjero.net Git - wget/blob - aclocal.m4
[svn] Remove K&R support.
[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 dnl ************************************************************
115 dnl START OF IPv6 AUTOCONFIGURATION SUPPORT MACROS
116 dnl ************************************************************
117
118 AC_DEFUN([TYPE_STRUCT_SOCKADDR_IN6],[
119   wget_have_sockaddr_in6=
120   AC_CHECK_TYPES([struct sockaddr_in6],[
121     wget_have_sockaddr_in6=yes
122   ],[
123     wget_have_sockaddr_in6=no
124   ],[
125 #include <sys/types.h>
126 #include <sys/socket.h>
127 #include <netinet/in.h>
128   ])
129
130   if test "X$wget_have_sockaddr_in6" = "Xyes"; then :
131     $1
132   else :
133     $2
134   fi
135 ])
136
137
138 AC_DEFUN([MEMBER_SIN6_SCOPE_ID],[
139   AC_REQUIRE([TYPE_STRUCT_SOCKADDR_IN6])
140   
141   wget_member_sin6_scope_id=
142   if test "X$wget_have_sockaddr_in6" = "Xyes"; then
143     AC_CHECK_MEMBER([struct sockaddr_in6.sin6_scope_id],[
144       wget_member_sin6_scope_id=yes
145     ],[
146       wget_member_sin6_scope_id=no
147     ],[
148 #include <sys/types.h>
149 #include <sys/socket.h>
150 #include <netinet/in.h>
151     ])
152   fi
153
154   if test "X$wget_member_sin6_scope_id" = "Xyes"; then
155     AC_DEFINE([HAVE_SOCKADDR_IN6_SCOPE_ID], 1,
156       [Define if struct sockaddr_in6 has the sin6_scope_id member])
157     $1
158   else :
159     $2
160   fi
161 ])
162
163
164 AC_DEFUN([PROTO_INET6],[
165   AC_CACHE_CHECK([for INET6 protocol support], [wget_cv_proto_inet6],[
166     AC_TRY_CPP([
167 #include <sys/types.h>
168 #include <sys/socket.h>
169
170 #ifndef PF_INET6
171 #error Missing PF_INET6
172 #endif
173 #ifndef AF_INET6
174 #error Mlssing AF_INET6
175 #endif
176     ],[
177       wget_cv_proto_inet6=yes
178     ],[
179       wget_cv_proto_inet6=no
180     ])
181   ])
182
183   if test "X$wget_cv_proto_inet6" = "Xyes"; then :
184     $1
185   else :
186     $2
187   fi
188 ])
189
190
191 AC_DEFUN([WGET_STRUCT_SOCKADDR_STORAGE],[
192   AC_CHECK_TYPES([struct sockaddr_storage],[], [], [
193 #include <sys/types.h>
194 #include <sys/socket.h>
195   ])
196 ])
197
198 dnl ************************************************************
199 dnl END OF IPv6 AUTOCONFIGURATION SUPPORT MACROS
200 dnl ************************************************************
201 \f
202 # This code originates from Ulrich Drepper's AM_WITH_NLS.
203
204 AC_DEFUN([WGET_WITH_NLS],
205   [AC_MSG_CHECKING([whether NLS is requested])
206     dnl Default is enabled NLS
207     AC_ARG_ENABLE(nls,
208       [  --disable-nls           do not use Native Language Support],
209       HAVE_NLS=$enableval, HAVE_NLS=yes)
210     AC_MSG_RESULT($HAVE_NLS)
211
212     dnl If something goes wrong, we may still decide not to use NLS.
213     dnl For this reason, defer AC_SUBST'ing HAVE_NLS until the very
214     dnl last moment.
215
216     if test x"$HAVE_NLS" = xyes; then
217       dnl If LINGUAS is specified, use only those languages.  In fact,
218       dnl compute an intersection of languages in LINGUAS and
219       dnl ALL_LINGUAS, and use that.
220       if test x"$LINGUAS" != x; then
221         new_linguas=
222         for lang1 in $ALL_LINGUAS; do
223           for lang2 in $LINGUAS; do
224             if test "$lang1" = "$lang2"; then
225               new_linguas="$new_linguas $lang1"
226             fi
227           done
228         done
229         ALL_LINGUAS=$new_linguas
230       fi
231       AC_MSG_NOTICE([language catalogs: $ALL_LINGUAS])
232       AM_PATH_PROG_WITH_TEST(MSGFMT, msgfmt,
233         [test -z "`$ac_dir/$ac_word -h 2>&1 | grep 'dv '`"], msgfmt)
234       AM_PATH_PROG_WITH_TEST(XGETTEXT, xgettext,
235           [test -z "`$ac_dir/$ac_word -h 2>&1 | grep '(HELP)'`"], :)
236       AC_SUBST(MSGFMT)
237       AC_PATH_PROG(GMSGFMT, gmsgfmt, $MSGFMT)
238       CATOBJEXT=.gmo
239       INSTOBJEXT=.mo
240       DATADIRNAME=share
241
242       dnl Test whether we really found GNU xgettext.
243       if test "$XGETTEXT" != ":"; then
244         dnl If it is no GNU xgettext we define it as : so that the
245         dnl Makefiles still can work.
246         if $XGETTEXT --omit-header /dev/null 2> /dev/null; then
247           : ;
248         else
249           AC_MSG_RESULT(
250             [found xgettext programs is not GNU xgettext; ignore it])
251           XGETTEXT=":"
252         fi
253       fi
254
255       AC_CHECK_HEADERS(locale.h libintl.h)
256
257       dnl Prefer gettext found in -lintl to the one in libc.
258       dnl Otherwise it can happen that we include libintl.h from
259       dnl /usr/local/lib, but fail to specify -lintl, which results in
260       dnl link or run-time failures.  (Symptom: libintl_bindtextdomain
261       dnl not found at link-time.)
262
263       AC_CHECK_LIB(intl, gettext, [
264         dnl gettext is in libintl; announce the fact manually.
265         LIBS="-lintl $LIBS"
266         AC_DEFINE([HAVE_GETTEXT], 1,
267                   [Define if you have the gettext function.])
268       ], [
269         AC_CHECK_FUNCS(gettext, [], [
270           AC_MSG_RESULT([gettext not found; disabling NLS])
271           HAVE_NLS=no
272         ])
273       ])
274
275       for lang in $ALL_LINGUAS; do
276         GMOFILES="$GMOFILES $lang.gmo"
277         POFILES="$POFILES $lang.po"
278       done
279       dnl Construct list of names of catalog files to be constructed.
280       for lang in $ALL_LINGUAS; do
281         CATALOGS="$CATALOGS ${lang}${CATOBJEXT}"
282       done
283
284       dnl Make all variables we use known to autoconf.
285       AC_SUBST(CATALOGS)
286       AC_SUBST(CATOBJEXT)
287       AC_SUBST(DATADIRNAME)
288       AC_SUBST(GMOFILES)
289       AC_SUBST(INSTOBJEXT)
290       AC_SUBST(INTLLIBS)
291       AC_SUBST(POFILES)
292     fi
293     AC_SUBST(HAVE_NLS)
294     dnl Some independently maintained files, such as po/Makefile.in,
295     dnl use `USE_NLS', so support it.
296     USE_NLS=$HAVE_NLS
297     AC_SUBST(USE_NLS)
298     if test "x$HAVE_NLS" = xyes; then
299       AC_DEFINE([HAVE_NLS], 1, [Define this if you want the NLS support.])
300     fi
301   ])
302
303 dnl Generate list of files to be processed by xgettext which will
304 dnl be included in po/Makefile.
305 dnl
306 dnl This is not strictly an Autoconf macro, because it is run from
307 dnl within `config.status' rather than from within configure.  This
308 dnl is why special rules must be applied for it.
309 AC_DEFUN(WGET_PROCESS_PO,
310   [
311    dnl I wonder what the following several lines do...
312    if test "x$srcdir" != "x."; then
313      if test "x`echo $srcdir | sed 's@/.*@@'`" = "x"; then
314        posrcprefix="$srcdir/"
315      else
316        posrcprefix="../$srcdir/"
317      fi
318    else
319      posrcprefix="../"
320    fi
321    rm -f po/POTFILES
322    dnl Use `echo' rather than AC_MSG_RESULT, because this is run from
323    dnl `config.status'.
324    echo "generating po/POTFILES from $srcdir/po/POTFILES.in"
325    sed -e "/^#/d" -e "/^\$/d" -e "s,.*, $posrcprefix& \\\\,"  \
326        -e "\$s/\(.*\) \\\\/\1/" \
327         < $srcdir/po/POTFILES.in > po/POTFILES
328    echo "creating po/Makefile"
329    sed -e "/POTFILES =/r po/POTFILES" po/Makefile.in > po/Makefile
330   ])
331
332 # Search path for a program which passes the given test.
333 # Ulrich Drepper <drepper@cygnus.com>, 1996.
334 #
335 # This file may be copied and used freely without restrictions.  It
336 # can be used in projects which are not available under the GNU Public
337 # License but which still want to provide support for the GNU gettext
338 # functionality.  Please note that the actual code is *not* freely
339 # available.
340
341 # serial 1
342
343 dnl AM_PATH_PROG_WITH_TEST(VARIABLE, PROG-TO-CHECK-FOR,
344 dnl   TEST-PERFORMED-ON-FOUND_PROGRAM [, VALUE-IF-NOT-FOUND [, PATH]])
345 AC_DEFUN(AM_PATH_PROG_WITH_TEST,
346 [# Extract the first word of "$2", so it can be a program name with args.
347 set dummy $2; ac_word=[$]2
348 AC_MSG_CHECKING([for $ac_word])
349 AC_CACHE_VAL(ac_cv_path_$1,
350 [case "[$]$1" in
351   /*)
352   ac_cv_path_$1="[$]$1" # Let the user override the test with a path.
353   ;;
354   *)
355   IFS="${IFS=   }"; ac_save_ifs="$IFS"; IFS="${IFS}:"
356   for ac_dir in ifelse([$5], , $PATH, [$5]); do
357     test -z "$ac_dir" && ac_dir=.
358     if test -f $ac_dir/$ac_word; then
359       if [$3]; then
360         ac_cv_path_$1="$ac_dir/$ac_word"
361         break
362       fi
363     fi
364   done
365   IFS="$ac_save_ifs"
366 dnl If no 4th arg is given, leave the cache variable unset,
367 dnl so AC_PATH_PROGS will keep looking.
368 ifelse([$4], , , [  test -z "[$]ac_cv_path_$1" && ac_cv_path_$1="$4"
369 ])dnl
370   ;;
371 esac])dnl
372 $1="$ac_cv_path_$1"
373 if test -n "[$]$1"; then
374   AC_MSG_RESULT([$]$1)
375 else
376   AC_MSG_RESULT(no)
377 fi
378 AC_SUBST($1)dnl
379 ])
380
381 # Include libtool code.
382
383 builtin(include, libtool.m4)dnl