]> git.ipfire.org Git - thirdparty/bash.git/blob - aclocal.m4
Bash-5.2 patch 26: fix typo when specifying readline's custom color prefix
[thirdparty/bash.git] / aclocal.m4
1 dnl
2 dnl Bash specific tests
3 dnl
4 dnl Some derived from PDKSH 5.1.3 autoconf tests
5 dnl
6 dnl Copyright (C) 1987-2021 Free Software Foundation, Inc.
7 dnl
8
9 dnl
10 dnl Check for <inttypes.h>. This is separated out so that it can be
11 dnl AC_REQUIREd.
12 dnl
13 dnl BASH_HEADER_INTTYPES
14 AC_DEFUN(BASH_HEADER_INTTYPES,
15 [
16 AC_CHECK_HEADERS(inttypes.h)
17 ])
18
19 dnl
20 dnl check for typedef'd symbols in header files, but allow the caller to
21 dnl specify the include files to be checked in addition to the default
22 dnl
23 dnl This could be changed to use AC_COMPILE_IFELSE instead of AC_EGREP_CPP
24 dnl
25 dnl BASH_CHECK_TYPE(TYPE, HEADERS, DEFAULT[, VALUE-IF-FOUND])
26 AC_DEFUN(BASH_CHECK_TYPE,
27 [
28 AC_REQUIRE([BASH_HEADER_INTTYPES])
29 AC_MSG_CHECKING(for $1)
30 AC_CACHE_VAL(bash_cv_type_$1,
31 [AC_EGREP_CPP($1, [#include <sys/types.h>
32 #if HAVE_STDLIB_H
33 #include <stdlib.h>
34 #endif
35 #if HAVE_STDDEF_H
36 #include <stddef.h>
37 #endif
38 #if HAVE_INTTYPES_H
39 #include <inttypes.h>
40 #endif
41 #if HAVE_STDINT_H
42 #include <stdint.h>
43 #endif
44 $2
45 ], bash_cv_type_$1=yes, bash_cv_type_$1=no)])
46 AC_MSG_RESULT($bash_cv_type_$1)
47 ifelse($#, 4, [if test $bash_cv_type_$1 = yes; then
48 AC_DEFINE($4)
49 fi])
50 if test $bash_cv_type_$1 = no; then
51 AC_DEFINE_UNQUOTED($1, $3)
52 fi
53 ])
54
55 dnl
56 dnl BASH_CHECK_DECL(FUNC)
57 dnl
58 dnl Check for a declaration of FUNC in stdlib.h and inttypes.h like
59 dnl AC_CHECK_DECL
60 dnl
61 AC_DEFUN(BASH_CHECK_DECL,
62 [
63 AC_REQUIRE([BASH_HEADER_INTTYPES])
64 AC_CHECK_DECLS([$1])
65 ])
66
67 AC_DEFUN(BASH_DECL_PRINTF,
68 [AC_MSG_CHECKING(for declaration of printf in <stdio.h>)
69 AC_CACHE_VAL(bash_cv_printf_declared,
70 [AC_RUN_IFELSE([AC_LANG_SOURCE([[
71 #include <stdio.h>
72 #ifdef __STDC__
73 typedef int (*_bashfunc)(const char *, ...);
74 #else
75 typedef int (*_bashfunc)();
76 #endif
77 #include <stdlib.h>
78 int
79 main()
80 {
81 _bashfunc pf;
82 pf = (_bashfunc) printf;
83 exit(pf == 0);
84 }
85 ]])], [bash_cv_printf_declared=yes], [bash_cv_printf_declared=no],
86 [AC_MSG_WARN(cannot check printf declaration if cross compiling -- defaulting to yes)
87 bash_cv_printf_declared=yes]
88 )])
89 AC_MSG_RESULT($bash_cv_printf_declared)
90 if test $bash_cv_printf_declared = yes; then
91 AC_DEFINE(PRINTF_DECLARED)
92 fi
93 ])
94
95 AC_DEFUN(BASH_DECL_SBRK,
96 [AC_MSG_CHECKING(for declaration of sbrk in <unistd.h>)
97 AC_CACHE_VAL(bash_cv_sbrk_declared,
98 [AC_EGREP_HEADER(sbrk, unistd.h,
99 bash_cv_sbrk_declared=yes, bash_cv_sbrk_declared=no)])
100 AC_MSG_RESULT($bash_cv_sbrk_declared)
101 if test $bash_cv_sbrk_declared = yes; then
102 AC_DEFINE(SBRK_DECLARED)
103 fi
104 ])
105
106 dnl
107 dnl Check for sys_siglist[] or _sys_siglist[]
108 dnl
109 AC_DEFUN(BASH_DECL_UNDER_SYS_SIGLIST,
110 [AC_MSG_CHECKING([for _sys_siglist in signal.h or unistd.h])
111 AC_CACHE_VAL(bash_cv_decl_under_sys_siglist,
112 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
113 #include <sys/types.h>
114 #include <signal.h>
115 #ifdef HAVE_UNISTD_H
116 #include <unistd.h>
117 #endif]], [[ char *msg = _sys_siglist[2]; ]])],
118 [bash_cv_decl_under_sys_siglist=yes], [bash_cv_decl_under_sys_siglist=no],
119 [AC_MSG_WARN(cannot check for _sys_siglist[] if cross compiling -- defaulting to no)])])dnl
120 AC_MSG_RESULT($bash_cv_decl_under_sys_siglist)
121 if test $bash_cv_decl_under_sys_siglist = yes; then
122 AC_DEFINE(UNDER_SYS_SIGLIST_DECLARED)
123 fi
124 ])
125
126 AC_DEFUN(BASH_UNDER_SYS_SIGLIST,
127 [AC_REQUIRE([BASH_DECL_UNDER_SYS_SIGLIST])
128 AC_MSG_CHECKING([for _sys_siglist in system C library])
129 AC_CACHE_VAL(bash_cv_under_sys_siglist,
130 [AC_RUN_IFELSE([AC_LANG_SOURCE([[
131 #include <sys/types.h>
132 #include <signal.h>
133 #ifdef HAVE_UNISTD_H
134 #include <unistd.h>
135 #endif
136 #include <stdlib.h>
137 #ifndef UNDER_SYS_SIGLIST_DECLARED
138 extern char *_sys_siglist[];
139 #endif
140 int
141 main()
142 {
143 char *msg = (char *)_sys_siglist[2];
144 exit(msg == 0);
145 }
146 ]])],
147 [bash_cv_under_sys_siglist=yes], [bash_cv_under_sys_siglist=no],
148 [AC_MSG_WARN(cannot check for _sys_siglist[] if cross compiling -- defaulting to no)
149 bash_cv_under_sys_siglist=no]
150 )])
151 AC_MSG_RESULT($bash_cv_under_sys_siglist)
152 if test $bash_cv_under_sys_siglist = yes; then
153 AC_DEFINE(HAVE_UNDER_SYS_SIGLIST)
154 fi
155 ])
156
157 dnl this defines HAVE_DECL_SYS_SIGLIST
158 AC_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
168 AC_DEFUN(BASH_SYS_SIGLIST,
169 [AC_REQUIRE([BASH_DECL_SYS_SIGLIST])
170 AC_MSG_CHECKING([for sys_siglist in system C library])
171 AC_CACHE_VAL(bash_cv_sys_siglist,
172 [AC_RUN_IFELSE([AC_LANG_SOURCE([[
173 #include <sys/types.h>
174 #include <signal.h>
175 #ifdef HAVE_UNISTD_H
176 #include <unistd.h>
177 #endif
178 #include <stdlib.h>
179 #if !HAVE_DECL_SYS_SIGLIST
180 extern char *sys_siglist[];
181 #endif
182 int
183 main()
184 {
185 char *msg = sys_siglist[2];
186 exit(msg == 0);
187 }
188 ]])], [bash_cv_sys_siglist=yes], [bash_cv_sys_siglist=no],
189 [AC_MSG_WARN(cannot check for sys_siglist if cross compiling -- defaulting to no)
190 bash_cv_sys_siglist=no]
191 )])
192 AC_MSG_RESULT($bash_cv_sys_siglist)
193 if test $bash_cv_sys_siglist = yes; then
194 AC_DEFINE(HAVE_SYS_SIGLIST)
195 fi
196 ])
197
198 dnl Check for the various permutations of sys_siglist and make sure we
199 dnl compile in siglist.o if they're not defined
200 AC_DEFUN(BASH_CHECK_SYS_SIGLIST, [
201 AC_REQUIRE([BASH_SYS_SIGLIST])
202 AC_REQUIRE([BASH_DECL_UNDER_SYS_SIGLIST])
203 AC_REQUIRE([BASH_FUNC_STRSIGNAL])
204 if 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
206 else
207 SIGLIST_O=
208 fi
209 AC_SUBST([SIGLIST_O])
210 ])
211
212 dnl Check for sys_errlist[] and sys_nerr, check for declaration
213 AC_DEFUN(BASH_SYS_ERRLIST,
214 [AC_MSG_CHECKING([for sys_errlist and sys_nerr])
215 AC_CACHE_VAL(bash_cv_sys_errlist,
216 [AC_LINK_IFELSE([AC_LANG_PROGRAM([[
217 #include <errno.h>
218 ]],[[
219 extern char *sys_errlist[];
220 extern int sys_nerr;
221 char *msg = sys_errlist[sys_nerr - 1];
222 ]] )],
223 [bash_cv_sys_errlist=yes], [bash_cv_sys_errlist=no]
224 )])
225 AC_MSG_RESULT($bash_cv_sys_errlist)
226 if test $bash_cv_sys_errlist = yes; then
227 AC_DEFINE(HAVE_SYS_ERRLIST)
228 fi
229 ])
230
231 dnl
232 dnl Check if dup2() does not clear the close on exec flag
233 dnl
234 AC_DEFUN(BASH_FUNC_DUP2_CLOEXEC_CHECK,
235 [AC_MSG_CHECKING(if dup2 fails to clear the close-on-exec flag)
236 AC_CACHE_VAL(bash_cv_dup2_broken,
237 [AC_RUN_IFELSE([AC_LANG_SOURCE([[
238 #include <sys/types.h>
239 #include <fcntl.h>
240 #include <stdlib.h>
241 int
242 main()
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 }
255 ]])], [bash_cv_dup2_broken=yes], [bash_cv_dup2_broken=no],
256 [AC_MSG_WARN(cannot check dup2 if cross compiling -- defaulting to no)
257 bash_cv_dup2_broken=no]
258 )])
259 AC_MSG_RESULT($bash_cv_dup2_broken)
260 if test $bash_cv_dup2_broken = yes; then
261 AC_DEFINE(DUP2_BROKEN)
262 fi
263 ])
264
265 AC_DEFUN(BASH_FUNC_STRSIGNAL,
266 [AC_MSG_CHECKING([for the existence of strsignal])
267 AC_CACHE_VAL(bash_cv_have_strsignal,
268 [AC_LINK_IFELSE(
269 [AC_LANG_PROGRAM([[#include <sys/types.h>
270 #include <signal.h>
271 #include <string.h>]],
272 [[char *s = (char *)strsignal(2);]])],
273 [bash_cv_have_strsignal=yes], [bash_cv_have_strsignal=no])])
274 AC_MSG_RESULT($bash_cv_have_strsignal)
275 if test $bash_cv_have_strsignal = yes; then
276 AC_DEFINE(HAVE_STRSIGNAL)
277 fi
278 ])
279
280 dnl Check to see if opendir will open non-directories (not a nice thing)
281 AC_DEFUN(BASH_FUNC_OPENDIR_CHECK,
282 [AC_REQUIRE([AC_HEADER_DIRENT])dnl
283 AC_MSG_CHECKING(if opendir() opens non-directories)
284 AC_CACHE_VAL(bash_cv_opendir_not_robust,
285 [AC_RUN_IFELSE([AC_LANG_SOURCE([[
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 */
292 #ifdef HAVE_SYS_STAT_H
293 #include <sys/stat.h>
294 #endif
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 */
309 #include <stdlib.h>
310 int
311 main()
312 {
313 DIR *dir;
314 int fd, err;
315 err = mkdir("bash-aclocal", 0700);
316 if (err < 0) {
317 perror("mkdir");
318 exit(1);
319 }
320 unlink("bash-aclocal/not_a_directory");
321 fd = open("bash-aclocal/not_a_directory", O_WRONLY|O_CREAT|O_EXCL, 0666);
322 write(fd, "\n", 1);
323 close(fd);
324 dir = opendir("bash-aclocal/not_a_directory");
325 unlink("bash-aclocal/not_a_directory");
326 rmdir("bash-aclocal");
327 exit (dir == 0);
328 }
329 ]])], [bash_cv_opendir_not_robust=yes], [bash_cv_opendir_not_robust=no],
330 [AC_MSG_WARN(cannot check opendir if cross compiling -- defaulting to no)
331 bash_cv_opendir_not_robust=no]
332 )])
333 AC_MSG_RESULT($bash_cv_opendir_not_robust)
334 if test $bash_cv_opendir_not_robust = yes; then
335 AC_DEFINE(OPENDIR_NOT_ROBUST)
336 fi
337 ])
338
339 dnl
340 dnl A signed 16-bit integer quantity
341 dnl
342 AC_DEFUN(BASH_TYPE_BITS16_T,
343 [
344 if test "$ac_cv_sizeof_short" = 2; then
345 AC_CHECK_TYPE(bits16_t, short)
346 elif test "$ac_cv_sizeof_char" = 2; then
347 AC_CHECK_TYPE(bits16_t, char)
348 else
349 AC_CHECK_TYPE(bits16_t, short)
350 fi
351 ])
352
353 dnl
354 dnl An unsigned 16-bit integer quantity
355 dnl
356 AC_DEFUN(BASH_TYPE_U_BITS16_T,
357 [
358 if test "$ac_cv_sizeof_short" = 2; then
359 AC_CHECK_TYPE(u_bits16_t, unsigned short)
360 elif test "$ac_cv_sizeof_char" = 2; then
361 AC_CHECK_TYPE(u_bits16_t, unsigned char)
362 else
363 AC_CHECK_TYPE(u_bits16_t, unsigned short)
364 fi
365 ])
366
367 dnl
368 dnl A signed 32-bit integer quantity
369 dnl
370 AC_DEFUN(BASH_TYPE_BITS32_T,
371 [
372 if test "$ac_cv_sizeof_int" = 4; then
373 AC_CHECK_TYPE(bits32_t, int)
374 elif test "$ac_cv_sizeof_long" = 4; then
375 AC_CHECK_TYPE(bits32_t, long)
376 else
377 AC_CHECK_TYPE(bits32_t, int)
378 fi
379 ])
380
381 dnl
382 dnl An unsigned 32-bit integer quantity
383 dnl
384 AC_DEFUN(BASH_TYPE_U_BITS32_T,
385 [
386 if test "$ac_cv_sizeof_int" = 4; then
387 AC_CHECK_TYPE(u_bits32_t, unsigned int)
388 elif test "$ac_cv_sizeof_long" = 4; then
389 AC_CHECK_TYPE(u_bits32_t, unsigned long)
390 else
391 AC_CHECK_TYPE(u_bits32_t, unsigned int)
392 fi
393 ])
394
395 AC_DEFUN(BASH_TYPE_PTRDIFF_T,
396 [
397 if test "$ac_cv_sizeof_int" = "$ac_cv_sizeof_char_p"; then
398 AC_CHECK_TYPE(ptrdiff_t, int)
399 elif test "$ac_cv_sizeof_long" = "$ac_cv_sizeof_char_p"; then
400 AC_CHECK_TYPE(ptrdiff_t, long)
401 elif 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])
403 else
404 AC_CHECK_TYPE(ptrdiff_t, int)
405 fi
406 ])
407
408 dnl
409 dnl A signed 64-bit quantity
410 dnl
411 AC_DEFUN(BASH_TYPE_BITS64_T,
412 [
413 if test "$ac_cv_sizeof_char_p" = 8; then
414 AC_CHECK_TYPE(bits64_t, char *)
415 elif test "$ac_cv_sizeof_double" = 8; then
416 AC_CHECK_TYPE(bits64_t, double)
417 elif test -n "$ac_cv_type_long_long" && test "$ac_cv_sizeof_long_long" = 8; then
418 AC_CHECK_TYPE(bits64_t, [long long])
419 elif test "$ac_cv_sizeof_long" = 8; then
420 AC_CHECK_TYPE(bits64_t, long)
421 else
422 AC_CHECK_TYPE(bits64_t, double)
423 fi
424 ])
425
426 AC_DEFUN(BASH_SIZEOF_RLIMIT,
427 [AC_MSG_CHECKING(for size of struct rlimit fields)
428 AC_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>
435 main()
436 {
437 struct rlimit r;
438 exit(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 )])
444 AC_MSG_RESULT($bash_cv_sizeof_rlim_cur)
445 ])
446
447 AC_DEFUN(BASH_SIZEOF_QUAD_T,
448 [AC_MSG_CHECKING(for size of quad_t)
449 AC_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
460 main()
461 {
462 #if HAVE_QUAD_T
463 quad_t x;
464 exit(sizeof (x));
465 #else
466 exit (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 )])
473 AC_MSG_RESULT($bash_cv_sizeof_quad_t)
474 ])
475
476 dnl
477 dnl Type of struct rlimit fields: updated to check POSIX rlim_t and
478 dnl if it doesn't exist determine the best guess based on sizeof(r.rlim_cur)
479 dnl
480 AC_DEFUN(BASH_TYPE_RLIMIT,
481 [AC_MSG_CHECKING(for type of struct rlimit fields)
482 AC_CACHE_VAL(bash_cv_type_rlimit,
483 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
484 #include <sys/types.h>
485 #include <sys/resource.h>]],
486 [[rlim_t xxx;]]
487 )],
488 [bash_cv_type_rlimit=rlim_t], [
489 BASH_SIZEOF_RLIMIT
490 BASH_SIZEOF_QUAD_T
491 if test $bash_cv_sizeof_rlim_cur = $ac_cv_sizeof_long; then
492 bash_cv_type_rlimit='unsigned long'
493 elif test $bash_cv_sizeof_rlim_cur = $ac_cv_sizeof_long_long; then
494 bash_cv_type_rlimit='unsigned long long'
495 elif test $bash_cv_sizeof_rlim_cur = $ac_cv_sizeof_int; then
496 bash_cv_type_rlimit='unsigned int'
497 elif test $bash_cv_sizeof_rlim_cur = $bash_cv_sizeof_quad_t; then
498 bash_cv_type_rlimit='quad_t'
499 else
500 bash_cv_type_rlimit='unsigned long'
501 fi
502 ]
503 )])
504 AC_MSG_RESULT($bash_cv_type_rlimit)
505 AC_DEFINE_UNQUOTED([RLIMTYPE], [$bash_cv_type_rlimit])
506 ])
507
508 AC_DEFUN(BASH_TYPE_SIG_ATOMIC_T,
509 [AC_CACHE_CHECK([for sig_atomic_t in signal.h], ac_cv_have_sig_atomic_t,
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])])
515 if test "$ac_cv_have_sig_atomic_t" = "no"
516 then
517 BASH_CHECK_TYPE(sig_atomic_t, [#include <signal.h>], int)
518 fi
519 ])
520
521 AC_DEFUN(BASH_FUNC_LSTAT,
522 [dnl Cannot use AC_CHECK_FUNCS(lstat) because Linux defines lstat() as an
523 dnl inline function in <sys/stat.h>.
524 AC_CACHE_CHECK([for lstat], bash_cv_func_lstat,
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])])
532 if test $bash_cv_func_lstat = yes; then
533 AC_DEFINE(HAVE_LSTAT)
534 fi
535 ])
536
537 AC_DEFUN(BASH_FUNC_INET_ATON,
538 [
539 AC_CACHE_CHECK([for inet_aton], bash_cv_func_inet_aton,
540 [AC_LINK_IFELSE([AC_LANG_PROGRAM([[
541 #include <sys/types.h>
542 #include <netinet/in.h>
543 #include <arpa/inet.h>
544 struct in_addr ap;]], [[ inet_aton("127.0.0.1", &ap); ]])],
545 [bash_cv_func_inet_aton=yes], [bash_cv_func_inet_aton=no])])
546 if test $bash_cv_func_inet_aton = yes; then
547 AC_DEFINE(HAVE_INET_ATON)
548 else
549 AC_LIBOBJ(inet_aton)
550 fi
551 ])
552
553 AC_DEFUN(BASH_FUNC_GETENV,
554 [AC_MSG_CHECKING(to see if getenv can be redefined)
555 AC_CACHE_VAL(bash_cv_getenv_redef,
556 [AC_RUN_IFELSE([AC_LANG_SOURCE([[
557 #ifdef HAVE_UNISTD_H
558 # include <unistd.h>
559 #endif
560 #include <stdlib.h>
561 #ifndef __STDC__
562 # ifndef const
563 # define const
564 # endif
565 #endif
566 char *
567 getenv (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 {
574 return "42";
575 }
576 int
577 main()
578 {
579 char *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)
584 exit(1);
585 #endif
586 s = getenv("ABCDE");
587 exit(s == 0); /* force optimizer to leave getenv in */
588 }
589 ]])], [bash_cv_getenv_redef=yes], [bash_cv_getenv_redef=no],
590 [AC_MSG_WARN(cannot check getenv redefinition if cross compiling -- defaulting to yes)
591 bash_cv_getenv_redef=yes]
592 )])
593 AC_MSG_RESULT($bash_cv_getenv_redef)
594 if test $bash_cv_getenv_redef = yes; then
595 AC_DEFINE(CAN_REDEFINE_GETENV)
596 fi
597 ])
598
599 # We should check for putenv before calling this
600 AC_DEFUN(BASH_FUNC_STD_PUTENV,
601 [
602 AC_REQUIRE([AC_C_PROTOTYPES])
603 AC_CACHE_CHECK([for standard-conformant putenv declaration], bash_cv_std_putenv,
604 [AC_LINK_IFELSE([AC_LANG_PROGRAM([[
605 #if HAVE_STDLIB_H
606 #include <stdlib.h>
607 #endif
608 #if HAVE_STDDEF_H
609 #include <stddef.h>
610 #endif
611 #ifndef __STDC__
612 # ifndef const
613 # define const
614 # endif
615 #endif
616 #ifdef PROTOTYPES
617 extern int putenv (char *);
618 #else
619 extern int putenv ();
620 #endif
621 ]], [[return (putenv == 0);]] )],
622 [bash_cv_std_putenv=yes], [bash_cv_std_putenv=no]
623 )])
624 if test $bash_cv_std_putenv = yes; then
625 AC_DEFINE(HAVE_STD_PUTENV)
626 fi
627 ])
628
629 # We should check for unsetenv before calling this
630 AC_DEFUN(BASH_FUNC_STD_UNSETENV,
631 [
632 AC_REQUIRE([AC_C_PROTOTYPES])
633 AC_CACHE_CHECK([for standard-conformant unsetenv declaration], bash_cv_std_unsetenv,
634 [AC_LINK_IFELSE([AC_LANG_PROGRAM([[
635 #if HAVE_STDLIB_H
636 #include <stdlib.h>
637 #endif
638 #if HAVE_STDDEF_H
639 #include <stddef.h>
640 #endif
641 #ifndef __STDC__
642 # ifndef const
643 # define const
644 # endif
645 #endif
646 #ifdef PROTOTYPES
647 extern int unsetenv (const char *);
648 #else
649 extern int unsetenv ();
650 #endif
651 ]], [[return (unsetenv == 0);]] )],
652 [bash_cv_std_unsetenv=yes], [bash_cv_std_unsetenv=no]
653 )])
654 if test $bash_cv_std_unsetenv = yes; then
655 AC_DEFINE(HAVE_STD_UNSETENV)
656 fi
657 ])
658
659 AC_DEFUN(BASH_FUNC_ULIMIT_MAXFDS,
660 [AC_MSG_CHECKING(whether ulimit can substitute for getdtablesize)
661 AC_CACHE_VAL(bash_cv_ulimit_maxfds,
662 [AC_RUN_IFELSE([AC_LANG_SOURCE([[
663 #include <stdlib.h>
664 #ifdef HAVE_ULIMIT_H
665 #include <ulimit.h>
666 #endif
667 int
668 main()
669 {
670 long maxfds = ulimit(4, 0L);
671 exit (maxfds == -1L);
672 }
673 ]])], [bash_cv_ulimit_maxfds=yes], [bash_cv_ulimit_maxfds=no],
674 [AC_MSG_WARN(cannot check ulimit if cross compiling -- defaulting to no)
675 bash_cv_ulimit_maxfds=no]
676 )])
677 AC_MSG_RESULT($bash_cv_ulimit_maxfds)
678 if test $bash_cv_ulimit_maxfds = yes; then
679 AC_DEFINE(ULIMIT_MAXFDS)
680 fi
681 ])
682
683 AC_DEFUN(BASH_FUNC_GETCWD,
684 [AC_MSG_CHECKING([if getcwd() will dynamically allocate memory with 0 size])
685 AC_CACHE_VAL(bash_cv_getcwd_malloc,
686 [AC_RUN_IFELSE([AC_LANG_SOURCE([[
687 #include <stdio.h>
688 #ifdef HAVE_UNISTD_H
689 #include <unistd.h>
690 #endif
691 #include <stdlib.h>
692
693 int
694 main()
695 {
696 char *xpwd;
697 xpwd = getcwd(0, 0);
698 exit (xpwd == 0);
699 }
700 ]])], [bash_cv_getcwd_malloc=yes], [bash_cv_getcwd_malloc=no],
701 [AC_MSG_WARN(cannot check whether getcwd allocates memory when cross-compiling -- defaulting to no)
702 bash_cv_getcwd_malloc=no]
703 )])
704 AC_MSG_RESULT($bash_cv_getcwd_malloc)
705 if test $bash_cv_getcwd_malloc = no; then
706 AC_DEFINE(GETCWD_BROKEN)
707 AC_LIBOBJ(getcwd)
708 fi
709 ])
710
711 dnl
712 dnl This needs BASH_CHECK_SOCKLIB, but since that's not called on every
713 dnl system, we can't use AC_PREREQ. Only called if we need the socket library
714 dnl
715 AC_DEFUN(BASH_FUNC_GETHOSTBYNAME,
716 [if test "X$bash_cv_have_gethostbyname" = "X"; then
717 _bash_needmsg=yes
718 else
719 AC_MSG_CHECKING(for gethostbyname in socket library)
720 _bash_needmsg=
721 fi
722 AC_CACHE_VAL(bash_cv_have_gethostbyname,
723 [AC_LINK_IFELSE([AC_LANG_PROGRAM([[
724 #include <netdb.h>
725 ]], [[
726 struct hostent *hp;
727 hp = gethostbyname("localhost");
728 ]] )],
729 [bash_cv_have_gethostbyname=yes], [bash_cv_have_gethostbyname=no]
730 )])
731 if test "X$_bash_needmsg" = Xyes; then
732 AC_MSG_CHECKING(for gethostbyname in socket library)
733 fi
734 AC_MSG_RESULT($bash_cv_have_gethostbyname)
735 if test "$bash_cv_have_gethostbyname" = yes; then
736 AC_DEFINE(HAVE_GETHOSTBYNAME)
737 fi
738 ])
739
740 AC_DEFUN(BASH_FUNC_FNMATCH_EXTMATCH,
741 [AC_MSG_CHECKING(if fnmatch does extended pattern matching with FNM_EXTMATCH)
742 AC_CACHE_VAL(bash_cv_fnm_extmatch,
743 [AC_RUN_IFELSE([AC_LANG_SOURCE([[
744 #include <fnmatch.h>
745
746 int
747 main()
748 {
749 #ifdef FNM_EXTMATCH
750 return (0);
751 #else
752 return (1);
753 #endif
754 }
755 ]])], [bash_cv_fnm_extmatch=yes], [bash_cv_fnm_extmatch=no],
756 [AC_MSG_WARN(cannot check FNM_EXTMATCH if cross compiling -- defaulting to no)
757 bash_cv_fnm_extmatch=no]
758 )])
759 AC_MSG_RESULT($bash_cv_fnm_extmatch)
760 if test $bash_cv_fnm_extmatch = yes; then
761 AC_DEFINE(HAVE_LIBC_FNM_EXTMATCH)
762 fi
763 ])
764
765 AC_DEFUN(BASH_FUNC_POSIX_SETJMP,
766 [AC_REQUIRE([BASH_SYS_SIGNAL_VINTAGE])
767 AC_MSG_CHECKING(for presence of POSIX-style sigsetjmp/siglongjmp)
768 AC_CACHE_VAL(bash_cv_func_sigsetjmp,
769 [AC_RUN_IFELSE([AC_LANG_SOURCE([[
770 #ifdef HAVE_UNISTD_H
771 #include <unistd.h>
772 #endif
773 #include <sys/types.h>
774 #include <signal.h>
775 #include <setjmp.h>
776 #include <stdlib.h>
777
778 int
779 main()
780 {
781 #if !defined (_POSIX_VERSION) || !defined (HAVE_POSIX_SIGNALS)
782 exit (1);
783 #else
784
785 int code;
786 sigset_t set, oset, nset;
787 sigjmp_buf xx;
788
789 /* get the mask */
790 sigemptyset(&set);
791 sigemptyset(&oset);
792
793 sigprocmask(SIG_BLOCK, (sigset_t *)NULL, &oset);
794 /* paranoia -- make sure SIGINT is not blocked */
795 sigdelset (&oset, SIGINT);
796 sigprocmask (SIG_SETMASK, &oset, (sigset_t *)NULL);
797
798 /* save it */
799 code = sigsetjmp(xx, 1);
800 if (code)
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 }
808
809 /* change it so that SIGINT is blocked */
810 sigaddset(&set, SIGINT);
811 sigprocmask(SIG_BLOCK, &set, (sigset_t *)NULL);
812
813 /* and siglongjmp */
814 siglongjmp(xx, 10);
815 exit(1);
816 #endif
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]
825 )])
826 AC_MSG_RESULT($bash_cv_func_sigsetjmp)
827 if test $bash_cv_func_sigsetjmp = present; then
828 AC_DEFINE(HAVE_POSIX_SIGSETJMP)
829 fi
830 ])
831
832 AC_DEFUN(BASH_FUNC_STRCOLL,
833 [AC_MSG_CHECKING(whether or not strcoll and strcmp differ)
834 AC_CACHE_VAL(bash_cv_func_strcoll_broken,
835 [AC_RUN_IFELSE([AC_LANG_SOURCE([[
836 #include <stdio.h>
837 #if defined (HAVE_LOCALE_H)
838 #include <locale.h>
839 #endif
840 #include <string.h>
841 #include <stdlib.h>
842
843 int
844 main(c, v)
845 int c;
846 char *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 }
873 ]])], [bash_cv_func_strcoll_broken=yes], [bash_cv_func_strcoll_broken=no],
874 [AC_MSG_WARN(cannot check strcoll if cross compiling -- defaulting to no)
875 bash_cv_func_strcoll_broken=no]
876 )])
877 AC_MSG_RESULT($bash_cv_func_strcoll_broken)
878 if test $bash_cv_func_strcoll_broken = yes; then
879 AC_DEFINE(STRCOLL_BROKEN)
880 fi
881 ])
882
883 AC_DEFUN(BASH_FUNC_PRINTF_A_FORMAT,
884 [AC_MSG_CHECKING([for printf floating point output in hex notation])
885 AC_CACHE_VAL(bash_cv_printf_a_format,
886 [AC_RUN_IFELSE([AC_LANG_SOURCE([[
887 #include <stdio.h>
888 #include <string.h>
889 #include <stdlib.h>
890
891 int
892 main()
893 {
894 double y = 0.0;
895 char abuf[1024];
896
897 sprintf(abuf, "%A", y);
898 exit(strchr(abuf, 'P') == (char *)0);
899 }
900 ]])], [bash_cv_printf_a_format=yes], [bash_cv_printf_a_format=no],
901 [AC_MSG_WARN(cannot check printf if cross compiling -- defaulting to no)
902 bash_cv_printf_a_format=no]
903 )])
904 AC_MSG_RESULT($bash_cv_printf_a_format)
905 if test $bash_cv_printf_a_format = yes; then
906 AC_DEFINE(HAVE_PRINTF_A_FORMAT)
907 fi
908 ])
909
910 AC_DEFUN(BASH_STRUCT_TERMIOS_LDISC,
911 [
912 AC_CHECK_MEMBER(struct termios.c_line, AC_DEFINE(TERMIOS_LDISC), ,[
913 #include <sys/types.h>
914 #include <termios.h>
915 ])
916 ])
917
918 AC_DEFUN(BASH_STRUCT_TERMIO_LDISC,
919 [
920 AC_CHECK_MEMBER(struct termio.c_line, AC_DEFINE(TERMIO_LDISC), ,[
921 #include <sys/types.h>
922 #include <termio.h>
923 ])
924 ])
925
926 dnl
927 dnl Like AC_STRUCT_ST_BLOCKS, but doesn't muck with LIBOBJS
928 dnl
929 dnl sets bash_cv_struct_stat_st_blocks
930 dnl
931 dnl unused for now; we'll see how AC_CHECK_MEMBERS works
932 dnl
933 AC_DEFUN(BASH_STRUCT_ST_BLOCKS,
934 [
935 AC_MSG_CHECKING([for struct stat.st_blocks])
936 AC_CACHE_VAL(bash_cv_struct_stat_st_blocks,
937 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
938 #include <sys/types.h>
939 #include <sys/stat.h>
940 ]], [[
941 int
942 main()
943 {
944 static struct stat a;
945 if (a.st_blocks) return 0;
946 return 0;
947 }
948 ]])], [bash_cv_struct_stat_st_blocks=yes], [bash_cv_struct_stat_st_blocks=no])
949 ])
950 AC_MSG_RESULT($bash_cv_struct_stat_st_blocks)
951 if test "$bash_cv_struct_stat_st_blocks" = "yes"; then
952 AC_DEFINE(HAVE_STRUCT_STAT_ST_BLOCKS)
953 fi
954 ])
955
956 AC_DEFUN([BASH_CHECK_LIB_TERMCAP],
957 [
958 if test "X$bash_cv_termcap_lib" = "X"; then
959 _bash_needmsg=yes
960 else
961 AC_MSG_CHECKING(which library has the termcap functions)
962 _bash_needmsg=
963 fi
964 AC_CACHE_VAL(bash_cv_termcap_lib,
965 [AC_CHECK_FUNC(tgetent, bash_cv_termcap_lib=libc,
966 [AC_CHECK_LIB(termcap, tgetent, bash_cv_termcap_lib=libtermcap,
967 [AC_CHECK_LIB(tinfo, tgetent, bash_cv_termcap_lib=libtinfo,
968 [AC_CHECK_LIB(curses, tgetent, bash_cv_termcap_lib=libcurses,
969 [AC_CHECK_LIB(ncurses, tgetent, bash_cv_termcap_lib=libncurses,
970 [AC_CHECK_LIB(ncursesw, tgetent, bash_cv_termcap_lib=libncursesw,
971 bash_cv_termcap_lib=gnutermcap)])])])])])])
972 if test "X$_bash_needmsg" = "Xyes"; then
973 AC_MSG_CHECKING(which library has the termcap functions)
974 fi
975 AC_MSG_RESULT(using $bash_cv_termcap_lib)
976 if test $bash_cv_termcap_lib = gnutermcap && test -z "$prefer_curses"; then
977 LDFLAGS="$LDFLAGS -L./lib/termcap"
978 TERMCAP_LIB="./lib/termcap/libtermcap.a"
979 TERMCAP_DEP="./lib/termcap/libtermcap.a"
980 elif test $bash_cv_termcap_lib = libtermcap && test -z "$prefer_curses"; then
981 TERMCAP_LIB=-ltermcap
982 TERMCAP_DEP=
983 elif test $bash_cv_termcap_lib = libtinfo; then
984 TERMCAP_LIB=-ltinfo
985 TERMCAP_DEP=
986 elif test $bash_cv_termcap_lib = libncurses; then
987 TERMCAP_LIB=-lncurses
988 TERMCAP_DEP=
989 elif test $bash_cv_termcap_lib = libc; then
990 TERMCAP_LIB=
991 TERMCAP_DEP=
992 else
993 # we assume ncurses is installed somewhere the linker can find it
994 TERMCAP_LIB=-lncurses
995 TERMCAP_DEP=
996 fi
997 ])
998
999 dnl
1000 dnl Check for the presence of getpeername in libsocket.
1001 dnl If libsocket is present, check for libnsl and add it to LIBS if
1002 dnl it's there, since most systems with libsocket require linking
1003 dnl with libnsl as well. This should only be called if getpeername
1004 dnl was not found in libc.
1005 dnl
1006 dnl NOTE: IF WE FIND GETPEERNAME, WE ASSUME THAT WE HAVE BIND/CONNECT
1007 dnl AS WELL
1008 dnl
1009 AC_DEFUN(BASH_CHECK_LIB_SOCKET,
1010 [
1011 if test "X$bash_cv_have_socklib" = "X"; then
1012 _bash_needmsg=
1013 else
1014 AC_MSG_CHECKING(for socket library)
1015 _bash_needmsg=yes
1016 fi
1017 AC_CACHE_VAL(bash_cv_have_socklib,
1018 [AC_CHECK_LIB(socket, getpeername,
1019 bash_cv_have_socklib=yes, bash_cv_have_socklib=no, -lnsl)])
1020 if test "X$_bash_needmsg" = Xyes; then
1021 AC_MSG_RESULT($bash_cv_have_socklib)
1022 _bash_needmsg=
1023 fi
1024 if 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)
1046 fi
1047 ])
1048
1049 dnl like _AC_STRUCT_DIRENT(MEMBER) but public
1050 AC_DEFUN(BASH_STRUCT_DIRENT,
1051 [
1052 AC_REQUIRE([AC_HEADER_DIRENT])
1053 AC_CHECK_MEMBERS(struct dirent.$1, bash_cv_dirent_has_$1=yes, bash_cv_dirent_has_$1=no,
1054 [[
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 */
1074 ]])
1075 ])
1076
1077 AC_DEFUN(BASH_STRUCT_DIRENT_D_INO,
1078 [AC_REQUIRE([AC_HEADER_DIRENT])
1079 AC_MSG_CHECKING(for struct dirent.d_ino)
1080 AC_CACHE_VAL(bash_cv_dirent_has_d_ino, [BASH_STRUCT_DIRENT([d_ino])])
1081 AC_MSG_RESULT($bash_cv_dirent_has_d_ino)
1082 if test $bash_cv_dirent_has_d_ino = yes; then
1083 AC_DEFINE(HAVE_STRUCT_DIRENT_D_INO)
1084 fi
1085 ])
1086
1087 AC_DEFUN(BASH_STRUCT_DIRENT_D_FILENO,
1088 [AC_REQUIRE([AC_HEADER_DIRENT])
1089 AC_MSG_CHECKING(for struct dirent.d_fileno)
1090 AC_CACHE_VAL(bash_cv_dirent_has_d_fileno, [BASH_STRUCT_DIRENT([d_fileno])])
1091 AC_MSG_RESULT($bash_cv_dirent_has_d_fileno)
1092 if test $bash_cv_dirent_has_d_fileno = yes; then
1093 AC_DEFINE(HAVE_STRUCT_DIRENT_D_FILENO)
1094 fi
1095 ])
1096
1097 AC_DEFUN(BASH_STRUCT_DIRENT_D_NAMLEN,
1098 [AC_REQUIRE([AC_HEADER_DIRENT])
1099 AC_MSG_CHECKING(for struct dirent.d_namlen)
1100 AC_CACHE_VAL(bash_cv_dirent_has_d_namlen, [BASH_STRUCT_DIRENT([d_namlen])])
1101 AC_MSG_RESULT($bash_cv_dirent_has_d_namlen)
1102 if test $bash_cv_dirent_has_d_namlen = yes; then
1103 AC_DEFINE(HAVE_STRUCT_DIRENT_D_NAMLEN)
1104 fi
1105 ])
1106
1107 AC_DEFUN(BASH_STRUCT_TIMEVAL,
1108 [AC_MSG_CHECKING(for struct timeval in sys/time.h and time.h)
1109 AC_CACHE_VAL(bash_cv_struct_timeval,
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)
1121 ])
1122 AC_MSG_RESULT($bash_cv_struct_timeval)
1123 if test $bash_cv_struct_timeval = yes; then
1124 AC_DEFINE(HAVE_TIMEVAL)
1125 fi
1126 ])
1127
1128 AC_DEFUN(BASH_STRUCT_TIMEZONE,
1129 [AC_MSG_CHECKING(for struct timezone in sys/time.h and time.h)
1130 AC_CACHE_VAL(bash_cv_struct_timezone,
1131 [
1132 AC_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 ])
1138 AC_MSG_RESULT($bash_cv_struct_timezone)
1139 if test $bash_cv_struct_timezone = yes; then
1140 AC_DEFINE(HAVE_STRUCT_TIMEZONE)
1141 fi
1142 ])
1143
1144 AC_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 [[
1151 struct winsize x;
1152 if (sizeof (x) > 0) return (0);
1153 ]] )], [bash_cv_struct_winsize_ioctl=yes], [bash_cv_struct_winsize_ioctl=no])
1154 ])
1155 ])
1156
1157 AC_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 [[
1164 struct winsize x;
1165 if (sizeof (x) > 0) return (0);
1166 ]] )], [bash_cv_struct_winsize_termios=yes], [bash_cv_struct_winsize_termios=no])
1167 ])
1168 ])
1169
1170 AC_DEFUN(BASH_STRUCT_WINSIZE,
1171 [AC_MSG_CHECKING(for struct winsize in sys/ioctl.h and termios.h)
1172 AC_CACHE_VAL(bash_cv_struct_winsize_header,
1173 [
1174 BASH_CHECK_WINSIZE_IOCTL
1175 BASH_CHECK_WINSIZE_TERMIOS
1176
1177 if test $bash_cv_struct_winsize_ioctl = yes; then
1178 bash_cv_struct_winsize_header=ioctl_h
1179 elif test $bash_cv_struct_winsize_termios = yes; then
1180 bash_cv_struct_winsize_header=termios_h
1181 else
1182 bash_cv_struct_winsize_header=other
1183 fi
1184 ])
1185 if test $bash_cv_struct_winsize_header = ioctl_h; then
1186 AC_MSG_RESULT(sys/ioctl.h)
1187 AC_DEFINE(STRUCT_WINSIZE_IN_SYS_IOCTL)
1188 elif test $bash_cv_struct_winsize_header = termios_h; then
1189 AC_MSG_RESULT(termios.h)
1190 AC_DEFINE(STRUCT_WINSIZE_IN_TERMIOS)
1191 else
1192 AC_MSG_RESULT(not found)
1193 fi
1194 ])
1195
1196 AC_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 ]], [[
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);
1206 ]] )],
1207 [bash_cv_posix_signals=yes], [bash_cv_posix_signals=no]
1208 )])
1209 ])
1210
1211 AC_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 ]], [[
1216 int mask = sigmask(SIGINT);
1217 sigsetmask(mask); sigblock(mask); sigpause(mask);
1218 ]] )],
1219 [bash_cv_bsd_signals=yes], [bash_cv_bsd_signals=no]
1220 )])
1221 ])
1222
1223 AC_DEFUN(BASH_HAVE_SYSV_SIGNALS,
1224 [AC_CACHE_VAL(bash_cv_sysv_signals,
1225 [AC_LINK_IFELSE([AC_LANG_PROGRAM([[
1226 #include <signal.h>
1227 void foo() { }
1228 ]], [[
1229 int mask = sigmask(SIGINT);
1230 sigset(SIGINT, foo); sigrelse(SIGINT);
1231 sighold(SIGINT); sigpause(SIGINT);
1232 ]] )],
1233 [bash_cv_sysv_signals=yes], [bash_cv_sysv_signals=no]
1234 )])
1235 ])
1236
1237 dnl Check type of signal routines (posix, 4.2bsd, 4.1bsd or v7)
1238 AC_DEFUN(BASH_SYS_SIGNAL_VINTAGE,
1239 [AC_MSG_CHECKING(for type of signal functions)
1240 AC_CACHE_VAL(bash_cv_signal_vintage,
1241 [
1242 BASH_HAVE_POSIX_SIGNALS
1243 if test $bash_cv_posix_signals = yes; then
1244 bash_cv_signal_vintage=posix
1245 else
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
1257 fi
1258 ])
1259 AC_MSG_RESULT($bash_cv_signal_vintage)
1260 if test "$bash_cv_signal_vintage" = posix; then
1261 AC_DEFINE(HAVE_POSIX_SIGNALS)
1262 elif test "$bash_cv_signal_vintage" = "4.2bsd"; then
1263 AC_DEFINE(HAVE_BSD_SIGNALS)
1264 elif test "$bash_cv_signal_vintage" = svr3; then
1265 AC_DEFINE(HAVE_USG_SIGHOLD)
1266 fi
1267 ])
1268
1269 dnl Check if the pgrp of setpgrp() can't be the pid of a zombie process.
1270 AC_DEFUN(BASH_SYS_PGRP_SYNC,
1271 [AC_REQUIRE([AC_FUNC_GETPGRP])
1272 AC_MSG_CHECKING(whether pgrps need synchronization)
1273 AC_CACHE_VAL(bash_cv_pgrp_pipe,
1274 [AC_RUN_IFELSE([AC_LANG_SOURCE([[
1275 #ifdef HAVE_UNISTD_H
1276 # include <unistd.h>
1277 #endif
1278 #ifdef HAVE_SYS_WAIT_H
1279 # include <sys/wait.h>
1280 #endif
1281 #include <stdlib.h>
1282 int
1283 main()
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 }
1327 ]])], [bash_cv_pgrp_pipe=no], [bash_cv_pgrp_pipe=yes],
1328 [AC_MSG_WARN(cannot check pgrp synchronization if cross compiling -- defaulting to no)
1329 bash_cv_pgrp_pipe=no]
1330 )])
1331 AC_MSG_RESULT($bash_cv_pgrp_pipe)
1332 if test $bash_cv_pgrp_pipe = yes; then
1333 AC_DEFINE(PGRP_PIPE)
1334 fi
1335 ])
1336
1337 AC_DEFUN(BASH_SYS_REINSTALL_SIGHANDLERS,
1338 [AC_REQUIRE([BASH_SYS_SIGNAL_VINTAGE])
1339 AC_MSG_CHECKING([if signal handlers must be reinstalled when invoked])
1340 AC_CACHE_VAL(bash_cv_must_reinstall_sighandlers,
1341 [AC_RUN_IFELSE([AC_LANG_SOURCE([[
1342 #include <signal.h>
1343 #ifdef HAVE_UNISTD_H
1344 #include <unistd.h>
1345 #endif
1346 #include <stdlib.h>
1347
1348 typedef void sigfunc();
1349
1350 volatile int nsigint;
1351
1352 #ifdef HAVE_POSIX_SIGNALS
1353 sigfunc *
1354 set_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
1370 void
1371 sigint(s)
1372 int s;
1373 {
1374 nsigint++;
1375 }
1376
1377 int
1378 main()
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 }
1386 ]])], [bash_cv_must_reinstall_sighandlers=no], [bash_cv_must_reinstall_sighandlers=yes],
1387 [AC_MSG_WARN(cannot check signal handling if cross compiling -- defaulting to no)
1388 bash_cv_must_reinstall_sighandlers=no]
1389 )])
1390 AC_MSG_RESULT($bash_cv_must_reinstall_sighandlers)
1391 if test $bash_cv_must_reinstall_sighandlers = yes; then
1392 AC_DEFINE(MUST_REINSTALL_SIGHANDLERS)
1393 fi
1394 ])
1395
1396 dnl check that some necessary job control definitions are present
1397 AC_DEFUN(BASH_SYS_JOB_CONTROL_MISSING,
1398 [AC_REQUIRE([BASH_SYS_SIGNAL_VINTAGE])
1399 AC_MSG_CHECKING(for presence of necessary job control definitions)
1400 AC_CACHE_VAL(bash_cv_job_control_missing,
1401 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
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
1411 /* add more tests in here as appropriate */
1412
1413 /* signal type */
1414 #if !defined (HAVE_POSIX_SIGNALS) && !defined (HAVE_BSD_SIGNALS)
1415 #error
1416 #endif
1417
1418 /* signals and tty control. */
1419 #if !defined (SIGTSTP) || !defined (SIGSTOP) || !defined (SIGCONT)
1420 #error
1421 #endif
1422
1423 /* process control */
1424 #if !defined (WNOHANG) || !defined (WUNTRACED)
1425 #error
1426 #endif
1427
1428 /* Posix systems have tcgetpgrp and waitpid. */
1429 #if defined (_POSIX_VERSION) && !defined (HAVE_TCGETPGRP)
1430 #error
1431 #endif
1432
1433 #if defined (_POSIX_VERSION) && !defined (HAVE_WAITPID)
1434 #error
1435 #endif
1436
1437 /* Other systems have TIOCSPGRP/TIOCGPRGP and wait3. */
1438 #if !defined (_POSIX_VERSION) && !defined (HAVE_WAIT3)
1439 #error
1440 #endif
1441
1442 ]], [[ int x; ]] )],
1443 [bash_cv_job_control_missing=present], [bash_cv_job_control_missing=missing]
1444 )])
1445 AC_MSG_RESULT($bash_cv_job_control_missing)
1446 if test $bash_cv_job_control_missing = missing; then
1447 AC_DEFINE(JOB_CONTROL_MISSING)
1448 fi
1449 ])
1450
1451 dnl check whether named pipes are present
1452 dnl this requires a previous check for mkfifo, but that is awkward to specify
1453 AC_DEFUN(BASH_SYS_NAMED_PIPES,
1454 [AC_MSG_CHECKING(for presence of named pipes)
1455 AC_CACHE_VAL(bash_cv_sys_named_pipes,
1456 [AC_RUN_IFELSE([AC_LANG_SOURCE([[
1457 #include <sys/types.h>
1458 #include <sys/stat.h>
1459 #ifdef HAVE_UNISTD_H
1460 #include <unistd.h>
1461 #endif
1462 #include <stdio.h>
1463 #include <stdlib.h>
1464
1465 /* Add more tests in here as appropriate. */
1466 int
1467 main()
1468 {
1469 int fd, err;
1470
1471 #if defined (HAVE_MKFIFO)
1472 exit (0);
1473 #endif
1474
1475 #if !defined (S_IFIFO) && (defined (_POSIX_VERSION) && !defined (S_ISFIFO))
1476 exit (1);
1477 #endif
1478
1479 #if defined (NeXT)
1480 exit (1);
1481 #endif
1482 err = mkdir("bash-aclocal", 0700);
1483 if (err < 0) {
1484 perror ("mkdir");
1485 exit(1);
1486 }
1487 fd = mknod ("bash-aclocal/sh-np-autoconf", 0666 | S_IFIFO, 0);
1488 if (fd == -1) {
1489 rmdir ("bash-aclocal");
1490 exit (1);
1491 }
1492 close(fd);
1493 unlink ("bash-aclocal/sh-np-autoconf");
1494 rmdir ("bash-aclocal");
1495 exit(0);
1496 }
1497 ]])], [bash_cv_sys_named_pipes=present], [bash_cv_sys_named_pipes=missing],
1498 [AC_MSG_WARN(cannot check for named pipes if cross-compiling -- defaulting to missing)
1499 bash_cv_sys_named_pipes=missing]
1500 )])
1501 AC_MSG_RESULT($bash_cv_sys_named_pipes)
1502 if test $bash_cv_sys_named_pipes = missing; then
1503 AC_DEFINE(NAMED_PIPES_MISSING)
1504 fi
1505 ])
1506
1507 AC_DEFUN(BASH_SYS_DEFAULT_MAIL_DIR,
1508 [AC_MSG_CHECKING(for default mail directory)
1509 AC_CACHE_VAL(bash_cv_mail_dir,
1510 [if test -d /var/mail; then
1511 bash_cv_mail_dir=/var/mail
1512 elif test -d /var/spool/mail; then
1513 bash_cv_mail_dir=/var/spool/mail
1514 elif test -d /usr/mail; then
1515 bash_cv_mail_dir=/usr/mail
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 ])
1522 AC_MSG_RESULT($bash_cv_mail_dir)
1523 AC_DEFINE_UNQUOTED(DEFAULT_MAIL_DIRECTORY, "$bash_cv_mail_dir")
1524 ])
1525
1526 AC_DEFUN(BASH_HAVE_TIOCGWINSZ,
1527 [AC_MSG_CHECKING(for TIOCGWINSZ in sys/ioctl.h)
1528 AC_CACHE_VAL(bash_cv_tiocgwinsz_in_ioctl,
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 )])
1534 AC_MSG_RESULT($bash_cv_tiocgwinsz_in_ioctl)
1535 if test $bash_cv_tiocgwinsz_in_ioctl = yes; then
1536 AC_DEFINE(GWINSZ_IN_SYS_IOCTL)
1537 fi
1538 ])
1539
1540 AC_DEFUN(BASH_HAVE_TIOCSTAT,
1541 [AC_MSG_CHECKING(for TIOCSTAT in sys/ioctl.h)
1542 AC_CACHE_VAL(bash_cv_tiocstat_in_ioctl,
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 )])
1548 AC_MSG_RESULT($bash_cv_tiocstat_in_ioctl)
1549 if test $bash_cv_tiocstat_in_ioctl = yes; then
1550 AC_DEFINE(TIOCSTAT_IN_SYS_IOCTL)
1551 fi
1552 ])
1553
1554 AC_DEFUN(BASH_HAVE_FIONREAD,
1555 [AC_MSG_CHECKING(for FIONREAD in sys/ioctl.h)
1556 AC_CACHE_VAL(bash_cv_fionread_in_ioctl,
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 )])
1562 AC_MSG_RESULT($bash_cv_fionread_in_ioctl)
1563 if test $bash_cv_fionread_in_ioctl = yes; then
1564 AC_DEFINE(FIONREAD_IN_SYS_IOCTL)
1565 fi
1566 ])
1567
1568 dnl
1569 dnl See if speed_t is declared in <sys/types.h>. Some versions of linux
1570 dnl require a definition of speed_t each time <termcap.h> is included,
1571 dnl but you can only get speed_t if you include <termios.h> (on some
1572 dnl versions) or <sys/types.h> (on others).
1573 dnl
1574 AC_DEFUN(BASH_CHECK_SPEED_T,
1575 [AC_MSG_CHECKING(for speed_t in sys/types.h)
1576 AC_CACHE_VAL(bash_cv_speed_t_in_sys_types,
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])])
1582 AC_MSG_RESULT($bash_cv_speed_t_in_sys_types)
1583 if test $bash_cv_speed_t_in_sys_types = yes; then
1584 AC_DEFINE(SPEED_T_IN_SYS_TYPES)
1585 fi
1586 ])
1587
1588 AC_DEFUN(BASH_CHECK_GETPW_FUNCS,
1589 [AC_MSG_CHECKING(whether getpw functions are declared in pwd.h)
1590 AC_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
1597 #include <pwd.h>
1598 ],
1599 bash_cv_getpw_declared=yes,bash_cv_getpw_declared=no)])
1600 AC_MSG_RESULT($bash_cv_getpw_declared)
1601 if test $bash_cv_getpw_declared = yes; then
1602 AC_DEFINE(HAVE_GETPW_DECLS)
1603 fi
1604 ])
1605
1606 AC_DEFUN(BASH_CHECK_DEV_FD,
1607 [AC_MSG_CHECKING(whether /dev/fd is available)
1608 AC_CACHE_VAL(bash_cv_dev_fd,
1609 [bash_cv_dev_fd=""
1610 if test -d /dev/fd && (exec test -r /dev/fd/0 < /dev/null) ; then
1611 # check for systems like FreeBSD 5 that only provide /dev/fd/[012]
1612 if (exec test -r /dev/fd/3 3</dev/null) ; then
1613 bash_cv_dev_fd=standard
1614 else
1615 bash_cv_dev_fd=absent
1616 fi
1617 fi
1618 if test -z "$bash_cv_dev_fd" ; then
1619 if test -d /proc/self/fd && (exec test -r /proc/self/fd/0 < /dev/null) ; then
1620 bash_cv_dev_fd=whacky
1621 else
1622 bash_cv_dev_fd=absent
1623 fi
1624 fi
1625 ])
1626 AC_MSG_RESULT($bash_cv_dev_fd)
1627 if test $bash_cv_dev_fd = "standard"; then
1628 AC_DEFINE(HAVE_DEV_FD)
1629 AC_DEFINE(DEV_FD_PREFIX, "/dev/fd/")
1630 elif test $bash_cv_dev_fd = "whacky"; then
1631 AC_DEFINE(HAVE_DEV_FD)
1632 AC_DEFINE(DEV_FD_PREFIX, "/proc/self/fd/")
1633 fi
1634 ])
1635
1636 AC_DEFUN(BASH_CHECK_DEV_STDIN,
1637 [AC_MSG_CHECKING(whether /dev/stdin stdout stderr are available)
1638 AC_CACHE_VAL(bash_cv_dev_stdin,
1639 [if (exec test -r /dev/stdin < /dev/null) ; then
1640 bash_cv_dev_stdin=present
1641 else
1642 bash_cv_dev_stdin=absent
1643 fi
1644 ])
1645 AC_MSG_RESULT($bash_cv_dev_stdin)
1646 if test $bash_cv_dev_stdin = "present"; then
1647 AC_DEFINE(HAVE_DEV_STDIN)
1648 fi
1649 ])
1650
1651
1652 AC_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
1666 dnl
1667 dnl Check if HPUX needs _KERNEL defined for RLIMIT_* definitions
1668 dnl
1669 AC_DEFUN(BASH_CHECK_KERNEL_RLIMIT,
1670 [AC_MSG_CHECKING([whether $host_os needs _KERNEL for RLIMIT defines])
1671 AC_CACHE_VAL(bash_cv_kernel_rlimit,
1672 [BASH_CHECK_RLIMIT
1673 if test $bash_cv_rlimit = no; then
1674 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1675 #include <sys/types.h>
1676 #define _KERNEL
1677 #include <sys/resource.h>
1678 #undef _KERNEL
1679 ]],
1680 [[
1681 int f;
1682 f = RLIMIT_DATA;
1683 ]] )], [bash_cv_kernel_rlimit=yes], [bash_cv_kernel_rlimit=no] )
1684 fi
1685 ])
1686 AC_MSG_RESULT($bash_cv_kernel_rlimit)
1687 if test $bash_cv_kernel_rlimit = yes; then
1688 AC_DEFINE(RLIMIT_NEEDS_KERNEL)
1689 fi
1690 ])
1691
1692 dnl
1693 dnl Check for 64-bit off_t -- used for malloc alignment
1694 dnl
1695 dnl C does not allow duplicate case labels, so the compile will fail if
1696 dnl sizeof(off_t) is > 4.
1697 dnl
1698 AC_DEFUN(BASH_CHECK_OFF_T_64,
1699 [AC_CACHE_CHECK(for 64-bit off_t, bash_cv_off_t_64,
1700 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1701 #ifdef HAVE_UNISTD_H
1702 #include <unistd.h>
1703 #endif
1704 #include <sys/types.h>
1705 ]],[[
1706 switch (0) case 0: case (sizeof (off_t) <= 4):;
1707 ]] )], [bash_cv_off_t_64=no], [bash_cv_off_t_64=yes]
1708 ))
1709 if test $bash_cv_off_t_64 = yes; then
1710 AC_DEFINE(HAVE_OFF_T_64)
1711 fi])
1712
1713 AC_DEFUN(BASH_CHECK_RTSIGS,
1714 [AC_MSG_CHECKING(for unusable real-time signals due to large values)
1715 AC_CACHE_VAL(bash_cv_unusable_rtsigs,
1716 [AC_RUN_IFELSE([AC_LANG_SOURCE([[
1717 #include <sys/types.h>
1718 #include <signal.h>
1719 #include <stdlib.h>
1720
1721 #ifndef NSIG
1722 # define NSIG 64
1723 #endif
1724
1725 int
1726 main ()
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);
1736 }
1737 ]])], [bash_cv_unusable_rtsigs=yes], [bash_cv_unusable_rtsigs=no],
1738 [AC_MSG_WARN(cannot check real-time signals if cross compiling -- defaulting to yes)
1739 bash_cv_unusable_rtsigs=yes]
1740 )])
1741 AC_MSG_RESULT($bash_cv_unusable_rtsigs)
1742 if test $bash_cv_unusable_rtsigs = yes; then
1743 AC_DEFINE(UNUSABLE_RT_SIGNALS)
1744 fi
1745 ])
1746
1747 dnl
1748 dnl check for availability of multibyte characters and functions
1749 dnl
1750 dnl geez, I wish I didn't have to check for all of this stuff separately
1751 dnl
1752 AC_DEFUN(BASH_CHECK_MULTIBYTE,
1753 [
1754 AC_CHECK_HEADERS(wctype.h)
1755 AC_CHECK_HEADERS(wchar.h)
1756 AC_CHECK_HEADERS(langinfo.h)
1757
1758 AC_CHECK_HEADERS(mbstr.h)
1759
1760 AC_CHECK_FUNC(mbrlen, AC_DEFINE(HAVE_MBRLEN))
1761 AC_CHECK_FUNC(mbscasecmp, AC_DEFINE(HAVE_MBSCMP))
1762 AC_CHECK_FUNC(mbscmp, AC_DEFINE(HAVE_MBSCMP))
1763 AC_CHECK_FUNC(mbsnrtowcs, AC_DEFINE(HAVE_MBSNRTOWCS))
1764 AC_CHECK_FUNC(mbsrtowcs, AC_DEFINE(HAVE_MBSRTOWCS))
1765
1766 AC_REPLACE_FUNCS(mbschr)
1767
1768 AC_CHECK_FUNC(wcrtomb, AC_DEFINE(HAVE_WCRTOMB))
1769 AC_CHECK_FUNC(wcscoll, AC_DEFINE(HAVE_WCSCOLL))
1770 AC_CHECK_FUNC(wcsdup, AC_DEFINE(HAVE_WCSDUP))
1771 AC_CHECK_FUNC(wcwidth, AC_DEFINE(HAVE_WCWIDTH))
1772 AC_CHECK_FUNC(wctype, AC_DEFINE(HAVE_WCTYPE))
1773
1774 AC_REPLACE_FUNCS(wcswidth)
1775
1776 dnl checks for both mbrtowc and mbstate_t
1777 AC_FUNC_MBRTOWC
1778 if test $ac_cv_func_mbrtowc = yes; then
1779 AC_DEFINE(HAVE_MBSTATE_T)
1780 fi
1781
1782 AC_CHECK_FUNCS(iswlower iswupper towlower towupper iswctype)
1783
1784 AC_REQUIRE([AM_LANGINFO_CODESET])
1785
1786 dnl check for wchar_t in <wchar.h>
1787 AC_CACHE_CHECK([for wchar_t in wchar.h], bash_cv_type_wchar_t,
1788 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([
1789 [#include <wchar.h>]],
1790 [[
1791 wchar_t foo;
1792 foo = 0;
1793 ]] )], [bash_cv_type_wchar_t=yes], [bash_cv_type_wchar_t=no]
1794 )])
1795 if test $bash_cv_type_wchar_t = yes; then
1796 AC_DEFINE(HAVE_WCHAR_T, 1, [systems should define this type here])
1797 fi
1798
1799 dnl check for wctype_t in <wctype.h>
1800 AC_CACHE_CHECK([for wctype_t in wctype.h], bash_cv_type_wctype_t,
1801 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([
1802 [#include <wctype.h>]],
1803 [[
1804 wctype_t foo;
1805 foo = 0;
1806 ]] )], [bash_cv_type_wctype_t=yes], [bash_cv_type_wctype_t=no]
1807 )])
1808 if test $bash_cv_type_wctype_t = yes; then
1809 AC_DEFINE(HAVE_WCTYPE_T, 1, [systems should define this type here])
1810 fi
1811
1812 dnl check for wint_t in <wctype.h>
1813 AC_CACHE_CHECK([for wint_t in wctype.h], bash_cv_type_wint_t,
1814 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([
1815 [#include <wctype.h>]],
1816 [[
1817 wint_t foo;
1818 foo = 0;
1819 ]] )], [bash_cv_type_wint_t=yes], [bash_cv_type_wint_t=no]
1820 )])
1821 if test $bash_cv_type_wint_t = yes; then
1822 AC_DEFINE(HAVE_WINT_T, 1, [systems should define this type here])
1823 fi
1824
1825 dnl check for broken wcwidth
1826 AC_CACHE_CHECK([for wcwidth broken with unicode combining characters],
1827 bash_cv_wcwidth_broken,
1828 [AC_RUN_IFELSE([AC_LANG_SOURCE([[
1829 #include <unistd.h>
1830 #include <stdlib.h>
1831 #include <stdio.h>
1832
1833 #include <locale.h>
1834 #include <wchar.h>
1835
1836 int
1837 main(c, v)
1838 int c;
1839 char **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 }
1847 ]])], [bash_cv_wcwidth_broken=yes], [bash_cv_wcwidth_broken=no],
1848 [bash_cv_wcwidth_broken=no]
1849 )])
1850 if test "$bash_cv_wcwidth_broken" = yes; then
1851 AC_DEFINE(WCWIDTH_BROKEN, 1, [wcwidth is usually not broken])
1852 fi
1853
1854 if test "$am_cv_func_iconv" = yes; then
1855 OLDLIBS="$LIBS"
1856 LIBS="$LIBS $LIBINTL $LIBICONV"
1857 AC_CHECK_FUNCS(locale_charset)
1858 LIBS="$OLDLIBS"
1859 fi
1860
1861 AC_CHECK_SIZEOF(wchar_t, 4)
1862
1863 ])
1864
1865 dnl need: prefix exec_prefix libdir includedir CC TERMCAP_LIB
1866 dnl require:
1867 dnl AC_PROG_CC
1868 dnl BASH_CHECK_LIB_TERMCAP
1869
1870 AC_DEFUN([RL_LIB_READLINE_VERSION],
1871 [
1872 AC_REQUIRE([BASH_CHECK_LIB_TERMCAP])
1873
1874 AC_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
1887 if test -z "$ac_cv_rl_prefix"; then
1888 test "x$prefix" = xNONE && ac_cv_rl_prefix=$ac_default_prefix || ac_cv_rl_prefix=${prefix}
1889 fi
1890
1891 eval ac_cv_rl_includedir=${ac_cv_rl_prefix}/include
1892 eval ac_cv_rl_libdir=${ac_cv_rl_prefix}/lib
1893
1894 LIBS="$LIBS -lreadline ${TERMCAP_LIB}"
1895 CFLAGS="$CFLAGS -I${ac_cv_rl_includedir}"
1896 LDFLAGS="$LDFLAGS -L${ac_cv_rl_libdir}"
1897
1898 AC_CACHE_VAL(ac_cv_rl_version,
1899 [AC_RUN_IFELSE([AC_LANG_SOURCE([[
1900 #include <stdio.h>
1901 #include <readline/readline.h>
1902 #include <stdlib.h>
1903
1904 extern int rl_gnu_readline_p;
1905
1906 int
1907 main()
1908 {
1909 FILE *fp;
1910 fp = fopen("conftest.rlv", "w");
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");
1917 fclose(fp);
1918 exit(0);
1919 }
1920 ]])],
1921 [ac_cv_rl_version=`cat conftest.rlv`],
1922 [ac_cv_rl_version='0.0'],
1923 [ac_cv_rl_version='8.0']
1924 )])
1925
1926 CFLAGS="$_save_CFLAGS"
1927 LDFLAGS="$_save_LDFLAGS"
1928 LIBS="$_save_LIBS"
1929
1930 RL_MAJOR=0
1931 RL_MINOR=0
1932
1933 # (
1934 case "$ac_cv_rl_version" in
1935 2*|3*|4*|5*|6*|7*|8*|9*)
1936 RL_MAJOR=`echo $ac_cv_rl_version | sed 's:\..*$::'`
1937 RL_MINOR=`echo $ac_cv_rl_version | sed -e 's:^.*\.::' -e 's:[[a-zA-Z]]*$::'`
1938 ;;
1939 esac
1940
1941 # (((
1942 case $RL_MAJOR in
1943 [[0-9][0-9]]) _RL_MAJOR=$RL_MAJOR ;;
1944 [[0-9]]) _RL_MAJOR=0$RL_MAJOR ;;
1945 *) _RL_MAJOR=00 ;;
1946 esac
1947
1948 # (((
1949 case $RL_MINOR in
1950 [[0-9][0-9]]) _RL_MINOR=$RL_MINOR ;;
1951 [[0-9]]) _RL_MINOR=0$RL_MINOR ;;
1952 *) _RL_MINOR=00 ;;
1953 esac
1954
1955 RL_VERSION="0x${_RL_MAJOR}${_RL_MINOR}"
1956
1957 # Readline versions greater than 4.2 have these defines in readline.h
1958
1959 if test $ac_cv_rl_version = '0.0' ; then
1960 AC_MSG_WARN([Could not test version of installed readline library.])
1961 elif 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)
1967 else
1968
1969 AC_DEFINE_UNQUOTED(RL_READLINE_VERSION, $RL_VERSION, [encoded version of the installed readline library])
1970 AC_DEFINE_UNQUOTED(RL_VERSION_MAJOR, $RL_MAJOR, [major version of installed readline library])
1971 AC_DEFINE_UNQUOTED(RL_VERSION_MINOR, $RL_MINOR, [minor version of installed readline library])
1972
1973 AC_SUBST(RL_VERSION)
1974 AC_SUBST(RL_MAJOR)
1975 AC_SUBST(RL_MINOR)
1976
1977 # set these for use by the caller
1978 RL_PREFIX=$ac_cv_rl_prefix
1979 RL_LIBDIR=$ac_cv_rl_libdir
1980 RL_INCLUDEDIR=$ac_cv_rl_includedir
1981
1982 AC_MSG_RESULT($ac_cv_rl_version)
1983
1984 fi
1985 ])
1986
1987 AC_DEFUN(BASH_CHECK_WCONTINUED,
1988 [
1989 AC_MSG_CHECKING(whether WCONTINUED flag to waitpid is unavailable or available but broken)
1990 AC_CACHE_VAL(bash_cv_wcontinued_broken,
1991 [AC_RUN_IFELSE([AC_LANG_SOURCE([[
1992 #include <sys/types.h>
1993 #include <sys/wait.h>
1994 #include <unistd.h>
1995 #include <errno.h>
1996 #include <stdlib.h>
1997
1998 #ifndef errno
1999 extern int errno;
2000 #endif
2001 int
2002 main()
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 }
2012 ]])], [bash_cv_wcontinued_broken=no], [bash_cv_wcontinued_broken=yes],
2013 [AC_MSG_WARN(cannot check WCONTINUED if cross compiling -- defaulting to no)
2014 bash_cv_wcontinued_broken=no]
2015 )])
2016 AC_MSG_RESULT($bash_cv_wcontinued_broken)
2017 if test $bash_cv_wcontinued_broken = yes; then
2018 AC_DEFINE(WCONTINUED_BROKEN)
2019 fi
2020 ])
2021
2022 dnl
2023 dnl tests added for bashdb
2024 dnl
2025
2026
2027 AC_DEFUN([AM_PATH_LISPDIR],
2028 [AC_ARG_WITH(lispdir, AS_HELP_STRING([--with-lispdir], [override the default lisp directory]),
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
2052 dnl From gnulib
2053 AC_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 ])
2059
2060 AC_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],
2065 [AC_RUN_IFELSE([AC_LANG_SOURCE([[
2066 #include <stdio.h>
2067 #include <stdlib.h>
2068
2069 int
2070 main()
2071 {
2072 int n;
2073 n = snprintf (0, 0, "%s", "0123456");
2074 exit(n != 7);
2075 }
2076 ]])], [bash_cv_func_snprintf=yes], [bash_cv_func_snprintf=no],
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
2090 AC_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],
2095 [AC_RUN_IFELSE([AC_LANG_SOURCE([[
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
2104 static int
2105 #if HAVE_STDARG_H
2106 foo(const char *fmt, ...)
2107 #else
2108 foo(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
2126 int
2127 main()
2128 {
2129 int n;
2130 n = foo("%s", "0123456");
2131 exit(n != 7);
2132 }
2133 ]])], [bash_cv_func_vsnprintf=yes], [bash_cv_func_vsnprintf=no],
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 ])
2146
2147 AC_DEFUN(BASH_STRUCT_WEXITSTATUS_OFFSET,
2148 [AC_MSG_CHECKING(for offset of exit status in return status from wait)
2149 AC_CACHE_VAL(bash_cv_wexitstatus_offset,
2150 [AC_RUN_IFELSE([AC_LANG_SOURCE([[
2151 #include <stdlib.h>
2152 #include <unistd.h>
2153
2154 #include <sys/wait.h>
2155
2156 int
2157 main(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 */
2175 for (i = 0; i < (sizeof(s) * 8); i++)
2176 {
2177 n = (s >> i) & 0xff;
2178 if (n == 42)
2179 exit (i);
2180 }
2181
2182 exit (254);
2183 }
2184 ]])], [bash_cv_wexitstatus_offset=0], [bash_cv_wexitstatus_offset=$?],
2185 [AC_MSG_WARN(cannot check WEXITSTATUS offset if cross compiling -- defaulting to 0)
2186 bash_cv_wexitstatus_offset=0]
2187 )])
2188 if 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
2191 fi
2192 AC_MSG_RESULT($bash_cv_wexitstatus_offset)
2193 AC_DEFINE_UNQUOTED([WEXITSTATUS_OFFSET], [$bash_cv_wexitstatus_offset], [Offset of exit status in wait status word])
2194 ])
2195
2196 AC_DEFUN([BASH_FUNC_SBRK],
2197 [
2198 AC_MSG_CHECKING([for sbrk])
2199 AC_CACHE_VAL(ac_cv_func_sbrk,
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])])
2205 AC_MSG_RESULT($ac_cv_func_sbrk)
2206 if test X$ac_cv_func_sbrk = Xyes; then
2207 AC_CACHE_CHECK([for working sbrk], [bash_cv_func_sbrk],
2208 [AC_RUN_IFELSE([AC_LANG_SOURCE([[
2209 #include <stdlib.h>
2210 #include <unistd.h>
2211
2212 int
2213 main(int c, char **v)
2214 {
2215 void *x;
2216
2217 x = sbrk (4096);
2218 exit ((x == (void *)-1) ? 1 : 0);
2219 }
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 ])])
2223 if test $bash_cv_func_sbrk = no; then
2224 ac_cv_func_sbrk=no
2225 fi
2226 fi
2227 if test $ac_cv_func_sbrk = yes; then
2228 AC_DEFINE(HAVE_SBRK, 1,
2229 [Define if you have a working sbrk function.])
2230 fi
2231 ])
2232
2233 AC_DEFUN(BASH_FUNC_FNMATCH_EQUIV_FALLBACK,
2234 [AC_MSG_CHECKING(whether fnmatch can be used to check bracket equivalence classes)
2235 AC_CACHE_VAL(bash_cv_fnmatch_equiv_fallback,
2236 [AC_RUN_IFELSE([AC_LANG_SOURCE([[
2237 #include <stdlib.h>
2238 #include <unistd.h>
2239 #include <stdio.h>
2240 #include <fnmatch.h>
2241 #include <locale.h>
2242
2243 char *pattern = "[[=a=]]";
2244
2245 /* char *string = "รค"; */
2246 unsigned char string[4] = { '\xc3', '\xa4', '\0' };
2247
2248 int
2249 main (int c, char **v)
2250 {
2251 setlocale (LC_ALL, "en_US.UTF-8");
2252 if (fnmatch (pattern, (const char *)string, 0) != FNM_NOMATCH)
2253 exit (0);
2254 exit (1);
2255 }
2256 ]])], [bash_cv_fnmatch_equiv_fallback=yes], [bash_cv_fnmatch_equiv_fallback=no],
2257 [AC_MSG_WARN(cannot check fnmatch if cross compiling -- defaulting to no)
2258 bash_cv_fnmatch_equiv_fallback=no]
2259 )])
2260 AC_MSG_RESULT($bash_cv_fnmatch_equiv_fallback)
2261 if test "$bash_cv_fnmatch_equiv_fallback" = "yes" ; then
2262 bash_cv_fnmatch_equiv_value=1
2263 else
2264 bash_cv_fnmatch_equiv_value=0
2265 fi
2266 AC_DEFINE_UNQUOTED([FNMATCH_EQUIV_FALLBACK], [$bash_cv_fnmatch_equiv_value], [Whether fnmatch can be used for bracket equivalence classes])
2267 ])