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

Revision 12992, 33.4 KB checked in by kcr, 25 years ago (diff)
This commit was generated by cvs2svn to compensate for changes in r12991, 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;
320unlink("/tmp/not_a_directory");
321fd = open("/tmp/not_a_directory", O_WRONLY|O_CREAT, 0666);
322write(fd, "\n", 1);
323close(fd);
324dir = opendir("/tmp/not_a_directory");
325unlink("/tmp/not_a_directory");
326exit (dir == 0);
327}], bash_cv_opendir_not_robust=yes,bash_cv_opendir_not_robust=no,
328    [AC_MSG_WARN(cannot check opendir if cross compiling -- defaulting to no)
329     bash_cv_opendir_not_robust=no]
330)])
331AC_MSG_RESULT($bash_cv_opendir_not_robust)
332if test $bash_cv_opendir_not_robust = yes; then
333AC_DEFINE(OPENDIR_NOT_ROBUST)
334fi
335])
336
337dnl
338AC_DEFUN(BASH_TYPE_SIGHANDLER,
339[AC_MSG_CHECKING([whether signal handlers are of type void])
340AC_CACHE_VAL(bash_cv_void_sighandler,
341[AC_TRY_COMPILE([#include <sys/types.h>
342#include <signal.h>
343#ifdef signal
344#undef signal
345#endif
346#ifdef __cplusplus
347extern "C"
348#endif
349void (*signal ()) ();],
350[int i;], bash_cv_void_sighandler=yes, bash_cv_void_sighandler=no)])dnl
351AC_MSG_RESULT($bash_cv_void_sighandler)
352if test $bash_cv_void_sighandler = yes; then
353AC_DEFINE(VOID_SIGHANDLER)
354fi
355])
356
357AC_DEFUN(BASH_TYPE_INT32_T,
358[
359if test "$ac_cv_sizeof_int" = 4; then
360  AC_CHECK_TYPE(int32_t, int)
361elif test "$ac_cv_sizeof_long" = 4; then
362  AC_CHECK_TYPE(int32_t, long)
363else
364  AC_CHECK_TYPE(int32_t, int)
365fi
366])
367
368AC_DEFUN(BASH_TYPE_U_INT32_T,
369[
370if test "$ac_cv_sizeof_int" = 4; then
371  AC_CHECK_TYPE(u_int32_t, unsigned int)
372elif test "$ac_cv_sizeof_long" = 4; then
373  AC_CHECK_TYPE(u_int32_t, unsigned long)
374else
375  AC_CHECK_TYPE(u_int32_t, unsigned int)
376fi
377])
378
379AC_DEFUN(BASH_TYPE_PTRDIFF_T,
380[
381if test "$ac_cv_sizeof_int" = "$ac_cv_sizeof_char_p"; then
382  AC_CHECK_TYPE(ptrdiff_t, int)
383elif test "$ac_cv_sizeof_long" = "$ac_cv_sizeof_char_p"; then
384  AC_CHECK_TYPE(ptrdiff_t, long)
385else
386  AC_CHECK_TYPE(ptrdiff_t, int)
387fi
388])
389
390AC_DEFUN(BASH_TYPE_BITS64_T,
391[
392if test "$ac_sv_sizeof_char_p" = 8; then
393  AC_CHECK_TYPE(bits64_t, char *)
394elif test "$ac_cv_sizeof_double" = 8; then
395  AC_CHECK_TYPE(bits64_t, double)
396elif test "$ac_cv_sizeof_long" = 8; then
397  AC_CHECK_TYPE(bits64_t, long)
398else
399  AC_CHECK_TYPE(bits64_t, double)
400fi
401])
402
403AC_DEFUN(BASH_FUNC_STRSIGNAL,
404[AC_MSG_CHECKING([for the existence of strsignal])
405AC_CACHE_VAL(bash_cv_have_strsignal,
406[AC_TRY_LINK([#include <sys/types.h>
407#include <signal.h>],
408[char *s = (char *)strsignal(2);],
409 bash_cv_have_strsignal=yes, bash_cv_have_strsignal=no)])
410AC_MSG_RESULT($bash_cv_have_strsignal)
411if test $bash_cv_have_strsignal = yes; then
412AC_DEFINE(HAVE_STRSIGNAL)
413fi
414])
415
416AC_DEFUN(BASH_FUNC_LSTAT,
417[dnl Cannot use AC_CHECK_FUNCS(lstat) because Linux defines lstat() as an
418dnl inline function in <sys/stat.h>.
419AC_CACHE_CHECK([for lstat], bash_cv_func_lstat,
420[AC_TRY_LINK([
421#include <sys/types.h>
422#include <sys/stat.h>
423],[ lstat(".",(struct stat *)0); ],
424bash_cv_func_lstat=yes, bash_cv_func_lstat=no)])
425if test $bash_cv_func_lstat = yes; then
426  AC_DEFINE(HAVE_LSTAT)
427fi
428])
429
430AC_DEFUN(BASH_STRUCT_TERMIOS_LDISC,
431[AC_MSG_CHECKING([for a c_line member of struct termios])
432AC_CACHE_VAL(bash_cv_termios_ldisc,
433[AC_TRY_COMPILE([#include <sys/types.h>
434#include <termios.h>],[struct termios t; int i; i = t.c_line;],
435  bash_cv_termios_ldisc=yes, bash_cv_termios_ldisc=no)])dnl
436AC_MSG_RESULT($bash_cv_termios_ldisc)
437if test $bash_cv_termios_ldisc = yes; then
438AC_DEFINE(TERMIOS_LDISC)
439fi
440])
441
442AC_DEFUN(BASH_STRUCT_TERMIO_LDISC,
443[AC_MSG_CHECKING([for a c_line member of struct termio])
444AC_CACHE_VAL(bash_cv_termio_ldisc,
445[AC_TRY_COMPILE([#include <sys/types.h>
446#include <termio.h>],[struct termio t; int i; i = t.c_line;],
447  bash_cv_termio_ldisc=yes, bash_cv_termio_ldisc=no)])dnl
448AC_MSG_RESULT($bash_cv_termio_ldisc)
449if test $bash_cv_termio_ldisc = yes; then
450AC_DEFINE(TERMIO_LDISC)
451fi
452])
453
454AC_DEFUN(BASH_FUNC_GETENV,
455[AC_MSG_CHECKING(to see if getenv can be redefined)
456AC_CACHE_VAL(bash_cv_getenv_redef,
457[AC_TRY_RUN([
458#ifdef HAVE_UNISTD_H
459#  include <unistd.h>
460#endif
461#ifndef __STDC__
462#  ifndef const
463#    define const
464#  endif
465#endif
466char *
467getenv (name)
468#if defined (__linux__) || defined (__bsdi__) || defined (convex)
469     const char *name;
470#else
471     char const *name;
472#endif /* !__linux__ && !__bsdi__ && !convex */
473{
474return "42";
475}
476main()
477{
478char *s;
479/* The next allows this program to run, but does not allow bash to link
480   when it redefines getenv.  I'm not really interested in figuring out
481   why not. */
482#if defined (NeXT)
483exit(1);
484#endif
485s = getenv("ABCDE");
486exit(s == 0);   /* force optimizer to leave getenv in */
487}
488], bash_cv_getenv_redef=yes, bash_cv_getenv_redef=no,
489   [AC_MSG_WARN(cannot check getenv redefinition if cross compiling -- defaulting to yes)
490    bash_cv_getenv_redef=yes]
491)])
492AC_MSG_RESULT($bash_cv_getenv_redef)
493if test $bash_cv_getenv_redef = yes; then
494AC_DEFINE(CAN_REDEFINE_GETENV)
495fi
496])
497
498AC_DEFUN(BASH_FUNC_PRINTF,
499[AC_MSG_CHECKING(for declaration of printf in <stdio.h>)
500AC_CACHE_VAL(bash_cv_printf_declared,
501[AC_TRY_RUN([
502#include <stdio.h>
503#ifdef __STDC__
504typedef int (*_bashfunc)(const char *, ...);
505#else
506typedef int (*_bashfunc)();
507#endif
508main()
509{
510_bashfunc pf;
511pf = (_bashfunc) printf;
512exit(pf == 0);
513}
514], bash_cv_printf_declared=yes, bash_cv_printf_declared=no,
515   [AC_MSG_WARN(cannot check printf declaration if cross compiling -- defaulting to yes)
516    bash_cv_printf_declared=yes]
517)])
518AC_MSG_RESULT($bash_cv_printf_declared)
519if test $bash_cv_printf_declared = yes; then
520AC_DEFINE(PRINTF_DECLARED)
521fi
522])
523
524AC_DEFUN(BASH_FUNC_ULIMIT_MAXFDS,
525[AC_MSG_CHECKING(whether ulimit can substitute for getdtablesize)
526AC_CACHE_VAL(bash_cv_ulimit_maxfds,
527[AC_TRY_RUN([
528main()
529{
530long maxfds = ulimit(4, 0L);
531exit (maxfds == -1L);
532}
533], bash_cv_ulimit_maxfds=yes, bash_cv_ulimit_maxfds=no,
534   [AC_MSG_WARN(cannot check ulimit if cross compiling -- defaulting to no)
535    bash_cv_ulimit_maxfds=no]
536)])
537AC_MSG_RESULT($bash_cv_ulimit_maxfds)
538if test $bash_cv_ulimit_maxfds = yes; then
539AC_DEFINE(ULIMIT_MAXFDS)
540fi
541])
542
543AC_DEFUN(BASH_CHECK_LIB_TERMCAP,
544[
545if test "X$bash_cv_termcap_lib" = "X"; then
546_bash_needmsg=yes
547else
548AC_MSG_CHECKING(which library has the termcap functions)
549_bash_needmsg=
550fi
551AC_CACHE_VAL(bash_cv_termcap_lib,
552[AC_CHECK_LIB(termcap, tgetent, bash_cv_termcap_lib=libtermcap,
553    [AC_CHECK_LIB(curses, tgetent, bash_cv_termcap_lib=libcurses,
554        [AC_CHECK_LIB(ncurses, tgetent, bash_cv_termcap_lib=libncurses,
555            bash_cv_termcap_lib=gnutermcap)])])])
556if test "X$_bash_needmsg" = "Xyes"; then
557AC_MSG_CHECKING(which library has the termcap functions)
558fi
559AC_MSG_RESULT(using $bash_cv_termcap_lib)
560if test $bash_cv_termcap_lib = gnutermcap && test -z "$prefer_curses"; then
561LDFLAGS="$LDFLAGS -L./lib/termcap"
562TERMCAP_LIB="./lib/termcap/libtermcap.a"
563TERMCAP_DEP="./lib/termcap/libtermcap.a"
564elif test $bash_cv_termcap_lib = libtermcap && test -z "$prefer_curses"; then
565TERMCAP_LIB=-ltermcap
566TERMCAP_DEP=
567elif test $bash_cv_termcap_lib = libncurses; then
568TERMCAP_LIB=-lncurses
569TERMCAP_DEP=
570else
571TERMCAP_LIB=-lcurses
572TERMCAP_DEP=
573fi
574])
575
576AC_DEFUN(BASH_FUNC_GETCWD,
577[AC_MSG_CHECKING([if getcwd() calls popen()])
578AC_CACHE_VAL(bash_cv_getcwd_calls_popen,
579[AC_TRY_RUN([
580#include <stdio.h>
581#ifdef HAVE_UNISTD_H
582#include <unistd.h>
583#endif
584
585#ifndef __STDC__
586#ifndef const
587#define const
588#endif
589#endif
590
591int popen_called;
592
593FILE *
594popen(command, type)
595     const char *command;
596     const char *type;
597{
598        popen_called = 1;
599        return (FILE *)NULL;
600}
601
602FILE *_popen(command, type)
603     const char *command;
604     const char *type;
605{
606  return (popen (command, type));
607}
608
609int
610pclose(stream)
611FILE *stream;
612{
613        return 0;
614}
615
616int
617_pclose(stream)
618FILE *stream;
619{
620        return 0;
621}
622
623main()
624{
625        char    lbuf[32];
626        popen_called = 0;
627        getcwd(lbuf, 32);
628        exit (popen_called);
629}
630], bash_cv_getcwd_calls_popen=no, bash_cv_getcwd_calls_popen=yes,
631   [AC_MSG_WARN(cannot check whether getcwd calls popen if cross compiling -- defaulting to no)
632    bash_cv_getcwd_calls_popen=no]
633)])
634AC_MSG_RESULT($bash_cv_getcwd_calls_popen)
635if test $bash_cv_getcwd_calls_popen = yes; then
636AC_DEFINE(GETCWD_BROKEN)
637fi
638])
639
640AC_DEFUN(BASH_STRUCT_DIRENT_D_INO,
641[AC_REQUIRE([AC_HEADER_DIRENT])
642AC_MSG_CHECKING(if struct dirent has a d_ino member)
643AC_CACHE_VAL(bash_cv_dirent_has_dino,
644[AC_TRY_COMPILE([
645#include <stdio.h>
646#include <sys/types.h>
647#ifdef HAVE_UNISTD_H
648# include <unistd.h>
649#endif /* HAVE_UNISTD_H */
650#if defined(HAVE_DIRENT_H)
651# include <dirent.h>
652#else
653# define dirent direct
654# ifdef HAVE_SYS_NDIR_H
655#  include <sys/ndir.h>
656# endif /* SYSNDIR */
657# ifdef HAVE_SYS_DIR_H
658#  include <sys/dir.h>
659# endif /* SYSDIR */
660# ifdef HAVE_NDIR_H
661#  include <ndir.h>
662# endif
663#endif /* HAVE_DIRENT_H */
664],[
665struct dirent d; int z; z = d.d_ino;
666], bash_cv_dirent_has_dino=yes, bash_cv_dirent_has_dino=no)])
667AC_MSG_RESULT($bash_cv_dirent_has_dino)
668if test $bash_cv_dirent_has_dino = yes; then
669AC_DEFINE(STRUCT_DIRENT_HAS_D_INO)
670fi
671])
672
673AC_DEFUN(BASH_STRUCT_DIRENT_D_FILENO,
674[AC_REQUIRE([AC_HEADER_DIRENT])
675AC_MSG_CHECKING(if struct dirent has a d_fileno member)
676AC_CACHE_VAL(bash_cv_dirent_has_d_fileno,
677[AC_TRY_COMPILE([
678#include <stdio.h>
679#include <sys/types.h>
680#ifdef HAVE_UNISTD_H
681# include <unistd.h>
682#endif /* HAVE_UNISTD_H */
683#if defined(HAVE_DIRENT_H)
684# include <dirent.h>
685#else
686# define dirent direct
687# ifdef HAVE_SYS_NDIR_H
688#  include <sys/ndir.h>
689# endif /* SYSNDIR */
690# ifdef HAVE_SYS_DIR_H
691#  include <sys/dir.h>
692# endif /* SYSDIR */
693# ifdef HAVE_NDIR_H
694#  include <ndir.h>
695# endif
696#endif /* HAVE_DIRENT_H */
697],[
698struct dirent d; int z; z = d.d_fileno;
699], bash_cv_dirent_has_d_fileno=yes, bash_cv_dirent_has_d_fileno=no)])
700AC_MSG_RESULT($bash_cv_dirent_has_d_fileno)
701if test $bash_cv_dirent_has_d_fileno = yes; then
702AC_DEFINE(STRUCT_DIRENT_HAS_D_FILENO)
703fi
704])
705
706AC_DEFUN(BASH_REINSTALL_SIGHANDLERS,
707[AC_REQUIRE([AC_TYPE_SIGNAL])
708AC_REQUIRE([BASH_SIGNAL_CHECK])
709AC_MSG_CHECKING([if signal handlers must be reinstalled when invoked])
710AC_CACHE_VAL(bash_cv_must_reinstall_sighandlers,
711[AC_TRY_RUN([
712#include <signal.h>
713#ifdef HAVE_UNISTD_H
714#include <unistd.h>
715#endif
716
717typedef RETSIGTYPE sigfunc();
718
719int nsigint;
720
721#ifdef HAVE_POSIX_SIGNALS
722sigfunc *
723set_signal_handler(sig, handler)
724     int sig;
725     sigfunc *handler;
726{
727  struct sigaction act, oact;
728  act.sa_handler = handler;
729  act.sa_flags = 0;
730  sigemptyset (&act.sa_mask);
731  sigemptyset (&oact.sa_mask);
732  sigaction (sig, &act, &oact);
733  return (oact.sa_handler);
734}
735#else
736#define set_signal_handler(s, h) signal(s, h)
737#endif
738
739RETSIGTYPE
740sigint(s)
741int s;
742{
743  nsigint++;
744}
745
746main()
747{
748        nsigint = 0;
749        set_signal_handler(SIGINT, sigint);
750        kill((int)getpid(), SIGINT);
751        kill((int)getpid(), SIGINT);
752        exit(nsigint != 2);
753}
754], bash_cv_must_reinstall_sighandlers=no, bash_cv_must_reinstall_sighandlers=yes,
755   [AC_MSG_WARN(cannot check signal handling if cross compiling -- defaulting to no)
756    bash_cv_must_reinstall_sighandlers=no]
757)])
758AC_MSG_RESULT($bash_cv_must_reinstall_sighandlers)
759if test $bash_cv_must_reinstall_sighandlers = yes; then
760AC_DEFINE(MUST_REINSTALL_SIGHANDLERS)
761fi
762])
763
764AC_DEFUN(BASH_FUNC_SBRK_DECLARED,
765[AC_MSG_CHECKING(for declaration of sbrk in <unistd.h>)
766AC_CACHE_VAL(bash_cv_sbrk_declared,
767[AC_EGREP_HEADER(sbrk, unistd.h,
768 bash_cv_sbrk_declared=yes, bash_cv_sbrk_declared=no)])
769AC_MSG_RESULT($bash_cv_sbrk_declared)
770if test $bash_cv_sbrk_declared = yes; then
771AC_DEFINE(SBRK_DECLARED)
772fi
773])
774
775dnl check that some necessary job control definitions are present
776AC_DEFUN(BASH_JOB_CONTROL_MISSING,
777[AC_REQUIRE([BASH_SIGNAL_CHECK])
778AC_MSG_CHECKING(for presence of necessary job control definitions)
779AC_CACHE_VAL(bash_cv_job_control_missing,
780[AC_TRY_RUN([
781#include <sys/types.h>
782#ifdef HAVE_SYS_WAIT_H
783#include <sys/wait.h>
784#endif
785#ifdef HAVE_UNISTD_H
786#include <unistd.h>
787#endif
788#include <signal.h>
789
790/* Add more tests in here as appropriate. */
791main()
792{
793/* signal type */
794#if !defined (HAVE_POSIX_SIGNALS) && !defined (HAVE_BSD_SIGNALS)
795exit(1);
796#endif
797
798/* signals and tty control. */
799#if !defined (SIGTSTP) || !defined (SIGSTOP) || !defined (SIGCONT)
800exit (1);
801#endif
802
803/* process control */
804#if !defined (WNOHANG) || !defined (WUNTRACED)
805exit(1);
806#endif
807
808/* Posix systems have tcgetpgrp and waitpid. */
809#if defined (_POSIX_VERSION) && !defined (HAVE_TCGETPGRP)
810exit(1);
811#endif
812
813#if defined (_POSIX_VERSION) && !defined (HAVE_WAITPID)
814exit(1);
815#endif
816
817/* Other systems have TIOCSPGRP/TIOCGPRGP and wait3. */
818#if !defined (_POSIX_VERSION) && !defined (HAVE_WAIT3)
819exit(1);
820#endif
821
822exit(0);
823}], bash_cv_job_control_missing=present, bash_cv_job_control_missing=missing,
824    [AC_MSG_WARN(cannot check job control if cross-compiling -- defaulting to missing)
825     bash_cv_job_control_missing=missing]
826)])
827AC_MSG_RESULT($bash_cv_job_control_missing)
828if test $bash_cv_job_control_missing = missing; then
829AC_DEFINE(JOB_CONTROL_MISSING)
830fi
831])
832
833dnl check whether named pipes are present
834dnl this requires a previous check for mkfifo, but that is awkward to specify
835AC_DEFUN(BASH_SYS_NAMED_PIPES,
836[AC_MSG_CHECKING(for presence of named pipes)
837AC_CACHE_VAL(bash_cv_sys_named_pipes,
838[AC_TRY_RUN([
839#include <sys/types.h>
840#include <sys/stat.h>
841#ifdef HAVE_UNISTD_H
842#include <unistd.h>
843#endif
844
845/* Add more tests in here as appropriate. */
846main()
847{
848int fd;
849
850#if defined (HAVE_MKFIFO)
851exit (0);
852#endif
853
854#if !defined (S_IFIFO) && (defined (_POSIX_VERSION) && !defined (S_ISFIFO))
855exit (1);
856#endif
857
858#if defined (NeXT)
859exit (1);
860#endif
861
862fd = mknod ("/tmp/sh-np-autoconf", 0666 | S_IFIFO, 0);
863if (fd == -1)
864  exit (1);
865close(fd);
866unlink ("/tmp/sh-np-autoconf");
867exit(0);
868}], bash_cv_sys_named_pipes=present, bash_cv_sys_named_pipes=missing,
869    [AC_MSG_WARN(cannot check for named pipes if cross-compiling -- defaulting to missing)
870     bash_cv_sys_named_pipes=missing]
871)])
872AC_MSG_RESULT($bash_cv_sys_named_pipes)
873if test $bash_cv_sys_named_pipes = missing; then
874AC_DEFINE(NAMED_PIPES_MISSING)
875fi
876])
877
878AC_DEFUN(BASH_FUNC_POSIX_SETJMP,
879[AC_REQUIRE([BASH_SIGNAL_CHECK])
880AC_MSG_CHECKING(for presence of POSIX-style sigsetjmp/siglongjmp)
881AC_CACHE_VAL(bash_cv_func_sigsetjmp,
882[AC_TRY_RUN([
883#ifdef HAVE_UNISTD_H
884#include <unistd.h>
885#endif
886#include <sys/types.h>
887#include <signal.h>
888#include <setjmp.h>
889
890main()
891{
892#if !defined (_POSIX_VERSION) || !defined (HAVE_POSIX_SIGNALS)
893exit (1);
894#else
895
896int code;
897sigset_t set, oset;
898sigjmp_buf xx;
899
900/* get the mask */
901sigemptyset(&set);
902sigemptyset(&oset);
903sigprocmask(SIG_BLOCK, (sigset_t *)NULL, &set);
904sigprocmask(SIG_BLOCK, (sigset_t *)NULL, &oset);
905
906/* save it */
907code = sigsetjmp(xx, 1);
908if (code)
909  exit(0);      /* could get sigmask and compare to oset here. */
910
911/* change it */
912sigaddset(&set, SIGINT);
913sigprocmask(SIG_BLOCK, &set, (sigset_t *)NULL);
914
915/* and siglongjmp */
916siglongjmp(xx, 10);
917exit(1);
918#endif
919}], bash_cv_func_sigsetjmp=present, bash_cv_func_sigsetjmp=missing,
920    [AC_MSG_WARN(cannot check for sigsetjmp/siglongjmp if cross-compiling -- defaulting to missing)
921     bash_cv_func_sigsetjmp=missing]
922)])
923AC_MSG_RESULT($bash_cv_func_sigsetjmp)
924if test $bash_cv_func_sigsetjmp = present; then
925AC_DEFINE(HAVE_POSIX_SIGSETJMP)
926fi
927])
928
929AC_DEFUN(BASH_HAVE_TIOCGWINSZ,
930[AC_MSG_CHECKING(for TIOCGWINSZ in sys/ioctl.h)
931AC_CACHE_VAL(bash_cv_tiocgwinsz_in_ioctl,
932[AC_TRY_COMPILE([#include <sys/types.h>
933#include <sys/ioctl.h>], [int x = TIOCGWINSZ;],
934  bash_cv_tiocgwinsz_in_ioctl=yes,bash_cv_tiocgwinsz_in_ioctl=no)])
935AC_MSG_RESULT($bash_cv_tiocgwinsz_in_ioctl)
936if test $bash_cv_tiocgwinsz_in_ioctl = yes; then   
937AC_DEFINE(GWINSZ_IN_SYS_IOCTL)
938fi
939])
940
941AC_DEFUN(BASH_STRUCT_WINSIZE,
942[AC_MSG_CHECKING(for struct winsize in sys/ioctl.h and termios.h)
943AC_CACHE_VAL(bash_cv_struct_winsize_header,
944[AC_TRY_COMPILE([#include <sys/types.h>
945#include <sys/ioctl.h>], [struct winsize x;],
946  bash_cv_struct_winsize_header=ioctl_h,
947  [AC_TRY_COMPILE([#include <sys/types.h>
948#include <termios.h>], [struct winsize x;],
949  bash_cv_struct_winsize_header=termios_h, bash_cv_struct_winsize_header=other)
950])])
951if test $bash_cv_struct_winsize_header = ioctl_h; then
952  AC_MSG_RESULT(sys/ioctl.h)
953  AC_DEFINE(STRUCT_WINSIZE_IN_SYS_IOCTL)
954elif test $bash_cv_struct_winsize_header = termios_h; then
955  AC_MSG_RESULT(termios.h)
956  AC_DEFINE(STRUCT_WINSIZE_IN_TERMIOS)
957else
958  AC_MSG_RESULT(not found)
959fi
960])
961
962AC_DEFUN(BASH_HAVE_TIOCSTAT,
963[AC_MSG_CHECKING(for TIOCSTAT in sys/ioctl.h)
964AC_CACHE_VAL(bash_cv_tiocstat_in_ioctl,
965[AC_TRY_COMPILE([#include <sys/types.h>
966#include <sys/ioctl.h>], [int x = TIOCSTAT;],
967  bash_cv_tiocstat_in_ioctl=yes,bash_cv_tiocstat_in_ioctl=no)])
968AC_MSG_RESULT($bash_cv_tiocstat_in_ioctl)
969if test $bash_cv_tiocstat_in_ioctl = yes; then   
970AC_DEFINE(TIOCSTAT_IN_SYS_IOCTL)
971fi
972])
973
974AC_DEFUN(BASH_HAVE_FIONREAD,
975[AC_MSG_CHECKING(for FIONREAD in sys/ioctl.h)
976AC_CACHE_VAL(bash_cv_fionread_in_ioctl,
977[AC_TRY_COMPILE([#include <sys/types.h>
978#include <sys/ioctl.h>], [int x = FIONREAD;],
979  bash_cv_fionread_in_ioctl=yes,bash_cv_fionread_in_ioctl=no)])
980AC_MSG_RESULT($bash_cv_fionread_in_ioctl)
981if test $bash_cv_fionread_in_ioctl = yes; then   
982AC_DEFINE(FIONREAD_IN_SYS_IOCTL)
983fi
984])
985
986dnl
987dnl See if speed_t is declared in <sys/types.h>.  Some versions of linux
988dnl require a definition of speed_t each time <termcap.h> is included,
989dnl but you can only get speed_t if you include <termios.h> (on some
990dnl versions) or <sys/types.h> (on others).
991dnl
992AC_DEFUN(BASH_MISC_SPEED_T,
993[AC_MSG_CHECKING(for speed_t in sys/types.h)
994AC_CACHE_VAL(bash_cv_speed_t_in_sys_types,
995[AC_TRY_COMPILE([#include <sys/types.h>], [speed_t x;],
996  bash_cv_speed_t_in_sys_types=yes,bash_cv_speed_t_in_sys_types=no)])
997AC_MSG_RESULT($bash_cv_speed_t_in_sys_types)
998if test $bash_cv_speed_t_in_sys_types = yes; then   
999AC_DEFINE(SPEED_T_IN_SYS_TYPES)
1000fi
1001])
1002
1003AC_DEFUN(BASH_CHECK_GETPW_FUNCS,
1004[AC_MSG_CHECKING(whether programs are able to redeclare getpw functions)
1005AC_CACHE_VAL(bash_cv_can_redecl_getpw,
1006[AC_TRY_COMPILE([#include <sys/types.h>
1007#include <pwd.h>
1008extern struct passwd *getpwent();
1009extern struct passwd *getpwuid();
1010extern struct passwd *getpwnam();],
1011[struct passwd *z; z = getpwent(); z = getpwuid(0); z = getpwnam("root");],
1012  bash_cv_can_redecl_getpw=yes,bash_cv_can_redecl_getpw=no)])
1013AC_MSG_RESULT($bash_cv_can_redecl_getpw)
1014if test $bash_cv_can_redecl_getpw = no; then
1015AC_DEFINE(HAVE_GETPW_DECLS)
1016fi
1017])
1018
1019AC_DEFUN(BASH_CHECK_DEV_FD,
1020[AC_MSG_CHECKING(whether /dev/fd is available)
1021AC_CACHE_VAL(bash_cv_dev_fd,
1022[if test -d /dev/fd  && test -r /dev/fd/0; then
1023   bash_cv_dev_fd=standard
1024 elif test -d /proc/self/fd && test -r /proc/self/fd/0; then
1025   bash_cv_dev_fd=whacky
1026 else
1027   bash_cv_dev_fd=absent
1028 fi
1029])
1030AC_MSG_RESULT($bash_cv_dev_fd)
1031if test $bash_cv_dev_fd = "standard"; then
1032  AC_DEFINE(HAVE_DEV_FD)
1033  AC_DEFINE(DEV_FD_PREFIX, "/dev/fd/")
1034elif test $bash_cv_dev_fd = "whacky"; then
1035  AC_DEFINE(HAVE_DEV_FD)
1036  AC_DEFINE(DEV_FD_PREFIX, "/proc/self/fd/")
1037fi
1038])
1039
1040dnl
1041dnl Check for the presence of getpeername (the only networking function
1042dnl bash currently requires) in libsocket.  If libsocket is present,
1043dnl check for libnsl and add it to LIBS if it's there, since most
1044dnl systems with libsocket require linking with libnsl as well.
1045dnl This should only be called if getpeername was not found in libc.
1046dnl
1047AC_DEFUN(BASH_CHECK_SOCKLIB,
1048[
1049if test "X$bash_cv_have_socklib" = "X"; then
1050_bash_needmsg=
1051else
1052AC_MSG_CHECKING(for socket library)
1053_bash_needmsg=yes
1054fi
1055AC_CACHE_VAL(bash_cv_have_socklib,
1056[AC_CHECK_LIB(socket, getpeername,
1057        bash_cv_have_socklib=yes, bash_cv_have_socklib=no, -lnsl)])
1058if test "X$_bash_needmsg" = Xyes; then
1059  AC_MSG_RESULT($bash_cv_have_socklib)
1060  _bash_needmsg=
1061fi
1062if test $bash_cv_have_socklib = yes; then
1063  # check for libnsl, add it to LIBS if present
1064  if test "X$bash_cv_have_libnsl" = "X"; then
1065    _bash_needmsg=
1066  else
1067    AC_MSG_CHECKING(for libnsl)
1068    _bash_needmsg=yes
1069  fi
1070  AC_CACHE_VAL(bash_cv_have_libnsl,
1071           [AC_CHECK_LIB(nsl, t_open,
1072                 bash_cv_have_libnsl=yes, bash_cv_have_libnsl=no)])
1073  if test "X$_bash_needmsg" = Xyes; then
1074    AC_MSG_RESULT($bash_cv_have_libnsl)
1075    _bash_needmsg=
1076  fi
1077  if test $bash_cv_have_libnsl = yes; then
1078    LIBS="-lsocket -lnsl $LIBS"
1079  else
1080    LIBS="-lsocket $LIBS"
1081  fi
1082  AC_DEFINE(HAVE_LIBSOCKET)
1083  AC_DEFINE(HAVE_GETPEERNAME)
1084fi
1085])
1086
1087AC_DEFUN(BASH_DEFAULT_MAIL_DIR,
1088[AC_MSG_CHECKING(for default mail directory)
1089AC_CACHE_VAL(bash_cv_mail_dir,
1090[if test -d /var/mail; then
1091   bash_cv_mail_dir=/var/mail
1092 elif test -d /usr/mail; then
1093   bash_cv_mail_dir=/usr/mail
1094 elif test -d /var/spool/mail; then
1095   bash_cv_mail_dir=/var/spool/mail
1096 elif test -d /usr/spool/mail; then
1097   bash_cv_mail_dir=/usr/spool/mail
1098 else
1099   bash_cv_mail_dir=unknown
1100 fi
1101])
1102AC_MSG_RESULT($bash_cv_mail_dir)
1103if test $bash_cv_mail_dir = "/var/mail"; then
1104   AC_DEFINE(DEFAULT_MAIL_DIRECTORY, "/var/mail")
1105elif test $bash_cv_mail_dir = "/usr/mail"; then
1106   AC_DEFINE(DEFAULT_MAIL_DIRECTORY, "/usr/mail")
1107elif test $bash_cv_mail_dir = "/var/spool/mail"; then
1108   AC_DEFINE(DEFAULT_MAIL_DIRECTORY, "/var/spool/mail")
1109elif test $bash_cv_mail_dir = "/usr/spool/mail"; then
1110   AC_DEFINE(DEFAULT_MAIL_DIRECTORY, "/usr/spool/mail")
1111else
1112   AC_DEFINE(DEFAULT_MAIL_DIRECTORY, "unknown")
1113fi
1114])
1115
1116dnl
1117dnl Check if HPUX needs _KERNEL defined for RLIMIT_* definitions
1118dnl
1119AC_DEFUN(BASH_KERNEL_RLIMIT_CHECK,
1120[AC_MSG_CHECKING([whether $host_os needs _KERNEL for RLIMIT defines])
1121AC_CACHE_VAL(bash_cv_kernel_rlimit,
1122[AC_TRY_COMPILE([
1123#include <sys/types.h>
1124#include <sys/resource.h>
1125],
1126[
1127  int f;
1128  f = RLIMIT_DATA;
1129], bash_cv_kernel_rlimit=no,
1130[AC_TRY_COMPILE([
1131#include <sys/types.h>
1132#define _KERNEL
1133#include <sys/resource.h>
1134#undef _KERNEL
1135],
1136[
1137        int f;
1138        f = RLIMIT_DATA;
1139], bash_cv_kernel_rlimit=yes, bash_cv_kernel_rlimit=no)]
1140)])
1141AC_MSG_RESULT($bash_cv_kernel_rlimit)
1142if test $bash_cv_kernel_rlimit = yes; then
1143AC_DEFINE(RLIMIT_NEEDS_KERNEL)
1144fi
1145])
1146
1147AC_DEFUN(BASH_FUNC_STRCOLL,
1148[
1149AC_MSG_CHECKING(whether or not strcoll and strcmp differ)
1150AC_CACHE_VAL(bash_cv_func_strcoll_broken,
1151[AC_TRY_RUN([
1152#include <stdio.h>
1153#if defined (HAVE_LOCALE_H)
1154#include <locale.h>
1155#endif
1156
1157main(c, v)
1158int     c;
1159char    *v[];
1160{
1161        int     r1, r2;
1162        char    *deflocale, *defcoll;
1163
1164#ifdef HAVE_SETLOCALE
1165        deflocale = setlocale(LC_ALL, "");
1166        defcoll = setlocale(LC_COLLATE, "");
1167#endif
1168
1169#ifdef HAVE_STRCOLL
1170        /* These two values are taken from tests/glob-test. */
1171        r1 = strcoll("abd", "aXd");
1172#else
1173        r1 = 0;
1174#endif
1175        r2 = strcmp("abd", "aXd");
1176
1177        /* These two should both be greater than 0.  It is permissible for
1178           a system to return different values, as long as the sign is the
1179           same. */
1180
1181        /* Exit with 1 (failure) if these two values are both > 0, since
1182           this tests whether strcoll(3) is broken with respect to strcmp(3)
1183           in the default locale. */
1184        exit (r1 > 0 && r2 > 0);
1185}
1186], bash_cv_func_strcoll_broken=yes, bash_cv_func_strcoll_broken=no,
1187   [AC_MSG_WARN(cannot check strcoll if cross compiling -- defaulting to no)
1188    bash_cv_func_strcoll_broken=no]
1189)])
1190AC_MSG_RESULT($bash_cv_func_strcoll_broken)
1191if test $bash_cv_func_strcoll_broken = yes; then
1192AC_DEFINE(STRCOLL_BROKEN)
1193fi
1194])
1195
1196dnl
1197dnl If available, use support for large files unless the user specified
1198dnl one of the CPPFLAGS, LDFLAGS, or LIBS variables (<eggert@twinsun.com>
1199dnl via GNU patch 2.5)
1200dnl
1201AC_DEFUN(BASH_LARGE_FILE_SUPPORT,
1202[AC_MSG_CHECKING(whether large file support needs explicit enabling)
1203ac_getconfs=''
1204ac_result=yes
1205ac_set=''
1206ac_shellvars='CPPFLAGS LDFLAGS LIBS'
1207for ac_shellvar in $ac_shellvars; do
1208  case $ac_shellvar in
1209  CPPFLAGS) ac_lfsvar=LFS_CFLAGS ac_lfs64var=LFS64_CFLAGS ;;
1210  *) ac_lfsvar=LFS_$ac_shellvar ac_lfs64var=LFS64_$ac_shellvar ;;
1211  esac
1212  eval test '"${'$ac_shellvar'+set}"' = set && ac_set=$ac_shellvar
1213  (getconf $ac_lfsvar) >/dev/null 2>&1 || { ac_result=no; break; }
1214  ac_getconf=`getconf $ac_lfsvar`
1215  ac_getconf64=`getconf $ac_lfs64var`
1216  ac_getconfs=$ac_getconfs$ac_getconf\ $ac_getconf64
1217  eval ac_test_$ac_shellvar="\$ac_getconf\ \$ac_getconf64"
1218done
1219case "$ac_result$ac_getconfs" in
1220yes) ac_result=no ;;
1221esac
1222case "$ac_result$ac_set" in
1223yes?*) ac_result="yes, but $ac_set is already set, so use its settings"
1224esac
1225AC_MSG_RESULT($ac_result)
1226case $ac_result in
1227yes)
1228  for ac_shellvar in $ac_shellvars; do
1229    eval $ac_shellvar=\$ac_test_$ac_shellvar
1230  done ;;
1231esac
1232])
1233
1234dnl
1235dnl AC_SYS_RESTARTABLE_SYSCALLS tests only for restarted system calls
1236dnl after a signal handler has been installed with signal().  Since
1237dnl Bash uses sigaction() if it is available, we need to check whether
1238dnl or not a signal handler installed with sigaction and SA_RESTART
1239dnl causes system calls to be restarted after the signal is caught
1240dnl
1241AC_DEFUN(BASH_SYS_RESTARTABLE_SYSCALLS,
1242[AC_REQUIRE([BASH_SIGNAL_CHECK])
1243AC_CACHE_CHECK(for restartable system calls with posix sigaction,
1244bash_cv_sys_restartable_syscalls,
1245[AC_TRY_RUN(
1246[/* Exit 0 (true) if wait returns something other than -1,
1247   i.e. the pid of the child, which means that wait was restarted
1248   after getting the signal.  */
1249#include <sys/types.h>
1250#include <signal.h>
1251static int caught = 0;
1252void ucatch (isig) int isig; { caught = 1; }
1253main ()
1254{
1255#if !defined (_POSIX_VERSION) || !defined (HAVE_POSIX_SIGNALS)
1256  exit (1);
1257#else
1258  struct sigaction act, oact;
1259  int i, status;
1260
1261  act.sa_handler = ucatch;
1262  /* Might want to add SA_RESTART here, but bash's set_signal_handler
1263     does not. */
1264  act.sa_flags = 0;
1265  sigemptyset(&act.sa_mask);
1266  sigemptyset(&oact.sa_mask);
1267  i = fork ();
1268  /* A possible race condition here, but in practice it never happens. */
1269  if (i == 0) { sleep (3); kill (getppid (), SIGINT); sleep (3); exit (0); }
1270  sigaction(SIGINT, &act, &oact);
1271  status = wait(&i);
1272  if (status == -1) wait(&i);
1273  exit (status == -1);
1274#endif
1275}
1276], bash_cv_sys_restartable_syscalls=yes, bash_cv_sys_restartable_syscalls=no,
1277   AC_MSG_WARN(cannot check restartable syscalls if cross compiling))
1278])
1279if test $bash_cv_sys_restartable_syscalls = yes; then
1280  AC_DEFINE(HAVE_RESTARTABLE_SYSCALLS)
1281fi
1282])
1283dnl
1284dnl Check for 64-bit off_t -- used for malloc alignment
1285dnl
1286dnl C does not allow duplicate case labels, so the compile will fail if
1287dnl sizeof(off_t) is > 4.
1288dnl
1289AC_DEFUN(BASH_CHECK_OFF_T_64,
1290[AC_CACHE_CHECK(for 64-bit off_t, bash_cv_off_t_64,
1291AC_TRY_COMPILE([
1292#ifdef HAVE_UNISTD_H
1293#include <unistd.h>
1294#endif
1295#include <sys/types.h>
1296],[
1297switch (0) case 0: case (sizeof (off_t) <= 4):;
1298], bash_cv_off_t_64=no, bash_cv_off_t_64=yes))
1299if test $bash_cv_off_t_64 = yes; then
1300        AC_DEFINE(HAVE_OFF_T_64)
1301fi])
Note: See TracBrowser for help on using the repository browser.