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