Annotation of embedaddon/readline/aclocal.m4, revision 1.1.1.2

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

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>