source: trunk/essentials/net-misc/wget/m4/wget.m4

Last change on this file was 3447, checked in by bird, 18 years ago

stupid stupid stupid.

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