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