2 dnl Bash specific tests
4 dnl Some derived from PDKSH 5.1.3 autoconf tests
6 dnl Copyright (C) 1987-2023 Free Software Foundation, Inc.
10 dnl Check for <inttypes.h>. This is separated out so that it can be
13 dnl BASH_HEADER_INTTYPES
14 AC_DEFUN(BASH_HEADER_INTTYPES,
16 AC_CHECK_HEADERS(inttypes.h)
20 dnl check for typedef'd symbols in header files, but allow the caller to
21 dnl specify the include files to be checked in addition to the default
23 dnl This could be changed to use AC_COMPILE_IFELSE instead of AC_EGREP_CPP
25 dnl BASH_CHECK_TYPE(TYPE, HEADERS, DEFAULT[, VALUE-IF-FOUND])
26 AC_DEFUN(BASH_CHECK_TYPE,
28 AC_REQUIRE([BASH_HEADER_INTTYPES])
29 AC_MSG_CHECKING(for $1)
30 AC_CACHE_VAL(bash_cv_type_$1,
31 [AC_EGREP_CPP($1, [#include <sys/types.h>
45 ], bash_cv_type_$1=yes, bash_cv_type_$1=no)])
46 AC_MSG_RESULT($bash_cv_type_$1)
47 ifelse($#, 4, [if test $bash_cv_type_$1 = yes; then
50 if test $bash_cv_type_$1 = no; then
51 AC_DEFINE_UNQUOTED($1, $3)
56 dnl BASH_CHECK_DECL(FUNC)
58 dnl Check for a declaration of FUNC in stdlib.h and inttypes.h like
61 AC_DEFUN(BASH_CHECK_DECL,
63 AC_REQUIRE([BASH_HEADER_INTTYPES])
67 AC_DEFUN(BASH_DECL_PRINTF,
68 [AC_MSG_CHECKING(for declaration of printf in <stdio.h>)
69 AC_CACHE_VAL(bash_cv_printf_declared,
70 [AC_RUN_IFELSE([AC_LANG_SOURCE([[
72 typedef int (*_bashfunc)(const char *, ...);
78 pf = (_bashfunc) printf;
81 ]])], [bash_cv_printf_declared=yes], [bash_cv_printf_declared=no],
82 [AC_MSG_WARN(cannot check printf declaration if cross compiling -- defaulting to yes)
83 bash_cv_printf_declared=yes]
85 AC_MSG_RESULT($bash_cv_printf_declared)
86 if test $bash_cv_printf_declared = yes; then
87 AC_DEFINE(PRINTF_DECLARED)
91 AC_DEFUN(BASH_DECL_SBRK,
92 [AC_MSG_CHECKING(for declaration of sbrk in <unistd.h>)
93 AC_CACHE_VAL(bash_cv_sbrk_declared,
94 [AC_EGREP_HEADER(sbrk, unistd.h,
95 bash_cv_sbrk_declared=yes, bash_cv_sbrk_declared=no)])
96 AC_MSG_RESULT($bash_cv_sbrk_declared)
97 if test $bash_cv_sbrk_declared = yes; then
98 AC_DEFINE(SBRK_DECLARED)
103 dnl Check for sys_siglist[] or _sys_siglist[]
105 AC_DEFUN(BASH_DECL_UNDER_SYS_SIGLIST,
106 [AC_MSG_CHECKING([for _sys_siglist in signal.h or unistd.h])
107 AC_CACHE_VAL(bash_cv_decl_under_sys_siglist,
108 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
109 #include <sys/types.h>
113 #endif]], [[ char *msg = _sys_siglist[2]; ]])],
114 [bash_cv_decl_under_sys_siglist=yes], [bash_cv_decl_under_sys_siglist=no],
115 [AC_MSG_WARN(cannot check for _sys_siglist[] if cross compiling -- defaulting to no)])])dnl
116 AC_MSG_RESULT($bash_cv_decl_under_sys_siglist)
117 if test $bash_cv_decl_under_sys_siglist = yes; then
118 AC_DEFINE(UNDER_SYS_SIGLIST_DECLARED)
122 AC_DEFUN(BASH_UNDER_SYS_SIGLIST,
123 [AC_REQUIRE([BASH_DECL_UNDER_SYS_SIGLIST])
124 AC_MSG_CHECKING([for _sys_siglist in system C library])
125 AC_CACHE_VAL(bash_cv_under_sys_siglist,
126 [AC_RUN_IFELSE([AC_LANG_SOURCE([[
127 #include <sys/types.h>
133 #ifndef UNDER_SYS_SIGLIST_DECLARED
134 extern char *_sys_siglist[];
139 char *msg = (char *)_sys_siglist[2];
143 [bash_cv_under_sys_siglist=yes], [bash_cv_under_sys_siglist=no],
144 [AC_MSG_WARN(cannot check for _sys_siglist[] if cross compiling -- defaulting to no)
145 bash_cv_under_sys_siglist=no]
147 AC_MSG_RESULT($bash_cv_under_sys_siglist)
148 if test $bash_cv_under_sys_siglist = yes; then
149 AC_DEFINE(HAVE_UNDER_SYS_SIGLIST)
153 dnl this defines HAVE_DECL_SYS_SIGLIST
154 AC_DEFUN([BASH_DECL_SYS_SIGLIST],
155 [AC_CHECK_DECLS([sys_siglist],,,
157 /* NetBSD declares sys_siglist in unistd.h. */
164 AC_DEFUN(BASH_SYS_SIGLIST,
165 [AC_REQUIRE([BASH_DECL_SYS_SIGLIST])
166 AC_MSG_CHECKING([for sys_siglist in system C library])
167 AC_CACHE_VAL(bash_cv_sys_siglist,
168 [AC_RUN_IFELSE([AC_LANG_SOURCE([[
169 #include <sys/types.h>
175 #if !HAVE_DECL_SYS_SIGLIST
176 extern char *sys_siglist[];
181 char *msg = sys_siglist[2];
184 ]])], [bash_cv_sys_siglist=yes], [bash_cv_sys_siglist=no],
185 [AC_MSG_WARN(cannot check for sys_siglist if cross compiling -- defaulting to no)
186 bash_cv_sys_siglist=no]
188 AC_MSG_RESULT($bash_cv_sys_siglist)
189 if test $bash_cv_sys_siglist = yes; then
190 AC_DEFINE(HAVE_SYS_SIGLIST)
194 dnl Check for the various permutations of sys_siglist and make sure we
195 dnl compile in siglist.o if they're not defined
196 AC_DEFUN(BASH_CHECK_SYS_SIGLIST, [
197 AC_REQUIRE([BASH_SYS_SIGLIST])
198 AC_REQUIRE([BASH_DECL_UNDER_SYS_SIGLIST])
199 AC_REQUIRE([BASH_FUNC_STRSIGNAL])
200 if test "$bash_cv_sys_siglist" = no && test "$bash_cv_under_sys_siglist" = no && test "$bash_cv_have_strsignal" = no; then
205 AC_SUBST([SIGLIST_O])
208 dnl Check for sys_errlist[] and sys_nerr, check for declaration
209 AC_DEFUN(BASH_SYS_ERRLIST,
210 [AC_MSG_CHECKING([for sys_errlist and sys_nerr])
211 AC_CACHE_VAL(bash_cv_sys_errlist,
212 [AC_LINK_IFELSE([AC_LANG_PROGRAM([[
215 extern char *sys_errlist[];
217 char *msg = sys_errlist[sys_nerr - 1];
219 [bash_cv_sys_errlist=yes], [bash_cv_sys_errlist=no]
221 AC_MSG_RESULT($bash_cv_sys_errlist)
222 if test $bash_cv_sys_errlist = yes; then
223 AC_DEFINE(HAVE_SYS_ERRLIST)
228 dnl Check if dup2() does not clear the close on exec flag
230 AC_DEFUN(BASH_FUNC_DUP2_CLOEXEC_CHECK,
231 [AC_MSG_CHECKING(if dup2 fails to clear the close-on-exec flag)
232 AC_CACHE_VAL(bash_cv_dup2_broken,
233 [AC_RUN_IFELSE([AC_LANG_SOURCE([[
234 #include <sys/types.h>
239 #endif /* HAVE_UNISTD_H */
244 fd1 = open("/dev/null", 2);
245 if (fcntl(fd1, 2, 1) < 0)
250 fl = fcntl(fd2, 1, 0);
251 /* fl will be 1 if dup2 did not reset the close-on-exec flag. */
254 ]])], [bash_cv_dup2_broken=yes], [bash_cv_dup2_broken=no],
255 [AC_MSG_WARN(cannot check dup2 if cross compiling -- defaulting to no)
256 bash_cv_dup2_broken=no]
258 AC_MSG_RESULT($bash_cv_dup2_broken)
259 if test $bash_cv_dup2_broken = yes; then
260 AC_DEFINE(DUP2_BROKEN)
264 AC_DEFUN(BASH_FUNC_STRSIGNAL,
265 [AC_MSG_CHECKING([for the existence of strsignal])
266 AC_CACHE_VAL(bash_cv_have_strsignal,
268 [AC_LANG_PROGRAM([[#include <sys/types.h>
270 #include <string.h>]],
271 [[char *s = (char *)strsignal(2);]])],
272 [bash_cv_have_strsignal=yes], [bash_cv_have_strsignal=no])])
273 AC_MSG_RESULT($bash_cv_have_strsignal)
274 if test $bash_cv_have_strsignal = yes; then
275 AC_DEFINE(HAVE_STRSIGNAL)
279 dnl Check to see if opendir will open non-directories (not a nice thing)
280 AC_DEFUN(BASH_FUNC_OPENDIR_CHECK,
281 [AC_REQUIRE([AC_HEADER_DIRENT])dnl
282 AC_MSG_CHECKING(if opendir() opens non-directories)
283 AC_CACHE_VAL(bash_cv_opendir_not_robust,
284 [AC_RUN_IFELSE([AC_LANG_SOURCE([[
286 #include <sys/types.h>
290 #endif /* HAVE_UNISTD_H */
291 #ifdef HAVE_SYS_STAT_H
292 #include <sys/stat.h>
294 #if defined(HAVE_DIRENT_H)
297 # define dirent direct
298 # ifdef HAVE_SYS_NDIR_H
299 # include <sys/ndir.h>
300 # endif /* SYSNDIR */
301 # ifdef HAVE_SYS_DIR_H
302 # include <sys/dir.h>
307 #endif /* HAVE_DIRENT_H */
314 err = mkdir("bash-aclocal", 0700);
319 unlink("bash-aclocal/not_a_directory");
320 fd = open("bash-aclocal/not_a_directory", O_WRONLY|O_CREAT|O_EXCL, 0666);
323 dir = opendir("bash-aclocal/not_a_directory");
324 unlink("bash-aclocal/not_a_directory");
325 rmdir("bash-aclocal");
328 ]])], [bash_cv_opendir_not_robust=yes], [bash_cv_opendir_not_robust=no],
329 [AC_MSG_WARN(cannot check opendir if cross compiling -- defaulting to no)
330 bash_cv_opendir_not_robust=no]
332 AC_MSG_RESULT($bash_cv_opendir_not_robust)
333 if test $bash_cv_opendir_not_robust = yes; then
334 AC_DEFINE(OPENDIR_NOT_ROBUST)
339 dnl A signed 16-bit integer quantity
341 AC_DEFUN(BASH_TYPE_BITS16_T,
343 if test "$ac_cv_sizeof_short" = 2; then
344 AC_CHECK_TYPE(bits16_t, short)
345 elif test "$ac_cv_sizeof_char" = 2; then
346 AC_CHECK_TYPE(bits16_t, char)
348 AC_CHECK_TYPE(bits16_t, short)
353 dnl An unsigned 16-bit integer quantity
355 AC_DEFUN(BASH_TYPE_U_BITS16_T,
357 if test "$ac_cv_sizeof_short" = 2; then
358 AC_CHECK_TYPE(u_bits16_t, unsigned short)
359 elif test "$ac_cv_sizeof_char" = 2; then
360 AC_CHECK_TYPE(u_bits16_t, unsigned char)
362 AC_CHECK_TYPE(u_bits16_t, unsigned short)
367 dnl A signed 32-bit integer quantity
369 AC_DEFUN(BASH_TYPE_BITS32_T,
371 if test "$ac_cv_sizeof_int" = 4; then
372 AC_CHECK_TYPE(bits32_t, int)
373 elif test "$ac_cv_sizeof_long" = 4; then
374 AC_CHECK_TYPE(bits32_t, long)
376 AC_CHECK_TYPE(bits32_t, int)
381 dnl An unsigned 32-bit integer quantity
383 AC_DEFUN(BASH_TYPE_U_BITS32_T,
385 if test "$ac_cv_sizeof_int" = 4; then
386 AC_CHECK_TYPE(u_bits32_t, unsigned int)
387 elif test "$ac_cv_sizeof_long" = 4; then
388 AC_CHECK_TYPE(u_bits32_t, unsigned long)
390 AC_CHECK_TYPE(u_bits32_t, unsigned int)
394 AC_DEFUN(BASH_TYPE_PTRDIFF_T,
396 if test "$ac_cv_sizeof_int" = "$ac_cv_sizeof_char_p"; then
397 AC_CHECK_TYPE(ptrdiff_t, int)
398 elif test "$ac_cv_sizeof_long" = "$ac_cv_sizeof_char_p"; then
399 AC_CHECK_TYPE(ptrdiff_t, long)
400 elif test "$ac_cv_type_long_long" = yes && test "$ac_cv_sizeof_long_long" = "$ac_cv_sizeof_char_p"; then
401 AC_CHECK_TYPE(ptrdiff_t, [long long])
403 AC_CHECK_TYPE(ptrdiff_t, int)
408 dnl A signed 64-bit quantity
410 AC_DEFUN(BASH_TYPE_BITS64_T,
412 if test "$ac_cv_sizeof_char_p" = 8; then
413 AC_CHECK_TYPE(bits64_t, char *)
414 elif test "$ac_cv_sizeof_double" = 8; then
415 AC_CHECK_TYPE(bits64_t, double)
416 elif test -n "$ac_cv_type_long_long" && test "$ac_cv_sizeof_long_long" = 8; then
417 AC_CHECK_TYPE(bits64_t, [long long])
418 elif test "$ac_cv_sizeof_long" = 8; then
419 AC_CHECK_TYPE(bits64_t, long)
421 AC_CHECK_TYPE(bits64_t, double)
425 AC_DEFUN(BASH_SIZEOF_RLIMIT,
426 [AC_MSG_CHECKING(for size of struct rlimit fields)
427 AC_CACHE_VAL(bash_cv_sizeof_rlim_cur,
428 [AC_RUN_IFELSE([AC_LANG_SOURCE([[
429 #ifdef HAVE_SYS_TIME_H
430 #include <sys/time.h>
433 #include <sys/resource.h>
438 exit(sizeof (r.rlim_cur));
440 ]])], [bash_cv_sizeof_rlim_cur=$?], [bash_cv_sizeof_rlim_cur=$?],
441 [AC_MSG_WARN(cannot check size of rlimit fields if cross compiling -- defaulting to long)
442 bash_cv_sizeof_rlim_cur=$ac_cv_sizeof_long]
444 AC_MSG_RESULT($bash_cv_sizeof_rlim_cur)
447 AC_DEFUN(BASH_SIZEOF_QUAD_T,
448 [AC_MSG_CHECKING(for size of quad_t)
449 AC_CACHE_VAL(bash_cv_sizeof_quad_t,
450 [AC_RUN_IFELSE([AC_LANG_SOURCE([[
451 #include <sys/types.h>
454 #include <inttypes.h>
470 ]])], [bash_cv_sizeof_quad_t=$?], [bash_cv_sizeof_quad_t=$?],
471 [AC_MSG_WARN(cannot check size of quad_t if cross compiling -- defaulting to 0)
472 bash_cv_sizeof_quad_t=0]
474 AC_MSG_RESULT($bash_cv_sizeof_quad_t)
478 dnl Type of struct rlimit fields: updated to check POSIX rlim_t and
479 dnl if it doesn't exist determine the best guess based on sizeof(r.rlim_cur)
481 AC_DEFUN(BASH_TYPE_RLIMIT,
482 [AC_MSG_CHECKING(for type of struct rlimit fields)
483 AC_CACHE_VAL(bash_cv_type_rlimit,
484 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
485 #include <sys/types.h>
486 #include <sys/resource.h>]],
489 [bash_cv_type_rlimit=rlim_t], [
492 if test $bash_cv_sizeof_rlim_cur = $ac_cv_sizeof_long; then
493 bash_cv_type_rlimit='unsigned long'
494 elif test $bash_cv_sizeof_rlim_cur = $ac_cv_sizeof_long_long; then
495 bash_cv_type_rlimit='unsigned long long'
496 elif test $bash_cv_sizeof_rlim_cur = $ac_cv_sizeof_int; then
497 bash_cv_type_rlimit='unsigned int'
498 elif test $bash_cv_sizeof_rlim_cur = $bash_cv_sizeof_quad_t; then
499 bash_cv_type_rlimit='quad_t'
501 bash_cv_type_rlimit='unsigned long'
505 AC_MSG_RESULT($bash_cv_type_rlimit)
506 AC_DEFINE_UNQUOTED([RLIMTYPE], [$bash_cv_type_rlimit])
509 AC_DEFUN(BASH_TYPE_SIG_ATOMIC_T,
510 [AC_CACHE_CHECK([for sig_atomic_t in signal.h], ac_cv_have_sig_atomic_t,
513 [[ #include <signal.h> ]],
514 [[ sig_atomic_t x; ]])],
515 [ac_cv_have_sig_atomic_t=yes],[ac_cv_have_sig_atomic_t=no])])
516 if test "$ac_cv_have_sig_atomic_t" = "no"
518 BASH_CHECK_TYPE(sig_atomic_t, [#include <signal.h>], int)
522 AC_DEFUN(BASH_FUNC_LSTAT,
523 [dnl Cannot use AC_CHECK_FUNCS(lstat) because Linux defines lstat() as an
524 dnl inline function in <sys/stat.h>.
525 AC_CACHE_CHECK([for lstat], bash_cv_func_lstat,
528 #include <sys/types.h>
529 #include <sys/stat.h>
531 [[ lstat(".",(struct stat *)0); ]])],
532 [bash_cv_func_lstat=yes],[bash_cv_func_lstat=no])])
533 if test $bash_cv_func_lstat = yes; then
534 AC_DEFINE(HAVE_LSTAT)
538 AC_DEFUN(BASH_FUNC_INET_ATON,
540 AC_CACHE_CHECK([for inet_aton], bash_cv_func_inet_aton,
541 [AC_LINK_IFELSE([AC_LANG_PROGRAM([[
542 #include <sys/types.h>
543 #include <netinet/in.h>
544 #include <arpa/inet.h>
545 struct in_addr ap;]], [[ inet_aton("127.0.0.1", &ap); ]])],
546 [bash_cv_func_inet_aton=yes], [bash_cv_func_inet_aton=no])])
547 if test $bash_cv_func_inet_aton = yes; then
548 AC_DEFINE(HAVE_INET_ATON)
554 AC_DEFUN(BASH_FUNC_GETENV,
555 [AC_MSG_CHECKING(to see if getenv can be redefined)
556 AC_CACHE_VAL(bash_cv_getenv_redef,
557 [AC_RUN_IFELSE([AC_LANG_SOURCE([[
563 getenv (const char *name)
571 /* The next allows this program to run, but does not allow bash to link
572 when it redefines getenv. I'm not really interested in figuring out
578 exit(s == 0); /* force optimizer to leave getenv in */
580 ]])], [bash_cv_getenv_redef=yes], [bash_cv_getenv_redef=no],
581 [AC_MSG_WARN(cannot check getenv redefinition if cross compiling -- defaulting to yes)
582 bash_cv_getenv_redef=yes]
584 AC_MSG_RESULT($bash_cv_getenv_redef)
585 if test $bash_cv_getenv_redef = yes; then
586 AC_DEFINE(CAN_REDEFINE_GETENV)
590 # We should check for putenv before calling this
591 AC_DEFUN(BASH_FUNC_STD_PUTENV,
593 AC_CACHE_CHECK([for standard-conformant putenv declaration], bash_cv_std_putenv,
594 [AC_LINK_IFELSE([AC_LANG_PROGRAM([[
601 extern int putenv (char *);
602 ]], [[return (putenv == 0);]] )],
603 [bash_cv_std_putenv=yes], [bash_cv_std_putenv=no]
605 if test $bash_cv_std_putenv = yes; then
606 AC_DEFINE(HAVE_STD_PUTENV)
610 # We should check for unsetenv before calling this
611 AC_DEFUN(BASH_FUNC_STD_UNSETENV,
613 AC_CACHE_CHECK([for standard-conformant unsetenv declaration], bash_cv_std_unsetenv,
614 [AC_LINK_IFELSE([AC_LANG_PROGRAM([[
621 extern int unsetenv (const char *);
622 ]], [[return (unsetenv == 0);]] )],
623 [bash_cv_std_unsetenv=yes], [bash_cv_std_unsetenv=no]
625 if test $bash_cv_std_unsetenv = yes; then
626 AC_DEFINE(HAVE_STD_UNSETENV)
630 AC_DEFUN(BASH_FUNC_ULIMIT_MAXFDS,
631 [AC_MSG_CHECKING(whether ulimit can substitute for getdtablesize)
632 AC_CACHE_VAL(bash_cv_ulimit_maxfds,
633 [AC_RUN_IFELSE([AC_LANG_SOURCE([[
641 long maxfds = ulimit(4, 0L);
642 exit (maxfds == -1L);
644 ]])], [bash_cv_ulimit_maxfds=yes], [bash_cv_ulimit_maxfds=no],
645 [AC_MSG_WARN(cannot check ulimit if cross compiling -- defaulting to no)
646 bash_cv_ulimit_maxfds=no]
648 AC_MSG_RESULT($bash_cv_ulimit_maxfds)
649 if test $bash_cv_ulimit_maxfds = yes; then
650 AC_DEFINE(ULIMIT_MAXFDS)
654 AC_DEFUN(BASH_FUNC_GETCWD,
655 [AC_MSG_CHECKING([if getcwd() will dynamically allocate memory with 0 size])
656 AC_CACHE_VAL(bash_cv_getcwd_malloc,
657 [AC_RUN_IFELSE([AC_LANG_SOURCE([[
671 ]])], [bash_cv_getcwd_malloc=yes], [bash_cv_getcwd_malloc=no],
672 [AC_MSG_WARN(cannot check whether getcwd allocates memory when cross-compiling -- defaulting to no)
673 bash_cv_getcwd_malloc=no]
675 AC_MSG_RESULT($bash_cv_getcwd_malloc)
676 if test $bash_cv_getcwd_malloc = no; then
677 AC_DEFINE(GETCWD_BROKEN)
683 dnl This needs BASH_CHECK_SOCKLIB, but since that's not called on every
684 dnl system, we can't use AC_PREREQ. Only called if we need the socket library
686 AC_DEFUN(BASH_FUNC_GETHOSTBYNAME,
687 [if test "X$bash_cv_have_gethostbyname" = "X"; then
690 AC_MSG_CHECKING(for gethostbyname in socket library)
693 AC_CACHE_VAL(bash_cv_have_gethostbyname,
694 [AC_LINK_IFELSE([AC_LANG_PROGRAM([[
698 hp = gethostbyname("localhost");
700 [bash_cv_have_gethostbyname=yes], [bash_cv_have_gethostbyname=no]
702 if test "X$_bash_needmsg" = Xyes; then
703 AC_MSG_CHECKING(for gethostbyname in socket library)
705 AC_MSG_RESULT($bash_cv_have_gethostbyname)
706 if test "$bash_cv_have_gethostbyname" = yes; then
707 AC_DEFINE(HAVE_GETHOSTBYNAME)
711 AC_DEFUN(BASH_FUNC_FNMATCH_EXTMATCH,
712 [AC_MSG_CHECKING(if fnmatch does extended pattern matching with FNM_EXTMATCH)
713 AC_CACHE_VAL(bash_cv_fnm_extmatch,
714 [AC_RUN_IFELSE([AC_LANG_SOURCE([[
726 ]])], [bash_cv_fnm_extmatch=yes], [bash_cv_fnm_extmatch=no],
727 [AC_MSG_WARN(cannot check FNM_EXTMATCH if cross compiling -- defaulting to no)
728 bash_cv_fnm_extmatch=no]
730 AC_MSG_RESULT($bash_cv_fnm_extmatch)
731 if test $bash_cv_fnm_extmatch = yes; then
732 AC_DEFINE(HAVE_LIBC_FNM_EXTMATCH)
736 AC_DEFUN(BASH_FUNC_POSIX_SETJMP,
737 [AC_REQUIRE([BASH_SYS_SIGNAL_VINTAGE])
738 AC_MSG_CHECKING(for presence of POSIX-style sigsetjmp/siglongjmp)
739 AC_CACHE_VAL(bash_cv_func_sigsetjmp,
740 [AC_RUN_IFELSE([AC_LANG_SOURCE([[
744 #include <sys/types.h>
752 #if !defined (_POSIX_VERSION) || !defined (HAVE_POSIX_SIGNALS)
757 sigset_t set, oset, nset;
764 sigprocmask(SIG_BLOCK, (sigset_t *)NULL, &oset);
765 /* paranoia -- make sure SIGINT is not blocked */
766 sigdelset (&oset, SIGINT);
767 sigprocmask (SIG_SETMASK, &oset, (sigset_t *)NULL);
770 code = sigsetjmp(xx, 1);
773 sigprocmask(SIG_BLOCK, (sigset_t *)NULL, &nset);
774 /* could compare nset to oset here, but we just look for SIGINT */
775 if (sigismember (&nset, SIGINT))
780 /* change it so that SIGINT is blocked */
781 sigaddset(&set, SIGINT);
782 sigprocmask(SIG_BLOCK, &set, (sigset_t *)NULL);
789 ]])], [bash_cv_func_sigsetjmp=present], [bash_cv_func_sigsetjmp=missing],
790 [AC_MSG_WARN(cannot check for sigsetjmp/siglongjmp if cross-compiling -- defaulting to $bash_cv_posix_signals)
791 if test "$bash_cv_posix_signals" = "yes" ; then
792 bash_cv_func_sigsetjmp=present
794 bash_cv_func_sigsetjmp=missing
797 AC_MSG_RESULT($bash_cv_func_sigsetjmp)
798 if test $bash_cv_func_sigsetjmp = present; then
799 AC_DEFINE(HAVE_POSIX_SIGSETJMP)
803 AC_DEFUN(BASH_FUNC_STRCOLL,
804 [AC_MSG_CHECKING(whether or not strcoll and strcmp differ)
805 AC_CACHE_VAL(bash_cv_func_strcoll_broken,
806 [AC_RUN_IFELSE([AC_LANG_SOURCE([[
808 #if defined (HAVE_LOCALE_H)
815 main(int c, char **v)
818 char *deflocale, *defcoll;
820 #ifdef HAVE_SETLOCALE
821 deflocale = setlocale(LC_ALL, "");
822 defcoll = setlocale(LC_COLLATE, "");
826 /* These two values are taken from tests/glob-test. */
827 r1 = strcoll("abd", "aXd");
831 r2 = strcmp("abd", "aXd");
833 /* These two should both be greater than 0. It is permissible for
834 a system to return different values, as long as the sign is the
837 /* Exit with 1 (failure) if these two values are both > 0, since
838 this tests whether strcoll(3) is broken with respect to strcmp(3)
839 in the default locale. */
840 exit (r1 > 0 && r2 > 0);
842 ]])], [bash_cv_func_strcoll_broken=yes], [bash_cv_func_strcoll_broken=no],
843 [AC_MSG_WARN(cannot check strcoll if cross compiling -- defaulting to no)
844 bash_cv_func_strcoll_broken=no]
846 AC_MSG_RESULT($bash_cv_func_strcoll_broken)
847 if test $bash_cv_func_strcoll_broken = yes; then
848 AC_DEFINE(STRCOLL_BROKEN)
852 AC_DEFUN(BASH_FUNC_PRINTF_A_FORMAT,
853 [AC_MSG_CHECKING([for printf floating point output in hex notation])
854 AC_CACHE_VAL(bash_cv_printf_a_format,
855 [AC_RUN_IFELSE([AC_LANG_SOURCE([[
866 sprintf(abuf, "%A", y);
867 exit(strchr(abuf, 'P') == (char *)0);
869 ]])], [bash_cv_printf_a_format=yes], [bash_cv_printf_a_format=no],
870 [AC_MSG_WARN(cannot check printf if cross compiling -- defaulting to no)
871 bash_cv_printf_a_format=no]
873 AC_MSG_RESULT($bash_cv_printf_a_format)
874 if test $bash_cv_printf_a_format = yes; then
875 AC_DEFINE(HAVE_PRINTF_A_FORMAT)
879 AC_DEFUN(BASH_STRUCT_TERMIOS_LDISC,
881 AC_CHECK_MEMBER(struct termios.c_line, AC_DEFINE(TERMIOS_LDISC), ,[
882 #include <sys/types.h>
887 AC_DEFUN(BASH_STRUCT_TERMIO_LDISC,
889 AC_CHECK_MEMBER(struct termio.c_line, AC_DEFINE(TERMIO_LDISC), ,[
890 #include <sys/types.h>
896 dnl Like AC_STRUCT_ST_BLOCKS, but doesn't muck with LIBOBJS
898 dnl sets bash_cv_struct_stat_st_blocks
900 dnl unused for now; we'll see how AC_CHECK_MEMBERS works
902 AC_DEFUN(BASH_STRUCT_ST_BLOCKS,
904 AC_MSG_CHECKING([for struct stat.st_blocks])
905 AC_CACHE_VAL(bash_cv_struct_stat_st_blocks,
906 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
907 #include <sys/types.h>
908 #include <sys/stat.h>
913 static struct stat a;
914 if (a.st_blocks) return 0;
917 ]])], [bash_cv_struct_stat_st_blocks=yes], [bash_cv_struct_stat_st_blocks=no])
919 AC_MSG_RESULT($bash_cv_struct_stat_st_blocks)
920 if test "$bash_cv_struct_stat_st_blocks" = "yes"; then
921 AC_DEFINE(HAVE_STRUCT_STAT_ST_BLOCKS)
925 AC_DEFUN([BASH_CHECK_LIB_TERMCAP],
927 if test "X$bash_cv_termcap_lib" = "X"; then
930 AC_MSG_CHECKING(which library has the termcap functions)
933 AC_CACHE_VAL(bash_cv_termcap_lib,
934 [AC_CHECK_FUNC(tgetent, bash_cv_termcap_lib=libc,
935 [AC_CHECK_LIB(termcap, tgetent, bash_cv_termcap_lib=libtermcap,
936 [AC_CHECK_LIB(tinfo, tgetent, bash_cv_termcap_lib=libtinfo,
937 [AC_CHECK_LIB(curses, tgetent, bash_cv_termcap_lib=libcurses,
938 [AC_CHECK_LIB(ncurses, tgetent, bash_cv_termcap_lib=libncurses,
939 [AC_CHECK_LIB(ncursesw, tgetent, bash_cv_termcap_lib=libncursesw,
940 bash_cv_termcap_lib=gnutermcap)])])])])])])
941 if test "X$_bash_needmsg" = "Xyes"; then
942 AC_MSG_CHECKING(which library has the termcap functions)
944 AC_MSG_RESULT(using $bash_cv_termcap_lib)
945 if test $bash_cv_termcap_lib = gnutermcap && test -z "$prefer_curses"; then
946 LDFLAGS="$LDFLAGS -L./lib/termcap"
947 TERMCAP_LIB="./lib/termcap/libtermcap.a"
948 TERMCAP_DEP="./lib/termcap/libtermcap.a"
949 elif test $bash_cv_termcap_lib = libtermcap && test -z "$prefer_curses"; then
950 TERMCAP_LIB=-ltermcap
952 elif test $bash_cv_termcap_lib = libtinfo; then
955 elif test $bash_cv_termcap_lib = libncurses; then
956 TERMCAP_LIB=-lncurses
958 elif test $bash_cv_termcap_lib = libc; then
962 # we assume ncurses is installed somewhere the linker can find it
963 TERMCAP_LIB=-lncurses
969 dnl Check for the presence of getpeername in libsocket.
970 dnl If libsocket is present, check for libnsl and add it to LIBS if
971 dnl it's there, since most systems with libsocket require linking
972 dnl with libnsl as well. This should only be called if getpeername
973 dnl was not found in libc.
975 dnl NOTE: IF WE FIND GETPEERNAME, WE ASSUME THAT WE HAVE BIND/CONNECT
978 AC_DEFUN(BASH_CHECK_LIB_SOCKET,
980 if test "X$bash_cv_have_socklib" = "X"; then
983 AC_MSG_CHECKING(for socket library)
986 AC_CACHE_VAL(bash_cv_have_socklib,
987 [AC_CHECK_LIB(socket, getpeername,
988 bash_cv_have_socklib=yes, bash_cv_have_socklib=no, -lnsl)])
989 if test "X$_bash_needmsg" = Xyes; then
990 AC_MSG_RESULT($bash_cv_have_socklib)
993 if test $bash_cv_have_socklib = yes; then
994 # check for libnsl, add it to LIBS if present
995 if test "X$bash_cv_have_libnsl" = "X"; then
998 AC_MSG_CHECKING(for libnsl)
1001 AC_CACHE_VAL(bash_cv_have_libnsl,
1002 [AC_CHECK_LIB(nsl, t_open,
1003 bash_cv_have_libnsl=yes, bash_cv_have_libnsl=no)])
1004 if test "X$_bash_needmsg" = Xyes; then
1005 AC_MSG_RESULT($bash_cv_have_libnsl)
1008 if test $bash_cv_have_libnsl = yes; then
1009 LIBS="-lsocket -lnsl $LIBS"
1011 LIBS="-lsocket $LIBS"
1013 AC_DEFINE(HAVE_LIBSOCKET)
1014 AC_DEFINE(HAVE_GETPEERNAME)
1018 dnl like _AC_STRUCT_DIRENT(MEMBER) but public
1019 AC_DEFUN(BASH_STRUCT_DIRENT,
1021 AC_REQUIRE([AC_HEADER_DIRENT])
1022 AC_CHECK_MEMBERS(struct dirent.$1, bash_cv_dirent_has_$1=yes, bash_cv_dirent_has_$1=no,
1025 #include <sys/types.h>
1026 #ifdef HAVE_UNISTD_H
1027 # include <unistd.h>
1028 #endif /* HAVE_UNISTD_H */
1029 #if defined(HAVE_DIRENT_H)
1030 # include <dirent.h>
1032 # define dirent direct
1033 # ifdef HAVE_SYS_NDIR_H
1034 # include <sys/ndir.h>
1035 # endif /* SYSNDIR */
1036 # ifdef HAVE_SYS_DIR_H
1037 # include <sys/dir.h>
1038 # endif /* SYSDIR */
1042 #endif /* HAVE_DIRENT_H */
1046 AC_DEFUN(BASH_STRUCT_DIRENT_D_INO,
1047 [AC_REQUIRE([AC_HEADER_DIRENT])
1048 AC_MSG_CHECKING(for struct dirent.d_ino)
1049 AC_CACHE_VAL(bash_cv_dirent_has_d_ino, [BASH_STRUCT_DIRENT([d_ino])])
1050 AC_MSG_RESULT($bash_cv_dirent_has_d_ino)
1051 if test $bash_cv_dirent_has_d_ino = yes; then
1052 AC_DEFINE(HAVE_STRUCT_DIRENT_D_INO)
1056 AC_DEFUN(BASH_STRUCT_DIRENT_D_FILENO,
1057 [AC_REQUIRE([AC_HEADER_DIRENT])
1058 AC_MSG_CHECKING(for struct dirent.d_fileno)
1059 AC_CACHE_VAL(bash_cv_dirent_has_d_fileno, [BASH_STRUCT_DIRENT([d_fileno])])
1060 AC_MSG_RESULT($bash_cv_dirent_has_d_fileno)
1061 if test $bash_cv_dirent_has_d_fileno = yes; then
1062 AC_DEFINE(HAVE_STRUCT_DIRENT_D_FILENO)
1066 AC_DEFUN(BASH_STRUCT_DIRENT_D_NAMLEN,
1067 [AC_REQUIRE([AC_HEADER_DIRENT])
1068 AC_MSG_CHECKING(for struct dirent.d_namlen)
1069 AC_CACHE_VAL(bash_cv_dirent_has_d_namlen, [BASH_STRUCT_DIRENT([d_namlen])])
1070 AC_MSG_RESULT($bash_cv_dirent_has_d_namlen)
1071 if test $bash_cv_dirent_has_d_namlen = yes; then
1072 AC_DEFINE(HAVE_STRUCT_DIRENT_D_NAMLEN)
1076 AC_DEFUN(BASH_STRUCT_TIMEVAL,
1077 [AC_MSG_CHECKING(for struct timeval in sys/time.h and time.h)
1078 AC_CACHE_VAL(bash_cv_struct_timeval,
1081 [[#if HAVE_SYS_TIME_H
1082 #include <sys/time.h>
1086 [[static struct timeval x; x.tv_sec = x.tv_usec;]]
1088 bash_cv_struct_timeval=yes,
1089 bash_cv_struct_timeval=no)
1091 AC_MSG_RESULT($bash_cv_struct_timeval)
1092 if test $bash_cv_struct_timeval = yes; then
1093 AC_DEFINE(HAVE_TIMEVAL)
1097 AC_DEFUN(BASH_STRUCT_TIMEZONE,
1098 [AC_MSG_CHECKING(for struct timezone in sys/time.h and time.h)
1099 AC_CACHE_VAL(bash_cv_struct_timezone,
1101 AC_EGREP_HEADER(struct timezone, sys/time.h,
1102 bash_cv_struct_timezone=yes,
1103 AC_EGREP_HEADER(struct timezone, time.h,
1104 bash_cv_struct_timezone=yes,
1105 bash_cv_struct_timezone=no))
1107 AC_MSG_RESULT($bash_cv_struct_timezone)
1108 if test $bash_cv_struct_timezone = yes; then
1109 AC_DEFINE(HAVE_STRUCT_TIMEZONE)
1113 AC_DEFUN(BASH_CHECK_WINSIZE_IOCTL,
1114 [AC_CACHE_VAL(bash_cv_struct_winsize_ioctl,
1115 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1116 #include <sys/types.h>
1117 #include <sys/ioctl.h>
1121 if (sizeof (x) > 0) return (0);
1122 ]] )], [bash_cv_struct_winsize_ioctl=yes], [bash_cv_struct_winsize_ioctl=no])
1126 AC_DEFUN(BASH_CHECK_WINSIZE_TERMIOS,
1127 [AC_CACHE_VAL(bash_cv_struct_winsize_termios,
1128 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1129 #include <sys/types.h>
1130 #include <sys/termios.h>
1134 if (sizeof (x) > 0) return (0);
1135 ]] )], [bash_cv_struct_winsize_termios=yes], [bash_cv_struct_winsize_termios=no])
1139 AC_DEFUN(BASH_STRUCT_WINSIZE,
1140 [AC_MSG_CHECKING(for struct winsize in sys/ioctl.h and termios.h)
1141 AC_CACHE_VAL(bash_cv_struct_winsize_header,
1143 BASH_CHECK_WINSIZE_IOCTL
1144 BASH_CHECK_WINSIZE_TERMIOS
1146 if test $bash_cv_struct_winsize_ioctl = yes; then
1147 bash_cv_struct_winsize_header=ioctl_h
1148 elif test $bash_cv_struct_winsize_termios = yes; then
1149 bash_cv_struct_winsize_header=termios_h
1151 bash_cv_struct_winsize_header=other
1154 if test $bash_cv_struct_winsize_header = ioctl_h; then
1155 AC_MSG_RESULT(sys/ioctl.h)
1156 AC_DEFINE(STRUCT_WINSIZE_IN_SYS_IOCTL)
1157 elif test $bash_cv_struct_winsize_header = termios_h; then
1158 AC_MSG_RESULT(termios.h)
1159 AC_DEFINE(STRUCT_WINSIZE_IN_TERMIOS)
1161 AC_MSG_RESULT(not found)
1165 AC_DEFUN(BASH_HAVE_POSIX_SIGNALS,
1166 [AC_CACHE_VAL(bash_cv_posix_signals,
1167 [AC_LINK_IFELSE([AC_LANG_PROGRAM([[
1171 struct sigaction sa;
1172 sigemptyset(&ss); sigsuspend(&ss);
1173 sigaction(SIGINT, &sa, (struct sigaction *) 0);
1174 sigprocmask(SIG_BLOCK, &ss, (sigset_t *) 0);
1176 [bash_cv_posix_signals=yes], [bash_cv_posix_signals=no]
1180 AC_DEFUN(BASH_HAVE_BSD_SIGNALS,
1181 [AC_CACHE_VAL(bash_cv_bsd_signals,
1182 [AC_LINK_IFELSE([AC_LANG_PROGRAM([[
1185 int mask = sigmask(SIGINT);
1186 sigsetmask(mask); sigblock(mask); sigpause(mask);
1188 [bash_cv_bsd_signals=yes], [bash_cv_bsd_signals=no]
1192 AC_DEFUN(BASH_HAVE_SYSV_SIGNALS,
1193 [AC_CACHE_VAL(bash_cv_sysv_signals,
1194 [AC_LINK_IFELSE([AC_LANG_PROGRAM([[
1198 int mask = sigmask(SIGINT);
1199 sigset(SIGINT, foo); sigrelse(SIGINT);
1200 sighold(SIGINT); sigpause(SIGINT);
1202 [bash_cv_sysv_signals=yes], [bash_cv_sysv_signals=no]
1206 dnl Check type of signal routines (posix, 4.2bsd, 4.1bsd or v7)
1207 AC_DEFUN(BASH_SYS_SIGNAL_VINTAGE,
1208 [AC_MSG_CHECKING(for type of signal functions)
1209 AC_CACHE_VAL(bash_cv_signal_vintage,
1211 BASH_HAVE_POSIX_SIGNALS
1212 if test $bash_cv_posix_signals = yes; then
1213 bash_cv_signal_vintage=posix
1215 BASH_HAVE_BSD_SIGNALS
1216 if test $bash_cv_bsd_signals = yes; then
1217 bash_cv_signal_vintage=4.2bsd
1219 BASH_HAVE_SYSV_SIGNALS
1220 if test $bash_cv_sysv_signals = yes; then
1221 bash_cv_signal_vintage=svr3
1223 bash_cv_signal_vintage=v7
1228 AC_MSG_RESULT($bash_cv_signal_vintage)
1229 if test "$bash_cv_signal_vintage" = posix; then
1230 AC_DEFINE(HAVE_POSIX_SIGNALS)
1231 elif test "$bash_cv_signal_vintage" = "4.2bsd"; then
1232 AC_DEFINE(HAVE_BSD_SIGNALS)
1233 elif test "$bash_cv_signal_vintage" = svr3; then
1234 AC_DEFINE(HAVE_USG_SIGHOLD)
1238 dnl Check if the pgrp of setpgrp() can't be the pid of a zombie process.
1239 AC_DEFUN(BASH_SYS_PGRP_SYNC,
1240 [AC_REQUIRE([AC_FUNC_GETPGRP])
1241 AC_MSG_CHECKING(whether pgrps need synchronization)
1242 AC_CACHE_VAL(bash_cv_pgrp_pipe,
1243 [AC_RUN_IFELSE([AC_LANG_SOURCE([[
1244 #ifdef HAVE_UNISTD_H
1245 # include <unistd.h>
1247 #ifdef HAVE_SYS_WAIT_H
1248 # include <sys/wait.h>
1254 # ifdef GETPGRP_VOID
1255 # define getpgID() getpgrp()
1257 # define getpgID() getpgrp(0)
1258 # define setpgid(x,y) setpgrp(x,y)
1260 int pid1, pid2, fds[2];
1264 switch (pid1 = fork()) {
1268 setpgid(0, getpid());
1271 setpgid(pid1, pid1);
1273 sleep(2); /* let first child die */
1278 switch (pid2 = fork()) {
1283 ok = getpgID() == pid1;
1284 write(fds[1], &ok, 1);
1287 setpgid(pid2, pid1);
1290 if (read(fds[0], &ok, 1) != 1)
1296 ]])], [bash_cv_pgrp_pipe=no], [bash_cv_pgrp_pipe=yes],
1297 [AC_MSG_WARN(cannot check pgrp synchronization if cross compiling -- defaulting to no)
1298 bash_cv_pgrp_pipe=no]
1300 AC_MSG_RESULT($bash_cv_pgrp_pipe)
1301 if test $bash_cv_pgrp_pipe = yes; then
1302 AC_DEFINE(PGRP_PIPE)
1306 AC_DEFUN(BASH_SYS_REINSTALL_SIGHANDLERS,
1307 [AC_REQUIRE([BASH_SYS_SIGNAL_VINTAGE])
1308 AC_MSG_CHECKING([if signal handlers must be reinstalled when invoked])
1309 AC_CACHE_VAL(bash_cv_must_reinstall_sighandlers,
1310 [AC_RUN_IFELSE([AC_LANG_SOURCE([[
1312 #ifdef HAVE_UNISTD_H
1317 typedef void sigfunc(int);
1319 volatile int nsigint;
1321 #ifdef HAVE_POSIX_SIGNALS
1323 set_signal_handler(int sig, sigfunc *handler)
1325 struct sigaction act, oact;
1326 act.sa_handler = handler;
1328 sigemptyset (&act.sa_mask);
1329 sigemptyset (&oact.sa_mask);
1330 sigaction (sig, &act, &oact);
1331 return (oact.sa_handler);
1334 #define set_signal_handler(s, h) signal(s, h)
1347 set_signal_handler(SIGINT, sigint);
1348 kill((int)getpid(), SIGINT);
1349 kill((int)getpid(), SIGINT);
1352 ]])], [bash_cv_must_reinstall_sighandlers=no], [bash_cv_must_reinstall_sighandlers=yes],
1353 [AC_MSG_WARN(cannot check signal handling if cross compiling -- defaulting to no)
1354 bash_cv_must_reinstall_sighandlers=no]
1356 AC_MSG_RESULT($bash_cv_must_reinstall_sighandlers)
1357 if test $bash_cv_must_reinstall_sighandlers = yes; then
1358 AC_DEFINE(MUST_REINSTALL_SIGHANDLERS)
1362 dnl check that some necessary job control definitions are present
1363 AC_DEFUN(BASH_SYS_JOB_CONTROL_MISSING,
1364 [AC_REQUIRE([BASH_SYS_SIGNAL_VINTAGE])
1365 AC_MSG_CHECKING(for presence of necessary job control definitions)
1366 AC_CACHE_VAL(bash_cv_job_control_missing,
1367 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1368 #include <sys/types.h>
1369 #ifdef HAVE_SYS_WAIT_H
1370 #include <sys/wait.h>
1372 #ifdef HAVE_UNISTD_H
1377 /* add more tests in here as appropriate */
1380 #if !defined (HAVE_POSIX_SIGNALS) && !defined (HAVE_BSD_SIGNALS)
1384 /* signals and tty control. */
1385 #if !defined (SIGTSTP) || !defined (SIGSTOP) || !defined (SIGCONT)
1389 /* process control */
1390 #if !defined (WNOHANG) || !defined (WUNTRACED)
1394 /* Posix systems have tcgetpgrp and waitpid. */
1395 #if defined (_POSIX_VERSION) && !defined (HAVE_TCGETPGRP)
1399 #if defined (_POSIX_VERSION) && !defined (HAVE_WAITPID)
1403 /* Other systems have TIOCSPGRP/TIOCGPRGP and wait3. */
1404 #if !defined (_POSIX_VERSION) && !defined (HAVE_WAIT3)
1408 ]], [[ int x; ]] )],
1409 [bash_cv_job_control_missing=present], [bash_cv_job_control_missing=missing]
1411 AC_MSG_RESULT($bash_cv_job_control_missing)
1412 if test $bash_cv_job_control_missing = missing; then
1413 AC_DEFINE(JOB_CONTROL_MISSING)
1417 dnl check whether named pipes are present
1418 dnl this requires a previous check for mkfifo, but that is awkward to specify
1419 AC_DEFUN(BASH_SYS_NAMED_PIPES,
1420 [AC_MSG_CHECKING(for presence of named pipes)
1421 AC_CACHE_VAL(bash_cv_sys_named_pipes,
1422 [AC_RUN_IFELSE([AC_LANG_SOURCE([[
1423 #include <sys/types.h>
1424 #include <sys/stat.h>
1425 #ifdef HAVE_UNISTD_H
1431 /* Add more tests in here as appropriate. */
1437 #if defined (HAVE_MKFIFO)
1441 #if !defined (S_IFIFO) && (defined (_POSIX_VERSION) && !defined (S_ISFIFO))
1448 err = mkdir("bash-aclocal", 0700);
1453 fd = mknod ("bash-aclocal/sh-np-autoconf", 0666 | S_IFIFO, 0);
1455 rmdir ("bash-aclocal");
1459 unlink ("bash-aclocal/sh-np-autoconf");
1460 rmdir ("bash-aclocal");
1463 ]])], [bash_cv_sys_named_pipes=present], [bash_cv_sys_named_pipes=missing],
1464 [AC_MSG_WARN(cannot check for named pipes if cross-compiling -- defaulting to missing)
1465 bash_cv_sys_named_pipes=missing]
1467 AC_MSG_RESULT($bash_cv_sys_named_pipes)
1468 if test $bash_cv_sys_named_pipes = missing; then
1469 AC_DEFINE(NAMED_PIPES_MISSING)
1473 AC_DEFUN(BASH_SYS_DEFAULT_MAIL_DIR,
1474 [AC_MSG_CHECKING(for default mail directory)
1475 AC_CACHE_VAL(bash_cv_mail_dir,
1476 [if test -d /var/mail; then
1477 bash_cv_mail_dir=/var/mail
1478 elif test -d /var/spool/mail; then
1479 bash_cv_mail_dir=/var/spool/mail
1480 elif test -d /usr/mail; then
1481 bash_cv_mail_dir=/usr/mail
1482 elif test -d /usr/spool/mail; then
1483 bash_cv_mail_dir=/usr/spool/mail
1485 bash_cv_mail_dir=unknown
1488 AC_MSG_RESULT($bash_cv_mail_dir)
1489 AC_DEFINE_UNQUOTED(DEFAULT_MAIL_DIRECTORY, "$bash_cv_mail_dir")
1492 AC_DEFUN(BASH_HAVE_TIOCGWINSZ,
1493 [AC_MSG_CHECKING(for TIOCGWINSZ in sys/ioctl.h)
1494 AC_CACHE_VAL(bash_cv_tiocgwinsz_in_ioctl,
1495 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1496 #include <sys/types.h>
1497 #include <sys/ioctl.h>]], [[int x = TIOCGWINSZ;]] )],
1498 [bash_cv_tiocgwinsz_in_ioctl=yes], [bash_cv_tiocgwinsz_in_ioctl=no]
1500 AC_MSG_RESULT($bash_cv_tiocgwinsz_in_ioctl)
1501 if test $bash_cv_tiocgwinsz_in_ioctl = yes; then
1502 AC_DEFINE(GWINSZ_IN_SYS_IOCTL)
1506 AC_DEFUN(BASH_HAVE_TIOCSTAT,
1507 [AC_MSG_CHECKING(for TIOCSTAT in sys/ioctl.h)
1508 AC_CACHE_VAL(bash_cv_tiocstat_in_ioctl,
1509 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1510 #include <sys/types.h>
1511 #include <sys/ioctl.h>]], [[int x = TIOCSTAT;]] )],
1512 [bash_cv_tiocstat_in_ioctl=yes], [bash_cv_tiocstat_in_ioctl=no]
1514 AC_MSG_RESULT($bash_cv_tiocstat_in_ioctl)
1515 if test $bash_cv_tiocstat_in_ioctl = yes; then
1516 AC_DEFINE(TIOCSTAT_IN_SYS_IOCTL)
1520 AC_DEFUN(BASH_HAVE_FIONREAD,
1521 [AC_MSG_CHECKING(for FIONREAD in sys/ioctl.h)
1522 AC_CACHE_VAL(bash_cv_fionread_in_ioctl,
1523 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1524 #include <sys/types.h>
1525 #include <sys/ioctl.h>]], [[int x = FIONREAD;]] )],
1526 [bash_cv_fionread_in_ioctl=yes], [bash_cv_fionread_in_ioctl=no]
1528 AC_MSG_RESULT($bash_cv_fionread_in_ioctl)
1529 if test $bash_cv_fionread_in_ioctl = yes; then
1530 AC_DEFINE(FIONREAD_IN_SYS_IOCTL)
1535 dnl See if speed_t is declared in <sys/types.h>. Some versions of linux
1536 dnl require a definition of speed_t each time <termcap.h> is included,
1537 dnl but you can only get speed_t if you include <termios.h> (on some
1538 dnl versions) or <sys/types.h> (on others).
1540 AC_DEFUN(BASH_CHECK_SPEED_T,
1541 [AC_MSG_CHECKING(for speed_t in sys/types.h)
1542 AC_CACHE_VAL(bash_cv_speed_t_in_sys_types,
1545 [[#include <sys/types.h>]],
1547 [bash_cv_speed_t_in_sys_types=yes],[bash_cv_speed_t_in_sys_types=no])])
1548 AC_MSG_RESULT($bash_cv_speed_t_in_sys_types)
1549 if test $bash_cv_speed_t_in_sys_types = yes; then
1550 AC_DEFINE(SPEED_T_IN_SYS_TYPES)
1554 AC_DEFUN(BASH_CHECK_GETPW_FUNCS,
1555 [AC_MSG_CHECKING(whether getpw functions are declared in pwd.h)
1556 AC_CACHE_VAL(bash_cv_getpw_declared,
1557 [AC_EGREP_CPP(getpwuid,
1559 #include <sys/types.h>
1560 #ifdef HAVE_UNISTD_H
1561 # include <unistd.h>
1565 bash_cv_getpw_declared=yes,bash_cv_getpw_declared=no)])
1566 AC_MSG_RESULT($bash_cv_getpw_declared)
1567 if test $bash_cv_getpw_declared = yes; then
1568 AC_DEFINE(HAVE_GETPW_DECLS)
1572 AC_DEFUN(BASH_CHECK_DEV_FD,
1573 [AC_MSG_CHECKING(whether /dev/fd is available)
1574 AC_CACHE_VAL(bash_cv_dev_fd,
1576 if test -d /dev/fd && (exec test -r /dev/fd/0 < /dev/null) ; then
1577 # check for systems like FreeBSD 5 that only provide /dev/fd/[012]
1578 if (exec test -r /dev/fd/3 3</dev/null) ; then
1579 bash_cv_dev_fd=standard
1581 bash_cv_dev_fd=absent
1584 if test -z "$bash_cv_dev_fd" ; then
1585 if test -d /proc/self/fd && (exec test -r /proc/self/fd/0 < /dev/null) ; then
1586 bash_cv_dev_fd=whacky
1588 bash_cv_dev_fd=absent
1592 AC_MSG_RESULT($bash_cv_dev_fd)
1593 if test $bash_cv_dev_fd = "standard"; then
1594 AC_DEFINE(HAVE_DEV_FD)
1595 AC_DEFINE(DEV_FD_PREFIX, "/dev/fd/")
1596 elif test $bash_cv_dev_fd = "whacky"; then
1597 AC_DEFINE(HAVE_DEV_FD)
1598 AC_DEFINE(DEV_FD_PREFIX, "/proc/self/fd/")
1602 AC_DEFUN(BASH_CHECK_DEV_STDIN,
1603 [AC_MSG_CHECKING(whether /dev/stdin stdout stderr are available)
1604 AC_CACHE_VAL(bash_cv_dev_stdin,
1605 [if (exec test -r /dev/stdin < /dev/null) ; then
1606 bash_cv_dev_stdin=present
1608 bash_cv_dev_stdin=absent
1611 AC_MSG_RESULT($bash_cv_dev_stdin)
1612 if test $bash_cv_dev_stdin = "present"; then
1613 AC_DEFINE(HAVE_DEV_STDIN)
1618 AC_DEFUN(BASH_CHECK_RLIMIT,
1619 [AC_CACHE_VAL(bash_cv_rlimit,
1620 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1621 #include <sys/types.h>
1622 #include <sys/resource.h>
1628 [bash_cv_rlimit=yes], [bash_cv_rlimit=no]
1633 dnl Check if HPUX needs _KERNEL defined for RLIMIT_* definitions
1635 AC_DEFUN(BASH_CHECK_KERNEL_RLIMIT,
1636 [AC_MSG_CHECKING([whether $host_os needs _KERNEL for RLIMIT defines])
1637 AC_CACHE_VAL(bash_cv_kernel_rlimit,
1639 if test $bash_cv_rlimit = no; then
1640 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1641 #include <sys/types.h>
1643 #include <sys/resource.h>
1649 ]] )], [bash_cv_kernel_rlimit=yes], [bash_cv_kernel_rlimit=no] )
1652 AC_MSG_RESULT($bash_cv_kernel_rlimit)
1653 if test $bash_cv_kernel_rlimit = yes; then
1654 AC_DEFINE(RLIMIT_NEEDS_KERNEL)
1659 dnl Check for 64-bit off_t -- used for malloc alignment
1661 dnl C does not allow duplicate case labels, so the compile will fail if
1662 dnl sizeof(off_t) is > 4.
1664 AC_DEFUN(BASH_CHECK_OFF_T_64,
1665 [AC_CACHE_CHECK(for 64-bit off_t, bash_cv_off_t_64,
1666 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1667 #ifdef HAVE_UNISTD_H
1670 #include <sys/types.h>
1672 switch (0) case 0: case (sizeof (off_t) <= 4):;
1673 ]] )], [bash_cv_off_t_64=no], [bash_cv_off_t_64=yes]
1675 if test $bash_cv_off_t_64 = yes; then
1676 AC_DEFINE(HAVE_OFF_T_64)
1679 AC_DEFUN(BASH_CHECK_RTSIGS,
1680 [AC_MSG_CHECKING(for unusable real-time signals due to large values)
1681 AC_CACHE_VAL(bash_cv_unusable_rtsigs,
1682 [AC_RUN_IFELSE([AC_LANG_SOURCE([[
1683 #include <sys/types.h>
1694 int n_sigs = 2 * NSIG;
1696 int rtmin = SIGRTMIN;
1701 exit(rtmin < n_sigs);
1703 ]])], [bash_cv_unusable_rtsigs=yes], [bash_cv_unusable_rtsigs=no],
1704 [AC_MSG_WARN(cannot check real-time signals if cross compiling -- defaulting to yes)
1705 bash_cv_unusable_rtsigs=yes]
1707 AC_MSG_RESULT($bash_cv_unusable_rtsigs)
1708 if test $bash_cv_unusable_rtsigs = yes; then
1709 AC_DEFINE(UNUSABLE_RT_SIGNALS)
1714 dnl check for availability of multibyte characters and functions
1716 dnl geez, I wish I didn't have to check for all of this stuff separately
1718 AC_DEFUN(BASH_CHECK_MULTIBYTE,
1720 AC_CHECK_HEADERS(wctype.h)
1721 AC_CHECK_HEADERS(wchar.h)
1722 AC_CHECK_HEADERS(langinfo.h)
1724 AC_CHECK_HEADERS(mbstr.h)
1726 AC_CHECK_FUNC(mbrlen, AC_DEFINE(HAVE_MBRLEN))
1727 AC_CHECK_FUNC(mbscasecmp, AC_DEFINE(HAVE_MBSCASECMP))
1728 AC_CHECK_FUNC(mbscmp, AC_DEFINE(HAVE_MBSCMP))
1729 AC_CHECK_FUNC(mbsncmp, AC_DEFINE(HAVE_MBSNCMP))
1730 AC_CHECK_FUNC(mbsnrtowcs, AC_DEFINE(HAVE_MBSNRTOWCS))
1731 AC_CHECK_FUNC(mbsrtowcs, AC_DEFINE(HAVE_MBSRTOWCS))
1733 AC_REPLACE_FUNCS(mbschr)
1735 AC_CHECK_FUNC(wcrtomb, AC_DEFINE(HAVE_WCRTOMB))
1736 AC_CHECK_FUNC(wcscoll, AC_DEFINE(HAVE_WCSCOLL))
1737 AC_CHECK_FUNC(wcsdup, AC_DEFINE(HAVE_WCSDUP))
1738 AC_CHECK_FUNC(wcwidth, AC_DEFINE(HAVE_WCWIDTH))
1739 AC_CHECK_FUNC(wctype, AC_DEFINE(HAVE_WCTYPE))
1740 AC_CHECK_FUNC(wcsnrtombs, AC_DEFINE(HAVE_WCSNRTOMBS))
1742 AC_REPLACE_FUNCS(wcswidth)
1744 dnl checks for both mbrtowc and mbstate_t
1746 if test $ac_cv_func_mbrtowc = yes; then
1747 AC_DEFINE(HAVE_MBSTATE_T)
1750 AC_CHECK_FUNCS(iswlower iswupper towlower towupper iswctype)
1752 AC_REQUIRE([AM_LANGINFO_CODESET])
1754 dnl check for wchar_t in <wchar.h>
1755 AC_CACHE_CHECK([for wchar_t in wchar.h], bash_cv_type_wchar_t,
1756 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([
1757 [#include <wchar.h>]],
1761 ]] )], [bash_cv_type_wchar_t=yes], [bash_cv_type_wchar_t=no]
1763 if test $bash_cv_type_wchar_t = yes; then
1764 AC_DEFINE(HAVE_WCHAR_T, 1, [systems should define this type here])
1767 dnl check for wctype_t in <wctype.h>
1768 AC_CACHE_CHECK([for wctype_t in wctype.h], bash_cv_type_wctype_t,
1769 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([
1770 [#include <wctype.h>]],
1774 ]] )], [bash_cv_type_wctype_t=yes], [bash_cv_type_wctype_t=no]
1776 if test $bash_cv_type_wctype_t = yes; then
1777 AC_DEFINE(HAVE_WCTYPE_T, 1, [systems should define this type here])
1780 dnl check for wint_t in <wctype.h>
1781 AC_CACHE_CHECK([for wint_t in wctype.h], bash_cv_type_wint_t,
1782 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([
1783 [#include <wctype.h>]],
1787 ]] )], [bash_cv_type_wint_t=yes], [bash_cv_type_wint_t=no]
1789 if test $bash_cv_type_wint_t = yes; then
1790 AC_DEFINE(HAVE_WINT_T, 1, [systems should define this type here])
1793 dnl check for broken wcwidth
1794 AC_CACHE_CHECK([for wcwidth broken with unicode combining characters],
1795 bash_cv_wcwidth_broken,
1796 [AC_RUN_IFELSE([AC_LANG_SOURCE([[
1805 main(int c, char **v)
1809 setlocale(LC_ALL, "en_US.UTF-8");
1810 w = wcwidth (0x0301);
1811 exit (w == 0); /* exit 0 if wcwidth broken */
1813 ]])], [bash_cv_wcwidth_broken=yes], [bash_cv_wcwidth_broken=no],
1814 [bash_cv_wcwidth_broken=no]
1816 if test "$bash_cv_wcwidth_broken" = yes; then
1817 AC_DEFINE(WCWIDTH_BROKEN, 1, [wcwidth is usually not broken])
1820 if test "$am_cv_func_iconv" = yes; then
1822 LIBS="$LIBS $LIBINTL $LIBICONV"
1823 AC_CHECK_FUNCS(locale_charset)
1827 AC_CHECK_SIZEOF(wchar_t, 4)
1831 dnl need: prefix exec_prefix libdir includedir CC TERMCAP_LIB
1834 dnl BASH_CHECK_LIB_TERMCAP
1836 AC_DEFUN([RL_LIB_READLINE_VERSION],
1838 AC_REQUIRE([BASH_CHECK_LIB_TERMCAP])
1840 AC_MSG_CHECKING([version of installed readline library])
1842 # What a pain in the ass this is.
1844 # save cpp and ld options
1845 _save_CFLAGS="$CFLAGS"
1846 _save_LDFLAGS="$LDFLAGS"
1849 # Don't set ac_cv_rl_prefix if the caller has already assigned a value. This
1850 # allows the caller to do something like $_rl_prefix=$withval if the user
1851 # specifies --with-installed-readline=PREFIX as an argument to configure
1853 if test -z "$ac_cv_rl_prefix"; then
1854 test "x$prefix" = xNONE && ac_cv_rl_prefix=$ac_default_prefix || ac_cv_rl_prefix=${prefix}
1857 eval ac_cv_rl_includedir=${ac_cv_rl_prefix}/include
1858 eval ac_cv_rl_libdir=${ac_cv_rl_prefix}/lib
1860 LIBS="$LIBS -lreadline ${TERMCAP_LIB}"
1861 CFLAGS="$CFLAGS -I${ac_cv_rl_includedir}"
1862 LDFLAGS="$LDFLAGS -L${ac_cv_rl_libdir}"
1864 AC_CACHE_VAL(ac_cv_rl_version,
1865 [AC_RUN_IFELSE([AC_LANG_SOURCE([[
1867 #include <readline/readline.h>
1870 extern int rl_gnu_readline_p;
1876 fp = fopen("conftest.rlv", "w");
1879 if (rl_gnu_readline_p != 1)
1880 fprintf(fp, "0.0\n");
1882 fprintf(fp, "%s\n", rl_library_version ? rl_library_version : "0.0");
1887 [ac_cv_rl_version=`cat conftest.rlv`],
1888 [ac_cv_rl_version='0.0'],
1889 [ac_cv_rl_version='8.0']
1892 CFLAGS="$_save_CFLAGS"
1893 LDFLAGS="$_save_LDFLAGS"
1900 case "$ac_cv_rl_version" in
1901 2*|3*|4*|5*|6*|7*|8*|9*)
1902 RL_MAJOR=`echo $ac_cv_rl_version | sed 's:\..*$::'`
1903 RL_MINOR=`echo $ac_cv_rl_version | sed -e 's:^.*\.::' -e 's:[[a-zA-Z]]*$::'`
1909 [[0-9][0-9]]) _RL_MAJOR=$RL_MAJOR ;;
1910 [[0-9]]) _RL_MAJOR=0$RL_MAJOR ;;
1916 [[0-9][0-9]]) _RL_MINOR=$RL_MINOR ;;
1917 [[0-9]]) _RL_MINOR=0$RL_MINOR ;;
1921 RL_VERSION="0x${_RL_MAJOR}${_RL_MINOR}"
1923 # Readline versions greater than 4.2 have these defines in readline.h
1925 if test $ac_cv_rl_version = '0.0' ; then
1926 AC_MSG_WARN([Could not test version of installed readline library.])
1927 elif test $RL_MAJOR -gt 4 || { test $RL_MAJOR = 4 && test $RL_MINOR -gt 2 ; } ; then
1928 # set these for use by the caller
1929 RL_PREFIX=$ac_cv_rl_prefix
1930 RL_LIBDIR=$ac_cv_rl_libdir
1931 RL_INCLUDEDIR=$ac_cv_rl_includedir
1932 AC_MSG_RESULT($ac_cv_rl_version)
1935 AC_DEFINE_UNQUOTED(RL_READLINE_VERSION, $RL_VERSION, [encoded version of the installed readline library])
1936 AC_DEFINE_UNQUOTED(RL_VERSION_MAJOR, $RL_MAJOR, [major version of installed readline library])
1937 AC_DEFINE_UNQUOTED(RL_VERSION_MINOR, $RL_MINOR, [minor version of installed readline library])
1939 AC_SUBST(RL_VERSION)
1943 # set these for use by the caller
1944 RL_PREFIX=$ac_cv_rl_prefix
1945 RL_LIBDIR=$ac_cv_rl_libdir
1946 RL_INCLUDEDIR=$ac_cv_rl_includedir
1948 AC_MSG_RESULT($ac_cv_rl_version)
1953 AC_DEFUN(BASH_CHECK_WCONTINUED,
1955 AC_MSG_CHECKING(whether WCONTINUED flag to waitpid is unavailable or available but broken)
1956 AC_CACHE_VAL(bash_cv_wcontinued_broken,
1957 [AC_RUN_IFELSE([AC_LANG_SOURCE([[
1958 #include <sys/types.h>
1959 #include <sys/wait.h>
1972 x = waitpid(-1, (int *)0, WNOHANG|WCONTINUED);
1973 if (x == -1 && errno == EINVAL)
1978 ]])], [bash_cv_wcontinued_broken=no], [bash_cv_wcontinued_broken=yes],
1979 [AC_MSG_WARN(cannot check WCONTINUED if cross compiling -- defaulting to no)
1980 bash_cv_wcontinued_broken=no]
1982 AC_MSG_RESULT($bash_cv_wcontinued_broken)
1983 if test $bash_cv_wcontinued_broken = yes; then
1984 AC_DEFINE(WCONTINUED_BROKEN)
1989 dnl tests added for bashdb
1993 AC_DEFUN([AM_PATH_LISPDIR],
1994 [AC_ARG_WITH(lispdir, AS_HELP_STRING([--with-lispdir], [override the default lisp directory]),
1995 [ lispdir="$withval"
1996 AC_MSG_CHECKING([where .elc files should go])
1997 AC_MSG_RESULT([$lispdir])],
1999 # If set to t, that means we are running in a shell under Emacs.
2000 # If you have an Emacs named "t", then use the full path.
2001 test x"$EMACS" = xt && EMACS=
2002 AC_CHECK_PROGS(EMACS, emacs xemacs, no)
2003 if test $EMACS != "no"; then
2004 if test x${lispdir+set} != xset; then
2005 AC_CACHE_CHECK([where .elc files should go], [am_cv_lispdir], [dnl
2006 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;}'`
2007 if test -z "$am_cv_lispdir"; then
2008 am_cv_lispdir='${datadir}/emacs/site-lisp'
2011 lispdir="$am_cv_lispdir"
2019 AC_DEFUN([BASH_FUNC_FPURGE],
2021 AC_CHECK_FUNCS_ONCE([fpurge])
2022 AC_CHECK_FUNCS_ONCE([__fpurge])
2023 AC_CHECK_DECLS([fpurge], , , [#include <stdio.h>])
2026 AC_DEFUN([BASH_FUNC_SNPRINTF],
2028 AC_CHECK_FUNCS_ONCE([snprintf])
2029 if test X$ac_cv_func_snprintf = Xyes; then
2030 AC_CACHE_CHECK([for standard-conformant snprintf], [bash_cv_func_snprintf],
2031 [AC_RUN_IFELSE([AC_LANG_SOURCE([[
2039 n = snprintf (0, 0, "%s", "0123456");
2042 ]])], [bash_cv_func_snprintf=yes], [bash_cv_func_snprintf=no],
2043 [AC_MSG_WARN([cannot check standard snprintf if cross-compiling])
2044 bash_cv_func_snprintf=yes]
2046 if test $bash_cv_func_snprintf = no; then
2047 ac_cv_func_snprintf=no
2050 if test $ac_cv_func_snprintf = no; then
2051 AC_DEFINE(HAVE_SNPRINTF, 0,
2052 [Define if you have a standard-conformant snprintf function.])
2056 AC_DEFUN([BASH_FUNC_VSNPRINTF],
2058 AC_CHECK_FUNCS_ONCE([vsnprintf])
2059 if test X$ac_cv_func_vsnprintf = Xyes; then
2060 AC_CACHE_CHECK([for standard-conformant vsnprintf], [bash_cv_func_vsnprintf],
2061 [AC_RUN_IFELSE([AC_LANG_SOURCE([[
2067 foo(const char *fmt, ...)
2072 va_start(args, fmt);
2073 n = vsnprintf(0, 0, fmt, args);
2082 n = foo("%s", "0123456");
2085 ]])], [bash_cv_func_vsnprintf=yes], [bash_cv_func_vsnprintf=no],
2086 [AC_MSG_WARN([cannot check standard vsnprintf if cross-compiling])
2087 bash_cv_func_vsnprintf=yes]
2089 if test $bash_cv_func_vsnprintf = no; then
2090 ac_cv_func_vsnprintf=no
2093 if test $ac_cv_func_vsnprintf = no; then
2094 AC_DEFINE(HAVE_VSNPRINTF, 0,
2095 [Define if you have a standard-conformant vsnprintf function.])
2099 AC_DEFUN(BASH_STRUCT_WEXITSTATUS_OFFSET,
2100 [AC_MSG_CHECKING(for offset of exit status in return status from wait)
2101 AC_CACHE_VAL(bash_cv_wexitstatus_offset,
2102 [AC_RUN_IFELSE([AC_LANG_SOURCE([[
2106 #include <sys/wait.h>
2109 main(int c, char **v)
2119 /* wait for the process */
2125 for (i = 0; i < (sizeof(s) * 8); i++)
2127 n = (s >> i) & 0xff;
2134 ]])], [bash_cv_wexitstatus_offset=0], [bash_cv_wexitstatus_offset=$?],
2135 [AC_MSG_WARN(cannot check WEXITSTATUS offset if cross compiling -- defaulting to 0)
2136 bash_cv_wexitstatus_offset=0]
2138 if test "$bash_cv_wexitstatus_offset" -gt 32 ; then
2139 AC_MSG_WARN(bad exit status from test program -- defaulting to 0)
2140 bash_cv_wexitstatus_offset=0
2142 AC_MSG_RESULT($bash_cv_wexitstatus_offset)
2143 AC_DEFINE_UNQUOTED([WEXITSTATUS_OFFSET], [$bash_cv_wexitstatus_offset], [Offset of exit status in wait status word])
2146 AC_DEFUN([BASH_FUNC_SBRK],
2148 AC_MSG_CHECKING([for sbrk])
2149 AC_CACHE_VAL(ac_cv_func_sbrk,
2152 [[#include <unistd.h>]],
2153 [[ void *x = sbrk (4096); ]])],
2154 [ac_cv_func_sbrk=yes],[ac_cv_func_sbrk=no])])
2155 AC_MSG_RESULT($ac_cv_func_sbrk)
2156 if test X$ac_cv_func_sbrk = Xyes; then
2157 AC_CACHE_CHECK([for working sbrk], [bash_cv_func_sbrk],
2158 [AC_RUN_IFELSE([AC_LANG_SOURCE([[
2163 main(int c, char **v)
2168 exit ((x == (void *)-1) ? 1 : 0);
2170 ]])],[bash_cv_func_sbrk=yes],[bash_cv_func_sbrk=no],[AC_MSG_WARN([cannot check working sbrk if cross-compiling])
2171 bash_cv_func_sbrk=yes
2173 if test $bash_cv_func_sbrk = no; then
2177 if test $ac_cv_func_sbrk = yes; then
2178 AC_DEFINE(HAVE_SBRK, 1,
2179 [Define if you have a working sbrk function.])
2183 AC_DEFUN(BASH_FUNC_FNMATCH_EQUIV_FALLBACK,
2184 [AC_MSG_CHECKING(whether fnmatch can be used to check bracket equivalence classes)
2185 AC_CACHE_VAL(bash_cv_fnmatch_equiv_fallback,
2186 [AC_RUN_IFELSE([AC_LANG_SOURCE([[
2190 #include <fnmatch.h>
2193 char *pattern = "[[=a=]]";
2195 /* char *string = "รค"; */
2196 unsigned char string[4] = { '\xc3', '\xa4', '\0' };
2199 main (int c, char **v)
2201 setlocale (LC_ALL, "en_US.UTF-8");
2202 if (fnmatch (pattern, (const char *)string, 0) != FNM_NOMATCH)
2206 ]])], [bash_cv_fnmatch_equiv_fallback=yes], [bash_cv_fnmatch_equiv_fallback=no],
2207 [AC_MSG_WARN(cannot check fnmatch if cross compiling -- defaulting to no)
2208 bash_cv_fnmatch_equiv_fallback=no]
2210 AC_MSG_RESULT($bash_cv_fnmatch_equiv_fallback)
2211 if test "$bash_cv_fnmatch_equiv_fallback" = "yes" ; then
2212 bash_cv_fnmatch_equiv_value=1
2214 bash_cv_fnmatch_equiv_value=0
2216 AC_DEFINE_UNQUOTED([FNMATCH_EQUIV_FALLBACK], [$bash_cv_fnmatch_equiv_value], [Whether fnmatch can be used for bracket equivalence classes])