2 dnl Bush specific tests
4 dnl Some derived from PDKSH 5.1.3 autoconf tests
7 AC_DEFUN(BUSH_C_LONG_LONG,
8 [AC_CACHE_CHECK(for long long, ac_cv_c_long_long,
9 [if test "$GCC" = yes; then
18 exit(sizeof(long long) < sizeof(long));
20 ], ac_cv_c_long_long=yes, ac_cv_c_long_long=no)
22 if test $ac_cv_c_long_long = yes; then
23 AC_DEFINE(HAVE_LONG_LONG, 1, [Define if the `long long' type works.])
28 dnl This is very similar to AC_C_LONG_DOUBLE, with the fix for IRIX
29 dnl (< changed to <=) added.
31 AC_DEFUN(BUSH_C_LONG_DOUBLE,
32 [AC_CACHE_CHECK(for long double, ac_cv_c_long_double,
33 [if test "$GCC" = yes; then
34 ac_cv_c_long_double=yes
41 /* The Stardent Vistra knows sizeof(long double), but does not
43 long double foo = 0.0;
44 /* On Ultrix 4.3 cc, long double is 4 and double is 8. */
45 /* On IRIX 5.3, the compiler converts long double to double with a warning,
46 but compiles this successfully. */
47 exit(sizeof(long double) <= sizeof(double));
49 ], ac_cv_c_long_double=yes, ac_cv_c_long_double=no)
51 if test $ac_cv_c_long_double = yes; then
52 AC_DEFINE(HAVE_LONG_DOUBLE, 1, [Define if the `long double' type works.])
57 dnl Check for <inttypes.h>. This is separated out so that it can be
60 dnl BUSH_HEADER_INTTYPES
61 AC_DEFUN(BUSH_HEADER_INTTYPES,
63 AC_CHECK_HEADERS(inttypes.h)
67 dnl check for typedef'd symbols in header files, but allow the caller to
68 dnl specify the include files to be checked in addition to the default
70 dnl This could be changed to use AC_COMPILE_IFELSE instead of AC_EGREP_CPP
72 dnl BUSH_CHECK_TYPE(TYPE, HEADERS, DEFAULT[, VALUE-IF-FOUND])
73 AC_DEFUN(BUSH_CHECK_TYPE,
75 AC_REQUIRE([AC_HEADER_STDC])dnl
76 AC_REQUIRE([BUSH_HEADER_INTTYPES])
77 AC_MSG_CHECKING(for $1)
78 AC_CACHE_VAL(bush_cv_type_$1,
79 [AC_EGREP_CPP($1, [#include <sys/types.h>
91 ], bush_cv_type_$1=yes, bush_cv_type_$1=no)])
92 AC_MSG_RESULT($bush_cv_type_$1)
93 ifelse($#, 4, [if test $bush_cv_type_$1 = yes; then
96 if test $bush_cv_type_$1 = no; then
97 AC_DEFINE_UNQUOTED($1, $3)
102 dnl BUSH_CHECK_DECL(FUNC)
104 dnl Check for a declaration of FUNC in stdlib.h and inttypes.h like
107 AC_DEFUN(BUSH_CHECK_DECL,
109 AC_REQUIRE([AC_HEADER_STDC])
110 AC_REQUIRE([BUSH_HEADER_INTTYPES])
111 AC_CACHE_CHECK([for declaration of $1], bush_cv_decl_$1,
118 # include <inttypes.h>
122 bush_cv_decl_$1=yes, bush_cv_decl_$1=no)])
123 bush_tr_func=HAVE_DECL_`echo $1 | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
124 if test $bush_cv_decl_$1 = yes; then
125 AC_DEFINE_UNQUOTED($bush_tr_func, 1)
127 AC_DEFINE_UNQUOTED($bush_tr_func, 0)
131 AC_DEFUN(BUSH_DECL_PRINTF,
132 [AC_MSG_CHECKING(for declaration of printf in <stdio.h>)
133 AC_CACHE_VAL(bush_cv_printf_declared,
137 typedef int (*_bushfunc)(const char *, ...);
139 typedef int (*_bushfunc)();
146 pf = (_bushfunc) printf;
149 ], bush_cv_printf_declared=yes, bush_cv_printf_declared=no,
150 [AC_MSG_WARN(cannot check printf declaration if cross compiling -- defaulting to yes)
151 bush_cv_printf_declared=yes]
153 AC_MSG_RESULT($bush_cv_printf_declared)
154 if test $bush_cv_printf_declared = yes; then
155 AC_DEFINE(PRINTF_DECLARED)
159 AC_DEFUN(BUSH_DECL_SBRK,
160 [AC_MSG_CHECKING(for declaration of sbrk in <unistd.h>)
161 AC_CACHE_VAL(bush_cv_sbrk_declared,
162 [AC_EGREP_HEADER(sbrk, unistd.h,
163 bush_cv_sbrk_declared=yes, bush_cv_sbrk_declared=no)])
164 AC_MSG_RESULT($bush_cv_sbrk_declared)
165 if test $bush_cv_sbrk_declared = yes; then
166 AC_DEFINE(SBRK_DECLARED)
171 dnl Check for sys_siglist[] or _sys_siglist[]
173 AC_DEFUN(BUSH_DECL_UNDER_SYS_SIGLIST,
174 [AC_MSG_CHECKING([for _sys_siglist in signal.h or unistd.h])
175 AC_CACHE_VAL(bush_cv_decl_under_sys_siglist,
177 #include <sys/types.h>
181 #endif], [ char *msg = _sys_siglist[2]; ],
182 bush_cv_decl_under_sys_siglist=yes, bush_cv_decl_under_sys_siglist=no,
183 [AC_MSG_WARN(cannot check for _sys_siglist[] if cross compiling -- defaulting to no)])])dnl
184 AC_MSG_RESULT($bush_cv_decl_under_sys_siglist)
185 if test $bush_cv_decl_under_sys_siglist = yes; then
186 AC_DEFINE(UNDER_SYS_SIGLIST_DECLARED)
190 AC_DEFUN(BUSH_UNDER_SYS_SIGLIST,
191 [AC_REQUIRE([BUSH_DECL_UNDER_SYS_SIGLIST])
192 AC_MSG_CHECKING([for _sys_siglist in system C library])
193 AC_CACHE_VAL(bush_cv_under_sys_siglist,
195 #include <sys/types.h>
201 #ifndef UNDER_SYS_SIGLIST_DECLARED
202 extern char *_sys_siglist[];
207 char *msg = (char *)_sys_siglist[2];
210 bush_cv_under_sys_siglist=yes, bush_cv_under_sys_siglist=no,
211 [AC_MSG_WARN(cannot check for _sys_siglist[] if cross compiling -- defaulting to no)
212 bush_cv_under_sys_siglist=no])])
213 AC_MSG_RESULT($bush_cv_under_sys_siglist)
214 if test $bush_cv_under_sys_siglist = yes; then
215 AC_DEFINE(HAVE_UNDER_SYS_SIGLIST)
219 AC_DEFUN(BUSH_SYS_SIGLIST,
220 [AC_REQUIRE([AC_DECL_SYS_SIGLIST])
221 AC_MSG_CHECKING([for sys_siglist in system C library])
222 AC_CACHE_VAL(bush_cv_sys_siglist,
224 #include <sys/types.h>
230 #if !HAVE_DECL_SYS_SIGLIST
231 extern char *sys_siglist[];
236 char *msg = sys_siglist[2];
239 bush_cv_sys_siglist=yes, bush_cv_sys_siglist=no,
240 [AC_MSG_WARN(cannot check for sys_siglist if cross compiling -- defaulting to no)
241 bush_cv_sys_siglist=no])])
242 AC_MSG_RESULT($bush_cv_sys_siglist)
243 if test $bush_cv_sys_siglist = yes; then
244 AC_DEFINE(HAVE_SYS_SIGLIST)
248 dnl Check for the various permutations of sys_siglist and make sure we
249 dnl compile in siglist.o if they're not defined
250 AC_DEFUN(BUSH_CHECK_SYS_SIGLIST, [
251 AC_REQUIRE([BUSH_SYS_SIGLIST])
252 AC_REQUIRE([BUSH_DECL_UNDER_SYS_SIGLIST])
253 AC_REQUIRE([BUSH_FUNC_STRSIGNAL])
254 if test "$bush_cv_sys_siglist" = no && test "$bush_cv_under_sys_siglist" = no && test "$bush_cv_have_strsignal" = no; then
259 AC_SUBST([SIGLIST_O])
262 dnl Check for sys_errlist[] and sys_nerr, check for declaration
263 AC_DEFUN(BUSH_SYS_ERRLIST,
264 [AC_MSG_CHECKING([for sys_errlist and sys_nerr])
265 AC_CACHE_VAL(bush_cv_sys_errlist,
266 [AC_TRY_LINK([#include <errno.h>],
267 [extern char *sys_errlist[];
269 char *msg = sys_errlist[sys_nerr - 1];],
270 bush_cv_sys_errlist=yes, bush_cv_sys_errlist=no)])dnl
271 AC_MSG_RESULT($bush_cv_sys_errlist)
272 if test $bush_cv_sys_errlist = yes; then
273 AC_DEFINE(HAVE_SYS_ERRLIST)
278 dnl Check if dup2() does not clear the close on exec flag
280 AC_DEFUN(BUSH_FUNC_DUP2_CLOEXEC_CHECK,
281 [AC_MSG_CHECKING(if dup2 fails to clear the close-on-exec flag)
282 AC_CACHE_VAL(bush_cv_dup2_broken,
284 #include <sys/types.h>
291 fd1 = open("/dev/null", 2);
292 if (fcntl(fd1, 2, 1) < 0)
297 fl = fcntl(fd2, 1, 0);
298 /* fl will be 1 if dup2 did not reset the close-on-exec flag. */
301 ], bush_cv_dup2_broken=yes, bush_cv_dup2_broken=no,
302 [AC_MSG_WARN(cannot check dup2 if cross compiling -- defaulting to no)
303 bush_cv_dup2_broken=no])
305 AC_MSG_RESULT($bush_cv_dup2_broken)
306 if test $bush_cv_dup2_broken = yes; then
307 AC_DEFINE(DUP2_BROKEN)
311 AC_DEFUN(BUSH_FUNC_STRSIGNAL,
312 [AC_MSG_CHECKING([for the existence of strsignal])
313 AC_CACHE_VAL(bush_cv_have_strsignal,
314 [AC_TRY_LINK([#include <sys/types.h>
316 #include <string.h>],
317 [char *s = (char *)strsignal(2);],
318 bush_cv_have_strsignal=yes, bush_cv_have_strsignal=no)])
319 AC_MSG_RESULT($bush_cv_have_strsignal)
320 if test $bush_cv_have_strsignal = yes; then
321 AC_DEFINE(HAVE_STRSIGNAL)
325 dnl Check to see if opendir will open non-directories (not a nice thing)
326 AC_DEFUN(BUSH_FUNC_OPENDIR_CHECK,
327 [AC_REQUIRE([AC_HEADER_DIRENT])dnl
328 AC_MSG_CHECKING(if opendir() opens non-directories)
329 AC_CACHE_VAL(bush_cv_opendir_not_robust,
332 #include <sys/types.h>
336 #endif /* HAVE_UNISTD_H */
337 #ifdef HAVE_SYS_STAT_H
338 #include <sys/stat.h>
340 #if defined(HAVE_DIRENT_H)
343 # define dirent direct
344 # ifdef HAVE_SYS_NDIR_H
345 # include <sys/ndir.h>
346 # endif /* SYSNDIR */
347 # ifdef HAVE_SYS_DIR_H
348 # include <sys/dir.h>
353 #endif /* HAVE_DIRENT_H */
360 err = mkdir("bush-aclocal", 0700);
365 unlink("bush-aclocal/not_a_directory");
366 fd = open("bush-aclocal/not_a_directory", O_WRONLY|O_CREAT|O_EXCL, 0666);
369 dir = opendir("bush-aclocal/not_a_directory");
370 unlink("bush-aclocal/not_a_directory");
371 rmdir("bush-aclocal");
373 }], bush_cv_opendir_not_robust=yes,bush_cv_opendir_not_robust=no,
374 [AC_MSG_WARN(cannot check opendir if cross compiling -- defaulting to no)
375 bush_cv_opendir_not_robust=no]
377 AC_MSG_RESULT($bush_cv_opendir_not_robust)
378 if test $bush_cv_opendir_not_robust = yes; then
379 AC_DEFINE(OPENDIR_NOT_ROBUST)
384 AC_DEFUN(BUSH_TYPE_SIGHANDLER,
385 [AC_MSG_CHECKING([whether signal handlers are of type void])
386 AC_CACHE_VAL(bush_cv_void_sighandler,
387 [AC_TRY_COMPILE([#include <sys/types.h>
395 void (*signal ()) ();],
396 [int i;], bush_cv_void_sighandler=yes, bush_cv_void_sighandler=no)])dnl
397 AC_MSG_RESULT($bush_cv_void_sighandler)
398 if test $bush_cv_void_sighandler = yes; then
399 AC_DEFINE(VOID_SIGHANDLER)
404 dnl A signed 16-bit integer quantity
406 AC_DEFUN(BUSH_TYPE_BITS16_T,
408 if test "$ac_cv_sizeof_short" = 2; then
409 AC_CHECK_TYPE(bits16_t, short)
410 elif test "$ac_cv_sizeof_char" = 2; then
411 AC_CHECK_TYPE(bits16_t, char)
413 AC_CHECK_TYPE(bits16_t, short)
418 dnl An unsigned 16-bit integer quantity
420 AC_DEFUN(BUSH_TYPE_U_BITS16_T,
422 if test "$ac_cv_sizeof_short" = 2; then
423 AC_CHECK_TYPE(u_bits16_t, unsigned short)
424 elif test "$ac_cv_sizeof_char" = 2; then
425 AC_CHECK_TYPE(u_bits16_t, unsigned char)
427 AC_CHECK_TYPE(u_bits16_t, unsigned short)
432 dnl A signed 32-bit integer quantity
434 AC_DEFUN(BUSH_TYPE_BITS32_T,
436 if test "$ac_cv_sizeof_int" = 4; then
437 AC_CHECK_TYPE(bits32_t, int)
438 elif test "$ac_cv_sizeof_long" = 4; then
439 AC_CHECK_TYPE(bits32_t, long)
441 AC_CHECK_TYPE(bits32_t, int)
446 dnl An unsigned 32-bit integer quantity
448 AC_DEFUN(BUSH_TYPE_U_BITS32_T,
450 if test "$ac_cv_sizeof_int" = 4; then
451 AC_CHECK_TYPE(u_bits32_t, unsigned int)
452 elif test "$ac_cv_sizeof_long" = 4; then
453 AC_CHECK_TYPE(u_bits32_t, unsigned long)
455 AC_CHECK_TYPE(u_bits32_t, unsigned int)
459 AC_DEFUN(BUSH_TYPE_PTRDIFF_T,
461 if test "$ac_cv_sizeof_int" = "$ac_cv_sizeof_char_p"; then
462 AC_CHECK_TYPE(ptrdiff_t, int)
463 elif test "$ac_cv_sizeof_long" = "$ac_cv_sizeof_char_p"; then
464 AC_CHECK_TYPE(ptrdiff_t, long)
465 elif test "$ac_cv_type_long_long" = yes && test "$ac_cv_sizeof_long_long" = "$ac_cv_sizeof_char_p"; then
466 AC_CHECK_TYPE(ptrdiff_t, [long long])
468 AC_CHECK_TYPE(ptrdiff_t, int)
473 dnl A signed 64-bit quantity
475 AC_DEFUN(BUSH_TYPE_BITS64_T,
477 if test "$ac_cv_sizeof_char_p" = 8; then
478 AC_CHECK_TYPE(bits64_t, char *)
479 elif test "$ac_cv_sizeof_double" = 8; then
480 AC_CHECK_TYPE(bits64_t, double)
481 elif test -n "$ac_cv_type_long_long" && test "$ac_cv_sizeof_long_long" = 8; then
482 AC_CHECK_TYPE(bits64_t, [long long])
483 elif test "$ac_cv_sizeof_long" = 8; then
484 AC_CHECK_TYPE(bits64_t, long)
486 AC_CHECK_TYPE(bits64_t, double)
490 AC_DEFUN(BUSH_TYPE_LONG_LONG,
492 AC_CACHE_CHECK([for long long], bush_cv_type_long_long,
494 long long ll = 1; int i = 63;],
496 long long llm = (long long) -1;
497 return ll << i | ll >> i | llm / ll | llm % ll;
498 ], bush_cv_type_long_long='long long', bush_cv_type_long_long='long')])
499 if test "$bush_cv_type_long_long" = 'long long'; then
500 AC_DEFINE(HAVE_LONG_LONG, 1)
504 AC_DEFUN(BUSH_TYPE_UNSIGNED_LONG_LONG,
506 AC_CACHE_CHECK([for unsigned long long], bush_cv_type_unsigned_long_long,
508 unsigned long long ull = 1; int i = 63;],
510 unsigned long long ullmax = (unsigned long long) -1;
511 return ull << i | ull >> i | ullmax / ull | ullmax % ull;
512 ], bush_cv_type_unsigned_long_long='unsigned long long',
513 bush_cv_type_unsigned_long_long='unsigned long')])
514 if test "$bush_cv_type_unsigned_long_long" = 'unsigned long long'; then
515 AC_DEFINE(HAVE_UNSIGNED_LONG_LONG, 1)
520 dnl Type of struct rlimit fields: some systems (OSF/1, NetBSD, RISC/os 5.0)
521 dnl have a rlim_t, others (4.4BSD based systems) use quad_t, others use
522 dnl long and still others use int (HP-UX 9.01, SunOS 4.1.3). To simplify
523 dnl matters, this just checks for rlim_t, quad_t, or long.
525 AC_DEFUN(BUSH_TYPE_RLIMIT,
526 [AC_MSG_CHECKING(for size and type of struct rlimit fields)
527 AC_CACHE_VAL(bush_cv_type_rlimit,
528 [AC_TRY_COMPILE([#include <sys/types.h>
529 #include <sys/resource.h>],
530 [rlim_t xxx;], bush_cv_type_rlimit=rlim_t,[
532 #include <sys/types.h>
533 #include <sys/time.h>
534 #include <sys/resource.h>
541 if (sizeof(rl.rlim_cur) == sizeof(quad_t))
545 }], bush_cv_type_rlimit=quad_t, bush_cv_type_rlimit=long,
546 [AC_MSG_WARN(cannot check quad_t if cross compiling -- defaulting to long)
547 bush_cv_type_rlimit=long])])
549 AC_MSG_RESULT($bush_cv_type_rlimit)
550 if test $bush_cv_type_rlimit = quad_t; then
551 AC_DEFINE(RLIMTYPE, quad_t)
552 elif test $bush_cv_type_rlimit = rlim_t; then
553 AC_DEFINE(RLIMTYPE, rlim_t)
557 AC_DEFUN(BUSH_TYPE_SIG_ATOMIC_T,
558 [AC_CACHE_CHECK([for sig_atomic_t in signal.h], ac_cv_have_sig_atomic_t,
561 ],[ sig_atomic_t x; ],
562 ac_cv_have_sig_atomic_t=yes, ac_cv_have_sig_atomic_t=no)])
563 if test "$ac_cv_have_sig_atomic_t" = "no"
565 AC_CHECK_TYPE(sig_atomic_t,int)
569 AC_DEFUN(BUSH_FUNC_LSTAT,
570 [dnl Cannot use AC_CHECK_FUNCS(lstat) because Linux defines lstat() as an
571 dnl inline function in <sys/stat.h>.
572 AC_CACHE_CHECK([for lstat], bush_cv_func_lstat,
574 #include <sys/types.h>
575 #include <sys/stat.h>
576 ],[ lstat(".",(struct stat *)0); ],
577 bush_cv_func_lstat=yes, bush_cv_func_lstat=no)])
578 if test $bush_cv_func_lstat = yes; then
579 AC_DEFINE(HAVE_LSTAT)
583 AC_DEFUN(BUSH_FUNC_INET_ATON,
585 AC_CACHE_CHECK([for inet_aton], bush_cv_func_inet_aton,
587 #include <sys/types.h>
588 #include <netinet/in.h>
589 #include <arpa/inet.h>
590 struct in_addr ap;], [ inet_aton("127.0.0.1", &ap); ],
591 bush_cv_func_inet_aton=yes, bush_cv_func_inet_aton=no)])
592 if test $bush_cv_func_inet_aton = yes; then
593 AC_DEFINE(HAVE_INET_ATON)
599 AC_DEFUN(BUSH_FUNC_GETENV,
600 [AC_MSG_CHECKING(to see if getenv can be redefined)
601 AC_CACHE_VAL(bush_cv_getenv_redef,
614 #if defined (__linux__) || defined (__bsdi__) || defined (convex)
618 #endif /* !__linux__ && !__bsdi__ && !convex */
626 /* The next allows this program to run, but does not allow bush to link
627 when it redefines getenv. I'm not really interested in figuring out
633 exit(s == 0); /* force optimizer to leave getenv in */
635 ], bush_cv_getenv_redef=yes, bush_cv_getenv_redef=no,
636 [AC_MSG_WARN(cannot check getenv redefinition if cross compiling -- defaulting to yes)
637 bush_cv_getenv_redef=yes]
639 AC_MSG_RESULT($bush_cv_getenv_redef)
640 if test $bush_cv_getenv_redef = yes; then
641 AC_DEFINE(CAN_REDEFINE_GETENV)
645 # We should check for putenv before calling this
646 AC_DEFUN(BUSH_FUNC_STD_PUTENV,
648 AC_REQUIRE([AC_HEADER_STDC])
649 AC_REQUIRE([AC_C_PROTOTYPES])
650 AC_CACHE_CHECK([for standard-conformant putenv declaration], bush_cv_std_putenv,
662 extern int putenv (char *);
664 extern int putenv ();
667 [return (putenv == 0);],
668 bush_cv_std_putenv=yes, bush_cv_std_putenv=no
670 if test $bush_cv_std_putenv = yes; then
671 AC_DEFINE(HAVE_STD_PUTENV)
675 # We should check for unsetenv before calling this
676 AC_DEFUN(BUSH_FUNC_STD_UNSETENV,
678 AC_REQUIRE([AC_HEADER_STDC])
679 AC_REQUIRE([AC_C_PROTOTYPES])
680 AC_CACHE_CHECK([for standard-conformant unsetenv declaration], bush_cv_std_unsetenv,
692 extern int unsetenv (const char *);
694 extern int unsetenv ();
697 [return (unsetenv == 0);],
698 bush_cv_std_unsetenv=yes, bush_cv_std_unsetenv=no
700 if test $bush_cv_std_unsetenv = yes; then
701 AC_DEFINE(HAVE_STD_UNSETENV)
705 AC_DEFUN(BUSH_FUNC_ULIMIT_MAXFDS,
706 [AC_MSG_CHECKING(whether ulimit can substitute for getdtablesize)
707 AC_CACHE_VAL(bush_cv_ulimit_maxfds,
716 long maxfds = ulimit(4, 0L);
717 exit (maxfds == -1L);
719 ], bush_cv_ulimit_maxfds=yes, bush_cv_ulimit_maxfds=no,
720 [AC_MSG_WARN(cannot check ulimit if cross compiling -- defaulting to no)
721 bush_cv_ulimit_maxfds=no]
723 AC_MSG_RESULT($bush_cv_ulimit_maxfds)
724 if test $bush_cv_ulimit_maxfds = yes; then
725 AC_DEFINE(ULIMIT_MAXFDS)
729 AC_DEFUN(BUSH_FUNC_GETCWD,
730 [AC_MSG_CHECKING([if getcwd() will dynamically allocate memory with 0 size])
731 AC_CACHE_VAL(bush_cv_getcwd_malloc,
746 ], bush_cv_getcwd_malloc=yes, bush_cv_getcwd_malloc=no,
747 [AC_MSG_WARN(cannot check whether getcwd allocates memory when cross-compiling -- defaulting to no)
748 bush_cv_getcwd_malloc=no]
750 AC_MSG_RESULT($bush_cv_getcwd_malloc)
751 if test $bush_cv_getcwd_malloc = no; then
752 AC_DEFINE(GETCWD_BROKEN)
758 dnl This needs BUSH_CHECK_SOCKLIB, but since that's not called on every
759 dnl system, we can't use AC_PREREQ
761 AC_DEFUN(BUSH_FUNC_GETHOSTBYNAME,
762 [if test "X$bush_cv_have_gethostbyname" = "X"; then
765 AC_MSG_CHECKING(for gethostbyname in socket library)
768 AC_CACHE_VAL(bush_cv_have_gethostbyname,
769 [AC_TRY_LINK([#include <netdb.h>],
770 [ struct hostent *hp;
771 hp = gethostbyname("localhost");
772 ], bush_cv_have_gethostbyname=yes, bush_cv_have_gethostbyname=no)]
774 if test "X$_bush_needmsg" = Xyes; then
775 AC_MSG_CHECKING(for gethostbyname in socket library)
777 AC_MSG_RESULT($bush_cv_have_gethostbyname)
778 if test "$bush_cv_have_gethostbyname" = yes; then
779 AC_DEFINE(HAVE_GETHOSTBYNAME)
783 AC_DEFUN(BUSH_FUNC_FNMATCH_EXTMATCH,
784 [AC_MSG_CHECKING(if fnmatch does extended pattern matching with FNM_EXTMATCH)
785 AC_CACHE_VAL(bush_cv_fnm_extmatch,
798 ], bush_cv_fnm_extmatch=yes, bush_cv_fnm_extmatch=no,
799 [AC_MSG_WARN(cannot check FNM_EXTMATCH if cross compiling -- defaulting to no)
800 bush_cv_fnm_extmatch=no])
802 AC_MSG_RESULT($bush_cv_fnm_extmatch)
803 if test $bush_cv_fnm_extmatch = yes; then
804 AC_DEFINE(HAVE_LIBC_FNM_EXTMATCH)
808 AC_DEFUN(BUSH_FUNC_POSIX_SETJMP,
809 [AC_REQUIRE([BUSH_SYS_SIGNAL_VINTAGE])
810 AC_MSG_CHECKING(for presence of POSIX-style sigsetjmp/siglongjmp)
811 AC_CACHE_VAL(bush_cv_func_sigsetjmp,
816 #include <sys/types.h>
824 #if !defined (_POSIX_VERSION) || !defined (HAVE_POSIX_SIGNALS)
835 sigprocmask(SIG_BLOCK, (sigset_t *)NULL, &set);
836 sigprocmask(SIG_BLOCK, (sigset_t *)NULL, &oset);
839 code = sigsetjmp(xx, 1);
841 exit(0); /* could get sigmask and compare to oset here. */
844 sigaddset(&set, SIGINT);
845 sigprocmask(SIG_BLOCK, &set, (sigset_t *)NULL);
851 }], bush_cv_func_sigsetjmp=present, bush_cv_func_sigsetjmp=missing,
852 [AC_MSG_WARN(cannot check for sigsetjmp/siglongjmp if cross-compiling -- defaulting to missing)
853 bush_cv_func_sigsetjmp=missing]
855 AC_MSG_RESULT($bush_cv_func_sigsetjmp)
856 if test $bush_cv_func_sigsetjmp = present; then
857 AC_DEFINE(HAVE_POSIX_SIGSETJMP)
861 AC_DEFUN(BUSH_FUNC_STRCOLL,
863 AC_MSG_CHECKING(whether or not strcoll and strcmp differ)
864 AC_CACHE_VAL(bush_cv_func_strcoll_broken,
867 #if defined (HAVE_LOCALE_H)
879 char *deflocale, *defcoll;
881 #ifdef HAVE_SETLOCALE
882 deflocale = setlocale(LC_ALL, "");
883 defcoll = setlocale(LC_COLLATE, "");
887 /* These two values are taken from tests/glob-test. */
888 r1 = strcoll("abd", "aXd");
892 r2 = strcmp("abd", "aXd");
894 /* These two should both be greater than 0. It is permissible for
895 a system to return different values, as long as the sign is the
898 /* Exit with 1 (failure) if these two values are both > 0, since
899 this tests whether strcoll(3) is broken with respect to strcmp(3)
900 in the default locale. */
901 exit (r1 > 0 && r2 > 0);
903 ], bush_cv_func_strcoll_broken=yes, bush_cv_func_strcoll_broken=no,
904 [AC_MSG_WARN(cannot check strcoll if cross compiling -- defaulting to no)
905 bush_cv_func_strcoll_broken=no]
907 AC_MSG_RESULT($bush_cv_func_strcoll_broken)
908 if test $bush_cv_func_strcoll_broken = yes; then
909 AC_DEFINE(STRCOLL_BROKEN)
913 AC_DEFUN(BUSH_FUNC_PRINTF_A_FORMAT,
914 [AC_MSG_CHECKING([for printf floating point output in hex notation])
915 AC_CACHE_VAL(bush_cv_printf_a_format,
927 sprintf(abuf, "%A", y);
928 exit(strchr(abuf, 'P') == (char *)0);
930 ], bush_cv_printf_a_format=yes, bush_cv_printf_a_format=no,
931 [AC_MSG_WARN(cannot check printf if cross compiling -- defaulting to no)
932 bush_cv_printf_a_format=no]
934 AC_MSG_RESULT($bush_cv_printf_a_format)
935 if test $bush_cv_printf_a_format = yes; then
936 AC_DEFINE(HAVE_PRINTF_A_FORMAT)
940 AC_DEFUN(BUSH_STRUCT_TERMIOS_LDISC,
942 AC_CHECK_MEMBER(struct termios.c_line, AC_DEFINE(TERMIOS_LDISC), ,[
943 #include <sys/types.h>
948 AC_DEFUN(BUSH_STRUCT_TERMIO_LDISC,
950 AC_CHECK_MEMBER(struct termio.c_line, AC_DEFINE(TERMIO_LDISC), ,[
951 #include <sys/types.h>
957 dnl Like AC_STRUCT_ST_BLOCKS, but doesn't muck with LIBOBJS
959 dnl sets bush_cv_struct_stat_st_blocks
961 dnl unused for now; we'll see how AC_CHECK_MEMBERS works
963 AC_DEFUN(BUSH_STRUCT_ST_BLOCKS,
965 AC_MSG_CHECKING([for struct stat.st_blocks])
966 AC_CACHE_VAL(bush_cv_struct_stat_st_blocks,
969 #include <sys/types.h>
970 #include <sys/stat.h>
976 static struct stat a;
977 if (a.st_blocks) return 0;
980 ], bush_cv_struct_stat_st_blocks=yes, bush_cv_struct_stat_st_blocks=no)
982 AC_MSG_RESULT($bush_cv_struct_stat_st_blocks)
983 if test "$bush_cv_struct_stat_st_blocks" = "yes"; then
984 AC_DEFINE(HAVE_STRUCT_STAT_ST_BLOCKS)
988 AC_DEFUN([BUSH_CHECK_LIB_TERMCAP],
990 if test "X$bush_cv_termcap_lib" = "X"; then
993 AC_MSG_CHECKING(which library has the termcap functions)
996 AC_CACHE_VAL(bush_cv_termcap_lib,
997 [AC_CHECK_FUNC(tgetent, bush_cv_termcap_lib=libc,
998 [AC_CHECK_LIB(termcap, tgetent, bush_cv_termcap_lib=libtermcap,
999 [AC_CHECK_LIB(tinfo, tgetent, bush_cv_termcap_lib=libtinfo,
1000 [AC_CHECK_LIB(curses, tgetent, bush_cv_termcap_lib=libcurses,
1001 [AC_CHECK_LIB(ncurses, tgetent, bush_cv_termcap_lib=libncurses,
1002 [AC_CHECK_LIB(ncursesw, tgetent, bush_cv_termcap_lib=libncursesw,
1003 bush_cv_termcap_lib=gnutermcap)])])])])])])
1004 if test "X$_bush_needmsg" = "Xyes"; then
1005 AC_MSG_CHECKING(which library has the termcap functions)
1007 AC_MSG_RESULT(using $bush_cv_termcap_lib)
1008 if test $bush_cv_termcap_lib = gnutermcap && test -z "$prefer_curses"; then
1009 LDFLAGS="$LDFLAGS -L./lib/termcap"
1010 TERMCAP_LIB="./lib/termcap/libtermcap.a"
1011 TERMCAP_DEP="./lib/termcap/libtermcap.a"
1012 elif test $bush_cv_termcap_lib = libtermcap && test -z "$prefer_curses"; then
1013 TERMCAP_LIB=-ltermcap
1015 elif test $bush_cv_termcap_lib = libtinfo; then
1018 elif test $bush_cv_termcap_lib = libncurses; then
1019 TERMCAP_LIB=-lncurses
1021 elif test $bush_cv_termcap_lib = libc; then
1025 TERMCAP_LIB=-lcurses
1031 dnl Check for the presence of getpeername in libsocket.
1032 dnl If libsocket is present, check for libnsl and add it to LIBS if
1033 dnl it's there, since most systems with libsocket require linking
1034 dnl with libnsl as well. This should only be called if getpeername
1035 dnl was not found in libc.
1037 dnl NOTE: IF WE FIND GETPEERNAME, WE ASSUME THAT WE HAVE BIND/CONNECT
1040 AC_DEFUN(BUSH_CHECK_LIB_SOCKET,
1042 if test "X$bush_cv_have_socklib" = "X"; then
1045 AC_MSG_CHECKING(for socket library)
1048 AC_CACHE_VAL(bush_cv_have_socklib,
1049 [AC_CHECK_LIB(socket, getpeername,
1050 bush_cv_have_socklib=yes, bush_cv_have_socklib=no, -lnsl)])
1051 if test "X$_bush_needmsg" = Xyes; then
1052 AC_MSG_RESULT($bush_cv_have_socklib)
1055 if test $bush_cv_have_socklib = yes; then
1056 # check for libnsl, add it to LIBS if present
1057 if test "X$bush_cv_have_libnsl" = "X"; then
1060 AC_MSG_CHECKING(for libnsl)
1063 AC_CACHE_VAL(bush_cv_have_libnsl,
1064 [AC_CHECK_LIB(nsl, t_open,
1065 bush_cv_have_libnsl=yes, bush_cv_have_libnsl=no)])
1066 if test "X$_bush_needmsg" = Xyes; then
1067 AC_MSG_RESULT($bush_cv_have_libnsl)
1070 if test $bush_cv_have_libnsl = yes; then
1071 LIBS="-lsocket -lnsl $LIBS"
1073 LIBS="-lsocket $LIBS"
1075 AC_DEFINE(HAVE_LIBSOCKET)
1076 AC_DEFINE(HAVE_GETPEERNAME)
1080 AC_DEFUN(BUSH_STRUCT_DIRENT_D_INO,
1081 [AC_REQUIRE([AC_HEADER_DIRENT])
1082 AC_MSG_CHECKING(for struct dirent.d_ino)
1083 AC_CACHE_VAL(bush_cv_dirent_has_dino,
1086 #include <sys/types.h>
1087 #ifdef HAVE_UNISTD_H
1088 # include <unistd.h>
1089 #endif /* HAVE_UNISTD_H */
1090 #if defined(HAVE_DIRENT_H)
1091 # include <dirent.h>
1093 # define dirent direct
1094 # ifdef HAVE_SYS_NDIR_H
1095 # include <sys/ndir.h>
1096 # endif /* SYSNDIR */
1097 # ifdef HAVE_SYS_DIR_H
1098 # include <sys/dir.h>
1099 # endif /* SYSDIR */
1103 #endif /* HAVE_DIRENT_H */
1105 struct dirent d; int z; z = d.d_ino;
1106 ], bush_cv_dirent_has_dino=yes, bush_cv_dirent_has_dino=no)])
1107 AC_MSG_RESULT($bush_cv_dirent_has_dino)
1108 if test $bush_cv_dirent_has_dino = yes; then
1109 AC_DEFINE(HAVE_STRUCT_DIRENT_D_INO)
1113 AC_DEFUN(BUSH_STRUCT_DIRENT_D_FILENO,
1114 [AC_REQUIRE([AC_HEADER_DIRENT])
1115 AC_MSG_CHECKING(for struct dirent.d_fileno)
1116 AC_CACHE_VAL(bush_cv_dirent_has_d_fileno,
1119 #include <sys/types.h>
1120 #ifdef HAVE_UNISTD_H
1121 # include <unistd.h>
1122 #endif /* HAVE_UNISTD_H */
1123 #if defined(HAVE_DIRENT_H)
1124 # include <dirent.h>
1126 # define dirent direct
1127 # ifdef HAVE_SYS_NDIR_H
1128 # include <sys/ndir.h>
1129 # endif /* SYSNDIR */
1130 # ifdef HAVE_SYS_DIR_H
1131 # include <sys/dir.h>
1132 # endif /* SYSDIR */
1136 #endif /* HAVE_DIRENT_H */
1138 struct dirent d; int z; z = d.d_fileno;
1139 ], bush_cv_dirent_has_d_fileno=yes, bush_cv_dirent_has_d_fileno=no)])
1140 AC_MSG_RESULT($bush_cv_dirent_has_d_fileno)
1141 if test $bush_cv_dirent_has_d_fileno = yes; then
1142 AC_DEFINE(HAVE_STRUCT_DIRENT_D_FILENO)
1146 AC_DEFUN(BUSH_STRUCT_DIRENT_D_NAMLEN,
1147 [AC_REQUIRE([AC_HEADER_DIRENT])
1148 AC_MSG_CHECKING(for struct dirent.d_namlen)
1149 AC_CACHE_VAL(bush_cv_dirent_has_d_namlen,
1152 #include <sys/types.h>
1153 #ifdef HAVE_UNISTD_H
1154 # include <unistd.h>
1155 #endif /* HAVE_UNISTD_H */
1156 #if defined(HAVE_DIRENT_H)
1157 # include <dirent.h>
1159 # define dirent direct
1160 # ifdef HAVE_SYS_NDIR_H
1161 # include <sys/ndir.h>
1162 # endif /* SYSNDIR */
1163 # ifdef HAVE_SYS_DIR_H
1164 # include <sys/dir.h>
1165 # endif /* SYSDIR */
1169 #endif /* HAVE_DIRENT_H */
1171 struct dirent d; int z; z = d.d_namlen;
1172 ], bush_cv_dirent_has_d_namlen=yes, bush_cv_dirent_has_d_namlen=no)])
1173 AC_MSG_RESULT($bush_cv_dirent_has_d_namlen)
1174 if test $bush_cv_dirent_has_d_namlen = yes; then
1175 AC_DEFINE(HAVE_STRUCT_DIRENT_D_NAMLEN)
1179 AC_DEFUN(BUSH_STRUCT_TIMEVAL,
1180 [AC_MSG_CHECKING(for struct timeval in sys/time.h and time.h)
1181 AC_CACHE_VAL(bush_cv_struct_timeval,
1184 [[#if HAVE_SYS_TIME_H
1185 #include <sys/time.h>
1189 [[static struct timeval x; x.tv_sec = x.tv_usec;]]
1191 bush_cv_struct_timeval=yes,
1192 bush_cv_struct_timeval=no)
1194 AC_MSG_RESULT($bush_cv_struct_timeval)
1195 if test $bush_cv_struct_timeval = yes; then
1196 AC_DEFINE(HAVE_TIMEVAL)
1200 AC_DEFUN(BUSH_STRUCT_TIMEZONE,
1201 [AC_MSG_CHECKING(for struct timezone in sys/time.h and time.h)
1202 AC_CACHE_VAL(bush_cv_struct_timezone,
1204 AC_EGREP_HEADER(struct timezone, sys/time.h,
1205 bush_cv_struct_timezone=yes,
1206 AC_EGREP_HEADER(struct timezone, time.h,
1207 bush_cv_struct_timezone=yes,
1208 bush_cv_struct_timezone=no))
1210 AC_MSG_RESULT($bush_cv_struct_timezone)
1211 if test $bush_cv_struct_timezone = yes; then
1212 AC_DEFINE(HAVE_STRUCT_TIMEZONE)
1216 AC_DEFUN(BUSH_STRUCT_WINSIZE,
1217 [AC_MSG_CHECKING(for struct winsize in sys/ioctl.h and termios.h)
1218 AC_CACHE_VAL(bush_cv_struct_winsize_header,
1219 [AC_TRY_COMPILE([#include <sys/types.h>
1220 #include <sys/ioctl.h>], [struct winsize x;],
1221 bush_cv_struct_winsize_header=ioctl_h,
1222 [AC_TRY_COMPILE([#include <sys/types.h>
1223 #include <termios.h>], [struct winsize x;],
1224 bush_cv_struct_winsize_header=termios_h, bush_cv_struct_winsize_header=other)
1226 if test $bush_cv_struct_winsize_header = ioctl_h; then
1227 AC_MSG_RESULT(sys/ioctl.h)
1228 AC_DEFINE(STRUCT_WINSIZE_IN_SYS_IOCTL)
1229 elif test $bush_cv_struct_winsize_header = termios_h; then
1230 AC_MSG_RESULT(termios.h)
1231 AC_DEFINE(STRUCT_WINSIZE_IN_TERMIOS)
1233 AC_MSG_RESULT(not found)
1237 dnl Check type of signal routines (posix, 4.2bsd, 4.1bsd or v7)
1238 AC_DEFUN(BUSH_SYS_SIGNAL_VINTAGE,
1239 [AC_REQUIRE([AC_TYPE_SIGNAL])
1240 AC_MSG_CHECKING(for type of signal functions)
1241 AC_CACHE_VAL(bush_cv_signal_vintage,
1243 AC_TRY_LINK([#include <signal.h>],[
1245 struct sigaction sa;
1246 sigemptyset(&ss); sigsuspend(&ss);
1247 sigaction(SIGINT, &sa, (struct sigaction *) 0);
1248 sigprocmask(SIG_BLOCK, &ss, (sigset_t *) 0);
1249 ], bush_cv_signal_vintage=posix,
1251 AC_TRY_LINK([#include <signal.h>], [
1252 int mask = sigmask(SIGINT);
1253 sigsetmask(mask); sigblock(mask); sigpause(mask);
1254 ], bush_cv_signal_vintage=4.2bsd,
1258 RETSIGTYPE foo() { }], [
1259 int mask = sigmask(SIGINT);
1260 sigset(SIGINT, foo); sigrelse(SIGINT);
1261 sighold(SIGINT); sigpause(SIGINT);
1262 ], bush_cv_signal_vintage=svr3, bush_cv_signal_vintage=v7
1267 AC_MSG_RESULT($bush_cv_signal_vintage)
1268 if test "$bush_cv_signal_vintage" = posix; then
1269 AC_DEFINE(HAVE_POSIX_SIGNALS)
1270 elif test "$bush_cv_signal_vintage" = "4.2bsd"; then
1271 AC_DEFINE(HAVE_BSD_SIGNALS)
1272 elif test "$bush_cv_signal_vintage" = svr3; then
1273 AC_DEFINE(HAVE_USG_SIGHOLD)
1277 dnl Check if the pgrp of setpgrp() can't be the pid of a zombie process.
1278 AC_DEFUN(BUSH_SYS_PGRP_SYNC,
1279 [AC_REQUIRE([AC_FUNC_GETPGRP])
1280 AC_MSG_CHECKING(whether pgrps need synchronization)
1281 AC_CACHE_VAL(bush_cv_pgrp_pipe,
1283 #ifdef HAVE_UNISTD_H
1284 # include <unistd.h>
1286 #ifdef HAVE_SYS_WAIT_H
1287 # include <sys/wait.h>
1293 # ifdef GETPGRP_VOID
1294 # define getpgID() getpgrp()
1296 # define getpgID() getpgrp(0)
1297 # define setpgid(x,y) setpgrp(x,y)
1299 int pid1, pid2, fds[2];
1303 switch (pid1 = fork()) {
1307 setpgid(0, getpid());
1310 setpgid(pid1, pid1);
1312 sleep(2); /* let first child die */
1317 switch (pid2 = fork()) {
1322 ok = getpgID() == pid1;
1323 write(fds[1], &ok, 1);
1326 setpgid(pid2, pid1);
1329 if (read(fds[0], &ok, 1) != 1)
1335 ], bush_cv_pgrp_pipe=no,bush_cv_pgrp_pipe=yes,
1336 [AC_MSG_WARN(cannot check pgrp synchronization if cross compiling -- defaulting to no)
1337 bush_cv_pgrp_pipe=no])
1339 AC_MSG_RESULT($bush_cv_pgrp_pipe)
1340 if test $bush_cv_pgrp_pipe = yes; then
1341 AC_DEFINE(PGRP_PIPE)
1345 AC_DEFUN(BUSH_SYS_REINSTALL_SIGHANDLERS,
1346 [AC_REQUIRE([AC_TYPE_SIGNAL])
1347 AC_REQUIRE([BUSH_SYS_SIGNAL_VINTAGE])
1348 AC_MSG_CHECKING([if signal handlers must be reinstalled when invoked])
1349 AC_CACHE_VAL(bush_cv_must_reinstall_sighandlers,
1352 #ifdef HAVE_UNISTD_H
1357 typedef RETSIGTYPE sigfunc();
1359 volatile int nsigint;
1361 #ifdef HAVE_POSIX_SIGNALS
1363 set_signal_handler(sig, handler)
1367 struct sigaction act, oact;
1368 act.sa_handler = handler;
1370 sigemptyset (&act.sa_mask);
1371 sigemptyset (&oact.sa_mask);
1372 sigaction (sig, &act, &oact);
1373 return (oact.sa_handler);
1376 #define set_signal_handler(s, h) signal(s, h)
1390 set_signal_handler(SIGINT, sigint);
1391 kill((int)getpid(), SIGINT);
1392 kill((int)getpid(), SIGINT);
1395 ], bush_cv_must_reinstall_sighandlers=no, bush_cv_must_reinstall_sighandlers=yes,
1396 [AC_MSG_WARN(cannot check signal handling if cross compiling -- defaulting to no)
1397 bush_cv_must_reinstall_sighandlers=no]
1399 AC_MSG_RESULT($bush_cv_must_reinstall_sighandlers)
1400 if test $bush_cv_must_reinstall_sighandlers = yes; then
1401 AC_DEFINE(MUST_REINSTALL_SIGHANDLERS)
1405 dnl check that some necessary job control definitions are present
1406 AC_DEFUN(BUSH_SYS_JOB_CONTROL_MISSING,
1407 [AC_REQUIRE([BUSH_SYS_SIGNAL_VINTAGE])
1408 AC_MSG_CHECKING(for presence of necessary job control definitions)
1409 AC_CACHE_VAL(bush_cv_job_control_missing,
1411 #include <sys/types.h>
1412 #ifdef HAVE_SYS_WAIT_H
1413 #include <sys/wait.h>
1415 #ifdef HAVE_UNISTD_H
1420 /* add more tests in here as appropriate */
1423 #if !defined (HAVE_POSIX_SIGNALS) && !defined (HAVE_BSD_SIGNALS)
1427 /* signals and tty control. */
1428 #if !defined (SIGTSTP) || !defined (SIGSTOP) || !defined (SIGCONT)
1432 /* process control */
1433 #if !defined (WNOHANG) || !defined (WUNTRACED)
1437 /* Posix systems have tcgetpgrp and waitpid. */
1438 #if defined (_POSIX_VERSION) && !defined (HAVE_TCGETPGRP)
1442 #if defined (_POSIX_VERSION) && !defined (HAVE_WAITPID)
1446 /* Other systems have TIOCSPGRP/TIOCGPRGP and wait3. */
1447 #if !defined (_POSIX_VERSION) && !defined (HAVE_WAIT3)
1451 ], , bush_cv_job_control_missing=present, bush_cv_job_control_missing=missing
1453 AC_MSG_RESULT($bush_cv_job_control_missing)
1454 if test $bush_cv_job_control_missing = missing; then
1455 AC_DEFINE(JOB_CONTROL_MISSING)
1459 dnl check whether named pipes are present
1460 dnl this requires a previous check for mkfifo, but that is awkward to specify
1461 AC_DEFUN(BUSH_SYS_NAMED_PIPES,
1462 [AC_MSG_CHECKING(for presence of named pipes)
1463 AC_CACHE_VAL(bush_cv_sys_named_pipes,
1465 #include <sys/types.h>
1466 #include <sys/stat.h>
1467 #ifdef HAVE_UNISTD_H
1473 /* Add more tests in here as appropriate. */
1479 #if defined (HAVE_MKFIFO)
1483 #if !defined (S_IFIFO) && (defined (_POSIX_VERSION) && !defined (S_ISFIFO))
1490 err = mkdir("bush-aclocal", 0700);
1495 fd = mknod ("bush-aclocal/sh-np-autoconf", 0666 | S_IFIFO, 0);
1497 rmdir ("bush-aclocal");
1501 unlink ("bush-aclocal/sh-np-autoconf");
1502 rmdir ("bush-aclocal");
1504 }], bush_cv_sys_named_pipes=present, bush_cv_sys_named_pipes=missing,
1505 [AC_MSG_WARN(cannot check for named pipes if cross-compiling -- defaulting to missing)
1506 bush_cv_sys_named_pipes=missing]
1508 AC_MSG_RESULT($bush_cv_sys_named_pipes)
1509 if test $bush_cv_sys_named_pipes = missing; then
1510 AC_DEFINE(NAMED_PIPES_MISSING)
1514 AC_DEFUN(BUSH_SYS_DEFAULT_MAIL_DIR,
1515 [AC_MSG_CHECKING(for default mail directory)
1516 AC_CACHE_VAL(bush_cv_mail_dir,
1517 [if test -d /var/mail; then
1518 bush_cv_mail_dir=/var/mail
1519 elif test -d /var/spool/mail; then
1520 bush_cv_mail_dir=/var/spool/mail
1521 elif test -d /usr/mail; then
1522 bush_cv_mail_dir=/usr/mail
1523 elif test -d /usr/spool/mail; then
1524 bush_cv_mail_dir=/usr/spool/mail
1526 bush_cv_mail_dir=unknown
1529 AC_MSG_RESULT($bush_cv_mail_dir)
1530 AC_DEFINE_UNQUOTED(DEFAULT_MAIL_DIRECTORY, "$bush_cv_mail_dir")
1533 AC_DEFUN(BUSH_HAVE_TIOCGWINSZ,
1534 [AC_MSG_CHECKING(for TIOCGWINSZ in sys/ioctl.h)
1535 AC_CACHE_VAL(bush_cv_tiocgwinsz_in_ioctl,
1536 [AC_TRY_COMPILE([#include <sys/types.h>
1537 #include <sys/ioctl.h>], [int x = TIOCGWINSZ;],
1538 bush_cv_tiocgwinsz_in_ioctl=yes,bush_cv_tiocgwinsz_in_ioctl=no)])
1539 AC_MSG_RESULT($bush_cv_tiocgwinsz_in_ioctl)
1540 if test $bush_cv_tiocgwinsz_in_ioctl = yes; then
1541 AC_DEFINE(GWINSZ_IN_SYS_IOCTL)
1545 AC_DEFUN(BUSH_HAVE_TIOCSTAT,
1546 [AC_MSG_CHECKING(for TIOCSTAT in sys/ioctl.h)
1547 AC_CACHE_VAL(bush_cv_tiocstat_in_ioctl,
1548 [AC_TRY_COMPILE([#include <sys/types.h>
1549 #include <sys/ioctl.h>], [int x = TIOCSTAT;],
1550 bush_cv_tiocstat_in_ioctl=yes,bush_cv_tiocstat_in_ioctl=no)])
1551 AC_MSG_RESULT($bush_cv_tiocstat_in_ioctl)
1552 if test $bush_cv_tiocstat_in_ioctl = yes; then
1553 AC_DEFINE(TIOCSTAT_IN_SYS_IOCTL)
1557 AC_DEFUN(BUSH_HAVE_FIONREAD,
1558 [AC_MSG_CHECKING(for FIONREAD in sys/ioctl.h)
1559 AC_CACHE_VAL(bush_cv_fionread_in_ioctl,
1560 [AC_TRY_COMPILE([#include <sys/types.h>
1561 #include <sys/ioctl.h>], [int x = FIONREAD;],
1562 bush_cv_fionread_in_ioctl=yes,bush_cv_fionread_in_ioctl=no)])
1563 AC_MSG_RESULT($bush_cv_fionread_in_ioctl)
1564 if test $bush_cv_fionread_in_ioctl = yes; then
1565 AC_DEFINE(FIONREAD_IN_SYS_IOCTL)
1570 dnl See if speed_t is declared in <sys/types.h>. Some versions of linux
1571 dnl require a definition of speed_t each time <termcap.h> is included,
1572 dnl but you can only get speed_t if you include <termios.h> (on some
1573 dnl versions) or <sys/types.h> (on others).
1575 AC_DEFUN(BUSH_CHECK_SPEED_T,
1576 [AC_MSG_CHECKING(for speed_t in sys/types.h)
1577 AC_CACHE_VAL(bush_cv_speed_t_in_sys_types,
1578 [AC_TRY_COMPILE([#include <sys/types.h>], [speed_t x;],
1579 bush_cv_speed_t_in_sys_types=yes,bush_cv_speed_t_in_sys_types=no)])
1580 AC_MSG_RESULT($bush_cv_speed_t_in_sys_types)
1581 if test $bush_cv_speed_t_in_sys_types = yes; then
1582 AC_DEFINE(SPEED_T_IN_SYS_TYPES)
1586 AC_DEFUN(BUSH_CHECK_GETPW_FUNCS,
1587 [AC_MSG_CHECKING(whether getpw functions are declared in pwd.h)
1588 AC_CACHE_VAL(bush_cv_getpw_declared,
1589 [AC_EGREP_CPP(getpwuid,
1591 #include <sys/types.h>
1592 #ifdef HAVE_UNISTD_H
1593 # include <unistd.h>
1597 bush_cv_getpw_declared=yes,bush_cv_getpw_declared=no)])
1598 AC_MSG_RESULT($bush_cv_getpw_declared)
1599 if test $bush_cv_getpw_declared = yes; then
1600 AC_DEFINE(HAVE_GETPW_DECLS)
1604 AC_DEFUN(BUSH_CHECK_DEV_FD,
1605 [AC_MSG_CHECKING(whether /dev/fd is available)
1606 AC_CACHE_VAL(bush_cv_dev_fd,
1608 if test -d /dev/fd && (exec test -r /dev/fd/0 < /dev/null) ; then
1609 # check for systems like FreeBSD 5 that only provide /dev/fd/[012]
1610 if (exec test -r /dev/fd/3 3</dev/null) ; then
1611 bush_cv_dev_fd=standard
1613 bush_cv_dev_fd=absent
1616 if test -z "$bush_cv_dev_fd" ; then
1617 if test -d /proc/self/fd && (exec test -r /proc/self/fd/0 < /dev/null) ; then
1618 bush_cv_dev_fd=whacky
1620 bush_cv_dev_fd=absent
1624 AC_MSG_RESULT($bush_cv_dev_fd)
1625 if test $bush_cv_dev_fd = "standard"; then
1626 AC_DEFINE(HAVE_DEV_FD)
1627 AC_DEFINE(DEV_FD_PREFIX, "/dev/fd/")
1628 elif test $bush_cv_dev_fd = "whacky"; then
1629 AC_DEFINE(HAVE_DEV_FD)
1630 AC_DEFINE(DEV_FD_PREFIX, "/proc/self/fd/")
1634 AC_DEFUN(BUSH_CHECK_DEV_STDIN,
1635 [AC_MSG_CHECKING(whether /dev/stdin stdout stderr are available)
1636 AC_CACHE_VAL(bush_cv_dev_stdin,
1637 [if (exec test -r /dev/stdin < /dev/null) ; then
1638 bush_cv_dev_stdin=present
1640 bush_cv_dev_stdin=absent
1643 AC_MSG_RESULT($bush_cv_dev_stdin)
1644 if test $bush_cv_dev_stdin = "present"; then
1645 AC_DEFINE(HAVE_DEV_STDIN)
1650 dnl Check if HPUX needs _KERNEL defined for RLIMIT_* definitions
1652 AC_DEFUN(BUSH_CHECK_KERNEL_RLIMIT,
1653 [AC_MSG_CHECKING([whether $host_os needs _KERNEL for RLIMIT defines])
1654 AC_CACHE_VAL(bush_cv_kernel_rlimit,
1656 #include <sys/types.h>
1657 #include <sys/resource.h>
1662 ], bush_cv_kernel_rlimit=no,
1664 #include <sys/types.h>
1666 #include <sys/resource.h>
1672 ], bush_cv_kernel_rlimit=yes, bush_cv_kernel_rlimit=no)]
1674 AC_MSG_RESULT($bush_cv_kernel_rlimit)
1675 if test $bush_cv_kernel_rlimit = yes; then
1676 AC_DEFINE(RLIMIT_NEEDS_KERNEL)
1681 dnl Check for 64-bit off_t -- used for malloc alignment
1683 dnl C does not allow duplicate case labels, so the compile will fail if
1684 dnl sizeof(off_t) is > 4.
1686 AC_DEFUN(BUSH_CHECK_OFF_T_64,
1687 [AC_CACHE_CHECK(for 64-bit off_t, bush_cv_off_t_64,
1689 #ifdef HAVE_UNISTD_H
1692 #include <sys/types.h>
1694 switch (0) case 0: case (sizeof (off_t) <= 4):;
1695 ], bush_cv_off_t_64=no, bush_cv_off_t_64=yes))
1696 if test $bush_cv_off_t_64 = yes; then
1697 AC_DEFINE(HAVE_OFF_T_64)
1700 AC_DEFUN(BUSH_CHECK_RTSIGS,
1701 [AC_MSG_CHECKING(for unusable real-time signals due to large values)
1702 AC_CACHE_VAL(bush_cv_unusable_rtsigs,
1704 #include <sys/types.h>
1715 int n_sigs = 2 * NSIG;
1717 int rtmin = SIGRTMIN;
1722 exit(rtmin < n_sigs);
1723 }], bush_cv_unusable_rtsigs=yes, bush_cv_unusable_rtsigs=no,
1724 [AC_MSG_WARN(cannot check real-time signals if cross compiling -- defaulting to yes)
1725 bush_cv_unusable_rtsigs=yes]
1727 AC_MSG_RESULT($bush_cv_unusable_rtsigs)
1728 if test $bush_cv_unusable_rtsigs = yes; then
1729 AC_DEFINE(UNUSABLE_RT_SIGNALS)
1734 dnl check for availability of multibyte characters and functions
1736 dnl geez, I wish I didn't have to check for all of this stuff separately
1738 AC_DEFUN(BUSH_CHECK_MULTIBYTE,
1740 AC_CHECK_HEADERS(wctype.h)
1741 AC_CHECK_HEADERS(wchar.h)
1742 AC_CHECK_HEADERS(langinfo.h)
1744 AC_CHECK_HEADERS(mbstr.h)
1746 AC_CHECK_FUNC(mbrlen, AC_DEFINE(HAVE_MBRLEN))
1747 AC_CHECK_FUNC(mbscasecmp, AC_DEFINE(HAVE_MBSCMP))
1748 AC_CHECK_FUNC(mbscmp, AC_DEFINE(HAVE_MBSCMP))
1749 AC_CHECK_FUNC(mbsnrtowcs, AC_DEFINE(HAVE_MBSNRTOWCS))
1750 AC_CHECK_FUNC(mbsrtowcs, AC_DEFINE(HAVE_MBSRTOWCS))
1752 AC_REPLACE_FUNCS(mbschr)
1754 AC_CHECK_FUNC(wcrtomb, AC_DEFINE(HAVE_WCRTOMB))
1755 AC_CHECK_FUNC(wcscoll, AC_DEFINE(HAVE_WCSCOLL))
1756 AC_CHECK_FUNC(wcsdup, AC_DEFINE(HAVE_WCSDUP))
1757 AC_CHECK_FUNC(wcwidth, AC_DEFINE(HAVE_WCWIDTH))
1758 AC_CHECK_FUNC(wctype, AC_DEFINE(HAVE_WCTYPE))
1760 AC_REPLACE_FUNCS(wcswidth)
1762 dnl checks for both mbrtowc and mbstate_t
1764 if test $ac_cv_func_mbrtowc = yes; then
1765 AC_DEFINE(HAVE_MBSTATE_T)
1768 AC_CHECK_FUNCS(iswlower iswupper towlower towupper iswctype)
1770 AC_CACHE_CHECK([for nl_langinfo and CODESET], bush_cv_langinfo_codeset,
1772 [#include <langinfo.h>],
1773 [char* cs = nl_langinfo(CODESET);],
1774 bush_cv_langinfo_codeset=yes, bush_cv_langinfo_codeset=no)])
1775 if test $bush_cv_langinfo_codeset = yes; then
1776 AC_DEFINE(HAVE_LANGINFO_CODESET)
1779 dnl check for wchar_t in <wchar.h>
1780 AC_CACHE_CHECK([for wchar_t in wchar.h], bush_cv_type_wchar_t,
1787 ], bush_cv_type_wchar_t=yes, bush_cv_type_wchar_t=no)])
1788 if test $bush_cv_type_wchar_t = yes; then
1789 AC_DEFINE(HAVE_WCHAR_T, 1, [systems should define this type here])
1792 dnl check for wctype_t in <wctype.h>
1793 AC_CACHE_CHECK([for wctype_t in wctype.h], bush_cv_type_wctype_t,
1795 [#include <wctype.h>],
1799 ], bush_cv_type_wctype_t=yes, bush_cv_type_wctype_t=no)])
1800 if test $bush_cv_type_wctype_t = yes; then
1801 AC_DEFINE(HAVE_WCTYPE_T, 1, [systems should define this type here])
1804 dnl check for wint_t in <wctype.h>
1805 AC_CACHE_CHECK([for wint_t in wctype.h], bush_cv_type_wint_t,
1807 [#include <wctype.h>],
1811 ], bush_cv_type_wint_t=yes, bush_cv_type_wint_t=no)])
1812 if test $bush_cv_type_wint_t = yes; then
1813 AC_DEFINE(HAVE_WINT_T, 1, [systems should define this type here])
1816 dnl check for broken wcwidth
1817 AC_CACHE_CHECK([for wcwidth broken with unicode combining characters],
1818 bush_cv_wcwidth_broken,
1834 setlocale(LC_ALL, "en_US.UTF-8");
1835 w = wcwidth (0x0301);
1836 exit (w == 0); /* exit 0 if wcwidth broken */
1839 bush_cv_wcwidth_broken=yes, bush_cv_wcwidth_broken=no, bush_cv_wcwidth_broken=no)])
1840 if test "$bush_cv_wcwidth_broken" = yes; then
1841 AC_DEFINE(WCWIDTH_BROKEN, 1, [wcwidth is usually not broken])
1844 if test "$am_cv_func_iconv" = yes; then
1846 LIBS="$LIBS $LIBINTL $LIBICONV"
1847 AC_CHECK_FUNCS(locale_charset)
1851 AC_CHECK_SIZEOF(wchar_t, 4)
1855 dnl need: prefix exec_prefix libdir includedir CC TERMCAP_LIB
1858 dnl BUSH_CHECK_LIB_TERMCAP
1860 AC_DEFUN([RL_LIB_READLINE_VERSION],
1862 AC_REQUIRE([BUSH_CHECK_LIB_TERMCAP])
1864 AC_MSG_CHECKING([version of installed readline library])
1866 # What a pain in the ass this is.
1868 # save cpp and ld options
1869 _save_CFLAGS="$CFLAGS"
1870 _save_LDFLAGS="$LDFLAGS"
1873 # Don't set ac_cv_rl_prefix if the caller has already assigned a value. This
1874 # allows the caller to do something like $_rl_prefix=$withval if the user
1875 # specifies --with-installed-readline=PREFIX as an argument to configure
1877 if test -z "$ac_cv_rl_prefix"; then
1878 test "x$prefix" = xNONE && ac_cv_rl_prefix=$ac_default_prefix || ac_cv_rl_prefix=${prefix}
1881 eval ac_cv_rl_includedir=${ac_cv_rl_prefix}/include
1882 eval ac_cv_rl_libdir=${ac_cv_rl_prefix}/lib
1884 LIBS="$LIBS -lreadline ${TERMCAP_LIB}"
1885 CFLAGS="$CFLAGS -I${ac_cv_rl_includedir}"
1886 LDFLAGS="$LDFLAGS -L${ac_cv_rl_libdir}"
1888 AC_CACHE_VAL(ac_cv_rl_version,
1891 #include <readline/readline.h>
1894 extern int rl_gnu_readline_p;
1900 fp = fopen("conftest.rlv", "w");
1903 if (rl_gnu_readline_p != 1)
1904 fprintf(fp, "0.0\n");
1906 fprintf(fp, "%s\n", rl_library_version ? rl_library_version : "0.0");
1911 ac_cv_rl_version=`cat conftest.rlv`,
1912 ac_cv_rl_version='0.0',
1913 ac_cv_rl_version='8.0')])
1915 CFLAGS="$_save_CFLAGS"
1916 LDFLAGS="$_save_LDFLAGS"
1923 case "$ac_cv_rl_version" in
1924 2*|3*|4*|5*|6*|7*|8*|9*)
1925 RL_MAJOR=`echo $ac_cv_rl_version | sed 's:\..*$::'`
1926 RL_MINOR=`echo $ac_cv_rl_version | sed -e 's:^.*\.::' -e 's:[[a-zA-Z]]*$::'`
1932 [[0-9][0-9]]) _RL_MAJOR=$RL_MAJOR ;;
1933 [[0-9]]) _RL_MAJOR=0$RL_MAJOR ;;
1939 [[0-9][0-9]]) _RL_MINOR=$RL_MINOR ;;
1940 [[0-9]]) _RL_MINOR=0$RL_MINOR ;;
1944 RL_VERSION="0x${_RL_MAJOR}${_RL_MINOR}"
1946 # Readline versions greater than 4.2 have these defines in readline.h
1948 if test $ac_cv_rl_version = '0.0' ; then
1949 AC_MSG_WARN([Could not test version of installed readline library.])
1950 elif test $RL_MAJOR -gt 4 || { test $RL_MAJOR = 4 && test $RL_MINOR -gt 2 ; } ; then
1951 # set these for use by the caller
1952 RL_PREFIX=$ac_cv_rl_prefix
1953 RL_LIBDIR=$ac_cv_rl_libdir
1954 RL_INCLUDEDIR=$ac_cv_rl_includedir
1955 AC_MSG_RESULT($ac_cv_rl_version)
1958 AC_DEFINE_UNQUOTED(RL_READLINE_VERSION, $RL_VERSION, [encoded version of the installed readline library])
1959 AC_DEFINE_UNQUOTED(RL_VERSION_MAJOR, $RL_MAJOR, [major version of installed readline library])
1960 AC_DEFINE_UNQUOTED(RL_VERSION_MINOR, $RL_MINOR, [minor version of installed readline library])
1962 AC_SUBST(RL_VERSION)
1966 # set these for use by the caller
1967 RL_PREFIX=$ac_cv_rl_prefix
1968 RL_LIBDIR=$ac_cv_rl_libdir
1969 RL_INCLUDEDIR=$ac_cv_rl_includedir
1971 AC_MSG_RESULT($ac_cv_rl_version)
1976 AC_DEFUN(BUSH_FUNC_CTYPE_NONASCII,
1978 AC_MSG_CHECKING(whether the ctype macros accept non-ascii characters)
1979 AC_CACHE_VAL(bush_cv_func_ctype_nonascii,
1981 #ifdef HAVE_LOCALE_H
1997 #ifdef HAVE_SETLOCALE
1998 /* We take a shot here. If that locale is not known, try the
1999 system default. We try this one because '\342' (226) is
2000 known to be a printable character in that locale. */
2001 deflocale = setlocale(LC_ALL, "en_US.ISO8859-1");
2003 deflocale = setlocale(LC_ALL, "");
2010 exit (r1 == 0 || r2 == 0);
2012 ], bush_cv_func_ctype_nonascii=yes, bush_cv_func_ctype_nonascii=no,
2013 [AC_MSG_WARN(cannot check ctype macros if cross compiling -- defaulting to no)
2014 bush_cv_func_ctype_nonascii=no]
2016 AC_MSG_RESULT($bush_cv_func_ctype_nonascii)
2017 if test $bush_cv_func_ctype_nonascii = yes; then
2018 AC_DEFINE(CTYPE_NON_ASCII)
2022 AC_DEFUN(BUSH_CHECK_WCONTINUED,
2024 AC_MSG_CHECKING(whether WCONTINUED flag to waitpid is unavailable or available but broken)
2025 AC_CACHE_VAL(bush_cv_wcontinued_broken,
2027 #include <sys/types.h>
2028 #include <sys/wait.h>
2041 x = waitpid(-1, (int *)0, WNOHANG|WCONTINUED);
2042 if (x == -1 && errno == EINVAL)
2047 ], bush_cv_wcontinued_broken=no,bush_cv_wcontinued_broken=yes,
2048 [AC_MSG_WARN(cannot check WCONTINUED if cross compiling -- defaulting to no)
2049 bush_cv_wcontinued_broken=no]
2051 AC_MSG_RESULT($bush_cv_wcontinued_broken)
2052 if test $bush_cv_wcontinued_broken = yes; then
2053 AC_DEFINE(WCONTINUED_BROKEN)
2058 dnl tests added for bushdb
2062 AC_DEFUN([AM_PATH_LISPDIR],
2063 [AC_ARG_WITH(lispdir, AC_HELP_STRING([--with-lispdir], [override the default lisp directory]),
2064 [ lispdir="$withval"
2065 AC_MSG_CHECKING([where .elc files should go])
2066 AC_MSG_RESULT([$lispdir])],
2068 # If set to t, that means we are running in a shell under Emacs.
2069 # If you have an Emacs named "t", then use the full path.
2070 test x"$EMACS" = xt && EMACS=
2071 AC_CHECK_PROGS(EMACS, emacs xemacs, no)
2072 if test $EMACS != "no"; then
2073 if test x${lispdir+set} != xset; then
2074 AC_CACHE_CHECK([where .elc files should go], [am_cv_lispdir], [dnl
2075 am_cv_lispdir=`$EMACS -batch -q -eval '(while load-path (princ (concat (car load-path) "\n")) (setq load-path (cdr load-path)))' | sed -n -e 's,/$,,' -e '/.*\/lib\/\(x\?emacs\/site-lisp\)$/{s,,${libdir}/\1,;p;q;}' -e '/.*\/share\/\(x\?emacs\/site-lisp\)$/{s,,${datadir}/\1,;p;q;}'`
2076 if test -z "$am_cv_lispdir"; then
2077 am_cv_lispdir='${datadir}/emacs/site-lisp'
2080 lispdir="$am_cv_lispdir"
2088 AC_DEFUN([BUSH_FUNC_FPURGE],
2090 AC_CHECK_FUNCS_ONCE([fpurge])
2091 AC_CHECK_FUNCS_ONCE([__fpurge])
2092 AC_CHECK_DECLS([fpurge], , , [#include <stdio.h>])
2095 AC_DEFUN([BUSH_FUNC_SNPRINTF],
2097 AC_CHECK_FUNCS_ONCE([snprintf])
2098 if test X$ac_cv_func_snprintf = Xyes; then
2099 AC_CACHE_CHECK([for standard-conformant snprintf], [bush_cv_func_snprintf],
2108 n = snprintf (0, 0, "%s", "0123456");
2111 ], bush_cv_func_snprintf=yes, bush_cv_func_snprintf=no,
2112 [AC_MSG_WARN([cannot check standard snprintf if cross-compiling])
2113 bush_cv_func_snprintf=yes]
2115 if test $bush_cv_func_snprintf = no; then
2116 ac_cv_func_snprintf=no
2119 if test $ac_cv_func_snprintf = no; then
2120 AC_DEFINE(HAVE_SNPRINTF, 0,
2121 [Define if you have a standard-conformant snprintf function.])
2125 AC_DEFUN([BUSH_FUNC_VSNPRINTF],
2127 AC_CHECK_FUNCS_ONCE([vsnprintf])
2128 if test X$ac_cv_func_vsnprintf = Xyes; then
2129 AC_CACHE_CHECK([for standard-conformant vsnprintf], [bush_cv_func_vsnprintf],
2134 #include <varargs.h>
2141 foo(const char *fmt, ...)
2143 foo(format, va_alist)
2152 va_start(args, fmt);
2156 n = vsnprintf(0, 0, fmt, args);
2165 n = foo("%s", "0123456");
2168 ], bush_cv_func_vsnprintf=yes, bush_cv_func_vsnprintf=no,
2169 [AC_MSG_WARN([cannot check standard vsnprintf if cross-compiling])
2170 bush_cv_func_vsnprintf=yes]
2172 if test $bush_cv_func_vsnprintf = no; then
2173 ac_cv_func_vsnprintf=no
2176 if test $ac_cv_func_vsnprintf = no; then
2177 AC_DEFINE(HAVE_VSNPRINTF, 0,
2178 [Define if you have a standard-conformant vsnprintf function.])
2182 AC_DEFUN(BUSH_STRUCT_WEXITSTATUS_OFFSET,
2183 [AC_MSG_CHECKING(for offset of exit status in return status from wait)
2184 AC_CACHE_VAL(bush_cv_wexitstatus_offset,
2189 #include <sys/wait.h>
2204 /* wait for the process */
2210 for (i = 0; i < (sizeof(s) * 8); i++)
2212 n = (s >> i) & 0xff;
2219 ], bush_cv_wexitstatus_offset=0, bush_cv_wexitstatus_offset=$?,
2220 [AC_MSG_WARN(cannot check WEXITSTATUS offset if cross compiling -- defaulting to 0)
2221 bush_cv_wexitstatus_offset=0]
2223 if test "$bush_cv_wexitstatus_offset" -gt 32 ; then
2224 AC_MSG_WARN(bad exit status from test program -- defaulting to 0)
2225 bush_cv_wexitstatus_offset=0
2227 AC_MSG_RESULT($bush_cv_wexitstatus_offset)
2228 AC_DEFINE_UNQUOTED([WEXITSTATUS_OFFSET], [$bush_cv_wexitstatus_offset], [Offset of exit status in wait status word])
2231 AC_DEFUN([BUSH_FUNC_SBRK],
2233 AC_MSG_CHECKING([for sbrk])
2234 AC_CACHE_VAL(ac_cv_func_sbrk,
2235 [AC_TRY_LINK([#include <unistd.h>],
2236 [ void *x = sbrk (4096); ],
2237 ac_cv_func_sbrk=yes, ac_cv_func_sbrk=no)])
2238 AC_MSG_RESULT($ac_cv_func_sbrk)
2239 if test X$ac_cv_func_sbrk = Xyes; then
2240 AC_CACHE_CHECK([for working sbrk], [bush_cv_func_sbrk],
2246 main(int c, char **v)
2251 exit ((x == (void *)-1) ? 1 : 0);
2253 ], bush_cv_func_sbrk=yes, bush_cv_func_snprintf=sbrk,
2254 [AC_MSG_WARN([cannot check working sbrk if cross-compiling])
2255 bush_cv_func_sbrk=yes]
2257 if test $bush_cv_func_sbrk = no; then
2261 if test $ac_cv_func_sbrk = yes; then
2262 AC_DEFINE(HAVE_SBRK, 1,
2263 [Define if you have a working sbrk function.])
2267 AC_DEFUN(BUSH_FUNC_FNMATCH_EQUIV_FALLBACK,
2268 [AC_MSG_CHECKING(whether fnmatch can be used to check bracket equivalence classes)
2269 AC_CACHE_VAL(bush_cv_fnmatch_equiv_fallback,
2274 #include <fnmatch.h>
2277 char *pattern = "[[=a=]]";
2279 /* char *string = "รค"; */
2280 unsigned char string[4] = { '\xc3', '\xa4', '\0' };
2283 main (int c, char **v)
2285 setlocale (LC_ALL, "en_US.UTF-8");
2286 if (fnmatch (pattern, (const char *)string, 0) != FNM_NOMATCH)
2291 ], bush_cv_fnmatch_equiv_fallback=yes, bush_cv_fnmatch_equiv_fallback=no,
2292 [AC_MSG_WARN(cannot check fnmatch if cross compiling -- defaulting to no)
2293 bush_cv_fnmatch_equiv_fallback=no]
2295 AC_MSG_RESULT($bush_cv_fnmatch_equiv_fallback)
2296 if test "$bush_cv_fnmatch_equiv_fallback" = "yes" ; then
2297 bush_cv_fnmatch_equiv_value=1
2299 bush_cv_fnmatch_equiv_value=0
2301 AC_DEFINE_UNQUOTED([FNMATCH_EQUIV_FALLBACK], [$bush_cv_fnmatch_equiv_value], [Whether fnmatch can be used for bracket equivalence classes])