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_DECL_UNDER_SYS_SIGLIST,
201 [AC_MSG_CHECKING([for _sys_siglist in signal.h or unistd.h])
202 AC_CACHE_VAL(bash_cv_decl_under_sys_siglist,
204 #include <sys/types.h>
208 #endif], [ char *msg = _sys_siglist[2]; ],
209 bash_cv_decl_under_sys_siglist=yes, bash_cv_decl_under_sys_siglist=no,
210 AC_MSG_ERROR(cannot check for _sys_siglist[] if cross compiling))])dnl
211 AC_MSG_RESULT($bash_cv_decl_under_sys_siglist)
212 if test $bash_cv_decl_under_sys_siglist = yes; then
213 AC_DEFINE(UNDER_SYS_SIGLIST_DECLARED)
217 AC_DEFUN(BASH_UNDER_SYS_SIGLIST,
218 [AC_REQUIRE([BASH_DECL_UNDER_SYS_SIGLIST])
219 AC_MSG_CHECKING([for _sys_siglist in system C library])
220 AC_CACHE_VAL(bash_cv_under_sys_siglist,
222 #include <sys/types.h>
227 #ifndef UNDER_SYS_SIGLIST_DECLARED
228 extern char *_sys_siglist[];
232 char *msg = (char *)_sys_siglist[2];
235 bash_cv_under_sys_siglist=yes, bash_cv_under_sys_siglist=no,
236 AC_MSG_ERROR(cannot check for _sys_siglist[] if cross compiling))])dnl
237 AC_MSG_RESULT($bash_cv_under_sys_siglist)
238 if test $bash_cv_under_sys_siglist = yes; then
239 AC_DEFINE(HAVE_UNDER_SYS_SIGLIST)
243 AC_DEFUN(BASH_SYS_SIGLIST,
244 [AC_REQUIRE([AC_DECL_SYS_SIGLIST])
245 AC_MSG_CHECKING([for sys_siglist in system C library])
246 AC_CACHE_VAL(bash_cv_sys_siglist,
248 #include <sys/types.h>
253 #ifndef SYS_SIGLIST_DECLARED
254 extern char *sys_siglist[];
258 char *msg = sys_siglist[2];
261 bash_cv_sys_siglist=yes, bash_cv_sys_siglist=no,
262 AC_MSG_ERROR(cannot check for sys_siglist if cross compiling))])dnl
263 AC_MSG_RESULT($bash_cv_sys_siglist)
264 if test $bash_cv_sys_siglist = yes; then
265 AC_DEFINE(HAVE_SYS_SIGLIST)
269 dnl Check for sys_errlist[] and sys_nerr, check for declaration
270 AC_DEFUN(BASH_SYS_ERRLIST,
271 [AC_MSG_CHECKING([for sys_errlist and sys_nerr])
272 AC_CACHE_VAL(bash_cv_sys_errlist,
273 [AC_TRY_LINK([#include <errno.h>],
274 [extern char *sys_errlist[];
276 char *msg = sys_errlist[sys_nerr - 1];],
277 bash_cv_sys_errlist=yes, bash_cv_sys_errlist=no)])dnl
278 AC_MSG_RESULT($bash_cv_sys_errlist)
279 if test $bash_cv_sys_errlist = yes; then
280 AC_DEFINE(HAVE_SYS_ERRLIST)
284 dnl Check to see if opendir will open non-directories (not a nice thing)
285 AC_DEFUN(BASH_FUNC_OPENDIR_CHECK,
286 [AC_REQUIRE([AC_HEADER_DIRENT])dnl
287 AC_MSG_CHECKING(if opendir() opens non-directories)
288 AC_CACHE_VAL(bash_cv_opendir_not_robust,
291 #include <sys/types.h>
295 #endif /* HAVE_UNISTD_H */
296 #if defined(HAVE_DIRENT_H)
299 # define dirent direct
300 # ifdef HAVE_SYS_NDIR_H
301 # include <sys/ndir.h>
302 # endif /* SYSNDIR */
303 # ifdef HAVE_SYS_DIR_H
304 # include <sys/dir.h>
309 #endif /* HAVE_DIRENT_H */
314 unlink("/tmp/not_a_directory");
315 fd = open("/tmp/not_a_directory", O_WRONLY|O_CREAT, 0666);
318 dir = opendir("/tmp/not_a_directory");
319 unlink("/tmp/not_a_directory");
321 }], bash_cv_opendir_not_robust=yes,bash_cv_opendir_not_robust=no,
322 AC_MSG_ERROR(cannot check opendir if cross compiling))])
323 AC_MSG_RESULT($bash_cv_opendir_not_robust)
324 if test $bash_cv_opendir_not_robust = yes; then
325 AC_DEFINE(OPENDIR_NOT_ROBUST)
330 AC_DEFUN(BASH_TYPE_SIGHANDLER,
331 [AC_MSG_CHECKING([whether signal handlers are of type void])
332 AC_CACHE_VAL(bash_cv_void_sighandler,
333 [AC_TRY_COMPILE([#include <sys/types.h>
341 void (*signal ()) ();],
342 [int i;], bash_cv_void_sighandler=yes, bash_cv_void_sighandler=no)])dnl
343 AC_MSG_RESULT($bash_cv_void_sighandler)
344 if test $bash_cv_void_sighandler = yes; then
345 AC_DEFINE(VOID_SIGHANDLER)
349 AC_DEFUN(BASH_FUNC_STRSIGNAL,
350 [AC_MSG_CHECKING([for the existance of strsignal])
351 AC_CACHE_VAL(bash_cv_have_strsignal,
352 [AC_TRY_LINK([#include <sys/types.h>
353 #include <signal.h>],
354 [char *s = (char *)strsignal(2);],
355 bash_cv_have_strsignal=yes, bash_cv_have_strsignal=no)])
356 AC_MSG_RESULT($bash_cv_have_strsignal)
357 if test $bash_cv_have_strsignal = yes; then
358 AC_DEFINE(HAVE_STRSIGNAL)
362 AC_DEFUN(BASH_FUNC_LSTAT,
363 [dnl Cannot use AC_CHECK_FUNCS(lstat) because Linux defines lstat() as an
364 dnl inline function in <sys/stat.h>.
365 AC_CACHE_CHECK([for lstat], bash_cv_func_lstat,
367 #include <sys/types.h>
368 #include <sys/stat.h>
369 ],[ lstat("",(struct stat *)0); ],
370 bash_cv_func_lstat=yes, bash_cv_func_lstat=no)])
371 if test $bash_cv_func_lstat = yes; then
372 AC_DEFINE(HAVE_LSTAT)
376 AC_DEFUN(BASH_STRUCT_TERMIOS_LDISC,
377 [AC_MSG_CHECKING([for a c_line member of struct termios])
378 AC_CACHE_VAL(bash_cv_termios_ldisc,
379 [AC_TRY_COMPILE([#include <sys/types.h>
380 #include <termios.h>],[struct termios t; int i; i = t.c_line;],
381 bash_cv_termios_ldisc=yes, bash_cv_termios_ldisc=no)])dnl
382 AC_MSG_RESULT($bash_cv_termios_ldisc)
383 if test $bash_cv_termios_ldisc = yes; then
384 AC_DEFINE(TERMIOS_LDISC)
388 AC_DEFUN(BASH_STRUCT_TERMIO_LDISC,
389 [AC_MSG_CHECKING([for a c_line member of struct termio])
390 AC_CACHE_VAL(bash_cv_termio_ldisc,
391 [AC_TRY_COMPILE([#include <sys/types.h>
392 #include <termio.h>],[struct termio t; int i; i = t.c_line;],
393 bash_cv_termio_ldisc=yes, bash_cv_termio_ldisc=no)])dnl
394 AC_MSG_RESULT($bash_cv_termio_ldisc)
395 if test $bash_cv_termio_ldisc = yes; then
396 AC_DEFINE(TERMIO_LDISC)
400 AC_DEFUN(BASH_FUNC_GETENV,
401 [AC_MSG_CHECKING(to see if getenv can be redefined)
402 AC_CACHE_VAL(bash_cv_getenv_redef,
414 #if defined (__linux__) || defined (__bsdi__) || defined (convex)
418 #endif /* !__linux__ && !__bsdi__ && !convex */
425 /* The next allows this program to run, but does not allow bash to link
426 when it redefines getenv. I'm not really interested in figuring out
432 exit(s == 0); /* force optimizer to leave getenv in */
434 ], bash_cv_getenv_redef=yes, bash_cv_getenv_redef=no,
435 AC_MSG_ERROR(cannot check getenv redefinition if cross compiling))])
436 AC_MSG_RESULT($bash_cv_getenv_redef)
437 if test $bash_cv_getenv_redef = yes; then
438 AC_DEFINE(CAN_REDEFINE_GETENV)
442 AC_DEFUN(BASH_FUNC_PRINTF,
443 [AC_MSG_CHECKING(for declaration of printf in <stdio.h>)
444 AC_CACHE_VAL(bash_cv_printf_declared,
448 typedef int (*_bashfunc)(const char *, ...);
450 typedef int (*_bashfunc)();
455 pf = (_bashfunc) printf;
458 ],bash_cv_printf_declared=yes, bash_cv_printf_declared=no,
459 AC_MSG_ERROR(cannot check printf declaration if cross compiling))])
460 AC_MSG_RESULT($bash_cv_printf_declared)
461 if test $bash_cv_printf_declared = yes; then
462 AC_DEFINE(PRINTF_DECLARED)
466 AC_DEFUN(BASH_FUNC_ULIMIT_MAXFDS,
467 [AC_MSG_CHECKING(whether ulimit can substitute for getdtablesize)
468 AC_CACHE_VAL(bash_cv_ulimit_maxfds,
472 long maxfds = ulimit(4, 0L);
473 exit (maxfds == -1L);
475 ],bash_cv_ulimit_maxfds=yes, bash_cv_ulimit_maxfds=no,
476 AC_MSG_ERROR(cannot check ulimit if cross compiling))])
477 AC_MSG_RESULT($bash_cv_ulimit_maxfds)
478 if test $bash_cv_ulimit_maxfds = yes; then
479 AC_DEFINE(ULIMIT_MAXFDS)
483 AC_DEFUN(BASH_CHECK_LIB_TERMCAP,
485 if test "X$bash_cv_termcap_lib" = "X"; then
488 AC_MSG_CHECKING(which library has the termcap functions)
491 AC_CACHE_VAL(bash_cv_termcap_lib,
492 [AC_CHECK_LIB(termcap, tgetent, bash_cv_termcap_lib=libtermcap,
493 [AC_CHECK_LIB(curses, tgetent, bash_cv_termcap_lib=libcurses,
494 [AC_CHECK_LIB(ncurses, tgetent, bash_cv_termcap_lib=libncurses,
495 bash_cv_termcap_lib=gnutermcap)])])])
496 if test "X$_bash_needmsg" = "Xyes"; then
497 AC_MSG_CHECKING(which library has the termcap functions)
499 AC_MSG_RESULT(using $bash_cv_termcap_lib)
500 if test $bash_cv_termcap_lib = gnutermcap; then
501 LDFLAGS="$LDFLAGS -L./lib/termcap"
502 TERMCAP_LIB="./lib/termcap/libtermcap.a"
503 TERMCAP_DEP="./lib/termcap/libtermcap.a"
504 elif test $bash_cv_termcap_lib = libtermcap && test -z "$prefer_curses"; then
505 TERMCAP_LIB=-ltermcap
507 elif test $bash_cv_termcap_lib = libncurses; then
508 TERMCAP_LIB=-lncurses
516 AC_DEFUN(BASH_FUNC_GETCWD,
517 [AC_MSG_CHECKING([if getcwd() calls popen()])
518 AC_CACHE_VAL(bash_cv_getcwd_calls_popen,
542 FILE *_popen(command, type)
546 return (popen (command, type));
570 ], bash_cv_getcwd_calls_popen=no, bash_cv_getcwd_calls_popen=yes,
571 AC_MSG_ERROR(cannot check whether getcwd calls popen if cross compiling))])
572 AC_MSG_RESULT($bash_cv_getcwd_calls_popen)
573 if test $bash_cv_getcwd_calls_popen = yes; then
574 AC_DEFINE(GETCWD_BROKEN)
578 AC_DEFUN(BASH_STRUCT_DIRENT_D_INO,
579 [AC_REQUIRE([AC_HEADER_DIRENT])
580 AC_MSG_CHECKING(if struct dirent has a d_ino member)
581 AC_CACHE_VAL(bash_cv_dirent_has_dino,
584 #include <sys/types.h>
587 #endif /* HAVE_UNISTD_H */
588 #if defined(HAVE_DIRENT_H)
591 # define dirent direct
592 # ifdef HAVE_SYS_NDIR_H
593 # include <sys/ndir.h>
594 # endif /* SYSNDIR */
595 # ifdef HAVE_SYS_DIR_H
596 # include <sys/dir.h>
601 #endif /* HAVE_DIRENT_H */
603 struct dirent d; int z; z = d.d_ino;
604 ], bash_cv_dirent_has_dino=yes, bash_cv_dirent_has_dino=no)])
605 AC_MSG_RESULT($bash_cv_dirent_has_dino)
606 if test $bash_cv_dirent_has_dino = yes; then
607 AC_DEFINE(STRUCT_DIRENT_HAS_D_INO)
611 AC_DEFUN(BASH_STRUCT_DIRENT_D_FILENO,
612 [AC_REQUIRE([AC_HEADER_DIRENT])
613 AC_MSG_CHECKING(if struct dirent has a d_fileno member)
614 AC_CACHE_VAL(bash_cv_dirent_has_d_fileno,
617 #include <sys/types.h>
620 #endif /* HAVE_UNISTD_H */
621 #if defined(HAVE_DIRENT_H)
624 # define dirent direct
625 # ifdef HAVE_SYS_NDIR_H
626 # include <sys/ndir.h>
627 # endif /* SYSNDIR */
628 # ifdef HAVE_SYS_DIR_H
629 # include <sys/dir.h>
634 #endif /* HAVE_DIRENT_H */
636 struct dirent d; int z; z = d.d_fileno;
637 ], bash_cv_dirent_has_d_fileno=yes, bash_cv_dirent_has_d_fileno=no)])
638 AC_MSG_RESULT($bash_cv_dirent_has_d_fileno)
639 if test $bash_cv_dirent_has_d_fileno = yes; then
640 AC_DEFINE(STRUCT_DIRENT_HAS_D_FILENO)
644 AC_DEFUN(BASH_REINSTALL_SIGHANDLERS,
645 [AC_REQUIRE([AC_TYPE_SIGNAL])
646 AC_REQUIRE([BASH_SIGNAL_CHECK])
647 AC_MSG_CHECKING([if signal handlers must be reinstalled when invoked])
648 AC_CACHE_VAL(bash_cv_must_reinstall_sighandlers,
655 typedef RETSIGTYPE sigfunc();
659 #ifdef HAVE_POSIX_SIGNALS
661 set_signal_handler(sig, handler)
665 struct sigaction act, oact;
666 act.sa_handler = handler;
668 sigemptyset (&act.sa_mask);
669 sigemptyset (&oact.sa_mask);
670 sigaction (sig, &act, &oact);
671 return (oact.sa_handler);
674 #define set_signal_handler(s, h) signal(s, h)
687 set_signal_handler(SIGINT, sigint);
688 kill((int)getpid(), SIGINT);
689 kill((int)getpid(), SIGINT);
692 ], bash_cv_must_reinstall_sighandlers=no, bash_cv_must_reinstall_sighandlers=yes,
693 AC_MSG_ERROR(cannot check signal handling if cross compiling))])
694 AC_MSG_RESULT($bash_cv_must_reinstall_sighandlers)
695 if test $bash_cv_must_reinstall_sighandlers = yes; then
696 AC_DEFINE(MUST_REINSTALL_SIGHANDLERS)
700 AC_DEFUN(BASH_FUNC_SBRK_DECLARED,
701 [AC_MSG_CHECKING(for declaration of sbrk in <unistd.h>)
702 AC_CACHE_VAL(bash_cv_sbrk_declared,
703 [AC_EGREP_HEADER(sbrk, unistd.h,
704 bash_cv_sbrk_declared=yes, bash_cv_sbrk_declared=no)])
705 AC_MSG_RESULT($bash_cv_sbrk_declared)
706 if test $bash_cv_sbrk_declared = yes; then
707 AC_DEFINE(SBRK_DECLARED)
711 dnl check that some necessary job control definitions are present
712 AC_DEFUN(BASH_JOB_CONTROL_MISSING,
713 [AC_REQUIRE([BASH_SIGNAL_CHECK])
714 AC_MSG_CHECKING(for presence of necessary job control definitions)
715 AC_CACHE_VAL(bash_cv_job_control_missing,
717 #include <sys/types.h>
718 #ifdef HAVE_SYS_WAIT_H
719 #include <sys/wait.h>
726 /* Add more tests in here as appropriate. */
730 #if !defined (HAVE_POSIX_SIGNALS) && !defined (HAVE_BSD_SIGNALS)
734 /* signals and tty control. */
735 #if !defined (SIGTSTP) || !defined (SIGSTOP) || !defined (SIGCONT)
739 /* process control */
740 #if !defined (WNOHANG) || !defined (WUNTRACED)
744 /* Posix systems have tcgetpgrp and waitpid. */
745 #if defined (_POSIX_VERSION) && !defined (HAVE_TCGETPGRP)
749 #if defined (_POSIX_VERSION) && !defined (HAVE_WAITPID)
753 /* Other systems have TIOCSPGRP/TIOCGPRGP and wait3. */
754 #if !defined (_POSIX_VERSION) && !defined (HAVE_WAIT3)
759 }],bash_cv_job_control_missing=present, bash_cv_job_control_missing=missing,
760 AC_MSG_ERROR(cannot check job control if cross-compiling))
762 AC_MSG_RESULT($bash_cv_job_control_missing)
763 if test $bash_cv_job_control_missing = missing; then
764 AC_DEFINE(JOB_CONTROL_MISSING)
768 dnl check whether named pipes are present
769 dnl this requires a previous check for mkfifo, but that is awkward to specify
770 AC_DEFUN(BASH_SYS_NAMED_PIPES,
771 [AC_MSG_CHECKING(for presence of named pipes)
772 AC_CACHE_VAL(bash_cv_sys_named_pipes,
774 #include <sys/types.h>
775 #include <sys/stat.h>
780 /* Add more tests in here as appropriate. */
785 #if defined (HAVE_MKFIFO)
789 #if !defined (S_IFIFO) && (defined (_POSIX_VERSION) && !defined (S_ISFIFO))
797 fd = mknod ("/tmp/sh-np-autoconf", 0666 | S_IFIFO, 0);
801 unlink ("/tmp/sh-np-autoconf");
803 }],bash_cv_sys_named_pipes=present, bash_cv_sys_named_pipes=missing,
804 AC_MSG_ERROR(cannot check for named pipes if cross-compiling))
806 AC_MSG_RESULT($bash_cv_sys_named_pipes)
807 if test $bash_cv_sys_named_pipes = missing; then
808 AC_DEFINE(NAMED_PIPES_MISSING)
812 AC_DEFUN(BASH_FUNC_POSIX_SETJMP,
813 [AC_REQUIRE([BASH_SIGNAL_CHECK])
814 AC_MSG_CHECKING(for presence of POSIX-style sigsetjmp/siglongjmp)
815 AC_CACHE_VAL(bash_cv_func_sigsetjmp,
820 #include <sys/types.h>
826 #if !defined (_POSIX_VERSION) || !defined (HAVE_POSIX_SIGNALS)
837 sigprocmask(SIG_BLOCK, (sigset_t *)NULL, &set);
838 sigprocmask(SIG_BLOCK, (sigset_t *)NULL, &oset);
841 code = sigsetjmp(xx, 1);
843 exit(0); /* could get sigmask and compare to oset here. */
846 sigaddset(&set, SIGINT);
847 sigprocmask(SIG_BLOCK, &set, (sigset_t *)NULL);
853 }],bash_cv_func_sigsetjmp=present, bash_cv_func_sigsetjmp=missing,
854 AC_MSG_ERROR(cannot check for sigsetjmp/siglongjmp if cross-compiling))
856 AC_MSG_RESULT($bash_cv_func_sigsetjmp)
857 if test $bash_cv_func_sigsetjmp = present; then
858 AC_DEFINE(HAVE_POSIX_SIGSETJMP)
862 AC_DEFUN(BASH_HAVE_TIOCGWINSZ,
863 [AC_MSG_CHECKING(for TIOCGWINSZ in sys/ioctl.h)
864 AC_CACHE_VAL(bash_cv_tiocgwinsz_in_ioctl,
865 [AC_TRY_COMPILE([#include <sys/types.h>
866 #include <sys/ioctl.h>], [int x = TIOCGWINSZ;],
867 bash_cv_tiocgwinsz_in_ioctl=yes,bash_cv_tiocgwinsz_in_ioctl=no)])
868 AC_MSG_RESULT($bash_cv_tiocgwinsz_in_ioctl)
869 if test $bash_cv_tiocgwinsz_in_ioctl = yes; then
870 AC_DEFINE(GWINSZ_IN_SYS_IOCTL)
874 AC_DEFUN(BASH_STRUCT_WINSIZE,
875 [AC_MSG_CHECKING(for struct winsize in sys/ioctl.h)
876 AC_CACHE_VAL(bash_cv_struct_winsize_in_ioctl,
877 [AC_TRY_COMPILE([#include <sys/types.h>
878 #include <sys/ioctl.h>], [struct winsize x;],
879 bash_cv_struct_winsize_in_ioctl=yes,bash_cv_struct_winsize_in_ioctl=no)])
880 AC_MSG_RESULT($bash_cv_struct_winsize_in_ioctl)
881 if test $bash_cv_struct_winsize_in_ioctl = yes; then
882 AC_DEFINE(STRUCT_WINSIZE_IN_SYS_IOCTL)
886 AC_DEFUN(BASH_HAVE_TIOCSTAT,
887 [AC_MSG_CHECKING(for TIOCSTAT in sys/ioctl.h)
888 AC_CACHE_VAL(bash_cv_tiocstat_in_ioctl,
889 [AC_TRY_COMPILE([#include <sys/types.h>
890 #include <sys/ioctl.h>], [int x = TIOCSTAT;],
891 bash_cv_tiocstat_in_ioctl=yes,bash_cv_tiocstat_in_ioctl=no)])
892 AC_MSG_RESULT($bash_cv_tiocstat_in_ioctl)
893 if test $bash_cv_tiocstat_in_ioctl = yes; then
894 AC_DEFINE(TIOCSTAT_IN_SYS_IOCTL)
898 AC_DEFUN(BASH_HAVE_FIONREAD,
899 [AC_MSG_CHECKING(for FIONREAD in sys/ioctl.h)
900 AC_CACHE_VAL(bash_cv_fionread_in_ioctl,
901 [AC_TRY_COMPILE([#include <sys/types.h>
902 #include <sys/ioctl.h>], [int x = FIONREAD;],
903 bash_cv_fionread_in_ioctl=yes,bash_cv_fionread_in_ioctl=no)])
904 AC_MSG_RESULT($bash_cv_fionread_in_ioctl)
905 if test $bash_cv_fionread_in_ioctl = yes; then
906 AC_DEFINE(FIONREAD_IN_SYS_IOCTL)
911 dnl See if speed_t is declared in <sys/types.h>. Some versions of linux
912 dnl require a definition of speed_t each time <termcap.h> is included,
913 dnl but you can only get speed_t if you include <termios.h> (on some
914 dnl versions) or <sys/types.h> (on others).
916 AC_DEFUN(BASH_MISC_SPEED_T,
917 [AC_MSG_CHECKING(for speed_t in sys/types.h)
918 AC_CACHE_VAL(bash_cv_speed_t_in_sys_types,
919 [AC_TRY_COMPILE([#include <sys/types.h>], [speed_t x;],
920 bash_cv_speed_t_in_sys_types=yes,bash_cv_speed_t_in_sys_types=no)])
921 AC_MSG_RESULT($bash_cv_speed_t_in_sys_types)
922 if test $bash_cv_speed_t_in_sys_types = yes; then
923 AC_DEFINE(SPEED_T_IN_SYS_TYPES)
927 AC_DEFUN(BASH_CHECK_GETPW_FUNCS,
928 [AC_MSG_CHECKING(whether programs are able to redeclare getpw functions)
929 AC_CACHE_VAL(bash_cv_can_redecl_getpw,
930 [AC_TRY_COMPILE([#include <sys/types.h>
932 extern struct passwd *getpwent();
933 extern struct passwd *getpwuid();
934 extern struct passwd *getpwnam();],
935 [struct passwd *z; z = getpwent(); z = getpwuid(0); z = getpwnam("root");],
936 bash_cv_can_redecl_getpw=yes,bash_cv_can_redecl_getpw=no)])
937 AC_MSG_RESULT($bash_cv_can_redecl_getpw)
938 if test $bash_cv_can_redecl_getpw = no; then
939 AC_DEFINE(HAVE_GETPW_DECLS)
943 AC_DEFUN(BASH_CHECK_DEV_FD,
944 [AC_MSG_CHECKING(whether /dev/fd is available)
945 AC_CACHE_VAL(bash_cv_dev_fd,
946 [if test -d /dev/fd && test -r /dev/fd/0; then
947 bash_cv_dev_fd=standard
948 elif test -d /proc/self/fd && test -r /proc/self/fd/0; then
949 bash_cv_dev_fd=whacky
951 bash_cv_dev_fd=absent
954 AC_MSG_RESULT($bash_cv_dev_fd)
955 if test $bash_cv_dev_fd = "standard"; then
956 AC_DEFINE(HAVE_DEV_FD)
957 AC_DEFINE(DEV_FD_PREFIX, "/dev/fd/")
958 elif test $bash_cv_dev_fd = "whacky"; then
959 AC_DEFINE(HAVE_DEV_FD)
960 AC_DEFINE(DEV_FD_PREFIX, "/proc/self/fd/")
965 dnl Check for the presence of getpeername (the only networking function
966 dnl bash currently requires) in libsocket. If libsocket is present,
967 dnl check for libnsl and add it to LIBS if it's there, since most
968 dnl systems with libsocket require linking with libnsl as well.
969 dnl This should only be called if getpeername was not found in libc.
971 AC_DEFUN(BASH_CHECK_SOCKLIB,
973 if test "X$bash_cv_have_socklib" = "X"; then
976 AC_MSG_CHECKING(for socket library)
979 AC_CACHE_VAL(bash_cv_have_socklib,
980 [AC_CHECK_LIB(socket, getpeername,
981 bash_cv_have_socklib=yes, bash_cv_have_socklib=no, -lnsl)])
982 if test "X$_bash_needmsg" = Xyes; then
983 AC_MSG_RESULT($bash_cv_have_socklib)
986 if test $bash_cv_have_socklib = yes; then
987 # check for libnsl, add it to LIBS if present
988 if test "X$bash_cv_have_libnsl" = "X"; then
991 AC_MSG_CHECKING(for libnsl)
994 AC_CACHE_VAL(bash_cv_have_libnsl,
995 [AC_CHECK_LIB(nsl, t_open,
996 bash_cv_have_libnsl=yes, bash_cv_have_libnsl=no)])
997 if test "X$_bash_needmsg" = Xyes; then
998 AC_MSG_RESULT($bash_cv_have_libnsl)
1001 if test $bash_cv_have_libnsl = yes; then
1002 LIBS="-lsocket -lnsl $LIBS"
1004 LIBS="-lsocket $LIBS"
1006 AC_DEFINE(HAVE_LIBSOCKET)
1007 AC_DEFINE(HAVE_GETPEERNAME)
1011 AC_DEFUN(BASH_DEFAULT_MAIL_DIR,
1012 [AC_MSG_CHECKING(for default mail directory)
1013 AC_CACHE_VAL(bash_cv_mail_dir,
1014 [if test -d /var/mail; then
1015 bash_cv_mail_dir=/var/mail
1016 elif test -d /usr/mail; then
1017 bash_cv_mail_dir=/usr/mail
1018 elif test -d /var/spool/mail; then
1019 bash_cv_mail_dir=/var/spool/mail
1020 elif test -d /usr/spool/mail; then
1021 bash_cv_mail_dir=/usr/spool/mail
1023 bash_cv_mail_dir=unknown
1026 AC_MSG_RESULT($bash_cv_mail_dir)
1027 if test $bash_cv_mail_dir = "/var/mail"; then
1028 AC_DEFINE(DEFAULT_MAIL_DIRECTORY, "/var/mail")
1029 elif test $bash_cv_mail_dir = "/usr/mail"; then
1030 AC_DEFINE(DEFAULT_MAIL_DIRECTORY, "/usr/mail")
1031 elif test $bash_cv_mail_dir = "/var/spool/mail"; then
1032 AC_DEFINE(DEFAULT_MAIL_DIRECTORY, "/var/spool/mail")
1033 elif test $bash_cv_mail_dir = "/usr/spool/mail"; then
1034 AC_DEFINE(DEFAULT_MAIL_DIRECTORY, "/usr/spool/mail")
1036 AC_DEFINE(DEFAULT_MAIL_DIRECTORY, "unknown")
1041 dnl Check if HPUX needs _KERNEL defined for RLIMIT_* definitions
1043 AC_DEFUN(BASH_KERNEL_RLIMIT_CHECK,
1044 [AC_MSG_CHECKING([whether $host_os needs _KERNEL for RLIMIT defines])
1045 AC_CACHE_VAL(bash_cv_kernel_rlimit,
1047 #include <sys/types.h>
1048 #include <sys/resource.h>
1053 ], bash_cv_kernel_rlimit=no,
1055 #include <sys/types.h>
1057 #include <sys/resource.h>
1063 ], bash_cv_kernel_rlimit=yes, bash_cv_kernel_rlimit=no)]
1065 AC_MSG_RESULT($bash_cv_kernel_rlimit)
1066 if test $bash_cv_kernel_rlimit = yes; then
1067 AC_DEFINE(RLIMIT_NEEDS_KERNEL)
1071 AC_DEFUN(BASH_FUNC_STRCOLL,
1073 AC_MSG_CHECKING(whether or not strcoll and strcmp differ)
1074 AC_CACHE_VAL(bash_cv_func_strcoll_broken,
1077 #if defined (HAVE_LOCALE_H)
1086 char *deflocale, *defcoll;
1088 #ifdef HAVE_SETLOCALE
1089 deflocale = setlocale(LC_ALL, "");
1090 defcoll = setlocale(LC_COLLATE, "");
1094 /* These two values are taken from tests/glob-test. */
1095 r1 = strcoll("abd", "aXd");
1099 r2 = strcmp("abd", "aXd");
1101 /* These two should both be greater than 0. It is permissible for
1102 a system to return different values, as long as the sign is the
1105 /* Exit with 1 (failure) if these two values are both > 0, since
1106 this tests whether strcoll(3) is broken with respect to strcmp(3)
1107 in the default locale. */
1108 exit (r1 > 0 && r2 > 0);
1110 ], bash_cv_func_strcoll_broken=yes, bash_cv_func_strcoll_broken=no,
1111 AC_MSG_ERROR(cannot check strcoll if cross compiling))
1113 AC_MSG_RESULT($bash_cv_func_strcoll_broken)
1114 if test $bash_cv_func_strcoll_broken = yes; then
1115 AC_DEFINE(STRCOLL_BROKEN)