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