]> git.ipfire.org Git - thirdparty/bash.git/blame - aclocal.m4
Bash-5.2 patch 26: fix typo when specifying readline's custom color prefix
[thirdparty/bash.git] / aclocal.m4
CommitLineData
8868edaf 1dnl
ccc6cda3
JA
2dnl Bash specific tests
3dnl
4dnl Some derived from PDKSH 5.1.3 autoconf tests
5dnl
74091dd4 6dnl Copyright (C) 1987-2021 Free Software Foundation, Inc.
f73dda09 7dnl
ccc6cda3 8
f73dda09
JA
9dnl
10dnl Check for <inttypes.h>. This is separated out so that it can be
11dnl AC_REQUIREd.
12dnl
13dnl BASH_HEADER_INTTYPES
14AC_DEFUN(BASH_HEADER_INTTYPES,
15[
16 AC_CHECK_HEADERS(inttypes.h)
17])
18
ccc6cda3
JA
19dnl
20dnl check for typedef'd symbols in header files, but allow the caller to
21dnl specify the include files to be checked in addition to the default
8868edaf
CR
22dnl
23dnl This could be changed to use AC_COMPILE_IFELSE instead of AC_EGREP_CPP
ccc6cda3
JA
24dnl
25dnl BASH_CHECK_TYPE(TYPE, HEADERS, DEFAULT[, VALUE-IF-FOUND])
26AC_DEFUN(BASH_CHECK_TYPE,
f73dda09 27[
f73dda09 28AC_REQUIRE([BASH_HEADER_INTTYPES])
ccc6cda3
JA
29AC_MSG_CHECKING(for $1)
30AC_CACHE_VAL(bash_cv_type_$1,
31[AC_EGREP_CPP($1, [#include <sys/types.h>
74091dd4 32#if HAVE_STDLIB_H
ccc6cda3 33#include <stdlib.h>
74091dd4
CR
34#endif
35#if HAVE_STDDEF_H
f73dda09
JA
36#include <stddef.h>
37#endif
38#if HAVE_INTTYPES_H
39#include <inttypes.h>
ccc6cda3 40#endif
0001803f
CR
41#if HAVE_STDINT_H
42#include <stdint.h>
43#endif
ccc6cda3
JA
44$2
45], bash_cv_type_$1=yes, bash_cv_type_$1=no)])
46AC_MSG_RESULT($bash_cv_type_$1)
47ifelse($#, 4, [if test $bash_cv_type_$1 = yes; then
48 AC_DEFINE($4)
49 fi])
50if test $bash_cv_type_$1 = no; then
f73dda09 51 AC_DEFINE_UNQUOTED($1, $3)
ccc6cda3
JA
52fi
53])
54
55dnl
f73dda09 56dnl BASH_CHECK_DECL(FUNC)
ccc6cda3 57dnl
f73dda09
JA
58dnl Check for a declaration of FUNC in stdlib.h and inttypes.h like
59dnl AC_CHECK_DECL
60dnl
61AC_DEFUN(BASH_CHECK_DECL,
62[
f73dda09 63AC_REQUIRE([BASH_HEADER_INTTYPES])
74091dd4 64AC_CHECK_DECLS([$1])
f73dda09
JA
65])
66
67AC_DEFUN(BASH_DECL_PRINTF,
68[AC_MSG_CHECKING(for declaration of printf in <stdio.h>)
69AC_CACHE_VAL(bash_cv_printf_declared,
74091dd4 70[AC_RUN_IFELSE([AC_LANG_SOURCE([[
f73dda09
JA
71#include <stdio.h>
72#ifdef __STDC__
73typedef int (*_bashfunc)(const char *, ...);
74#else
75typedef int (*_bashfunc)();
76#endif
8868edaf
CR
77#include <stdlib.h>
78int
ccc6cda3
JA
79main()
80{
f73dda09
JA
81_bashfunc pf;
82pf = (_bashfunc) printf;
83exit(pf == 0);
84}
74091dd4 85]])], [bash_cv_printf_declared=yes], [bash_cv_printf_declared=no],
f73dda09
JA
86 [AC_MSG_WARN(cannot check printf declaration if cross compiling -- defaulting to yes)
87 bash_cv_printf_declared=yes]
88)])
89AC_MSG_RESULT($bash_cv_printf_declared)
90if test $bash_cv_printf_declared = yes; then
91AC_DEFINE(PRINTF_DECLARED)
92fi
ccc6cda3 93])
f73dda09
JA
94
95AC_DEFUN(BASH_DECL_SBRK,
96[AC_MSG_CHECKING(for declaration of sbrk in <unistd.h>)
97AC_CACHE_VAL(bash_cv_sbrk_declared,
98[AC_EGREP_HEADER(sbrk, unistd.h,
99 bash_cv_sbrk_declared=yes, bash_cv_sbrk_declared=no)])
100AC_MSG_RESULT($bash_cv_sbrk_declared)
101if test $bash_cv_sbrk_declared = yes; then
102AC_DEFINE(SBRK_DECLARED)
ccc6cda3
JA
103fi
104])
105
106dnl
107dnl Check for sys_siglist[] or _sys_siglist[]
108dnl
e8ce775d
JA
109AC_DEFUN(BASH_DECL_UNDER_SYS_SIGLIST,
110[AC_MSG_CHECKING([for _sys_siglist in signal.h or unistd.h])
111AC_CACHE_VAL(bash_cv_decl_under_sys_siglist,
74091dd4 112[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
e8ce775d
JA
113#include <sys/types.h>
114#include <signal.h>
115#ifdef HAVE_UNISTD_H
116#include <unistd.h>
74091dd4
CR
117#endif]], [[ char *msg = _sys_siglist[2]; ]])],
118 [bash_cv_decl_under_sys_siglist=yes], [bash_cv_decl_under_sys_siglist=no],
b72432fd 119 [AC_MSG_WARN(cannot check for _sys_siglist[] if cross compiling -- defaulting to no)])])dnl
e8ce775d
JA
120AC_MSG_RESULT($bash_cv_decl_under_sys_siglist)
121if test $bash_cv_decl_under_sys_siglist = yes; then
122AC_DEFINE(UNDER_SYS_SIGLIST_DECLARED)
123fi
124])
125
ccc6cda3 126AC_DEFUN(BASH_UNDER_SYS_SIGLIST,
e8ce775d
JA
127[AC_REQUIRE([BASH_DECL_UNDER_SYS_SIGLIST])
128AC_MSG_CHECKING([for _sys_siglist in system C library])
ccc6cda3 129AC_CACHE_VAL(bash_cv_under_sys_siglist,
74091dd4 130[AC_RUN_IFELSE([AC_LANG_SOURCE([[
ccc6cda3
JA
131#include <sys/types.h>
132#include <signal.h>
133#ifdef HAVE_UNISTD_H
134#include <unistd.h>
135#endif
8868edaf 136#include <stdlib.h>
e8ce775d 137#ifndef UNDER_SYS_SIGLIST_DECLARED
ccc6cda3
JA
138extern char *_sys_siglist[];
139#endif
8868edaf 140int
ccc6cda3
JA
141main()
142{
e8ce775d 143char *msg = (char *)_sys_siglist[2];
ccc6cda3 144exit(msg == 0);
74091dd4
CR
145}
146]])],
147 [bash_cv_under_sys_siglist=yes], [bash_cv_under_sys_siglist=no],
b72432fd 148 [AC_MSG_WARN(cannot check for _sys_siglist[] if cross compiling -- defaulting to no)
74091dd4
CR
149 bash_cv_under_sys_siglist=no]
150)])
ccc6cda3
JA
151AC_MSG_RESULT($bash_cv_under_sys_siglist)
152if test $bash_cv_under_sys_siglist = yes; then
153AC_DEFINE(HAVE_UNDER_SYS_SIGLIST)
154fi
155])
156
74091dd4
CR
157dnl this defines HAVE_DECL_SYS_SIGLIST
158AC_DEFUN([BASH_DECL_SYS_SIGLIST],
159[AC_CHECK_DECLS([sys_siglist],,,
160[#include <signal.h>
161/* NetBSD declares sys_siglist in unistd.h. */
162#ifdef HAVE_UNISTD_H
163# include <unistd.h>
164#endif
165])
166])
167
ccc6cda3 168AC_DEFUN(BASH_SYS_SIGLIST,
74091dd4 169[AC_REQUIRE([BASH_DECL_SYS_SIGLIST])
ccc6cda3
JA
170AC_MSG_CHECKING([for sys_siglist in system C library])
171AC_CACHE_VAL(bash_cv_sys_siglist,
74091dd4 172[AC_RUN_IFELSE([AC_LANG_SOURCE([[
ccc6cda3
JA
173#include <sys/types.h>
174#include <signal.h>
175#ifdef HAVE_UNISTD_H
176#include <unistd.h>
177#endif
8868edaf 178#include <stdlib.h>
3185942a 179#if !HAVE_DECL_SYS_SIGLIST
ccc6cda3
JA
180extern char *sys_siglist[];
181#endif
8868edaf 182int
ccc6cda3
JA
183main()
184{
185char *msg = sys_siglist[2];
186exit(msg == 0);
74091dd4
CR
187}
188]])], [bash_cv_sys_siglist=yes], [bash_cv_sys_siglist=no],
b72432fd 189 [AC_MSG_WARN(cannot check for sys_siglist if cross compiling -- defaulting to no)
74091dd4
CR
190 bash_cv_sys_siglist=no]
191)])
ccc6cda3
JA
192AC_MSG_RESULT($bash_cv_sys_siglist)
193if test $bash_cv_sys_siglist = yes; then
194AC_DEFINE(HAVE_SYS_SIGLIST)
195fi
196])
197
f73dda09
JA
198dnl Check for the various permutations of sys_siglist and make sure we
199dnl compile in siglist.o if they're not defined
200AC_DEFUN(BASH_CHECK_SYS_SIGLIST, [
201AC_REQUIRE([BASH_SYS_SIGLIST])
202AC_REQUIRE([BASH_DECL_UNDER_SYS_SIGLIST])
203AC_REQUIRE([BASH_FUNC_STRSIGNAL])
204if test "$bash_cv_sys_siglist" = no && test "$bash_cv_under_sys_siglist" = no && test "$bash_cv_have_strsignal" = no; then
205 SIGLIST_O=siglist.o
206else
207 SIGLIST_O=
208fi
209AC_SUBST([SIGLIST_O])
210])
211
ccc6cda3
JA
212dnl Check for sys_errlist[] and sys_nerr, check for declaration
213AC_DEFUN(BASH_SYS_ERRLIST,
214[AC_MSG_CHECKING([for sys_errlist and sys_nerr])
215AC_CACHE_VAL(bash_cv_sys_errlist,
74091dd4
CR
216[AC_LINK_IFELSE([AC_LANG_PROGRAM([[
217#include <errno.h>
218]],[[
219extern char *sys_errlist[];
220extern int sys_nerr;
221char *msg = sys_errlist[sys_nerr - 1];
222]] )],
223[bash_cv_sys_errlist=yes], [bash_cv_sys_errlist=no]
224)])
ccc6cda3
JA
225AC_MSG_RESULT($bash_cv_sys_errlist)
226if test $bash_cv_sys_errlist = yes; then
227AC_DEFINE(HAVE_SYS_ERRLIST)
228fi
229])
230
f73dda09
JA
231dnl
232dnl Check if dup2() does not clear the close on exec flag
233dnl
234AC_DEFUN(BASH_FUNC_DUP2_CLOEXEC_CHECK,
235[AC_MSG_CHECKING(if dup2 fails to clear the close-on-exec flag)
236AC_CACHE_VAL(bash_cv_dup2_broken,
74091dd4 237[AC_RUN_IFELSE([AC_LANG_SOURCE([[
f73dda09
JA
238#include <sys/types.h>
239#include <fcntl.h>
8868edaf
CR
240#include <stdlib.h>
241int
f73dda09
JA
242main()
243{
244 int fd1, fd2, fl;
245 fd1 = open("/dev/null", 2);
246 if (fcntl(fd1, 2, 1) < 0)
247 exit(1);
248 fd2 = dup2(fd1, 1);
249 if (fd2 < 0)
250 exit(2);
251 fl = fcntl(fd2, 1, 0);
252 /* fl will be 1 if dup2 did not reset the close-on-exec flag. */
253 exit(fl != 1);
254}
74091dd4 255]])], [bash_cv_dup2_broken=yes], [bash_cv_dup2_broken=no],
f73dda09 256 [AC_MSG_WARN(cannot check dup2 if cross compiling -- defaulting to no)
74091dd4
CR
257 bash_cv_dup2_broken=no]
258)])
f73dda09
JA
259AC_MSG_RESULT($bash_cv_dup2_broken)
260if test $bash_cv_dup2_broken = yes; then
261AC_DEFINE(DUP2_BROKEN)
262fi
263])
264
265AC_DEFUN(BASH_FUNC_STRSIGNAL,
266[AC_MSG_CHECKING([for the existence of strsignal])
267AC_CACHE_VAL(bash_cv_have_strsignal,
74091dd4
CR
268[AC_LINK_IFELSE(
269 [AC_LANG_PROGRAM([[#include <sys/types.h>
8868edaf 270#include <signal.h>
74091dd4
CR
271#include <string.h>]],
272[[char *s = (char *)strsignal(2);]])],
273 [bash_cv_have_strsignal=yes], [bash_cv_have_strsignal=no])])
f73dda09
JA
274AC_MSG_RESULT($bash_cv_have_strsignal)
275if test $bash_cv_have_strsignal = yes; then
276AC_DEFINE(HAVE_STRSIGNAL)
277fi
278])
279
ccc6cda3
JA
280dnl Check to see if opendir will open non-directories (not a nice thing)
281AC_DEFUN(BASH_FUNC_OPENDIR_CHECK,
282[AC_REQUIRE([AC_HEADER_DIRENT])dnl
283AC_MSG_CHECKING(if opendir() opens non-directories)
284AC_CACHE_VAL(bash_cv_opendir_not_robust,
74091dd4 285[AC_RUN_IFELSE([AC_LANG_SOURCE([[
ccc6cda3
JA
286#include <stdio.h>
287#include <sys/types.h>
288#include <fcntl.h>
289#ifdef HAVE_UNISTD_H
290# include <unistd.h>
291#endif /* HAVE_UNISTD_H */
8868edaf
CR
292#ifdef HAVE_SYS_STAT_H
293#include <sys/stat.h>
294#endif
ccc6cda3
JA
295#if defined(HAVE_DIRENT_H)
296# include <dirent.h>
297#else
298# define dirent direct
299# ifdef HAVE_SYS_NDIR_H
300# include <sys/ndir.h>
301# endif /* SYSNDIR */
302# ifdef HAVE_SYS_DIR_H
303# include <sys/dir.h>
304# endif /* SYSDIR */
305# ifdef HAVE_NDIR_H
306# include <ndir.h>
307# endif
308#endif /* HAVE_DIRENT_H */
8868edaf
CR
309#include <stdlib.h>
310int
ccc6cda3
JA
311main()
312{
313DIR *dir;
bb70624e 314int fd, err;
3185942a 315err = mkdir("bash-aclocal", 0700);
bb70624e
JA
316if (err < 0) {
317 perror("mkdir");
318 exit(1);
319}
3185942a
JA
320unlink("bash-aclocal/not_a_directory");
321fd = open("bash-aclocal/not_a_directory", O_WRONLY|O_CREAT|O_EXCL, 0666);
ccc6cda3
JA
322write(fd, "\n", 1);
323close(fd);
3185942a
JA
324dir = opendir("bash-aclocal/not_a_directory");
325unlink("bash-aclocal/not_a_directory");
326rmdir("bash-aclocal");
ccc6cda3 327exit (dir == 0);
74091dd4
CR
328}
329]])], [bash_cv_opendir_not_robust=yes], [bash_cv_opendir_not_robust=no],
b72432fd 330 [AC_MSG_WARN(cannot check opendir if cross compiling -- defaulting to no)
cce855bc
JA
331 bash_cv_opendir_not_robust=no]
332)])
ccc6cda3
JA
333AC_MSG_RESULT($bash_cv_opendir_not_robust)
334if test $bash_cv_opendir_not_robust = yes; then
335AC_DEFINE(OPENDIR_NOT_ROBUST)
336fi
337])
338
bb70624e
JA
339dnl
340dnl A signed 16-bit integer quantity
341dnl
342AC_DEFUN(BASH_TYPE_BITS16_T,
343[
344if test "$ac_cv_sizeof_short" = 2; then
345 AC_CHECK_TYPE(bits16_t, short)
346elif test "$ac_cv_sizeof_char" = 2; then
347 AC_CHECK_TYPE(bits16_t, char)
348else
349 AC_CHECK_TYPE(bits16_t, short)
350fi
351])
352
353dnl
354dnl An unsigned 16-bit integer quantity
355dnl
356AC_DEFUN(BASH_TYPE_U_BITS16_T,
357[
358if test "$ac_cv_sizeof_short" = 2; then
359 AC_CHECK_TYPE(u_bits16_t, unsigned short)
360elif test "$ac_cv_sizeof_char" = 2; then
361 AC_CHECK_TYPE(u_bits16_t, unsigned char)
362else
363 AC_CHECK_TYPE(u_bits16_t, unsigned short)
364fi
365])
366
367dnl
368dnl A signed 32-bit integer quantity
369dnl
370AC_DEFUN(BASH_TYPE_BITS32_T,
cce855bc 371[
b72432fd 372if test "$ac_cv_sizeof_int" = 4; then
bb70624e 373 AC_CHECK_TYPE(bits32_t, int)
b72432fd 374elif test "$ac_cv_sizeof_long" = 4; then
bb70624e 375 AC_CHECK_TYPE(bits32_t, long)
cce855bc 376else
bb70624e 377 AC_CHECK_TYPE(bits32_t, int)
cce855bc
JA
378fi
379])
380
bb70624e
JA
381dnl
382dnl An unsigned 32-bit integer quantity
383dnl
384AC_DEFUN(BASH_TYPE_U_BITS32_T,
cce855bc 385[
b72432fd 386if test "$ac_cv_sizeof_int" = 4; then
bb70624e 387 AC_CHECK_TYPE(u_bits32_t, unsigned int)
b72432fd 388elif test "$ac_cv_sizeof_long" = 4; then
bb70624e 389 AC_CHECK_TYPE(u_bits32_t, unsigned long)
cce855bc 390else
bb70624e 391 AC_CHECK_TYPE(u_bits32_t, unsigned int)
cce855bc
JA
392fi
393])
394
395AC_DEFUN(BASH_TYPE_PTRDIFF_T,
396[
b72432fd
JA
397if test "$ac_cv_sizeof_int" = "$ac_cv_sizeof_char_p"; then
398 AC_CHECK_TYPE(ptrdiff_t, int)
399elif test "$ac_cv_sizeof_long" = "$ac_cv_sizeof_char_p"; then
400 AC_CHECK_TYPE(ptrdiff_t, long)
f73dda09
JA
401elif test "$ac_cv_type_long_long" = yes && test "$ac_cv_sizeof_long_long" = "$ac_cv_sizeof_char_p"; then
402 AC_CHECK_TYPE(ptrdiff_t, [long long])
cce855bc 403else
b72432fd 404 AC_CHECK_TYPE(ptrdiff_t, int)
cce855bc 405fi
b72432fd
JA
406])
407
bb70624e
JA
408dnl
409dnl A signed 64-bit quantity
410dnl
b72432fd
JA
411AC_DEFUN(BASH_TYPE_BITS64_T,
412[
f73dda09 413if test "$ac_cv_sizeof_char_p" = 8; then
b72432fd
JA
414 AC_CHECK_TYPE(bits64_t, char *)
415elif test "$ac_cv_sizeof_double" = 8; then
416 AC_CHECK_TYPE(bits64_t, double)
f73dda09
JA
417elif test -n "$ac_cv_type_long_long" && test "$ac_cv_sizeof_long_long" = 8; then
418 AC_CHECK_TYPE(bits64_t, [long long])
b72432fd
JA
419elif test "$ac_cv_sizeof_long" = 8; then
420 AC_CHECK_TYPE(bits64_t, long)
cce855bc 421else
b72432fd 422 AC_CHECK_TYPE(bits64_t, double)
cce855bc
JA
423fi
424])
425
74091dd4
CR
426AC_DEFUN(BASH_SIZEOF_RLIMIT,
427[AC_MSG_CHECKING(for size of struct rlimit fields)
428AC_CACHE_VAL(bash_cv_sizeof_rlim_cur,
429[AC_RUN_IFELSE([AC_LANG_SOURCE([[
430#ifdef HAVE_SYS_TIME_H
431#include <sys/time.h>
432#endif
433#include <stdlib.h>
434#include <sys/resource.h>
435main()
436{
437struct rlimit r;
438exit(sizeof (r.rlim_cur));
439}
440]])], [bash_cv_sizeof_rlim_cur=$?], [bash_cv_sizeof_rlim_cur=$?],
441 [AC_MSG_WARN(cannot check size of rlimit fields if cross compiling -- defaulting to long)
442 bash_cv_sizeof_rlim_cur=$ac_cv_sizeof_long]
443)])
444AC_MSG_RESULT($bash_cv_sizeof_rlim_cur)
f73dda09
JA
445])
446
74091dd4
CR
447AC_DEFUN(BASH_SIZEOF_QUAD_T,
448[AC_MSG_CHECKING(for size of quad_t)
449AC_CACHE_VAL(bash_cv_sizeof_quad_t,
450[AC_RUN_IFELSE([AC_LANG_SOURCE([[
451#include <sys/types.h>
452#include <stdlib.h>
453#if HAVE_INTTYPES_H
454#include <inttypes.h>
455#endif
456#if HAVE_STDINT_H
457#include <stdint.h>
458#endif
459
460main()
461{
462#if HAVE_QUAD_T
463quad_t x;
464exit(sizeof (x));
465#else
466exit (0);
467#endif
468}
469]])], [bash_cv_sizeof_quad_t=$?], [bash_cv_sizeof_quad_t=$?],
470 [AC_MSG_WARN(cannot check size of quad_t if cross compiling -- defaulting to 0)
471 bash_cv_sizeof_quad_t=0]
472)])
473AC_MSG_RESULT($bash_cv_sizeof_quad_t)
f73dda09
JA
474])
475
476dnl
74091dd4
CR
477dnl Type of struct rlimit fields: updated to check POSIX rlim_t and
478dnl if it doesn't exist determine the best guess based on sizeof(r.rlim_cur)
f73dda09
JA
479dnl
480AC_DEFUN(BASH_TYPE_RLIMIT,
74091dd4 481[AC_MSG_CHECKING(for type of struct rlimit fields)
f73dda09 482AC_CACHE_VAL(bash_cv_type_rlimit,
74091dd4 483[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
f73dda09 484#include <sys/types.h>
74091dd4
CR
485#include <sys/resource.h>]],
486[[rlim_t xxx;]]
487)],
488 [bash_cv_type_rlimit=rlim_t], [
489BASH_SIZEOF_RLIMIT
490BASH_SIZEOF_QUAD_T
491if test $bash_cv_sizeof_rlim_cur = $ac_cv_sizeof_long; then
492 bash_cv_type_rlimit='unsigned long'
493elif test $bash_cv_sizeof_rlim_cur = $ac_cv_sizeof_long_long; then
494 bash_cv_type_rlimit='unsigned long long'
495elif test $bash_cv_sizeof_rlim_cur = $ac_cv_sizeof_int; then
496 bash_cv_type_rlimit='unsigned int'
497elif test $bash_cv_sizeof_rlim_cur = $bash_cv_sizeof_quad_t; then
498 bash_cv_type_rlimit='quad_t'
499else
500 bash_cv_type_rlimit='unsigned long'
ccc6cda3 501fi
74091dd4
CR
502]
503)])
504AC_MSG_RESULT($bash_cv_type_rlimit)
505AC_DEFINE_UNQUOTED([RLIMTYPE], [$bash_cv_type_rlimit])
ccc6cda3
JA
506])
507
17345e5a
JA
508AC_DEFUN(BASH_TYPE_SIG_ATOMIC_T,
509[AC_CACHE_CHECK([for sig_atomic_t in signal.h], ac_cv_have_sig_atomic_t,
74091dd4
CR
510[AC_LINK_IFELSE(
511 [AC_LANG_PROGRAM(
512 [[ #include <signal.h> ]],
513 [[ sig_atomic_t x; ]])],
514 [ac_cv_have_sig_atomic_t=yes],[ac_cv_have_sig_atomic_t=no])])
17345e5a
JA
515if test "$ac_cv_have_sig_atomic_t" = "no"
516then
74091dd4 517 BASH_CHECK_TYPE(sig_atomic_t, [#include <signal.h>], int)
17345e5a
JA
518fi
519])
520
ccc6cda3
JA
521AC_DEFUN(BASH_FUNC_LSTAT,
522[dnl Cannot use AC_CHECK_FUNCS(lstat) because Linux defines lstat() as an
523dnl inline function in <sys/stat.h>.
524AC_CACHE_CHECK([for lstat], bash_cv_func_lstat,
74091dd4
CR
525[AC_LINK_IFELSE(
526 [AC_LANG_PROGRAM([[
527 #include <sys/types.h>
528 #include <sys/stat.h>
529 ]],
530 [[ lstat(".",(struct stat *)0); ]])],
531 [bash_cv_func_lstat=yes],[bash_cv_func_lstat=no])])
ccc6cda3
JA
532if test $bash_cv_func_lstat = yes; then
533 AC_DEFINE(HAVE_LSTAT)
534fi
535])
536
bb70624e
JA
537AC_DEFUN(BASH_FUNC_INET_ATON,
538[
539AC_CACHE_CHECK([for inet_aton], bash_cv_func_inet_aton,
74091dd4 540[AC_LINK_IFELSE([AC_LANG_PROGRAM([[
bb70624e
JA
541#include <sys/types.h>
542#include <netinet/in.h>
543#include <arpa/inet.h>
74091dd4
CR
544struct in_addr ap;]], [[ inet_aton("127.0.0.1", &ap); ]])],
545[bash_cv_func_inet_aton=yes], [bash_cv_func_inet_aton=no])])
bb70624e
JA
546if test $bash_cv_func_inet_aton = yes; then
547 AC_DEFINE(HAVE_INET_ATON)
f73dda09
JA
548else
549 AC_LIBOBJ(inet_aton)
ccc6cda3
JA
550fi
551])
552
553AC_DEFUN(BASH_FUNC_GETENV,
554[AC_MSG_CHECKING(to see if getenv can be redefined)
555AC_CACHE_VAL(bash_cv_getenv_redef,
74091dd4 556[AC_RUN_IFELSE([AC_LANG_SOURCE([[
ccc6cda3
JA
557#ifdef HAVE_UNISTD_H
558# include <unistd.h>
559#endif
8868edaf 560#include <stdlib.h>
ccc6cda3
JA
561#ifndef __STDC__
562# ifndef const
563# define const
564# endif
565#endif
566char *
567getenv (name)
568#if defined (__linux__) || defined (__bsdi__) || defined (convex)
569 const char *name;
570#else
571 char const *name;
572#endif /* !__linux__ && !__bsdi__ && !convex */
573{
574return "42";
575}
8868edaf 576int
ccc6cda3
JA
577main()
578{
579char *s;
580/* The next allows this program to run, but does not allow bash to link
581 when it redefines getenv. I'm not really interested in figuring out
582 why not. */
583#if defined (NeXT)
584exit(1);
585#endif
586s = getenv("ABCDE");
587exit(s == 0); /* force optimizer to leave getenv in */
588}
74091dd4 589]])], [bash_cv_getenv_redef=yes], [bash_cv_getenv_redef=no],
b72432fd 590 [AC_MSG_WARN(cannot check getenv redefinition if cross compiling -- defaulting to yes)
cce855bc
JA
591 bash_cv_getenv_redef=yes]
592)])
ccc6cda3
JA
593AC_MSG_RESULT($bash_cv_getenv_redef)
594if test $bash_cv_getenv_redef = yes; then
595AC_DEFINE(CAN_REDEFINE_GETENV)
596fi
597])
598
7117c2d2
JA
599# We should check for putenv before calling this
600AC_DEFUN(BASH_FUNC_STD_PUTENV,
601[
7117c2d2
JA
602AC_REQUIRE([AC_C_PROTOTYPES])
603AC_CACHE_CHECK([for standard-conformant putenv declaration], bash_cv_std_putenv,
74091dd4
CR
604[AC_LINK_IFELSE([AC_LANG_PROGRAM([[
605#if HAVE_STDLIB_H
7117c2d2 606#include <stdlib.h>
74091dd4
CR
607#endif
608#if HAVE_STDDEF_H
7117c2d2
JA
609#include <stddef.h>
610#endif
611#ifndef __STDC__
612# ifndef const
613# define const
614# endif
615#endif
616#ifdef PROTOTYPES
617extern int putenv (char *);
618#else
619extern int putenv ();
620#endif
74091dd4
CR
621]], [[return (putenv == 0);]] )],
622[bash_cv_std_putenv=yes], [bash_cv_std_putenv=no]
7117c2d2
JA
623)])
624if test $bash_cv_std_putenv = yes; then
625AC_DEFINE(HAVE_STD_PUTENV)
626fi
627])
628
629# We should check for unsetenv before calling this
630AC_DEFUN(BASH_FUNC_STD_UNSETENV,
631[
7117c2d2
JA
632AC_REQUIRE([AC_C_PROTOTYPES])
633AC_CACHE_CHECK([for standard-conformant unsetenv declaration], bash_cv_std_unsetenv,
74091dd4
CR
634[AC_LINK_IFELSE([AC_LANG_PROGRAM([[
635#if HAVE_STDLIB_H
7117c2d2 636#include <stdlib.h>
74091dd4
CR
637#endif
638#if HAVE_STDDEF_H
7117c2d2
JA
639#include <stddef.h>
640#endif
641#ifndef __STDC__
642# ifndef const
643# define const
644# endif
645#endif
646#ifdef PROTOTYPES
647extern int unsetenv (const char *);
648#else
649extern int unsetenv ();
650#endif
74091dd4
CR
651]], [[return (unsetenv == 0);]] )],
652[bash_cv_std_unsetenv=yes], [bash_cv_std_unsetenv=no]
7117c2d2
JA
653)])
654if test $bash_cv_std_unsetenv = yes; then
655AC_DEFINE(HAVE_STD_UNSETENV)
656fi
657])
658
ccc6cda3
JA
659AC_DEFUN(BASH_FUNC_ULIMIT_MAXFDS,
660[AC_MSG_CHECKING(whether ulimit can substitute for getdtablesize)
661AC_CACHE_VAL(bash_cv_ulimit_maxfds,
74091dd4 662[AC_RUN_IFELSE([AC_LANG_SOURCE([[
8868edaf
CR
663#include <stdlib.h>
664#ifdef HAVE_ULIMIT_H
665#include <ulimit.h>
666#endif
667int
ccc6cda3
JA
668main()
669{
670long maxfds = ulimit(4, 0L);
671exit (maxfds == -1L);
672}
74091dd4 673]])], [bash_cv_ulimit_maxfds=yes], [bash_cv_ulimit_maxfds=no],
b72432fd 674 [AC_MSG_WARN(cannot check ulimit if cross compiling -- defaulting to no)
cce855bc
JA
675 bash_cv_ulimit_maxfds=no]
676)])
ccc6cda3
JA
677AC_MSG_RESULT($bash_cv_ulimit_maxfds)
678if test $bash_cv_ulimit_maxfds = yes; then
679AC_DEFINE(ULIMIT_MAXFDS)
680fi
681])
682
ccc6cda3 683AC_DEFUN(BASH_FUNC_GETCWD,
3185942a 684[AC_MSG_CHECKING([if getcwd() will dynamically allocate memory with 0 size])
b80f6443 685AC_CACHE_VAL(bash_cv_getcwd_malloc,
74091dd4 686[AC_RUN_IFELSE([AC_LANG_SOURCE([[
ccc6cda3
JA
687#include <stdio.h>
688#ifdef HAVE_UNISTD_H
689#include <unistd.h>
690#endif
8868edaf 691#include <stdlib.h>
ccc6cda3 692
8868edaf 693int
ccc6cda3
JA
694main()
695{
b80f6443
JA
696 char *xpwd;
697 xpwd = getcwd(0, 0);
698 exit (xpwd == 0);
ccc6cda3 699}
74091dd4 700]])], [bash_cv_getcwd_malloc=yes], [bash_cv_getcwd_malloc=no],
b80f6443
JA
701 [AC_MSG_WARN(cannot check whether getcwd allocates memory when cross-compiling -- defaulting to no)
702 bash_cv_getcwd_malloc=no]
cce855bc 703)])
b80f6443
JA
704AC_MSG_RESULT($bash_cv_getcwd_malloc)
705if test $bash_cv_getcwd_malloc = no; then
ccc6cda3 706AC_DEFINE(GETCWD_BROKEN)
f73dda09
JA
707AC_LIBOBJ(getcwd)
708fi
709])
710
711dnl
712dnl This needs BASH_CHECK_SOCKLIB, but since that's not called on every
74091dd4 713dnl system, we can't use AC_PREREQ. Only called if we need the socket library
f73dda09
JA
714dnl
715AC_DEFUN(BASH_FUNC_GETHOSTBYNAME,
716[if test "X$bash_cv_have_gethostbyname" = "X"; then
717_bash_needmsg=yes
718else
719AC_MSG_CHECKING(for gethostbyname in socket library)
720_bash_needmsg=
721fi
722AC_CACHE_VAL(bash_cv_have_gethostbyname,
74091dd4
CR
723[AC_LINK_IFELSE([AC_LANG_PROGRAM([[
724#include <netdb.h>
725]], [[
726struct hostent *hp;
727hp = gethostbyname("localhost");
728]] )],
729[bash_cv_have_gethostbyname=yes], [bash_cv_have_gethostbyname=no]
730)])
f73dda09
JA
731if test "X$_bash_needmsg" = Xyes; then
732 AC_MSG_CHECKING(for gethostbyname in socket library)
733fi
734AC_MSG_RESULT($bash_cv_have_gethostbyname)
735if test "$bash_cv_have_gethostbyname" = yes; then
736AC_DEFINE(HAVE_GETHOSTBYNAME)
737fi
738])
739
740AC_DEFUN(BASH_FUNC_FNMATCH_EXTMATCH,
741[AC_MSG_CHECKING(if fnmatch does extended pattern matching with FNM_EXTMATCH)
742AC_CACHE_VAL(bash_cv_fnm_extmatch,
74091dd4 743[AC_RUN_IFELSE([AC_LANG_SOURCE([[
f73dda09
JA
744#include <fnmatch.h>
745
8868edaf 746int
f73dda09
JA
747main()
748{
749#ifdef FNM_EXTMATCH
8868edaf 750 return (0);
f73dda09 751#else
8868edaf 752 return (1);
f73dda09
JA
753#endif
754}
74091dd4 755]])], [bash_cv_fnm_extmatch=yes], [bash_cv_fnm_extmatch=no],
f73dda09 756 [AC_MSG_WARN(cannot check FNM_EXTMATCH if cross compiling -- defaulting to no)
74091dd4
CR
757 bash_cv_fnm_extmatch=no]
758)])
f73dda09
JA
759AC_MSG_RESULT($bash_cv_fnm_extmatch)
760if test $bash_cv_fnm_extmatch = yes; then
761AC_DEFINE(HAVE_LIBC_FNM_EXTMATCH)
762fi
763])
764
765AC_DEFUN(BASH_FUNC_POSIX_SETJMP,
766[AC_REQUIRE([BASH_SYS_SIGNAL_VINTAGE])
767AC_MSG_CHECKING(for presence of POSIX-style sigsetjmp/siglongjmp)
768AC_CACHE_VAL(bash_cv_func_sigsetjmp,
74091dd4 769[AC_RUN_IFELSE([AC_LANG_SOURCE([[
f73dda09
JA
770#ifdef HAVE_UNISTD_H
771#include <unistd.h>
772#endif
773#include <sys/types.h>
774#include <signal.h>
775#include <setjmp.h>
8868edaf 776#include <stdlib.h>
f73dda09 777
8868edaf 778int
f73dda09
JA
779main()
780{
781#if !defined (_POSIX_VERSION) || !defined (HAVE_POSIX_SIGNALS)
782exit (1);
783#else
784
785int code;
74091dd4 786sigset_t set, oset, nset;
f73dda09
JA
787sigjmp_buf xx;
788
789/* get the mask */
790sigemptyset(&set);
791sigemptyset(&oset);
74091dd4 792
f73dda09 793sigprocmask(SIG_BLOCK, (sigset_t *)NULL, &oset);
74091dd4
CR
794/* paranoia -- make sure SIGINT is not blocked */
795sigdelset (&oset, SIGINT);
796sigprocmask (SIG_SETMASK, &oset, (sigset_t *)NULL);
f73dda09
JA
797
798/* save it */
799code = sigsetjmp(xx, 1);
800if (code)
74091dd4
CR
801{
802 sigprocmask(SIG_BLOCK, (sigset_t *)NULL, &nset);
803 /* could compare nset to oset here, but we just look for SIGINT */
804 if (sigismember (&nset, SIGINT))
805 exit(1);
806 exit(0);
807}
f73dda09 808
74091dd4 809/* change it so that SIGINT is blocked */
f73dda09
JA
810sigaddset(&set, SIGINT);
811sigprocmask(SIG_BLOCK, &set, (sigset_t *)NULL);
812
813/* and siglongjmp */
814siglongjmp(xx, 10);
815exit(1);
816#endif
74091dd4
CR
817}
818]])], [bash_cv_func_sigsetjmp=present], [bash_cv_func_sigsetjmp=missing],
819 [AC_MSG_WARN(cannot check for sigsetjmp/siglongjmp if cross-compiling -- defaulting to $bash_cv_posix_signals)
820 if test "$bash_cv_posix_signals" = "yes" ; then
821 bash_cv_func_sigsetjmp=present
822 else
823 bash_cv_func_sigsetjmp=missing
824 fi]
f73dda09
JA
825)])
826AC_MSG_RESULT($bash_cv_func_sigsetjmp)
827if test $bash_cv_func_sigsetjmp = present; then
828AC_DEFINE(HAVE_POSIX_SIGSETJMP)
829fi
830])
831
832AC_DEFUN(BASH_FUNC_STRCOLL,
74091dd4 833[AC_MSG_CHECKING(whether or not strcoll and strcmp differ)
f73dda09 834AC_CACHE_VAL(bash_cv_func_strcoll_broken,
74091dd4 835[AC_RUN_IFELSE([AC_LANG_SOURCE([[
f73dda09
JA
836#include <stdio.h>
837#if defined (HAVE_LOCALE_H)
838#include <locale.h>
839#endif
8868edaf
CR
840#include <string.h>
841#include <stdlib.h>
f73dda09 842
8868edaf 843int
f73dda09
JA
844main(c, v)
845int c;
846char *v[];
847{
848 int r1, r2;
849 char *deflocale, *defcoll;
850
851#ifdef HAVE_SETLOCALE
852 deflocale = setlocale(LC_ALL, "");
853 defcoll = setlocale(LC_COLLATE, "");
854#endif
855
856#ifdef HAVE_STRCOLL
857 /* These two values are taken from tests/glob-test. */
858 r1 = strcoll("abd", "aXd");
859#else
860 r1 = 0;
861#endif
862 r2 = strcmp("abd", "aXd");
863
864 /* These two should both be greater than 0. It is permissible for
865 a system to return different values, as long as the sign is the
866 same. */
867
868 /* Exit with 1 (failure) if these two values are both > 0, since
869 this tests whether strcoll(3) is broken with respect to strcmp(3)
870 in the default locale. */
871 exit (r1 > 0 && r2 > 0);
872}
74091dd4 873]])], [bash_cv_func_strcoll_broken=yes], [bash_cv_func_strcoll_broken=no],
f73dda09
JA
874 [AC_MSG_WARN(cannot check strcoll if cross compiling -- defaulting to no)
875 bash_cv_func_strcoll_broken=no]
876)])
877AC_MSG_RESULT($bash_cv_func_strcoll_broken)
878if test $bash_cv_func_strcoll_broken = yes; then
879AC_DEFINE(STRCOLL_BROKEN)
880fi
881])
882
883AC_DEFUN(BASH_FUNC_PRINTF_A_FORMAT,
884[AC_MSG_CHECKING([for printf floating point output in hex notation])
885AC_CACHE_VAL(bash_cv_printf_a_format,
74091dd4 886[AC_RUN_IFELSE([AC_LANG_SOURCE([[
f73dda09
JA
887#include <stdio.h>
888#include <string.h>
8868edaf 889#include <stdlib.h>
f73dda09
JA
890
891int
892main()
893{
894 double y = 0.0;
895 char abuf[1024];
896
897 sprintf(abuf, "%A", y);
898 exit(strchr(abuf, 'P') == (char *)0);
899}
74091dd4 900]])], [bash_cv_printf_a_format=yes], [bash_cv_printf_a_format=no],
f73dda09
JA
901 [AC_MSG_WARN(cannot check printf if cross compiling -- defaulting to no)
902 bash_cv_printf_a_format=no]
903)])
904AC_MSG_RESULT($bash_cv_printf_a_format)
905if test $bash_cv_printf_a_format = yes; then
906AC_DEFINE(HAVE_PRINTF_A_FORMAT)
907fi
908])
909
910AC_DEFUN(BASH_STRUCT_TERMIOS_LDISC,
911[
912AC_CHECK_MEMBER(struct termios.c_line, AC_DEFINE(TERMIOS_LDISC), ,[
913#include <sys/types.h>
914#include <termios.h>
915])
916])
917
918AC_DEFUN(BASH_STRUCT_TERMIO_LDISC,
919[
920AC_CHECK_MEMBER(struct termio.c_line, AC_DEFINE(TERMIO_LDISC), ,[
921#include <sys/types.h>
922#include <termio.h>
923])
924])
925
926dnl
927dnl Like AC_STRUCT_ST_BLOCKS, but doesn't muck with LIBOBJS
928dnl
929dnl sets bash_cv_struct_stat_st_blocks
930dnl
931dnl unused for now; we'll see how AC_CHECK_MEMBERS works
932dnl
933AC_DEFUN(BASH_STRUCT_ST_BLOCKS,
934[
935AC_MSG_CHECKING([for struct stat.st_blocks])
936AC_CACHE_VAL(bash_cv_struct_stat_st_blocks,
74091dd4 937[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
f73dda09
JA
938#include <sys/types.h>
939#include <sys/stat.h>
74091dd4 940]], [[
8868edaf 941int
f73dda09
JA
942main()
943{
944static struct stat a;
945if (a.st_blocks) return 0;
946return 0;
947}
74091dd4 948]])], [bash_cv_struct_stat_st_blocks=yes], [bash_cv_struct_stat_st_blocks=no])
f73dda09
JA
949])
950AC_MSG_RESULT($bash_cv_struct_stat_st_blocks)
951if test "$bash_cv_struct_stat_st_blocks" = "yes"; then
952AC_DEFINE(HAVE_STRUCT_STAT_ST_BLOCKS)
953fi
954])
955
0628567a 956AC_DEFUN([BASH_CHECK_LIB_TERMCAP],
f73dda09
JA
957[
958if test "X$bash_cv_termcap_lib" = "X"; then
959_bash_needmsg=yes
960else
961AC_MSG_CHECKING(which library has the termcap functions)
962_bash_needmsg=
963fi
964AC_CACHE_VAL(bash_cv_termcap_lib,
b80f6443
JA
965[AC_CHECK_FUNC(tgetent, bash_cv_termcap_lib=libc,
966 [AC_CHECK_LIB(termcap, tgetent, bash_cv_termcap_lib=libtermcap,
7117c2d2 967 [AC_CHECK_LIB(tinfo, tgetent, bash_cv_termcap_lib=libtinfo,
f73dda09
JA
968 [AC_CHECK_LIB(curses, tgetent, bash_cv_termcap_lib=libcurses,
969 [AC_CHECK_LIB(ncurses, tgetent, bash_cv_termcap_lib=libncurses,
d233b485
CR
970 [AC_CHECK_LIB(ncursesw, tgetent, bash_cv_termcap_lib=libncursesw,
971 bash_cv_termcap_lib=gnutermcap)])])])])])])
f73dda09
JA
972if test "X$_bash_needmsg" = "Xyes"; then
973AC_MSG_CHECKING(which library has the termcap functions)
974fi
975AC_MSG_RESULT(using $bash_cv_termcap_lib)
976if test $bash_cv_termcap_lib = gnutermcap && test -z "$prefer_curses"; then
977LDFLAGS="$LDFLAGS -L./lib/termcap"
978TERMCAP_LIB="./lib/termcap/libtermcap.a"
979TERMCAP_DEP="./lib/termcap/libtermcap.a"
980elif test $bash_cv_termcap_lib = libtermcap && test -z "$prefer_curses"; then
981TERMCAP_LIB=-ltermcap
982TERMCAP_DEP=
983elif test $bash_cv_termcap_lib = libtinfo; then
984TERMCAP_LIB=-ltinfo
985TERMCAP_DEP=
986elif test $bash_cv_termcap_lib = libncurses; then
987TERMCAP_LIB=-lncurses
988TERMCAP_DEP=
b80f6443
JA
989elif test $bash_cv_termcap_lib = libc; then
990TERMCAP_LIB=
991TERMCAP_DEP=
f73dda09 992else
74091dd4
CR
993# we assume ncurses is installed somewhere the linker can find it
994TERMCAP_LIB=-lncurses
f73dda09
JA
995TERMCAP_DEP=
996fi
997])
998
999dnl
1000dnl Check for the presence of getpeername in libsocket.
1001dnl If libsocket is present, check for libnsl and add it to LIBS if
1002dnl it's there, since most systems with libsocket require linking
1003dnl with libnsl as well. This should only be called if getpeername
1004dnl was not found in libc.
1005dnl
1006dnl NOTE: IF WE FIND GETPEERNAME, WE ASSUME THAT WE HAVE BIND/CONNECT
1007dnl AS WELL
1008dnl
1009AC_DEFUN(BASH_CHECK_LIB_SOCKET,
1010[
1011if test "X$bash_cv_have_socklib" = "X"; then
1012_bash_needmsg=
1013else
1014AC_MSG_CHECKING(for socket library)
1015_bash_needmsg=yes
1016fi
1017AC_CACHE_VAL(bash_cv_have_socklib,
1018[AC_CHECK_LIB(socket, getpeername,
1019 bash_cv_have_socklib=yes, bash_cv_have_socklib=no, -lnsl)])
1020if test "X$_bash_needmsg" = Xyes; then
1021 AC_MSG_RESULT($bash_cv_have_socklib)
1022 _bash_needmsg=
1023fi
1024if test $bash_cv_have_socklib = yes; then
1025 # check for libnsl, add it to LIBS if present
1026 if test "X$bash_cv_have_libnsl" = "X"; then
1027 _bash_needmsg=
1028 else
1029 AC_MSG_CHECKING(for libnsl)
1030 _bash_needmsg=yes
1031 fi
1032 AC_CACHE_VAL(bash_cv_have_libnsl,
1033 [AC_CHECK_LIB(nsl, t_open,
1034 bash_cv_have_libnsl=yes, bash_cv_have_libnsl=no)])
1035 if test "X$_bash_needmsg" = Xyes; then
1036 AC_MSG_RESULT($bash_cv_have_libnsl)
1037 _bash_needmsg=
1038 fi
1039 if test $bash_cv_have_libnsl = yes; then
1040 LIBS="-lsocket -lnsl $LIBS"
1041 else
1042 LIBS="-lsocket $LIBS"
1043 fi
1044 AC_DEFINE(HAVE_LIBSOCKET)
1045 AC_DEFINE(HAVE_GETPEERNAME)
ccc6cda3
JA
1046fi
1047])
1048
74091dd4
CR
1049dnl like _AC_STRUCT_DIRENT(MEMBER) but public
1050AC_DEFUN(BASH_STRUCT_DIRENT,
1051[
1052AC_REQUIRE([AC_HEADER_DIRENT])
1053AC_CHECK_MEMBERS(struct dirent.$1, bash_cv_dirent_has_$1=yes, bash_cv_dirent_has_$1=no,
1054[[
ccc6cda3
JA
1055#include <stdio.h>
1056#include <sys/types.h>
1057#ifdef HAVE_UNISTD_H
1058# include <unistd.h>
1059#endif /* HAVE_UNISTD_H */
1060#if defined(HAVE_DIRENT_H)
1061# include <dirent.h>
1062#else
1063# define dirent direct
1064# ifdef HAVE_SYS_NDIR_H
1065# include <sys/ndir.h>
1066# endif /* SYSNDIR */
1067# ifdef HAVE_SYS_DIR_H
1068# include <sys/dir.h>
1069# endif /* SYSDIR */
1070# ifdef HAVE_NDIR_H
1071# include <ndir.h>
1072# endif
1073#endif /* HAVE_DIRENT_H */
74091dd4
CR
1074]])
1075])
1076
1077AC_DEFUN(BASH_STRUCT_DIRENT_D_INO,
1078[AC_REQUIRE([AC_HEADER_DIRENT])
1079AC_MSG_CHECKING(for struct dirent.d_ino)
1080AC_CACHE_VAL(bash_cv_dirent_has_d_ino, [BASH_STRUCT_DIRENT([d_ino])])
1081AC_MSG_RESULT($bash_cv_dirent_has_d_ino)
1082if test $bash_cv_dirent_has_d_ino = yes; then
b80f6443 1083AC_DEFINE(HAVE_STRUCT_DIRENT_D_INO)
ccc6cda3
JA
1084fi
1085])
1086
d166f048
JA
1087AC_DEFUN(BASH_STRUCT_DIRENT_D_FILENO,
1088[AC_REQUIRE([AC_HEADER_DIRENT])
b80f6443 1089AC_MSG_CHECKING(for struct dirent.d_fileno)
74091dd4 1090AC_CACHE_VAL(bash_cv_dirent_has_d_fileno, [BASH_STRUCT_DIRENT([d_fileno])])
d166f048
JA
1091AC_MSG_RESULT($bash_cv_dirent_has_d_fileno)
1092if test $bash_cv_dirent_has_d_fileno = yes; then
b80f6443
JA
1093AC_DEFINE(HAVE_STRUCT_DIRENT_D_FILENO)
1094fi
1095])
1096
1097AC_DEFUN(BASH_STRUCT_DIRENT_D_NAMLEN,
1098[AC_REQUIRE([AC_HEADER_DIRENT])
1099AC_MSG_CHECKING(for struct dirent.d_namlen)
74091dd4 1100AC_CACHE_VAL(bash_cv_dirent_has_d_namlen, [BASH_STRUCT_DIRENT([d_namlen])])
b80f6443
JA
1101AC_MSG_RESULT($bash_cv_dirent_has_d_namlen)
1102if test $bash_cv_dirent_has_d_namlen = yes; then
1103AC_DEFINE(HAVE_STRUCT_DIRENT_D_NAMLEN)
d166f048
JA
1104fi
1105])
1106
f73dda09
JA
1107AC_DEFUN(BASH_STRUCT_TIMEVAL,
1108[AC_MSG_CHECKING(for struct timeval in sys/time.h and time.h)
1109AC_CACHE_VAL(bash_cv_struct_timeval,
8868edaf
CR
1110[AC_COMPILE_IFELSE(
1111 [AC_LANG_PROGRAM(
1112 [[#if HAVE_SYS_TIME_H
1113 #include <sys/time.h>
1114 #endif
1115 #include <time.h>
1116 ]],
1117 [[static struct timeval x; x.tv_sec = x.tv_usec;]]
1118 )],
1119 bash_cv_struct_timeval=yes,
1120 bash_cv_struct_timeval=no)
f73dda09
JA
1121])
1122AC_MSG_RESULT($bash_cv_struct_timeval)
1123if test $bash_cv_struct_timeval = yes; then
1124 AC_DEFINE(HAVE_TIMEVAL)
1125fi
1126])
1127
b80f6443
JA
1128AC_DEFUN(BASH_STRUCT_TIMEZONE,
1129[AC_MSG_CHECKING(for struct timezone in sys/time.h and time.h)
1130AC_CACHE_VAL(bash_cv_struct_timezone,
1131[
1132AC_EGREP_HEADER(struct timezone, sys/time.h,
1133 bash_cv_struct_timezone=yes,
1134 AC_EGREP_HEADER(struct timezone, time.h,
1135 bash_cv_struct_timezone=yes,
1136 bash_cv_struct_timezone=no))
1137])
1138AC_MSG_RESULT($bash_cv_struct_timezone)
1139if test $bash_cv_struct_timezone = yes; then
1140 AC_DEFINE(HAVE_STRUCT_TIMEZONE)
1141fi
1142])
1143
74091dd4
CR
1144AC_DEFUN(BASH_CHECK_WINSIZE_IOCTL,
1145[AC_CACHE_VAL(bash_cv_struct_winsize_ioctl,
1146[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1147#include <sys/types.h>
1148#include <sys/ioctl.h>
1149]],
1150[[
1151struct winsize x;
1152if (sizeof (x) > 0) return (0);
1153]] )], [bash_cv_struct_winsize_ioctl=yes], [bash_cv_struct_winsize_ioctl=no])
1154])
1155])
1156
1157AC_DEFUN(BASH_CHECK_WINSIZE_TERMIOS,
1158[AC_CACHE_VAL(bash_cv_struct_winsize_termios,
1159[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1160#include <sys/types.h>
1161#include <sys/termios.h>
1162]],
1163[[
1164struct winsize x;
1165if (sizeof (x) > 0) return (0);
1166]] )], [bash_cv_struct_winsize_termios=yes], [bash_cv_struct_winsize_termios=no])
1167])
1168])
1169
f73dda09
JA
1170AC_DEFUN(BASH_STRUCT_WINSIZE,
1171[AC_MSG_CHECKING(for struct winsize in sys/ioctl.h and termios.h)
1172AC_CACHE_VAL(bash_cv_struct_winsize_header,
74091dd4
CR
1173[
1174BASH_CHECK_WINSIZE_IOCTL
1175BASH_CHECK_WINSIZE_TERMIOS
1176
1177if test $bash_cv_struct_winsize_ioctl = yes; then
1178 bash_cv_struct_winsize_header=ioctl_h
1179elif test $bash_cv_struct_winsize_termios = yes; then
1180 bash_cv_struct_winsize_header=termios_h
1181else
1182 bash_cv_struct_winsize_header=other
1183fi
1184])
f73dda09
JA
1185if test $bash_cv_struct_winsize_header = ioctl_h; then
1186 AC_MSG_RESULT(sys/ioctl.h)
1187 AC_DEFINE(STRUCT_WINSIZE_IN_SYS_IOCTL)
1188elif test $bash_cv_struct_winsize_header = termios_h; then
1189 AC_MSG_RESULT(termios.h)
1190 AC_DEFINE(STRUCT_WINSIZE_IN_TERMIOS)
1191else
1192 AC_MSG_RESULT(not found)
1193fi
1194])
1195
74091dd4
CR
1196AC_DEFUN(BASH_HAVE_POSIX_SIGNALS,
1197[AC_CACHE_VAL(bash_cv_posix_signals,
1198[AC_LINK_IFELSE([AC_LANG_PROGRAM([[
1199#include <signal.h>
1200]], [[
f73dda09
JA
1201 sigset_t ss;
1202 struct sigaction sa;
1203 sigemptyset(&ss); sigsuspend(&ss);
1204 sigaction(SIGINT, &sa, (struct sigaction *) 0);
1205 sigprocmask(SIG_BLOCK, &ss, (sigset_t *) 0);
74091dd4
CR
1206]] )],
1207[bash_cv_posix_signals=yes], [bash_cv_posix_signals=no]
1208)])
1209])
1210
1211AC_DEFUN(BASH_HAVE_BSD_SIGNALS,
1212[AC_CACHE_VAL(bash_cv_bsd_signals,
1213[AC_LINK_IFELSE([AC_LANG_PROGRAM([[
1214#include <signal.h>
1215]], [[
1216int mask = sigmask(SIGINT);
1217sigsetmask(mask); sigblock(mask); sigpause(mask);
1218]] )],
1219[bash_cv_bsd_signals=yes], [bash_cv_bsd_signals=no]
1220)])
1221])
1222
1223AC_DEFUN(BASH_HAVE_SYSV_SIGNALS,
1224[AC_CACHE_VAL(bash_cv_sysv_signals,
1225[AC_LINK_IFELSE([AC_LANG_PROGRAM([[
1226#include <signal.h>
1227void foo() { }
1228]], [[
1229int mask = sigmask(SIGINT);
1230sigset(SIGINT, foo); sigrelse(SIGINT);
1231sighold(SIGINT); sigpause(SIGINT);
1232]] )],
1233[bash_cv_sysv_signals=yes], [bash_cv_sysv_signals=no]
1234)])
1235])
1236
1237dnl Check type of signal routines (posix, 4.2bsd, 4.1bsd or v7)
1238AC_DEFUN(BASH_SYS_SIGNAL_VINTAGE,
1239[AC_MSG_CHECKING(for type of signal functions)
1240AC_CACHE_VAL(bash_cv_signal_vintage,
1241[
1242BASH_HAVE_POSIX_SIGNALS
1243if test $bash_cv_posix_signals = yes; then
1244 bash_cv_signal_vintage=posix
1245else
1246 BASH_HAVE_BSD_SIGNALS
1247 if test $bash_cv_bsd_signals = yes; then
1248 bash_cv_signal_vintage=4.2bsd
1249 else
1250 BASH_HAVE_SYSV_SIGNALS
1251 if test $bash_cv_sysv_signals = yes; then
1252 bash_cv_signal_vintage=svr3
1253 else
1254 bash_cv_signal_vintage=v7
1255 fi
1256 fi
1257fi
f73dda09
JA
1258])
1259AC_MSG_RESULT($bash_cv_signal_vintage)
1260if test "$bash_cv_signal_vintage" = posix; then
1261AC_DEFINE(HAVE_POSIX_SIGNALS)
1262elif test "$bash_cv_signal_vintage" = "4.2bsd"; then
1263AC_DEFINE(HAVE_BSD_SIGNALS)
1264elif test "$bash_cv_signal_vintage" = svr3; then
1265AC_DEFINE(HAVE_USG_SIGHOLD)
1266fi
1267])
1268
1269dnl Check if the pgrp of setpgrp() can't be the pid of a zombie process.
1270AC_DEFUN(BASH_SYS_PGRP_SYNC,
1271[AC_REQUIRE([AC_FUNC_GETPGRP])
1272AC_MSG_CHECKING(whether pgrps need synchronization)
1273AC_CACHE_VAL(bash_cv_pgrp_pipe,
74091dd4 1274[AC_RUN_IFELSE([AC_LANG_SOURCE([[
f73dda09
JA
1275#ifdef HAVE_UNISTD_H
1276# include <unistd.h>
1277#endif
8868edaf
CR
1278#ifdef HAVE_SYS_WAIT_H
1279# include <sys/wait.h>
1280#endif
1281#include <stdlib.h>
1282int
f73dda09
JA
1283main()
1284{
1285# ifdef GETPGRP_VOID
1286# define getpgID() getpgrp()
1287# else
1288# define getpgID() getpgrp(0)
1289# define setpgid(x,y) setpgrp(x,y)
1290# endif
1291 int pid1, pid2, fds[2];
1292 int status;
1293 char ok;
1294
1295 switch (pid1 = fork()) {
1296 case -1:
1297 exit(1);
1298 case 0:
1299 setpgid(0, getpid());
1300 exit(0);
1301 }
1302 setpgid(pid1, pid1);
1303
1304 sleep(2); /* let first child die */
1305
1306 if (pipe(fds) < 0)
1307 exit(2);
1308
1309 switch (pid2 = fork()) {
1310 case -1:
1311 exit(3);
1312 case 0:
1313 setpgid(0, pid1);
1314 ok = getpgID() == pid1;
1315 write(fds[1], &ok, 1);
1316 exit(0);
1317 }
1318 setpgid(pid2, pid1);
1319
1320 close(fds[1]);
1321 if (read(fds[0], &ok, 1) != 1)
1322 exit(4);
1323 wait(&status);
1324 wait(&status);
1325 exit(ok ? 0 : 5);
1326}
74091dd4 1327]])], [bash_cv_pgrp_pipe=no], [bash_cv_pgrp_pipe=yes],
f73dda09 1328 [AC_MSG_WARN(cannot check pgrp synchronization if cross compiling -- defaulting to no)
74091dd4
CR
1329 bash_cv_pgrp_pipe=no]
1330)])
f73dda09
JA
1331AC_MSG_RESULT($bash_cv_pgrp_pipe)
1332if test $bash_cv_pgrp_pipe = yes; then
1333AC_DEFINE(PGRP_PIPE)
1334fi
1335])
1336
1337AC_DEFUN(BASH_SYS_REINSTALL_SIGHANDLERS,
74091dd4 1338[AC_REQUIRE([BASH_SYS_SIGNAL_VINTAGE])
ccc6cda3
JA
1339AC_MSG_CHECKING([if signal handlers must be reinstalled when invoked])
1340AC_CACHE_VAL(bash_cv_must_reinstall_sighandlers,
74091dd4 1341[AC_RUN_IFELSE([AC_LANG_SOURCE([[
ccc6cda3
JA
1342#include <signal.h>
1343#ifdef HAVE_UNISTD_H
1344#include <unistd.h>
1345#endif
8868edaf 1346#include <stdlib.h>
ccc6cda3 1347
74091dd4 1348typedef void sigfunc();
ccc6cda3 1349
d233b485 1350volatile int nsigint;
ccc6cda3
JA
1351
1352#ifdef HAVE_POSIX_SIGNALS
1353sigfunc *
1354set_signal_handler(sig, handler)
1355 int sig;
1356 sigfunc *handler;
1357{
1358 struct sigaction act, oact;
1359 act.sa_handler = handler;
1360 act.sa_flags = 0;
1361 sigemptyset (&act.sa_mask);
1362 sigemptyset (&oact.sa_mask);
1363 sigaction (sig, &act, &oact);
1364 return (oact.sa_handler);
1365}
1366#else
1367#define set_signal_handler(s, h) signal(s, h)
1368#endif
1369
74091dd4 1370void
ccc6cda3
JA
1371sigint(s)
1372int s;
1373{
1374 nsigint++;
1375}
1376
8868edaf 1377int
ccc6cda3
JA
1378main()
1379{
1380 nsigint = 0;
1381 set_signal_handler(SIGINT, sigint);
1382 kill((int)getpid(), SIGINT);
1383 kill((int)getpid(), SIGINT);
1384 exit(nsigint != 2);
1385}
74091dd4 1386]])], [bash_cv_must_reinstall_sighandlers=no], [bash_cv_must_reinstall_sighandlers=yes],
b72432fd 1387 [AC_MSG_WARN(cannot check signal handling if cross compiling -- defaulting to no)
cce855bc
JA
1388 bash_cv_must_reinstall_sighandlers=no]
1389)])
ccc6cda3
JA
1390AC_MSG_RESULT($bash_cv_must_reinstall_sighandlers)
1391if test $bash_cv_must_reinstall_sighandlers = yes; then
1392AC_DEFINE(MUST_REINSTALL_SIGHANDLERS)
1393fi
1394])
1395
ccc6cda3 1396dnl check that some necessary job control definitions are present
f73dda09
JA
1397AC_DEFUN(BASH_SYS_JOB_CONTROL_MISSING,
1398[AC_REQUIRE([BASH_SYS_SIGNAL_VINTAGE])
ccc6cda3
JA
1399AC_MSG_CHECKING(for presence of necessary job control definitions)
1400AC_CACHE_VAL(bash_cv_job_control_missing,
74091dd4 1401[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
ccc6cda3
JA
1402#include <sys/types.h>
1403#ifdef HAVE_SYS_WAIT_H
1404#include <sys/wait.h>
1405#endif
1406#ifdef HAVE_UNISTD_H
1407#include <unistd.h>
1408#endif
1409#include <signal.h>
1410
d233b485
CR
1411/* add more tests in here as appropriate */
1412
ccc6cda3
JA
1413/* signal type */
1414#if !defined (HAVE_POSIX_SIGNALS) && !defined (HAVE_BSD_SIGNALS)
d233b485 1415#error
ccc6cda3
JA
1416#endif
1417
1418/* signals and tty control. */
1419#if !defined (SIGTSTP) || !defined (SIGSTOP) || !defined (SIGCONT)
d233b485 1420#error
ccc6cda3
JA
1421#endif
1422
1423/* process control */
1424#if !defined (WNOHANG) || !defined (WUNTRACED)
d233b485 1425#error
ccc6cda3
JA
1426#endif
1427
1428/* Posix systems have tcgetpgrp and waitpid. */
1429#if defined (_POSIX_VERSION) && !defined (HAVE_TCGETPGRP)
d233b485 1430#error
ccc6cda3
JA
1431#endif
1432
1433#if defined (_POSIX_VERSION) && !defined (HAVE_WAITPID)
d233b485 1434#error
ccc6cda3
JA
1435#endif
1436
1437/* Other systems have TIOCSPGRP/TIOCGPRGP and wait3. */
1438#if !defined (_POSIX_VERSION) && !defined (HAVE_WAIT3)
d233b485 1439#error
ccc6cda3
JA
1440#endif
1441
74091dd4
CR
1442]], [[ int x; ]] )],
1443[bash_cv_job_control_missing=present], [bash_cv_job_control_missing=missing]
cce855bc 1444)])
ccc6cda3
JA
1445AC_MSG_RESULT($bash_cv_job_control_missing)
1446if test $bash_cv_job_control_missing = missing; then
1447AC_DEFINE(JOB_CONTROL_MISSING)
1448fi
1449])
1450
1451dnl check whether named pipes are present
1452dnl this requires a previous check for mkfifo, but that is awkward to specify
1453AC_DEFUN(BASH_SYS_NAMED_PIPES,
1454[AC_MSG_CHECKING(for presence of named pipes)
1455AC_CACHE_VAL(bash_cv_sys_named_pipes,
74091dd4 1456[AC_RUN_IFELSE([AC_LANG_SOURCE([[
ccc6cda3
JA
1457#include <sys/types.h>
1458#include <sys/stat.h>
1459#ifdef HAVE_UNISTD_H
1460#include <unistd.h>
1461#endif
8868edaf
CR
1462#include <stdio.h>
1463#include <stdlib.h>
ccc6cda3
JA
1464
1465/* Add more tests in here as appropriate. */
8868edaf 1466int
ccc6cda3
JA
1467main()
1468{
bb70624e 1469int fd, err;
ccc6cda3
JA
1470
1471#if defined (HAVE_MKFIFO)
1472exit (0);
1473#endif
1474
1475#if !defined (S_IFIFO) && (defined (_POSIX_VERSION) && !defined (S_ISFIFO))
1476exit (1);
1477#endif
1478
1479#if defined (NeXT)
1480exit (1);
1481#endif
3185942a 1482err = mkdir("bash-aclocal", 0700);
bb70624e
JA
1483if (err < 0) {
1484 perror ("mkdir");
1485 exit(1);
1486}
3185942a 1487fd = mknod ("bash-aclocal/sh-np-autoconf", 0666 | S_IFIFO, 0);
bb70624e 1488if (fd == -1) {
3185942a 1489 rmdir ("bash-aclocal");
ccc6cda3 1490 exit (1);
bb70624e 1491}
ccc6cda3 1492close(fd);
3185942a
JA
1493unlink ("bash-aclocal/sh-np-autoconf");
1494rmdir ("bash-aclocal");
ccc6cda3 1495exit(0);
74091dd4
CR
1496}
1497]])], [bash_cv_sys_named_pipes=present], [bash_cv_sys_named_pipes=missing],
b72432fd 1498 [AC_MSG_WARN(cannot check for named pipes if cross-compiling -- defaulting to missing)
cce855bc
JA
1499 bash_cv_sys_named_pipes=missing]
1500)])
ccc6cda3
JA
1501AC_MSG_RESULT($bash_cv_sys_named_pipes)
1502if test $bash_cv_sys_named_pipes = missing; then
1503AC_DEFINE(NAMED_PIPES_MISSING)
1504fi
1505])
1506
f73dda09
JA
1507AC_DEFUN(BASH_SYS_DEFAULT_MAIL_DIR,
1508[AC_MSG_CHECKING(for default mail directory)
1509AC_CACHE_VAL(bash_cv_mail_dir,
1510[if test -d /var/mail; then
1511 bash_cv_mail_dir=/var/mail
f73dda09
JA
1512 elif test -d /var/spool/mail; then
1513 bash_cv_mail_dir=/var/spool/mail
7117c2d2
JA
1514 elif test -d /usr/mail; then
1515 bash_cv_mail_dir=/usr/mail
f73dda09
JA
1516 elif test -d /usr/spool/mail; then
1517 bash_cv_mail_dir=/usr/spool/mail
1518 else
1519 bash_cv_mail_dir=unknown
1520 fi
1521])
1522AC_MSG_RESULT($bash_cv_mail_dir)
7117c2d2 1523AC_DEFINE_UNQUOTED(DEFAULT_MAIL_DIRECTORY, "$bash_cv_mail_dir")
ccc6cda3
JA
1524])
1525
1526AC_DEFUN(BASH_HAVE_TIOCGWINSZ,
1527[AC_MSG_CHECKING(for TIOCGWINSZ in sys/ioctl.h)
1528AC_CACHE_VAL(bash_cv_tiocgwinsz_in_ioctl,
74091dd4
CR
1529[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1530#include <sys/types.h>
1531#include <sys/ioctl.h>]], [[int x = TIOCGWINSZ;]] )],
1532 [bash_cv_tiocgwinsz_in_ioctl=yes], [bash_cv_tiocgwinsz_in_ioctl=no]
1533)])
ccc6cda3
JA
1534AC_MSG_RESULT($bash_cv_tiocgwinsz_in_ioctl)
1535if test $bash_cv_tiocgwinsz_in_ioctl = yes; then
1536AC_DEFINE(GWINSZ_IN_SYS_IOCTL)
1537fi
1538])
1539
1540AC_DEFUN(BASH_HAVE_TIOCSTAT,
1541[AC_MSG_CHECKING(for TIOCSTAT in sys/ioctl.h)
1542AC_CACHE_VAL(bash_cv_tiocstat_in_ioctl,
74091dd4
CR
1543[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1544#include <sys/types.h>
1545#include <sys/ioctl.h>]], [[int x = TIOCSTAT;]] )],
1546 [bash_cv_tiocstat_in_ioctl=yes], [bash_cv_tiocstat_in_ioctl=no]
1547)])
ccc6cda3
JA
1548AC_MSG_RESULT($bash_cv_tiocstat_in_ioctl)
1549if test $bash_cv_tiocstat_in_ioctl = yes; then
1550AC_DEFINE(TIOCSTAT_IN_SYS_IOCTL)
1551fi
1552])
1553
1554AC_DEFUN(BASH_HAVE_FIONREAD,
1555[AC_MSG_CHECKING(for FIONREAD in sys/ioctl.h)
1556AC_CACHE_VAL(bash_cv_fionread_in_ioctl,
74091dd4
CR
1557[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1558#include <sys/types.h>
1559#include <sys/ioctl.h>]], [[int x = FIONREAD;]] )],
1560 [bash_cv_fionread_in_ioctl=yes], [bash_cv_fionread_in_ioctl=no]
1561)])
ccc6cda3
JA
1562AC_MSG_RESULT($bash_cv_fionread_in_ioctl)
1563if test $bash_cv_fionread_in_ioctl = yes; then
1564AC_DEFINE(FIONREAD_IN_SYS_IOCTL)
1565fi
1566])
1567
d166f048
JA
1568dnl
1569dnl See if speed_t is declared in <sys/types.h>. Some versions of linux
1570dnl require a definition of speed_t each time <termcap.h> is included,
1571dnl but you can only get speed_t if you include <termios.h> (on some
1572dnl versions) or <sys/types.h> (on others).
1573dnl
f73dda09 1574AC_DEFUN(BASH_CHECK_SPEED_T,
d166f048
JA
1575[AC_MSG_CHECKING(for speed_t in sys/types.h)
1576AC_CACHE_VAL(bash_cv_speed_t_in_sys_types,
74091dd4
CR
1577[AC_COMPILE_IFELSE(
1578 [AC_LANG_PROGRAM(
1579 [[#include <sys/types.h>]],
1580 [[speed_t x;]])],
1581 [bash_cv_speed_t_in_sys_types=yes],[bash_cv_speed_t_in_sys_types=no])])
d166f048
JA
1582AC_MSG_RESULT($bash_cv_speed_t_in_sys_types)
1583if test $bash_cv_speed_t_in_sys_types = yes; then
1584AC_DEFINE(SPEED_T_IN_SYS_TYPES)
1585fi
1586])
1587
ccc6cda3 1588AC_DEFUN(BASH_CHECK_GETPW_FUNCS,
28ef6c31
JA
1589[AC_MSG_CHECKING(whether getpw functions are declared in pwd.h)
1590AC_CACHE_VAL(bash_cv_getpw_declared,
1591[AC_EGREP_CPP(getpwuid,
1592[
1593#include <sys/types.h>
1594#ifdef HAVE_UNISTD_H
1595# include <unistd.h>
1596#endif
ccc6cda3 1597#include <pwd.h>
28ef6c31
JA
1598],
1599bash_cv_getpw_declared=yes,bash_cv_getpw_declared=no)])
1600AC_MSG_RESULT($bash_cv_getpw_declared)
1601if test $bash_cv_getpw_declared = yes; then
ccc6cda3
JA
1602AC_DEFINE(HAVE_GETPW_DECLS)
1603fi
1604])
1605
1606AC_DEFUN(BASH_CHECK_DEV_FD,
1607[AC_MSG_CHECKING(whether /dev/fd is available)
1608AC_CACHE_VAL(bash_cv_dev_fd,
0628567a 1609[bash_cv_dev_fd=""
3185942a 1610if test -d /dev/fd && (exec test -r /dev/fd/0 < /dev/null) ; then
95732b49 1611# check for systems like FreeBSD 5 that only provide /dev/fd/[012]
3185942a 1612 if (exec test -r /dev/fd/3 3</dev/null) ; then
95732b49
JA
1613 bash_cv_dev_fd=standard
1614 else
1615 bash_cv_dev_fd=absent
1616 fi
0628567a
JA
1617fi
1618if test -z "$bash_cv_dev_fd" ; then
3185942a 1619 if test -d /proc/self/fd && (exec test -r /proc/self/fd/0 < /dev/null) ; then
0628567a
JA
1620 bash_cv_dev_fd=whacky
1621 else
1622 bash_cv_dev_fd=absent
1623 fi
1624fi
ccc6cda3
JA
1625])
1626AC_MSG_RESULT($bash_cv_dev_fd)
1627if test $bash_cv_dev_fd = "standard"; then
1628 AC_DEFINE(HAVE_DEV_FD)
1629 AC_DEFINE(DEV_FD_PREFIX, "/dev/fd/")
1630elif test $bash_cv_dev_fd = "whacky"; then
1631 AC_DEFINE(HAVE_DEV_FD)
1632 AC_DEFINE(DEV_FD_PREFIX, "/proc/self/fd/")
1633fi
1634])
1635
bb70624e
JA
1636AC_DEFUN(BASH_CHECK_DEV_STDIN,
1637[AC_MSG_CHECKING(whether /dev/stdin stdout stderr are available)
1638AC_CACHE_VAL(bash_cv_dev_stdin,
d233b485 1639[if (exec test -r /dev/stdin < /dev/null) ; then
bb70624e
JA
1640 bash_cv_dev_stdin=present
1641 else
1642 bash_cv_dev_stdin=absent
1643 fi
1644])
1645AC_MSG_RESULT($bash_cv_dev_stdin)
1646if test $bash_cv_dev_stdin = "present"; then
1647 AC_DEFINE(HAVE_DEV_STDIN)
1648fi
1649])
1650
74091dd4
CR
1651
1652AC_DEFUN(BASH_CHECK_RLIMIT,
1653[AC_CACHE_VAL(bash_cv_rlimit,
1654[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1655#include <sys/types.h>
1656#include <sys/resource.h>
1657]],
1658[[
1659 int f;
1660 f = RLIMIT_DATA;
1661]] )],
1662[bash_cv_rlimit=yes], [bash_cv_rlimit=no]
1663)])
1664])
1665
ccc6cda3
JA
1666dnl
1667dnl Check if HPUX needs _KERNEL defined for RLIMIT_* definitions
1668dnl
f73dda09 1669AC_DEFUN(BASH_CHECK_KERNEL_RLIMIT,
ccc6cda3
JA
1670[AC_MSG_CHECKING([whether $host_os needs _KERNEL for RLIMIT defines])
1671AC_CACHE_VAL(bash_cv_kernel_rlimit,
74091dd4
CR
1672[BASH_CHECK_RLIMIT
1673if test $bash_cv_rlimit = no; then
1674AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
cce855bc
JA
1675#include <sys/types.h>
1676#define _KERNEL
1677#include <sys/resource.h>
1678#undef _KERNEL
74091dd4
CR
1679]],
1680[[
1681 int f;
1682 f = RLIMIT_DATA;
1683]] )], [bash_cv_kernel_rlimit=yes], [bash_cv_kernel_rlimit=no] )
1684fi
1685])
ccc6cda3
JA
1686AC_MSG_RESULT($bash_cv_kernel_rlimit)
1687if test $bash_cv_kernel_rlimit = yes; then
1688AC_DEFINE(RLIMIT_NEEDS_KERNEL)
1689fi
1690])
d166f048 1691
b72432fd
JA
1692dnl
1693dnl Check for 64-bit off_t -- used for malloc alignment
1694dnl
1695dnl C does not allow duplicate case labels, so the compile will fail if
1696dnl sizeof(off_t) is > 4.
1697dnl
1698AC_DEFUN(BASH_CHECK_OFF_T_64,
1699[AC_CACHE_CHECK(for 64-bit off_t, bash_cv_off_t_64,
74091dd4 1700AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
b72432fd
JA
1701#ifdef HAVE_UNISTD_H
1702#include <unistd.h>
1703#endif
1704#include <sys/types.h>
74091dd4 1705]],[[
b72432fd 1706switch (0) case 0: case (sizeof (off_t) <= 4):;
74091dd4
CR
1707]] )], [bash_cv_off_t_64=no], [bash_cv_off_t_64=yes]
1708))
b72432fd
JA
1709if test $bash_cv_off_t_64 = yes; then
1710 AC_DEFINE(HAVE_OFF_T_64)
1711fi])
bb70624e 1712
28ef6c31
JA
1713AC_DEFUN(BASH_CHECK_RTSIGS,
1714[AC_MSG_CHECKING(for unusable real-time signals due to large values)
1715AC_CACHE_VAL(bash_cv_unusable_rtsigs,
74091dd4 1716[AC_RUN_IFELSE([AC_LANG_SOURCE([[
28ef6c31
JA
1717#include <sys/types.h>
1718#include <signal.h>
8868edaf 1719#include <stdlib.h>
28ef6c31
JA
1720
1721#ifndef NSIG
1722# define NSIG 64
1723#endif
1724
8868edaf 1725int
28ef6c31
JA
1726main ()
1727{
1728 int n_sigs = 2 * NSIG;
1729#ifdef SIGRTMIN
1730 int rtmin = SIGRTMIN;
1731#else
1732 int rtmin = 0;
1733#endif
1734
1735 exit(rtmin < n_sigs);
74091dd4
CR
1736}
1737]])], [bash_cv_unusable_rtsigs=yes], [bash_cv_unusable_rtsigs=no],
28ef6c31
JA
1738 [AC_MSG_WARN(cannot check real-time signals if cross compiling -- defaulting to yes)
1739 bash_cv_unusable_rtsigs=yes]
1740)])
1741AC_MSG_RESULT($bash_cv_unusable_rtsigs)
1742if test $bash_cv_unusable_rtsigs = yes; then
1743AC_DEFINE(UNUSABLE_RT_SIGNALS)
1744fi
1745])
f73dda09 1746
7117c2d2
JA
1747dnl
1748dnl check for availability of multibyte characters and functions
1749dnl
0628567a
JA
1750dnl geez, I wish I didn't have to check for all of this stuff separately
1751dnl
7117c2d2
JA
1752AC_DEFUN(BASH_CHECK_MULTIBYTE,
1753[
1754AC_CHECK_HEADERS(wctype.h)
1755AC_CHECK_HEADERS(wchar.h)
1756AC_CHECK_HEADERS(langinfo.h)
1757
a0c0a00f
CR
1758AC_CHECK_HEADERS(mbstr.h)
1759
b80f6443 1760AC_CHECK_FUNC(mbrlen, AC_DEFINE(HAVE_MBRLEN))
0001803f 1761AC_CHECK_FUNC(mbscasecmp, AC_DEFINE(HAVE_MBSCMP))
3185942a 1762AC_CHECK_FUNC(mbscmp, AC_DEFINE(HAVE_MBSCMP))
495aee44 1763AC_CHECK_FUNC(mbsnrtowcs, AC_DEFINE(HAVE_MBSNRTOWCS))
3185942a 1764AC_CHECK_FUNC(mbsrtowcs, AC_DEFINE(HAVE_MBSRTOWCS))
0628567a 1765
0001803f
CR
1766AC_REPLACE_FUNCS(mbschr)
1767
0628567a
JA
1768AC_CHECK_FUNC(wcrtomb, AC_DEFINE(HAVE_WCRTOMB))
1769AC_CHECK_FUNC(wcscoll, AC_DEFINE(HAVE_WCSCOLL))
b80f6443 1770AC_CHECK_FUNC(wcsdup, AC_DEFINE(HAVE_WCSDUP))
0628567a
JA
1771AC_CHECK_FUNC(wcwidth, AC_DEFINE(HAVE_WCWIDTH))
1772AC_CHECK_FUNC(wctype, AC_DEFINE(HAVE_WCTYPE))
7117c2d2 1773
495aee44
CR
1774AC_REPLACE_FUNCS(wcswidth)
1775
0628567a
JA
1776dnl checks for both mbrtowc and mbstate_t
1777AC_FUNC_MBRTOWC
1778if test $ac_cv_func_mbrtowc = yes; then
7117c2d2
JA
1779 AC_DEFINE(HAVE_MBSTATE_T)
1780fi
1781
0628567a
JA
1782AC_CHECK_FUNCS(iswlower iswupper towlower towupper iswctype)
1783
74091dd4 1784AC_REQUIRE([AM_LANGINFO_CODESET])
7117c2d2 1785
0628567a
JA
1786dnl check for wchar_t in <wchar.h>
1787AC_CACHE_CHECK([for wchar_t in wchar.h], bash_cv_type_wchar_t,
74091dd4
CR
1788[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([
1789[#include <wchar.h>]],
1790[[
0628567a
JA
1791 wchar_t foo;
1792 foo = 0;
74091dd4
CR
1793]] )], [bash_cv_type_wchar_t=yes], [bash_cv_type_wchar_t=no]
1794)])
0628567a
JA
1795if test $bash_cv_type_wchar_t = yes; then
1796 AC_DEFINE(HAVE_WCHAR_T, 1, [systems should define this type here])
1797fi
1798
1799dnl check for wctype_t in <wctype.h>
1800AC_CACHE_CHECK([for wctype_t in wctype.h], bash_cv_type_wctype_t,
74091dd4
CR
1801[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([
1802[#include <wctype.h>]],
1803[[
0628567a
JA
1804 wctype_t foo;
1805 foo = 0;
74091dd4
CR
1806]] )], [bash_cv_type_wctype_t=yes], [bash_cv_type_wctype_t=no]
1807)])
0628567a
JA
1808if test $bash_cv_type_wctype_t = yes; then
1809 AC_DEFINE(HAVE_WCTYPE_T, 1, [systems should define this type here])
1810fi
1811
1812dnl check for wint_t in <wctype.h>
1813AC_CACHE_CHECK([for wint_t in wctype.h], bash_cv_type_wint_t,
74091dd4
CR
1814[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([
1815[#include <wctype.h>]],
1816[[
0628567a
JA
1817 wint_t foo;
1818 foo = 0;
74091dd4
CR
1819]] )], [bash_cv_type_wint_t=yes], [bash_cv_type_wint_t=no]
1820)])
0628567a
JA
1821if test $bash_cv_type_wint_t = yes; then
1822 AC_DEFINE(HAVE_WINT_T, 1, [systems should define this type here])
1823fi
1824
ac50fbac
CR
1825dnl check for broken wcwidth
1826AC_CACHE_CHECK([for wcwidth broken with unicode combining characters],
1827bash_cv_wcwidth_broken,
74091dd4 1828[AC_RUN_IFELSE([AC_LANG_SOURCE([[
ac50fbac
CR
1829#include <unistd.h>
1830#include <stdlib.h>
1831#include <stdio.h>
1832
1833#include <locale.h>
1834#include <wchar.h>
1835
8868edaf 1836int
ac50fbac
CR
1837main(c, v)
1838int c;
1839char **v;
1840{
1841 int w;
1842
1843 setlocale(LC_ALL, "en_US.UTF-8");
1844 w = wcwidth (0x0301);
1845 exit (w == 0); /* exit 0 if wcwidth broken */
1846}
74091dd4
CR
1847]])], [bash_cv_wcwidth_broken=yes], [bash_cv_wcwidth_broken=no],
1848 [bash_cv_wcwidth_broken=no]
1849)])
ac50fbac
CR
1850if test "$bash_cv_wcwidth_broken" = yes; then
1851 AC_DEFINE(WCWIDTH_BROKEN, 1, [wcwidth is usually not broken])
1852fi
1853
0001803f
CR
1854if test "$am_cv_func_iconv" = yes; then
1855 OLDLIBS="$LIBS"
a0c0a00f 1856 LIBS="$LIBS $LIBINTL $LIBICONV"
0001803f
CR
1857 AC_CHECK_FUNCS(locale_charset)
1858 LIBS="$OLDLIBS"
1859fi
1860
d233b485
CR
1861AC_CHECK_SIZEOF(wchar_t, 4)
1862
7117c2d2
JA
1863])
1864
f73dda09
JA
1865dnl need: prefix exec_prefix libdir includedir CC TERMCAP_LIB
1866dnl require:
1867dnl AC_PROG_CC
1868dnl BASH_CHECK_LIB_TERMCAP
1869
0628567a 1870AC_DEFUN([RL_LIB_READLINE_VERSION],
f73dda09
JA
1871[
1872AC_REQUIRE([BASH_CHECK_LIB_TERMCAP])
1873
1874AC_MSG_CHECKING([version of installed readline library])
1875
1876# What a pain in the ass this is.
1877
1878# save cpp and ld options
1879_save_CFLAGS="$CFLAGS"
1880_save_LDFLAGS="$LDFLAGS"
1881_save_LIBS="$LIBS"
1882
1883# Don't set ac_cv_rl_prefix if the caller has already assigned a value. This
1884# allows the caller to do something like $_rl_prefix=$withval if the user
1885# specifies --with-installed-readline=PREFIX as an argument to configure
1886
1887if test -z "$ac_cv_rl_prefix"; then
1888test "x$prefix" = xNONE && ac_cv_rl_prefix=$ac_default_prefix || ac_cv_rl_prefix=${prefix}
1889fi
1890
1891eval ac_cv_rl_includedir=${ac_cv_rl_prefix}/include
1892eval ac_cv_rl_libdir=${ac_cv_rl_prefix}/lib
1893
1894LIBS="$LIBS -lreadline ${TERMCAP_LIB}"
1895CFLAGS="$CFLAGS -I${ac_cv_rl_includedir}"
1896LDFLAGS="$LDFLAGS -L${ac_cv_rl_libdir}"
1897
b80f6443 1898AC_CACHE_VAL(ac_cv_rl_version,
74091dd4 1899[AC_RUN_IFELSE([AC_LANG_SOURCE([[
f73dda09
JA
1900#include <stdio.h>
1901#include <readline/readline.h>
8868edaf 1902#include <stdlib.h>
f73dda09 1903
95732b49
JA
1904extern int rl_gnu_readline_p;
1905
8868edaf 1906int
f73dda09
JA
1907main()
1908{
1909 FILE *fp;
1910 fp = fopen("conftest.rlv", "w");
95732b49
JA
1911 if (fp == 0)
1912 exit(1);
1913 if (rl_gnu_readline_p != 1)
1914 fprintf(fp, "0.0\n");
1915 else
1916 fprintf(fp, "%s\n", rl_library_version ? rl_library_version : "0.0");
f73dda09
JA
1917 fclose(fp);
1918 exit(0);
1919}
74091dd4
CR
1920]])],
1921[ac_cv_rl_version=`cat conftest.rlv`],
1922[ac_cv_rl_version='0.0'],
1923[ac_cv_rl_version='8.0']
1924)])
f73dda09
JA
1925
1926CFLAGS="$_save_CFLAGS"
1927LDFLAGS="$_save_LDFLAGS"
1928LIBS="$_save_LIBS"
1929
1930RL_MAJOR=0
1931RL_MINOR=0
1932
1933# (
1934case "$ac_cv_rl_version" in
19352*|3*|4*|5*|6*|7*|8*|9*)
1936 RL_MAJOR=`echo $ac_cv_rl_version | sed 's:\..*$::'`
7117c2d2 1937 RL_MINOR=`echo $ac_cv_rl_version | sed -e 's:^.*\.::' -e 's:[[a-zA-Z]]*$::'`
f73dda09
JA
1938 ;;
1939esac
1940
1941# (((
1942case $RL_MAJOR in
1943[[0-9][0-9]]) _RL_MAJOR=$RL_MAJOR ;;
1944[[0-9]]) _RL_MAJOR=0$RL_MAJOR ;;
1945*) _RL_MAJOR=00 ;;
1946esac
1947
1948# (((
1949case $RL_MINOR in
1950[[0-9][0-9]]) _RL_MINOR=$RL_MINOR ;;
1951[[0-9]]) _RL_MINOR=0$RL_MINOR ;;
1952*) _RL_MINOR=00 ;;
1953esac
1954
1955RL_VERSION="0x${_RL_MAJOR}${_RL_MINOR}"
1956
1957# Readline versions greater than 4.2 have these defines in readline.h
1958
1959if test $ac_cv_rl_version = '0.0' ; then
1960 AC_MSG_WARN([Could not test version of installed readline library.])
1961elif test $RL_MAJOR -gt 4 || { test $RL_MAJOR = 4 && test $RL_MINOR -gt 2 ; } ; then
1962 # set these for use by the caller
1963 RL_PREFIX=$ac_cv_rl_prefix
1964 RL_LIBDIR=$ac_cv_rl_libdir
1965 RL_INCLUDEDIR=$ac_cv_rl_includedir
1966 AC_MSG_RESULT($ac_cv_rl_version)
1967else
1968
1969AC_DEFINE_UNQUOTED(RL_READLINE_VERSION, $RL_VERSION, [encoded version of the installed readline library])
1970AC_DEFINE_UNQUOTED(RL_VERSION_MAJOR, $RL_MAJOR, [major version of installed readline library])
1971AC_DEFINE_UNQUOTED(RL_VERSION_MINOR, $RL_MINOR, [minor version of installed readline library])
1972
1973AC_SUBST(RL_VERSION)
1974AC_SUBST(RL_MAJOR)
1975AC_SUBST(RL_MINOR)
1976
1977# set these for use by the caller
1978RL_PREFIX=$ac_cv_rl_prefix
1979RL_LIBDIR=$ac_cv_rl_libdir
1980RL_INCLUDEDIR=$ac_cv_rl_includedir
1981
1982AC_MSG_RESULT($ac_cv_rl_version)
1983
1984fi
1985])
b80f6443 1986
95732b49
JA
1987AC_DEFUN(BASH_CHECK_WCONTINUED,
1988[
1989AC_MSG_CHECKING(whether WCONTINUED flag to waitpid is unavailable or available but broken)
1990AC_CACHE_VAL(bash_cv_wcontinued_broken,
74091dd4 1991[AC_RUN_IFELSE([AC_LANG_SOURCE([[
95732b49
JA
1992#include <sys/types.h>
1993#include <sys/wait.h>
1994#include <unistd.h>
1995#include <errno.h>
8868edaf 1996#include <stdlib.h>
95732b49
JA
1997
1998#ifndef errno
1999extern int errno;
2000#endif
8868edaf 2001int
95732b49
JA
2002main()
2003{
2004 int x;
2005
2006 x = waitpid(-1, (int *)0, WNOHANG|WCONTINUED);
2007 if (x == -1 && errno == EINVAL)
2008 exit (1);
2009 else
2010 exit (0);
2011}
74091dd4 2012]])], [bash_cv_wcontinued_broken=no], [bash_cv_wcontinued_broken=yes],
95732b49
JA
2013 [AC_MSG_WARN(cannot check WCONTINUED if cross compiling -- defaulting to no)
2014 bash_cv_wcontinued_broken=no]
2015)])
2016AC_MSG_RESULT($bash_cv_wcontinued_broken)
2017if test $bash_cv_wcontinued_broken = yes; then
2018AC_DEFINE(WCONTINUED_BROKEN)
2019fi
2020])
2021
b80f6443
JA
2022dnl
2023dnl tests added for bashdb
2024dnl
2025
2026
2027AC_DEFUN([AM_PATH_LISPDIR],
74091dd4 2028 [AC_ARG_WITH(lispdir, AS_HELP_STRING([--with-lispdir], [override the default lisp directory]),
b80f6443
JA
2029 [ lispdir="$withval"
2030 AC_MSG_CHECKING([where .elc files should go])
2031 AC_MSG_RESULT([$lispdir])],
2032 [
2033 # If set to t, that means we are running in a shell under Emacs.
2034 # If you have an Emacs named "t", then use the full path.
2035 test x"$EMACS" = xt && EMACS=
2036 AC_CHECK_PROGS(EMACS, emacs xemacs, no)
2037 if test $EMACS != "no"; then
2038 if test x${lispdir+set} != xset; then
2039 AC_CACHE_CHECK([where .elc files should go], [am_cv_lispdir], [dnl
2040 am_cv_lispdir=`$EMACS -batch -q -eval '(while load-path (princ (concat (car load-path) "\n")) (setq load-path (cdr load-path)))' | sed -n -e 's,/$,,' -e '/.*\/lib\/\(x\?emacs\/site-lisp\)$/{s,,${libdir}/\1,;p;q;}' -e '/.*\/share\/\(x\?emacs\/site-lisp\)$/{s,,${datadir}/\1,;p;q;}'`
2041 if test -z "$am_cv_lispdir"; then
2042 am_cv_lispdir='${datadir}/emacs/site-lisp'
2043 fi
2044 ])
2045 lispdir="$am_cv_lispdir"
2046 fi
2047 fi
2048 ])
2049 AC_SUBST(lispdir)
2050])
2051
3185942a
JA
2052dnl From gnulib
2053AC_DEFUN([BASH_FUNC_FPURGE],
2054[
2055 AC_CHECK_FUNCS_ONCE([fpurge])
2056 AC_CHECK_FUNCS_ONCE([__fpurge])
2057 AC_CHECK_DECLS([fpurge], , , [#include <stdio.h>])
2058])
0001803f
CR
2059
2060AC_DEFUN([BASH_FUNC_SNPRINTF],
2061[
2062 AC_CHECK_FUNCS_ONCE([snprintf])
2063 if test X$ac_cv_func_snprintf = Xyes; then
2064 AC_CACHE_CHECK([for standard-conformant snprintf], [bash_cv_func_snprintf],
74091dd4 2065 [AC_RUN_IFELSE([AC_LANG_SOURCE([[
0001803f 2066#include <stdio.h>
8868edaf 2067#include <stdlib.h>
0001803f 2068
8868edaf 2069int
0001803f
CR
2070main()
2071{
2072 int n;
2073 n = snprintf (0, 0, "%s", "0123456");
2074 exit(n != 7);
2075}
74091dd4 2076]])], [bash_cv_func_snprintf=yes], [bash_cv_func_snprintf=no],
0001803f
CR
2077 [AC_MSG_WARN([cannot check standard snprintf if cross-compiling])
2078 bash_cv_func_snprintf=yes]
2079)])
2080 if test $bash_cv_func_snprintf = no; then
2081 ac_cv_func_snprintf=no
2082 fi
2083 fi
2084 if test $ac_cv_func_snprintf = no; then
2085 AC_DEFINE(HAVE_SNPRINTF, 0,
2086 [Define if you have a standard-conformant snprintf function.])
2087 fi
2088])
2089
2090AC_DEFUN([BASH_FUNC_VSNPRINTF],
2091[
2092 AC_CHECK_FUNCS_ONCE([vsnprintf])
2093 if test X$ac_cv_func_vsnprintf = Xyes; then
2094 AC_CACHE_CHECK([for standard-conformant vsnprintf], [bash_cv_func_vsnprintf],
74091dd4 2095 [AC_RUN_IFELSE([AC_LANG_SOURCE([[
0001803f
CR
2096#if HAVE_STDARG_H
2097#include <stdarg.h>
2098#else
2099#include <varargs.h>
2100#endif
2101#include <stdio.h>
2102#include <stdlib.h>
2103
2104static int
2105#if HAVE_STDARG_H
2106foo(const char *fmt, ...)
2107#else
2108foo(format, va_alist)
2109 const char *format;
2110 va_dcl
2111#endif
2112{
2113 va_list args;
2114 int n;
2115
2116#if HAVE_STDARG_H
2117 va_start(args, fmt);
2118#else
2119 va_start(args);
2120#endif
2121 n = vsnprintf(0, 0, fmt, args);
2122 va_end (args);
2123 return n;
2124}
2125
8868edaf 2126int
0001803f
CR
2127main()
2128{
2129 int n;
2130 n = foo("%s", "0123456");
2131 exit(n != 7);
2132}
74091dd4 2133]])], [bash_cv_func_vsnprintf=yes], [bash_cv_func_vsnprintf=no],
0001803f
CR
2134 [AC_MSG_WARN([cannot check standard vsnprintf if cross-compiling])
2135 bash_cv_func_vsnprintf=yes]
2136)])
2137 if test $bash_cv_func_vsnprintf = no; then
2138 ac_cv_func_vsnprintf=no
2139 fi
2140 fi
2141 if test $ac_cv_func_vsnprintf = no; then
2142 AC_DEFINE(HAVE_VSNPRINTF, 0,
2143 [Define if you have a standard-conformant vsnprintf function.])
2144 fi
2145])
495aee44
CR
2146
2147AC_DEFUN(BASH_STRUCT_WEXITSTATUS_OFFSET,
2148[AC_MSG_CHECKING(for offset of exit status in return status from wait)
2149AC_CACHE_VAL(bash_cv_wexitstatus_offset,
74091dd4 2150[AC_RUN_IFELSE([AC_LANG_SOURCE([[
495aee44
CR
2151#include <stdlib.h>
2152#include <unistd.h>
2153
2154#include <sys/wait.h>
2155
8868edaf 2156int
495aee44
CR
2157main(c, v)
2158 int c;
2159 char **v;
2160{
2161 pid_t pid, p;
2162 int s, i, n;
2163
2164 s = 0;
2165 pid = fork();
2166 if (pid == 0)
2167 exit (42);
2168
2169 /* wait for the process */
2170 p = wait(&s);
2171 if (p != pid)
2172 exit (255);
2173
2174 /* crack s */
8868edaf 2175 for (i = 0; i < (sizeof(s) * 8); i++)
495aee44
CR
2176 {
2177 n = (s >> i) & 0xff;
2178 if (n == 42)
2179 exit (i);
2180 }
2181
2182 exit (254);
2183}
74091dd4 2184]])], [bash_cv_wexitstatus_offset=0], [bash_cv_wexitstatus_offset=$?],
495aee44
CR
2185 [AC_MSG_WARN(cannot check WEXITSTATUS offset if cross compiling -- defaulting to 0)
2186 bash_cv_wexitstatus_offset=0]
2187)])
2188if test "$bash_cv_wexitstatus_offset" -gt 32 ; then
2189 AC_MSG_WARN(bad exit status from test program -- defaulting to 0)
2190 bash_cv_wexitstatus_offset=0
2191fi
2192AC_MSG_RESULT($bash_cv_wexitstatus_offset)
2193AC_DEFINE_UNQUOTED([WEXITSTATUS_OFFSET], [$bash_cv_wexitstatus_offset], [Offset of exit status in wait status word])
2194])
d233b485
CR
2195
2196AC_DEFUN([BASH_FUNC_SBRK],
2197[
8868edaf
CR
2198 AC_MSG_CHECKING([for sbrk])
2199 AC_CACHE_VAL(ac_cv_func_sbrk,
74091dd4
CR
2200 [AC_LINK_IFELSE(
2201 [AC_LANG_PROGRAM(
2202 [[#include <unistd.h>]],
2203 [[ void *x = sbrk (4096); ]])],
2204 [ac_cv_func_sbrk=yes],[ac_cv_func_sbrk=no])])
8868edaf 2205 AC_MSG_RESULT($ac_cv_func_sbrk)
d233b485
CR
2206 if test X$ac_cv_func_sbrk = Xyes; then
2207 AC_CACHE_CHECK([for working sbrk], [bash_cv_func_sbrk],
74091dd4 2208 [AC_RUN_IFELSE([AC_LANG_SOURCE([[
d233b485
CR
2209#include <stdlib.h>
2210#include <unistd.h>
2211
2212int
2213main(int c, char **v)
2214{
2215 void *x;
2216
2217 x = sbrk (4096);
2218 exit ((x == (void *)-1) ? 1 : 0);
2219}
74091dd4
CR
2220]])],[bash_cv_func_sbrk=yes],[bash_cv_func_sbrk=no],[AC_MSG_WARN([cannot check working sbrk if cross-compiling])
2221 bash_cv_func_sbrk=yes
2222])])
d233b485
CR
2223 if test $bash_cv_func_sbrk = no; then
2224 ac_cv_func_sbrk=no
2225 fi
2226 fi
8868edaf
CR
2227 if test $ac_cv_func_sbrk = yes; then
2228 AC_DEFINE(HAVE_SBRK, 1,
d233b485
CR
2229 [Define if you have a working sbrk function.])
2230 fi
2231])
2232
2233AC_DEFUN(BASH_FUNC_FNMATCH_EQUIV_FALLBACK,
2234[AC_MSG_CHECKING(whether fnmatch can be used to check bracket equivalence classes)
2235AC_CACHE_VAL(bash_cv_fnmatch_equiv_fallback,
74091dd4 2236[AC_RUN_IFELSE([AC_LANG_SOURCE([[
d233b485
CR
2237#include <stdlib.h>
2238#include <unistd.h>
2239#include <stdio.h>
2240#include <fnmatch.h>
2241#include <locale.h>
2242
2243char *pattern = "[[=a=]]";
2244
2245/* char *string = "รค"; */
2246unsigned char string[4] = { '\xc3', '\xa4', '\0' };
2247
2248int
2249main (int c, char **v)
2250{
8868edaf 2251 setlocale (LC_ALL, "en_US.UTF-8");
d233b485
CR
2252 if (fnmatch (pattern, (const char *)string, 0) != FNM_NOMATCH)
2253 exit (0);
2254 exit (1);
2255}
74091dd4 2256]])], [bash_cv_fnmatch_equiv_fallback=yes], [bash_cv_fnmatch_equiv_fallback=no],
d233b485
CR
2257 [AC_MSG_WARN(cannot check fnmatch if cross compiling -- defaulting to no)
2258 bash_cv_fnmatch_equiv_fallback=no]
2259)])
2260AC_MSG_RESULT($bash_cv_fnmatch_equiv_fallback)
2261if test "$bash_cv_fnmatch_equiv_fallback" = "yes" ; then
2262 bash_cv_fnmatch_equiv_value=1
2263else
2264 bash_cv_fnmatch_equiv_value=0
2265fi
2266AC_DEFINE_UNQUOTED([FNMATCH_EQUIV_FALLBACK], [$bash_cv_fnmatch_equiv_value], [Whether fnmatch can be used for bracket equivalence classes])
2267])