source: trunk/third/readline/aclocal.m4 @ 15410

Revision 15410, 36.4 KB checked in by ghudson, 24 years ago (diff)
This commit was generated by cvs2svn to compensate for changes in r15409, which included commits to RCS files with non-trunk default branches.
Line 
1dnl
2dnl Bash specific tests
3dnl
4dnl Some derived from PDKSH 5.1.3 autoconf tests
5dnl
6dnl
7dnl Check if dup2() does not clear the close on exec flag
8dnl
9AC_DEFUN(BASH_DUP2_CLOEXEC_CHECK,
10[AC_MSG_CHECKING(if dup2 fails to clear the close-on-exec flag)
11AC_CACHE_VAL(bash_cv_dup2_broken,
12[AC_TRY_RUN([
13#include <sys/types.h>
14#include <fcntl.h>
15main()
16{
17  int fd1, fd2, fl;
18  fd1 = open("/dev/null", 2);
19  if (fcntl(fd1, 2, 1) < 0)
20    exit(1);
21  fd2 = dup2(fd1, 1);
22  if (fd2 < 0)
23    exit(2);
24  fl = fcntl(fd2, 1, 0);
25  /* fl will be 1 if dup2 did not reset the close-on-exec flag. */
26  exit(fl != 1);
27}
28], bash_cv_dup2_broken=yes, bash_cv_dup2_broken=no,
29    [AC_MSG_WARN(cannot check dup2 if cross compiling -- defaulting to no)
30     bash_cv_dup2_broken=no])
31])
32AC_MSG_RESULT($bash_cv_dup2_broken)
33if test $bash_cv_dup2_broken = yes; then
34AC_DEFINE(DUP2_BROKEN)
35fi
36])
37
38dnl Check type of signal routines (posix, 4.2bsd, 4.1bsd or v7)
39AC_DEFUN(BASH_SIGNAL_CHECK,
40[AC_REQUIRE([AC_TYPE_SIGNAL])
41AC_MSG_CHECKING(for type of signal functions)
42AC_CACHE_VAL(bash_cv_signal_vintage,
43[
44  AC_TRY_LINK([#include <signal.h>],[
45    sigset_t ss;
46    struct sigaction sa;
47    sigemptyset(&ss); sigsuspend(&ss);
48    sigaction(SIGINT, &sa, (struct sigaction *) 0);
49    sigprocmask(SIG_BLOCK, &ss, (sigset_t *) 0);
50  ], bash_cv_signal_vintage=posix,
51  [
52    AC_TRY_LINK([#include <signal.h>], [
53        int mask = sigmask(SIGINT);
54        sigsetmask(mask); sigblock(mask); sigpause(mask);
55    ], bash_cv_signal_vintage=4.2bsd,
56    [
57      AC_TRY_LINK([
58        #include <signal.h>
59        RETSIGTYPE foo() { }], [
60                int mask = sigmask(SIGINT);
61                sigset(SIGINT, foo); sigrelse(SIGINT);
62                sighold(SIGINT); sigpause(SIGINT);
63        ], bash_cv_signal_vintage=svr3, bash_cv_signal_vintage=v7
64    )]
65  )]
66)
67])
68AC_MSG_RESULT($bash_cv_signal_vintage)
69if test "$bash_cv_signal_vintage" = posix; then
70AC_DEFINE(HAVE_POSIX_SIGNALS)
71elif test "$bash_cv_signal_vintage" = "4.2bsd"; then
72AC_DEFINE(HAVE_BSD_SIGNALS)
73elif test "$bash_cv_signal_vintage" = svr3; then
74AC_DEFINE(HAVE_USG_SIGHOLD)
75fi
76])
77
78dnl Check if the pgrp of setpgrp() can't be the pid of a zombie process.
79AC_DEFUN(BASH_PGRP_SYNC,
80[AC_REQUIRE([AC_FUNC_GETPGRP])
81AC_MSG_CHECKING(whether pgrps need synchronization)
82AC_CACHE_VAL(bash_cv_pgrp_pipe,
83[AC_TRY_RUN([
84#ifdef HAVE_UNISTD_H
85#  include <unistd.h>
86#endif
87main()
88{
89# ifdef GETPGRP_VOID
90#  define getpgID()     getpgrp()
91# else
92#  define getpgID()     getpgrp(0)
93#  define setpgid(x,y)  setpgrp(x,y)
94# endif
95        int pid1, pid2, fds[2];
96        int status;
97        char ok;
98
99        switch (pid1 = fork()) {
100          case -1:
101            exit(1);
102          case 0:
103            setpgid(0, getpid());
104            exit(0);
105        }
106        setpgid(pid1, pid1);
107
108        sleep(2);       /* let first child die */
109
110        if (pipe(fds) < 0)
111          exit(2);
112
113        switch (pid2 = fork()) {
114          case -1:
115            exit(3);
116          case 0:
117            setpgid(0, pid1);
118            ok = getpgID() == pid1;
119            write(fds[1], &ok, 1);
120            exit(0);
121        }
122        setpgid(pid2, pid1);
123
124        close(fds[1]);
125        if (read(fds[0], &ok, 1) != 1)
126          exit(4);
127        wait(&status);
128        wait(&status);
129        exit(ok ? 0 : 5);
130}
131], bash_cv_pgrp_pipe=no,bash_cv_pgrp_pipe=yes,
132   [AC_MSG_WARN(cannot check pgrp synchronization if cross compiling -- defaulting to no)
133    bash_cv_pgrp_pipe=no])
134])
135AC_MSG_RESULT($bash_cv_pgrp_pipe)
136if test $bash_cv_pgrp_pipe = yes; then
137AC_DEFINE(PGRP_PIPE)
138fi
139])
140
141dnl
142dnl check for typedef'd symbols in header files, but allow the caller to
143dnl specify the include files to be checked in addition to the default
144dnl
145dnl BASH_CHECK_TYPE(TYPE, HEADERS, DEFAULT[, VALUE-IF-FOUND])
146AC_DEFUN(BASH_CHECK_TYPE,
147[AC_REQUIRE([AC_HEADER_STDC])dnl
148AC_MSG_CHECKING(for $1)
149AC_CACHE_VAL(bash_cv_type_$1,
150[AC_EGREP_CPP($1, [#include <sys/types.h>
151#if STDC_HEADERS
152#include <stdlib.h>
153#endif
154$2
155], bash_cv_type_$1=yes, bash_cv_type_$1=no)])
156AC_MSG_RESULT($bash_cv_type_$1)
157ifelse($#, 4, [if test $bash_cv_type_$1 = yes; then
158        AC_DEFINE($4)
159        fi])
160if test $bash_cv_type_$1 = no; then
161  AC_DEFINE($1, $3)
162fi
163])
164
165dnl
166dnl Type of struct rlimit fields: some systems (OSF/1, NetBSD, RISC/os 5.0)
167dnl have a rlim_t, others (4.4BSD based systems) use quad_t, others use
168dnl long and still others use int (HP-UX 9.01, SunOS 4.1.3).  To simplify
169dnl matters, this just checks for rlim_t, quad_t, or long.
170dnl
171AC_DEFUN(BASH_RLIMIT_TYPE,
172[AC_MSG_CHECKING(for size and type of struct rlimit fields)
173AC_CACHE_VAL(bash_cv_type_rlimit,
174[AC_TRY_COMPILE([#include <sys/types.h>
175#include <sys/resource.h>],
176[rlim_t xxx;], bash_cv_type_rlimit=rlim_t,[
177AC_TRY_RUN([
178#include <sys/types.h>
179#include <sys/time.h>
180#include <sys/resource.h>
181main()
182{
183#ifdef HAVE_QUAD_T
184  struct rlimit rl;
185  if (sizeof(rl.rlim_cur) == sizeof(quad_t))
186    exit(0);
187#endif
188  exit(1);
189}], bash_cv_type_rlimit=quad_t, bash_cv_type_rlimit=long,
190        [AC_MSG_WARN(cannot check quad_t if cross compiling -- defaulting to long)
191         bash_cv_type_rlimit=long])])
192])
193AC_MSG_RESULT($bash_cv_type_rlimit)
194if test $bash_cv_type_rlimit = quad_t; then
195AC_DEFINE(RLIMTYPE, quad_t)
196elif test $bash_cv_type_rlimit = rlim_t; then
197AC_DEFINE(RLIMTYPE, rlim_t)
198fi
199])
200
201dnl
202dnl Check for sys_siglist[] or _sys_siglist[]
203dnl
204AC_DEFUN(BASH_DECL_UNDER_SYS_SIGLIST,
205[AC_MSG_CHECKING([for _sys_siglist in signal.h or unistd.h])
206AC_CACHE_VAL(bash_cv_decl_under_sys_siglist,
207[AC_TRY_COMPILE([
208#include <sys/types.h>
209#include <signal.h>
210#ifdef HAVE_UNISTD_H
211#include <unistd.h>
212#endif], [ char *msg = _sys_siglist[2]; ],
213  bash_cv_decl_under_sys_siglist=yes, bash_cv_decl_under_sys_siglist=no,
214  [AC_MSG_WARN(cannot check for _sys_siglist[] if cross compiling -- defaulting to no)])])dnl
215AC_MSG_RESULT($bash_cv_decl_under_sys_siglist)
216if test $bash_cv_decl_under_sys_siglist = yes; then
217AC_DEFINE(UNDER_SYS_SIGLIST_DECLARED)
218fi
219])
220
221AC_DEFUN(BASH_UNDER_SYS_SIGLIST,
222[AC_REQUIRE([BASH_DECL_UNDER_SYS_SIGLIST])
223AC_MSG_CHECKING([for _sys_siglist in system C library])
224AC_CACHE_VAL(bash_cv_under_sys_siglist,
225[AC_TRY_RUN([
226#include <sys/types.h>
227#include <signal.h>
228#ifdef HAVE_UNISTD_H
229#include <unistd.h>
230#endif
231#ifndef UNDER_SYS_SIGLIST_DECLARED
232extern char *_sys_siglist[];
233#endif
234main()
235{
236char *msg = (char *)_sys_siglist[2];
237exit(msg == 0);
238}],
239        bash_cv_under_sys_siglist=yes, bash_cv_under_sys_siglist=no,
240        [AC_MSG_WARN(cannot check for _sys_siglist[] if cross compiling -- defaulting to no)
241         bash_cv_under_sys_siglist=no])])
242AC_MSG_RESULT($bash_cv_under_sys_siglist)
243if test $bash_cv_under_sys_siglist = yes; then
244AC_DEFINE(HAVE_UNDER_SYS_SIGLIST)
245fi
246])
247
248AC_DEFUN(BASH_SYS_SIGLIST,
249[AC_REQUIRE([AC_DECL_SYS_SIGLIST])
250AC_MSG_CHECKING([for sys_siglist in system C library])
251AC_CACHE_VAL(bash_cv_sys_siglist,
252[AC_TRY_RUN([
253#include <sys/types.h>
254#include <signal.h>
255#ifdef HAVE_UNISTD_H
256#include <unistd.h>
257#endif
258#ifndef SYS_SIGLIST_DECLARED
259extern char *sys_siglist[];
260#endif
261main()
262{
263char *msg = sys_siglist[2];
264exit(msg == 0);
265}],
266        bash_cv_sys_siglist=yes, bash_cv_sys_siglist=no,
267        [AC_MSG_WARN(cannot check for sys_siglist if cross compiling -- defaulting to no)
268         bash_cv_sys_siglist=no])])
269AC_MSG_RESULT($bash_cv_sys_siglist)
270if test $bash_cv_sys_siglist = yes; then
271AC_DEFINE(HAVE_SYS_SIGLIST)
272fi
273])
274
275dnl Check for sys_errlist[] and sys_nerr, check for declaration
276AC_DEFUN(BASH_SYS_ERRLIST,
277[AC_MSG_CHECKING([for sys_errlist and sys_nerr])
278AC_CACHE_VAL(bash_cv_sys_errlist,
279[AC_TRY_LINK([#include <errno.h>],
280[extern char *sys_errlist[];
281 extern int sys_nerr;
282 char *msg = sys_errlist[sys_nerr - 1];],
283    bash_cv_sys_errlist=yes, bash_cv_sys_errlist=no)])dnl
284AC_MSG_RESULT($bash_cv_sys_errlist)
285if test $bash_cv_sys_errlist = yes; then
286AC_DEFINE(HAVE_SYS_ERRLIST)
287fi
288])
289
290dnl Check to see if opendir will open non-directories (not a nice thing)
291AC_DEFUN(BASH_FUNC_OPENDIR_CHECK,
292[AC_REQUIRE([AC_HEADER_DIRENT])dnl
293AC_MSG_CHECKING(if opendir() opens non-directories)
294AC_CACHE_VAL(bash_cv_opendir_not_robust,
295[AC_TRY_RUN([
296#include <stdio.h>
297#include <sys/types.h>
298#include <fcntl.h>
299#ifdef HAVE_UNISTD_H
300# include <unistd.h>
301#endif /* HAVE_UNISTD_H */
302#if defined(HAVE_DIRENT_H)
303# include <dirent.h>
304#else
305# define dirent direct
306# ifdef HAVE_SYS_NDIR_H
307#  include <sys/ndir.h>
308# endif /* SYSNDIR */
309# ifdef HAVE_SYS_DIR_H
310#  include <sys/dir.h>
311# endif /* SYSDIR */
312# ifdef HAVE_NDIR_H
313#  include <ndir.h>
314# endif
315#endif /* HAVE_DIRENT_H */
316main()
317{
318DIR *dir;
319int fd, err;
320err = mkdir("/tmp/bash-aclocal", 0700);
321if (err < 0) {
322  perror("mkdir");
323  exit(1);
324}
325unlink("/tmp/bash-aclocal/not_a_directory");
326fd = open("/tmp/bash-aclocal/not_a_directory", O_WRONLY|O_CREAT|O_EXCL, 0666);
327write(fd, "\n", 1);
328close(fd);
329dir = opendir("/tmp/bash-aclocal/not_a_directory");
330unlink("/tmp/bash-aclocal/not_a_directory");
331rmdir("/tmp/bash-aclocal");
332exit (dir == 0);
333}], bash_cv_opendir_not_robust=yes,bash_cv_opendir_not_robust=no,
334    [AC_MSG_WARN(cannot check opendir if cross compiling -- defaulting to no)
335     bash_cv_opendir_not_robust=no]
336)])
337AC_MSG_RESULT($bash_cv_opendir_not_robust)
338if test $bash_cv_opendir_not_robust = yes; then
339AC_DEFINE(OPENDIR_NOT_ROBUST)
340fi
341])
342
343dnl
344AC_DEFUN(BASH_TYPE_SIGHANDLER,
345[AC_MSG_CHECKING([whether signal handlers are of type void])
346AC_CACHE_VAL(bash_cv_void_sighandler,
347[AC_TRY_COMPILE([#include <sys/types.h>
348#include <signal.h>
349#ifdef signal
350#undef signal
351#endif
352#ifdef __cplusplus
353extern "C"
354#endif
355void (*signal ()) ();],
356[int i;], bash_cv_void_sighandler=yes, bash_cv_void_sighandler=no)])dnl
357AC_MSG_RESULT($bash_cv_void_sighandler)
358if test $bash_cv_void_sighandler = yes; then
359AC_DEFINE(VOID_SIGHANDLER)
360fi
361])
362
363dnl
364dnl A signed 16-bit integer quantity
365dnl
366AC_DEFUN(BASH_TYPE_BITS16_T,
367[
368if test "$ac_cv_sizeof_short" = 2; then
369  AC_CHECK_TYPE(bits16_t, short)
370elif test "$ac_cv_sizeof_char" = 2; then
371  AC_CHECK_TYPE(bits16_t, char)
372else
373  AC_CHECK_TYPE(bits16_t, short)
374fi
375])
376
377dnl
378dnl An unsigned 16-bit integer quantity
379dnl
380AC_DEFUN(BASH_TYPE_U_BITS16_T,
381[
382if test "$ac_cv_sizeof_short" = 2; then
383  AC_CHECK_TYPE(u_bits16_t, unsigned short)
384elif test "$ac_cv_sizeof_char" = 2; then
385  AC_CHECK_TYPE(u_bits16_t, unsigned char)
386else
387  AC_CHECK_TYPE(u_bits16_t, unsigned short)
388fi
389])
390
391dnl
392dnl A signed 32-bit integer quantity
393dnl
394AC_DEFUN(BASH_TYPE_BITS32_T,
395[
396if test "$ac_cv_sizeof_int" = 4; then
397  AC_CHECK_TYPE(bits32_t, int)
398elif test "$ac_cv_sizeof_long" = 4; then
399  AC_CHECK_TYPE(bits32_t, long)
400else
401  AC_CHECK_TYPE(bits32_t, int)
402fi
403])
404
405dnl
406dnl An unsigned 32-bit integer quantity
407dnl
408AC_DEFUN(BASH_TYPE_U_BITS32_T,
409[
410if test "$ac_cv_sizeof_int" = 4; then
411  AC_CHECK_TYPE(u_bits32_t, unsigned int)
412elif test "$ac_cv_sizeof_long" = 4; then
413  AC_CHECK_TYPE(u_bits32_t, unsigned long)
414else
415  AC_CHECK_TYPE(u_bits32_t, unsigned int)
416fi
417])
418
419AC_DEFUN(BASH_TYPE_PTRDIFF_T,
420[
421if test "$ac_cv_sizeof_int" = "$ac_cv_sizeof_char_p"; then
422  AC_CHECK_TYPE(ptrdiff_t, int)
423elif test "$ac_cv_sizeof_long" = "$ac_cv_sizeof_char_p"; then
424  AC_CHECK_TYPE(ptrdiff_t, long)
425else
426  AC_CHECK_TYPE(ptrdiff_t, int)
427fi
428])
429
430dnl
431dnl A signed 64-bit quantity
432dnl
433AC_DEFUN(BASH_TYPE_BITS64_T,
434[
435if test "$ac_sv_sizeof_char_p" = 8; then
436  AC_CHECK_TYPE(bits64_t, char *)
437elif test "$ac_cv_sizeof_double" = 8; then
438  AC_CHECK_TYPE(bits64_t, double)
439elif test "$ac_cv_sizeof_long" = 8; then
440  AC_CHECK_TYPE(bits64_t, long)
441else
442  AC_CHECK_TYPE(bits64_t, double)
443fi
444])
445
446AC_DEFUN(BASH_FUNC_STRSIGNAL,
447[AC_MSG_CHECKING([for the existence of strsignal])
448AC_CACHE_VAL(bash_cv_have_strsignal,
449[AC_TRY_LINK([#include <sys/types.h>
450#include <signal.h>],
451[char *s = (char *)strsignal(2);],
452 bash_cv_have_strsignal=yes, bash_cv_have_strsignal=no)])
453AC_MSG_RESULT($bash_cv_have_strsignal)
454if test $bash_cv_have_strsignal = yes; then
455AC_DEFINE(HAVE_STRSIGNAL)
456fi
457])
458
459AC_DEFUN(BASH_FUNC_LSTAT,
460[dnl Cannot use AC_CHECK_FUNCS(lstat) because Linux defines lstat() as an
461dnl inline function in <sys/stat.h>.
462AC_CACHE_CHECK([for lstat], bash_cv_func_lstat,
463[AC_TRY_LINK([
464#include <sys/types.h>
465#include <sys/stat.h>
466],[ lstat(".",(struct stat *)0); ],
467bash_cv_func_lstat=yes, bash_cv_func_lstat=no)])
468if test $bash_cv_func_lstat = yes; then
469  AC_DEFINE(HAVE_LSTAT)
470fi
471])
472
473AC_DEFUN(BASH_FUNC_INET_ATON,
474[
475AC_CACHE_CHECK([for inet_aton], bash_cv_func_inet_aton,
476[AC_TRY_LINK([
477#include <sys/types.h>
478#include <netinet/in.h>
479#include <arpa/inet.h>
480struct in_addr ap;], [ inet_aton("127.0.0.1", &ap); ],
481bash_cv_func_inet_aton=yes, bash_cv_func_inet_aton=no)])
482if test $bash_cv_func_inet_aton = yes; then
483  AC_DEFINE(HAVE_INET_ATON)
484fi
485])
486
487AC_DEFUN(BASH_STRUCT_TERMIOS_LDISC,
488[AC_MSG_CHECKING([for a c_line member of struct termios])
489AC_CACHE_VAL(bash_cv_termios_ldisc,
490[AC_TRY_COMPILE([#include <sys/types.h>
491#include <termios.h>],[struct termios t; int i; i = t.c_line;],
492  bash_cv_termios_ldisc=yes, bash_cv_termios_ldisc=no)])dnl
493AC_MSG_RESULT($bash_cv_termios_ldisc)
494if test $bash_cv_termios_ldisc = yes; then
495AC_DEFINE(TERMIOS_LDISC)
496fi
497])
498
499AC_DEFUN(BASH_STRUCT_TERMIO_LDISC,
500[AC_MSG_CHECKING([for a c_line member of struct termio])
501AC_CACHE_VAL(bash_cv_termio_ldisc,
502[AC_TRY_COMPILE([#include <sys/types.h>
503#include <termio.h>],[struct termio t; int i; i = t.c_line;],
504  bash_cv_termio_ldisc=yes, bash_cv_termio_ldisc=no)])dnl
505AC_MSG_RESULT($bash_cv_termio_ldisc)
506if test $bash_cv_termio_ldisc = yes; then
507AC_DEFINE(TERMIO_LDISC)
508fi
509])
510
511AC_DEFUN(BASH_FUNC_GETENV,
512[AC_MSG_CHECKING(to see if getenv can be redefined)
513AC_CACHE_VAL(bash_cv_getenv_redef,
514[AC_TRY_RUN([
515#ifdef HAVE_UNISTD_H
516#  include <unistd.h>
517#endif
518#ifndef __STDC__
519#  ifndef const
520#    define const
521#  endif
522#endif
523char *
524getenv (name)
525#if defined (__linux__) || defined (__bsdi__) || defined (convex)
526     const char *name;
527#else
528     char const *name;
529#endif /* !__linux__ && !__bsdi__ && !convex */
530{
531return "42";
532}
533main()
534{
535char *s;
536/* The next allows this program to run, but does not allow bash to link
537   when it redefines getenv.  I'm not really interested in figuring out
538   why not. */
539#if defined (NeXT)
540exit(1);
541#endif
542s = getenv("ABCDE");
543exit(s == 0);   /* force optimizer to leave getenv in */
544}
545], bash_cv_getenv_redef=yes, bash_cv_getenv_redef=no,
546   [AC_MSG_WARN(cannot check getenv redefinition if cross compiling -- defaulting to yes)
547    bash_cv_getenv_redef=yes]
548)])
549AC_MSG_RESULT($bash_cv_getenv_redef)
550if test $bash_cv_getenv_redef = yes; then
551AC_DEFINE(CAN_REDEFINE_GETENV)
552fi
553])
554
555AC_DEFUN(BASH_FUNC_PRINTF,
556[AC_MSG_CHECKING(for declaration of printf in <stdio.h>)
557AC_CACHE_VAL(bash_cv_printf_declared,
558[AC_TRY_RUN([
559#include <stdio.h>
560#ifdef __STDC__
561typedef int (*_bashfunc)(const char *, ...);
562#else
563typedef int (*_bashfunc)();
564#endif
565main()
566{
567_bashfunc pf;
568pf = (_bashfunc) printf;
569exit(pf == 0);
570}
571], bash_cv_printf_declared=yes, bash_cv_printf_declared=no,
572   [AC_MSG_WARN(cannot check printf declaration if cross compiling -- defaulting to yes)
573    bash_cv_printf_declared=yes]
574)])
575AC_MSG_RESULT($bash_cv_printf_declared)
576if test $bash_cv_printf_declared = yes; then
577AC_DEFINE(PRINTF_DECLARED)
578fi
579])
580
581AC_DEFUN(BASH_FUNC_ULIMIT_MAXFDS,
582[AC_MSG_CHECKING(whether ulimit can substitute for getdtablesize)
583AC_CACHE_VAL(bash_cv_ulimit_maxfds,
584[AC_TRY_RUN([
585main()
586{
587long maxfds = ulimit(4, 0L);
588exit (maxfds == -1L);
589}
590], bash_cv_ulimit_maxfds=yes, bash_cv_ulimit_maxfds=no,
591   [AC_MSG_WARN(cannot check ulimit if cross compiling -- defaulting to no)
592    bash_cv_ulimit_maxfds=no]
593)])
594AC_MSG_RESULT($bash_cv_ulimit_maxfds)
595if test $bash_cv_ulimit_maxfds = yes; then
596AC_DEFINE(ULIMIT_MAXFDS)
597fi
598])
599
600AC_DEFUN(BASH_CHECK_LIB_TERMCAP,
601[
602if test "X$bash_cv_termcap_lib" = "X"; then
603_bash_needmsg=yes
604else
605AC_MSG_CHECKING(which library has the termcap functions)
606_bash_needmsg=
607fi
608AC_CACHE_VAL(bash_cv_termcap_lib,
609[AC_CHECK_LIB(termcap, tgetent, bash_cv_termcap_lib=libtermcap,
610    [AC_CHECK_LIB(curses, tgetent, bash_cv_termcap_lib=libcurses,
611        [AC_CHECK_LIB(ncurses, tgetent, bash_cv_termcap_lib=libncurses,
612            bash_cv_termcap_lib=gnutermcap)])])])
613if test "X$_bash_needmsg" = "Xyes"; then
614AC_MSG_CHECKING(which library has the termcap functions)
615fi
616AC_MSG_RESULT(using $bash_cv_termcap_lib)
617if test $bash_cv_termcap_lib = gnutermcap && test -z "$prefer_curses"; then
618LDFLAGS="$LDFLAGS -L./lib/termcap"
619TERMCAP_LIB="./lib/termcap/libtermcap.a"
620TERMCAP_DEP="./lib/termcap/libtermcap.a"
621elif test $bash_cv_termcap_lib = libtermcap && test -z "$prefer_curses"; then
622TERMCAP_LIB=-ltermcap
623TERMCAP_DEP=
624elif test $bash_cv_termcap_lib = libncurses; then
625TERMCAP_LIB=-lncurses
626TERMCAP_DEP=
627else
628TERMCAP_LIB=-lcurses
629TERMCAP_DEP=
630fi
631])
632
633AC_DEFUN(BASH_FUNC_GETCWD,
634[AC_MSG_CHECKING([if getcwd() calls popen()])
635AC_CACHE_VAL(bash_cv_getcwd_calls_popen,
636[AC_TRY_RUN([
637#include <stdio.h>
638#ifdef HAVE_UNISTD_H
639#include <unistd.h>
640#endif
641
642#ifndef __STDC__
643#ifndef const
644#define const
645#endif
646#endif
647
648int popen_called;
649
650FILE *
651popen(command, type)
652     const char *command;
653     const char *type;
654{
655        popen_called = 1;
656        return (FILE *)NULL;
657}
658
659FILE *_popen(command, type)
660     const char *command;
661     const char *type;
662{
663  return (popen (command, type));
664}
665
666int
667pclose(stream)
668FILE *stream;
669{
670        return 0;
671}
672
673int
674_pclose(stream)
675FILE *stream;
676{
677        return 0;
678}
679
680main()
681{
682        char    lbuf[32];
683        popen_called = 0;
684        getcwd(lbuf, 32);
685        exit (popen_called);
686}
687], bash_cv_getcwd_calls_popen=no, bash_cv_getcwd_calls_popen=yes,
688   [AC_MSG_WARN(cannot check whether getcwd calls popen if cross compiling -- defaulting to no)
689    bash_cv_getcwd_calls_popen=no]
690)])
691AC_MSG_RESULT($bash_cv_getcwd_calls_popen)
692if test $bash_cv_getcwd_calls_popen = yes; then
693AC_DEFINE(GETCWD_BROKEN)
694fi
695])
696
697AC_DEFUN(BASH_STRUCT_DIRENT_D_INO,
698[AC_REQUIRE([AC_HEADER_DIRENT])
699AC_MSG_CHECKING(if struct dirent has a d_ino member)
700AC_CACHE_VAL(bash_cv_dirent_has_dino,
701[AC_TRY_COMPILE([
702#include <stdio.h>
703#include <sys/types.h>
704#ifdef HAVE_UNISTD_H
705# include <unistd.h>
706#endif /* HAVE_UNISTD_H */
707#if defined(HAVE_DIRENT_H)
708# include <dirent.h>
709#else
710# define dirent direct
711# ifdef HAVE_SYS_NDIR_H
712#  include <sys/ndir.h>
713# endif /* SYSNDIR */
714# ifdef HAVE_SYS_DIR_H
715#  include <sys/dir.h>
716# endif /* SYSDIR */
717# ifdef HAVE_NDIR_H
718#  include <ndir.h>
719# endif
720#endif /* HAVE_DIRENT_H */
721],[
722struct dirent d; int z; z = d.d_ino;
723], bash_cv_dirent_has_dino=yes, bash_cv_dirent_has_dino=no)])
724AC_MSG_RESULT($bash_cv_dirent_has_dino)
725if test $bash_cv_dirent_has_dino = yes; then
726AC_DEFINE(STRUCT_DIRENT_HAS_D_INO)
727fi
728])
729
730AC_DEFUN(BASH_STRUCT_DIRENT_D_FILENO,
731[AC_REQUIRE([AC_HEADER_DIRENT])
732AC_MSG_CHECKING(if struct dirent has a d_fileno member)
733AC_CACHE_VAL(bash_cv_dirent_has_d_fileno,
734[AC_TRY_COMPILE([
735#include <stdio.h>
736#include <sys/types.h>
737#ifdef HAVE_UNISTD_H
738# include <unistd.h>
739#endif /* HAVE_UNISTD_H */
740#if defined(HAVE_DIRENT_H)
741# include <dirent.h>
742#else
743# define dirent direct
744# ifdef HAVE_SYS_NDIR_H
745#  include <sys/ndir.h>
746# endif /* SYSNDIR */
747# ifdef HAVE_SYS_DIR_H
748#  include <sys/dir.h>
749# endif /* SYSDIR */
750# ifdef HAVE_NDIR_H
751#  include <ndir.h>
752# endif
753#endif /* HAVE_DIRENT_H */
754],[
755struct dirent d; int z; z = d.d_fileno;
756], bash_cv_dirent_has_d_fileno=yes, bash_cv_dirent_has_d_fileno=no)])
757AC_MSG_RESULT($bash_cv_dirent_has_d_fileno)
758if test $bash_cv_dirent_has_d_fileno = yes; then
759AC_DEFINE(STRUCT_DIRENT_HAS_D_FILENO)
760fi
761])
762
763AC_DEFUN(BASH_REINSTALL_SIGHANDLERS,
764[AC_REQUIRE([AC_TYPE_SIGNAL])
765AC_REQUIRE([BASH_SIGNAL_CHECK])
766AC_MSG_CHECKING([if signal handlers must be reinstalled when invoked])
767AC_CACHE_VAL(bash_cv_must_reinstall_sighandlers,
768[AC_TRY_RUN([
769#include <signal.h>
770#ifdef HAVE_UNISTD_H
771#include <unistd.h>
772#endif
773
774typedef RETSIGTYPE sigfunc();
775
776int nsigint;
777
778#ifdef HAVE_POSIX_SIGNALS
779sigfunc *
780set_signal_handler(sig, handler)
781     int sig;
782     sigfunc *handler;
783{
784  struct sigaction act, oact;
785  act.sa_handler = handler;
786  act.sa_flags = 0;
787  sigemptyset (&act.sa_mask);
788  sigemptyset (&oact.sa_mask);
789  sigaction (sig, &act, &oact);
790  return (oact.sa_handler);
791}
792#else
793#define set_signal_handler(s, h) signal(s, h)
794#endif
795
796RETSIGTYPE
797sigint(s)
798int s;
799{
800  nsigint++;
801}
802
803main()
804{
805        nsigint = 0;
806        set_signal_handler(SIGINT, sigint);
807        kill((int)getpid(), SIGINT);
808        kill((int)getpid(), SIGINT);
809        exit(nsigint != 2);
810}
811], bash_cv_must_reinstall_sighandlers=no, bash_cv_must_reinstall_sighandlers=yes,
812   [AC_MSG_WARN(cannot check signal handling if cross compiling -- defaulting to no)
813    bash_cv_must_reinstall_sighandlers=no]
814)])
815AC_MSG_RESULT($bash_cv_must_reinstall_sighandlers)
816if test $bash_cv_must_reinstall_sighandlers = yes; then
817AC_DEFINE(MUST_REINSTALL_SIGHANDLERS)
818fi
819])
820
821AC_DEFUN(BASH_FUNC_SBRK_DECLARED,
822[AC_MSG_CHECKING(for declaration of sbrk in <unistd.h>)
823AC_CACHE_VAL(bash_cv_sbrk_declared,
824[AC_EGREP_HEADER(sbrk, unistd.h,
825 bash_cv_sbrk_declared=yes, bash_cv_sbrk_declared=no)])
826AC_MSG_RESULT($bash_cv_sbrk_declared)
827if test $bash_cv_sbrk_declared = yes; then
828AC_DEFINE(SBRK_DECLARED)
829fi
830])
831
832dnl check that some necessary job control definitions are present
833AC_DEFUN(BASH_JOB_CONTROL_MISSING,
834[AC_REQUIRE([BASH_SIGNAL_CHECK])
835AC_MSG_CHECKING(for presence of necessary job control definitions)
836AC_CACHE_VAL(bash_cv_job_control_missing,
837[AC_TRY_RUN([
838#include <sys/types.h>
839#ifdef HAVE_SYS_WAIT_H
840#include <sys/wait.h>
841#endif
842#ifdef HAVE_UNISTD_H
843#include <unistd.h>
844#endif
845#include <signal.h>
846
847/* Add more tests in here as appropriate. */
848main()
849{
850/* signal type */
851#if !defined (HAVE_POSIX_SIGNALS) && !defined (HAVE_BSD_SIGNALS)
852exit(1);
853#endif
854
855/* signals and tty control. */
856#if !defined (SIGTSTP) || !defined (SIGSTOP) || !defined (SIGCONT)
857exit (1);
858#endif
859
860/* process control */
861#if !defined (WNOHANG) || !defined (WUNTRACED)
862exit(1);
863#endif
864
865/* Posix systems have tcgetpgrp and waitpid. */
866#if defined (_POSIX_VERSION) && !defined (HAVE_TCGETPGRP)
867exit(1);
868#endif
869
870#if defined (_POSIX_VERSION) && !defined (HAVE_WAITPID)
871exit(1);
872#endif
873
874/* Other systems have TIOCSPGRP/TIOCGPRGP and wait3. */
875#if !defined (_POSIX_VERSION) && !defined (HAVE_WAIT3)
876exit(1);
877#endif
878
879exit(0);
880}], bash_cv_job_control_missing=present, bash_cv_job_control_missing=missing,
881    [AC_MSG_WARN(cannot check job control if cross-compiling -- defaulting to missing)
882     bash_cv_job_control_missing=missing]
883)])
884AC_MSG_RESULT($bash_cv_job_control_missing)
885if test $bash_cv_job_control_missing = missing; then
886AC_DEFINE(JOB_CONTROL_MISSING)
887fi
888])
889
890dnl check whether named pipes are present
891dnl this requires a previous check for mkfifo, but that is awkward to specify
892AC_DEFUN(BASH_SYS_NAMED_PIPES,
893[AC_MSG_CHECKING(for presence of named pipes)
894AC_CACHE_VAL(bash_cv_sys_named_pipes,
895[AC_TRY_RUN([
896#include <sys/types.h>
897#include <sys/stat.h>
898#ifdef HAVE_UNISTD_H
899#include <unistd.h>
900#endif
901
902/* Add more tests in here as appropriate. */
903main()
904{
905int fd, err;
906
907#if defined (HAVE_MKFIFO)
908exit (0);
909#endif
910
911#if !defined (S_IFIFO) && (defined (_POSIX_VERSION) && !defined (S_ISFIFO))
912exit (1);
913#endif
914
915#if defined (NeXT)
916exit (1);
917#endif
918err = mkdir("/tmp/bash-aclocal", 0700);
919if (err < 0) {
920  perror ("mkdir");
921  exit(1);
922}
923fd = mknod ("/tmp/bash-aclocal/sh-np-autoconf", 0666 | S_IFIFO, 0);
924if (fd == -1) {
925  rmdir ("/tmp/bash-aclocal");
926  exit (1);
927}
928close(fd);
929unlink ("/tmp/bash-aclocal/sh-np-autoconf");
930rmdir ("/tmp/bash-aclocal");
931exit(0);
932}], bash_cv_sys_named_pipes=present, bash_cv_sys_named_pipes=missing,
933    [AC_MSG_WARN(cannot check for named pipes if cross-compiling -- defaulting to missing)
934     bash_cv_sys_named_pipes=missing]
935)])
936AC_MSG_RESULT($bash_cv_sys_named_pipes)
937if test $bash_cv_sys_named_pipes = missing; then
938AC_DEFINE(NAMED_PIPES_MISSING)
939fi
940])
941
942AC_DEFUN(BASH_FUNC_POSIX_SETJMP,
943[AC_REQUIRE([BASH_SIGNAL_CHECK])
944AC_MSG_CHECKING(for presence of POSIX-style sigsetjmp/siglongjmp)
945AC_CACHE_VAL(bash_cv_func_sigsetjmp,
946[AC_TRY_RUN([
947#ifdef HAVE_UNISTD_H
948#include <unistd.h>
949#endif
950#include <sys/types.h>
951#include <signal.h>
952#include <setjmp.h>
953
954main()
955{
956#if !defined (_POSIX_VERSION) || !defined (HAVE_POSIX_SIGNALS)
957exit (1);
958#else
959
960int code;
961sigset_t set, oset;
962sigjmp_buf xx;
963
964/* get the mask */
965sigemptyset(&set);
966sigemptyset(&oset);
967sigprocmask(SIG_BLOCK, (sigset_t *)NULL, &set);
968sigprocmask(SIG_BLOCK, (sigset_t *)NULL, &oset);
969
970/* save it */
971code = sigsetjmp(xx, 1);
972if (code)
973  exit(0);      /* could get sigmask and compare to oset here. */
974
975/* change it */
976sigaddset(&set, SIGINT);
977sigprocmask(SIG_BLOCK, &set, (sigset_t *)NULL);
978
979/* and siglongjmp */
980siglongjmp(xx, 10);
981exit(1);
982#endif
983}], bash_cv_func_sigsetjmp=present, bash_cv_func_sigsetjmp=missing,
984    [AC_MSG_WARN(cannot check for sigsetjmp/siglongjmp if cross-compiling -- defaulting to missing)
985     bash_cv_func_sigsetjmp=missing]
986)])
987AC_MSG_RESULT($bash_cv_func_sigsetjmp)
988if test $bash_cv_func_sigsetjmp = present; then
989AC_DEFINE(HAVE_POSIX_SIGSETJMP)
990fi
991])
992
993AC_DEFUN(BASH_HAVE_TIOCGWINSZ,
994[AC_MSG_CHECKING(for TIOCGWINSZ in sys/ioctl.h)
995AC_CACHE_VAL(bash_cv_tiocgwinsz_in_ioctl,
996[AC_TRY_COMPILE([#include <sys/types.h>
997#include <sys/ioctl.h>], [int x = TIOCGWINSZ;],
998  bash_cv_tiocgwinsz_in_ioctl=yes,bash_cv_tiocgwinsz_in_ioctl=no)])
999AC_MSG_RESULT($bash_cv_tiocgwinsz_in_ioctl)
1000if test $bash_cv_tiocgwinsz_in_ioctl = yes; then   
1001AC_DEFINE(GWINSZ_IN_SYS_IOCTL)
1002fi
1003])
1004
1005AC_DEFUN(BASH_STRUCT_WINSIZE,
1006[AC_MSG_CHECKING(for struct winsize in sys/ioctl.h and termios.h)
1007AC_CACHE_VAL(bash_cv_struct_winsize_header,
1008[AC_TRY_COMPILE([#include <sys/types.h>
1009#include <sys/ioctl.h>], [struct winsize x;],
1010  bash_cv_struct_winsize_header=ioctl_h,
1011  [AC_TRY_COMPILE([#include <sys/types.h>
1012#include <termios.h>], [struct winsize x;],
1013  bash_cv_struct_winsize_header=termios_h, bash_cv_struct_winsize_header=other)
1014])])
1015if test $bash_cv_struct_winsize_header = ioctl_h; then
1016  AC_MSG_RESULT(sys/ioctl.h)
1017  AC_DEFINE(STRUCT_WINSIZE_IN_SYS_IOCTL)
1018elif test $bash_cv_struct_winsize_header = termios_h; then
1019  AC_MSG_RESULT(termios.h)
1020  AC_DEFINE(STRUCT_WINSIZE_IN_TERMIOS)
1021else
1022  AC_MSG_RESULT(not found)
1023fi
1024])
1025
1026AC_DEFUN(BASH_HAVE_TIOCSTAT,
1027[AC_MSG_CHECKING(for TIOCSTAT in sys/ioctl.h)
1028AC_CACHE_VAL(bash_cv_tiocstat_in_ioctl,
1029[AC_TRY_COMPILE([#include <sys/types.h>
1030#include <sys/ioctl.h>], [int x = TIOCSTAT;],
1031  bash_cv_tiocstat_in_ioctl=yes,bash_cv_tiocstat_in_ioctl=no)])
1032AC_MSG_RESULT($bash_cv_tiocstat_in_ioctl)
1033if test $bash_cv_tiocstat_in_ioctl = yes; then   
1034AC_DEFINE(TIOCSTAT_IN_SYS_IOCTL)
1035fi
1036])
1037
1038AC_DEFUN(BASH_HAVE_FIONREAD,
1039[AC_MSG_CHECKING(for FIONREAD in sys/ioctl.h)
1040AC_CACHE_VAL(bash_cv_fionread_in_ioctl,
1041[AC_TRY_COMPILE([#include <sys/types.h>
1042#include <sys/ioctl.h>], [int x = FIONREAD;],
1043  bash_cv_fionread_in_ioctl=yes,bash_cv_fionread_in_ioctl=no)])
1044AC_MSG_RESULT($bash_cv_fionread_in_ioctl)
1045if test $bash_cv_fionread_in_ioctl = yes; then   
1046AC_DEFINE(FIONREAD_IN_SYS_IOCTL)
1047fi
1048])
1049
1050dnl
1051dnl See if speed_t is declared in <sys/types.h>.  Some versions of linux
1052dnl require a definition of speed_t each time <termcap.h> is included,
1053dnl but you can only get speed_t if you include <termios.h> (on some
1054dnl versions) or <sys/types.h> (on others).
1055dnl
1056AC_DEFUN(BASH_MISC_SPEED_T,
1057[AC_MSG_CHECKING(for speed_t in sys/types.h)
1058AC_CACHE_VAL(bash_cv_speed_t_in_sys_types,
1059[AC_TRY_COMPILE([#include <sys/types.h>], [speed_t x;],
1060  bash_cv_speed_t_in_sys_types=yes,bash_cv_speed_t_in_sys_types=no)])
1061AC_MSG_RESULT($bash_cv_speed_t_in_sys_types)
1062if test $bash_cv_speed_t_in_sys_types = yes; then   
1063AC_DEFINE(SPEED_T_IN_SYS_TYPES)
1064fi
1065])
1066
1067AC_DEFUN(BASH_CHECK_GETPW_FUNCS,
1068[AC_MSG_CHECKING(whether programs are able to redeclare getpw functions)
1069AC_CACHE_VAL(bash_cv_can_redecl_getpw,
1070[AC_TRY_COMPILE([#include <sys/types.h>
1071#include <pwd.h>
1072extern struct passwd *getpwent();
1073extern struct passwd *getpwuid();
1074extern struct passwd *getpwnam();],
1075[struct passwd *z; z = getpwent(); z = getpwuid(0); z = getpwnam("root");],
1076  bash_cv_can_redecl_getpw=yes,bash_cv_can_redecl_getpw=no)])
1077AC_MSG_RESULT($bash_cv_can_redecl_getpw)
1078if test $bash_cv_can_redecl_getpw = no; then
1079AC_DEFINE(HAVE_GETPW_DECLS)
1080fi
1081])
1082
1083AC_DEFUN(BASH_CHECK_DEV_FD,
1084[AC_MSG_CHECKING(whether /dev/fd is available)
1085AC_CACHE_VAL(bash_cv_dev_fd,
1086[if test -d /dev/fd  && test -r /dev/fd/0; then
1087   bash_cv_dev_fd=standard
1088 elif test -d /proc/self/fd && test -r /proc/self/fd/0; then
1089   bash_cv_dev_fd=whacky
1090 else
1091   bash_cv_dev_fd=absent
1092 fi
1093])
1094AC_MSG_RESULT($bash_cv_dev_fd)
1095if test $bash_cv_dev_fd = "standard"; then
1096  AC_DEFINE(HAVE_DEV_FD)
1097  AC_DEFINE(DEV_FD_PREFIX, "/dev/fd/")
1098elif test $bash_cv_dev_fd = "whacky"; then
1099  AC_DEFINE(HAVE_DEV_FD)
1100  AC_DEFINE(DEV_FD_PREFIX, "/proc/self/fd/")
1101fi
1102])
1103
1104AC_DEFUN(BASH_CHECK_DEV_STDIN,
1105[AC_MSG_CHECKING(whether /dev/stdin stdout stderr are available)
1106AC_CACHE_VAL(bash_cv_dev_stdin,
1107[if test -d /dev/fd && test -r /dev/stdin; then
1108   bash_cv_dev_stdin=present
1109 elif test -d /proc/self/fd && test -r /dev/stdin; then
1110   bash_cv_dev_stdin=present
1111 else
1112   bash_cv_dev_stdin=absent
1113 fi
1114])
1115AC_MSG_RESULT($bash_cv_dev_stdin)
1116if test $bash_cv_dev_stdin = "present"; then
1117  AC_DEFINE(HAVE_DEV_STDIN)
1118fi
1119])
1120
1121dnl
1122dnl Check for the presence of getpeername in libsocket.
1123dnl If libsocket is present, check for libnsl and add it to LIBS if
1124dnl it's there, since most systems with libsocket require linking
1125dnl with libnsl as well.  This should only be called if getpeername
1126dnl was not found in libc.
1127dnl
1128dnl NOTE: IF WE FIND GETPEERNAME, WE ASSUME THAT WE HAVE BIND/CONNECT
1129dnl       AS WELL
1130dnl
1131AC_DEFUN(BASH_CHECK_SOCKLIB,
1132[
1133if test "X$bash_cv_have_socklib" = "X"; then
1134_bash_needmsg=
1135else
1136AC_MSG_CHECKING(for socket library)
1137_bash_needmsg=yes
1138fi
1139AC_CACHE_VAL(bash_cv_have_socklib,
1140[AC_CHECK_LIB(socket, getpeername,
1141        bash_cv_have_socklib=yes, bash_cv_have_socklib=no, -lnsl)])
1142if test "X$_bash_needmsg" = Xyes; then
1143  AC_MSG_RESULT($bash_cv_have_socklib)
1144  _bash_needmsg=
1145fi
1146if test $bash_cv_have_socklib = yes; then
1147  # check for libnsl, add it to LIBS if present
1148  if test "X$bash_cv_have_libnsl" = "X"; then
1149    _bash_needmsg=
1150  else
1151    AC_MSG_CHECKING(for libnsl)
1152    _bash_needmsg=yes
1153  fi
1154  AC_CACHE_VAL(bash_cv_have_libnsl,
1155           [AC_CHECK_LIB(nsl, t_open,
1156                 bash_cv_have_libnsl=yes, bash_cv_have_libnsl=no)])
1157  if test "X$_bash_needmsg" = Xyes; then
1158    AC_MSG_RESULT($bash_cv_have_libnsl)
1159    _bash_needmsg=
1160  fi
1161  if test $bash_cv_have_libnsl = yes; then
1162    LIBS="-lsocket -lnsl $LIBS"
1163  else
1164    LIBS="-lsocket $LIBS"
1165  fi
1166  AC_DEFINE(HAVE_LIBSOCKET)
1167  AC_DEFINE(HAVE_GETPEERNAME)
1168fi
1169])
1170
1171dnl
1172dnl This needs BASH_CHECK_SOCKLIB, but since that's not called on every
1173dnl system, we can't use AC_PREREQ
1174dnl
1175AC_DEFUN(BASH_FUNC_GETHOSTBYNAME,
1176[if test "X$bash_cv_have_gethostbyname" = "X"; then
1177_bash_needmsg=yes
1178else
1179AC_MSG_CHECKING(for gethostbyname in socket library)
1180_bash_needmsg=
1181fi
1182AC_CACHE_VAL(bash_cv_have_gethostbyname,
1183[AC_TRY_LINK([#include <netdb.h>],
1184[ struct hostent *hp;
1185  hp = gethostbyname("localhost");
1186], bash_cv_have_gethostbyname=yes, bash_cv_have_gethostbyname=no)]
1187)
1188if test "X$_bash_needmsg" = Xyes; then
1189    AC_MSG_CHECKING(for gethostbyname in socket library)
1190fi
1191AC_MSG_RESULT($bash_cv_have_gethostbyname)
1192if test "$bash_cv_have_gethostbyname" = yes; then
1193AC_DEFINE(HAVE_GETHOSTBYNAME)
1194fi
1195])
1196
1197AC_DEFUN(BASH_DEFAULT_MAIL_DIR,
1198[AC_MSG_CHECKING(for default mail directory)
1199AC_CACHE_VAL(bash_cv_mail_dir,
1200[if test -d /var/mail; then
1201   bash_cv_mail_dir=/var/mail
1202 elif test -d /usr/mail; then
1203   bash_cv_mail_dir=/usr/mail
1204 elif test -d /var/spool/mail; then
1205   bash_cv_mail_dir=/var/spool/mail
1206 elif test -d /usr/spool/mail; then
1207   bash_cv_mail_dir=/usr/spool/mail
1208 else
1209   bash_cv_mail_dir=unknown
1210 fi
1211])
1212AC_MSG_RESULT($bash_cv_mail_dir)
1213if test $bash_cv_mail_dir = "/var/mail"; then
1214   AC_DEFINE(DEFAULT_MAIL_DIRECTORY, "/var/mail")
1215elif test $bash_cv_mail_dir = "/usr/mail"; then
1216   AC_DEFINE(DEFAULT_MAIL_DIRECTORY, "/usr/mail")
1217elif test $bash_cv_mail_dir = "/var/spool/mail"; then
1218   AC_DEFINE(DEFAULT_MAIL_DIRECTORY, "/var/spool/mail")
1219elif test $bash_cv_mail_dir = "/usr/spool/mail"; then
1220   AC_DEFINE(DEFAULT_MAIL_DIRECTORY, "/usr/spool/mail")
1221else
1222   AC_DEFINE(DEFAULT_MAIL_DIRECTORY, "unknown")
1223fi
1224])
1225
1226dnl
1227dnl Check if HPUX needs _KERNEL defined for RLIMIT_* definitions
1228dnl
1229AC_DEFUN(BASH_KERNEL_RLIMIT_CHECK,
1230[AC_MSG_CHECKING([whether $host_os needs _KERNEL for RLIMIT defines])
1231AC_CACHE_VAL(bash_cv_kernel_rlimit,
1232[AC_TRY_COMPILE([
1233#include <sys/types.h>
1234#include <sys/resource.h>
1235],
1236[
1237  int f;
1238  f = RLIMIT_DATA;
1239], bash_cv_kernel_rlimit=no,
1240[AC_TRY_COMPILE([
1241#include <sys/types.h>
1242#define _KERNEL
1243#include <sys/resource.h>
1244#undef _KERNEL
1245],
1246[
1247        int f;
1248        f = RLIMIT_DATA;
1249], bash_cv_kernel_rlimit=yes, bash_cv_kernel_rlimit=no)]
1250)])
1251AC_MSG_RESULT($bash_cv_kernel_rlimit)
1252if test $bash_cv_kernel_rlimit = yes; then
1253AC_DEFINE(RLIMIT_NEEDS_KERNEL)
1254fi
1255])
1256
1257AC_DEFUN(BASH_FUNC_STRCOLL,
1258[
1259AC_MSG_CHECKING(whether or not strcoll and strcmp differ)
1260AC_CACHE_VAL(bash_cv_func_strcoll_broken,
1261[AC_TRY_RUN([
1262#include <stdio.h>
1263#if defined (HAVE_LOCALE_H)
1264#include <locale.h>
1265#endif
1266
1267main(c, v)
1268int     c;
1269char    *v[];
1270{
1271        int     r1, r2;
1272        char    *deflocale, *defcoll;
1273
1274#ifdef HAVE_SETLOCALE
1275        deflocale = setlocale(LC_ALL, "");
1276        defcoll = setlocale(LC_COLLATE, "");
1277#endif
1278
1279#ifdef HAVE_STRCOLL
1280        /* These two values are taken from tests/glob-test. */
1281        r1 = strcoll("abd", "aXd");
1282#else
1283        r1 = 0;
1284#endif
1285        r2 = strcmp("abd", "aXd");
1286
1287        /* These two should both be greater than 0.  It is permissible for
1288           a system to return different values, as long as the sign is the
1289           same. */
1290
1291        /* Exit with 1 (failure) if these two values are both > 0, since
1292           this tests whether strcoll(3) is broken with respect to strcmp(3)
1293           in the default locale. */
1294        exit (r1 > 0 && r2 > 0);
1295}
1296], bash_cv_func_strcoll_broken=yes, bash_cv_func_strcoll_broken=no,
1297   [AC_MSG_WARN(cannot check strcoll if cross compiling -- defaulting to no)
1298    bash_cv_func_strcoll_broken=no]
1299)])
1300AC_MSG_RESULT($bash_cv_func_strcoll_broken)
1301if test $bash_cv_func_strcoll_broken = yes; then
1302AC_DEFINE(STRCOLL_BROKEN)
1303fi
1304])
1305
1306dnl
1307dnl If available, use support for large files unless the user specified
1308dnl one of the CPPFLAGS, LDFLAGS, or LIBS variables (<eggert@twinsun.com>
1309dnl via GNU patch 2.5)
1310dnl
1311AC_DEFUN(BASH_LARGE_FILE_SUPPORT,
1312[AC_MSG_CHECKING(whether large file support needs explicit enabling)
1313ac_getconfs=''
1314ac_result=yes
1315ac_set=''
1316ac_shellvars='CPPFLAGS LDFLAGS LIBS'
1317for ac_shellvar in $ac_shellvars; do
1318  case $ac_shellvar in
1319  CPPFLAGS) ac_lfsvar=LFS_CFLAGS ac_lfs64var=LFS64_CFLAGS ;;
1320  *) ac_lfsvar=LFS_$ac_shellvar ac_lfs64var=LFS64_$ac_shellvar ;;
1321  esac
1322  eval test '"${'$ac_shellvar'+set}"' = set && ac_set=$ac_shellvar
1323  (getconf $ac_lfsvar) >/dev/null 2>&1 || { ac_result=no; break; }
1324  ac_getconf=`getconf $ac_lfsvar`
1325  ac_getconf64=`getconf $ac_lfs64var`
1326  ac_getconfs=$ac_getconfs$ac_getconf\ $ac_getconf64
1327  eval ac_test_$ac_shellvar="\$ac_getconf\ \$ac_getconf64"
1328done
1329case "$ac_result$ac_getconfs" in
1330yes) ac_result=no ;;
1331esac
1332case "$ac_result$ac_set" in
1333yes?*) ac_result="yes, but $ac_set is already set, so use its settings"
1334esac
1335AC_MSG_RESULT($ac_result)
1336case $ac_result in
1337yes)
1338  for ac_shellvar in $ac_shellvars; do
1339    eval $ac_shellvar=\$ac_test_$ac_shellvar
1340  done ;;
1341esac
1342])
1343
1344dnl
1345dnl AC_SYS_RESTARTABLE_SYSCALLS tests only for restarted system calls
1346dnl after a signal handler has been installed with signal().  Since
1347dnl Bash uses sigaction() if it is available, we need to check whether
1348dnl or not a signal handler installed with sigaction and SA_RESTART
1349dnl causes system calls to be restarted after the signal is caught
1350dnl
1351AC_DEFUN(BASH_SYS_RESTARTABLE_SYSCALLS,
1352[AC_REQUIRE([BASH_SIGNAL_CHECK])
1353AC_CACHE_CHECK(for restartable system calls with posix sigaction,
1354bash_cv_sys_restartable_syscalls,
1355[AC_TRY_RUN(
1356[/* Exit 0 (true) if wait returns something other than -1,
1357   i.e. the pid of the child, which means that wait was restarted
1358   after getting the signal.  */
1359#include <sys/types.h>
1360#include <signal.h>
1361static int caught = 0;
1362void ucatch (isig) int isig; { caught = 1; }
1363main ()
1364{
1365#if !defined (_POSIX_VERSION) || !defined (HAVE_POSIX_SIGNALS)
1366  exit (1);
1367#else
1368  struct sigaction act, oact;
1369  int i, status;
1370
1371  act.sa_handler = ucatch;
1372  /* Might want to add SA_RESTART here, but bash's set_signal_handler
1373     does not. */
1374  act.sa_flags = 0;
1375  sigemptyset(&act.sa_mask);
1376  sigemptyset(&oact.sa_mask);
1377  i = fork ();
1378  /* A possible race condition here, but in practice it never happens. */
1379  if (i == 0) { sleep (3); kill (getppid (), SIGINT); sleep (3); exit (0); }
1380  sigaction(SIGINT, &act, &oact);
1381  status = wait(&i);
1382  if (status == -1) wait(&i);
1383  exit (status == -1);
1384#endif
1385}
1386], bash_cv_sys_restartable_syscalls=yes, bash_cv_sys_restartable_syscalls=no,
1387   AC_MSG_WARN(cannot check restartable syscalls if cross compiling))
1388])
1389if test $bash_cv_sys_restartable_syscalls = yes; then
1390  AC_DEFINE(HAVE_RESTARTABLE_SYSCALLS)
1391fi
1392])
1393dnl
1394dnl Check for 64-bit off_t -- used for malloc alignment
1395dnl
1396dnl C does not allow duplicate case labels, so the compile will fail if
1397dnl sizeof(off_t) is > 4.
1398dnl
1399AC_DEFUN(BASH_CHECK_OFF_T_64,
1400[AC_CACHE_CHECK(for 64-bit off_t, bash_cv_off_t_64,
1401AC_TRY_COMPILE([
1402#ifdef HAVE_UNISTD_H
1403#include <unistd.h>
1404#endif
1405#include <sys/types.h>
1406],[
1407switch (0) case 0: case (sizeof (off_t) <= 4):;
1408], bash_cv_off_t_64=no, bash_cv_off_t_64=yes))
1409if test $bash_cv_off_t_64 = yes; then
1410        AC_DEFINE(HAVE_OFF_T_64)
1411fi])
1412
1413AC_DEFUN(BASH_STRUCT_TIMEVAL,
1414[AC_MSG_CHECKING(for struct timeval in sys/time.h and time.h)
1415AC_CACHE_VAL(bash_cv_struct_timeval,
1416[
1417AC_EGREP_HEADER(struct timeval, sys/time.h,
1418                bash_cv_struct_timeval=yes,
1419                AC_EGREP_HEADER(struct timeval, time.h,
1420                        bash_cv_struct_timeval=yes,
1421                        bash_cv_struct_timeval=no))
1422])
1423AC_MSG_RESULT($bash_cv_struct_timeval)
1424if test $bash_cv_struct_timeval = yes; then
1425  AC_DEFINE(HAVE_TIMEVAL)
1426fi
1427])
Note: See TracBrowser for help on using the repository browser.