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

Revision 17010, 42.1 KB checked in by ghudson, 23 years ago (diff)
This commit was generated by cvs2svn to compensate for changes in r17009, which included commits to RCS files with non-trunk default branches.
RevLine 
[12991]1dnl
2dnl Bash specific tests
3dnl
4dnl Some derived from PDKSH 5.1.3 autoconf tests
5dnl
[17009]6
7AC_DEFUN(BASH_C_LONG_LONG,
8[AC_CACHE_CHECK(for long long, ac_cv_c_long_long,
9[if test "$GCC" = yes; then
10  ac_cv_c_long_long=yes
11else
12AC_TRY_RUN([
13int
[12991]14main()
15{
[17009]16long long foo = 0;
17exit(sizeof(long long) < sizeof(long));
[12991]18}
[17009]19], ac_cv_c_long_long=yes, ac_cv_c_long_long=no)
20fi])
21if test $ac_cv_c_long_long = yes; then
22  AC_DEFINE(HAVE_LONG_LONG, 1, [Define if the `long long' type works.])
[12991]23fi
24])
25
[17009]26dnl
27dnl This is very similar to AC_C_LONG_DOUBLE, with the fix for IRIX
28dnl (< changed to <=) added.
29dnl
30AC_DEFUN(BASH_C_LONG_DOUBLE,
31[AC_CACHE_CHECK(for long double, ac_cv_c_long_double,
32[if test "$GCC" = yes; then
33  ac_cv_c_long_double=yes
34else
35AC_TRY_RUN([
36int
[12991]37main()
38{
[17009]39  /* The Stardent Vistra knows sizeof(long double), but does not
40     support it. */
41  long double foo = 0.0;
42  /* On Ultrix 4.3 cc, long double is 4 and double is 8.  */
43  /* On IRIX 5.3, the compiler converts long double to double with a warning,
44     but compiles this successfully. */
45  exit(sizeof(long double) <= sizeof(double));
[12991]46}
[17009]47], ac_cv_c_long_double=yes, ac_cv_c_long_double=no)
48fi])
49if test $ac_cv_c_long_double = yes; then
50  AC_DEFINE(HAVE_LONG_DOUBLE, 1, [Define if the `long double' type works.])
[12991]51fi
52])
53
54dnl
[17009]55dnl Check for <inttypes.h>.  This is separated out so that it can be
56dnl AC_REQUIREd.
57dnl
58dnl BASH_HEADER_INTTYPES
59AC_DEFUN(BASH_HEADER_INTTYPES,
60[
61 AC_CHECK_HEADERS(inttypes.h)
62])
63
64dnl
[12991]65dnl check for typedef'd symbols in header files, but allow the caller to
66dnl specify the include files to be checked in addition to the default
67dnl
68dnl BASH_CHECK_TYPE(TYPE, HEADERS, DEFAULT[, VALUE-IF-FOUND])
69AC_DEFUN(BASH_CHECK_TYPE,
[17009]70[
71AC_REQUIRE([AC_HEADER_STDC])dnl
72AC_REQUIRE([BASH_HEADER_INTTYPES])
[12991]73AC_MSG_CHECKING(for $1)
74AC_CACHE_VAL(bash_cv_type_$1,
75[AC_EGREP_CPP($1, [#include <sys/types.h>
76#if STDC_HEADERS
77#include <stdlib.h>
[17009]78#include <stddef.h>
[12991]79#endif
[17009]80#if HAVE_INTTYPES_H
81#include <inttypes.h>
82#endif
[12991]83$2
84], bash_cv_type_$1=yes, bash_cv_type_$1=no)])
85AC_MSG_RESULT($bash_cv_type_$1)
86ifelse($#, 4, [if test $bash_cv_type_$1 = yes; then
87        AC_DEFINE($4)
88        fi])
89if test $bash_cv_type_$1 = no; then
[17009]90  AC_DEFINE_UNQUOTED($1, $3)
[12991]91fi
92])
93
94dnl
[17009]95dnl BASH_CHECK_DECL(FUNC)
[12991]96dnl
[17009]97dnl Check for a declaration of FUNC in stdlib.h and inttypes.h like
98dnl AC_CHECK_DECL
99dnl
100AC_DEFUN(BASH_CHECK_DECL,
101[
102AC_REQUIRE([AC_HEADER_STDC])
103AC_REQUIRE([BASH_HEADER_INTTYPES])
104AC_CACHE_CHECK([for declaration of $1], bash_cv_decl_$1,
105[AC_TRY_LINK(
106[
107#if STDC_HEADERS
108#  include <stdlib.h>
109#endif
110#if HAVE_INTTYPES_H
111#  include <inttypes.h>
112#endif
113],
114[return !$1;],
115bash_cv_decl_$1=yes, bash_cv_decl_$1=no)])
116bash_tr_func=HAVE_DECL_`echo $1 | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
117if test $bash_cv_decl_$1 = yes; then
118  AC_DEFINE_UNQUOTED($bash_tr_func, 1)
119else
120  AC_DEFINE_UNQUOTED($bash_tr_func, 0)
121fi
122])
123
124AC_DEFUN(BASH_DECL_PRINTF,
125[AC_MSG_CHECKING(for declaration of printf in <stdio.h>)
126AC_CACHE_VAL(bash_cv_printf_declared,
127[AC_TRY_RUN([
128#include <stdio.h>
129#ifdef __STDC__
130typedef int (*_bashfunc)(const char *, ...);
131#else
132typedef int (*_bashfunc)();
133#endif
[12991]134main()
135{
[17009]136_bashfunc pf;
137pf = (_bashfunc) printf;
138exit(pf == 0);
139}
140], bash_cv_printf_declared=yes, bash_cv_printf_declared=no,
141   [AC_MSG_WARN(cannot check printf declaration if cross compiling -- defaulting to yes)
142    bash_cv_printf_declared=yes]
143)])
144AC_MSG_RESULT($bash_cv_printf_declared)
145if test $bash_cv_printf_declared = yes; then
146AC_DEFINE(PRINTF_DECLARED)
147fi
[12991]148])
[17009]149
150AC_DEFUN(BASH_DECL_SBRK,
151[AC_MSG_CHECKING(for declaration of sbrk in <unistd.h>)
152AC_CACHE_VAL(bash_cv_sbrk_declared,
153[AC_EGREP_HEADER(sbrk, unistd.h,
154 bash_cv_sbrk_declared=yes, bash_cv_sbrk_declared=no)])
155AC_MSG_RESULT($bash_cv_sbrk_declared)
156if test $bash_cv_sbrk_declared = yes; then
157AC_DEFINE(SBRK_DECLARED)
[12991]158fi
159])
160
161dnl
162dnl Check for sys_siglist[] or _sys_siglist[]
163dnl
164AC_DEFUN(BASH_DECL_UNDER_SYS_SIGLIST,
165[AC_MSG_CHECKING([for _sys_siglist in signal.h or unistd.h])
166AC_CACHE_VAL(bash_cv_decl_under_sys_siglist,
167[AC_TRY_COMPILE([
168#include <sys/types.h>
169#include <signal.h>
170#ifdef HAVE_UNISTD_H
171#include <unistd.h>
172#endif], [ char *msg = _sys_siglist[2]; ],
173  bash_cv_decl_under_sys_siglist=yes, bash_cv_decl_under_sys_siglist=no,
174  [AC_MSG_WARN(cannot check for _sys_siglist[] if cross compiling -- defaulting to no)])])dnl
175AC_MSG_RESULT($bash_cv_decl_under_sys_siglist)
176if test $bash_cv_decl_under_sys_siglist = yes; then
177AC_DEFINE(UNDER_SYS_SIGLIST_DECLARED)
178fi
179])
180
181AC_DEFUN(BASH_UNDER_SYS_SIGLIST,
182[AC_REQUIRE([BASH_DECL_UNDER_SYS_SIGLIST])
183AC_MSG_CHECKING([for _sys_siglist in system C library])
184AC_CACHE_VAL(bash_cv_under_sys_siglist,
185[AC_TRY_RUN([
186#include <sys/types.h>
187#include <signal.h>
188#ifdef HAVE_UNISTD_H
189#include <unistd.h>
190#endif
191#ifndef UNDER_SYS_SIGLIST_DECLARED
192extern char *_sys_siglist[];
193#endif
194main()
195{
196char *msg = (char *)_sys_siglist[2];
197exit(msg == 0);
198}],
199        bash_cv_under_sys_siglist=yes, bash_cv_under_sys_siglist=no,
200        [AC_MSG_WARN(cannot check for _sys_siglist[] if cross compiling -- defaulting to no)
201         bash_cv_under_sys_siglist=no])])
202AC_MSG_RESULT($bash_cv_under_sys_siglist)
203if test $bash_cv_under_sys_siglist = yes; then
204AC_DEFINE(HAVE_UNDER_SYS_SIGLIST)
205fi
206])
207
208AC_DEFUN(BASH_SYS_SIGLIST,
209[AC_REQUIRE([AC_DECL_SYS_SIGLIST])
210AC_MSG_CHECKING([for sys_siglist in system C library])
211AC_CACHE_VAL(bash_cv_sys_siglist,
212[AC_TRY_RUN([
213#include <sys/types.h>
214#include <signal.h>
215#ifdef HAVE_UNISTD_H
216#include <unistd.h>
217#endif
218#ifndef SYS_SIGLIST_DECLARED
219extern char *sys_siglist[];
220#endif
221main()
222{
223char *msg = sys_siglist[2];
224exit(msg == 0);
225}],
226        bash_cv_sys_siglist=yes, bash_cv_sys_siglist=no,
227        [AC_MSG_WARN(cannot check for sys_siglist if cross compiling -- defaulting to no)
228         bash_cv_sys_siglist=no])])
229AC_MSG_RESULT($bash_cv_sys_siglist)
230if test $bash_cv_sys_siglist = yes; then
231AC_DEFINE(HAVE_SYS_SIGLIST)
232fi
233])
234
[17009]235dnl Check for the various permutations of sys_siglist and make sure we
236dnl compile in siglist.o if they're not defined
237AC_DEFUN(BASH_CHECK_SYS_SIGLIST, [
238AC_REQUIRE([BASH_SYS_SIGLIST])
239AC_REQUIRE([BASH_DECL_UNDER_SYS_SIGLIST])
240AC_REQUIRE([BASH_FUNC_STRSIGNAL])
241if test "$bash_cv_sys_siglist" = no && test "$bash_cv_under_sys_siglist" = no && test "$bash_cv_have_strsignal" = no; then
242  SIGLIST_O=siglist.o
243else
244  SIGLIST_O=
245fi
246AC_SUBST([SIGLIST_O])
247])
248
[12991]249dnl Check for sys_errlist[] and sys_nerr, check for declaration
250AC_DEFUN(BASH_SYS_ERRLIST,
251[AC_MSG_CHECKING([for sys_errlist and sys_nerr])
252AC_CACHE_VAL(bash_cv_sys_errlist,
253[AC_TRY_LINK([#include <errno.h>],
254[extern char *sys_errlist[];
255 extern int sys_nerr;
256 char *msg = sys_errlist[sys_nerr - 1];],
257    bash_cv_sys_errlist=yes, bash_cv_sys_errlist=no)])dnl
258AC_MSG_RESULT($bash_cv_sys_errlist)
259if test $bash_cv_sys_errlist = yes; then
260AC_DEFINE(HAVE_SYS_ERRLIST)
261fi
262])
263
[17009]264dnl
265dnl Check if dup2() does not clear the close on exec flag
266dnl
267AC_DEFUN(BASH_FUNC_DUP2_CLOEXEC_CHECK,
268[AC_MSG_CHECKING(if dup2 fails to clear the close-on-exec flag)
269AC_CACHE_VAL(bash_cv_dup2_broken,
270[AC_TRY_RUN([
271#include <sys/types.h>
272#include <fcntl.h>
273main()
274{
275  int fd1, fd2, fl;
276  fd1 = open("/dev/null", 2);
277  if (fcntl(fd1, 2, 1) < 0)
278    exit(1);
279  fd2 = dup2(fd1, 1);
280  if (fd2 < 0)
281    exit(2);
282  fl = fcntl(fd2, 1, 0);
283  /* fl will be 1 if dup2 did not reset the close-on-exec flag. */
284  exit(fl != 1);
285}
286], bash_cv_dup2_broken=yes, bash_cv_dup2_broken=no,
287    [AC_MSG_WARN(cannot check dup2 if cross compiling -- defaulting to no)
288     bash_cv_dup2_broken=no])
289])
290AC_MSG_RESULT($bash_cv_dup2_broken)
291if test $bash_cv_dup2_broken = yes; then
292AC_DEFINE(DUP2_BROKEN)
293fi
294])
295
296AC_DEFUN(BASH_FUNC_STRSIGNAL,
297[AC_MSG_CHECKING([for the existence of strsignal])
298AC_CACHE_VAL(bash_cv_have_strsignal,
299[AC_TRY_LINK([#include <sys/types.h>
300#include <signal.h>],
301[char *s = (char *)strsignal(2);],
302 bash_cv_have_strsignal=yes, bash_cv_have_strsignal=no)])
303AC_MSG_RESULT($bash_cv_have_strsignal)
304if test $bash_cv_have_strsignal = yes; then
305AC_DEFINE(HAVE_STRSIGNAL)
306fi
307])
308
[12991]309dnl Check to see if opendir will open non-directories (not a nice thing)
310AC_DEFUN(BASH_FUNC_OPENDIR_CHECK,
311[AC_REQUIRE([AC_HEADER_DIRENT])dnl
312AC_MSG_CHECKING(if opendir() opens non-directories)
313AC_CACHE_VAL(bash_cv_opendir_not_robust,
314[AC_TRY_RUN([
315#include <stdio.h>
316#include <sys/types.h>
317#include <fcntl.h>
318#ifdef HAVE_UNISTD_H
319# include <unistd.h>
320#endif /* HAVE_UNISTD_H */
321#if defined(HAVE_DIRENT_H)
322# include <dirent.h>
323#else
324# define dirent direct
325# ifdef HAVE_SYS_NDIR_H
326#  include <sys/ndir.h>
327# endif /* SYSNDIR */
328# ifdef HAVE_SYS_DIR_H
329#  include <sys/dir.h>
330# endif /* SYSDIR */
331# ifdef HAVE_NDIR_H
332#  include <ndir.h>
333# endif
334#endif /* HAVE_DIRENT_H */
335main()
336{
337DIR *dir;
[15409]338int fd, err;
339err = mkdir("/tmp/bash-aclocal", 0700);
340if (err < 0) {
341  perror("mkdir");
342  exit(1);
343}
344unlink("/tmp/bash-aclocal/not_a_directory");
345fd = open("/tmp/bash-aclocal/not_a_directory", O_WRONLY|O_CREAT|O_EXCL, 0666);
[12991]346write(fd, "\n", 1);
347close(fd);
[15409]348dir = opendir("/tmp/bash-aclocal/not_a_directory");
349unlink("/tmp/bash-aclocal/not_a_directory");
350rmdir("/tmp/bash-aclocal");
[12991]351exit (dir == 0);
352}], bash_cv_opendir_not_robust=yes,bash_cv_opendir_not_robust=no,
353    [AC_MSG_WARN(cannot check opendir if cross compiling -- defaulting to no)
354     bash_cv_opendir_not_robust=no]
355)])
356AC_MSG_RESULT($bash_cv_opendir_not_robust)
357if test $bash_cv_opendir_not_robust = yes; then
358AC_DEFINE(OPENDIR_NOT_ROBUST)
359fi
360])
361
362dnl
363AC_DEFUN(BASH_TYPE_SIGHANDLER,
364[AC_MSG_CHECKING([whether signal handlers are of type void])
365AC_CACHE_VAL(bash_cv_void_sighandler,
366[AC_TRY_COMPILE([#include <sys/types.h>
367#include <signal.h>
368#ifdef signal
369#undef signal
370#endif
371#ifdef __cplusplus
372extern "C"
373#endif
374void (*signal ()) ();],
375[int i;], bash_cv_void_sighandler=yes, bash_cv_void_sighandler=no)])dnl
376AC_MSG_RESULT($bash_cv_void_sighandler)
377if test $bash_cv_void_sighandler = yes; then
378AC_DEFINE(VOID_SIGHANDLER)
379fi
380])
381
[15409]382dnl
383dnl A signed 16-bit integer quantity
384dnl
385AC_DEFUN(BASH_TYPE_BITS16_T,
[12991]386[
[15409]387if test "$ac_cv_sizeof_short" = 2; then
388  AC_CHECK_TYPE(bits16_t, short)
389elif test "$ac_cv_sizeof_char" = 2; then
390  AC_CHECK_TYPE(bits16_t, char)
391else
392  AC_CHECK_TYPE(bits16_t, short)
393fi
394])
395
396dnl
397dnl An unsigned 16-bit integer quantity
398dnl
399AC_DEFUN(BASH_TYPE_U_BITS16_T,
400[
401if test "$ac_cv_sizeof_short" = 2; then
402  AC_CHECK_TYPE(u_bits16_t, unsigned short)
403elif test "$ac_cv_sizeof_char" = 2; then
404  AC_CHECK_TYPE(u_bits16_t, unsigned char)
405else
406  AC_CHECK_TYPE(u_bits16_t, unsigned short)
407fi
408])
409
410dnl
411dnl A signed 32-bit integer quantity
412dnl
413AC_DEFUN(BASH_TYPE_BITS32_T,
414[
[12991]415if test "$ac_cv_sizeof_int" = 4; then
[15409]416  AC_CHECK_TYPE(bits32_t, int)
[12991]417elif test "$ac_cv_sizeof_long" = 4; then
[15409]418  AC_CHECK_TYPE(bits32_t, long)
[12991]419else
[15409]420  AC_CHECK_TYPE(bits32_t, int)
[12991]421fi
422])
423
[15409]424dnl
425dnl An unsigned 32-bit integer quantity
426dnl
427AC_DEFUN(BASH_TYPE_U_BITS32_T,
[12991]428[
429if test "$ac_cv_sizeof_int" = 4; then
[15409]430  AC_CHECK_TYPE(u_bits32_t, unsigned int)
[12991]431elif test "$ac_cv_sizeof_long" = 4; then
[15409]432  AC_CHECK_TYPE(u_bits32_t, unsigned long)
[12991]433else
[15409]434  AC_CHECK_TYPE(u_bits32_t, unsigned int)
[12991]435fi
436])
437
438AC_DEFUN(BASH_TYPE_PTRDIFF_T,
439[
440if test "$ac_cv_sizeof_int" = "$ac_cv_sizeof_char_p"; then
441  AC_CHECK_TYPE(ptrdiff_t, int)
442elif test "$ac_cv_sizeof_long" = "$ac_cv_sizeof_char_p"; then
443  AC_CHECK_TYPE(ptrdiff_t, long)
[17009]444elif test "$ac_cv_type_long_long" = yes && test "$ac_cv_sizeof_long_long" = "$ac_cv_sizeof_char_p"; then
445  AC_CHECK_TYPE(ptrdiff_t, [long long])
[12991]446else
447  AC_CHECK_TYPE(ptrdiff_t, int)
448fi
449])
450
[15409]451dnl
452dnl A signed 64-bit quantity
453dnl
[12991]454AC_DEFUN(BASH_TYPE_BITS64_T,
455[
[17009]456if test "$ac_cv_sizeof_char_p" = 8; then
[12991]457  AC_CHECK_TYPE(bits64_t, char *)
458elif test "$ac_cv_sizeof_double" = 8; then
459  AC_CHECK_TYPE(bits64_t, double)
[17009]460elif test -n "$ac_cv_type_long_long" && test "$ac_cv_sizeof_long_long" = 8; then
461  AC_CHECK_TYPE(bits64_t, [long long])
[12991]462elif test "$ac_cv_sizeof_long" = 8; then
463  AC_CHECK_TYPE(bits64_t, long)
464else
465  AC_CHECK_TYPE(bits64_t, double)
466fi
467])
468
[17009]469AC_DEFUN(BASH_TYPE_LONG_LONG,
470[
471AC_CACHE_CHECK([for long long], bash_cv_type_long_long,
472[AC_TRY_LINK([
473long long ll = 1; int i = 63;],
474[
475long long llm = (long long) -1;
476return ll << i | ll >> i | llm / ll | llm % ll;
477], bash_cv_type_long_long='long long', bash_cv_type_long_long='long')])
478if test "$bash_cv_type_long_long" = 'long long'; then
479  AC_DEFINE(HAVE_LONG_LONG, 1)
[12991]480fi
481])
482
[17009]483AC_DEFUN(BASH_TYPE_UNSIGNED_LONG_LONG,
484[
485AC_CACHE_CHECK([for unsigned long long], bash_cv_type_unsigned_long_long,
486[AC_TRY_LINK([
487unsigned long long ull = 1; int i = 63;],
488[
489unsigned long long ullmax = (unsigned long long) -1;
490return ull << i | ull >> i | ullmax / ull | ullmax % ull;
491], bash_cv_type_unsigned_long_long='unsigned long long',
492   bash_cv_type_unsigned_long_long='unsigned long')])
493if test "$bash_cv_type_unsigned_long_long" = 'unsigned long long'; then
494  AC_DEFINE(HAVE_UNSIGNED_LONG_LONG, 1)
495fi
496])
497
498dnl
499dnl Type of struct rlimit fields: some systems (OSF/1, NetBSD, RISC/os 5.0)
500dnl have a rlim_t, others (4.4BSD based systems) use quad_t, others use
501dnl long and still others use int (HP-UX 9.01, SunOS 4.1.3).  To simplify
502dnl matters, this just checks for rlim_t, quad_t, or long.
503dnl
504AC_DEFUN(BASH_TYPE_RLIMIT,
505[AC_MSG_CHECKING(for size and type of struct rlimit fields)
506AC_CACHE_VAL(bash_cv_type_rlimit,
507[AC_TRY_COMPILE([#include <sys/types.h>
508#include <sys/resource.h>],
509[rlim_t xxx;], bash_cv_type_rlimit=rlim_t,[
510AC_TRY_RUN([
511#include <sys/types.h>
512#include <sys/time.h>
513#include <sys/resource.h>
514main()
515{
516#ifdef HAVE_QUAD_T
517  struct rlimit rl;
518  if (sizeof(rl.rlim_cur) == sizeof(quad_t))
519    exit(0);
520#endif
521  exit(1);
522}], bash_cv_type_rlimit=quad_t, bash_cv_type_rlimit=long,
523        [AC_MSG_WARN(cannot check quad_t if cross compiling -- defaulting to long)
524         bash_cv_type_rlimit=long])])
525])
526AC_MSG_RESULT($bash_cv_type_rlimit)
527if test $bash_cv_type_rlimit = quad_t; then
528AC_DEFINE(RLIMTYPE, quad_t)
529elif test $bash_cv_type_rlimit = rlim_t; then
530AC_DEFINE(RLIMTYPE, rlim_t)
531fi
532])
533
[12991]534AC_DEFUN(BASH_FUNC_LSTAT,
535[dnl Cannot use AC_CHECK_FUNCS(lstat) because Linux defines lstat() as an
536dnl inline function in <sys/stat.h>.
537AC_CACHE_CHECK([for lstat], bash_cv_func_lstat,
538[AC_TRY_LINK([
539#include <sys/types.h>
540#include <sys/stat.h>
541],[ lstat(".",(struct stat *)0); ],
542bash_cv_func_lstat=yes, bash_cv_func_lstat=no)])
543if test $bash_cv_func_lstat = yes; then
544  AC_DEFINE(HAVE_LSTAT)
545fi
546])
547
[15409]548AC_DEFUN(BASH_FUNC_INET_ATON,
549[
550AC_CACHE_CHECK([for inet_aton], bash_cv_func_inet_aton,
551[AC_TRY_LINK([
552#include <sys/types.h>
553#include <netinet/in.h>
554#include <arpa/inet.h>
555struct in_addr ap;], [ inet_aton("127.0.0.1", &ap); ],
556bash_cv_func_inet_aton=yes, bash_cv_func_inet_aton=no)])
557if test $bash_cv_func_inet_aton = yes; then
558  AC_DEFINE(HAVE_INET_ATON)
[17009]559else
560  AC_LIBOBJ(inet_aton)
[15409]561fi
562])
563
[12991]564AC_DEFUN(BASH_FUNC_GETENV,
565[AC_MSG_CHECKING(to see if getenv can be redefined)
566AC_CACHE_VAL(bash_cv_getenv_redef,
567[AC_TRY_RUN([
568#ifdef HAVE_UNISTD_H
569#  include <unistd.h>
570#endif
571#ifndef __STDC__
572#  ifndef const
573#    define const
574#  endif
575#endif
576char *
577getenv (name)
578#if defined (__linux__) || defined (__bsdi__) || defined (convex)
579     const char *name;
580#else
581     char const *name;
582#endif /* !__linux__ && !__bsdi__ && !convex */
583{
584return "42";
585}
586main()
587{
588char *s;
589/* The next allows this program to run, but does not allow bash to link
590   when it redefines getenv.  I'm not really interested in figuring out
591   why not. */
592#if defined (NeXT)
593exit(1);
594#endif
595s = getenv("ABCDE");
596exit(s == 0);   /* force optimizer to leave getenv in */
597}
598], bash_cv_getenv_redef=yes, bash_cv_getenv_redef=no,
599   [AC_MSG_WARN(cannot check getenv redefinition if cross compiling -- defaulting to yes)
600    bash_cv_getenv_redef=yes]
601)])
602AC_MSG_RESULT($bash_cv_getenv_redef)
603if test $bash_cv_getenv_redef = yes; then
604AC_DEFINE(CAN_REDEFINE_GETENV)
605fi
606])
607
608AC_DEFUN(BASH_FUNC_ULIMIT_MAXFDS,
609[AC_MSG_CHECKING(whether ulimit can substitute for getdtablesize)
610AC_CACHE_VAL(bash_cv_ulimit_maxfds,
611[AC_TRY_RUN([
612main()
613{
614long maxfds = ulimit(4, 0L);
615exit (maxfds == -1L);
616}
617], bash_cv_ulimit_maxfds=yes, bash_cv_ulimit_maxfds=no,
618   [AC_MSG_WARN(cannot check ulimit if cross compiling -- defaulting to no)
619    bash_cv_ulimit_maxfds=no]
620)])
621AC_MSG_RESULT($bash_cv_ulimit_maxfds)
622if test $bash_cv_ulimit_maxfds = yes; then
623AC_DEFINE(ULIMIT_MAXFDS)
624fi
625])
626
627AC_DEFUN(BASH_FUNC_GETCWD,
628[AC_MSG_CHECKING([if getcwd() calls popen()])
629AC_CACHE_VAL(bash_cv_getcwd_calls_popen,
630[AC_TRY_RUN([
631#include <stdio.h>
632#ifdef HAVE_UNISTD_H
633#include <unistd.h>
634#endif
635
636#ifndef __STDC__
637#ifndef const
638#define const
639#endif
640#endif
641
642int popen_called;
643
644FILE *
645popen(command, type)
646     const char *command;
647     const char *type;
648{
649        popen_called = 1;
650        return (FILE *)NULL;
651}
652
653FILE *_popen(command, type)
654     const char *command;
655     const char *type;
656{
657  return (popen (command, type));
658}
659
660int
661pclose(stream)
662FILE *stream;
663{
664        return 0;
665}
666
667int
668_pclose(stream)
669FILE *stream;
670{
671        return 0;
672}
673
674main()
675{
676        char    lbuf[32];
677        popen_called = 0;
678        getcwd(lbuf, 32);
679        exit (popen_called);
680}
681], bash_cv_getcwd_calls_popen=no, bash_cv_getcwd_calls_popen=yes,
682   [AC_MSG_WARN(cannot check whether getcwd calls popen if cross compiling -- defaulting to no)
683    bash_cv_getcwd_calls_popen=no]
684)])
685AC_MSG_RESULT($bash_cv_getcwd_calls_popen)
686if test $bash_cv_getcwd_calls_popen = yes; then
687AC_DEFINE(GETCWD_BROKEN)
[17009]688AC_LIBOBJ(getcwd)
[12991]689fi
690])
691
[17009]692dnl
693dnl This needs BASH_CHECK_SOCKLIB, but since that's not called on every
694dnl system, we can't use AC_PREREQ
695dnl
696AC_DEFUN(BASH_FUNC_GETHOSTBYNAME,
697[if test "X$bash_cv_have_gethostbyname" = "X"; then
698_bash_needmsg=yes
699else
700AC_MSG_CHECKING(for gethostbyname in socket library)
701_bash_needmsg=
702fi
703AC_CACHE_VAL(bash_cv_have_gethostbyname,
704[AC_TRY_LINK([#include <netdb.h>],
705[ struct hostent *hp;
706  hp = gethostbyname("localhost");
707], bash_cv_have_gethostbyname=yes, bash_cv_have_gethostbyname=no)]
708)
709if test "X$_bash_needmsg" = Xyes; then
710    AC_MSG_CHECKING(for gethostbyname in socket library)
711fi
712AC_MSG_RESULT($bash_cv_have_gethostbyname)
713if test "$bash_cv_have_gethostbyname" = yes; then
714AC_DEFINE(HAVE_GETHOSTBYNAME)
715fi
716])
717
718AC_DEFUN(BASH_FUNC_FNMATCH_EXTMATCH,
719[AC_MSG_CHECKING(if fnmatch does extended pattern matching with FNM_EXTMATCH)
720AC_CACHE_VAL(bash_cv_fnm_extmatch,
721[AC_TRY_RUN([
722#include <fnmatch.h>
723
724main()
725{
726#ifdef FNM_EXTMATCH
727  exit (0);
728#else
729  exit (1);
730#endif
731}
732], bash_cv_fnm_extmatch=yes, bash_cv_fnm_extmatch=no,
733    [AC_MSG_WARN(cannot check FNM_EXTMATCH if cross compiling -- defaulting to no)
734     bash_cv_fnm_extmatch=no])
735])
736AC_MSG_RESULT($bash_cv_fnm_extmatch)
737if test $bash_cv_fnm_extmatch = yes; then
738AC_DEFINE(HAVE_LIBC_FNM_EXTMATCH)
739fi
740])
741
742AC_DEFUN(BASH_FUNC_POSIX_SETJMP,
743[AC_REQUIRE([BASH_SYS_SIGNAL_VINTAGE])
744AC_MSG_CHECKING(for presence of POSIX-style sigsetjmp/siglongjmp)
745AC_CACHE_VAL(bash_cv_func_sigsetjmp,
746[AC_TRY_RUN([
747#ifdef HAVE_UNISTD_H
748#include <unistd.h>
749#endif
750#include <sys/types.h>
751#include <signal.h>
752#include <setjmp.h>
753
754main()
755{
756#if !defined (_POSIX_VERSION) || !defined (HAVE_POSIX_SIGNALS)
757exit (1);
758#else
759
760int code;
761sigset_t set, oset;
762sigjmp_buf xx;
763
764/* get the mask */
765sigemptyset(&set);
766sigemptyset(&oset);
767sigprocmask(SIG_BLOCK, (sigset_t *)NULL, &set);
768sigprocmask(SIG_BLOCK, (sigset_t *)NULL, &oset);
769
770/* save it */
771code = sigsetjmp(xx, 1);
772if (code)
773  exit(0);      /* could get sigmask and compare to oset here. */
774
775/* change it */
776sigaddset(&set, SIGINT);
777sigprocmask(SIG_BLOCK, &set, (sigset_t *)NULL);
778
779/* and siglongjmp */
780siglongjmp(xx, 10);
781exit(1);
782#endif
783}], bash_cv_func_sigsetjmp=present, bash_cv_func_sigsetjmp=missing,
784    [AC_MSG_WARN(cannot check for sigsetjmp/siglongjmp if cross-compiling -- defaulting to missing)
785     bash_cv_func_sigsetjmp=missing]
786)])
787AC_MSG_RESULT($bash_cv_func_sigsetjmp)
788if test $bash_cv_func_sigsetjmp = present; then
789AC_DEFINE(HAVE_POSIX_SIGSETJMP)
790fi
791])
792
793AC_DEFUN(BASH_FUNC_STRCOLL,
794[
795AC_MSG_CHECKING(whether or not strcoll and strcmp differ)
796AC_CACHE_VAL(bash_cv_func_strcoll_broken,
797[AC_TRY_RUN([
798#include <stdio.h>
799#if defined (HAVE_LOCALE_H)
800#include <locale.h>
801#endif
802
803main(c, v)
804int     c;
805char    *v[];
806{
807        int     r1, r2;
808        char    *deflocale, *defcoll;
809
810#ifdef HAVE_SETLOCALE
811        deflocale = setlocale(LC_ALL, "");
812        defcoll = setlocale(LC_COLLATE, "");
813#endif
814
815#ifdef HAVE_STRCOLL
816        /* These two values are taken from tests/glob-test. */
817        r1 = strcoll("abd", "aXd");
818#else
819        r1 = 0;
820#endif
821        r2 = strcmp("abd", "aXd");
822
823        /* These two should both be greater than 0.  It is permissible for
824           a system to return different values, as long as the sign is the
825           same. */
826
827        /* Exit with 1 (failure) if these two values are both > 0, since
828           this tests whether strcoll(3) is broken with respect to strcmp(3)
829           in the default locale. */
830        exit (r1 > 0 && r2 > 0);
831}
832], bash_cv_func_strcoll_broken=yes, bash_cv_func_strcoll_broken=no,
833   [AC_MSG_WARN(cannot check strcoll if cross compiling -- defaulting to no)
834    bash_cv_func_strcoll_broken=no]
835)])
836AC_MSG_RESULT($bash_cv_func_strcoll_broken)
837if test $bash_cv_func_strcoll_broken = yes; then
838AC_DEFINE(STRCOLL_BROKEN)
839fi
840])
841
842AC_DEFUN(BASH_FUNC_PRINTF_A_FORMAT,
843[AC_MSG_CHECKING([for printf floating point output in hex notation])
844AC_CACHE_VAL(bash_cv_printf_a_format,
845[AC_TRY_RUN([
846#include <stdio.h>
847#include <string.h>
848
849int
850main()
851{
852        double y = 0.0;
853        char abuf[1024];
854
855        sprintf(abuf, "%A", y);
856        exit(strchr(abuf, 'P') == (char *)0);
857}
858], bash_cv_printf_a_format=yes, bash_cv_printf_a_format=no,
859   [AC_MSG_WARN(cannot check printf if cross compiling -- defaulting to no)
860    bash_cv_printf_a_format=no]
861)])
862AC_MSG_RESULT($bash_cv_printf_a_format)
863if test $bash_cv_printf_a_format = yes; then
864AC_DEFINE(HAVE_PRINTF_A_FORMAT)
865fi
866])
867
868AC_DEFUN(BASH_STRUCT_TERMIOS_LDISC,
869[
870AC_CHECK_MEMBER(struct termios.c_line, AC_DEFINE(TERMIOS_LDISC), ,[
871#include <sys/types.h>
872#include <termios.h>
873])
874])
875
876AC_DEFUN(BASH_STRUCT_TERMIO_LDISC,
877[
878AC_CHECK_MEMBER(struct termio.c_line, AC_DEFINE(TERMIO_LDISC), ,[
879#include <sys/types.h>
880#include <termio.h>
881])
882])
883
884dnl
885dnl Like AC_STRUCT_ST_BLOCKS, but doesn't muck with LIBOBJS
886dnl
887dnl sets bash_cv_struct_stat_st_blocks
888dnl
889dnl unused for now; we'll see how AC_CHECK_MEMBERS works
890dnl
891AC_DEFUN(BASH_STRUCT_ST_BLOCKS,
892[
893AC_MSG_CHECKING([for struct stat.st_blocks])
894AC_CACHE_VAL(bash_cv_struct_stat_st_blocks,
895[AC_TRY_COMPILE(
896[
897#include <sys/types.h>
898#include <sys/stat.h>
899],
900[
901main()
902{
903static struct stat a;
904if (a.st_blocks) return 0;
905return 0;
906}
907], bash_cv_struct_stat_st_blocks=yes, bash_cv_struct_stat_st_blocks=no)
908])
909AC_MSG_RESULT($bash_cv_struct_stat_st_blocks)
910if test "$bash_cv_struct_stat_st_blocks" = "yes"; then
911AC_DEFINE(HAVE_STRUCT_STAT_ST_BLOCKS)
912fi
913])
914
915AC_DEFUN(BASH_CHECK_LIB_TERMCAP,
916[
917if test "X$bash_cv_termcap_lib" = "X"; then
918_bash_needmsg=yes
919else
920AC_MSG_CHECKING(which library has the termcap functions)
921_bash_needmsg=
922fi
923AC_CACHE_VAL(bash_cv_termcap_lib,
924[AC_CHECK_LIB(termcap, tgetent, bash_cv_termcap_lib=libtermcap,
925    [AC_CHECK_LIB(tinfo, tgetent, bash_cv_termcal_lib=libtinfo,
926        [AC_CHECK_LIB(curses, tgetent, bash_cv_termcap_lib=libcurses,
927            [AC_CHECK_LIB(ncurses, tgetent, bash_cv_termcap_lib=libncurses,
928                bash_cv_termcap_lib=gnutermcap)])])])])
929if test "X$_bash_needmsg" = "Xyes"; then
930AC_MSG_CHECKING(which library has the termcap functions)
931fi
932AC_MSG_RESULT(using $bash_cv_termcap_lib)
933if test $bash_cv_termcap_lib = gnutermcap && test -z "$prefer_curses"; then
934LDFLAGS="$LDFLAGS -L./lib/termcap"
935TERMCAP_LIB="./lib/termcap/libtermcap.a"
936TERMCAP_DEP="./lib/termcap/libtermcap.a"
937elif test $bash_cv_termcap_lib = libtermcap && test -z "$prefer_curses"; then
938TERMCAP_LIB=-ltermcap
939TERMCAP_DEP=
940elif test $bash_cv_termcap_lib = libtinfo; then
941TERMCAP_LIB=-ltinfo
942TERMCAP_DEP=
943elif test $bash_cv_termcap_lib = libncurses; then
944TERMCAP_LIB=-lncurses
945TERMCAP_DEP=
946else
947TERMCAP_LIB=-lcurses
948TERMCAP_DEP=
949fi
950])
951
952dnl
953dnl Check for the presence of getpeername in libsocket.
954dnl If libsocket is present, check for libnsl and add it to LIBS if
955dnl it's there, since most systems with libsocket require linking
956dnl with libnsl as well.  This should only be called if getpeername
957dnl was not found in libc.
958dnl
959dnl NOTE: IF WE FIND GETPEERNAME, WE ASSUME THAT WE HAVE BIND/CONNECT
960dnl       AS WELL
961dnl
962AC_DEFUN(BASH_CHECK_LIB_SOCKET,
963[
964if test "X$bash_cv_have_socklib" = "X"; then
965_bash_needmsg=
966else
967AC_MSG_CHECKING(for socket library)
968_bash_needmsg=yes
969fi
970AC_CACHE_VAL(bash_cv_have_socklib,
971[AC_CHECK_LIB(socket, getpeername,
972        bash_cv_have_socklib=yes, bash_cv_have_socklib=no, -lnsl)])
973if test "X$_bash_needmsg" = Xyes; then
974  AC_MSG_RESULT($bash_cv_have_socklib)
975  _bash_needmsg=
976fi
977if test $bash_cv_have_socklib = yes; then
978  # check for libnsl, add it to LIBS if present
979  if test "X$bash_cv_have_libnsl" = "X"; then
980    _bash_needmsg=
981  else
982    AC_MSG_CHECKING(for libnsl)
983    _bash_needmsg=yes
984  fi
985  AC_CACHE_VAL(bash_cv_have_libnsl,
986           [AC_CHECK_LIB(nsl, t_open,
987                 bash_cv_have_libnsl=yes, bash_cv_have_libnsl=no)])
988  if test "X$_bash_needmsg" = Xyes; then
989    AC_MSG_RESULT($bash_cv_have_libnsl)
990    _bash_needmsg=
991  fi
992  if test $bash_cv_have_libnsl = yes; then
993    LIBS="-lsocket -lnsl $LIBS"
994  else
995    LIBS="-lsocket $LIBS"
996  fi
997  AC_DEFINE(HAVE_LIBSOCKET)
998  AC_DEFINE(HAVE_GETPEERNAME)
999fi
1000])
1001
[12991]1002AC_DEFUN(BASH_STRUCT_DIRENT_D_INO,
1003[AC_REQUIRE([AC_HEADER_DIRENT])
1004AC_MSG_CHECKING(if struct dirent has a d_ino member)
1005AC_CACHE_VAL(bash_cv_dirent_has_dino,
1006[AC_TRY_COMPILE([
1007#include <stdio.h>
1008#include <sys/types.h>
1009#ifdef HAVE_UNISTD_H
1010# include <unistd.h>
1011#endif /* HAVE_UNISTD_H */
1012#if defined(HAVE_DIRENT_H)
1013# include <dirent.h>
1014#else
1015# define dirent direct
1016# ifdef HAVE_SYS_NDIR_H
1017#  include <sys/ndir.h>
1018# endif /* SYSNDIR */
1019# ifdef HAVE_SYS_DIR_H
1020#  include <sys/dir.h>
1021# endif /* SYSDIR */
1022# ifdef HAVE_NDIR_H
1023#  include <ndir.h>
1024# endif
1025#endif /* HAVE_DIRENT_H */
1026],[
1027struct dirent d; int z; z = d.d_ino;
1028], bash_cv_dirent_has_dino=yes, bash_cv_dirent_has_dino=no)])
1029AC_MSG_RESULT($bash_cv_dirent_has_dino)
1030if test $bash_cv_dirent_has_dino = yes; then
1031AC_DEFINE(STRUCT_DIRENT_HAS_D_INO)
1032fi
1033])
1034
1035AC_DEFUN(BASH_STRUCT_DIRENT_D_FILENO,
1036[AC_REQUIRE([AC_HEADER_DIRENT])
1037AC_MSG_CHECKING(if struct dirent has a d_fileno member)
1038AC_CACHE_VAL(bash_cv_dirent_has_d_fileno,
1039[AC_TRY_COMPILE([
1040#include <stdio.h>
1041#include <sys/types.h>
1042#ifdef HAVE_UNISTD_H
1043# include <unistd.h>
1044#endif /* HAVE_UNISTD_H */
1045#if defined(HAVE_DIRENT_H)
1046# include <dirent.h>
1047#else
1048# define dirent direct
1049# ifdef HAVE_SYS_NDIR_H
1050#  include <sys/ndir.h>
1051# endif /* SYSNDIR */
1052# ifdef HAVE_SYS_DIR_H
1053#  include <sys/dir.h>
1054# endif /* SYSDIR */
1055# ifdef HAVE_NDIR_H
1056#  include <ndir.h>
1057# endif
1058#endif /* HAVE_DIRENT_H */
1059],[
1060struct dirent d; int z; z = d.d_fileno;
1061], bash_cv_dirent_has_d_fileno=yes, bash_cv_dirent_has_d_fileno=no)])
1062AC_MSG_RESULT($bash_cv_dirent_has_d_fileno)
1063if test $bash_cv_dirent_has_d_fileno = yes; then
1064AC_DEFINE(STRUCT_DIRENT_HAS_D_FILENO)
1065fi
1066])
1067
[17009]1068AC_DEFUN(BASH_STRUCT_TIMEVAL,
1069[AC_MSG_CHECKING(for struct timeval in sys/time.h and time.h)
1070AC_CACHE_VAL(bash_cv_struct_timeval,
1071[
1072AC_EGREP_HEADER(struct timeval, sys/time.h,
1073                bash_cv_struct_timeval=yes,
1074                AC_EGREP_HEADER(struct timeval, time.h,
1075                        bash_cv_struct_timeval=yes,
1076                        bash_cv_struct_timeval=no))
1077])
1078AC_MSG_RESULT($bash_cv_struct_timeval)
1079if test $bash_cv_struct_timeval = yes; then
1080  AC_DEFINE(HAVE_TIMEVAL)
1081fi
1082])
1083
1084AC_DEFUN(BASH_STRUCT_WINSIZE,
1085[AC_MSG_CHECKING(for struct winsize in sys/ioctl.h and termios.h)
1086AC_CACHE_VAL(bash_cv_struct_winsize_header,
1087[AC_TRY_COMPILE([#include <sys/types.h>
1088#include <sys/ioctl.h>], [struct winsize x;],
1089  bash_cv_struct_winsize_header=ioctl_h,
1090  [AC_TRY_COMPILE([#include <sys/types.h>
1091#include <termios.h>], [struct winsize x;],
1092  bash_cv_struct_winsize_header=termios_h, bash_cv_struct_winsize_header=other)
1093])])
1094if test $bash_cv_struct_winsize_header = ioctl_h; then
1095  AC_MSG_RESULT(sys/ioctl.h)
1096  AC_DEFINE(STRUCT_WINSIZE_IN_SYS_IOCTL)
1097elif test $bash_cv_struct_winsize_header = termios_h; then
1098  AC_MSG_RESULT(termios.h)
1099  AC_DEFINE(STRUCT_WINSIZE_IN_TERMIOS)
1100else
1101  AC_MSG_RESULT(not found)
1102fi
1103])
1104
1105dnl Check type of signal routines (posix, 4.2bsd, 4.1bsd or v7)
1106AC_DEFUN(BASH_SYS_SIGNAL_VINTAGE,
[12991]1107[AC_REQUIRE([AC_TYPE_SIGNAL])
[17009]1108AC_MSG_CHECKING(for type of signal functions)
1109AC_CACHE_VAL(bash_cv_signal_vintage,
1110[
1111  AC_TRY_LINK([#include <signal.h>],[
1112    sigset_t ss;
1113    struct sigaction sa;
1114    sigemptyset(&ss); sigsuspend(&ss);
1115    sigaction(SIGINT, &sa, (struct sigaction *) 0);
1116    sigprocmask(SIG_BLOCK, &ss, (sigset_t *) 0);
1117  ], bash_cv_signal_vintage=posix,
1118  [
1119    AC_TRY_LINK([#include <signal.h>], [
1120        int mask = sigmask(SIGINT);
1121        sigsetmask(mask); sigblock(mask); sigpause(mask);
1122    ], bash_cv_signal_vintage=4.2bsd,
1123    [
1124      AC_TRY_LINK([
1125        #include <signal.h>
1126        RETSIGTYPE foo() { }], [
1127                int mask = sigmask(SIGINT);
1128                sigset(SIGINT, foo); sigrelse(SIGINT);
1129                sighold(SIGINT); sigpause(SIGINT);
1130        ], bash_cv_signal_vintage=svr3, bash_cv_signal_vintage=v7
1131    )]
1132  )]
1133)
1134])
1135AC_MSG_RESULT($bash_cv_signal_vintage)
1136if test "$bash_cv_signal_vintage" = posix; then
1137AC_DEFINE(HAVE_POSIX_SIGNALS)
1138elif test "$bash_cv_signal_vintage" = "4.2bsd"; then
1139AC_DEFINE(HAVE_BSD_SIGNALS)
1140elif test "$bash_cv_signal_vintage" = svr3; then
1141AC_DEFINE(HAVE_USG_SIGHOLD)
1142fi
1143])
1144
1145dnl Check if the pgrp of setpgrp() can't be the pid of a zombie process.
1146AC_DEFUN(BASH_SYS_PGRP_SYNC,
1147[AC_REQUIRE([AC_FUNC_GETPGRP])
1148AC_MSG_CHECKING(whether pgrps need synchronization)
1149AC_CACHE_VAL(bash_cv_pgrp_pipe,
1150[AC_TRY_RUN([
1151#ifdef HAVE_UNISTD_H
1152#  include <unistd.h>
1153#endif
1154main()
1155{
1156# ifdef GETPGRP_VOID
1157#  define getpgID()     getpgrp()
1158# else
1159#  define getpgID()     getpgrp(0)
1160#  define setpgid(x,y)  setpgrp(x,y)
1161# endif
1162        int pid1, pid2, fds[2];
1163        int status;
1164        char ok;
1165
1166        switch (pid1 = fork()) {
1167          case -1:
1168            exit(1);
1169          case 0:
1170            setpgid(0, getpid());
1171            exit(0);
1172        }
1173        setpgid(pid1, pid1);
1174
1175        sleep(2);       /* let first child die */
1176
1177        if (pipe(fds) < 0)
1178          exit(2);
1179
1180        switch (pid2 = fork()) {
1181          case -1:
1182            exit(3);
1183          case 0:
1184            setpgid(0, pid1);
1185            ok = getpgID() == pid1;
1186            write(fds[1], &ok, 1);
1187            exit(0);
1188        }
1189        setpgid(pid2, pid1);
1190
1191        close(fds[1]);
1192        if (read(fds[0], &ok, 1) != 1)
1193          exit(4);
1194        wait(&status);
1195        wait(&status);
1196        exit(ok ? 0 : 5);
1197}
1198], bash_cv_pgrp_pipe=no,bash_cv_pgrp_pipe=yes,
1199   [AC_MSG_WARN(cannot check pgrp synchronization if cross compiling -- defaulting to no)
1200    bash_cv_pgrp_pipe=no])
1201])
1202AC_MSG_RESULT($bash_cv_pgrp_pipe)
1203if test $bash_cv_pgrp_pipe = yes; then
1204AC_DEFINE(PGRP_PIPE)
1205fi
1206])
1207
1208AC_DEFUN(BASH_SYS_REINSTALL_SIGHANDLERS,
1209[AC_REQUIRE([AC_TYPE_SIGNAL])
1210AC_REQUIRE([BASH_SYS_SIGNAL_VINTAGE])
[12991]1211AC_MSG_CHECKING([if signal handlers must be reinstalled when invoked])
1212AC_CACHE_VAL(bash_cv_must_reinstall_sighandlers,
1213[AC_TRY_RUN([
1214#include <signal.h>
1215#ifdef HAVE_UNISTD_H
1216#include <unistd.h>
1217#endif
1218
1219typedef RETSIGTYPE sigfunc();
1220
1221int nsigint;
1222
1223#ifdef HAVE_POSIX_SIGNALS
1224sigfunc *
1225set_signal_handler(sig, handler)
1226     int sig;
1227     sigfunc *handler;
1228{
1229  struct sigaction act, oact;
1230  act.sa_handler = handler;
1231  act.sa_flags = 0;
1232  sigemptyset (&act.sa_mask);
1233  sigemptyset (&oact.sa_mask);
1234  sigaction (sig, &act, &oact);
1235  return (oact.sa_handler);
1236}
1237#else
1238#define set_signal_handler(s, h) signal(s, h)
1239#endif
1240
1241RETSIGTYPE
1242sigint(s)
1243int s;
1244{
1245  nsigint++;
1246}
1247
1248main()
1249{
1250        nsigint = 0;
1251        set_signal_handler(SIGINT, sigint);
1252        kill((int)getpid(), SIGINT);
1253        kill((int)getpid(), SIGINT);
1254        exit(nsigint != 2);
1255}
1256], bash_cv_must_reinstall_sighandlers=no, bash_cv_must_reinstall_sighandlers=yes,
1257   [AC_MSG_WARN(cannot check signal handling if cross compiling -- defaulting to no)
1258    bash_cv_must_reinstall_sighandlers=no]
1259)])
1260AC_MSG_RESULT($bash_cv_must_reinstall_sighandlers)
1261if test $bash_cv_must_reinstall_sighandlers = yes; then
1262AC_DEFINE(MUST_REINSTALL_SIGHANDLERS)
1263fi
1264])
1265
1266dnl check that some necessary job control definitions are present
[17009]1267AC_DEFUN(BASH_SYS_JOB_CONTROL_MISSING,
1268[AC_REQUIRE([BASH_SYS_SIGNAL_VINTAGE])
[12991]1269AC_MSG_CHECKING(for presence of necessary job control definitions)
1270AC_CACHE_VAL(bash_cv_job_control_missing,
1271[AC_TRY_RUN([
1272#include <sys/types.h>
1273#ifdef HAVE_SYS_WAIT_H
1274#include <sys/wait.h>
1275#endif
1276#ifdef HAVE_UNISTD_H
1277#include <unistd.h>
1278#endif
1279#include <signal.h>
1280
1281/* Add more tests in here as appropriate. */
1282main()
1283{
1284/* signal type */
1285#if !defined (HAVE_POSIX_SIGNALS) && !defined (HAVE_BSD_SIGNALS)
1286exit(1);
1287#endif
1288
1289/* signals and tty control. */
1290#if !defined (SIGTSTP) || !defined (SIGSTOP) || !defined (SIGCONT)
1291exit (1);
1292#endif
1293
1294/* process control */
1295#if !defined (WNOHANG) || !defined (WUNTRACED)
1296exit(1);
1297#endif
1298
1299/* Posix systems have tcgetpgrp and waitpid. */
1300#if defined (_POSIX_VERSION) && !defined (HAVE_TCGETPGRP)
1301exit(1);
1302#endif
1303
1304#if defined (_POSIX_VERSION) && !defined (HAVE_WAITPID)
1305exit(1);
1306#endif
1307
1308/* Other systems have TIOCSPGRP/TIOCGPRGP and wait3. */
1309#if !defined (_POSIX_VERSION) && !defined (HAVE_WAIT3)
1310exit(1);
1311#endif
1312
1313exit(0);
1314}], bash_cv_job_control_missing=present, bash_cv_job_control_missing=missing,
1315    [AC_MSG_WARN(cannot check job control if cross-compiling -- defaulting to missing)
1316     bash_cv_job_control_missing=missing]
1317)])
1318AC_MSG_RESULT($bash_cv_job_control_missing)
1319if test $bash_cv_job_control_missing = missing; then
1320AC_DEFINE(JOB_CONTROL_MISSING)
1321fi
1322])
1323
1324dnl check whether named pipes are present
1325dnl this requires a previous check for mkfifo, but that is awkward to specify
1326AC_DEFUN(BASH_SYS_NAMED_PIPES,
1327[AC_MSG_CHECKING(for presence of named pipes)
1328AC_CACHE_VAL(bash_cv_sys_named_pipes,
1329[AC_TRY_RUN([
1330#include <sys/types.h>
1331#include <sys/stat.h>
1332#ifdef HAVE_UNISTD_H
1333#include <unistd.h>
1334#endif
1335
1336/* Add more tests in here as appropriate. */
1337main()
1338{
[15409]1339int fd, err;
[12991]1340
1341#if defined (HAVE_MKFIFO)
1342exit (0);
1343#endif
1344
1345#if !defined (S_IFIFO) && (defined (_POSIX_VERSION) && !defined (S_ISFIFO))
1346exit (1);
1347#endif
1348
1349#if defined (NeXT)
1350exit (1);
1351#endif
[15409]1352err = mkdir("/tmp/bash-aclocal", 0700);
1353if (err < 0) {
1354  perror ("mkdir");
1355  exit(1);
1356}
1357fd = mknod ("/tmp/bash-aclocal/sh-np-autoconf", 0666 | S_IFIFO, 0);
1358if (fd == -1) {
1359  rmdir ("/tmp/bash-aclocal");
[12991]1360  exit (1);
[15409]1361}
[12991]1362close(fd);
[15409]1363unlink ("/tmp/bash-aclocal/sh-np-autoconf");
1364rmdir ("/tmp/bash-aclocal");
[12991]1365exit(0);
1366}], bash_cv_sys_named_pipes=present, bash_cv_sys_named_pipes=missing,
1367    [AC_MSG_WARN(cannot check for named pipes if cross-compiling -- defaulting to missing)
1368     bash_cv_sys_named_pipes=missing]
1369)])
1370AC_MSG_RESULT($bash_cv_sys_named_pipes)
1371if test $bash_cv_sys_named_pipes = missing; then
1372AC_DEFINE(NAMED_PIPES_MISSING)
1373fi
1374])
1375
[17009]1376AC_DEFUN(BASH_SYS_DEFAULT_MAIL_DIR,
1377[AC_MSG_CHECKING(for default mail directory)
1378AC_CACHE_VAL(bash_cv_mail_dir,
1379[if test -d /var/mail; then
1380   bash_cv_mail_dir=/var/mail
1381 elif test -d /usr/mail; then
1382   bash_cv_mail_dir=/usr/mail
1383 elif test -d /var/spool/mail; then
1384   bash_cv_mail_dir=/var/spool/mail
1385 elif test -d /usr/spool/mail; then
1386   bash_cv_mail_dir=/usr/spool/mail
1387 else
1388   bash_cv_mail_dir=unknown
1389 fi
1390])
1391AC_MSG_RESULT($bash_cv_mail_dir)
1392if test $bash_cv_mail_dir = "/var/mail"; then
1393   AC_DEFINE(DEFAULT_MAIL_DIRECTORY, "/var/mail")
1394elif test $bash_cv_mail_dir = "/usr/mail"; then
1395   AC_DEFINE(DEFAULT_MAIL_DIRECTORY, "/usr/mail")
1396elif test $bash_cv_mail_dir = "/var/spool/mail"; then
1397   AC_DEFINE(DEFAULT_MAIL_DIRECTORY, "/var/spool/mail")
1398elif test $bash_cv_mail_dir = "/usr/spool/mail"; then
1399   AC_DEFINE(DEFAULT_MAIL_DIRECTORY, "/usr/spool/mail")
1400else
1401   AC_DEFINE(DEFAULT_MAIL_DIRECTORY, "unknown")
[12991]1402fi
1403])
1404
1405AC_DEFUN(BASH_HAVE_TIOCGWINSZ,
1406[AC_MSG_CHECKING(for TIOCGWINSZ in sys/ioctl.h)
1407AC_CACHE_VAL(bash_cv_tiocgwinsz_in_ioctl,
1408[AC_TRY_COMPILE([#include <sys/types.h>
1409#include <sys/ioctl.h>], [int x = TIOCGWINSZ;],
1410  bash_cv_tiocgwinsz_in_ioctl=yes,bash_cv_tiocgwinsz_in_ioctl=no)])
1411AC_MSG_RESULT($bash_cv_tiocgwinsz_in_ioctl)
1412if test $bash_cv_tiocgwinsz_in_ioctl = yes; then   
1413AC_DEFINE(GWINSZ_IN_SYS_IOCTL)
1414fi
1415])
1416
1417AC_DEFUN(BASH_HAVE_TIOCSTAT,
1418[AC_MSG_CHECKING(for TIOCSTAT in sys/ioctl.h)
1419AC_CACHE_VAL(bash_cv_tiocstat_in_ioctl,
1420[AC_TRY_COMPILE([#include <sys/types.h>
1421#include <sys/ioctl.h>], [int x = TIOCSTAT;],
1422  bash_cv_tiocstat_in_ioctl=yes,bash_cv_tiocstat_in_ioctl=no)])
1423AC_MSG_RESULT($bash_cv_tiocstat_in_ioctl)
1424if test $bash_cv_tiocstat_in_ioctl = yes; then   
1425AC_DEFINE(TIOCSTAT_IN_SYS_IOCTL)
1426fi
1427])
1428
1429AC_DEFUN(BASH_HAVE_FIONREAD,
1430[AC_MSG_CHECKING(for FIONREAD in sys/ioctl.h)
1431AC_CACHE_VAL(bash_cv_fionread_in_ioctl,
1432[AC_TRY_COMPILE([#include <sys/types.h>
1433#include <sys/ioctl.h>], [int x = FIONREAD;],
1434  bash_cv_fionread_in_ioctl=yes,bash_cv_fionread_in_ioctl=no)])
1435AC_MSG_RESULT($bash_cv_fionread_in_ioctl)
1436if test $bash_cv_fionread_in_ioctl = yes; then   
1437AC_DEFINE(FIONREAD_IN_SYS_IOCTL)
1438fi
1439])
1440
1441dnl
1442dnl See if speed_t is declared in <sys/types.h>.  Some versions of linux
1443dnl require a definition of speed_t each time <termcap.h> is included,
1444dnl but you can only get speed_t if you include <termios.h> (on some
1445dnl versions) or <sys/types.h> (on others).
1446dnl
[17009]1447AC_DEFUN(BASH_CHECK_SPEED_T,
[12991]1448[AC_MSG_CHECKING(for speed_t in sys/types.h)
1449AC_CACHE_VAL(bash_cv_speed_t_in_sys_types,
1450[AC_TRY_COMPILE([#include <sys/types.h>], [speed_t x;],
1451  bash_cv_speed_t_in_sys_types=yes,bash_cv_speed_t_in_sys_types=no)])
1452AC_MSG_RESULT($bash_cv_speed_t_in_sys_types)
1453if test $bash_cv_speed_t_in_sys_types = yes; then   
1454AC_DEFINE(SPEED_T_IN_SYS_TYPES)
1455fi
1456])
1457
1458AC_DEFUN(BASH_CHECK_GETPW_FUNCS,
[17009]1459[AC_MSG_CHECKING(whether getpw functions are declared in pwd.h)
1460AC_CACHE_VAL(bash_cv_getpw_declared,
1461[AC_EGREP_CPP(getpwuid,
1462[
1463#include <sys/types.h>
1464#ifdef HAVE_UNISTD_H
1465#  include <unistd.h>
1466#endif
[12991]1467#include <pwd.h>
[17009]1468],
1469bash_cv_getpw_declared=yes,bash_cv_getpw_declared=no)])
1470AC_MSG_RESULT($bash_cv_getpw_declared)
1471if test $bash_cv_getpw_declared = yes; then
[12991]1472AC_DEFINE(HAVE_GETPW_DECLS)
1473fi
1474])
1475
1476AC_DEFUN(BASH_CHECK_DEV_FD,
1477[AC_MSG_CHECKING(whether /dev/fd is available)
1478AC_CACHE_VAL(bash_cv_dev_fd,
1479[if test -d /dev/fd  && test -r /dev/fd/0; then
1480   bash_cv_dev_fd=standard
1481 elif test -d /proc/self/fd && test -r /proc/self/fd/0; then
1482   bash_cv_dev_fd=whacky
1483 else
1484   bash_cv_dev_fd=absent
1485 fi
1486])
1487AC_MSG_RESULT($bash_cv_dev_fd)
1488if test $bash_cv_dev_fd = "standard"; then
1489  AC_DEFINE(HAVE_DEV_FD)
1490  AC_DEFINE(DEV_FD_PREFIX, "/dev/fd/")
1491elif test $bash_cv_dev_fd = "whacky"; then
1492  AC_DEFINE(HAVE_DEV_FD)
1493  AC_DEFINE(DEV_FD_PREFIX, "/proc/self/fd/")
1494fi
1495])
1496
[15409]1497AC_DEFUN(BASH_CHECK_DEV_STDIN,
1498[AC_MSG_CHECKING(whether /dev/stdin stdout stderr are available)
1499AC_CACHE_VAL(bash_cv_dev_stdin,
1500[if test -d /dev/fd && test -r /dev/stdin; then
1501   bash_cv_dev_stdin=present
1502 elif test -d /proc/self/fd && test -r /dev/stdin; then
1503   bash_cv_dev_stdin=present
1504 else
1505   bash_cv_dev_stdin=absent
1506 fi
1507])
1508AC_MSG_RESULT($bash_cv_dev_stdin)
1509if test $bash_cv_dev_stdin = "present"; then
1510  AC_DEFINE(HAVE_DEV_STDIN)
1511fi
1512])
1513
[12991]1514dnl
1515dnl Check if HPUX needs _KERNEL defined for RLIMIT_* definitions
1516dnl
[17009]1517AC_DEFUN(BASH_CHECK_KERNEL_RLIMIT,
[12991]1518[AC_MSG_CHECKING([whether $host_os needs _KERNEL for RLIMIT defines])
1519AC_CACHE_VAL(bash_cv_kernel_rlimit,
1520[AC_TRY_COMPILE([
1521#include <sys/types.h>
1522#include <sys/resource.h>
1523],
1524[
1525  int f;
1526  f = RLIMIT_DATA;
1527], bash_cv_kernel_rlimit=no,
1528[AC_TRY_COMPILE([
1529#include <sys/types.h>
1530#define _KERNEL
1531#include <sys/resource.h>
1532#undef _KERNEL
1533],
1534[
1535        int f;
1536        f = RLIMIT_DATA;
1537], bash_cv_kernel_rlimit=yes, bash_cv_kernel_rlimit=no)]
1538)])
1539AC_MSG_RESULT($bash_cv_kernel_rlimit)
1540if test $bash_cv_kernel_rlimit = yes; then
1541AC_DEFINE(RLIMIT_NEEDS_KERNEL)
1542fi
1543])
1544
1545dnl
1546dnl Check for 64-bit off_t -- used for malloc alignment
1547dnl
1548dnl C does not allow duplicate case labels, so the compile will fail if
1549dnl sizeof(off_t) is > 4.
1550dnl
1551AC_DEFUN(BASH_CHECK_OFF_T_64,
1552[AC_CACHE_CHECK(for 64-bit off_t, bash_cv_off_t_64,
1553AC_TRY_COMPILE([
1554#ifdef HAVE_UNISTD_H
1555#include <unistd.h>
1556#endif
1557#include <sys/types.h>
1558],[
1559switch (0) case 0: case (sizeof (off_t) <= 4):;
1560], bash_cv_off_t_64=no, bash_cv_off_t_64=yes))
1561if test $bash_cv_off_t_64 = yes; then
1562        AC_DEFINE(HAVE_OFF_T_64)
1563fi])
[15409]1564
[17009]1565AC_DEFUN(BASH_CHECK_RTSIGS,
1566[AC_MSG_CHECKING(for unusable real-time signals due to large values)
1567AC_CACHE_VAL(bash_cv_unusable_rtsigs,
1568[AC_TRY_RUN([
1569#include <sys/types.h>
1570#include <signal.h>
1571
1572#ifndef NSIG
1573#  define NSIG 64
1574#endif
1575
1576main ()
1577{
1578  int n_sigs = 2 * NSIG;
1579#ifdef SIGRTMIN
1580  int rtmin = SIGRTMIN;
1581#else
1582  int rtmin = 0;
1583#endif
1584
1585  exit(rtmin < n_sigs);
1586}], bash_cv_unusable_rtsigs=yes, bash_cv_unusable_rtsigs=no,
1587    [AC_MSG_WARN(cannot check real-time signals if cross compiling -- defaulting to yes)
1588     bash_cv_unusable_rtsigs=yes]
1589)])
1590AC_MSG_RESULT($bash_cv_unusable_rtsigs)
1591if test $bash_cv_unusable_rtsigs = yes; then
1592AC_DEFINE(UNUSABLE_RT_SIGNALS)
1593fi
1594])
1595
1596dnl need: prefix exec_prefix libdir includedir CC TERMCAP_LIB
1597dnl require:
1598dnl     AC_PROG_CC
1599dnl     BASH_CHECK_LIB_TERMCAP
1600
1601AC_DEFUN(RL_LIB_READLINE_VERSION,
[15409]1602[
[17009]1603AC_REQUIRE([BASH_CHECK_LIB_TERMCAP])
1604
1605AC_MSG_CHECKING([version of installed readline library])
1606
1607# What a pain in the ass this is.
1608
1609# save cpp and ld options
1610_save_CFLAGS="$CFLAGS"
1611_save_LDFLAGS="$LDFLAGS"
1612_save_LIBS="$LIBS"
1613
1614# Don't set ac_cv_rl_prefix if the caller has already assigned a value.  This
1615# allows the caller to do something like $_rl_prefix=$withval if the user
1616# specifies --with-installed-readline=PREFIX as an argument to configure
1617
1618if test -z "$ac_cv_rl_prefix"; then
1619test "x$prefix" = xNONE && ac_cv_rl_prefix=$ac_default_prefix || ac_cv_rl_prefix=${prefix}
[15409]1620fi
[17009]1621
1622eval ac_cv_rl_includedir=${ac_cv_rl_prefix}/include
1623eval ac_cv_rl_libdir=${ac_cv_rl_prefix}/lib
1624
1625LIBS="$LIBS -lreadline ${TERMCAP_LIB}"
1626CFLAGS="$CFLAGS -I${ac_cv_rl_includedir}"
1627LDFLAGS="$LDFLAGS -L${ac_cv_rl_libdir}"
1628
1629AC_TRY_RUN([
1630#include <stdio.h>
1631#include <readline/readline.h>
1632
1633main()
1634{
1635        FILE *fp;
1636        fp = fopen("conftest.rlv", "w");
1637        if (fp == 0) exit(1);
1638        fprintf(fp, "%s\n", rl_library_version ? rl_library_version : "0.0");
1639        fclose(fp);
1640        exit(0);
1641}
1642],
1643ac_cv_rl_version=`cat conftest.rlv`,
1644ac_cv_rl_version='0.0',
1645ac_cv_rl_version='4.2')
1646
1647CFLAGS="$_save_CFLAGS"
1648LDFLAGS="$_save_LDFLAGS"
1649LIBS="$_save_LIBS"
1650
1651RL_MAJOR=0
1652RL_MINOR=0
1653
1654# (
1655case "$ac_cv_rl_version" in
16562*|3*|4*|5*|6*|7*|8*|9*)
1657        RL_MAJOR=`echo $ac_cv_rl_version | sed 's:\..*$::'`
1658        RL_MINOR=`echo $ac_cv_rl_version | sed -e 's:^.*\.::' -e 's:[a-zA-Z]*$::'`
1659        ;;
1660esac
1661
1662# (((
1663case $RL_MAJOR in
1664[[0-9][0-9]])   _RL_MAJOR=$RL_MAJOR ;;
1665[[0-9]])        _RL_MAJOR=0$RL_MAJOR ;;
1666*)              _RL_MAJOR=00 ;;
1667esac
1668
1669# (((
1670case $RL_MINOR in
1671[[0-9][0-9]])   _RL_MINOR=$RL_MINOR ;;
1672[[0-9]])        _RL_MINOR=0$RL_MINOR ;;
1673*)              _RL_MINOR=00 ;;
1674esac
1675
1676RL_VERSION="0x${_RL_MAJOR}${_RL_MINOR}"
1677
1678# Readline versions greater than 4.2 have these defines in readline.h
1679
1680if test $ac_cv_rl_version = '0.0' ; then
1681        AC_MSG_WARN([Could not test version of installed readline library.])
1682elif test $RL_MAJOR -gt 4 || { test $RL_MAJOR = 4 && test $RL_MINOR -gt 2 ; } ; then
1683        # set these for use by the caller
1684        RL_PREFIX=$ac_cv_rl_prefix
1685        RL_LIBDIR=$ac_cv_rl_libdir
1686        RL_INCLUDEDIR=$ac_cv_rl_includedir
1687        AC_MSG_RESULT($ac_cv_rl_version)
1688else
1689
1690AC_DEFINE_UNQUOTED(RL_READLINE_VERSION, $RL_VERSION, [encoded version of the installed readline library])
1691AC_DEFINE_UNQUOTED(RL_VERSION_MAJOR, $RL_MAJOR, [major version of installed readline library])
1692AC_DEFINE_UNQUOTED(RL_VERSION_MINOR, $RL_MINOR, [minor version of installed readline library])
1693
1694AC_SUBST(RL_VERSION)
1695AC_SUBST(RL_MAJOR)
1696AC_SUBST(RL_MINOR)
1697
1698# set these for use by the caller
1699RL_PREFIX=$ac_cv_rl_prefix
1700RL_LIBDIR=$ac_cv_rl_libdir
1701RL_INCLUDEDIR=$ac_cv_rl_includedir
1702
1703AC_MSG_RESULT($ac_cv_rl_version)
1704
1705fi
[15409]1706])
Note: See TracBrowser for help on using the repository browser.