Release 2.33.1
[external/binutils.git] / readline / aclocal.m4
1 nl
2 dnl Bash specific tests
3 dnl
4 dnl Some derived from PDKSH 5.1.3 autoconf tests
5 dnl
6
7 AC_DEFUN(BASH_C_LONG_LONG,
8 [AC_CACHE_CHECK(for long long, ac_cv_c_long_long,
9 [if test "$GCC" = yes; then
10   ac_cv_c_long_long=yes
11 else
12 AC_TRY_RUN([
13 int
14 main()
15 {
16 long long foo = 0;
17 exit(sizeof(long long) < sizeof(long));
18 }
19 ], ac_cv_c_long_long=yes, ac_cv_c_long_long=no)
20 fi])
21 if test $ac_cv_c_long_long = yes; then
22   AC_DEFINE(HAVE_LONG_LONG, 1, [Define if the `long long' type works.])
23 fi
24 ])
25
26 dnl
27 dnl This is very similar to AC_C_LONG_DOUBLE, with the fix for IRIX
28 dnl (< changed to <=) added.
29 dnl
30 AC_DEFUN(BASH_C_LONG_DOUBLE,
31 [AC_CACHE_CHECK(for long double, ac_cv_c_long_double,
32 [if test "$GCC" = yes; then
33   ac_cv_c_long_double=yes
34 else
35 AC_TRY_RUN([
36 int
37 main()
38 {
39   /* The Stardent Vistra knows sizeof(long double), but does not
40      support it. */
41   long double foo = 0.0;
42   /* On Ultrix 4.3 cc, long double is 4 and double is 8.  */
43   /* On IRIX 5.3, the compiler converts long double to double with a warning,
44      but compiles this successfully. */
45   exit(sizeof(long double) <= sizeof(double));
46 }
47 ], ac_cv_c_long_double=yes, ac_cv_c_long_double=no)
48 fi])
49 if test $ac_cv_c_long_double = yes; then
50   AC_DEFINE(HAVE_LONG_DOUBLE, 1, [Define if the `long double' type works.])
51 fi
52 ])
53
54 dnl
55 dnl Check for <inttypes.h>.  This is separated out so that it can be
56 dnl AC_REQUIREd.
57 dnl
58 dnl BASH_HEADER_INTTYPES
59 AC_DEFUN(BASH_HEADER_INTTYPES,
60 [
61  AC_CHECK_HEADERS(inttypes.h)
62 ])
63
64 dnl
65 dnl check for typedef'd symbols in header files, but allow the caller to
66 dnl specify the include files to be checked in addition to the default
67 dnl 
68 dnl BASH_CHECK_TYPE(TYPE, HEADERS, DEFAULT[, VALUE-IF-FOUND])
69 AC_DEFUN(BASH_CHECK_TYPE,
70 [
71 AC_REQUIRE([AC_HEADER_STDC])dnl
72 AC_REQUIRE([BASH_HEADER_INTTYPES])
73 AC_MSG_CHECKING(for $1)
74 AC_CACHE_VAL(bash_cv_type_$1,
75 [AC_EGREP_CPP($1, [#include <sys/types.h>
76 #if STDC_HEADERS
77 #include <stdlib.h>
78 #include <stddef.h>
79 #endif
80 #if HAVE_INTTYPES_H
81 #include <inttypes.h>
82 #endif
83 #if HAVE_STDINT_H
84 #include <stdint.h>
85 #endif
86 $2
87 ], bash_cv_type_$1=yes, bash_cv_type_$1=no)])
88 AC_MSG_RESULT($bash_cv_type_$1)
89 ifelse($#, 4, [if test $bash_cv_type_$1 = yes; then
90         AC_DEFINE($4)
91         fi])
92 if test $bash_cv_type_$1 = no; then
93   AC_DEFINE_UNQUOTED($1, $3)
94 fi
95 ])
96
97 dnl
98 dnl BASH_CHECK_DECL(FUNC)
99 dnl
100 dnl Check for a declaration of FUNC in stdlib.h and inttypes.h like
101 dnl AC_CHECK_DECL
102 dnl
103 AC_DEFUN(BASH_CHECK_DECL,
104 [
105 AC_REQUIRE([AC_HEADER_STDC])
106 AC_REQUIRE([BASH_HEADER_INTTYPES])
107 AC_CACHE_CHECK([for declaration of $1], bash_cv_decl_$1,
108 [AC_TRY_LINK(
109 [
110 #if STDC_HEADERS
111 #  include <stdlib.h>
112 #endif
113 #if HAVE_INTTYPES_H
114 #  include <inttypes.h>
115 #endif
116 ],
117 [return !$1;],
118 bash_cv_decl_$1=yes, bash_cv_decl_$1=no)])
119 bash_tr_func=HAVE_DECL_`echo $1 | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
120 if test $bash_cv_decl_$1 = yes; then
121   AC_DEFINE_UNQUOTED($bash_tr_func, 1)
122 else
123   AC_DEFINE_UNQUOTED($bash_tr_func, 0)
124 fi
125 ])
126
127 AC_DEFUN(BASH_DECL_PRINTF,
128 [AC_MSG_CHECKING(for declaration of printf in <stdio.h>)
129 AC_CACHE_VAL(bash_cv_printf_declared,
130 [AC_TRY_RUN([
131 #include <stdio.h>
132 #ifdef __STDC__
133 typedef int (*_bashfunc)(const char *, ...);
134 #else
135 typedef int (*_bashfunc)();
136 #endif
137 main()
138 {
139 _bashfunc pf;
140 pf = (_bashfunc) printf;
141 exit(pf == 0);
142 }
143 ], bash_cv_printf_declared=yes, bash_cv_printf_declared=no,
144    [AC_MSG_WARN(cannot check printf declaration if cross compiling -- defaulting to yes)
145     bash_cv_printf_declared=yes]
146 )])
147 AC_MSG_RESULT($bash_cv_printf_declared)
148 if test $bash_cv_printf_declared = yes; then
149 AC_DEFINE(PRINTF_DECLARED)
150 fi
151 ])
152
153 AC_DEFUN(BASH_DECL_SBRK,
154 [AC_MSG_CHECKING(for declaration of sbrk in <unistd.h>)
155 AC_CACHE_VAL(bash_cv_sbrk_declared,
156 [AC_EGREP_HEADER(sbrk, unistd.h,
157  bash_cv_sbrk_declared=yes, bash_cv_sbrk_declared=no)])
158 AC_MSG_RESULT($bash_cv_sbrk_declared)
159 if test $bash_cv_sbrk_declared = yes; then
160 AC_DEFINE(SBRK_DECLARED)
161 fi
162 ])
163
164 dnl
165 dnl Check for sys_siglist[] or _sys_siglist[]
166 dnl
167 AC_DEFUN(BASH_DECL_UNDER_SYS_SIGLIST,
168 [AC_MSG_CHECKING([for _sys_siglist in signal.h or unistd.h])
169 AC_CACHE_VAL(bash_cv_decl_under_sys_siglist,
170 [AC_TRY_COMPILE([
171 #include <sys/types.h>
172 #include <signal.h>
173 #ifdef HAVE_UNISTD_H
174 #include <unistd.h>
175 #endif], [ char *msg = _sys_siglist[2]; ],
176   bash_cv_decl_under_sys_siglist=yes, bash_cv_decl_under_sys_siglist=no,
177   [AC_MSG_WARN(cannot check for _sys_siglist[] if cross compiling -- defaulting to no)])])dnl
178 AC_MSG_RESULT($bash_cv_decl_under_sys_siglist)
179 if test $bash_cv_decl_under_sys_siglist = yes; then
180 AC_DEFINE(UNDER_SYS_SIGLIST_DECLARED)
181 fi
182 ])
183
184 AC_DEFUN(BASH_UNDER_SYS_SIGLIST,
185 [AC_REQUIRE([BASH_DECL_UNDER_SYS_SIGLIST])
186 AC_MSG_CHECKING([for _sys_siglist in system C library])
187 AC_CACHE_VAL(bash_cv_under_sys_siglist,
188 [AC_TRY_RUN([
189 #include <sys/types.h>
190 #include <signal.h>
191 #ifdef HAVE_UNISTD_H
192 #include <unistd.h>
193 #endif
194 #ifndef UNDER_SYS_SIGLIST_DECLARED
195 extern char *_sys_siglist[];
196 #endif
197 main()
198 {
199 char *msg = (char *)_sys_siglist[2];
200 exit(msg == 0);
201 }],
202         bash_cv_under_sys_siglist=yes, bash_cv_under_sys_siglist=no,
203         [AC_MSG_WARN(cannot check for _sys_siglist[] if cross compiling -- defaulting to no)
204          bash_cv_under_sys_siglist=no])])
205 AC_MSG_RESULT($bash_cv_under_sys_siglist)
206 if test $bash_cv_under_sys_siglist = yes; then
207 AC_DEFINE(HAVE_UNDER_SYS_SIGLIST)
208 fi
209 ])
210
211 AC_DEFUN(BASH_SYS_SIGLIST,
212 [AC_REQUIRE([AC_DECL_SYS_SIGLIST])
213 AC_MSG_CHECKING([for sys_siglist in system C library])
214 AC_CACHE_VAL(bash_cv_sys_siglist,
215 [AC_TRY_RUN([
216 #include <sys/types.h>
217 #include <signal.h>
218 #ifdef HAVE_UNISTD_H
219 #include <unistd.h>
220 #endif
221 #if !HAVE_DECL_SYS_SIGLIST
222 extern char *sys_siglist[];
223 #endif
224 main()
225 {
226 char *msg = sys_siglist[2];
227 exit(msg == 0);
228 }],
229         bash_cv_sys_siglist=yes, bash_cv_sys_siglist=no,
230         [AC_MSG_WARN(cannot check for sys_siglist if cross compiling -- defaulting to no)
231          bash_cv_sys_siglist=no])])
232 AC_MSG_RESULT($bash_cv_sys_siglist)
233 if test $bash_cv_sys_siglist = yes; then
234 AC_DEFINE(HAVE_SYS_SIGLIST)
235 fi
236 ])
237
238 dnl Check for the various permutations of sys_siglist and make sure we
239 dnl compile in siglist.o if they're not defined
240 AC_DEFUN(BASH_CHECK_SYS_SIGLIST, [
241 AC_REQUIRE([BASH_SYS_SIGLIST])
242 AC_REQUIRE([BASH_DECL_UNDER_SYS_SIGLIST])
243 AC_REQUIRE([BASH_FUNC_STRSIGNAL])
244 if test "$bash_cv_sys_siglist" = no && test "$bash_cv_under_sys_siglist" = no && test "$bash_cv_have_strsignal" = no; then
245   SIGLIST_O=siglist.o
246 else
247   SIGLIST_O=
248 fi
249 AC_SUBST([SIGLIST_O])
250 ])
251
252 dnl Check for sys_errlist[] and sys_nerr, check for declaration
253 AC_DEFUN(BASH_SYS_ERRLIST,
254 [AC_MSG_CHECKING([for sys_errlist and sys_nerr])
255 AC_CACHE_VAL(bash_cv_sys_errlist,
256 [AC_TRY_LINK([#include <errno.h>],
257 [extern char *sys_errlist[];
258  extern int sys_nerr;
259  char *msg = sys_errlist[sys_nerr - 1];],
260     bash_cv_sys_errlist=yes, bash_cv_sys_errlist=no)])dnl
261 AC_MSG_RESULT($bash_cv_sys_errlist)
262 if test $bash_cv_sys_errlist = yes; then
263 AC_DEFINE(HAVE_SYS_ERRLIST)
264 fi
265 ])
266
267 dnl
268 dnl Check if dup2() does not clear the close on exec flag
269 dnl
270 AC_DEFUN(BASH_FUNC_DUP2_CLOEXEC_CHECK,
271 [AC_MSG_CHECKING(if dup2 fails to clear the close-on-exec flag)
272 AC_CACHE_VAL(bash_cv_dup2_broken,
273 [AC_TRY_RUN([
274 #include <sys/types.h>
275 #include <fcntl.h>
276 main()
277 {
278   int fd1, fd2, fl;
279   fd1 = open("/dev/null", 2);
280   if (fcntl(fd1, 2, 1) < 0)
281     exit(1);
282   fd2 = dup2(fd1, 1);
283   if (fd2 < 0)
284     exit(2);
285   fl = fcntl(fd2, 1, 0);
286   /* fl will be 1 if dup2 did not reset the close-on-exec flag. */
287   exit(fl != 1);
288 }
289 ], bash_cv_dup2_broken=yes, bash_cv_dup2_broken=no,
290     [AC_MSG_WARN(cannot check dup2 if cross compiling -- defaulting to no)
291      bash_cv_dup2_broken=no])
292 ])
293 AC_MSG_RESULT($bash_cv_dup2_broken)
294 if test $bash_cv_dup2_broken = yes; then
295 AC_DEFINE(DUP2_BROKEN)
296 fi
297 ])
298
299 AC_DEFUN(BASH_FUNC_STRSIGNAL,
300 [AC_MSG_CHECKING([for the existence of strsignal])
301 AC_CACHE_VAL(bash_cv_have_strsignal,
302 [AC_TRY_LINK([#include <sys/types.h>
303 #include <signal.h>],
304 [char *s = (char *)strsignal(2);],
305  bash_cv_have_strsignal=yes, bash_cv_have_strsignal=no)])
306 AC_MSG_RESULT($bash_cv_have_strsignal)
307 if test $bash_cv_have_strsignal = yes; then
308 AC_DEFINE(HAVE_STRSIGNAL)
309 fi
310 ])
311
312 dnl Check to see if opendir will open non-directories (not a nice thing)
313 AC_DEFUN(BASH_FUNC_OPENDIR_CHECK,
314 [AC_REQUIRE([AC_HEADER_DIRENT])dnl
315 AC_MSG_CHECKING(if opendir() opens non-directories)
316 AC_CACHE_VAL(bash_cv_opendir_not_robust,
317 [AC_TRY_RUN([
318 #include <stdio.h>
319 #include <sys/types.h>
320 #include <fcntl.h>
321 #ifdef HAVE_UNISTD_H
322 # include <unistd.h>
323 #endif /* HAVE_UNISTD_H */
324 #if defined(HAVE_DIRENT_H)
325 # include <dirent.h>
326 #else
327 # define dirent direct
328 # ifdef HAVE_SYS_NDIR_H
329 #  include <sys/ndir.h>
330 # endif /* SYSNDIR */
331 # ifdef HAVE_SYS_DIR_H
332 #  include <sys/dir.h>
333 # endif /* SYSDIR */
334 # ifdef HAVE_NDIR_H
335 #  include <ndir.h>
336 # endif
337 #endif /* HAVE_DIRENT_H */
338 main()
339 {
340 DIR *dir;
341 int fd, err;
342 err = mkdir("bash-aclocal", 0700);
343 if (err < 0) {
344   perror("mkdir");
345   exit(1);
346 }
347 unlink("bash-aclocal/not_a_directory");
348 fd = open("bash-aclocal/not_a_directory", O_WRONLY|O_CREAT|O_EXCL, 0666);
349 write(fd, "\n", 1);
350 close(fd);
351 dir = opendir("bash-aclocal/not_a_directory");
352 unlink("bash-aclocal/not_a_directory");
353 rmdir("bash-aclocal");
354 exit (dir == 0);
355 }], bash_cv_opendir_not_robust=yes,bash_cv_opendir_not_robust=no,
356     [AC_MSG_WARN(cannot check opendir if cross compiling -- defaulting to no)
357      bash_cv_opendir_not_robust=no]
358 )])
359 AC_MSG_RESULT($bash_cv_opendir_not_robust)
360 if test $bash_cv_opendir_not_robust = yes; then
361 AC_DEFINE(OPENDIR_NOT_ROBUST)
362 fi
363 ])
364
365 dnl
366 AC_DEFUN(BASH_TYPE_SIGHANDLER,
367 [AC_MSG_CHECKING([whether signal handlers are of type void])
368 AC_CACHE_VAL(bash_cv_void_sighandler,
369 [AC_TRY_COMPILE([#include <sys/types.h>
370 #include <signal.h>
371 #ifdef signal
372 #undef signal
373 #endif
374 #ifdef __cplusplus
375 extern "C"
376 #endif
377 void (*signal ()) ();],
378 [int i;], bash_cv_void_sighandler=yes, bash_cv_void_sighandler=no)])dnl
379 AC_MSG_RESULT($bash_cv_void_sighandler)
380 if test $bash_cv_void_sighandler = yes; then
381 AC_DEFINE(VOID_SIGHANDLER)
382 fi
383 ])
384
385 dnl
386 dnl A signed 16-bit integer quantity
387 dnl
388 AC_DEFUN(BASH_TYPE_BITS16_T,
389 [
390 if test "$ac_cv_sizeof_short" = 2; then
391   AC_CHECK_TYPE(bits16_t, short)
392 elif test "$ac_cv_sizeof_char" = 2; then
393   AC_CHECK_TYPE(bits16_t, char)
394 else
395   AC_CHECK_TYPE(bits16_t, short)
396 fi
397 ])
398
399 dnl
400 dnl An unsigned 16-bit integer quantity
401 dnl
402 AC_DEFUN(BASH_TYPE_U_BITS16_T,
403 [
404 if test "$ac_cv_sizeof_short" = 2; then
405   AC_CHECK_TYPE(u_bits16_t, unsigned short)
406 elif test "$ac_cv_sizeof_char" = 2; then
407   AC_CHECK_TYPE(u_bits16_t, unsigned char)
408 else
409   AC_CHECK_TYPE(u_bits16_t, unsigned short)
410 fi
411 ])
412
413 dnl
414 dnl A signed 32-bit integer quantity
415 dnl
416 AC_DEFUN(BASH_TYPE_BITS32_T,
417 [
418 if test "$ac_cv_sizeof_int" = 4; then
419   AC_CHECK_TYPE(bits32_t, int)
420 elif test "$ac_cv_sizeof_long" = 4; then
421   AC_CHECK_TYPE(bits32_t, long)
422 else
423   AC_CHECK_TYPE(bits32_t, int)
424 fi
425 ])
426
427 dnl
428 dnl An unsigned 32-bit integer quantity
429 dnl
430 AC_DEFUN(BASH_TYPE_U_BITS32_T,
431 [
432 if test "$ac_cv_sizeof_int" = 4; then
433   AC_CHECK_TYPE(u_bits32_t, unsigned int)
434 elif test "$ac_cv_sizeof_long" = 4; then
435   AC_CHECK_TYPE(u_bits32_t, unsigned long)
436 else
437   AC_CHECK_TYPE(u_bits32_t, unsigned int)
438 fi
439 ])
440
441 AC_DEFUN(BASH_TYPE_PTRDIFF_T,
442 [
443 if test "$ac_cv_sizeof_int" = "$ac_cv_sizeof_char_p"; then
444   AC_CHECK_TYPE(ptrdiff_t, int)
445 elif test "$ac_cv_sizeof_long" = "$ac_cv_sizeof_char_p"; then
446   AC_CHECK_TYPE(ptrdiff_t, long)
447 elif test "$ac_cv_type_long_long" = yes && test "$ac_cv_sizeof_long_long" = "$ac_cv_sizeof_char_p"; then
448   AC_CHECK_TYPE(ptrdiff_t, [long long])
449 else
450   AC_CHECK_TYPE(ptrdiff_t, int)
451 fi
452 ])
453
454 dnl
455 dnl A signed 64-bit quantity
456 dnl
457 AC_DEFUN(BASH_TYPE_BITS64_T,
458 [
459 if test "$ac_cv_sizeof_char_p" = 8; then
460   AC_CHECK_TYPE(bits64_t, char *)
461 elif test "$ac_cv_sizeof_double" = 8; then
462   AC_CHECK_TYPE(bits64_t, double)
463 elif test -n "$ac_cv_type_long_long" && test "$ac_cv_sizeof_long_long" = 8; then
464   AC_CHECK_TYPE(bits64_t, [long long])
465 elif test "$ac_cv_sizeof_long" = 8; then
466   AC_CHECK_TYPE(bits64_t, long)
467 else
468   AC_CHECK_TYPE(bits64_t, double)
469 fi
470 ])
471
472 AC_DEFUN(BASH_TYPE_LONG_LONG,
473 [
474 AC_CACHE_CHECK([for long long], bash_cv_type_long_long,
475 [AC_TRY_LINK([
476 long long ll = 1; int i = 63;],
477 [
478 long long llm = (long long) -1;
479 return ll << i | ll >> i | llm / ll | llm % ll;
480 ], bash_cv_type_long_long='long long', bash_cv_type_long_long='long')])
481 if test "$bash_cv_type_long_long" = 'long long'; then
482   AC_DEFINE(HAVE_LONG_LONG, 1)
483 fi
484 ])
485
486 AC_DEFUN(BASH_TYPE_UNSIGNED_LONG_LONG,
487 [
488 AC_CACHE_CHECK([for unsigned long long], bash_cv_type_unsigned_long_long,
489 [AC_TRY_LINK([
490 unsigned long long ull = 1; int i = 63;],
491 [
492 unsigned long long ullmax = (unsigned long long) -1;
493 return ull << i | ull >> i | ullmax / ull | ullmax % ull;
494 ], bash_cv_type_unsigned_long_long='unsigned long long',
495    bash_cv_type_unsigned_long_long='unsigned long')])
496 if test "$bash_cv_type_unsigned_long_long" = 'unsigned long long'; then
497   AC_DEFINE(HAVE_UNSIGNED_LONG_LONG, 1)
498 fi
499 ])
500
501 dnl
502 dnl Type of struct rlimit fields: some systems (OSF/1, NetBSD, RISC/os 5.0)
503 dnl have a rlim_t, others (4.4BSD based systems) use quad_t, others use
504 dnl long and still others use int (HP-UX 9.01, SunOS 4.1.3).  To simplify
505 dnl matters, this just checks for rlim_t, quad_t, or long.
506 dnl
507 AC_DEFUN(BASH_TYPE_RLIMIT,
508 [AC_MSG_CHECKING(for size and type of struct rlimit fields)
509 AC_CACHE_VAL(bash_cv_type_rlimit,
510 [AC_TRY_COMPILE([#include <sys/types.h>
511 #include <sys/resource.h>],
512 [rlim_t xxx;], bash_cv_type_rlimit=rlim_t,[
513 AC_TRY_RUN([
514 #include <sys/types.h>
515 #include <sys/time.h>
516 #include <sys/resource.h>
517 main()
518 {
519 #ifdef HAVE_QUAD_T
520   struct rlimit rl;
521   if (sizeof(rl.rlim_cur) == sizeof(quad_t))
522     exit(0);
523 #endif
524   exit(1);
525 }], bash_cv_type_rlimit=quad_t, bash_cv_type_rlimit=long,
526         [AC_MSG_WARN(cannot check quad_t if cross compiling -- defaulting to long)
527          bash_cv_type_rlimit=long])])
528 ])
529 AC_MSG_RESULT($bash_cv_type_rlimit)
530 if test $bash_cv_type_rlimit = quad_t; then
531 AC_DEFINE(RLIMTYPE, quad_t)
532 elif test $bash_cv_type_rlimit = rlim_t; then
533 AC_DEFINE(RLIMTYPE, rlim_t)
534 fi
535 ])
536
537 AC_DEFUN(BASH_TYPE_SIG_ATOMIC_T,
538 [AC_CACHE_CHECK([for sig_atomic_t in signal.h], ac_cv_have_sig_atomic_t,
539 [AC_TRY_LINK([
540 #include <signal.h>
541 ],[ sig_atomic_t x; ],
542 ac_cv_have_sig_atomic_t=yes, ac_cv_have_sig_atomic_t=no)])
543 if test "$ac_cv_have_sig_atomic_t" = "no"
544 then
545     AC_CHECK_TYPE(sig_atomic_t,int)
546 fi
547 ])
548
549 AC_DEFUN(BASH_FUNC_LSTAT,
550 [dnl Cannot use AC_CHECK_FUNCS(lstat) because Linux defines lstat() as an
551 dnl inline function in <sys/stat.h>.
552 AC_CACHE_CHECK([for lstat], bash_cv_func_lstat,
553 [AC_TRY_LINK([
554 #include <sys/types.h>
555 #include <sys/stat.h>
556 ],[ lstat(".",(struct stat *)0); ],
557 bash_cv_func_lstat=yes, bash_cv_func_lstat=no)])
558 if test $bash_cv_func_lstat = yes; then
559   AC_DEFINE(HAVE_LSTAT)
560 fi
561 ])
562
563 AC_DEFUN(BASH_FUNC_INET_ATON,
564 [
565 AC_CACHE_CHECK([for inet_aton], bash_cv_func_inet_aton,
566 [AC_TRY_LINK([
567 #include <sys/types.h>
568 #include <netinet/in.h>
569 #include <arpa/inet.h>
570 struct in_addr ap;], [ inet_aton("127.0.0.1", &ap); ],
571 bash_cv_func_inet_aton=yes, bash_cv_func_inet_aton=no)])
572 if test $bash_cv_func_inet_aton = yes; then
573   AC_DEFINE(HAVE_INET_ATON)
574 else
575   AC_LIBOBJ(inet_aton)
576 fi
577 ])
578
579 AC_DEFUN(BASH_FUNC_GETENV,
580 [AC_MSG_CHECKING(to see if getenv can be redefined)
581 AC_CACHE_VAL(bash_cv_getenv_redef,
582 [AC_TRY_RUN([
583 #ifdef HAVE_UNISTD_H
584 #  include <unistd.h>
585 #endif
586 #ifndef __STDC__
587 #  ifndef const
588 #    define const
589 #  endif
590 #endif
591 char *
592 getenv (name)
593 #if defined (__linux__) || defined (__bsdi__) || defined (convex)
594      const char *name;
595 #else
596      char const *name;
597 #endif /* !__linux__ && !__bsdi__ && !convex */
598 {
599 return "42";
600 }
601 main()
602 {
603 char *s;
604 /* The next allows this program to run, but does not allow bash to link
605    when it redefines getenv.  I'm not really interested in figuring out
606    why not. */
607 #if defined (NeXT)
608 exit(1);
609 #endif
610 s = getenv("ABCDE");
611 exit(s == 0);   /* force optimizer to leave getenv in */
612 }
613 ], bash_cv_getenv_redef=yes, bash_cv_getenv_redef=no,
614    [AC_MSG_WARN(cannot check getenv redefinition if cross compiling -- defaulting to yes)
615     bash_cv_getenv_redef=yes]
616 )])
617 AC_MSG_RESULT($bash_cv_getenv_redef)
618 if test $bash_cv_getenv_redef = yes; then
619 AC_DEFINE(CAN_REDEFINE_GETENV)
620 fi
621 ])
622
623 # We should check for putenv before calling this
624 AC_DEFUN(BASH_FUNC_STD_PUTENV,
625 [
626 AC_REQUIRE([AC_HEADER_STDC])
627 AC_REQUIRE([AC_C_PROTOTYPES])
628 AC_CACHE_CHECK([for standard-conformant putenv declaration], bash_cv_std_putenv,
629 [AC_TRY_LINK([
630 #if STDC_HEADERS
631 #include <stdlib.h>
632 #include <stddef.h>
633 #endif
634 #ifndef __STDC__
635 #  ifndef const
636 #    define const
637 #  endif
638 #endif
639 #ifdef PROTOTYPES
640 extern int putenv (char *);
641 #else
642 extern int putenv ();
643 #endif
644 ],
645 [return (putenv == 0);],
646 bash_cv_std_putenv=yes, bash_cv_std_putenv=no
647 )])
648 if test $bash_cv_std_putenv = yes; then
649 AC_DEFINE(HAVE_STD_PUTENV)
650 fi
651 ])
652
653 # We should check for unsetenv before calling this
654 AC_DEFUN(BASH_FUNC_STD_UNSETENV,
655 [
656 AC_REQUIRE([AC_HEADER_STDC])
657 AC_REQUIRE([AC_C_PROTOTYPES])
658 AC_CACHE_CHECK([for standard-conformant unsetenv declaration], bash_cv_std_unsetenv,
659 [AC_TRY_LINK([
660 #if STDC_HEADERS
661 #include <stdlib.h>
662 #include <stddef.h>
663 #endif
664 #ifndef __STDC__
665 #  ifndef const
666 #    define const
667 #  endif
668 #endif
669 #ifdef PROTOTYPES
670 extern int unsetenv (const char *);
671 #else
672 extern int unsetenv ();
673 #endif
674 ],
675 [return (unsetenv == 0);],
676 bash_cv_std_unsetenv=yes, bash_cv_std_unsetenv=no
677 )])
678 if test $bash_cv_std_unsetenv = yes; then
679 AC_DEFINE(HAVE_STD_UNSETENV)
680 fi
681 ])
682
683 AC_DEFUN(BASH_FUNC_ULIMIT_MAXFDS,
684 [AC_MSG_CHECKING(whether ulimit can substitute for getdtablesize)
685 AC_CACHE_VAL(bash_cv_ulimit_maxfds,
686 [AC_TRY_RUN([
687 main()
688 {
689 long maxfds = ulimit(4, 0L);
690 exit (maxfds == -1L);
691 }
692 ], bash_cv_ulimit_maxfds=yes, bash_cv_ulimit_maxfds=no,
693    [AC_MSG_WARN(cannot check ulimit if cross compiling -- defaulting to no)
694     bash_cv_ulimit_maxfds=no]
695 )])
696 AC_MSG_RESULT($bash_cv_ulimit_maxfds)
697 if test $bash_cv_ulimit_maxfds = yes; then
698 AC_DEFINE(ULIMIT_MAXFDS)
699 fi
700 ])
701
702 AC_DEFUN(BASH_FUNC_GETCWD,
703 [AC_MSG_CHECKING([if getcwd() will dynamically allocate memory with 0 size])
704 AC_CACHE_VAL(bash_cv_getcwd_malloc,
705 [AC_TRY_RUN([
706 #include <stdio.h>
707 #ifdef HAVE_UNISTD_H
708 #include <unistd.h>
709 #endif
710
711 main()
712 {
713         char    *xpwd;
714         xpwd = getcwd(0, 0);
715         exit (xpwd == 0);
716 }
717 ], bash_cv_getcwd_malloc=yes, bash_cv_getcwd_malloc=no,
718    [AC_MSG_WARN(cannot check whether getcwd allocates memory when cross-compiling -- defaulting to no)
719     bash_cv_getcwd_malloc=no]
720 )])
721 AC_MSG_RESULT($bash_cv_getcwd_malloc)
722 if test $bash_cv_getcwd_malloc = no; then
723 AC_DEFINE(GETCWD_BROKEN)
724 AC_LIBOBJ(getcwd)
725 fi
726 ])
727
728 dnl
729 dnl This needs BASH_CHECK_SOCKLIB, but since that's not called on every
730 dnl system, we can't use AC_PREREQ
731 dnl
732 AC_DEFUN(BASH_FUNC_GETHOSTBYNAME,
733 [if test "X$bash_cv_have_gethostbyname" = "X"; then
734 _bash_needmsg=yes
735 else
736 AC_MSG_CHECKING(for gethostbyname in socket library)
737 _bash_needmsg=
738 fi
739 AC_CACHE_VAL(bash_cv_have_gethostbyname,
740 [AC_TRY_LINK([#include <netdb.h>],
741 [ struct hostent *hp;
742   hp = gethostbyname("localhost");
743 ], bash_cv_have_gethostbyname=yes, bash_cv_have_gethostbyname=no)]
744 )
745 if test "X$_bash_needmsg" = Xyes; then
746     AC_MSG_CHECKING(for gethostbyname in socket library)
747 fi
748 AC_MSG_RESULT($bash_cv_have_gethostbyname)
749 if test "$bash_cv_have_gethostbyname" = yes; then
750 AC_DEFINE(HAVE_GETHOSTBYNAME)
751 fi
752 ])
753
754 AC_DEFUN(BASH_FUNC_FNMATCH_EXTMATCH,
755 [AC_MSG_CHECKING(if fnmatch does extended pattern matching with FNM_EXTMATCH)
756 AC_CACHE_VAL(bash_cv_fnm_extmatch,
757 [AC_TRY_RUN([
758 #include <fnmatch.h>
759
760 main()
761 {
762 #ifdef FNM_EXTMATCH
763   exit (0);
764 #else
765   exit (1);
766 #endif
767 }
768 ], bash_cv_fnm_extmatch=yes, bash_cv_fnm_extmatch=no,
769     [AC_MSG_WARN(cannot check FNM_EXTMATCH if cross compiling -- defaulting to no)
770      bash_cv_fnm_extmatch=no])
771 ])
772 AC_MSG_RESULT($bash_cv_fnm_extmatch)
773 if test $bash_cv_fnm_extmatch = yes; then
774 AC_DEFINE(HAVE_LIBC_FNM_EXTMATCH)
775 fi
776 ])
777
778 AC_DEFUN(BASH_FUNC_POSIX_SETJMP,
779 [AC_REQUIRE([BASH_SYS_SIGNAL_VINTAGE])
780 AC_MSG_CHECKING(for presence of POSIX-style sigsetjmp/siglongjmp)
781 AC_CACHE_VAL(bash_cv_func_sigsetjmp,
782 [AC_TRY_RUN([
783 #ifdef HAVE_UNISTD_H
784 #include <unistd.h>
785 #endif
786 #include <sys/types.h>
787 #include <signal.h>
788 #include <setjmp.h>
789
790 main()
791 {
792 #if !defined (_POSIX_VERSION) || !defined (HAVE_POSIX_SIGNALS)
793 exit (1);
794 #else
795
796 int code;
797 sigset_t set, oset;
798 sigjmp_buf xx;
799
800 /* get the mask */
801 sigemptyset(&set);
802 sigemptyset(&oset);
803 sigprocmask(SIG_BLOCK, (sigset_t *)NULL, &set);
804 sigprocmask(SIG_BLOCK, (sigset_t *)NULL, &oset);
805
806 /* save it */
807 code = sigsetjmp(xx, 1);
808 if (code)
809   exit(0);      /* could get sigmask and compare to oset here. */
810
811 /* change it */
812 sigaddset(&set, SIGINT);
813 sigprocmask(SIG_BLOCK, &set, (sigset_t *)NULL);
814
815 /* and siglongjmp */
816 siglongjmp(xx, 10);
817 exit(1);
818 #endif
819 }], bash_cv_func_sigsetjmp=present, bash_cv_func_sigsetjmp=missing,
820     [AC_MSG_WARN(cannot check for sigsetjmp/siglongjmp if cross-compiling -- defaulting to missing)
821      bash_cv_func_sigsetjmp=missing]
822 )])
823 AC_MSG_RESULT($bash_cv_func_sigsetjmp)
824 if test $bash_cv_func_sigsetjmp = present; then
825 AC_DEFINE(HAVE_POSIX_SIGSETJMP)
826 fi
827 ])
828
829 AC_DEFUN(BASH_FUNC_STRCOLL,
830 [
831 AC_MSG_CHECKING(whether or not strcoll and strcmp differ)
832 AC_CACHE_VAL(bash_cv_func_strcoll_broken,
833 [AC_TRY_RUN([
834 #include <stdio.h>
835 #if defined (HAVE_LOCALE_H)
836 #include <locale.h>
837 #endif
838
839 main(c, v)
840 int     c;
841 char    *v[];
842 {
843         int     r1, r2;
844         char    *deflocale, *defcoll;
845
846 #ifdef HAVE_SETLOCALE
847         deflocale = setlocale(LC_ALL, "");
848         defcoll = setlocale(LC_COLLATE, "");
849 #endif
850
851 #ifdef HAVE_STRCOLL
852         /* These two values are taken from tests/glob-test. */
853         r1 = strcoll("abd", "aXd");
854 #else
855         r1 = 0;
856 #endif
857         r2 = strcmp("abd", "aXd");
858
859         /* These two should both be greater than 0.  It is permissible for
860            a system to return different values, as long as the sign is the
861            same. */
862
863         /* Exit with 1 (failure) if these two values are both > 0, since
864            this tests whether strcoll(3) is broken with respect to strcmp(3)
865            in the default locale. */
866         exit (r1 > 0 && r2 > 0);
867 }
868 ], bash_cv_func_strcoll_broken=yes, bash_cv_func_strcoll_broken=no,
869    [AC_MSG_WARN(cannot check strcoll if cross compiling -- defaulting to no)
870     bash_cv_func_strcoll_broken=no]
871 )])
872 AC_MSG_RESULT($bash_cv_func_strcoll_broken)
873 if test $bash_cv_func_strcoll_broken = yes; then
874 AC_DEFINE(STRCOLL_BROKEN)
875 fi
876 ])
877
878 AC_DEFUN(BASH_FUNC_PRINTF_A_FORMAT,
879 [AC_MSG_CHECKING([for printf floating point output in hex notation])
880 AC_CACHE_VAL(bash_cv_printf_a_format,
881 [AC_TRY_RUN([
882 #include <stdio.h>
883 #include <string.h>
884
885 int
886 main()
887 {
888         double y = 0.0;
889         char abuf[1024];
890
891         sprintf(abuf, "%A", y);
892         exit(strchr(abuf, 'P') == (char *)0);
893 }
894 ], bash_cv_printf_a_format=yes, bash_cv_printf_a_format=no,
895    [AC_MSG_WARN(cannot check printf if cross compiling -- defaulting to no)
896     bash_cv_printf_a_format=no]
897 )])
898 AC_MSG_RESULT($bash_cv_printf_a_format)
899 if test $bash_cv_printf_a_format = yes; then
900 AC_DEFINE(HAVE_PRINTF_A_FORMAT)
901 fi
902 ])
903
904 AC_DEFUN(BASH_STRUCT_TERMIOS_LDISC,
905 [
906 AC_CHECK_MEMBER(struct termios.c_line, AC_DEFINE(TERMIOS_LDISC), ,[
907 #include <sys/types.h>
908 #include <termios.h>
909 ])
910 ])
911
912 AC_DEFUN(BASH_STRUCT_TERMIO_LDISC,
913 [
914 AC_CHECK_MEMBER(struct termio.c_line, AC_DEFINE(TERMIO_LDISC), ,[
915 #include <sys/types.h>
916 #include <termio.h>
917 ])
918 ])
919
920 dnl
921 dnl Like AC_STRUCT_ST_BLOCKS, but doesn't muck with LIBOBJS
922 dnl
923 dnl sets bash_cv_struct_stat_st_blocks
924 dnl
925 dnl unused for now; we'll see how AC_CHECK_MEMBERS works
926 dnl
927 AC_DEFUN(BASH_STRUCT_ST_BLOCKS,
928 [
929 AC_MSG_CHECKING([for struct stat.st_blocks])
930 AC_CACHE_VAL(bash_cv_struct_stat_st_blocks,
931 [AC_TRY_COMPILE(
932 [
933 #include <sys/types.h>
934 #include <sys/stat.h>
935 ],
936 [
937 main()
938 {
939 static struct stat a;
940 if (a.st_blocks) return 0;
941 return 0;
942 }
943 ], bash_cv_struct_stat_st_blocks=yes, bash_cv_struct_stat_st_blocks=no)
944 ])
945 AC_MSG_RESULT($bash_cv_struct_stat_st_blocks)
946 if test "$bash_cv_struct_stat_st_blocks" = "yes"; then
947 AC_DEFINE(HAVE_STRUCT_STAT_ST_BLOCKS)
948 fi
949 ])
950
951 AC_DEFUN([BASH_CHECK_LIB_TERMCAP],
952 [
953 if test "X$bash_cv_termcap_lib" = "X"; then
954 _bash_needmsg=yes
955 else
956 AC_MSG_CHECKING(which library has the termcap functions)
957 _bash_needmsg=
958 fi
959 AC_CACHE_VAL(bash_cv_termcap_lib,
960 [AC_CHECK_FUNC(tgetent, bash_cv_termcap_lib=libc,
961   [AC_CHECK_LIB(termcap, tgetent, bash_cv_termcap_lib=libtermcap,
962     [AC_CHECK_LIB(tinfo, tgetent, bash_cv_termcap_lib=libtinfo,
963         [AC_CHECK_LIB(curses, tgetent, bash_cv_termcap_lib=libcurses,
964             [AC_CHECK_LIB(ncurses, tgetent, bash_cv_termcap_lib=libncurses,
965                 [AC_CHECK_LIB(ncursesw, tgetent, bash_cv_termcap_lib=libncursesw,
966                     bash_cv_termcap_lib=gnutermcap)])])])])])])
967 if test "X$_bash_needmsg" = "Xyes"; then
968 AC_MSG_CHECKING(which library has the termcap functions)
969 fi
970 AC_MSG_RESULT(using $bash_cv_termcap_lib)
971 if test $bash_cv_termcap_lib = gnutermcap && test -z "$prefer_curses"; then
972 LDFLAGS="$LDFLAGS -L./lib/termcap"
973 TERMCAP_LIB="./lib/termcap/libtermcap.a"
974 TERMCAP_DEP="./lib/termcap/libtermcap.a"
975 elif test $bash_cv_termcap_lib = libtermcap && test -z "$prefer_curses"; then
976 TERMCAP_LIB=-ltermcap
977 TERMCAP_DEP=
978 elif test $bash_cv_termcap_lib = libtinfo; then
979 TERMCAP_LIB=-ltinfo
980 TERMCAP_DEP=
981 elif test $bash_cv_termcap_lib = libncurses; then
982 TERMCAP_LIB=-lncurses
983 TERMCAP_DEP=
984 elif test $bash_cv_termcap_lib = libc; then
985 TERMCAP_LIB=
986 TERMCAP_DEP=
987 else
988 TERMCAP_LIB=-lcurses
989 TERMCAP_DEP=
990 fi
991 ])
992
993 dnl
994 dnl Check for the presence of getpeername in libsocket.
995 dnl If libsocket is present, check for libnsl and add it to LIBS if
996 dnl it's there, since most systems with libsocket require linking
997 dnl with libnsl as well.  This should only be called if getpeername
998 dnl was not found in libc.
999 dnl
1000 dnl NOTE: IF WE FIND GETPEERNAME, WE ASSUME THAT WE HAVE BIND/CONNECT
1001 dnl       AS WELL
1002 dnl
1003 AC_DEFUN(BASH_CHECK_LIB_SOCKET,
1004 [
1005 if test "X$bash_cv_have_socklib" = "X"; then
1006 _bash_needmsg=
1007 else
1008 AC_MSG_CHECKING(for socket library)
1009 _bash_needmsg=yes
1010 fi
1011 AC_CACHE_VAL(bash_cv_have_socklib,
1012 [AC_CHECK_LIB(socket, getpeername,
1013         bash_cv_have_socklib=yes, bash_cv_have_socklib=no, -lnsl)])
1014 if test "X$_bash_needmsg" = Xyes; then
1015   AC_MSG_RESULT($bash_cv_have_socklib)
1016   _bash_needmsg=
1017 fi
1018 if test $bash_cv_have_socklib = yes; then
1019   # check for libnsl, add it to LIBS if present
1020   if test "X$bash_cv_have_libnsl" = "X"; then
1021     _bash_needmsg=
1022   else
1023     AC_MSG_CHECKING(for libnsl)
1024     _bash_needmsg=yes
1025   fi
1026   AC_CACHE_VAL(bash_cv_have_libnsl,
1027            [AC_CHECK_LIB(nsl, t_open,
1028                  bash_cv_have_libnsl=yes, bash_cv_have_libnsl=no)])
1029   if test "X$_bash_needmsg" = Xyes; then
1030     AC_MSG_RESULT($bash_cv_have_libnsl)
1031     _bash_needmsg=
1032   fi
1033   if test $bash_cv_have_libnsl = yes; then
1034     LIBS="-lsocket -lnsl $LIBS"
1035   else
1036     LIBS="-lsocket $LIBS"
1037   fi
1038   AC_DEFINE(HAVE_LIBSOCKET)
1039   AC_DEFINE(HAVE_GETPEERNAME)
1040 fi
1041 ])
1042
1043 AC_DEFUN(BASH_STRUCT_DIRENT_D_INO,
1044 [AC_REQUIRE([AC_HEADER_DIRENT])
1045 AC_MSG_CHECKING(for struct dirent.d_ino)
1046 AC_CACHE_VAL(bash_cv_dirent_has_dino,
1047 [AC_TRY_COMPILE([
1048 #include <stdio.h>
1049 #include <sys/types.h>
1050 #ifdef HAVE_UNISTD_H
1051 # include <unistd.h>
1052 #endif /* HAVE_UNISTD_H */
1053 #if defined(HAVE_DIRENT_H)
1054 # include <dirent.h>
1055 #else
1056 # define dirent direct
1057 # ifdef HAVE_SYS_NDIR_H
1058 #  include <sys/ndir.h>
1059 # endif /* SYSNDIR */
1060 # ifdef HAVE_SYS_DIR_H
1061 #  include <sys/dir.h>
1062 # endif /* SYSDIR */
1063 # ifdef HAVE_NDIR_H
1064 #  include <ndir.h>
1065 # endif
1066 #endif /* HAVE_DIRENT_H */
1067 ],[
1068 struct dirent d; int z; z = d.d_ino;
1069 ], bash_cv_dirent_has_dino=yes, bash_cv_dirent_has_dino=no)])
1070 AC_MSG_RESULT($bash_cv_dirent_has_dino)
1071 if test $bash_cv_dirent_has_dino = yes; then
1072 AC_DEFINE(HAVE_STRUCT_DIRENT_D_INO)
1073 fi
1074 ])
1075
1076 AC_DEFUN(BASH_STRUCT_DIRENT_D_FILENO,
1077 [AC_REQUIRE([AC_HEADER_DIRENT])
1078 AC_MSG_CHECKING(for struct dirent.d_fileno)
1079 AC_CACHE_VAL(bash_cv_dirent_has_d_fileno,
1080 [AC_TRY_COMPILE([
1081 #include <stdio.h>
1082 #include <sys/types.h>
1083 #ifdef HAVE_UNISTD_H
1084 # include <unistd.h>
1085 #endif /* HAVE_UNISTD_H */
1086 #if defined(HAVE_DIRENT_H)
1087 # include <dirent.h>
1088 #else
1089 # define dirent direct
1090 # ifdef HAVE_SYS_NDIR_H
1091 #  include <sys/ndir.h>
1092 # endif /* SYSNDIR */
1093 # ifdef HAVE_SYS_DIR_H
1094 #  include <sys/dir.h>
1095 # endif /* SYSDIR */
1096 # ifdef HAVE_NDIR_H
1097 #  include <ndir.h>
1098 # endif
1099 #endif /* HAVE_DIRENT_H */
1100 ],[
1101 struct dirent d; int z; z = d.d_fileno;
1102 ], bash_cv_dirent_has_d_fileno=yes, bash_cv_dirent_has_d_fileno=no)])
1103 AC_MSG_RESULT($bash_cv_dirent_has_d_fileno)
1104 if test $bash_cv_dirent_has_d_fileno = yes; then
1105 AC_DEFINE(HAVE_STRUCT_DIRENT_D_FILENO)
1106 fi
1107 ])
1108
1109 AC_DEFUN(BASH_STRUCT_DIRENT_D_NAMLEN,
1110 [AC_REQUIRE([AC_HEADER_DIRENT])
1111 AC_MSG_CHECKING(for struct dirent.d_namlen)
1112 AC_CACHE_VAL(bash_cv_dirent_has_d_namlen,
1113 [AC_TRY_COMPILE([
1114 #include <stdio.h>
1115 #include <sys/types.h>
1116 #ifdef HAVE_UNISTD_H
1117 # include <unistd.h>
1118 #endif /* HAVE_UNISTD_H */
1119 #if defined(HAVE_DIRENT_H)
1120 # include <dirent.h>
1121 #else
1122 # define dirent direct
1123 # ifdef HAVE_SYS_NDIR_H
1124 #  include <sys/ndir.h>
1125 # endif /* SYSNDIR */
1126 # ifdef HAVE_SYS_DIR_H
1127 #  include <sys/dir.h>
1128 # endif /* SYSDIR */
1129 # ifdef HAVE_NDIR_H
1130 #  include <ndir.h>
1131 # endif
1132 #endif /* HAVE_DIRENT_H */
1133 ],[
1134 struct dirent d; int z; z = d.d_namlen;
1135 ], bash_cv_dirent_has_d_namlen=yes, bash_cv_dirent_has_d_namlen=no)])
1136 AC_MSG_RESULT($bash_cv_dirent_has_d_namlen)
1137 if test $bash_cv_dirent_has_d_namlen = yes; then
1138 AC_DEFINE(HAVE_STRUCT_DIRENT_D_NAMLEN)
1139 fi
1140 ])
1141
1142 AC_DEFUN(BASH_STRUCT_TIMEVAL,
1143 [AC_MSG_CHECKING(for struct timeval in sys/time.h and time.h)
1144 AC_CACHE_VAL(bash_cv_struct_timeval,
1145 [
1146 AC_EGREP_HEADER(struct timeval, sys/time.h,
1147                 bash_cv_struct_timeval=yes,
1148                 AC_EGREP_HEADER(struct timeval, time.h,
1149                         bash_cv_struct_timeval=yes,
1150                         bash_cv_struct_timeval=no))
1151 ])
1152 AC_MSG_RESULT($bash_cv_struct_timeval)
1153 if test $bash_cv_struct_timeval = yes; then
1154   AC_DEFINE(HAVE_TIMEVAL)
1155 fi
1156 ])
1157
1158 AC_DEFUN(BASH_STRUCT_TIMEZONE,
1159 [AC_MSG_CHECKING(for struct timezone in sys/time.h and time.h)
1160 AC_CACHE_VAL(bash_cv_struct_timezone,
1161 [
1162 AC_EGREP_HEADER(struct timezone, sys/time.h,
1163                 bash_cv_struct_timezone=yes,
1164                 AC_EGREP_HEADER(struct timezone, time.h,
1165                         bash_cv_struct_timezone=yes,
1166                         bash_cv_struct_timezone=no))
1167 ])
1168 AC_MSG_RESULT($bash_cv_struct_timezone)
1169 if test $bash_cv_struct_timezone = yes; then
1170   AC_DEFINE(HAVE_STRUCT_TIMEZONE)
1171 fi
1172 ])
1173
1174 AC_DEFUN(BASH_STRUCT_WINSIZE,
1175 [AC_MSG_CHECKING(for struct winsize in sys/ioctl.h and termios.h)
1176 AC_CACHE_VAL(bash_cv_struct_winsize_header,
1177 [AC_TRY_COMPILE([#include <sys/types.h>
1178 #include <sys/ioctl.h>], [struct winsize x;],
1179   bash_cv_struct_winsize_header=ioctl_h,
1180   [AC_TRY_COMPILE([#include <sys/types.h>
1181 #include <termios.h>], [struct winsize x;],
1182   bash_cv_struct_winsize_header=termios_h, bash_cv_struct_winsize_header=other)
1183 ])])
1184 if test $bash_cv_struct_winsize_header = ioctl_h; then
1185   AC_MSG_RESULT(sys/ioctl.h)
1186   AC_DEFINE(STRUCT_WINSIZE_IN_SYS_IOCTL)
1187 elif test $bash_cv_struct_winsize_header = termios_h; then
1188   AC_MSG_RESULT(termios.h)
1189   AC_DEFINE(STRUCT_WINSIZE_IN_TERMIOS)
1190 else
1191   AC_MSG_RESULT(not found)
1192 fi
1193 ])
1194
1195 dnl Check type of signal routines (posix, 4.2bsd, 4.1bsd or v7)
1196 AC_DEFUN(BASH_SYS_SIGNAL_VINTAGE,
1197 [AC_REQUIRE([AC_TYPE_SIGNAL])
1198 AC_MSG_CHECKING(for type of signal functions)
1199 AC_CACHE_VAL(bash_cv_signal_vintage,
1200 [
1201   AC_TRY_LINK([#include <signal.h>],[
1202     sigset_t ss;
1203     struct sigaction sa;
1204     sigemptyset(&ss); sigsuspend(&ss);
1205     sigaction(SIGINT, &sa, (struct sigaction *) 0);
1206     sigprocmask(SIG_BLOCK, &ss, (sigset_t *) 0);
1207   ], bash_cv_signal_vintage=posix,
1208   [
1209     AC_TRY_LINK([#include <signal.h>], [
1210         int mask = sigmask(SIGINT);
1211         sigsetmask(mask); sigblock(mask); sigpause(mask);
1212     ], bash_cv_signal_vintage=4.2bsd,
1213     [
1214       AC_TRY_LINK([
1215         #include <signal.h>
1216         RETSIGTYPE foo() { }], [
1217                 int mask = sigmask(SIGINT);
1218                 sigset(SIGINT, foo); sigrelse(SIGINT);
1219                 sighold(SIGINT); sigpause(SIGINT);
1220         ], bash_cv_signal_vintage=svr3, bash_cv_signal_vintage=v7
1221     )]
1222   )]
1223 )
1224 ])
1225 AC_MSG_RESULT($bash_cv_signal_vintage)
1226 if test "$bash_cv_signal_vintage" = posix; then
1227 AC_DEFINE(HAVE_POSIX_SIGNALS)
1228 elif test "$bash_cv_signal_vintage" = "4.2bsd"; then
1229 AC_DEFINE(HAVE_BSD_SIGNALS)
1230 elif test "$bash_cv_signal_vintage" = svr3; then
1231 AC_DEFINE(HAVE_USG_SIGHOLD)
1232 fi
1233 ])
1234
1235 dnl Check if the pgrp of setpgrp() can't be the pid of a zombie process.
1236 AC_DEFUN(BASH_SYS_PGRP_SYNC,
1237 [AC_REQUIRE([AC_FUNC_GETPGRP])
1238 AC_MSG_CHECKING(whether pgrps need synchronization)
1239 AC_CACHE_VAL(bash_cv_pgrp_pipe,
1240 [AC_TRY_RUN([
1241 #ifdef HAVE_UNISTD_H
1242 #  include <unistd.h>
1243 #endif
1244 main()
1245 {
1246 # ifdef GETPGRP_VOID
1247 #  define getpgID()     getpgrp()
1248 # else
1249 #  define getpgID()     getpgrp(0)
1250 #  define setpgid(x,y)  setpgrp(x,y)
1251 # endif
1252         int pid1, pid2, fds[2];
1253         int status;
1254         char ok;
1255
1256         switch (pid1 = fork()) {
1257           case -1:
1258             exit(1);
1259           case 0:
1260             setpgid(0, getpid());
1261             exit(0);
1262         }
1263         setpgid(pid1, pid1);
1264
1265         sleep(2);       /* let first child die */
1266
1267         if (pipe(fds) < 0)
1268           exit(2);
1269
1270         switch (pid2 = fork()) {
1271           case -1:
1272             exit(3);
1273           case 0:
1274             setpgid(0, pid1);
1275             ok = getpgID() == pid1;
1276             write(fds[1], &ok, 1);
1277             exit(0);
1278         }
1279         setpgid(pid2, pid1);
1280
1281         close(fds[1]);
1282         if (read(fds[0], &ok, 1) != 1)
1283           exit(4);
1284         wait(&status);
1285         wait(&status);
1286         exit(ok ? 0 : 5);
1287 }
1288 ], bash_cv_pgrp_pipe=no,bash_cv_pgrp_pipe=yes,
1289    [AC_MSG_WARN(cannot check pgrp synchronization if cross compiling -- defaulting to no)
1290     bash_cv_pgrp_pipe=no])
1291 ])
1292 AC_MSG_RESULT($bash_cv_pgrp_pipe)
1293 if test $bash_cv_pgrp_pipe = yes; then
1294 AC_DEFINE(PGRP_PIPE)
1295 fi
1296 ])
1297
1298 AC_DEFUN(BASH_SYS_REINSTALL_SIGHANDLERS,
1299 [AC_REQUIRE([AC_TYPE_SIGNAL])
1300 AC_REQUIRE([BASH_SYS_SIGNAL_VINTAGE])
1301 AC_MSG_CHECKING([if signal handlers must be reinstalled when invoked])
1302 AC_CACHE_VAL(bash_cv_must_reinstall_sighandlers,
1303 [AC_TRY_RUN([
1304 #include <signal.h>
1305 #ifdef HAVE_UNISTD_H
1306 #include <unistd.h>
1307 #endif
1308
1309 typedef RETSIGTYPE sigfunc();
1310
1311 volatile int nsigint;
1312
1313 #ifdef HAVE_POSIX_SIGNALS
1314 sigfunc *
1315 set_signal_handler(sig, handler)
1316      int sig;
1317      sigfunc *handler;
1318 {
1319   struct sigaction act, oact;
1320   act.sa_handler = handler;
1321   act.sa_flags = 0;
1322   sigemptyset (&act.sa_mask);
1323   sigemptyset (&oact.sa_mask);
1324   sigaction (sig, &act, &oact);
1325   return (oact.sa_handler);
1326 }
1327 #else
1328 #define set_signal_handler(s, h) signal(s, h)
1329 #endif
1330
1331 RETSIGTYPE
1332 sigint(s)
1333 int s;
1334 {
1335   nsigint++;
1336 }
1337
1338 main()
1339 {
1340         nsigint = 0;
1341         set_signal_handler(SIGINT, sigint);
1342         kill((int)getpid(), SIGINT);
1343         kill((int)getpid(), SIGINT);
1344         exit(nsigint != 2);
1345 }
1346 ], bash_cv_must_reinstall_sighandlers=no, bash_cv_must_reinstall_sighandlers=yes,
1347    [AC_MSG_WARN(cannot check signal handling if cross compiling -- defaulting to no)
1348     bash_cv_must_reinstall_sighandlers=no]
1349 )])
1350 AC_MSG_RESULT($bash_cv_must_reinstall_sighandlers)
1351 if test $bash_cv_must_reinstall_sighandlers = yes; then
1352 AC_DEFINE(MUST_REINSTALL_SIGHANDLERS)
1353 fi
1354 ])
1355
1356 dnl check that some necessary job control definitions are present
1357 AC_DEFUN(BASH_SYS_JOB_CONTROL_MISSING,
1358 [AC_REQUIRE([BASH_SYS_SIGNAL_VINTAGE])
1359 AC_MSG_CHECKING(for presence of necessary job control definitions)
1360 AC_CACHE_VAL(bash_cv_job_control_missing,
1361 [AC_TRY_COMPILE([
1362 #include <sys/types.h>
1363 #ifdef HAVE_SYS_WAIT_H
1364 #include <sys/wait.h>
1365 #endif
1366 #ifdef HAVE_UNISTD_H
1367 #include <unistd.h>
1368 #endif
1369 #include <signal.h>
1370
1371 /* add more tests in here as appropriate */
1372
1373 /* signal type */
1374 #if !defined (HAVE_POSIX_SIGNALS) && !defined (HAVE_BSD_SIGNALS)
1375 #error
1376 #endif
1377
1378 /* signals and tty control. */
1379 #if !defined (SIGTSTP) || !defined (SIGSTOP) || !defined (SIGCONT)
1380 #error
1381 #endif
1382
1383 /* process control */
1384 #if !defined (WNOHANG) || !defined (WUNTRACED) 
1385 #error
1386 #endif
1387
1388 /* Posix systems have tcgetpgrp and waitpid. */
1389 #if defined (_POSIX_VERSION) && !defined (HAVE_TCGETPGRP)
1390 #error
1391 #endif
1392
1393 #if defined (_POSIX_VERSION) && !defined (HAVE_WAITPID)
1394 #error
1395 #endif
1396
1397 /* Other systems have TIOCSPGRP/TIOCGPRGP and wait3. */
1398 #if !defined (_POSIX_VERSION) && !defined (HAVE_WAIT3)
1399 #error
1400 #endif
1401
1402 ], , bash_cv_job_control_missing=present, bash_cv_job_control_missing=missing
1403 )])
1404 AC_MSG_RESULT($bash_cv_job_control_missing)
1405 if test $bash_cv_job_control_missing = missing; then
1406 AC_DEFINE(JOB_CONTROL_MISSING)
1407 fi
1408 ])
1409
1410 dnl check whether named pipes are present
1411 dnl this requires a previous check for mkfifo, but that is awkward to specify
1412 AC_DEFUN(BASH_SYS_NAMED_PIPES,
1413 [AC_MSG_CHECKING(for presence of named pipes)
1414 AC_CACHE_VAL(bash_cv_sys_named_pipes,
1415 [AC_TRY_RUN([
1416 #include <sys/types.h>
1417 #include <sys/stat.h>
1418 #ifdef HAVE_UNISTD_H
1419 #include <unistd.h>
1420 #endif
1421
1422 /* Add more tests in here as appropriate. */
1423 main()
1424 {
1425 int fd, err;
1426
1427 #if defined (HAVE_MKFIFO)
1428 exit (0);
1429 #endif
1430
1431 #if !defined (S_IFIFO) && (defined (_POSIX_VERSION) && !defined (S_ISFIFO))
1432 exit (1);
1433 #endif
1434
1435 #if defined (NeXT)
1436 exit (1);
1437 #endif
1438 err = mkdir("bash-aclocal", 0700);
1439 if (err < 0) {
1440   perror ("mkdir");
1441   exit(1);
1442 }
1443 fd = mknod ("bash-aclocal/sh-np-autoconf", 0666 | S_IFIFO, 0);
1444 if (fd == -1) {
1445   rmdir ("bash-aclocal");
1446   exit (1);
1447 }
1448 close(fd);
1449 unlink ("bash-aclocal/sh-np-autoconf");
1450 rmdir ("bash-aclocal");
1451 exit(0);
1452 }], bash_cv_sys_named_pipes=present, bash_cv_sys_named_pipes=missing,
1453     [AC_MSG_WARN(cannot check for named pipes if cross-compiling -- defaulting to missing)
1454      bash_cv_sys_named_pipes=missing]
1455 )])
1456 AC_MSG_RESULT($bash_cv_sys_named_pipes)
1457 if test $bash_cv_sys_named_pipes = missing; then
1458 AC_DEFINE(NAMED_PIPES_MISSING)
1459 fi
1460 ])
1461
1462 AC_DEFUN(BASH_SYS_DEFAULT_MAIL_DIR,
1463 [AC_MSG_CHECKING(for default mail directory)
1464 AC_CACHE_VAL(bash_cv_mail_dir,
1465 [if test -d /var/mail; then
1466    bash_cv_mail_dir=/var/mail
1467  elif test -d /var/spool/mail; then
1468    bash_cv_mail_dir=/var/spool/mail
1469  elif test -d /usr/mail; then
1470    bash_cv_mail_dir=/usr/mail
1471  elif test -d /usr/spool/mail; then
1472    bash_cv_mail_dir=/usr/spool/mail
1473  else
1474    bash_cv_mail_dir=unknown
1475  fi
1476 ])
1477 AC_MSG_RESULT($bash_cv_mail_dir)
1478 AC_DEFINE_UNQUOTED(DEFAULT_MAIL_DIRECTORY, "$bash_cv_mail_dir")
1479 ])
1480
1481 AC_DEFUN(BASH_HAVE_TIOCGWINSZ,
1482 [AC_MSG_CHECKING(for TIOCGWINSZ in sys/ioctl.h)
1483 AC_CACHE_VAL(bash_cv_tiocgwinsz_in_ioctl,
1484 [AC_TRY_COMPILE([#include <sys/types.h>
1485 #include <sys/ioctl.h>], [int x = TIOCGWINSZ;],
1486   bash_cv_tiocgwinsz_in_ioctl=yes,bash_cv_tiocgwinsz_in_ioctl=no)])
1487 AC_MSG_RESULT($bash_cv_tiocgwinsz_in_ioctl)
1488 if test $bash_cv_tiocgwinsz_in_ioctl = yes; then   
1489 AC_DEFINE(GWINSZ_IN_SYS_IOCTL)
1490 fi
1491 ])
1492
1493 AC_DEFUN(BASH_HAVE_TIOCSTAT,
1494 [AC_MSG_CHECKING(for TIOCSTAT in sys/ioctl.h)
1495 AC_CACHE_VAL(bash_cv_tiocstat_in_ioctl,
1496 [AC_TRY_COMPILE([#include <sys/types.h>
1497 #include <sys/ioctl.h>], [int x = TIOCSTAT;],
1498   bash_cv_tiocstat_in_ioctl=yes,bash_cv_tiocstat_in_ioctl=no)])
1499 AC_MSG_RESULT($bash_cv_tiocstat_in_ioctl)
1500 if test $bash_cv_tiocstat_in_ioctl = yes; then   
1501 AC_DEFINE(TIOCSTAT_IN_SYS_IOCTL)
1502 fi
1503 ])
1504
1505 AC_DEFUN(BASH_HAVE_FIONREAD,
1506 [AC_MSG_CHECKING(for FIONREAD in sys/ioctl.h)
1507 AC_CACHE_VAL(bash_cv_fionread_in_ioctl,
1508 [AC_TRY_COMPILE([#include <sys/types.h>
1509 #include <sys/ioctl.h>], [int x = FIONREAD;],
1510   bash_cv_fionread_in_ioctl=yes,bash_cv_fionread_in_ioctl=no)])
1511 AC_MSG_RESULT($bash_cv_fionread_in_ioctl)
1512 if test $bash_cv_fionread_in_ioctl = yes; then   
1513 AC_DEFINE(FIONREAD_IN_SYS_IOCTL)
1514 fi
1515 ])
1516
1517 dnl
1518 dnl See if speed_t is declared in <sys/types.h>.  Some versions of linux
1519 dnl require a definition of speed_t each time <termcap.h> is included,
1520 dnl but you can only get speed_t if you include <termios.h> (on some
1521 dnl versions) or <sys/types.h> (on others).
1522 dnl
1523 AC_DEFUN(BASH_CHECK_SPEED_T,
1524 [AC_MSG_CHECKING(for speed_t in sys/types.h)
1525 AC_CACHE_VAL(bash_cv_speed_t_in_sys_types,
1526 [AC_TRY_COMPILE([#include <sys/types.h>], [speed_t x;],
1527   bash_cv_speed_t_in_sys_types=yes,bash_cv_speed_t_in_sys_types=no)])
1528 AC_MSG_RESULT($bash_cv_speed_t_in_sys_types)
1529 if test $bash_cv_speed_t_in_sys_types = yes; then   
1530 AC_DEFINE(SPEED_T_IN_SYS_TYPES)
1531 fi
1532 ])
1533
1534 AC_DEFUN(BASH_CHECK_GETPW_FUNCS,
1535 [AC_MSG_CHECKING(whether getpw functions are declared in pwd.h)
1536 AC_CACHE_VAL(bash_cv_getpw_declared,
1537 [AC_EGREP_CPP(getpwuid,
1538 [
1539 #include <sys/types.h>
1540 #ifdef HAVE_UNISTD_H
1541 #  include <unistd.h>
1542 #endif
1543 #include <pwd.h>
1544 ],
1545 bash_cv_getpw_declared=yes,bash_cv_getpw_declared=no)])
1546 AC_MSG_RESULT($bash_cv_getpw_declared)
1547 if test $bash_cv_getpw_declared = yes; then
1548 AC_DEFINE(HAVE_GETPW_DECLS)
1549 fi
1550 ])
1551
1552 AC_DEFUN(BASH_CHECK_DEV_FD,
1553 [AC_MSG_CHECKING(whether /dev/fd is available)
1554 AC_CACHE_VAL(bash_cv_dev_fd,
1555 [bash_cv_dev_fd=""
1556 if test -d /dev/fd  && (exec test -r /dev/fd/0 < /dev/null) ; then
1557 # check for systems like FreeBSD 5 that only provide /dev/fd/[012]
1558    if (exec test -r /dev/fd/3 3</dev/null) ; then
1559      bash_cv_dev_fd=standard
1560    else
1561      bash_cv_dev_fd=absent
1562    fi
1563 fi
1564 if test -z "$bash_cv_dev_fd" ; then 
1565   if test -d /proc/self/fd && (exec test -r /proc/self/fd/0 < /dev/null) ; then
1566     bash_cv_dev_fd=whacky
1567   else
1568     bash_cv_dev_fd=absent
1569   fi
1570 fi
1571 ])
1572 AC_MSG_RESULT($bash_cv_dev_fd)
1573 if test $bash_cv_dev_fd = "standard"; then
1574   AC_DEFINE(HAVE_DEV_FD)
1575   AC_DEFINE(DEV_FD_PREFIX, "/dev/fd/")
1576 elif test $bash_cv_dev_fd = "whacky"; then
1577   AC_DEFINE(HAVE_DEV_FD)
1578   AC_DEFINE(DEV_FD_PREFIX, "/proc/self/fd/")
1579 fi
1580 ])
1581
1582 AC_DEFUN(BASH_CHECK_DEV_STDIN,
1583 [AC_MSG_CHECKING(whether /dev/stdin stdout stderr are available)
1584 AC_CACHE_VAL(bash_cv_dev_stdin,
1585 [if (exec test -r /dev/stdin < /dev/null) ; then
1586    bash_cv_dev_stdin=present
1587  else
1588    bash_cv_dev_stdin=absent
1589  fi
1590 ])
1591 AC_MSG_RESULT($bash_cv_dev_stdin)
1592 if test $bash_cv_dev_stdin = "present"; then
1593   AC_DEFINE(HAVE_DEV_STDIN)
1594 fi
1595 ])
1596
1597 dnl
1598 dnl Check if HPUX needs _KERNEL defined for RLIMIT_* definitions
1599 dnl
1600 AC_DEFUN(BASH_CHECK_KERNEL_RLIMIT,
1601 [AC_MSG_CHECKING([whether $host_os needs _KERNEL for RLIMIT defines])
1602 AC_CACHE_VAL(bash_cv_kernel_rlimit,
1603 [AC_TRY_COMPILE([
1604 #include <sys/types.h>
1605 #include <sys/resource.h>
1606 ],
1607 [
1608   int f;
1609   f = RLIMIT_DATA;
1610 ], bash_cv_kernel_rlimit=no,
1611 [AC_TRY_COMPILE([
1612 #include <sys/types.h>
1613 #define _KERNEL
1614 #include <sys/resource.h>
1615 #undef _KERNEL
1616 ],
1617 [
1618         int f;
1619         f = RLIMIT_DATA;
1620 ], bash_cv_kernel_rlimit=yes, bash_cv_kernel_rlimit=no)]
1621 )])
1622 AC_MSG_RESULT($bash_cv_kernel_rlimit)
1623 if test $bash_cv_kernel_rlimit = yes; then
1624 AC_DEFINE(RLIMIT_NEEDS_KERNEL)
1625 fi
1626 ])
1627
1628 dnl
1629 dnl Check for 64-bit off_t -- used for malloc alignment
1630 dnl
1631 dnl C does not allow duplicate case labels, so the compile will fail if
1632 dnl sizeof(off_t) is > 4.
1633 dnl
1634 AC_DEFUN(BASH_CHECK_OFF_T_64,
1635 [AC_CACHE_CHECK(for 64-bit off_t, bash_cv_off_t_64,
1636 AC_TRY_COMPILE([
1637 #ifdef HAVE_UNISTD_H
1638 #include <unistd.h>
1639 #endif
1640 #include <sys/types.h>
1641 ],[
1642 switch (0) case 0: case (sizeof (off_t) <= 4):;
1643 ], bash_cv_off_t_64=no, bash_cv_off_t_64=yes))
1644 if test $bash_cv_off_t_64 = yes; then
1645         AC_DEFINE(HAVE_OFF_T_64)
1646 fi])
1647
1648 AC_DEFUN(BASH_CHECK_RTSIGS,
1649 [AC_MSG_CHECKING(for unusable real-time signals due to large values)
1650 AC_CACHE_VAL(bash_cv_unusable_rtsigs,
1651 [AC_TRY_RUN([
1652 #include <sys/types.h>
1653 #include <signal.h>
1654
1655 #ifndef NSIG
1656 #  define NSIG 64
1657 #endif
1658
1659 main ()
1660 {
1661   int n_sigs = 2 * NSIG;
1662 #ifdef SIGRTMIN
1663   int rtmin = SIGRTMIN;
1664 #else
1665   int rtmin = 0;
1666 #endif
1667
1668   exit(rtmin < n_sigs);
1669 }], bash_cv_unusable_rtsigs=yes, bash_cv_unusable_rtsigs=no,
1670     [AC_MSG_WARN(cannot check real-time signals if cross compiling -- defaulting to yes)
1671      bash_cv_unusable_rtsigs=yes]
1672 )])
1673 AC_MSG_RESULT($bash_cv_unusable_rtsigs)
1674 if test $bash_cv_unusable_rtsigs = yes; then
1675 AC_DEFINE(UNUSABLE_RT_SIGNALS)
1676 fi
1677 ])
1678
1679 dnl
1680 dnl check for availability of multibyte characters and functions
1681 dnl
1682 dnl geez, I wish I didn't have to check for all of this stuff separately
1683 dnl
1684 AC_DEFUN(BASH_CHECK_MULTIBYTE,
1685 [
1686 AC_CHECK_HEADERS(wctype.h)
1687 AC_CHECK_HEADERS(wchar.h)
1688 AC_CHECK_HEADERS(langinfo.h)
1689
1690 AC_CHECK_HEADERS(mbstr.h)
1691
1692 AC_CHECK_FUNC(mbrlen, AC_DEFINE(HAVE_MBRLEN))
1693 AC_CHECK_FUNC(mbscasecmp, AC_DEFINE(HAVE_MBSCMP))
1694 AC_CHECK_FUNC(mbscmp, AC_DEFINE(HAVE_MBSCMP))
1695 AC_CHECK_FUNC(mbsnrtowcs, AC_DEFINE(HAVE_MBSNRTOWCS))
1696 AC_CHECK_FUNC(mbsrtowcs, AC_DEFINE(HAVE_MBSRTOWCS))
1697
1698 AC_REPLACE_FUNCS(mbschr)
1699
1700 AC_CHECK_FUNC(wcrtomb, AC_DEFINE(HAVE_WCRTOMB))
1701 AC_CHECK_FUNC(wcscoll, AC_DEFINE(HAVE_WCSCOLL))
1702 AC_CHECK_FUNC(wcsdup, AC_DEFINE(HAVE_WCSDUP))
1703 AC_CHECK_FUNC(wcwidth, AC_DEFINE(HAVE_WCWIDTH))
1704 AC_CHECK_FUNC(wctype, AC_DEFINE(HAVE_WCTYPE))
1705
1706 AC_REPLACE_FUNCS(wcswidth)
1707
1708 dnl checks for both mbrtowc and mbstate_t
1709 AC_FUNC_MBRTOWC
1710 if test $ac_cv_func_mbrtowc = yes; then
1711         AC_DEFINE(HAVE_MBSTATE_T)
1712 fi
1713
1714 AC_CHECK_FUNCS(iswlower iswupper towlower towupper iswctype)
1715
1716 AC_CACHE_CHECK([for nl_langinfo and CODESET], bash_cv_langinfo_codeset,
1717 [AC_TRY_LINK(
1718 [#include <langinfo.h>],
1719 [char* cs = nl_langinfo(CODESET);],
1720 bash_cv_langinfo_codeset=yes, bash_cv_langinfo_codeset=no)])
1721 if test $bash_cv_langinfo_codeset = yes; then
1722   AC_DEFINE(HAVE_LANGINFO_CODESET)
1723 fi
1724
1725 dnl check for wchar_t in <wchar.h>
1726 AC_CACHE_CHECK([for wchar_t in wchar.h], bash_cv_type_wchar_t,
1727 [AC_TRY_COMPILE(
1728 [#include <wchar.h>
1729 ],
1730 [
1731         wchar_t foo;
1732         foo = 0;
1733 ], bash_cv_type_wchar_t=yes, bash_cv_type_wchar_t=no)])
1734 if test $bash_cv_type_wchar_t = yes; then
1735         AC_DEFINE(HAVE_WCHAR_T, 1, [systems should define this type here])
1736 fi
1737
1738 dnl check for wctype_t in <wctype.h>
1739 AC_CACHE_CHECK([for wctype_t in wctype.h], bash_cv_type_wctype_t,
1740 [AC_TRY_COMPILE(
1741 [#include <wctype.h>],
1742 [
1743         wctype_t foo;
1744         foo = 0;
1745 ], bash_cv_type_wctype_t=yes, bash_cv_type_wctype_t=no)])
1746 if test $bash_cv_type_wctype_t = yes; then
1747         AC_DEFINE(HAVE_WCTYPE_T, 1, [systems should define this type here])
1748 fi
1749
1750 dnl check for wint_t in <wctype.h>
1751 AC_CACHE_CHECK([for wint_t in wctype.h], bash_cv_type_wint_t,
1752 [AC_TRY_COMPILE(
1753 [#include <wctype.h>],
1754 [
1755         wint_t foo;
1756         foo = 0;
1757 ], bash_cv_type_wint_t=yes, bash_cv_type_wint_t=no)])
1758 if test $bash_cv_type_wint_t = yes; then
1759         AC_DEFINE(HAVE_WINT_T, 1, [systems should define this type here])
1760 fi
1761
1762 dnl check for broken wcwidth
1763 AC_CACHE_CHECK([for wcwidth broken with unicode combining characters],
1764 bash_cv_wcwidth_broken,
1765 [AC_TRY_RUN([
1766 #include <unistd.h>
1767 #include <stdlib.h>
1768 #include <stdio.h>
1769
1770 #include <locale.h>
1771 #include <wchar.h>
1772
1773 main(c, v)
1774 int     c;
1775 char    **v;
1776 {
1777         int     w;
1778
1779         setlocale(LC_ALL, "en_US.UTF-8");
1780         w = wcwidth (0x0301);
1781         exit (w == 0);  /* exit 0 if wcwidth broken */
1782 }
1783 ],
1784 bash_cv_wcwidth_broken=yes, bash_cv_wcwidth_broken=no, bash_cv_wcwidth_broken=no)])
1785 if test "$bash_cv_wcwidth_broken" = yes; then
1786         AC_DEFINE(WCWIDTH_BROKEN, 1, [wcwidth is usually not broken])
1787 fi
1788
1789 if test "$am_cv_func_iconv" = yes; then
1790         OLDLIBS="$LIBS"
1791         LIBS="$LIBS $LIBINTL $LIBICONV"
1792         AC_CHECK_FUNCS(locale_charset)
1793         LIBS="$OLDLIBS"
1794 fi
1795
1796 AC_CHECK_SIZEOF(wchar_t, 4)
1797
1798 ])
1799
1800 dnl need: prefix exec_prefix libdir includedir CC TERMCAP_LIB
1801 dnl require:
1802 dnl     AC_PROG_CC
1803 dnl     BASH_CHECK_LIB_TERMCAP
1804
1805 AC_DEFUN([RL_LIB_READLINE_VERSION],
1806 [
1807 AC_REQUIRE([BASH_CHECK_LIB_TERMCAP])
1808
1809 AC_MSG_CHECKING([version of installed readline library])
1810
1811 # What a pain in the ass this is.
1812
1813 # save cpp and ld options
1814 _save_CFLAGS="$CFLAGS"
1815 _save_LDFLAGS="$LDFLAGS"
1816 _save_LIBS="$LIBS"
1817
1818 # Don't set ac_cv_rl_prefix if the caller has already assigned a value.  This
1819 # allows the caller to do something like $_rl_prefix=$withval if the user
1820 # specifies --with-installed-readline=PREFIX as an argument to configure
1821
1822 if test -z "$ac_cv_rl_prefix"; then
1823 test "x$prefix" = xNONE && ac_cv_rl_prefix=$ac_default_prefix || ac_cv_rl_prefix=${prefix}
1824 fi
1825
1826 eval ac_cv_rl_includedir=${ac_cv_rl_prefix}/include
1827 eval ac_cv_rl_libdir=${ac_cv_rl_prefix}/lib
1828
1829 LIBS="$LIBS -lreadline ${TERMCAP_LIB}"
1830 CFLAGS="$CFLAGS -I${ac_cv_rl_includedir}"
1831 LDFLAGS="$LDFLAGS -L${ac_cv_rl_libdir}"
1832
1833 AC_CACHE_VAL(ac_cv_rl_version,
1834 [AC_TRY_RUN([
1835 #include <stdio.h>
1836 #include <readline/readline.h>
1837
1838 extern int rl_gnu_readline_p;
1839
1840 main()
1841 {
1842         FILE *fp;
1843         fp = fopen("conftest.rlv", "w");
1844         if (fp == 0)
1845                 exit(1);
1846         if (rl_gnu_readline_p != 1)
1847                 fprintf(fp, "0.0\n");
1848         else
1849                 fprintf(fp, "%s\n", rl_library_version ? rl_library_version : "0.0");
1850         fclose(fp);
1851         exit(0);
1852 }
1853 ],
1854 ac_cv_rl_version=`cat conftest.rlv`,
1855 ac_cv_rl_version='0.0',
1856 ac_cv_rl_version='8.0')])
1857
1858 CFLAGS="$_save_CFLAGS"
1859 LDFLAGS="$_save_LDFLAGS"
1860 LIBS="$_save_LIBS"
1861
1862 RL_MAJOR=0
1863 RL_MINOR=0
1864
1865 # (
1866 case "$ac_cv_rl_version" in
1867 2*|3*|4*|5*|6*|7*|8*|9*)
1868         RL_MAJOR=`echo $ac_cv_rl_version | sed 's:\..*$::'`
1869         RL_MINOR=`echo $ac_cv_rl_version | sed -e 's:^.*\.::' -e 's:[[a-zA-Z]]*$::'`
1870         ;;
1871 esac
1872
1873 # (((
1874 case $RL_MAJOR in
1875 [[0-9][0-9]])   _RL_MAJOR=$RL_MAJOR ;;
1876 [[0-9]])        _RL_MAJOR=0$RL_MAJOR ;;
1877 *)              _RL_MAJOR=00 ;;
1878 esac
1879
1880 # (((
1881 case $RL_MINOR in
1882 [[0-9][0-9]])   _RL_MINOR=$RL_MINOR ;;
1883 [[0-9]])        _RL_MINOR=0$RL_MINOR ;;
1884 *)              _RL_MINOR=00 ;;
1885 esac
1886
1887 RL_VERSION="0x${_RL_MAJOR}${_RL_MINOR}"
1888
1889 # Readline versions greater than 4.2 have these defines in readline.h
1890
1891 if test $ac_cv_rl_version = '0.0' ; then
1892         AC_MSG_WARN([Could not test version of installed readline library.])
1893 elif test $RL_MAJOR -gt 4 || { test $RL_MAJOR = 4 && test $RL_MINOR -gt 2 ; } ; then
1894         # set these for use by the caller
1895         RL_PREFIX=$ac_cv_rl_prefix
1896         RL_LIBDIR=$ac_cv_rl_libdir
1897         RL_INCLUDEDIR=$ac_cv_rl_includedir
1898         AC_MSG_RESULT($ac_cv_rl_version)
1899 else
1900
1901 AC_DEFINE_UNQUOTED(RL_READLINE_VERSION, $RL_VERSION, [encoded version of the installed readline library])
1902 AC_DEFINE_UNQUOTED(RL_VERSION_MAJOR, $RL_MAJOR, [major version of installed readline library])
1903 AC_DEFINE_UNQUOTED(RL_VERSION_MINOR, $RL_MINOR, [minor version of installed readline library])
1904
1905 AC_SUBST(RL_VERSION)
1906 AC_SUBST(RL_MAJOR)
1907 AC_SUBST(RL_MINOR)
1908
1909 # set these for use by the caller
1910 RL_PREFIX=$ac_cv_rl_prefix
1911 RL_LIBDIR=$ac_cv_rl_libdir
1912 RL_INCLUDEDIR=$ac_cv_rl_includedir
1913
1914 AC_MSG_RESULT($ac_cv_rl_version)
1915
1916 fi
1917 ])
1918
1919 AC_DEFUN(BASH_FUNC_CTYPE_NONASCII,
1920 [
1921 AC_MSG_CHECKING(whether the ctype macros accept non-ascii characters)
1922 AC_CACHE_VAL(bash_cv_func_ctype_nonascii,
1923 [AC_TRY_RUN([
1924 #ifdef HAVE_LOCALE_H
1925 #include <locale.h>
1926 #endif
1927 #include <stdio.h>
1928 #include <ctype.h>
1929
1930 main(c, v)
1931 int     c;
1932 char    *v[];
1933 {
1934         char    *deflocale;
1935         unsigned char x;
1936         int     r1, r2;
1937
1938 #ifdef HAVE_SETLOCALE
1939         /* We take a shot here.  If that locale is not known, try the
1940            system default.  We try this one because '\342' (226) is
1941            known to be a printable character in that locale. */
1942         deflocale = setlocale(LC_ALL, "en_US.ISO8859-1");
1943         if (deflocale == 0)
1944                 deflocale = setlocale(LC_ALL, "");
1945 #endif
1946
1947         x = '\342';
1948         r1 = isprint(x);
1949         x -= 128;
1950         r2 = isprint(x);
1951         exit (r1 == 0 || r2 == 0);
1952 }
1953 ], bash_cv_func_ctype_nonascii=yes, bash_cv_func_ctype_nonascii=no,
1954    [AC_MSG_WARN(cannot check ctype macros if cross compiling -- defaulting to no)
1955     bash_cv_func_ctype_nonascii=no]
1956 )])
1957 AC_MSG_RESULT($bash_cv_func_ctype_nonascii)
1958 if test $bash_cv_func_ctype_nonascii = yes; then
1959 AC_DEFINE(CTYPE_NON_ASCII)
1960 fi
1961 ])
1962
1963 AC_DEFUN(BASH_CHECK_WCONTINUED,
1964 [
1965 AC_MSG_CHECKING(whether WCONTINUED flag to waitpid is unavailable or available but broken)
1966 AC_CACHE_VAL(bash_cv_wcontinued_broken,
1967 [AC_TRY_RUN([
1968 #include <sys/types.h>
1969 #include <sys/wait.h>
1970 #include <unistd.h>
1971 #include <errno.h>
1972
1973 #ifndef errno
1974 extern int errno;
1975 #endif
1976 main()
1977 {
1978         int     x;
1979
1980         x = waitpid(-1, (int *)0, WNOHANG|WCONTINUED);
1981         if (x == -1 && errno == EINVAL)
1982                 exit (1);
1983         else
1984                 exit (0);
1985 }
1986 ], bash_cv_wcontinued_broken=no,bash_cv_wcontinued_broken=yes,
1987    [AC_MSG_WARN(cannot check WCONTINUED if cross compiling -- defaulting to no)
1988     bash_cv_wcontinued_broken=no]
1989 )])
1990 AC_MSG_RESULT($bash_cv_wcontinued_broken)
1991 if test $bash_cv_wcontinued_broken = yes; then
1992 AC_DEFINE(WCONTINUED_BROKEN)
1993 fi
1994 ])
1995
1996 dnl
1997 dnl tests added for bashdb
1998 dnl
1999
2000
2001 AC_DEFUN([AM_PATH_LISPDIR],
2002  [AC_ARG_WITH(lispdir, AC_HELP_STRING([--with-lispdir], [override the default lisp directory]),
2003   [ lispdir="$withval" 
2004     AC_MSG_CHECKING([where .elc files should go])
2005     AC_MSG_RESULT([$lispdir])],
2006   [
2007   # If set to t, that means we are running in a shell under Emacs.
2008   # If you have an Emacs named "t", then use the full path.
2009   test x"$EMACS" = xt && EMACS=
2010   AC_CHECK_PROGS(EMACS, emacs xemacs, no)
2011   if test $EMACS != "no"; then
2012     if test x${lispdir+set} != xset; then
2013       AC_CACHE_CHECK([where .elc files should go], [am_cv_lispdir], [dnl
2014         am_cv_lispdir=`$EMACS -batch -q -eval '(while load-path (princ (concat (car load-path) "\n")) (setq load-path (cdr load-path)))' | sed -n -e 's,/$,,' -e '/.*\/lib\/\(x\?emacs\/site-lisp\)$/{s,,${libdir}/\1,;p;q;}' -e '/.*\/share\/\(x\?emacs\/site-lisp\)$/{s,,${datadir}/\1,;p;q;}'`
2015         if test -z "$am_cv_lispdir"; then
2016           am_cv_lispdir='${datadir}/emacs/site-lisp'
2017         fi
2018       ])
2019       lispdir="$am_cv_lispdir"
2020     fi
2021   fi
2022  ])
2023  AC_SUBST(lispdir)
2024 ])
2025
2026 dnl
2027 dnl tests added for gettext
2028 dnl
2029 # codeset.m4 serial AM1 (gettext-0.10.40)
2030 dnl Copyright (C) 2000-2002 Free Software Foundation, Inc.
2031 dnl This file is free software, distributed under the terms of the GNU
2032 dnl General Public License.  As a special exception to the GNU General
2033 dnl Public License, this file may be distributed as part of a program
2034 dnl that contains a configuration script generated by Autoconf, under
2035 dnl the same distribution terms as the rest of that program.
2036
2037 dnl From Bruno Haible.
2038
2039 AC_DEFUN([AM_LANGINFO_CODESET],
2040 [
2041   AC_CACHE_CHECK([for nl_langinfo and CODESET], am_cv_langinfo_codeset,
2042     [AC_TRY_LINK([#include <langinfo.h>],
2043       [char* cs = nl_langinfo(CODESET);],
2044       am_cv_langinfo_codeset=yes,
2045       am_cv_langinfo_codeset=no)
2046     ])
2047   if test $am_cv_langinfo_codeset = yes; then
2048     AC_DEFINE(HAVE_LANGINFO_CODESET, 1,
2049       [Define if you have <langinfo.h> and nl_langinfo(CODESET).])
2050   fi
2051 ])
2052 # gettext.m4 serial 20 (gettext-0.12)
2053 dnl Copyright (C) 1995-2003 Free Software Foundation, Inc.
2054 dnl This file is free software, distributed under the terms of the GNU
2055 dnl General Public License.  As a special exception to the GNU General
2056 dnl Public License, this file may be distributed as part of a program
2057 dnl that contains a configuration script generated by Autoconf, under
2058 dnl the same distribution terms as the rest of that program.
2059 dnl
2060 dnl This file can can be used in projects which are not available under
2061 dnl the GNU General Public License or the GNU Library General Public
2062 dnl License but which still want to provide support for the GNU gettext
2063 dnl functionality.
2064 dnl Please note that the actual code of the GNU gettext library is covered
2065 dnl by the GNU Library General Public License, and the rest of the GNU
2066 dnl gettext package package is covered by the GNU General Public License.
2067 dnl They are *not* in the public domain.
2068
2069 dnl Authors:
2070 dnl   Ulrich Drepper <drepper@cygnus.com>, 1995-2000.
2071 dnl   Bruno Haible <haible@clisp.cons.org>, 2000-2003.
2072
2073 dnl Macro to add for using GNU gettext.
2074
2075 dnl Usage: AM_GNU_GETTEXT([INTLSYMBOL], [NEEDSYMBOL], [INTLDIR]).
2076 dnl INTLSYMBOL can be one of 'external', 'no-libtool', 'use-libtool'. The
2077 dnl    default (if it is not specified or empty) is 'no-libtool'.
2078 dnl    INTLSYMBOL should be 'external' for packages with no intl directory,
2079 dnl    and 'no-libtool' or 'use-libtool' for packages with an intl directory.
2080 dnl    If INTLSYMBOL is 'use-libtool', then a libtool library
2081 dnl    $(top_builddir)/intl/libintl.la will be created (shared and/or static,
2082 dnl    depending on --{enable,disable}-{shared,static} and on the presence of
2083 dnl    AM-DISABLE-SHARED). If INTLSYMBOL is 'no-libtool', a static library
2084 dnl    $(top_builddir)/intl/libintl.a will be created.
2085 dnl If NEEDSYMBOL is specified and is 'need-ngettext', then GNU gettext
2086 dnl    implementations (in libc or libintl) without the ngettext() function
2087 dnl    will be ignored.  If NEEDSYMBOL is specified and is
2088 dnl    'need-formatstring-macros', then GNU gettext implementations that don't
2089 dnl    support the ISO C 99 <inttypes.h> formatstring macros will be ignored.
2090 dnl INTLDIR is used to find the intl libraries.  If empty,
2091 dnl    the value `$(top_builddir)/intl/' is used.
2092 dnl
2093 dnl The result of the configuration is one of three cases:
2094 dnl 1) GNU gettext, as included in the intl subdirectory, will be compiled
2095 dnl    and used.
2096 dnl    Catalog format: GNU --> install in $(datadir)
2097 dnl    Catalog extension: .mo after installation, .gmo in source tree
2098 dnl 2) GNU gettext has been found in the system's C library.
2099 dnl    Catalog format: GNU --> install in $(datadir)
2100 dnl    Catalog extension: .mo after installation, .gmo in source tree
2101 dnl 3) No internationalization, always use English msgid.
2102 dnl    Catalog format: none
2103 dnl    Catalog extension: none
2104 dnl If INTLSYMBOL is 'external', only cases 2 and 3 can occur.
2105 dnl The use of .gmo is historical (it was needed to avoid overwriting the
2106 dnl GNU format catalogs when building on a platform with an X/Open gettext),
2107 dnl but we keep it in order not to force irrelevant filename changes on the
2108 dnl maintainers.
2109 dnl
2110 AC_DEFUN([AM_GNU_GETTEXT],
2111 [
2112   dnl Argument checking.
2113   ifelse([$1], [], , [ifelse([$1], [external], , [ifelse([$1], [no-libtool], , [ifelse([$1], [use-libtool], ,
2114     [errprint([ERROR: invalid first argument to AM_GNU_GETTEXT
2115 ])])])])])
2116   ifelse([$2], [], , [ifelse([$2], [need-ngettext], , [ifelse([$2], [need-formatstring-macros], ,
2117     [errprint([ERROR: invalid second argument to AM_GNU_GETTEXT
2118 ])])])])
2119   define(gt_included_intl, ifelse([$1], [external], [no], [yes]))
2120   define(gt_libtool_suffix_prefix, ifelse([$1], [use-libtool], [l], []))
2121
2122   AC_REQUIRE([AM_PO_SUBDIRS])dnl
2123   ifelse(gt_included_intl, yes, [
2124     AC_REQUIRE([AM_INTL_SUBDIR])dnl
2125   ])
2126
2127   dnl Prerequisites of AC_LIB_LINKFLAGS_BODY.
2128   AC_REQUIRE([AC_LIB_PREPARE_PREFIX])
2129   AC_REQUIRE([AC_LIB_RPATH])
2130
2131   dnl Sometimes libintl requires libiconv, so first search for libiconv.
2132   dnl Ideally we would do this search only after the
2133   dnl      if test "$USE_NLS" = "yes"; then
2134   dnl        if test "$gt_cv_func_gnugettext_libc" != "yes"; then
2135   dnl tests. But if configure.in invokes AM_ICONV after AM_GNU_GETTEXT
2136   dnl the configure script would need to contain the same shell code
2137   dnl again, outside any 'if'. There are two solutions:
2138   dnl - Invoke AM_ICONV_LINKFLAGS_BODY here, outside any 'if'.
2139   dnl - Control the expansions in more detail using AC_PROVIDE_IFELSE.
2140   dnl Since AC_PROVIDE_IFELSE is only in autoconf >= 2.52 and not
2141   dnl documented, we avoid it.
2142   ifelse(gt_included_intl, yes, , [
2143     AC_REQUIRE([AM_ICONV_LINKFLAGS_BODY])
2144   ])
2145
2146   dnl Set USE_NLS.
2147   AM_NLS
2148
2149   ifelse(gt_included_intl, yes, [
2150     BUILD_INCLUDED_LIBINTL=no
2151     USE_INCLUDED_LIBINTL=no
2152   ])
2153   LIBINTL=
2154   LTLIBINTL=
2155   POSUB=
2156
2157   dnl If we use NLS figure out what method
2158   if test "$USE_NLS" = "yes"; then
2159     gt_use_preinstalled_gnugettext=no
2160     ifelse(gt_included_intl, yes, [
2161       AC_MSG_CHECKING([whether included gettext is requested])
2162       AC_ARG_WITH(included-gettext,
2163         [  --with-included-gettext use the GNU gettext library included here],
2164         nls_cv_force_use_gnu_gettext=$withval,
2165         nls_cv_force_use_gnu_gettext=no)
2166       AC_MSG_RESULT($nls_cv_force_use_gnu_gettext)
2167
2168       nls_cv_use_gnu_gettext="$nls_cv_force_use_gnu_gettext"
2169       if test "$nls_cv_force_use_gnu_gettext" != "yes"; then
2170     ])
2171         dnl User does not insist on using GNU NLS library.  Figure out what
2172         dnl to use.  If GNU gettext is available we use this.  Else we have
2173         dnl to fall back to GNU NLS library.
2174
2175         dnl Add a version number to the cache macros.
2176         define([gt_api_version], ifelse([$2], [need-formatstring-macros], 3, ifelse([$2], [need-ngettext], 2, 1)))
2177         define([gt_cv_func_gnugettext_libc], [gt_cv_func_gnugettext]gt_api_version[_libc])
2178         define([gt_cv_func_gnugettext_libintl], [gt_cv_func_gnugettext]gt_api_version[_libintl])
2179
2180         AC_CACHE_CHECK([for GNU gettext in libc], gt_cv_func_gnugettext_libc,
2181          [AC_TRY_LINK([#include <libintl.h>
2182 ]ifelse([$2], [need-formatstring-macros],
2183 [#ifndef __GNU_GETTEXT_SUPPORTED_REVISION
2184 #define __GNU_GETTEXT_SUPPORTED_REVISION(major) ((major) == 0 ? 0 : -1)
2185 #endif
2186 changequote(,)dnl
2187 typedef int array [2 * (__GNU_GETTEXT_SUPPORTED_REVISION(0) >= 1) - 1];
2188 changequote([,])dnl
2189 ], [])[extern int _nl_msg_cat_cntr;
2190 extern int *_nl_domain_bindings;],
2191             [bindtextdomain ("", "");
2192 return (int) gettext ("")]ifelse([$2], [need-ngettext], [ + (int) ngettext ("", "", 0)], [])[ + _nl_msg_cat_cntr + *_nl_domain_bindings],
2193             gt_cv_func_gnugettext_libc=yes,
2194             gt_cv_func_gnugettext_libc=no)])
2195
2196         if test "$gt_cv_func_gnugettext_libc" != "yes"; then
2197           dnl Sometimes libintl requires libiconv, so first search for libiconv.
2198           ifelse(gt_included_intl, yes, , [
2199             AM_ICONV_LINK
2200           ])
2201           dnl Search for libintl and define LIBINTL, LTLIBINTL and INCINTL
2202           dnl accordingly. Don't use AC_LIB_LINKFLAGS_BODY([intl],[iconv])
2203           dnl because that would add "-liconv" to LIBINTL and LTLIBINTL
2204           dnl even if libiconv doesn't exist.
2205           AC_LIB_LINKFLAGS_BODY([intl])
2206           AC_CACHE_CHECK([for GNU gettext in libintl],
2207             gt_cv_func_gnugettext_libintl,
2208            [gt_save_CPPFLAGS="$CPPFLAGS"
2209             CPPFLAGS="$CPPFLAGS $INCINTL"
2210             gt_save_LIBS="$LIBS"
2211             LIBS="$LIBS $LIBINTL"
2212             dnl Now see whether libintl exists and does not depend on libiconv.
2213             AC_TRY_LINK([#include <libintl.h>
2214 ]ifelse([$2], [need-formatstring-macros],
2215 [#ifndef __GNU_GETTEXT_SUPPORTED_REVISION
2216 #define __GNU_GETTEXT_SUPPORTED_REVISION(major) ((major) == 0 ? 0 : -1)
2217 #endif
2218 changequote(,)dnl
2219 typedef int array [2 * (__GNU_GETTEXT_SUPPORTED_REVISION(0) >= 1) - 1];
2220 changequote([,])dnl
2221 ], [])[extern int _nl_msg_cat_cntr;
2222 extern
2223 #ifdef __cplusplus
2224 "C"
2225 #endif
2226 const char *_nl_expand_alias ();],
2227               [bindtextdomain ("", "");
2228 return (int) gettext ("")]ifelse([$2], [need-ngettext], [ + (int) ngettext ("", "", 0)], [])[ + _nl_msg_cat_cntr + *_nl_expand_alias (0)],
2229               gt_cv_func_gnugettext_libintl=yes,
2230               gt_cv_func_gnugettext_libintl=no)
2231             dnl Now see whether libintl exists and depends on libiconv.
2232             if test "$gt_cv_func_gnugettext_libintl" != yes && test -n "$LIBICONV"; then
2233               LIBS="$LIBS $LIBICONV"
2234               AC_TRY_LINK([#include <libintl.h>
2235 ]ifelse([$2], [need-formatstring-macros],
2236 [#ifndef __GNU_GETTEXT_SUPPORTED_REVISION
2237 #define __GNU_GETTEXT_SUPPORTED_REVISION(major) ((major) == 0 ? 0 : -1)
2238 #endif
2239 changequote(,)dnl
2240 typedef int array [2 * (__GNU_GETTEXT_SUPPORTED_REVISION(0) >= 1) - 1];
2241 changequote([,])dnl
2242 ], [])[extern int _nl_msg_cat_cntr;
2243 extern
2244 #ifdef __cplusplus
2245 "C"
2246 #endif
2247 const char *_nl_expand_alias ();],
2248                 [bindtextdomain ("", "");
2249 return (int) gettext ("")]ifelse([$2], [need-ngettext], [ + (int) ngettext ("", "", 0)], [])[ + _nl_msg_cat_cntr + *_nl_expand_alias (0)],
2250                [LIBINTL="$LIBINTL $LIBICONV"
2251                 LTLIBINTL="$LTLIBINTL $LTLIBICONV"
2252                 gt_cv_func_gnugettext_libintl=yes
2253                ])
2254             fi
2255             CPPFLAGS="$gt_save_CPPFLAGS"
2256             LIBS="$gt_save_LIBS"])
2257         fi
2258
2259         dnl If an already present or preinstalled GNU gettext() is found,
2260         dnl use it.  But if this macro is used in GNU gettext, and GNU
2261         dnl gettext is already preinstalled in libintl, we update this
2262         dnl libintl.  (Cf. the install rule in intl/Makefile.in.)
2263         if test "$gt_cv_func_gnugettext_libc" = "yes" \
2264            || { test "$gt_cv_func_gnugettext_libintl" = "yes" \
2265                 && test "$PACKAGE" != gettext-runtime \
2266                 && test "$PACKAGE" != gettext-tools; }; then
2267           gt_use_preinstalled_gnugettext=yes
2268         else
2269           dnl Reset the values set by searching for libintl.
2270           LIBINTL=
2271           LTLIBINTL=
2272           INCINTL=
2273         fi
2274
2275     ifelse(gt_included_intl, yes, [
2276         if test "$gt_use_preinstalled_gnugettext" != "yes"; then
2277           dnl GNU gettext is not found in the C library.
2278           dnl Fall back on included GNU gettext library.
2279           nls_cv_use_gnu_gettext=yes
2280         fi
2281       fi
2282
2283       if test "$nls_cv_use_gnu_gettext" = "yes"; then
2284         dnl Mark actions used to generate GNU NLS library.
2285         BUILD_INCLUDED_LIBINTL=yes
2286         USE_INCLUDED_LIBINTL=yes
2287         LIBINTL="ifelse([$3],[],\${top_builddir}/intl,[$3])/libintl.[]gt_libtool_suffix_prefix[]a $LIBICONV"
2288         LTLIBINTL="ifelse([$3],[],\${top_builddir}/intl,[$3])/libintl.[]gt_libtool_suffix_prefix[]a $LTLIBICONV"
2289         LIBS=`echo " $LIBS " | sed -e 's/ -lintl / /' -e 's/^ //' -e 's/ $//'`
2290       fi
2291
2292       if test "$gt_use_preinstalled_gnugettext" = "yes" \
2293          || test "$nls_cv_use_gnu_gettext" = "yes"; then
2294         dnl Mark actions to use GNU gettext tools.
2295         CATOBJEXT=.gmo
2296       fi
2297     ])
2298
2299     if test "$gt_use_preinstalled_gnugettext" = "yes" \
2300        || test "$nls_cv_use_gnu_gettext" = "yes"; then
2301       AC_DEFINE(ENABLE_NLS, 1,
2302         [Define to 1 if translation of program messages to the user's native language
2303    is requested.])
2304     else
2305       USE_NLS=no
2306     fi
2307   fi
2308
2309   AC_MSG_CHECKING([whether to use NLS])
2310   AC_MSG_RESULT([$USE_NLS])
2311   if test "$USE_NLS" = "yes"; then
2312     AC_MSG_CHECKING([where the gettext function comes from])
2313     if test "$gt_use_preinstalled_gnugettext" = "yes"; then
2314       if test "$gt_cv_func_gnugettext_libintl" = "yes"; then
2315         gt_source="external libintl"
2316       else
2317         gt_source="libc"
2318       fi
2319     else
2320       gt_source="included intl directory"
2321     fi
2322     AC_MSG_RESULT([$gt_source])
2323   fi
2324
2325   if test "$USE_NLS" = "yes"; then
2326
2327     if test "$gt_use_preinstalled_gnugettext" = "yes"; then
2328       if test "$gt_cv_func_gnugettext_libintl" = "yes"; then
2329         AC_MSG_CHECKING([how to link with libintl])
2330         AC_MSG_RESULT([$LIBINTL])
2331         AC_LIB_APPENDTOVAR([CPPFLAGS], [$INCINTL])
2332       fi
2333
2334       dnl For backward compatibility. Some packages may be using this.
2335       AC_DEFINE(HAVE_GETTEXT, 1,
2336        [Define if the GNU gettext() function is already present or preinstalled.])
2337       AC_DEFINE(HAVE_DCGETTEXT, 1,
2338        [Define if the GNU dcgettext() function is already present or preinstalled.])
2339     fi
2340
2341     dnl We need to process the po/ directory.
2342     POSUB=po
2343   fi
2344
2345   ifelse(gt_included_intl, yes, [
2346     dnl If this is used in GNU gettext we have to set BUILD_INCLUDED_LIBINTL
2347     dnl to 'yes' because some of the testsuite requires it.
2348     if test "$PACKAGE" = gettext-runtime || test "$PACKAGE" = gettext-tools; then
2349       BUILD_INCLUDED_LIBINTL=yes
2350     fi
2351
2352     dnl Make all variables we use known to autoconf.
2353     AC_SUBST(BUILD_INCLUDED_LIBINTL)
2354     AC_SUBST(USE_INCLUDED_LIBINTL)
2355     AC_SUBST(CATOBJEXT)
2356
2357     dnl For backward compatibility. Some configure.ins may be using this.
2358     nls_cv_header_intl=
2359     nls_cv_header_libgt=
2360
2361     dnl For backward compatibility. Some Makefiles may be using this.
2362     DATADIRNAME=share
2363     AC_SUBST(DATADIRNAME)
2364
2365     dnl For backward compatibility. Some Makefiles may be using this.
2366     INSTOBJEXT=.mo
2367     AC_SUBST(INSTOBJEXT)
2368
2369     dnl For backward compatibility. Some Makefiles may be using this.
2370     GENCAT=gencat
2371     AC_SUBST(GENCAT)
2372
2373     dnl For backward compatibility. Some Makefiles may be using this.
2374     if test "$USE_INCLUDED_LIBINTL" = yes; then
2375       INTLOBJS="\$(GETTOBJS)"
2376     fi
2377     AC_SUBST(INTLOBJS)
2378
2379     dnl Enable libtool support if the surrounding package wishes it.
2380     INTL_LIBTOOL_SUFFIX_PREFIX=gt_libtool_suffix_prefix
2381     AC_SUBST(INTL_LIBTOOL_SUFFIX_PREFIX)
2382   ])
2383
2384   dnl For backward compatibility. Some Makefiles may be using this.
2385   INTLLIBS="$LIBINTL"
2386   AC_SUBST(INTLLIBS)
2387
2388   dnl Make all documented variables known to autoconf.
2389   AC_SUBST(LIBINTL)
2390   AC_SUBST(LTLIBINTL)
2391   AC_SUBST(POSUB)
2392 ])
2393
2394
2395 dnl Checks for all prerequisites of the intl subdirectory,
2396 dnl except for INTL_LIBTOOL_SUFFIX_PREFIX (and possibly LIBTOOL), INTLOBJS,
2397 dnl            USE_INCLUDED_LIBINTL, BUILD_INCLUDED_LIBINTL.
2398 AC_DEFUN([AM_INTL_SUBDIR],
2399 [
2400   AC_REQUIRE([AC_PROG_INSTALL])dnl
2401   AC_REQUIRE([AM_MKINSTALLDIRS])dnl
2402   AC_REQUIRE([AC_PROG_CC])dnl
2403   AC_REQUIRE([AC_CANONICAL_HOST])dnl
2404   AC_REQUIRE([AC_PROG_RANLIB])dnl
2405   AC_REQUIRE([AC_ISC_POSIX])dnl
2406   AC_REQUIRE([AC_HEADER_STDC])dnl
2407   AC_REQUIRE([AC_C_CONST])dnl
2408   AC_REQUIRE([AC_C_INLINE])dnl
2409   AC_REQUIRE([AC_TYPE_OFF_T])dnl
2410   AC_REQUIRE([AC_TYPE_SIZE_T])dnl
2411   AC_REQUIRE([AC_FUNC_ALLOCA])dnl
2412   AC_REQUIRE([AC_FUNC_MMAP])dnl
2413   AC_REQUIRE([jm_GLIBC21])dnl
2414   AC_REQUIRE([gt_INTDIV0])dnl
2415   AC_REQUIRE([jm_AC_TYPE_UINTMAX_T])dnl
2416   AC_REQUIRE([gt_HEADER_INTTYPES_H])dnl
2417   AC_REQUIRE([gt_INTTYPES_PRI])dnl
2418
2419   AC_CHECK_HEADERS([argz.h limits.h locale.h nl_types.h malloc.h stddef.h \
2420 stdlib.h string.h unistd.h sys/param.h])
2421   AC_CHECK_FUNCS([feof_unlocked fgets_unlocked getc_unlocked getcwd getegid \
2422 geteuid getgid getuid mempcpy munmap putenv setenv setlocale localeconv stpcpy \
2423 strcasecmp strdup strtoul tsearch __argz_count __argz_stringify __argz_next \
2424 __fsetlocking])
2425
2426   AM_ICONV
2427   AM_LANGINFO_CODESET
2428   if test $ac_cv_header_locale_h = yes; then
2429     AM_LC_MESSAGES
2430   fi
2431
2432   dnl intl/plural.c is generated from intl/plural.y. It requires bison,
2433   dnl because plural.y uses bison specific features. It requires at least
2434   dnl bison-1.26 because earlier versions generate a plural.c that doesn't
2435   dnl compile.
2436   dnl bison is only needed for the maintainer (who touches plural.y). But in
2437   dnl order to avoid separate Makefiles or --enable-maintainer-mode, we put
2438   dnl the rule in general Makefile. Now, some people carelessly touch the
2439   dnl files or have a broken "make" program, hence the plural.c rule will
2440   dnl sometimes fire. To avoid an error, defines BISON to ":" if it is not
2441   dnl present or too old.
2442   AC_CHECK_PROGS([INTLBISON], [bison])
2443   if test -z "$INTLBISON"; then
2444     ac_verc_fail=yes
2445   else
2446     dnl Found it, now check the version.
2447     AC_MSG_CHECKING([version of bison])
2448 changequote(<<,>>)dnl
2449     ac_prog_version=`$INTLBISON --version 2>&1 | sed -n 's/^.*GNU Bison.* \([0-9]*\.[0-9.]*\).*$/\1/p'`
2450     case $ac_prog_version in
2451       '') ac_prog_version="v. ?.??, bad"; ac_verc_fail=yes;;
2452       1.2[6-9]* | 1.[3-9][0-9]* | [2-9].*)
2453 changequote([,])dnl
2454          ac_prog_version="$ac_prog_version, ok"; ac_verc_fail=no;;
2455       *) ac_prog_version="$ac_prog_version, bad"; ac_verc_fail=yes;;
2456     esac
2457     AC_MSG_RESULT([$ac_prog_version])
2458   fi
2459   if test $ac_verc_fail = yes; then
2460     INTLBISON=:
2461   fi
2462 ])
2463
2464
2465 dnl Usage: AM_GNU_GETTEXT_VERSION([gettext-version])
2466 AC_DEFUN([AM_GNU_GETTEXT_VERSION], [])
2467 # glibc21.m4 serial 2 (fileutils-4.1.3, gettext-0.10.40)
2468 dnl Copyright (C) 2000-2002 Free Software Foundation, Inc.
2469 dnl This file is free software, distributed under the terms of the GNU
2470 dnl General Public License.  As a special exception to the GNU General
2471 dnl Public License, this file may be distributed as part of a program
2472 dnl that contains a configuration script generated by Autoconf, under
2473 dnl the same distribution terms as the rest of that program.
2474
2475 # Test for the GNU C Library, version 2.1 or newer.
2476 # From Bruno Haible.
2477
2478 AC_DEFUN([jm_GLIBC21],
2479   [
2480     AC_CACHE_CHECK(whether we are using the GNU C Library 2.1 or newer,
2481       ac_cv_gnu_library_2_1,
2482       [AC_EGREP_CPP([Lucky GNU user],
2483         [
2484 #include <features.h>
2485 #ifdef __GNU_LIBRARY__
2486  #if (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 1) || (__GLIBC__ > 2)
2487   Lucky GNU user
2488  #endif
2489 #endif
2490         ],
2491         ac_cv_gnu_library_2_1=yes,
2492         ac_cv_gnu_library_2_1=no)
2493       ]
2494     )
2495     AC_SUBST(GLIBC21)
2496     GLIBC21="$ac_cv_gnu_library_2_1"
2497   ]
2498 )
2499 # iconv.m4 serial AM4 (gettext-0.11.3)
2500 dnl Copyright (C) 2000-2002 Free Software Foundation, Inc.
2501 dnl This file is free software, distributed under the terms of the GNU
2502 dnl General Public License.  As a special exception to the GNU General
2503 dnl Public License, this file may be distributed as part of a program
2504 dnl that contains a configuration script generated by Autoconf, under
2505 dnl the same distribution terms as the rest of that program.
2506
2507 dnl From Bruno Haible.
2508
2509 AC_DEFUN([AM_ICONV_LINKFLAGS_BODY],
2510 [
2511   dnl Prerequisites of AC_LIB_LINKFLAGS_BODY.
2512   AC_REQUIRE([AC_LIB_PREPARE_PREFIX])
2513   AC_REQUIRE([AC_LIB_RPATH])
2514
2515   dnl Search for libiconv and define LIBICONV, LTLIBICONV and INCICONV
2516   dnl accordingly.
2517   AC_LIB_LINKFLAGS_BODY([iconv])
2518 ])
2519
2520 AC_DEFUN([AM_ICONV_LINK],
2521 [
2522   dnl Some systems have iconv in libc, some have it in libiconv (OSF/1 and
2523   dnl those with the standalone portable GNU libiconv installed).
2524
2525   dnl Search for libiconv and define LIBICONV, LTLIBICONV and INCICONV
2526   dnl accordingly.
2527   AC_REQUIRE([AM_ICONV_LINKFLAGS_BODY])
2528
2529   dnl Add $INCICONV to CPPFLAGS before performing the following checks,
2530   dnl because if the user has installed libiconv and not disabled its use
2531   dnl via --without-libiconv-prefix, he wants to use it. The first
2532   dnl AC_TRY_LINK will then fail, the second AC_TRY_LINK will succeed.
2533   am_save_CPPFLAGS="$CPPFLAGS"
2534   AC_LIB_APPENDTOVAR([CPPFLAGS], [$INCICONV])
2535
2536   AC_CACHE_CHECK(for iconv, am_cv_func_iconv, [
2537     am_cv_func_iconv="no, consider installing GNU libiconv"
2538     am_cv_lib_iconv=no
2539     AC_TRY_LINK([#include <stdlib.h>
2540 #include <iconv.h>],
2541       [iconv_t cd = iconv_open("","");
2542        iconv(cd,NULL,NULL,NULL,NULL);
2543        iconv_close(cd);],
2544       am_cv_func_iconv=yes)
2545     if test "$am_cv_func_iconv" != yes; then
2546       am_save_LIBS="$LIBS"
2547       LIBS="$LIBS $LIBICONV"
2548       AC_TRY_LINK([#include <stdlib.h>
2549 #include <iconv.h>],
2550         [iconv_t cd = iconv_open("","");
2551          iconv(cd,NULL,NULL,NULL,NULL);
2552          iconv_close(cd);],
2553         am_cv_lib_iconv=yes
2554         am_cv_func_iconv=yes)
2555       LIBS="$am_save_LIBS"
2556     fi
2557   ])
2558   if test "$am_cv_func_iconv" = yes; then
2559     AC_DEFINE(HAVE_ICONV, 1, [Define if you have the iconv() function.])
2560   fi
2561   if test "$am_cv_lib_iconv" = yes; then
2562     AC_MSG_CHECKING([how to link with libiconv])
2563     AC_MSG_RESULT([$LIBICONV])
2564   else
2565     dnl If $LIBICONV didn't lead to a usable library, we don't need $INCICONV
2566     dnl either.
2567     CPPFLAGS="$am_save_CPPFLAGS"
2568     LIBICONV=
2569     LTLIBICONV=
2570   fi
2571   AC_SUBST(LIBICONV)
2572   AC_SUBST(LTLIBICONV)
2573 ])
2574
2575 AC_DEFUN([AM_ICONV],
2576 [
2577   AM_ICONV_LINK
2578   if test "$am_cv_func_iconv" = yes; then
2579     AC_MSG_CHECKING([for iconv declaration])
2580     AC_CACHE_VAL(am_cv_proto_iconv, [
2581       AC_TRY_COMPILE([
2582 #include <stdlib.h>
2583 #include <iconv.h>
2584 extern
2585 #ifdef __cplusplus
2586 "C"
2587 #endif
2588 #if defined(__STDC__) || defined(__cplusplus)
2589 size_t iconv (iconv_t cd, char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft);
2590 #else
2591 size_t iconv();
2592 #endif
2593 ], [], am_cv_proto_iconv_arg1="", am_cv_proto_iconv_arg1="const")
2594       am_cv_proto_iconv="extern size_t iconv (iconv_t cd, $am_cv_proto_iconv_arg1 char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft);"])
2595     am_cv_proto_iconv=`echo "[$]am_cv_proto_iconv" | tr -s ' ' | sed -e 's/( /(/'`
2596     AC_MSG_RESULT([$]{ac_t:-
2597          }[$]am_cv_proto_iconv)
2598     AC_DEFINE_UNQUOTED(ICONV_CONST, $am_cv_proto_iconv_arg1,
2599       [Define as const if the declaration of iconv() needs const.])
2600   fi
2601 ])
2602 # intdiv0.m4 serial 1 (gettext-0.11.3)
2603 dnl Copyright (C) 2002 Free Software Foundation, Inc.
2604 dnl This file is free software, distributed under the terms of the GNU
2605 dnl General Public License.  As a special exception to the GNU General
2606 dnl Public License, this file may be distributed as part of a program
2607 dnl that contains a configuration script generated by Autoconf, under
2608 dnl the same distribution terms as the rest of that program.
2609
2610 dnl From Bruno Haible.
2611
2612 AC_DEFUN([gt_INTDIV0],
2613 [
2614   AC_REQUIRE([AC_PROG_CC])dnl
2615   AC_REQUIRE([AC_CANONICAL_HOST])dnl
2616
2617   AC_CACHE_CHECK([whether integer division by zero raises SIGFPE],
2618     gt_cv_int_divbyzero_sigfpe,
2619     [
2620       AC_TRY_RUN([
2621 #include <stdlib.h>
2622 #include <signal.h>
2623
2624 static void
2625 #ifdef __cplusplus
2626 sigfpe_handler (int sig)
2627 #else
2628 sigfpe_handler (sig) int sig;
2629 #endif
2630 {
2631   /* Exit with code 0 if SIGFPE, with code 1 if any other signal.  */
2632   exit (sig != SIGFPE);
2633 }
2634
2635 int x = 1;
2636 int y = 0;
2637 int z;
2638 int nan;
2639
2640 int main ()
2641 {
2642   signal (SIGFPE, sigfpe_handler);
2643 /* IRIX and AIX (when "xlc -qcheck" is used) yield signal SIGTRAP.  */
2644 #if (defined (__sgi) || defined (_AIX)) && defined (SIGTRAP)
2645   signal (SIGTRAP, sigfpe_handler);
2646 #endif
2647 /* Linux/SPARC yields signal SIGILL.  */
2648 #if defined (__sparc__) && defined (__linux__)
2649   signal (SIGILL, sigfpe_handler);
2650 #endif
2651
2652   z = x / y;
2653   nan = y / y;
2654   exit (1);
2655 }
2656 ], gt_cv_int_divbyzero_sigfpe=yes, gt_cv_int_divbyzero_sigfpe=no,
2657         [
2658           # Guess based on the CPU.
2659           case "$host_cpu" in
2660             alpha* | i[34567]86 | m68k | s390*)
2661               gt_cv_int_divbyzero_sigfpe="guessing yes";;
2662             *)
2663               gt_cv_int_divbyzero_sigfpe="guessing no";;
2664           esac
2665         ])
2666     ])
2667   case "$gt_cv_int_divbyzero_sigfpe" in
2668     *yes) value=1;;
2669     *) value=0;;
2670   esac
2671   AC_DEFINE_UNQUOTED(INTDIV0_RAISES_SIGFPE, $value,
2672     [Define if integer division by zero raises signal SIGFPE.])
2673 ])
2674 # inttypes.m4 serial 1 (gettext-0.11.4)
2675 dnl Copyright (C) 1997-2002 Free Software Foundation, Inc.
2676 dnl This file is free software, distributed under the terms of the GNU
2677 dnl General Public License.  As a special exception to the GNU General
2678 dnl Public License, this file may be distributed as part of a program
2679 dnl that contains a configuration script generated by Autoconf, under
2680 dnl the same distribution terms as the rest of that program.
2681
2682 dnl From Paul Eggert.
2683
2684 # Define HAVE_INTTYPES_H if <inttypes.h> exists and doesn't clash with
2685 # <sys/types.h>.
2686
2687 AC_DEFUN([gt_HEADER_INTTYPES_H],
2688 [
2689   AC_CACHE_CHECK([for inttypes.h], gt_cv_header_inttypes_h,
2690   [
2691     AC_TRY_COMPILE(
2692       [#include <sys/types.h>
2693 #include <inttypes.h>],
2694       [], gt_cv_header_inttypes_h=yes, gt_cv_header_inttypes_h=no)
2695   ])
2696   if test $gt_cv_header_inttypes_h = yes; then
2697     AC_DEFINE_UNQUOTED(HAVE_INTTYPES_H, 1,
2698       [Define if <inttypes.h> exists and doesn't clash with <sys/types.h>.])
2699   fi
2700 ])
2701 # inttypes_h.m4 serial 5 (gettext-0.12)
2702 dnl Copyright (C) 1997-2003 Free Software Foundation, Inc.
2703 dnl This file is free software, distributed under the terms of the GNU
2704 dnl General Public License.  As a special exception to the GNU General
2705 dnl Public License, this file may be distributed as part of a program
2706 dnl that contains a configuration script generated by Autoconf, under
2707 dnl the same distribution terms as the rest of that program.
2708
2709 dnl From Paul Eggert.
2710
2711 # Define HAVE_INTTYPES_H_WITH_UINTMAX if <inttypes.h> exists,
2712 # doesn't clash with <sys/types.h>, and declares uintmax_t.
2713
2714 AC_DEFUN([jm_AC_HEADER_INTTYPES_H],
2715 [
2716   AC_CACHE_CHECK([for inttypes.h], jm_ac_cv_header_inttypes_h,
2717   [AC_TRY_COMPILE(
2718     [#include <sys/types.h>
2719 #include <inttypes.h>],
2720     [uintmax_t i = (uintmax_t) -1;],
2721     jm_ac_cv_header_inttypes_h=yes,
2722     jm_ac_cv_header_inttypes_h=no)])
2723   if test $jm_ac_cv_header_inttypes_h = yes; then
2724     AC_DEFINE_UNQUOTED(HAVE_INTTYPES_H_WITH_UINTMAX, 1,
2725       [Define if <inttypes.h> exists, doesn't clash with <sys/types.h>,
2726        and declares uintmax_t. ])
2727   fi
2728 ])
2729 # inttypes-pri.m4 serial 1 (gettext-0.11.4)
2730 dnl Copyright (C) 1997-2002 Free Software Foundation, Inc.
2731 dnl This file is free software, distributed under the terms of the GNU
2732 dnl General Public License.  As a special exception to the GNU General
2733 dnl Public License, this file may be distributed as part of a program
2734 dnl that contains a configuration script generated by Autoconf, under
2735 dnl the same distribution terms as the rest of that program.
2736
2737 dnl From Bruno Haible.
2738
2739 # Define PRI_MACROS_BROKEN if <inttypes.h> exists and defines the PRI*
2740 # macros to non-string values.  This is the case on AIX 4.3.3.
2741
2742 AC_DEFUN([gt_INTTYPES_PRI],
2743 [
2744   AC_REQUIRE([gt_HEADER_INTTYPES_H])
2745   if test $gt_cv_header_inttypes_h = yes; then
2746     AC_CACHE_CHECK([whether the inttypes.h PRIxNN macros are broken],
2747       gt_cv_inttypes_pri_broken,
2748       [
2749         AC_TRY_COMPILE([#include <inttypes.h>
2750 #ifdef PRId32
2751 char *p = PRId32;
2752 #endif
2753 ], [], gt_cv_inttypes_pri_broken=no, gt_cv_inttypes_pri_broken=yes)
2754       ])
2755   fi
2756   if test "$gt_cv_inttypes_pri_broken" = yes; then
2757     AC_DEFINE_UNQUOTED(PRI_MACROS_BROKEN, 1,
2758       [Define if <inttypes.h> exists and defines unusable PRI* macros.])
2759   fi
2760 ])
2761 # isc-posix.m4 serial 2 (gettext-0.11.2)
2762 dnl Copyright (C) 1995-2002 Free Software Foundation, Inc.
2763 dnl This file is free software, distributed under the terms of the GNU
2764 dnl General Public License.  As a special exception to the GNU General
2765 dnl Public License, this file may be distributed as part of a program
2766 dnl that contains a configuration script generated by Autoconf, under
2767 dnl the same distribution terms as the rest of that program.
2768
2769 # This file is not needed with autoconf-2.53 and newer.  Remove it in 2005.
2770
2771 # This test replaces the one in autoconf.
2772 # Currently this macro should have the same name as the autoconf macro
2773 # because gettext's gettext.m4 (distributed in the automake package)
2774 # still uses it.  Otherwise, the use in gettext.m4 makes autoheader
2775 # give these diagnostics:
2776 #   configure.in:556: AC_TRY_COMPILE was called before AC_ISC_POSIX
2777 #   configure.in:556: AC_TRY_RUN was called before AC_ISC_POSIX
2778
2779 undefine([AC_ISC_POSIX])
2780
2781 AC_DEFUN([AC_ISC_POSIX],
2782   [
2783     dnl This test replaces the obsolescent AC_ISC_POSIX kludge.
2784     AC_CHECK_LIB(cposix, strerror, [LIBS="$LIBS -lcposix"])
2785   ]
2786 )
2787 # lcmessage.m4 serial 3 (gettext-0.11.3)
2788 dnl Copyright (C) 1995-2002 Free Software Foundation, Inc.
2789 dnl This file is free software, distributed under the terms of the GNU
2790 dnl General Public License.  As a special exception to the GNU General
2791 dnl Public License, this file may be distributed as part of a program
2792 dnl that contains a configuration script generated by Autoconf, under
2793 dnl the same distribution terms as the rest of that program.
2794 dnl
2795 dnl This file can can be used in projects which are not available under
2796 dnl the GNU General Public License or the GNU Library General Public
2797 dnl License but which still want to provide support for the GNU gettext
2798 dnl functionality.
2799 dnl Please note that the actual code of the GNU gettext library is covered
2800 dnl by the GNU Library General Public License, and the rest of the GNU
2801 dnl gettext package package is covered by the GNU General Public License.
2802 dnl They are *not* in the public domain.
2803
2804 dnl Authors:
2805 dnl   Ulrich Drepper <drepper@cygnus.com>, 1995.
2806
2807 # Check whether LC_MESSAGES is available in <locale.h>.
2808
2809 AC_DEFUN([AM_LC_MESSAGES],
2810 [
2811   AC_CACHE_CHECK([for LC_MESSAGES], am_cv_val_LC_MESSAGES,
2812     [AC_TRY_LINK([#include <locale.h>], [return LC_MESSAGES],
2813        am_cv_val_LC_MESSAGES=yes, am_cv_val_LC_MESSAGES=no)])
2814   if test $am_cv_val_LC_MESSAGES = yes; then
2815     AC_DEFINE(HAVE_LC_MESSAGES, 1,
2816       [Define if your <locale.h> file defines LC_MESSAGES.])
2817   fi
2818 ])
2819 # lib-ld.m4 serial 2 (gettext-0.12)
2820 dnl Copyright (C) 1996-2003 Free Software Foundation, Inc.
2821 dnl This file is free software, distributed under the terms of the GNU
2822 dnl General Public License.  As a special exception to the GNU General
2823 dnl Public License, this file may be distributed as part of a program
2824 dnl that contains a configuration script generated by Autoconf, under
2825 dnl the same distribution terms as the rest of that program.
2826
2827 dnl Subroutines of libtool.m4,
2828 dnl with replacements s/AC_/AC_LIB/ and s/lt_cv/acl_cv/ to avoid collision
2829 dnl with libtool.m4.
2830
2831 dnl From libtool-1.4. Sets the variable with_gnu_ld to yes or no.
2832 AC_DEFUN([AC_LIB_PROG_LD_GNU],
2833 [AC_CACHE_CHECK([if the linker ($LD) is GNU ld], acl_cv_prog_gnu_ld,
2834 [# I'd rather use --version here, but apparently some GNU ld's only accept -v.
2835 if $LD -v 2>&1 </dev/null | egrep '(GNU|with BFD)' 1>&5; then
2836   acl_cv_prog_gnu_ld=yes
2837 else
2838   acl_cv_prog_gnu_ld=no
2839 fi])
2840 with_gnu_ld=$acl_cv_prog_gnu_ld
2841 ])
2842
2843 dnl From libtool-1.4. Sets the variable LD.
2844 AC_DEFUN([AC_LIB_PROG_LD],
2845 [AC_ARG_WITH(gnu-ld,
2846 [  --with-gnu-ld           assume the C compiler uses GNU ld [default=no]],
2847 test "$withval" = no || with_gnu_ld=yes, with_gnu_ld=no)
2848 AC_REQUIRE([AC_PROG_CC])dnl
2849 AC_REQUIRE([AC_CANONICAL_HOST])dnl
2850 # Prepare PATH_SEPARATOR.
2851 # The user is always right.
2852 if test "${PATH_SEPARATOR+set}" != set; then
2853   echo "#! /bin/sh" >conf$$.sh
2854   echo  "exit 0"   >>conf$$.sh
2855   chmod +x conf$$.sh
2856   if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then
2857     PATH_SEPARATOR=';'
2858   else
2859     PATH_SEPARATOR=:
2860   fi
2861   rm -f conf$$.sh
2862 fi
2863 ac_prog=ld
2864 if test "$GCC" = yes; then
2865   # Check if gcc -print-prog-name=ld gives a path.
2866   AC_MSG_CHECKING([for ld used by GCC])
2867   case $host in
2868   *-*-mingw*)
2869     # gcc leaves a trailing carriage return which upsets mingw
2870     ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;;
2871   *)
2872     ac_prog=`($CC -print-prog-name=ld) 2>&5` ;;
2873   esac
2874   case $ac_prog in
2875     # Accept absolute paths.
2876     [[\\/]* | [A-Za-z]:[\\/]*)]
2877       [re_direlt='/[^/][^/]*/\.\./']
2878       # Canonicalize the path of ld
2879       ac_prog=`echo $ac_prog| sed 's%\\\\%/%g'`
2880       while echo $ac_prog | grep "$re_direlt" > /dev/null 2>&1; do
2881         ac_prog=`echo $ac_prog| sed "s%$re_direlt%/%"`
2882       done
2883       test -z "$LD" && LD="$ac_prog"
2884       ;;
2885   "")
2886     # If it fails, then pretend we aren't using GCC.
2887     ac_prog=ld
2888     ;;
2889   *)
2890     # If it is relative, then search for the first ld in PATH.
2891     with_gnu_ld=unknown
2892     ;;
2893   esac
2894 elif test "$with_gnu_ld" = yes; then
2895   AC_MSG_CHECKING([for GNU ld])
2896 else
2897   AC_MSG_CHECKING([for non-GNU ld])
2898 fi
2899 AC_CACHE_VAL(acl_cv_path_LD,
2900 [if test -z "$LD"; then
2901   IFS="${IFS=   }"; ac_save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR-:}"
2902   for ac_dir in $PATH; do
2903     test -z "$ac_dir" && ac_dir=.
2904     if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then
2905       acl_cv_path_LD="$ac_dir/$ac_prog"
2906       # Check to see if the program is GNU ld.  I'd rather use --version,
2907       # but apparently some GNU ld's only accept -v.
2908       # Break only if it was the GNU/non-GNU ld that we prefer.
2909       if "$acl_cv_path_LD" -v 2>&1 < /dev/null | egrep '(GNU|with BFD)' > /dev/null; then
2910         test "$with_gnu_ld" != no && break
2911       else
2912         test "$with_gnu_ld" != yes && break
2913       fi
2914     fi
2915   done
2916   IFS="$ac_save_ifs"
2917 else
2918   acl_cv_path_LD="$LD" # Let the user override the test with a path.
2919 fi])
2920 LD="$acl_cv_path_LD"
2921 if test -n "$LD"; then
2922   AC_MSG_RESULT($LD)
2923 else
2924   AC_MSG_RESULT(no)
2925 fi
2926 test -z "$LD" && AC_MSG_ERROR([no acceptable ld found in \$PATH])
2927 AC_LIB_PROG_LD_GNU
2928 ])
2929 # lib-link.m4 serial 4 (gettext-0.12)
2930 dnl Copyright (C) 2001-2003 Free Software Foundation, Inc.
2931 dnl This file is free software, distributed under the terms of the GNU
2932 dnl General Public License.  As a special exception to the GNU General
2933 dnl Public License, this file may be distributed as part of a program
2934 dnl that contains a configuration script generated by Autoconf, under
2935 dnl the same distribution terms as the rest of that program.
2936
2937 dnl From Bruno Haible.
2938
2939 dnl AC_LIB_LINKFLAGS(name [, dependencies]) searches for libname and
2940 dnl the libraries corresponding to explicit and implicit dependencies.
2941 dnl Sets and AC_SUBSTs the LIB${NAME} and LTLIB${NAME} variables and
2942 dnl augments the CPPFLAGS variable.
2943 AC_DEFUN([AC_LIB_LINKFLAGS],
2944 [
2945   AC_REQUIRE([AC_LIB_PREPARE_PREFIX])
2946   AC_REQUIRE([AC_LIB_RPATH])
2947   define([Name],[translit([$1],[./-], [___])])
2948   define([NAME],[translit([$1],[abcdefghijklmnopqrstuvwxyz./-],
2949                                [ABCDEFGHIJKLMNOPQRSTUVWXYZ___])])
2950   AC_CACHE_CHECK([how to link with lib[]$1], [ac_cv_lib[]Name[]_libs], [
2951     AC_LIB_LINKFLAGS_BODY([$1], [$2])
2952     ac_cv_lib[]Name[]_libs="$LIB[]NAME"
2953     ac_cv_lib[]Name[]_ltlibs="$LTLIB[]NAME"
2954     ac_cv_lib[]Name[]_cppflags="$INC[]NAME"
2955   ])
2956   LIB[]NAME="$ac_cv_lib[]Name[]_libs"
2957   LTLIB[]NAME="$ac_cv_lib[]Name[]_ltlibs"
2958   INC[]NAME="$ac_cv_lib[]Name[]_cppflags"
2959   AC_LIB_APPENDTOVAR([CPPFLAGS], [$INC]NAME)
2960   AC_SUBST([LIB]NAME)
2961   AC_SUBST([LTLIB]NAME)
2962   dnl Also set HAVE_LIB[]NAME so that AC_LIB_HAVE_LINKFLAGS can reuse the
2963   dnl results of this search when this library appears as a dependency.
2964   HAVE_LIB[]NAME=yes
2965   undefine([Name])
2966   undefine([NAME])
2967 ])
2968
2969 dnl AC_LIB_HAVE_LINKFLAGS(name, dependencies, includes, testcode)
2970 dnl searches for libname and the libraries corresponding to explicit and
2971 dnl implicit dependencies, together with the specified include files and
2972 dnl the ability to compile and link the specified testcode. If found, it
2973 dnl sets and AC_SUBSTs HAVE_LIB${NAME}=yes and the LIB${NAME} and
2974 dnl LTLIB${NAME} variables and augments the CPPFLAGS variable, and
2975 dnl #defines HAVE_LIB${NAME} to 1. Otherwise, it sets and AC_SUBSTs
2976 dnl HAVE_LIB${NAME}=no and LIB${NAME} and LTLIB${NAME} to empty.
2977 AC_DEFUN([AC_LIB_HAVE_LINKFLAGS],
2978 [
2979   AC_REQUIRE([AC_LIB_PREPARE_PREFIX])
2980   AC_REQUIRE([AC_LIB_RPATH])
2981   define([Name],[translit([$1],[./-], [___])])
2982   define([NAME],[translit([$1],[abcdefghijklmnopqrstuvwxyz./-],
2983                                [ABCDEFGHIJKLMNOPQRSTUVWXYZ___])])
2984
2985   dnl Search for lib[]Name and define LIB[]NAME, LTLIB[]NAME and INC[]NAME
2986   dnl accordingly.
2987   AC_LIB_LINKFLAGS_BODY([$1], [$2])
2988
2989   dnl Add $INC[]NAME to CPPFLAGS before performing the following checks,
2990   dnl because if the user has installed lib[]Name and not disabled its use
2991   dnl via --without-lib[]Name-prefix, he wants to use it.
2992   ac_save_CPPFLAGS="$CPPFLAGS"
2993   AC_LIB_APPENDTOVAR([CPPFLAGS], [$INC]NAME)
2994
2995   AC_CACHE_CHECK([for lib[]$1], [ac_cv_lib[]Name], [
2996     ac_save_LIBS="$LIBS"
2997     LIBS="$LIBS $LIB[]NAME"
2998     AC_TRY_LINK([$3], [$4], [ac_cv_lib[]Name=yes], [ac_cv_lib[]Name=no])
2999     LIBS="$ac_save_LIBS"
3000   ])
3001   if test "$ac_cv_lib[]Name" = yes; then
3002     HAVE_LIB[]NAME=yes
3003     AC_DEFINE([HAVE_LIB]NAME, 1, [Define if you have the $1 library.])
3004     AC_MSG_CHECKING([how to link with lib[]$1])
3005     AC_MSG_RESULT([$LIB[]NAME])
3006   else
3007     HAVE_LIB[]NAME=no
3008     dnl If $LIB[]NAME didn't lead to a usable library, we don't need
3009     dnl $INC[]NAME either.
3010     CPPFLAGS="$ac_save_CPPFLAGS"
3011     LIB[]NAME=
3012     LTLIB[]NAME=
3013   fi
3014   AC_SUBST([HAVE_LIB]NAME)
3015   AC_SUBST([LIB]NAME)
3016   AC_SUBST([LTLIB]NAME)
3017   undefine([Name])
3018   undefine([NAME])
3019 ])
3020
3021 dnl Determine the platform dependent parameters needed to use rpath:
3022 dnl libext, shlibext, hardcode_libdir_flag_spec, hardcode_libdir_separator,
3023 dnl hardcode_direct, hardcode_minus_L.
3024 AC_DEFUN([AC_LIB_RPATH],
3025 [
3026   AC_REQUIRE([AC_PROG_CC])                dnl we use $CC, $GCC, $LDFLAGS
3027   AC_REQUIRE([AC_LIB_PROG_LD])            dnl we use $LD, $with_gnu_ld
3028   AC_REQUIRE([AC_CANONICAL_HOST])         dnl we use $host
3029   AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT]) dnl we use $ac_aux_dir
3030   AC_CACHE_CHECK([for shared library run path origin], acl_cv_rpath, [
3031     CC="$CC" GCC="$GCC" LDFLAGS="$LDFLAGS" LD="$LD" with_gnu_ld="$with_gnu_ld" \
3032     ${CONFIG_SHELL-/bin/sh} "$ac_aux_dir/config.rpath" "$host" > conftest.sh
3033     . ./conftest.sh
3034     rm -f ./conftest.sh
3035     acl_cv_rpath=done
3036   ])
3037   wl="$acl_cv_wl"
3038   libext="$acl_cv_libext"
3039   shlibext="$acl_cv_shlibext"
3040   hardcode_libdir_flag_spec="$acl_cv_hardcode_libdir_flag_spec"
3041   hardcode_libdir_separator="$acl_cv_hardcode_libdir_separator"
3042   hardcode_direct="$acl_cv_hardcode_direct"
3043   hardcode_minus_L="$acl_cv_hardcode_minus_L"
3044   dnl Determine whether the user wants rpath handling at all.
3045   AC_ARG_ENABLE(rpath,
3046     [  --disable-rpath         do not hardcode runtime library paths],
3047     :, enable_rpath=yes)
3048 ])
3049
3050 dnl AC_LIB_LINKFLAGS_BODY(name [, dependencies]) searches for libname and
3051 dnl the libraries corresponding to explicit and implicit dependencies.
3052 dnl Sets the LIB${NAME}, LTLIB${NAME} and INC${NAME} variables.
3053 AC_DEFUN([AC_LIB_LINKFLAGS_BODY],
3054 [
3055   define([NAME],[translit([$1],[abcdefghijklmnopqrstuvwxyz./-],
3056                                [ABCDEFGHIJKLMNOPQRSTUVWXYZ___])])
3057   dnl By default, look in $includedir and $libdir.
3058   use_additional=yes
3059   AC_LIB_WITH_FINAL_PREFIX([
3060     eval additional_includedir=\"$includedir\"
3061     eval additional_libdir=\"$libdir\"
3062   ])
3063   AC_LIB_ARG_WITH([lib$1-prefix],
3064 [  --with-lib$1-prefix[=DIR]  search for lib$1 in DIR/include and DIR/lib
3065   --without-lib$1-prefix     don't search for lib$1 in includedir and libdir],
3066 [
3067     if test "X$withval" = "Xno"; then
3068       use_additional=no
3069     else
3070       if test "X$withval" = "X"; then
3071         AC_LIB_WITH_FINAL_PREFIX([
3072           eval additional_includedir=\"$includedir\"
3073           eval additional_libdir=\"$libdir\"
3074         ])
3075       else
3076         additional_includedir="$withval/include"
3077         additional_libdir="$withval/lib"
3078       fi
3079     fi
3080 ])
3081   dnl Search the library and its dependencies in $additional_libdir and
3082   dnl $LDFLAGS. Using breadth-first-seach.
3083   LIB[]NAME=
3084   LTLIB[]NAME=
3085   INC[]NAME=
3086   rpathdirs=
3087   ltrpathdirs=
3088   names_already_handled=
3089   names_next_round='$1 $2'
3090   while test -n "$names_next_round"; do
3091     names_this_round="$names_next_round"
3092     names_next_round=
3093     for name in $names_this_round; do
3094       already_handled=
3095       for n in $names_already_handled; do
3096         if test "$n" = "$name"; then
3097           already_handled=yes
3098           break
3099         fi
3100       done
3101       if test -z "$already_handled"; then
3102         names_already_handled="$names_already_handled $name"
3103         dnl See if it was already located by an earlier AC_LIB_LINKFLAGS
3104         dnl or AC_LIB_HAVE_LINKFLAGS call.
3105         uppername=`echo "$name" | sed -e 'y|abcdefghijklmnopqrstuvwxyz./-|ABCDEFGHIJKLMNOPQRSTUVWXYZ___|'`
3106         eval value=\"\$HAVE_LIB$uppername\"
3107         if test -n "$value"; then
3108           if test "$value" = yes; then
3109             eval value=\"\$LIB$uppername\"
3110             test -z "$value" || LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$value"
3111             eval value=\"\$LTLIB$uppername\"
3112             test -z "$value" || LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }$value"
3113           else
3114             dnl An earlier call to AC_LIB_HAVE_LINKFLAGS has determined
3115             dnl that this library doesn't exist. So just drop it.
3116             :
3117           fi
3118         else
3119           dnl Search the library lib$name in $additional_libdir and $LDFLAGS
3120           dnl and the already constructed $LIBNAME/$LTLIBNAME.
3121           found_dir=
3122           found_la=
3123           found_so=
3124           found_a=
3125           if test $use_additional = yes; then
3126             if test "X$prefer_shared" = "Xyes" && test -n "$shlibext" && test -f "$additional_libdir/lib$name.$shlibext"; then
3127               found_dir="$additional_libdir"
3128               found_so="$additional_libdir/lib$name.$shlibext"
3129               if test -f "$additional_libdir/lib$name.la"; then
3130                 found_la="$additional_libdir/lib$name.la"
3131               fi
3132             else
3133               if test -f "$additional_libdir/lib$name.$libext"; then
3134                 found_dir="$additional_libdir"
3135                 found_a="$additional_libdir/lib$name.$libext"
3136                 if test -f "$additional_libdir/lib$name.la"; then
3137                   found_la="$additional_libdir/lib$name.la"
3138                 fi
3139               fi
3140             fi
3141           fi
3142           if test "X$found_dir" = "X"; then
3143             for x in $LDFLAGS $LTLIB[]NAME; do
3144               AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
3145               case "$x" in
3146                 -L*)
3147                   dir=`echo "X$x" | sed -e 's/^X-L//'`
3148                   if test "X$prefer_shared" = "Xyes" && test -n "$shlibext" && test -f "$dir/lib$name.$shlibext"; then
3149                     found_dir="$dir"
3150                     found_so="$dir/lib$name.$shlibext"
3151                     if test -f "$dir/lib$name.la"; then
3152                       found_la="$dir/lib$name.la"
3153                     fi
3154                   else
3155                     if test -f "$dir/lib$name.$libext"; then
3156                       found_dir="$dir"
3157                       found_a="$dir/lib$name.$libext"
3158                       if test -f "$dir/lib$name.la"; then
3159                         found_la="$dir/lib$name.la"
3160                       fi
3161                     fi
3162                   fi
3163                   ;;
3164               esac
3165               if test "X$found_dir" != "X"; then
3166                 break
3167               fi
3168             done
3169           fi
3170           if test "X$found_dir" != "X"; then
3171             dnl Found the library.
3172             LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-L$found_dir -l$name"
3173             if test "X$found_so" != "X"; then
3174               dnl Linking with a shared library. We attempt to hardcode its
3175               dnl directory into the executable's runpath, unless it's the
3176               dnl standard /usr/lib.
3177               if test "$enable_rpath" = no || test "X$found_dir" = "X/usr/lib"; then
3178                 dnl No hardcoding is needed.
3179                 LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so"
3180               else
3181                 dnl Use an explicit option to hardcode DIR into the resulting
3182                 dnl binary.
3183                 dnl Potentially add DIR to ltrpathdirs.
3184                 dnl The ltrpathdirs will be appended to $LTLIBNAME at the end.
3185                 haveit=
3186                 for x in $ltrpathdirs; do
3187                   if test "X$x" = "X$found_dir"; then
3188                     haveit=yes
3189                     break
3190                   fi
3191                 done
3192                 if test -z "$haveit"; then
3193                   ltrpathdirs="$ltrpathdirs $found_dir"
3194                 fi
3195                 dnl The hardcoding into $LIBNAME is system dependent.
3196                 if test "$hardcode_direct" = yes; then
3197                   dnl Using DIR/libNAME.so during linking hardcodes DIR into the
3198                   dnl resulting binary.
3199                   LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so"
3200                 else
3201                   if test -n "$hardcode_libdir_flag_spec" && test "$hardcode_minus_L" = no; then
3202                     dnl Use an explicit option to hardcode DIR into the resulting
3203                     dnl binary.
3204                     LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so"
3205                     dnl Potentially add DIR to rpathdirs.
3206                     dnl The rpathdirs will be appended to $LIBNAME at the end.
3207                     haveit=
3208                     for x in $rpathdirs; do
3209                       if test "X$x" = "X$found_dir"; then
3210                         haveit=yes
3211                         break
3212                       fi
3213                     done
3214                     if test -z "$haveit"; then
3215                       rpathdirs="$rpathdirs $found_dir"
3216                     fi
3217                   else
3218                     dnl Rely on "-L$found_dir".
3219                     dnl But don't add it if it's already contained in the LDFLAGS
3220                     dnl or the already constructed $LIBNAME
3221                     haveit=
3222                     for x in $LDFLAGS $LIB[]NAME; do
3223                       AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
3224                       if test "X$x" = "X-L$found_dir"; then
3225                         haveit=yes
3226                         break
3227                       fi
3228                     done
3229                     if test -z "$haveit"; then
3230                       LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-L$found_dir"
3231                     fi
3232                     if test "$hardcode_minus_L" != no; then
3233                       dnl FIXME: Not sure whether we should use
3234                       dnl "-L$found_dir -l$name" or "-L$found_dir $found_so"
3235                       dnl here.
3236                       LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so"
3237                     else
3238                       dnl We cannot use $hardcode_runpath_var and LD_RUN_PATH
3239                       dnl here, because this doesn't fit in flags passed to the
3240                       dnl compiler. So give up. No hardcoding. This affects only
3241                       dnl very old systems.
3242                       dnl FIXME: Not sure whether we should use
3243                       dnl "-L$found_dir -l$name" or "-L$found_dir $found_so"
3244                       dnl here.
3245                       LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-l$name"
3246                     fi
3247                   fi
3248                 fi
3249               fi
3250             else
3251               if test "X$found_a" != "X"; then
3252                 dnl Linking with a static library.
3253                 LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_a"
3254               else
3255                 dnl We shouldn't come here, but anyway it's good to have a
3256                 dnl fallback.
3257                 LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-L$found_dir -l$name"
3258               fi
3259             fi
3260             dnl Assume the include files are nearby.
3261             additional_includedir=
3262             case "$found_dir" in
3263               */lib | */lib/)
3264                 basedir=`echo "X$found_dir" | sed -e 's,^X,,' -e 's,/lib/*$,,'`
3265                 additional_includedir="$basedir/include"
3266                 ;;
3267             esac
3268             if test "X$additional_includedir" != "X"; then
3269               dnl Potentially add $additional_includedir to $INCNAME.
3270               dnl But don't add it
3271               dnl   1. if it's the standard /usr/include,
3272               dnl   2. if it's /usr/local/include and we are using GCC on Linux,
3273               dnl   3. if it's already present in $CPPFLAGS or the already
3274               dnl      constructed $INCNAME,
3275               dnl   4. if it doesn't exist as a directory.
3276               if test "X$additional_includedir" != "X/usr/include"; then
3277                 haveit=
3278                 if test "X$additional_includedir" = "X/usr/local/include"; then
3279                   if test -n "$GCC"; then
3280                     case $host_os in
3281                       linux*) haveit=yes;;
3282                     esac
3283                   fi
3284                 fi
3285                 if test -z "$haveit"; then
3286                   for x in $CPPFLAGS $INC[]NAME; do
3287                     AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
3288                     if test "X$x" = "X-I$additional_includedir"; then
3289                       haveit=yes
3290                       break
3291                     fi
3292                   done
3293                   if test -z "$haveit"; then
3294                     if test -d "$additional_includedir"; then
3295                       dnl Really add $additional_includedir to $INCNAME.
3296                       INC[]NAME="${INC[]NAME}${INC[]NAME:+ }-I$additional_includedir"
3297                     fi
3298                   fi
3299                 fi
3300               fi
3301             fi
3302             dnl Look for dependencies.
3303             if test -n "$found_la"; then
3304               dnl Read the .la file. It defines the variables
3305               dnl dlname, library_names, old_library, dependency_libs, current,
3306               dnl age, revision, installed, dlopen, dlpreopen, libdir.
3307               save_libdir="$libdir"
3308               case "$found_la" in
3309                 */* | *\\*) . "$found_la" ;;
3310                 *) . "./$found_la" ;;
3311               esac
3312               libdir="$save_libdir"
3313               dnl We use only dependency_libs.
3314               for dep in $dependency_libs; do
3315                 case "$dep" in
3316                   -L*)
3317                     additional_libdir=`echo "X$dep" | sed -e 's/^X-L//'`
3318                     dnl Potentially add $additional_libdir to $LIBNAME and $LTLIBNAME.
3319                     dnl But don't add it
3320                     dnl   1. if it's the standard /usr/lib,
3321                     dnl   2. if it's /usr/local/lib and we are using GCC on Linux,
3322                     dnl   3. if it's already present in $LDFLAGS or the already
3323                     dnl      constructed $LIBNAME,
3324                     dnl   4. if it doesn't exist as a directory.
3325                     if test "X$additional_libdir" != "X/usr/lib"; then
3326                       haveit=
3327                       if test "X$additional_libdir" = "X/usr/local/lib"; then
3328                         if test -n "$GCC"; then
3329                           case $host_os in
3330                             linux*) haveit=yes;;
3331                           esac
3332                         fi
3333                       fi
3334                       if test -z "$haveit"; then
3335                         haveit=
3336                         for x in $LDFLAGS $LIB[]NAME; do
3337                           AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
3338                           if test "X$x" = "X-L$additional_libdir"; then
3339                             haveit=yes
3340                             break
3341                           fi
3342                         done
3343                         if test -z "$haveit"; then
3344                           if test -d "$additional_libdir"; then
3345                             dnl Really add $additional_libdir to $LIBNAME.
3346                             LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-L$additional_libdir"
3347                           fi
3348                         fi
3349                         haveit=
3350                         for x in $LDFLAGS $LTLIB[]NAME; do
3351                           AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
3352                           if test "X$x" = "X-L$additional_libdir"; then
3353                             haveit=yes
3354                             break
3355                           fi
3356                         done
3357                         if test -z "$haveit"; then
3358                           if test -d "$additional_libdir"; then
3359                             dnl Really add $additional_libdir to $LTLIBNAME.
3360                             LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-L$additional_libdir"
3361                           fi
3362                         fi
3363                       fi
3364                     fi
3365                     ;;
3366                   -R*)
3367                     dir=`echo "X$dep" | sed -e 's/^X-R//'`
3368                     if test "$enable_rpath" != no; then
3369                       dnl Potentially add DIR to rpathdirs.
3370                       dnl The rpathdirs will be appended to $LIBNAME at the end.
3371                       haveit=
3372                       for x in $rpathdirs; do
3373                         if test "X$x" = "X$dir"; then
3374                           haveit=yes
3375                           break
3376                         fi
3377                       done
3378                       if test -z "$haveit"; then
3379                         rpathdirs="$rpathdirs $dir"
3380                       fi
3381                       dnl Potentially add DIR to ltrpathdirs.
3382                       dnl The ltrpathdirs will be appended to $LTLIBNAME at the end.
3383                       haveit=
3384                       for x in $ltrpathdirs; do
3385                         if test "X$x" = "X$dir"; then
3386                           haveit=yes
3387                           break
3388                         fi
3389                       done
3390                       if test -z "$haveit"; then
3391                         ltrpathdirs="$ltrpathdirs $dir"
3392                       fi
3393                     fi
3394                     ;;
3395                   -l*)
3396                     dnl Handle this in the next round.
3397                     names_next_round="$names_next_round "`echo "X$dep" | sed -e 's/^X-l//'`
3398                     ;;
3399                   *.la)
3400                     dnl Handle this in the next round. Throw away the .la's
3401                     dnl directory; it is already contained in a preceding -L
3402                     dnl option.
3403                     names_next_round="$names_next_round "`echo "X$dep" | sed -e 's,^X.*/,,' -e 's,^lib,,' -e 's,\.la$,,'`
3404                     ;;
3405                   *)
3406                     dnl Most likely an immediate library name.
3407                     LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$dep"
3408                     LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }$dep"
3409                     ;;
3410                 esac
3411               done
3412             fi
3413           else
3414             dnl Didn't find the library; assume it is in the system directories
3415             dnl known to the linker and runtime loader. (All the system
3416             dnl directories known to the linker should also be known to the
3417             dnl runtime loader, otherwise the system is severely misconfigured.)
3418             LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-l$name"
3419             LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-l$name"
3420           fi
3421         fi
3422       fi
3423     done
3424   done
3425   if test "X$rpathdirs" != "X"; then
3426     if test -n "$hardcode_libdir_separator"; then
3427       dnl Weird platform: only the last -rpath option counts, the user must
3428       dnl pass all path elements in one option. We can arrange that for a
3429       dnl single library, but not when more than one $LIBNAMEs are used.
3430       alldirs=
3431       for found_dir in $rpathdirs; do
3432         alldirs="${alldirs}${alldirs:+$hardcode_libdir_separator}$found_dir"
3433       done
3434       dnl Note: hardcode_libdir_flag_spec uses $libdir and $wl.
3435       acl_save_libdir="$libdir"
3436       libdir="$alldirs"
3437       eval flag=\"$hardcode_libdir_flag_spec\"
3438       libdir="$acl_save_libdir"
3439       LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$flag"
3440     else
3441       dnl The -rpath options are cumulative.
3442       for found_dir in $rpathdirs; do
3443         acl_save_libdir="$libdir"
3444         libdir="$found_dir"
3445         eval flag=\"$hardcode_libdir_flag_spec\"
3446         libdir="$acl_save_libdir"
3447         LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$flag"
3448       done
3449     fi
3450   fi
3451   if test "X$ltrpathdirs" != "X"; then
3452     dnl When using libtool, the option that works for both libraries and
3453     dnl executables is -R. The -R options are cumulative.
3454     for found_dir in $ltrpathdirs; do
3455       LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-R$found_dir"
3456     done
3457   fi
3458 ])
3459
3460 dnl AC_LIB_APPENDTOVAR(VAR, CONTENTS) appends the elements of CONTENTS to VAR,
3461 dnl unless already present in VAR.
3462 dnl Works only for CPPFLAGS, not for LIB* variables because that sometimes
3463 dnl contains two or three consecutive elements that belong together.
3464 AC_DEFUN([AC_LIB_APPENDTOVAR],
3465 [
3466   for element in [$2]; do
3467     haveit=
3468     for x in $[$1]; do
3469       AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
3470       if test "X$x" = "X$element"; then
3471         haveit=yes
3472         break
3473       fi
3474     done
3475     if test -z "$haveit"; then
3476       [$1]="${[$1]}${[$1]:+ }$element"
3477     fi
3478   done
3479 ])
3480 # lib-prefix.m4 serial 2 (gettext-0.12)
3481 dnl Copyright (C) 2001-2003 Free Software Foundation, Inc.
3482 dnl This file is free software, distributed under the terms of the GNU
3483 dnl General Public License.  As a special exception to the GNU General
3484 dnl Public License, this file may be distributed as part of a program
3485 dnl that contains a configuration script generated by Autoconf, under
3486 dnl the same distribution terms as the rest of that program.
3487
3488 dnl From Bruno Haible.
3489
3490 dnl AC_LIB_ARG_WITH is synonymous to AC_ARG_WITH in autoconf-2.13, and
3491 dnl similar to AC_ARG_WITH in autoconf 2.52...2.57 except that is doesn't
3492 dnl require excessive bracketing.
3493 ifdef([AC_HELP_STRING],
3494 [AC_DEFUN([AC_LIB_ARG_WITH], [AC_ARG_WITH([$1],[[$2]],[$3],[$4])])],
3495 [AC_DEFUN([AC_LIB_ARG_WITH], [AC_ARG_WITH([$1],[$2],[$3],[$4])])])
3496
3497 dnl AC_LIB_PREFIX adds to the CPPFLAGS and LDFLAGS the flags that are needed
3498 dnl to access previously installed libraries. The basic assumption is that
3499 dnl a user will want packages to use other packages he previously installed
3500 dnl with the same --prefix option.
3501 dnl This macro is not needed if only AC_LIB_LINKFLAGS is used to locate
3502 dnl libraries, but is otherwise very convenient.
3503 AC_DEFUN([AC_LIB_PREFIX],
3504 [
3505   AC_BEFORE([$0], [AC_LIB_LINKFLAGS])
3506   AC_REQUIRE([AC_PROG_CC])
3507   AC_REQUIRE([AC_CANONICAL_HOST])
3508   AC_REQUIRE([AC_LIB_PREPARE_PREFIX])
3509   dnl By default, look in $includedir and $libdir.
3510   use_additional=yes
3511   AC_LIB_WITH_FINAL_PREFIX([
3512     eval additional_includedir=\"$includedir\"
3513     eval additional_libdir=\"$libdir\"
3514   ])
3515   AC_LIB_ARG_WITH([lib-prefix],
3516 [  --with-lib-prefix[=DIR] search for libraries in DIR/include and DIR/lib
3517   --without-lib-prefix    don't search for libraries in includedir and libdir],
3518 [
3519     if test "X$withval" = "Xno"; then
3520       use_additional=no
3521     else
3522       if test "X$withval" = "X"; then
3523         AC_LIB_WITH_FINAL_PREFIX([
3524           eval additional_includedir=\"$includedir\"
3525           eval additional_libdir=\"$libdir\"
3526         ])
3527       else
3528         additional_includedir="$withval/include"
3529         additional_libdir="$withval/lib"
3530       fi
3531     fi
3532 ])
3533   if test $use_additional = yes; then
3534     dnl Potentially add $additional_includedir to $CPPFLAGS.
3535     dnl But don't add it
3536     dnl   1. if it's the standard /usr/include,
3537     dnl   2. if it's already present in $CPPFLAGS,
3538     dnl   3. if it's /usr/local/include and we are using GCC on Linux,
3539     dnl   4. if it doesn't exist as a directory.
3540     if test "X$additional_includedir" != "X/usr/include"; then
3541       haveit=
3542       for x in $CPPFLAGS; do
3543         AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
3544         if test "X$x" = "X-I$additional_includedir"; then
3545           haveit=yes
3546           break
3547         fi
3548       done
3549       if test -z "$haveit"; then
3550         if test "X$additional_includedir" = "X/usr/local/include"; then
3551           if test -n "$GCC"; then
3552             case $host_os in
3553               linux*) haveit=yes;;
3554             esac
3555           fi
3556         fi
3557         if test -z "$haveit"; then
3558           if test -d "$additional_includedir"; then
3559             dnl Really add $additional_includedir to $CPPFLAGS.
3560             CPPFLAGS="${CPPFLAGS}${CPPFLAGS:+ }-I$additional_includedir"
3561           fi
3562         fi
3563       fi
3564     fi
3565     dnl Potentially add $additional_libdir to $LDFLAGS.
3566     dnl But don't add it
3567     dnl   1. if it's the standard /usr/lib,
3568     dnl   2. if it's already present in $LDFLAGS,
3569     dnl   3. if it's /usr/local/lib and we are using GCC on Linux,
3570     dnl   4. if it doesn't exist as a directory.
3571     if test "X$additional_libdir" != "X/usr/lib"; then
3572       haveit=
3573       for x in $LDFLAGS; do
3574         AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
3575         if test "X$x" = "X-L$additional_libdir"; then
3576           haveit=yes
3577           break
3578         fi
3579       done
3580       if test -z "$haveit"; then
3581         if test "X$additional_libdir" = "X/usr/local/lib"; then
3582           if test -n "$GCC"; then
3583             case $host_os in
3584               linux*) haveit=yes;;
3585             esac
3586           fi
3587         fi
3588         if test -z "$haveit"; then
3589           if test -d "$additional_libdir"; then
3590             dnl Really add $additional_libdir to $LDFLAGS.
3591             LDFLAGS="${LDFLAGS}${LDFLAGS:+ }-L$additional_libdir"
3592           fi
3593         fi
3594       fi
3595     fi
3596   fi
3597 ])
3598
3599 dnl AC_LIB_PREPARE_PREFIX creates variables acl_final_prefix,
3600 dnl acl_final_exec_prefix, containing the values to which $prefix and
3601 dnl $exec_prefix will expand at the end of the configure script.
3602 AC_DEFUN([AC_LIB_PREPARE_PREFIX],
3603 [
3604   dnl Unfortunately, prefix and exec_prefix get only finally determined
3605   dnl at the end of configure.
3606   if test "X$prefix" = "XNONE"; then
3607     acl_final_prefix="$ac_default_prefix"
3608   else
3609     acl_final_prefix="$prefix"
3610   fi
3611   if test "X$exec_prefix" = "XNONE"; then
3612     acl_final_exec_prefix='${prefix}'
3613   else
3614     acl_final_exec_prefix="$exec_prefix"
3615   fi
3616   acl_save_prefix="$prefix"
3617   prefix="$acl_final_prefix"
3618   eval acl_final_exec_prefix=\"$acl_final_exec_prefix\"
3619   prefix="$acl_save_prefix"
3620 ])
3621
3622 dnl AC_LIB_WITH_FINAL_PREFIX([statement]) evaluates statement, with the
3623 dnl variables prefix and exec_prefix bound to the values they will have
3624 dnl at the end of the configure script.
3625 AC_DEFUN([AC_LIB_WITH_FINAL_PREFIX],
3626 [
3627   acl_save_prefix="$prefix"
3628   prefix="$acl_final_prefix"
3629   acl_save_exec_prefix="$exec_prefix"
3630   exec_prefix="$acl_final_exec_prefix"
3631   $1
3632   exec_prefix="$acl_save_exec_prefix"
3633   prefix="$acl_save_prefix"
3634 ])
3635 # nls.m4 serial 1 (gettext-0.12)
3636 dnl Copyright (C) 1995-2003 Free Software Foundation, Inc.
3637 dnl This file is free software, distributed under the terms of the GNU
3638 dnl General Public License.  As a special exception to the GNU General
3639 dnl Public License, this file may be distributed as part of a program
3640 dnl that contains a configuration script generated by Autoconf, under
3641 dnl the same distribution terms as the rest of that program.
3642 dnl
3643 dnl This file can can be used in projects which are not available under
3644 dnl the GNU General Public License or the GNU Library General Public
3645 dnl License but which still want to provide support for the GNU gettext
3646 dnl functionality.
3647 dnl Please note that the actual code of the GNU gettext library is covered
3648 dnl by the GNU Library General Public License, and the rest of the GNU
3649 dnl gettext package package is covered by the GNU General Public License.
3650 dnl They are *not* in the public domain.
3651
3652 dnl Authors:
3653 dnl   Ulrich Drepper <drepper@cygnus.com>, 1995-2000.
3654 dnl   Bruno Haible <haible@clisp.cons.org>, 2000-2003.
3655
3656 AC_DEFUN([AM_NLS],
3657 [
3658   AC_MSG_CHECKING([whether NLS is requested])
3659   dnl Default is enabled NLS
3660   AC_ARG_ENABLE(nls,
3661     [  --disable-nls           do not use Native Language Support],
3662     USE_NLS=$enableval, USE_NLS=yes)
3663   AC_MSG_RESULT($USE_NLS)
3664   AC_SUBST(USE_NLS)
3665 ])
3666
3667 AC_DEFUN([AM_MKINSTALLDIRS],
3668 [
3669   dnl If the AC_CONFIG_AUX_DIR macro for autoconf is used we possibly
3670   dnl find the mkinstalldirs script in another subdir but $(top_srcdir).
3671   dnl Try to locate it.
3672   MKINSTALLDIRS=
3673   if test -n "$ac_aux_dir"; then
3674     case "$ac_aux_dir" in
3675       /*) MKINSTALLDIRS="$ac_aux_dir/mkinstalldirs" ;;
3676       *) MKINSTALLDIRS="\$(top_builddir)/$ac_aux_dir/mkinstalldirs" ;;
3677     esac
3678   fi
3679   if test -z "$MKINSTALLDIRS"; then
3680     MKINSTALLDIRS="\$(top_srcdir)/mkinstalldirs"
3681   fi
3682   AC_SUBST(MKINSTALLDIRS)
3683 ])
3684 # po.m4 serial 1 (gettext-0.12)
3685 dnl Copyright (C) 1995-2003 Free Software Foundation, Inc.
3686 dnl This file is free software, distributed under the terms of the GNU
3687 dnl General Public License.  As a special exception to the GNU General
3688 dnl Public License, this file may be distributed as part of a program
3689 dnl that contains a configuration script generated by Autoconf, under
3690 dnl the same distribution terms as the rest of that program.
3691 dnl
3692 dnl This file can can be used in projects which are not available under
3693 dnl the GNU General Public License or the GNU Library General Public
3694 dnl License but which still want to provide support for the GNU gettext
3695 dnl functionality.
3696 dnl Please note that the actual code of the GNU gettext library is covered
3697 dnl by the GNU Library General Public License, and the rest of the GNU
3698 dnl gettext package package is covered by the GNU General Public License.
3699 dnl They are *not* in the public domain.
3700
3701 dnl Authors:
3702 dnl   Ulrich Drepper <drepper@cygnus.com>, 1995-2000.
3703 dnl   Bruno Haible <haible@clisp.cons.org>, 2000-2003.
3704
3705 dnl Checks for all prerequisites of the po subdirectory.
3706 AC_DEFUN([AM_PO_SUBDIRS],
3707 [
3708   AC_REQUIRE([AC_PROG_MAKE_SET])dnl
3709   AC_REQUIRE([AC_PROG_INSTALL])dnl
3710   AC_REQUIRE([AM_MKINSTALLDIRS])dnl
3711   AC_REQUIRE([AM_NLS])dnl
3712
3713   dnl Perform the following tests also if --disable-nls has been given,
3714   dnl because they are needed for "make dist" to work.
3715
3716   dnl Search for GNU msgfmt in the PATH.
3717   dnl The first test excludes Solaris msgfmt and early GNU msgfmt versions.
3718   dnl The second test excludes FreeBSD msgfmt.
3719   AM_PATH_PROG_WITH_TEST(MSGFMT, msgfmt,
3720     [$ac_dir/$ac_word --statistics /dev/null >/dev/null 2>&1 &&
3721      (if $ac_dir/$ac_word --statistics /dev/null 2>&1 >/dev/null | grep usage >/dev/null; then exit 1; else exit 0; fi)],
3722     :)
3723   AC_PATH_PROG(GMSGFMT, gmsgfmt, $MSGFMT)
3724
3725   dnl Search for GNU xgettext 0.12 or newer in the PATH.
3726   dnl The first test excludes Solaris xgettext and early GNU xgettext versions.
3727   dnl The second test excludes FreeBSD xgettext.
3728   AM_PATH_PROG_WITH_TEST(XGETTEXT, xgettext,
3729     [$ac_dir/$ac_word --omit-header --copyright-holder= --msgid-bugs-address= /dev/null >/dev/null 2>&1 &&
3730      (if $ac_dir/$ac_word --omit-header --copyright-holder= --msgid-bugs-address= /dev/null 2>&1 >/dev/null | grep usage >/dev/null; then exit 1; else exit 0; fi)],
3731     :)
3732   dnl Remove leftover from FreeBSD xgettext call.
3733   rm -f messages.po
3734
3735   dnl Search for GNU msgmerge 0.11 or newer in the PATH.
3736   AM_PATH_PROG_WITH_TEST(MSGMERGE, msgmerge,
3737     [$ac_dir/$ac_word --update -q /dev/null /dev/null >/dev/null 2>&1], :)
3738
3739   dnl This could go away some day; the PATH_PROG_WITH_TEST already does it.
3740   dnl Test whether we really found GNU msgfmt.
3741   if test "$GMSGFMT" != ":"; then
3742     dnl If it is no GNU msgfmt we define it as : so that the
3743     dnl Makefiles still can work.
3744     if $GMSGFMT --statistics /dev/null >/dev/null 2>&1 &&
3745        (if $GMSGFMT --statistics /dev/null 2>&1 >/dev/null | grep usage >/dev/null; then exit 1; else exit 0; fi); then
3746       : ;
3747     else
3748       GMSGFMT=`echo "$GMSGFMT" | sed -e 's,^.*/,,'`
3749       AC_MSG_RESULT(
3750         [found $GMSGFMT program is not GNU msgfmt; ignore it])
3751       GMSGFMT=":"
3752     fi
3753   fi
3754
3755   dnl This could go away some day; the PATH_PROG_WITH_TEST already does it.
3756   dnl Test whether we really found GNU xgettext.
3757   if test "$XGETTEXT" != ":"; then
3758     dnl If it is no GNU xgettext we define it as : so that the
3759     dnl Makefiles still can work.
3760     if $XGETTEXT --omit-header --copyright-holder= --msgid-bugs-address= /dev/null >/dev/null 2>&1 &&
3761        (if $XGETTEXT --omit-header --copyright-holder= --msgid-bugs-address= /dev/null 2>&1 >/dev/null | grep usage >/dev/null; then exit 1; else exit 0; fi); then
3762       : ;
3763     else
3764       AC_MSG_RESULT(
3765         [found xgettext program is not GNU xgettext; ignore it])
3766       XGETTEXT=":"
3767     fi
3768     dnl Remove leftover from FreeBSD xgettext call.
3769     rm -f messages.po
3770   fi
3771
3772   AC_OUTPUT_COMMANDS([
3773     for ac_file in $CONFIG_FILES; do
3774       # Support "outfile[:infile[:infile...]]"
3775       case "$ac_file" in
3776         *:*) ac_file=`echo "$ac_file"|sed 's%:.*%%'` ;;
3777       esac
3778       # PO directories have a Makefile.in generated from Makefile.in.in.
3779       case "$ac_file" in */Makefile.in)
3780         # Adjust a relative srcdir.
3781         ac_dir=`echo "$ac_file"|sed 's%/[^/][^/]*$%%'`
3782         ac_dir_suffix="/`echo "$ac_dir"|sed 's%^\./%%'`"
3783         ac_dots=`echo "$ac_dir_suffix"|sed 's%/[^/]*%../%g'`
3784         # In autoconf-2.13 it is called $ac_given_srcdir.
3785         # In autoconf-2.50 it is called $srcdir.
3786         test -n "$ac_given_srcdir" || ac_given_srcdir="$srcdir"
3787         case "$ac_given_srcdir" in
3788           .)  top_srcdir=`echo $ac_dots|sed 's%/$%%'` ;;
3789           /*) top_srcdir="$ac_given_srcdir" ;;
3790           *)  top_srcdir="$ac_dots$ac_given_srcdir" ;;
3791         esac
3792         if test -f "$ac_given_srcdir/$ac_dir/POTFILES.in"; then
3793           rm -f "$ac_dir/POTFILES"
3794           test -n "$as_me" && echo "$as_me: creating $ac_dir/POTFILES" || echo "creating $ac_dir/POTFILES"
3795           cat "$ac_given_srcdir/$ac_dir/POTFILES.in" | sed -e "/^#/d" -e "/^[   ]*\$/d" -e "s,.*,     $top_srcdir/& \\\\," | sed -e "\$s/\(.*\) \\\\/\1/" > "$ac_dir/POTFILES"
3796           POMAKEFILEDEPS="POTFILES.in"
3797           # ALL_LINGUAS, POFILES, GMOFILES, UPDATEPOFILES, DUMMYPOFILES depend
3798           # on $ac_dir but don't depend on user-specified configuration
3799           # parameters.
3800           if test -f "$ac_given_srcdir/$ac_dir/LINGUAS"; then
3801             # The LINGUAS file contains the set of available languages.
3802             if test -n "$OBSOLETE_ALL_LINGUAS"; then
3803               test -n "$as_me" && echo "$as_me: setting ALL_LINGUAS in configure.in is obsolete" || echo "setting ALL_LINGUAS in configure.in is obsolete"
3804             fi
3805             ALL_LINGUAS_=`sed -e "/^#/d" "$ac_given_srcdir/$ac_dir/LINGUAS"`
3806             # Hide the ALL_LINGUAS assigment from automake.
3807             eval 'ALL_LINGUAS''=$ALL_LINGUAS_'
3808             POMAKEFILEDEPS="$POMAKEFILEDEPS LINGUAS"
3809           else
3810             # The set of available languages was given in configure.in.
3811             eval 'ALL_LINGUAS''=$OBSOLETE_ALL_LINGUAS'
3812           fi
3813           case "$ac_given_srcdir" in
3814             .) srcdirpre= ;;
3815             *) srcdirpre='$(srcdir)/' ;;
3816           esac
3817           POFILES=
3818           GMOFILES=
3819           UPDATEPOFILES=
3820           DUMMYPOFILES=
3821           for lang in $ALL_LINGUAS; do
3822             POFILES="$POFILES $srcdirpre$lang.po"
3823             GMOFILES="$GMOFILES $srcdirpre$lang.gmo"
3824             UPDATEPOFILES="$UPDATEPOFILES $lang.po-update"
3825             DUMMYPOFILES="$DUMMYPOFILES $lang.nop"
3826           done
3827           # CATALOGS depends on both $ac_dir and the user's LINGUAS
3828           # environment variable.
3829           INST_LINGUAS=
3830           if test -n "$ALL_LINGUAS"; then
3831             for presentlang in $ALL_LINGUAS; do
3832               useit=no
3833               if test "%UNSET%" != "$LINGUAS"; then
3834                 desiredlanguages="$LINGUAS"
3835               else
3836                 desiredlanguages="$ALL_LINGUAS"
3837               fi
3838               for desiredlang in $desiredlanguages; do
3839                 # Use the presentlang catalog if desiredlang is
3840                 #   a. equal to presentlang, or
3841                 #   b. a variant of presentlang (because in this case,
3842                 #      presentlang can be used as a fallback for messages
3843                 #      which are not translated in the desiredlang catalog).
3844                 case "$desiredlang" in
3845                   "$presentlang"*) useit=yes;;
3846                 esac
3847               done
3848               if test $useit = yes; then
3849                 INST_LINGUAS="$INST_LINGUAS $presentlang"
3850               fi
3851             done
3852           fi
3853           CATALOGS=
3854           if test -n "$INST_LINGUAS"; then
3855             for lang in $INST_LINGUAS; do
3856               CATALOGS="$CATALOGS $lang.gmo"
3857             done
3858           fi
3859           test -n "$as_me" && echo "$as_me: creating $ac_dir/Makefile" || echo "creating $ac_dir/Makefile"
3860           sed -e "/^POTFILES =/r $ac_dir/POTFILES" -e "/^# Makevars/r $ac_given_srcdir/$ac_dir/Makevars" -e "s|@POFILES@|$POFILES|g" -e "s|@GMOFILES@|$GMOFILES|g" -e "s|@UPDATEPOFILES@|$UPDATEPOFILES|g" -e "s|@DUMMYPOFILES@|$DUMMYPOFILES|g" -e "s|@CATALOGS@|$CATALOGS|g" -e "s|@POMAKEFILEDEPS@|$POMAKEFILEDEPS|g" "$ac_dir/Makefile.in" > "$ac_dir/Makefile"
3861           for f in "$ac_given_srcdir/$ac_dir"/Rules-*; do
3862             if test -f "$f"; then
3863               case "$f" in
3864                 *.orig | *.bak | *~) ;;
3865                 *) cat "$f" >> "$ac_dir/Makefile" ;;
3866               esac
3867             fi
3868           done
3869         fi
3870         ;;
3871       esac
3872     done],
3873    [# Capture the value of obsolete ALL_LINGUAS because we need it to compute
3874     # POFILES, GMOFILES, UPDATEPOFILES, DUMMYPOFILES, CATALOGS. But hide it
3875     # from automake.
3876     eval 'OBSOLETE_ALL_LINGUAS''="$ALL_LINGUAS"'
3877     # Capture the value of LINGUAS because we need it to compute CATALOGS.
3878     LINGUAS="${LINGUAS-%UNSET%}"
3879    ])
3880 ])
3881 # progtest.m4 serial 3 (gettext-0.12)
3882 dnl Copyright (C) 1996-2003 Free Software Foundation, Inc.
3883 dnl This file is free software, distributed under the terms of the GNU
3884 dnl General Public License.  As a special exception to the GNU General
3885 dnl Public License, this file may be distributed as part of a program
3886 dnl that contains a configuration script generated by Autoconf, under
3887 dnl the same distribution terms as the rest of that program.
3888 dnl
3889 dnl This file can can be used in projects which are not available under
3890 dnl the GNU General Public License or the GNU Library General Public
3891 dnl License but which still want to provide support for the GNU gettext
3892 dnl functionality.
3893 dnl Please note that the actual code of the GNU gettext library is covered
3894 dnl by the GNU Library General Public License, and the rest of the GNU
3895 dnl gettext package package is covered by the GNU General Public License.
3896 dnl They are *not* in the public domain.
3897
3898 dnl Authors:
3899 dnl   Ulrich Drepper <drepper@cygnus.com>, 1996.
3900
3901 # Search path for a program which passes the given test.
3902
3903 dnl AM_PATH_PROG_WITH_TEST(VARIABLE, PROG-TO-CHECK-FOR,
3904 dnl   TEST-PERFORMED-ON-FOUND_PROGRAM [, VALUE-IF-NOT-FOUND [, PATH]])
3905 AC_DEFUN([AM_PATH_PROG_WITH_TEST],
3906 [
3907 # Prepare PATH_SEPARATOR.
3908 # The user is always right.
3909 if test "${PATH_SEPARATOR+set}" != set; then
3910   echo "#! /bin/sh" >conf$$.sh
3911   echo  "exit 0"   >>conf$$.sh
3912   chmod +x conf$$.sh
3913   if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then
3914     PATH_SEPARATOR=';'
3915   else
3916     PATH_SEPARATOR=:
3917   fi
3918   rm -f conf$$.sh
3919 fi
3920
3921 # Find out how to test for executable files. Don't use a zero-byte file,
3922 # as systems may use methods other than mode bits to determine executability.
3923 cat >conf$$.file <<_ASEOF
3924 #! /bin/sh
3925 exit 0
3926 _ASEOF
3927 chmod +x conf$$.file
3928 if test -x conf$$.file >/dev/null 2>&1; then
3929   ac_executable_p="test -x"
3930 else
3931   ac_executable_p="test -f"
3932 fi
3933 rm -f conf$$.file
3934
3935 # Extract the first word of "$2", so it can be a program name with args.
3936 set dummy $2; ac_word=[$]2
3937 AC_MSG_CHECKING([for $ac_word])
3938 AC_CACHE_VAL(ac_cv_path_$1,
3939 [case "[$]$1" in
3940   [[\\/]]* | ?:[[\\/]]*)
3941     ac_cv_path_$1="[$]$1" # Let the user override the test with a path.
3942     ;;
3943   *)
3944     ac_save_IFS="$IFS"; IFS=$PATH_SEPARATOR
3945     for ac_dir in ifelse([$5], , $PATH, [$5]); do
3946       IFS="$ac_save_IFS"
3947       test -z "$ac_dir" && ac_dir=.
3948       for ac_exec_ext in '' $ac_executable_extensions; do
3949         if $ac_executable_p "$ac_dir/$ac_word$ac_exec_ext"; then
3950           if [$3]; then
3951             ac_cv_path_$1="$ac_dir/$ac_word$ac_exec_ext"
3952             break 2
3953           fi
3954         fi
3955       done
3956     done
3957     IFS="$ac_save_IFS"
3958 dnl If no 4th arg is given, leave the cache variable unset,
3959 dnl so AC_PATH_PROGS will keep looking.
3960 ifelse([$4], , , [  test -z "[$]ac_cv_path_$1" && ac_cv_path_$1="$4"
3961 ])dnl
3962     ;;
3963 esac])dnl
3964 $1="$ac_cv_path_$1"
3965 if test ifelse([$4], , [-n "[$]$1"], ["[$]$1" != "$4"]); then
3966   AC_MSG_RESULT([$]$1)
3967 else
3968   AC_MSG_RESULT(no)
3969 fi
3970 AC_SUBST($1)dnl
3971 ])
3972 # stdint_h.m4 serial 3 (gettext-0.12)
3973 dnl Copyright (C) 1997-2003 Free Software Foundation, Inc.
3974 dnl This file is free software, distributed under the terms of the GNU
3975 dnl General Public License.  As a special exception to the GNU General
3976 dnl Public License, this file may be distributed as part of a program
3977 dnl that contains a configuration script generated by Autoconf, under
3978 dnl the same distribution terms as the rest of that program.
3979
3980 dnl From Paul Eggert.
3981
3982 # Define HAVE_STDINT_H_WITH_UINTMAX if <stdint.h> exists,
3983 # doesn't clash with <sys/types.h>, and declares uintmax_t.
3984
3985 AC_DEFUN([jm_AC_HEADER_STDINT_H],
3986 [
3987   AC_CACHE_CHECK([for stdint.h], jm_ac_cv_header_stdint_h,
3988   [AC_TRY_COMPILE(
3989     [#include <sys/types.h>
3990 #include <stdint.h>],
3991     [uintmax_t i = (uintmax_t) -1;],
3992     jm_ac_cv_header_stdint_h=yes,
3993     jm_ac_cv_header_stdint_h=no)])
3994   if test $jm_ac_cv_header_stdint_h = yes; then
3995     AC_DEFINE_UNQUOTED(HAVE_STDINT_H_WITH_UINTMAX, 1,
3996       [Define if <stdint.h> exists, doesn't clash with <sys/types.h>,
3997        and declares uintmax_t. ])
3998   fi
3999 ])
4000 # uintmax_t.m4 serial 7 (gettext-0.12)
4001 dnl Copyright (C) 1997-2003 Free Software Foundation, Inc.
4002 dnl This file is free software, distributed under the terms of the GNU
4003 dnl General Public License.  As a special exception to the GNU General
4004 dnl Public License, this file may be distributed as part of a program
4005 dnl that contains a configuration script generated by Autoconf, under
4006 dnl the same distribution terms as the rest of that program.
4007
4008 dnl From Paul Eggert.
4009
4010 AC_PREREQ(2.13)
4011
4012 # Define uintmax_t to 'unsigned long' or 'unsigned long long'
4013 # if it is not already defined in <stdint.h> or <inttypes.h>.
4014
4015 AC_DEFUN([jm_AC_TYPE_UINTMAX_T],
4016 [
4017   AC_REQUIRE([jm_AC_HEADER_INTTYPES_H])
4018   AC_REQUIRE([jm_AC_HEADER_STDINT_H])
4019   if test $jm_ac_cv_header_inttypes_h = no && test $jm_ac_cv_header_stdint_h = no; then
4020     AC_REQUIRE([jm_AC_TYPE_UNSIGNED_LONG_LONG])
4021     test $ac_cv_type_unsigned_long_long = yes \
4022       && ac_type='unsigned long long' \
4023       || ac_type='unsigned long'
4024     AC_DEFINE_UNQUOTED(uintmax_t, $ac_type,
4025       [Define to unsigned long or unsigned long long
4026        if <stdint.h> and <inttypes.h> don't define.])
4027   else
4028     AC_DEFINE(HAVE_UINTMAX_T, 1,
4029       [Define if you have the 'uintmax_t' type in <stdint.h> or <inttypes.h>.])
4030   fi
4031 ])
4032 # ulonglong.m4 serial 2 (fileutils-4.0.32, gettext-0.10.40)
4033 dnl Copyright (C) 1999-2002 Free Software Foundation, Inc.
4034 dnl This file is free software, distributed under the terms of the GNU
4035 dnl General Public License.  As a special exception to the GNU General
4036 dnl Public License, this file may be distributed as part of a program
4037 dnl that contains a configuration script generated by Autoconf, under
4038 dnl the same distribution terms as the rest of that program.
4039
4040 dnl From Paul Eggert.
4041
4042 AC_DEFUN([jm_AC_TYPE_UNSIGNED_LONG_LONG],
4043 [
4044   AC_CACHE_CHECK([for unsigned long long], ac_cv_type_unsigned_long_long,
4045   [AC_TRY_LINK([unsigned long long ull = 1; int i = 63;],
4046     [unsigned long long ullmax = (unsigned long long) -1;
4047      return ull << i | ull >> i | ullmax / ull | ullmax % ull;],
4048     ac_cv_type_unsigned_long_long=yes,
4049     ac_cv_type_unsigned_long_long=no)])
4050   if test $ac_cv_type_unsigned_long_long = yes; then
4051     AC_DEFINE(HAVE_UNSIGNED_LONG_LONG, 1,
4052       [Define if you have the unsigned long long type.])
4053   fi
4054 ])
4055
4056 dnl From gnulib
4057 AC_DEFUN([BASH_FUNC_FPURGE],
4058 [
4059   AC_CHECK_FUNCS_ONCE([fpurge])
4060   AC_CHECK_FUNCS_ONCE([__fpurge])
4061   AC_CHECK_DECLS([fpurge], , , [#include <stdio.h>])
4062 ])
4063
4064 AC_DEFUN([BASH_FUNC_SNPRINTF],
4065 [
4066   AC_CHECK_FUNCS_ONCE([snprintf])
4067   if test X$ac_cv_func_snprintf = Xyes; then
4068     AC_CACHE_CHECK([for standard-conformant snprintf], [bash_cv_func_snprintf],
4069       [AC_TRY_RUN([
4070 #include <stdio.h>
4071
4072 main()
4073 {
4074   int n;
4075   n = snprintf (0, 0, "%s", "0123456");
4076   exit(n != 7);
4077 }
4078 ], bash_cv_func_snprintf=yes, bash_cv_func_snprintf=no,
4079    [AC_MSG_WARN([cannot check standard snprintf if cross-compiling])
4080     bash_cv_func_snprintf=yes]
4081 )])
4082     if test $bash_cv_func_snprintf = no; then
4083       ac_cv_func_snprintf=no
4084     fi
4085   fi
4086   if test $ac_cv_func_snprintf = no; then
4087     AC_DEFINE(HAVE_SNPRINTF, 0,
4088       [Define if you have a standard-conformant snprintf function.])
4089   fi
4090 ])
4091
4092 AC_DEFUN([BASH_FUNC_VSNPRINTF],
4093 [
4094   AC_CHECK_FUNCS_ONCE([vsnprintf])
4095   if test X$ac_cv_func_vsnprintf = Xyes; then
4096     AC_CACHE_CHECK([for standard-conformant vsnprintf], [bash_cv_func_vsnprintf],
4097       [AC_TRY_RUN([
4098 #if HAVE_STDARG_H
4099 #include <stdarg.h>
4100 #else
4101 #include <varargs.h>
4102 #endif
4103 #include <stdio.h>
4104 #include <stdlib.h>
4105
4106 static int
4107 #if HAVE_STDARG_H
4108 foo(const char *fmt, ...)
4109 #else
4110 foo(format, va_alist)
4111      const char *format;
4112      va_dcl
4113 #endif
4114 {
4115   va_list args;
4116   int n;
4117
4118 #if HAVE_STDARG_H
4119   va_start(args, fmt);
4120 #else
4121   va_start(args);
4122 #endif
4123   n = vsnprintf(0, 0, fmt, args);
4124   va_end (args);
4125   return n;
4126 }
4127
4128 main()
4129 {
4130   int n;
4131   n = foo("%s", "0123456");
4132   exit(n != 7);
4133 }
4134 ], bash_cv_func_vsnprintf=yes, bash_cv_func_vsnprintf=no,
4135    [AC_MSG_WARN([cannot check standard vsnprintf if cross-compiling])
4136     bash_cv_func_vsnprintf=yes]
4137 )])
4138     if test $bash_cv_func_vsnprintf = no; then
4139       ac_cv_func_vsnprintf=no
4140     fi
4141   fi
4142   if test $ac_cv_func_vsnprintf = no; then
4143     AC_DEFINE(HAVE_VSNPRINTF, 0,
4144       [Define if you have a standard-conformant vsnprintf function.])
4145   fi
4146 ])
4147
4148 AC_DEFUN(BASH_STRUCT_WEXITSTATUS_OFFSET,
4149 [AC_MSG_CHECKING(for offset of exit status in return status from wait)
4150 AC_CACHE_VAL(bash_cv_wexitstatus_offset,
4151 [AC_TRY_RUN([
4152 #include <stdlib.h>
4153 #include <unistd.h>
4154
4155 #include <sys/wait.h>
4156
4157 main(c, v)
4158      int c;
4159      char **v;
4160 {
4161   pid_t pid, p;
4162   int s, i, n;
4163
4164   s = 0;
4165   pid = fork();
4166   if (pid == 0)
4167     exit (42);
4168
4169   /* wait for the process */
4170   p = wait(&s);
4171   if (p != pid)
4172     exit (255);
4173
4174   /* crack s */
4175   for (i = 0; i < (sizeof(s) - 8); i++)
4176     {
4177       n = (s >> i) & 0xff;
4178       if (n == 42)
4179         exit (i);
4180     }
4181
4182   exit (254);
4183 }
4184 ], bash_cv_wexitstatus_offset=0, bash_cv_wexitstatus_offset=$?,
4185    [AC_MSG_WARN(cannot check WEXITSTATUS offset if cross compiling -- defaulting to 0)
4186     bash_cv_wexitstatus_offset=0]
4187 )])
4188 if test "$bash_cv_wexitstatus_offset" -gt 32 ; then
4189   AC_MSG_WARN(bad exit status from test program -- defaulting to 0)
4190   bash_cv_wexitstatus_offset=0
4191 fi
4192 AC_MSG_RESULT($bash_cv_wexitstatus_offset)
4193 AC_DEFINE_UNQUOTED([WEXITSTATUS_OFFSET], [$bash_cv_wexitstatus_offset], [Offset of exit status in wait status word])
4194 ])
4195
4196 AC_DEFUN([BASH_FUNC_SBRK],
4197 [
4198   AC_CHECK_FUNCS_ONCE([sbrk])
4199   if test X$ac_cv_func_sbrk = Xyes; then
4200     AC_CACHE_CHECK([for working sbrk], [bash_cv_func_sbrk],
4201       [AC_TRY_RUN([
4202 #include <stdlib.h>
4203 #include <unistd.h>
4204
4205 int
4206 main(int c, char **v)
4207 {
4208         void *x;
4209
4210         x = sbrk (4096);
4211         exit ((x == (void *)-1) ? 1 : 0);
4212 }
4213 ], bash_cv_func_sbrk=yes, bash_cv_func_snprintf=sbrk,
4214    [AC_MSG_WARN([cannot check working sbrk if cross-compiling])
4215     bash_cv_func_sbrk=yes]
4216 )])
4217     if test $bash_cv_func_sbrk = no; then
4218       ac_cv_func_sbrk=no
4219     fi
4220   fi
4221   if test $ac_cv_func_sbrk = no; then
4222     AC_DEFINE(HAVE_SBRK, 0,
4223       [Define if you have a working sbrk function.])
4224   fi
4225 ])
4226
4227 AC_DEFUN(BASH_FUNC_FNMATCH_EQUIV_FALLBACK,
4228 [AC_MSG_CHECKING(whether fnmatch can be used to check bracket equivalence classes)
4229 AC_CACHE_VAL(bash_cv_fnmatch_equiv_fallback,
4230 [AC_TRY_RUN([
4231 #include <stdlib.h>
4232 #include <unistd.h>
4233 #include <stdio.h>
4234 #include <fnmatch.h>
4235 #include <locale.h>
4236
4237 char *pattern = "[[=a=]]";
4238
4239 /* char *string = "รค"; */
4240 unsigned char string[4] = { '\xc3', '\xa4', '\0' };
4241
4242 int
4243 main (int c, char **v)
4244 {
4245   setlocale (LC_ALL, "de_DE.UTF-8");
4246   if (fnmatch (pattern, (const char *)string, 0) != FNM_NOMATCH)
4247     exit (0);
4248   exit (1);
4249 }
4250
4251 ], bash_cv_fnmatch_equiv_fallback=yes, bash_cv_fnmatch_equiv_fallback=no,
4252    [AC_MSG_WARN(cannot check fnmatch if cross compiling -- defaulting to no)
4253     bash_cv_fnmatch_equiv_fallback=no]
4254 )])
4255 AC_MSG_RESULT($bash_cv_fnmatch_equiv_fallback)
4256 if test "$bash_cv_fnmatch_equiv_fallback" = "yes" ; then
4257     bash_cv_fnmatch_equiv_value=1
4258 else
4259     bash_cv_fnmatch_equiv_value=0
4260 fi
4261 AC_DEFINE_UNQUOTED([FNMATCH_EQUIV_FALLBACK], [$bash_cv_fnmatch_equiv_value], [Whether fnmatch can be used for bracket equivalence classes])
4262 ])