2 dnl Bash specific tests
4 dnl Some derived from PDKSH 5.1.3 autoconf tests
7 dnl Check if dup2() does not clear the close on exec flag
9 AC_DEFUN(BASH_DUP2_CLOEXEC_CHECK,
10 [AC_MSG_CHECKING(if dup2 fails to clear the close-on-exec flag)
11 AC_CACHE_VAL(bash_cv_dup2_broken,
13 #include <sys/types.h>
18 fd1 = open("/dev/null", 2);
19 if (fcntl(fd1, 2, 1) < 0)
24 fl = fcntl(fd2, 1, 0);
25 /* fl will be 1 if dup2 did not reset the close-on-exec flag. */
28 ], bash_cv_dup2_broken=yes, bash_cv_dup2_broken=no,
29 AC_MSG_ERROR(cannot check dup2 if cross compiling))
31 AC_MSG_RESULT($bash_cv_dup2_broken)
32 if test $bash_cv_dup2_broken = yes; then
33 AC_DEFINE(DUP2_BROKEN)
37 dnl Check type of signal routines (posix, 4.2bsd, 4.1bsd or v7)
38 AC_DEFUN(BASH_SIGNAL_CHECK,
39 [AC_REQUIRE([AC_TYPE_SIGNAL])
40 AC_MSG_CHECKING(for type of signal functions)
41 AC_CACHE_VAL(bash_cv_signal_vintage,
43 AC_TRY_LINK([#include <signal.h>],[
46 sigemptyset(&ss); sigsuspend(&ss);
47 sigaction(SIGINT, &sa, (struct sigaction *) 0);
48 sigprocmask(SIG_BLOCK, &ss, (sigset_t *) 0);
49 ], bash_cv_signal_vintage=posix,
51 AC_TRY_LINK([#include <signal.h>], [
52 int mask = sigmask(SIGINT);
53 sigsetmask(mask); sigblock(mask); sigpause(mask);
54 ], bash_cv_signal_vintage=4.2bsd,
58 RETSIGTYPE foo() { }], [
59 int mask = sigmask(SIGINT);
60 sigset(SIGINT, foo); sigrelse(SIGINT);
61 sighold(SIGINT); sigpause(SIGINT);
62 ], bash_cv_signal_vintage=svr3, bash_cv_signal_vintage=v7
67 AC_MSG_RESULT($bash_cv_signal_vintage)
68 if test "$bash_cv_signal_vintage" = posix; then
69 AC_DEFINE(HAVE_POSIX_SIGNALS)
70 elif test "$bash_cv_signal_vintage" = "4.2bsd"; then
71 AC_DEFINE(HAVE_BSD_SIGNALS)
72 elif test "$bash_cv_signal_vintage" = svr3; then
73 AC_DEFINE(HAVE_USG_SIGHOLD)
77 dnl Check if the pgrp of setpgrp() can't be the pid of a zombie process.
78 AC_DEFUN(BASH_PGRP_SYNC,
79 [AC_REQUIRE([AC_FUNC_GETPGRP])
80 AC_MSG_CHECKING(whether pgrps need synchronization)
81 AC_CACHE_VAL(bash_cv_pgrp_pipe,
89 # define getpgID() getpgrp()
91 # define getpgID() getpgrp(0)
92 # define setpgid(x,y) setpgrp(x,y)
94 int pid1, pid2, fds[2];
98 switch (pid1 = fork()) {
102 setpgid(0, getpid());
107 sleep(2); /* let first child die */
112 switch (pid2 = fork()) {
117 ok = getpgID() == pid1;
118 write(fds[1], &ok, 1);
124 if (read(fds[0], &ok, 1) != 1)
130 ], bash_cv_pgrp_pipe=no,bash_cv_pgrp_pipe=yes,
131 AC_MSG_ERROR(cannot check pgrp synchronization if cross compiling))
133 AC_MSG_RESULT($bash_cv_pgrp_pipe)
134 if test $bash_cv_pgrp_pipe = yes; then
140 dnl check for typedef'd symbols in header files, but allow the caller to
141 dnl specify the include files to be checked in addition to the default
143 dnl BASH_CHECK_TYPE(TYPE, HEADERS, DEFAULT[, VALUE-IF-FOUND])
144 AC_DEFUN(BASH_CHECK_TYPE,
145 [AC_REQUIRE([AC_HEADER_STDC])dnl
146 AC_MSG_CHECKING(for $1)
147 AC_CACHE_VAL(bash_cv_type_$1,
148 [AC_EGREP_CPP($1, [#include <sys/types.h>
153 ], bash_cv_type_$1=yes, bash_cv_type_$1=no)])
154 AC_MSG_RESULT($bash_cv_type_$1)
155 ifelse($#, 4, [if test $bash_cv_type_$1 = yes; then
158 if test $bash_cv_type_$1 = no; then
164 dnl Type of struct rlimit fields: some systems (OSF/1, NetBSD, RISC/os 5.0)
165 dnl have a rlim_t, others (4.4BSD based systems) use quad_t, others use
166 dnl long and still others use int (HP-UX 9.01, SunOS 4.1.3). To simplify
167 dnl matters, this just checks for rlim_t, quad_t, or long.
169 AC_DEFUN(BASH_RLIMIT_TYPE,
170 [AC_MSG_CHECKING(for size and type of struct rlimit fields)
171 AC_CACHE_VAL(bash_cv_type_rlimit,
172 [AC_TRY_COMPILE([#include <sys/types.h>],
173 [rlim_t xxx;], bash_cv_type_rlimit=rlim_t,[
175 #include <sys/types.h>
176 #include <sys/time.h>
177 #include <sys/resource.h>
182 if (sizeof(rl.rlim_cur) == sizeof(quad_t))
186 }], bash_cv_type_rlimit=quad_t, bash_cv_type_rlimit=long,
187 AC_MSG_ERROR(cannot check quad_t if cross compiling))])
189 AC_MSG_RESULT($bash_cv_type_rlimit)
190 if test $bash_cv_type_rlimit = quad_t; then
191 AC_DEFINE(RLIMTYPE, quad_t)
192 elif test $bash_cv_type_rlimit = rlim_t; then
193 AC_DEFINE(RLIMTYPE, rlim_t)
198 dnl Check for sys_siglist[] or _sys_siglist[]
200 AC_DEFUN(BASH_UNDER_SYS_SIGLIST,
201 [AC_MSG_CHECKING([for _sys_siglist in system C library])
202 AC_CACHE_VAL(bash_cv_under_sys_siglist,
204 #include <sys/types.h>
210 extern char *_sys_siglist[];
214 char *msg = _sys_siglist[2];
217 bash_cv_under_sys_siglist=yes, bash_cv_under_sys_siglist=no,
218 AC_MSG_ERROR(cannot check for _sys_siglist[] if cross compiling))])dnl
219 AC_MSG_RESULT($bash_cv_under_sys_siglist)
220 if test $bash_cv_under_sys_siglist = yes; then
221 AC_DEFINE(HAVE_UNDER_SYS_SIGLIST)
225 AC_DEFUN(BASH_SYS_SIGLIST,
226 [AC_REQUIRE([AC_DECL_SYS_SIGLIST])
227 AC_MSG_CHECKING([for sys_siglist in system C library])
228 AC_CACHE_VAL(bash_cv_sys_siglist,
230 #include <sys/types.h>
235 #ifndef SYS_SIGLIST_DECLARED
236 extern char *sys_siglist[];
240 char *msg = sys_siglist[2];
243 bash_cv_sys_siglist=yes, bash_cv_sys_siglist=no,
244 AC_MSG_ERROR(cannot check for sys_siglist if cross compiling))])dnl
245 AC_MSG_RESULT($bash_cv_sys_siglist)
246 if test $bash_cv_sys_siglist = yes; then
247 AC_DEFINE(HAVE_SYS_SIGLIST)
251 dnl Check for sys_errlist[] and sys_nerr, check for declaration
252 AC_DEFUN(BASH_SYS_ERRLIST,
253 [AC_MSG_CHECKING([for sys_errlist and sys_nerr])
254 AC_CACHE_VAL(bash_cv_sys_errlist,
255 [AC_TRY_LINK([#include <errno.h>],
256 [extern char *sys_errlist[];
258 char *msg = sys_errlist[sys_nerr - 1];],
259 bash_cv_sys_errlist=yes, bash_cv_sys_errlist=no)])dnl
260 AC_MSG_RESULT($bash_cv_sys_errlist)
261 if test $bash_cv_sys_errlist = yes; then
262 AC_DEFINE(HAVE_SYS_ERRLIST)
266 dnl Check to see if opendir will open non-directories (not a nice thing)
267 AC_DEFUN(BASH_FUNC_OPENDIR_CHECK,
268 [AC_REQUIRE([AC_HEADER_DIRENT])dnl
269 AC_MSG_CHECKING(if opendir() opens non-directories)
270 AC_CACHE_VAL(bash_cv_opendir_not_robust,
273 #include <sys/types.h>
277 #endif /* HAVE_UNISTD_H */
278 #if defined(HAVE_DIRENT_H)
281 # define dirent direct
282 # ifdef HAVE_SYS_NDIR_H
283 # include <sys/ndir.h>
284 # endif /* SYSNDIR */
285 # ifdef HAVE_SYS_DIR_H
286 # include <sys/dir.h>
291 #endif /* HAVE_DIRENT_H */
296 unlink("/tmp/not_a_directory");
297 fd = open("/tmp/not_a_directory", O_WRONLY|O_CREAT, 0666);
300 dir = opendir("/tmp/not_a_directory");
301 unlink("/tmp/not_a_directory");
303 }], bash_cv_opendir_not_robust=yes,bash_cv_opendir_not_robust=no,
304 AC_MSG_ERROR(cannot check opendir if cross compiling))])
305 AC_MSG_RESULT($bash_cv_opendir_not_robust)
306 if test $bash_cv_opendir_not_robust = yes; then
307 AC_DEFINE(OPENDIR_NOT_ROBUST)
312 AC_DEFUN(BASH_TYPE_SIGHANDLER,
313 [AC_MSG_CHECKING([whether signal handlers are of type void])
314 AC_CACHE_VAL(bash_cv_void_sighandler,
315 [AC_TRY_COMPILE([#include <sys/types.h>
323 void (*signal ()) ();],
324 [int i;], bash_cv_void_sighandler=yes, bash_cv_void_sighandler=no)])dnl
325 AC_MSG_RESULT($bash_cv_void_sighandler)
326 if test $bash_cv_void_sighandler = yes; then
327 AC_DEFINE(VOID_SIGHANDLER)
331 AC_DEFUN(BASH_FUNC_STRSIGNAL,
332 [AC_MSG_CHECKING([for the existance of strsignal])
333 AC_CACHE_VAL(bash_cv_have_strsignal,
334 [AC_TRY_LINK([#include <sys/types.h>
335 #include <signal.h>],
336 [char *s = (char *)strsignal(2);],
337 bash_cv_have_strsignal=yes, bash_cv_have_strsignal=no)])
338 AC_MSG_RESULT($bash_cv_have_strsignal)
339 if test $bash_cv_have_strsignal = yes; then
340 AC_DEFINE(HAVE_STRSIGNAL)
344 AC_DEFUN(BASH_FUNC_LSTAT,
345 [dnl Cannot use AC_CHECK_FUNCS(lstat) because Linux defines lstat() as an
346 dnl inline function in <sys/stat.h>.
347 AC_CACHE_CHECK([for lstat], bash_cv_func_lstat,
349 #include <sys/types.h>
350 #include <sys/stat.h>
351 ],[ lstat("",(struct stat *)0); ],
352 bash_cv_func_lstat=yes, bash_cv_func_lstat=no)])
353 if test $bash_cv_func_lstat = yes; then
354 AC_DEFINE(HAVE_LSTAT)
358 AC_DEFUN(BASH_STRUCT_TERMIOS_LDISC,
359 [AC_MSG_CHECKING([for a c_line member of struct termios])
360 AC_CACHE_VAL(bash_cv_termios_ldisc,
361 [AC_TRY_COMPILE([#include <sys/types.h>
362 #include <termios.h>],[struct termios t; int i; i = t.c_line;],
363 bash_cv_termios_ldisc=yes, bash_cv_termios_ldisc=no)])dnl
364 AC_MSG_RESULT($bash_cv_termios_ldisc)
365 if test $bash_cv_termios_ldisc = yes; then
366 AC_DEFINE(TERMIOS_LDISC)
370 AC_DEFUN(BASH_STRUCT_TERMIO_LDISC,
371 [AC_MSG_CHECKING([for a c_line member of struct termio])
372 AC_CACHE_VAL(bash_cv_termio_ldisc,
373 [AC_TRY_COMPILE([#include <sys/types.h>
374 #include <termio.h>],[struct termio t; int i; i = t.c_line;],
375 bash_cv_termio_ldisc=yes, bash_cv_termio_ldisc=no)])dnl
376 AC_MSG_RESULT($bash_cv_termio_ldisc)
377 if test $bash_cv_termio_ldisc = yes; then
378 AC_DEFINE(TERMIO_LDISC)
382 AC_DEFUN(BASH_FUNC_GETENV,
383 [AC_MSG_CHECKING(to see if getenv can be redefined)
384 AC_CACHE_VAL(bash_cv_getenv_redef,
396 #if defined (__linux__) || defined (__bsdi__) || defined (convex)
400 #endif /* !__linux__ && !__bsdi__ && !convex */
407 /* The next allows this program to run, but does not allow bash to link
408 when it redefines getenv. I'm not really interested in figuring out
414 exit(s == 0); /* force optimizer to leave getenv in */
416 ], bash_cv_getenv_redef=yes, bash_cv_getenv_redef=no,
417 AC_MSG_ERROR(cannot check getenv redefinition if cross compiling))])
418 AC_MSG_RESULT($bash_cv_getenv_redef)
419 if test $bash_cv_getenv_redef = yes; then
420 AC_DEFINE(CAN_REDEFINE_GETENV)
424 AC_DEFUN(BASH_FUNC_PRINTF,
425 [AC_MSG_CHECKING(for declaration of printf in <stdio.h>)
426 AC_CACHE_VAL(bash_cv_printf_declared,
430 typedef int (*_bashfunc)(const char *, ...);
432 typedef int (*_bashfunc)();
440 ],bash_cv_printf_declared=yes, bash_cv_printf_declared=no,
441 AC_MSG_ERROR(cannot check printf declaration if cross compiling))])
442 AC_MSG_RESULT($bash_cv_printf_declared)
443 if test $bash_cv_printf_declared = yes; then
444 AC_DEFINE(PRINTF_DECLARED)
448 AC_DEFUN(BASH_FUNC_ULIMIT_MAXFDS,
449 [AC_MSG_CHECKING(whether ulimit can substitute for getdtablesize)
450 AC_CACHE_VAL(bash_cv_ulimit_maxfds,
454 long maxfds = ulimit(4, 0L);
455 exit (maxfds == -1L);
457 ],bash_cv_ulimit_maxfds=yes, bash_cv_ulimit_maxfds=no,
458 AC_MSG_ERROR(cannot check ulimit if cross compiling))])
459 AC_MSG_RESULT($bash_cv_ulimit_maxfds)
460 if test $bash_cv_ulimit_maxfds = yes; then
461 AC_DEFINE(ULIMIT_MAXFDS)
465 AC_DEFUN(BASH_CHECK_LIB_TERMCAP,
467 if test "X$bash_cv_termcap_lib" = "X"; then
470 AC_MSG_CHECKING(which library has the termcap functions)
473 AC_CACHE_VAL(bash_cv_termcap_lib,
474 [AC_CHECK_LIB(termcap, tgetent, bash_cv_termcap_lib=libtermcap,
475 [AC_CHECK_LIB(curses, tgetent, bash_cv_termcap_lib=libcurses,
476 [AC_CHECK_LIB(ncurses, tgetent, bash_cv_termcap_lib=libncurses,
477 bash_cv_termcap_lib=gnutermcap)])])])
478 if test "X$_bash_needmsg" = "Xyes"; then
479 AC_MSG_CHECKING(which library has the termcap functions)
481 AC_MSG_RESULT(using $bash_cv_termcap_lib)
482 if test $bash_cv_termcap_lib = gnutermcap; then
483 LDFLAGS="$LDFLAGS -L./lib/termcap"
484 TERMCAP_LIB="./lib/termcap/libtermcap.a"
485 TERMCAP_DEP="./lib/termcap/libtermcap.a"
486 elif test $bash_cv_termcap_lib = libtermcap && test -z "$prefer_curses"; then
487 TERMCAP_LIB=-ltermcap
489 elif test $bash_cv_termcap_lib = libncurses; then
490 TERMCAP_LIB=-lncurses
498 AC_DEFUN(BASH_FUNC_GETCWD,
499 [AC_MSG_CHECKING([if getcwd() calls popen()])
500 AC_CACHE_VAL(bash_cv_getcwd_calls_popen,
524 FILE *_popen(command, type)
528 return (popen (command, type));
552 ], bash_cv_getcwd_calls_popen=no, bash_cv_getcwd_calls_popen=yes,
553 AC_MSG_ERROR(cannot check whether getcwd calls popen if cross compiling))])
554 AC_MSG_RESULT($bash_cv_getcwd_calls_popen)
555 if test $bash_cv_getcwd_calls_popen = yes; then
556 AC_DEFINE(GETCWD_BROKEN)
560 AC_DEFUN(BASH_STRUCT_DIRENT_D_INO,
561 [AC_REQUIRE([AC_HEADER_DIRENT])
562 AC_MSG_CHECKING(if struct dirent has a d_ino member)
563 AC_CACHE_VAL(bash_cv_dirent_has_dino,
566 #include <sys/types.h>
569 #endif /* HAVE_UNISTD_H */
570 #if defined(HAVE_DIRENT_H)
573 # define dirent direct
574 # ifdef HAVE_SYS_NDIR_H
575 # include <sys/ndir.h>
576 # endif /* SYSNDIR */
577 # ifdef HAVE_SYS_DIR_H
578 # include <sys/dir.h>
583 #endif /* HAVE_DIRENT_H */
585 struct dirent d; int z; z = d.d_ino;
586 ], bash_cv_dirent_has_dino=yes, bash_cv_dirent_has_dino=no)])
587 AC_MSG_RESULT($bash_cv_dirent_has_dino)
588 if test $bash_cv_dirent_has_dino = yes; then
589 AC_DEFINE(STRUCT_DIRENT_HAS_D_INO)
593 AC_DEFUN(BASH_STRUCT_DIRENT_D_FILENO,
594 [AC_REQUIRE([AC_HEADER_DIRENT])
595 AC_MSG_CHECKING(if struct dirent has a d_fileno member)
596 AC_CACHE_VAL(bash_cv_dirent_has_d_fileno,
599 #include <sys/types.h>
602 #endif /* HAVE_UNISTD_H */
603 #if defined(HAVE_DIRENT_H)
606 # define dirent direct
607 # ifdef HAVE_SYS_NDIR_H
608 # include <sys/ndir.h>
609 # endif /* SYSNDIR */
610 # ifdef HAVE_SYS_DIR_H
611 # include <sys/dir.h>
616 #endif /* HAVE_DIRENT_H */
618 struct dirent d; int z; z = d.d_fileno;
619 ], bash_cv_dirent_has_d_fileno=yes, bash_cv_dirent_has_d_fileno=no)])
620 AC_MSG_RESULT($bash_cv_dirent_has_d_fileno)
621 if test $bash_cv_dirent_has_d_fileno = yes; then
622 AC_DEFINE(STRUCT_DIRENT_HAS_D_FILENO)
626 AC_DEFUN(BASH_REINSTALL_SIGHANDLERS,
627 [AC_REQUIRE([AC_TYPE_SIGNAL])
628 AC_REQUIRE([BASH_SIGNAL_CHECK])
629 AC_MSG_CHECKING([if signal handlers must be reinstalled when invoked])
630 AC_CACHE_VAL(bash_cv_must_reinstall_sighandlers,
637 typedef RETSIGTYPE sigfunc();
641 #ifdef HAVE_POSIX_SIGNALS
643 set_signal_handler(sig, handler)
647 struct sigaction act, oact;
648 act.sa_handler = handler;
650 sigemptyset (&act.sa_mask);
651 sigemptyset (&oact.sa_mask);
652 sigaction (sig, &act, &oact);
653 return (oact.sa_handler);
656 #define set_signal_handler(s, h) signal(s, h)
669 set_signal_handler(SIGINT, sigint);
670 kill((int)getpid(), SIGINT);
671 kill((int)getpid(), SIGINT);
674 ], bash_cv_must_reinstall_sighandlers=no, bash_cv_must_reinstall_sighandlers=yes,
675 AC_MSG_ERROR(cannot check signal handling if cross compiling))])
676 AC_MSG_RESULT($bash_cv_must_reinstall_sighandlers)
677 if test $bash_cv_must_reinstall_sighandlers = yes; then
678 AC_DEFINE(MUST_REINSTALL_SIGHANDLERS)
682 AC_DEFUN(BASH_FUNC_SBRK_DECLARED,
683 [AC_MSG_CHECKING(for declaration of sbrk in <unistd.h>)
684 AC_CACHE_VAL(bash_cv_sbrk_declared,
685 [AC_EGREP_HEADER(sbrk, unistd.h,
686 bash_cv_sbrk_declared=yes, bash_cv_sbrk_declared=no)])
687 AC_MSG_RESULT($bash_cv_sbrk_declared)
688 if test $bash_cv_sbrk_declared = yes; then
689 AC_DEFINE(SBRK_DECLARED)
693 dnl check that some necessary job control definitions are present
694 AC_DEFUN(BASH_JOB_CONTROL_MISSING,
695 [AC_REQUIRE([BASH_SIGNAL_CHECK])
696 AC_MSG_CHECKING(for presence of necessary job control definitions)
697 AC_CACHE_VAL(bash_cv_job_control_missing,
699 #include <sys/types.h>
700 #ifdef HAVE_SYS_WAIT_H
701 #include <sys/wait.h>
708 /* Add more tests in here as appropriate. */
712 #if !defined (HAVE_POSIX_SIGNALS) && !defined (HAVE_BSD_SIGNALS)
716 /* signals and tty control. */
717 #if !defined (SIGTSTP) || !defined (SIGSTOP) || !defined (SIGCONT)
721 /* process control */
722 #if !defined (WNOHANG) || !defined (WUNTRACED)
726 /* Posix systems have tcgetpgrp and waitpid. */
727 #if defined (_POSIX_VERSION) && !defined (HAVE_TCGETPGRP)
731 #if defined (_POSIX_VERSION) && !defined (HAVE_WAITPID)
735 /* Other systems have TIOCSPGRP/TIOCGPRGP and wait3. */
736 #if !defined (_POSIX_VERSION) && !defined (HAVE_WAIT3)
741 }],bash_cv_job_control_missing=present, bash_cv_job_control_missing=missing,
742 AC_MSG_ERROR(cannot check job control if cross-compiling))
744 AC_MSG_RESULT($bash_cv_job_control_missing)
745 if test $bash_cv_job_control_missing = missing; then
746 AC_DEFINE(JOB_CONTROL_MISSING)
750 dnl check whether named pipes are present
751 dnl this requires a previous check for mkfifo, but that is awkward to specify
752 AC_DEFUN(BASH_SYS_NAMED_PIPES,
753 [AC_MSG_CHECKING(for presence of named pipes)
754 AC_CACHE_VAL(bash_cv_sys_named_pipes,
756 #include <sys/types.h>
757 #include <sys/stat.h>
762 /* Add more tests in here as appropriate. */
767 #if defined (HAVE_MKFIFO)
771 #if !defined (S_IFIFO) && (defined (_POSIX_VERSION) && !defined (S_ISFIFO))
779 fd = mknod ("/tmp/sh-np-autoconf", 0666 | S_IFIFO, 0);
783 unlink ("/tmp/sh-np-autoconf");
785 }],bash_cv_sys_named_pipes=present, bash_cv_sys_named_pipes=missing,
786 AC_MSG_ERROR(cannot check for named pipes if cross-compiling))
788 AC_MSG_RESULT($bash_cv_sys_named_pipes)
789 if test $bash_cv_sys_named_pipes = missing; then
790 AC_DEFINE(NAMED_PIPES_MISSING)
794 AC_DEFUN(BASH_FUNC_POSIX_SETJMP,
795 [AC_REQUIRE([BASH_SIGNAL_CHECK])
796 AC_MSG_CHECKING(for presence of POSIX-style sigsetjmp/siglongjmp)
797 AC_CACHE_VAL(bash_cv_func_sigsetjmp,
802 #include <sys/types.h>
808 #if !defined (_POSIX_VERSION) || !defined (HAVE_POSIX_SIGNALS)
819 sigprocmask(SIG_BLOCK, (sigset_t *)NULL, &set);
820 sigprocmask(SIG_BLOCK, (sigset_t *)NULL, &oset);
823 code = sigsetjmp(xx, 1);
825 exit(0); /* could get sigmask and compare to oset here. */
828 sigaddset(&set, SIGINT);
829 sigprocmask(SIG_BLOCK, &set, (sigset_t *)NULL);
835 }],bash_cv_func_sigsetjmp=present, bash_cv_func_sigsetjmp=missing,
836 AC_MSG_ERROR(cannot check for sigsetjmp/siglongjmp if cross-compiling))
838 AC_MSG_RESULT($bash_cv_func_sigsetjmp)
839 if test $bash_cv_func_sigsetjmp = present; then
840 AC_DEFINE(HAVE_POSIX_SIGSETJMP)
844 AC_DEFUN(BASH_HAVE_TIOCGWINSZ,
845 [AC_MSG_CHECKING(for TIOCGWINSZ in sys/ioctl.h)
846 AC_CACHE_VAL(bash_cv_tiocgwinsz_in_ioctl,
847 [AC_TRY_COMPILE([#include <sys/types.h>
848 #include <sys/ioctl.h>], [int x = TIOCGWINSZ;],
849 bash_cv_tiocgwinsz_in_ioctl=yes,bash_cv_tiocgwinsz_in_ioctl=no)])
850 AC_MSG_RESULT($bash_cv_tiocgwinsz_in_ioctl)
851 if test $bash_cv_tiocgwinsz_in_ioctl = yes; then
852 AC_DEFINE(GWINSZ_IN_SYS_IOCTL)
856 AC_DEFUN(BASH_STRUCT_WINSIZE,
857 [AC_MSG_CHECKING(for struct winsize in sys/ioctl.h)
858 AC_CACHE_VAL(bash_cv_struct_winsize_in_ioctl,
859 [AC_TRY_COMPILE([#include <sys/types.h>
860 #include <sys/ioctl.h>], [struct winsize x;],
861 bash_cv_struct_winsize_in_ioctl=yes,bash_cv_struct_winsize_in_ioctl=no)])
862 AC_MSG_RESULT($bash_cv_struct_winsize_in_ioctl)
863 if test $bash_cv_struct_winsize_in_ioctl = yes; then
864 AC_DEFINE(STRUCT_WINSIZE_IN_SYS_IOCTL)
868 AC_DEFUN(BASH_HAVE_TIOCSTAT,
869 [AC_MSG_CHECKING(for TIOCSTAT in sys/ioctl.h)
870 AC_CACHE_VAL(bash_cv_tiocstat_in_ioctl,
871 [AC_TRY_COMPILE([#include <sys/types.h>
872 #include <sys/ioctl.h>], [int x = TIOCSTAT;],
873 bash_cv_tiocstat_in_ioctl=yes,bash_cv_tiocstat_in_ioctl=no)])
874 AC_MSG_RESULT($bash_cv_tiocstat_in_ioctl)
875 if test $bash_cv_tiocstat_in_ioctl = yes; then
876 AC_DEFINE(TIOCSTAT_IN_SYS_IOCTL)
880 AC_DEFUN(BASH_HAVE_FIONREAD,
881 [AC_MSG_CHECKING(for FIONREAD in sys/ioctl.h)
882 AC_CACHE_VAL(bash_cv_fionread_in_ioctl,
883 [AC_TRY_COMPILE([#include <sys/types.h>
884 #include <sys/ioctl.h>], [int x = FIONREAD;],
885 bash_cv_fionread_in_ioctl=yes,bash_cv_fionread_in_ioctl=no)])
886 AC_MSG_RESULT($bash_cv_fionread_in_ioctl)
887 if test $bash_cv_fionread_in_ioctl = yes; then
888 AC_DEFINE(FIONREAD_IN_SYS_IOCTL)
893 dnl See if speed_t is declared in <sys/types.h>. Some versions of linux
894 dnl require a definition of speed_t each time <termcap.h> is included,
895 dnl but you can only get speed_t if you include <termios.h> (on some
896 dnl versions) or <sys/types.h> (on others).
898 AC_DEFUN(BASH_MISC_SPEED_T,
899 [AC_MSG_CHECKING(for speed_t in sys/types.h)
900 AC_CACHE_VAL(bash_cv_speed_t_in_sys_types,
901 [AC_TRY_COMPILE([#include <sys/types.h>], [speed_t x;],
902 bash_cv_speed_t_in_sys_types=yes,bash_cv_speed_t_in_sys_types=no)])
903 AC_MSG_RESULT($bash_cv_speed_t_in_sys_types)
904 if test $bash_cv_speed_t_in_sys_types = yes; then
905 AC_DEFINE(SPEED_T_IN_SYS_TYPES)
909 AC_DEFUN(BASH_CHECK_GETPW_FUNCS,
910 [AC_MSG_CHECKING(whether programs are able to redeclare getpw functions)
911 AC_CACHE_VAL(bash_cv_can_redecl_getpw,
912 [AC_TRY_COMPILE([#include <sys/types.h>
914 extern struct passwd *getpwent();], [struct passwd *z; z = getpwent();],
915 bash_cv_can_redecl_getpw=yes,bash_cv_can_redecl_getpw=no)])
916 AC_MSG_RESULT($bash_cv_can_redecl_getpw)
917 if test $bash_cv_can_redecl_getpw = no; then
918 AC_DEFINE(HAVE_GETPW_DECLS)
922 AC_DEFUN(BASH_CHECK_DEV_FD,
923 [AC_MSG_CHECKING(whether /dev/fd is available)
924 AC_CACHE_VAL(bash_cv_dev_fd,
925 [if test -d /dev/fd && test -r /dev/fd/0; then
926 bash_cv_dev_fd=standard
927 elif test -d /proc/self/fd && test -r /proc/self/fd/0; then
928 bash_cv_dev_fd=whacky
930 bash_cv_dev_fd=absent
933 AC_MSG_RESULT($bash_cv_dev_fd)
934 if test $bash_cv_dev_fd = "standard"; then
935 AC_DEFINE(HAVE_DEV_FD)
936 AC_DEFINE(DEV_FD_PREFIX, "/dev/fd/")
937 elif test $bash_cv_dev_fd = "whacky"; then
938 AC_DEFINE(HAVE_DEV_FD)
939 AC_DEFINE(DEV_FD_PREFIX, "/proc/self/fd/")
944 dnl Check for the presence of getpeername (the only networking function
945 dnl bash currently requires) in libsocket. If libsocket is present,
946 dnl check for libnsl and add it to LIBS if it's there, since most
947 dnl systems with libsocket require linking with libnsl as well.
948 dnl This should only be called if getpeername was not found in libc.
950 AC_DEFUN(BASH_CHECK_SOCKLIB,
952 if test "X$bash_cv_have_socklib" = "X"; then
955 AC_MSG_CHECKING(for socket library)
958 AC_CACHE_VAL(bash_cv_have_socklib,
959 [AC_CHECK_LIB(socket, getpeername,
960 bash_cv_have_socklib=yes, bash_cv_have_socklib=no, -lnsl)])
961 if test "X$_bash_needmsg" = Xyes; then
962 AC_MSG_RESULT($bash_cv_have_socklib)
965 if test $bash_cv_have_socklib = yes; then
966 # check for libnsl, add it to LIBS if present
967 if test "X$bash_cv_have_libnsl" = "X"; then
970 AC_MSG_CHECKING(for libnsl)
973 AC_CACHE_VAL(bash_cv_have_libnsl,
974 [AC_CHECK_LIB(nsl, t_open,
975 bash_cv_have_libnsl=yes, bash_cv_have_libnsl=no)])
976 if test "X$_bash_needmsg" = Xyes; then
977 AC_MSG_RESULT($bash_cv_have_libnsl)
980 if test $bash_cv_have_libnsl = yes; then
981 LIBS="-lsocket -lnsl $LIBS"
983 LIBS="-lsocket $LIBS"
985 AC_DEFINE(HAVE_LIBSOCKET)
986 AC_DEFINE(HAVE_GETPEERNAME)
990 AC_DEFUN(BASH_DEFAULT_MAIL_DIR,
991 [AC_MSG_CHECKING(for default mail directory)
992 AC_CACHE_VAL(bash_cv_mail_dir,
993 [if test -d /var/mail; then
994 bash_cv_mail_dir=/var/mail
995 elif test -d /usr/mail; then
996 bash_cv_mail_dir=/usr/mail
997 elif test -d /usr/spool/mail; then
998 bash_cv_mail_dir=/usr/spool/mail
999 elif test -d /var/spool/mail; then
1000 bash_cv_mail_dir=/var/spool/mail
1002 bash_cv_mail_dir=unknown
1005 AC_MSG_RESULT($bash_cv_mail_dir)
1006 if test $bash_cv_mail_dir = "/var/mail"; then
1007 AC_DEFINE(DEFAULT_MAIL_DIRECTORY, "/var/mail")
1008 elif test $bash_cv_mail_dir = "/usr/mail"; then
1009 AC_DEFINE(DEFAULT_MAIL_DIRECTORY, "/usr/mail")
1010 elif test $bash_cv_mail_dir = "/var/spool/mail"; then
1011 AC_DEFINE(DEFAULT_MAIL_DIRECTORY, "/var/spool/mail")
1012 elif test $bash_cv_mail_dir = "/usr/spool/mail"; then
1013 AC_DEFINE(DEFAULT_MAIL_DIRECTORY, "/usr/spool/mail")
1015 AC_DEFINE(DEFAULT_MAIL_DIRECTORY, "unknown")
1020 dnl Check if HPUX needs _KERNEL defined for RLIMIT_* definitions
1022 AC_DEFUN(BASH_KERNEL_RLIMIT_CHECK,
1023 [AC_MSG_CHECKING([whether $host_os needs _KERNEL for RLIMIT defines])
1024 AC_CACHE_VAL(bash_cv_kernel_rlimit,
1026 #include <sys/types.h>
1027 #include <sys/resource.h>
1032 ], bash_cv_kernel_rlimit=no,
1034 #include <sys/types.h>
1036 #include <sys/resource.h>
1042 ], bash_cv_kernel_rlimit=yes, bash_cv_kernel_rlimit=no)]
1044 AC_MSG_RESULT($bash_cv_kernel_rlimit)
1045 if test $bash_cv_kernel_rlimit = yes; then
1046 AC_DEFINE(RLIMIT_NEEDS_KERNEL)
1050 AC_DEFUN(BASH_FUNC_STRCOLL,
1052 AC_MSG_CHECKING(whether or not strcoll and strcmp differ)
1053 AC_CACHE_VAL(bash_cv_func_strcoll_broken,
1056 #if defined (HAVE_LOCALE_H)
1065 char *deflocale, *defcoll;
1067 #ifdef HAVE_SETLOCALE
1068 deflocale = setlocale(LC_ALL, "");
1069 defcoll = setlocale(LC_COLLATE, "");
1073 /* These two values are taken from tests/glob-test. */
1074 r1 = strcoll("abd", "aXd");
1078 r2 = strcmp("abd", "aXd");
1080 /* These two should both be greater than 0. It is permissible for
1081 a system to return different values, as long as the sign is the
1084 /* Exit with 1 (failure) if these two values are both > 0, since
1085 this tests whether strcoll(3) is broken with respect to strcmp(3)
1086 in the default locale. */
1087 exit (r1 > 0 && r2 > 0);
1089 ], bash_cv_func_strcoll_broken=yes, bash_cv_func_strcoll_broken=no,
1090 AC_MSG_ERROR(cannot check strcoll if cross compiling))
1092 AC_MSG_RESULT($bash_cv_func_strcoll_broken)
1093 if test $bash_cv_func_strcoll_broken = yes; then
1094 AC_DEFINE(STRCOLL_BROKEN)