home *** CD-ROM | disk | FTP | other *** search
/ linuxmafia.com 2016 / linuxmafia.com.tar / linuxmafia.com / pub / linux / backup / star-1.3.1.tar.gz / star-1.3.1.tar / star-1.3.1 / conf / aclocal.m4 < prev    next >
M4 Source File  |  2001-02-24  |  40KB  |  1,445 lines

  1. dnl @(#)aclocal.m4    1.18 01/02/24 Copyright 1998 J. Schilling
  2.  
  3. dnl Set VARIABLE to VALUE in C-string form, verbatim, or 1.
  4. dnl AC_DEFINE_STRING(VARIABLE [, VALUE])
  5. define(AC_DEFINE_STRING,
  6. [cat >> confdefs.h <<\EOF
  7. [#define] $1 ifelse($#, 2, "[$2]", $#, 3, "[$2]", 1)
  8. EOF
  9. ])
  10.  
  11. dnl Similar, but perform shell substitutions $ ` \ once on VALUE.
  12. define(AC_DEFINE_UNQUOTED_STRING,
  13. [cat >> confdefs.h <<EOF
  14. [#define] $1 ifelse($#, 2, "[$2]", $#, 3, "[$2]", 1)
  15. EOF
  16. ])
  17.  
  18. dnl Checks if structure 'stat' have field 'st_spare1'.
  19. dnl Defines HAVE_ST_SPARE1 on success.
  20. AC_DEFUN(AC_STRUCT_ST_SPARE1,
  21. [AC_CACHE_CHECK([if struct stat contains st_spare1], ac_cv_struct_st_spare1,
  22.                 [AC_TRY_COMPILE([#include <sys/types.h>
  23. #include <sys/stat.h>],
  24.                                 [struct  stat s; s.st_spare1 = 0;],
  25.                                 [ac_cv_struct_st_spare1=yes],
  26.                                 [ac_cv_struct_st_spare1=no])])
  27. if test $ac_cv_struct_st_spare1 = yes; then
  28.   AC_DEFINE(HAVE_ST_SPARE1)
  29. fi])
  30.  
  31. dnl Checks if structure 'stat' have field 'st_atim.tv_nsec'.
  32. dnl Defines HAVE_ST_NSEC on success.
  33. AC_DEFUN(AC_STRUCT_ST_NSEC,
  34. [AC_CACHE_CHECK([if struct stat contains st_atim.tv_nsec], ac_cv_struct_st_nsec,
  35.                 [AC_TRY_COMPILE([#include <sys/types.h>
  36. #include <sys/stat.h>],
  37.                                 [struct  stat s; s.st_atim.tv_nsec = 0;],
  38.                                 [ac_cv_struct_st_nsec=yes],
  39.                                 [ac_cv_struct_st_nsec=no])])
  40. if test $ac_cv_struct_st_nsec = yes; then
  41.   AC_DEFINE(HAVE_ST_NSEC)
  42. fi])
  43.  
  44. dnl Checks if structure 'mtget' have field 'mt_type'.
  45. dnl Defines HAVE_MTGET_TYPE on success.
  46. AC_DEFUN(AC_STRUCT_MTGET_TYPE,
  47. [AC_CACHE_CHECK([if struct mtget contains mt_type], ac_cv_struct_mtget_type,
  48.                 [AC_TRY_COMPILE([#include <sys/types.h>
  49. #include <sys/mtio.h>],
  50.                                 [struct  mtget t; t.mt_type = 0;],
  51.                                 [ac_cv_struct_mtget_type=yes],
  52.                                 [ac_cv_struct_mtget_type=no])])
  53. if test $ac_cv_struct_mtget_type = yes; then
  54.   AC_DEFINE(HAVE_MTGET_TYPE)
  55. fi])
  56.  
  57. dnl Checks if structure 'mtget' have field 'mt_dsreg'.
  58. dnl Defines HAVE_MTGET_DSREG on success.
  59. AC_DEFUN(AC_STRUCT_MTGET_DSREG,
  60. [AC_CACHE_CHECK([if struct mtget contains mt_dsreg], ac_cv_struct_mtget_dsreg,
  61.                 [AC_TRY_COMPILE([#include <sys/types.h>
  62. #include <sys/mtio.h>],
  63.                                 [struct  mtget t; t.mt_dsreg = 0;],
  64.                                 [ac_cv_struct_mtget_dsreg=yes],
  65.                                 [ac_cv_struct_mtget_dsreg=no])])
  66. if test $ac_cv_struct_mtget_dsreg = yes; then
  67.   AC_DEFINE(HAVE_MTGET_DSREG)
  68. fi])
  69.  
  70. dnl Checks if structure 'mtget' have field 'mt_erreg'.
  71. dnl Defines HAVE_MTGET_ERREG on success.
  72. AC_DEFUN(AC_STRUCT_MTGET_ERREG,
  73. [AC_CACHE_CHECK([if struct mtget contains mt_erreg], ac_cv_struct_mtget_erreg,
  74.                 [AC_TRY_COMPILE([#include <sys/types.h>
  75. #include <sys/mtio.h>],
  76.                                 [struct  mtget t; t.mt_erreg = 0;],
  77.                                 [ac_cv_struct_mtget_erreg=yes],
  78.                                 [ac_cv_struct_mtget_erreg=no])])
  79. if test $ac_cv_struct_mtget_erreg = yes; then
  80.   AC_DEFINE(HAVE_MTGET_ERREG)
  81. fi])
  82.  
  83. dnl Checks if structure 'mtget' have field 'mt_resid'.
  84. dnl Defines HAVE_MTGET_RESID on success.
  85. AC_DEFUN(AC_STRUCT_MTGET_RESID,
  86. [AC_CACHE_CHECK([if struct mtget contains mt_resid], ac_cv_struct_mtget_resid,
  87.                 [AC_TRY_COMPILE([#include <sys/types.h>
  88. #include <sys/mtio.h>],
  89.                                 [struct  mtget t; t.mt_resid = 0;],
  90.                                 [ac_cv_struct_mtget_resid=yes],
  91.                                 [ac_cv_struct_mtget_resid=no])])
  92. if test $ac_cv_struct_mtget_resid = yes; then
  93.   AC_DEFINE(HAVE_MTGET_RESID)
  94. fi])
  95.  
  96. dnl Checks if structure 'mtget' have field 'mt_fileno'.
  97. dnl Defines HAVE_MTGET_FILENO on success.
  98. AC_DEFUN(AC_STRUCT_MTGET_FILENO,
  99. [AC_CACHE_CHECK([if struct mtget contains mt_fileno],
  100.                 ac_cv_struct_mtget_fileno,
  101.                 [AC_TRY_COMPILE([#include <sys/types.h>
  102. #include <sys/mtio.h>],
  103.                         [struct  mtget t; t.mt_fileno = 0;],
  104.                         [ac_cv_struct_mtget_fileno=yes],
  105.                         [ac_cv_struct_mtget_fileno=no])])
  106. if test $ac_cv_struct_mtget_fileno = yes; then
  107.   AC_DEFINE(HAVE_MTGET_FILENO)
  108. fi])
  109.  
  110. dnl Checks if structure 'mtget' have field 'mt_blkno'.
  111. dnl Defines HAVE_MTGET_BLKNO on success.
  112. AC_DEFUN(AC_STRUCT_MTGET_BLKNO,
  113. [AC_CACHE_CHECK([if struct mtget contains mt_blkno], ac_cv_struct_mtget_blkno,
  114.                 [AC_TRY_COMPILE([#include <sys/types.h>
  115. #include <sys/mtio.h>],
  116.                                 [struct  mtget t; t.mt_blkno = 0;],
  117.                                 [ac_cv_struct_mtget_blkno=yes],
  118.                                 [ac_cv_struct_mtget_blkno=no])])
  119. if test $ac_cv_struct_mtget_blkno = yes; then
  120.   AC_DEFINE(HAVE_MTGET_BLKNO)
  121. fi])
  122.  
  123. dnl Checks if structure 'mtget' have field 'mt_flags'.
  124. dnl Defines HAVE_MTGET_FLAGS on success.
  125. AC_DEFUN(AC_STRUCT_MTGET_FLAGS,
  126. [AC_CACHE_CHECK([if struct mtget contains mt_flags], ac_cv_struct_mtget_flags,
  127.                 [AC_TRY_COMPILE([#include <sys/types.h>
  128. #include <sys/mtio.h>],
  129.                                 [struct  mtget t; t.mt_flags = 0;],
  130.                                 [ac_cv_struct_mtget_flags=yes],
  131.                                 [ac_cv_struct_mtget_flags=no])])
  132. if test $ac_cv_struct_mtget_flags = yes; then
  133.   AC_DEFINE(HAVE_MTGET_FLAGS)
  134. fi])
  135.  
  136. dnl Checks if structure 'mtget' have field 'mt_bf'.
  137. dnl Defines HAVE_MTGET_BF on success.
  138. AC_DEFUN(AC_STRUCT_MTGET_BF,
  139. [AC_CACHE_CHECK([if struct mtget contains mt_bf], ac_cv_struct_mtget_bf,
  140.                 [AC_TRY_COMPILE([#include <sys/types.h>
  141. #include <sys/mtio.h>],
  142.                                 [struct  mtget t; t.mt_bf = 0;],
  143.                                 [ac_cv_struct_mtget_bf=yes],
  144.                                 [ac_cv_struct_mtget_bf=no])])
  145. if test $ac_cv_struct_mtget_bf = yes; then
  146.   AC_DEFINE(HAVE_MTGET_BF)
  147. fi])
  148.  
  149. dnl Checks for illegal declaration of 'union semun' in sys/sem.h.
  150. dnl Defines HAVE_UNION_SEMUN on success.
  151. AC_DEFUN(AC_STRUCT_UNION_SEMUN,
  152. [AC_CACHE_CHECK([if an illegal declaration for union semun in sys/sem.h exists], ac_cv_struct_union_semun,
  153.                 [AC_TRY_COMPILE([#include <sys/types.h>
  154. #include <sys/ipc.h>
  155. #include <sys/sem.h>], [union semun s;],
  156.                 [ac_cv_struct_union_semun=yes],
  157.                 [ac_cv_struct_union_semun=no])])
  158. if test $ac_cv_struct_union_semun = yes; then
  159.   AC_DEFINE(HAVE_UNION_SEMUN)
  160. fi])
  161.  
  162. dnl Checks if 'union wait' is declared in 'wait.h' or 'sys/wait.h'.
  163. dnl Defines HAVE_UNION_WAIT on success.
  164. AC_DEFUN(AC_STRUCT_UNION_WAIT,
  165. [AC_CACHE_CHECK([if union wait is declared in wait.h or sys/wait.h], ac_cv_struct_union_wait,
  166.                 [AC_TRY_COMPILE([#include <sys/types.h>
  167. #if    defined(HAVE_WAIT_H)
  168. #    include <wait.h>
  169. #else
  170. #include <sys/wait.h>
  171. #endif], [union wait w;],
  172.                 [ac_cv_struct_union_wait=yes],
  173.                 [ac_cv_struct_union_wait=no])])
  174. if test $ac_cv_struct_union_wait = yes; then
  175.   AC_DEFINE(HAVE_UNION_WAIT)
  176. fi])
  177.  
  178. dnl Checks if 'struct rusage' is declared in sys/resource.h.
  179. dnl Defines HAVE_STRUCT_RUSAGE on success.
  180. AC_DEFUN(AC_STRUCT_RUSAGE,
  181. [AC_CACHE_CHECK([if struct rusage is declared in sys/resource.h], ac_cv_struct_rusage,
  182.                 [AC_TRY_COMPILE([#include <sys/time.h>
  183. #include <sys/resource.h>], [struct rusage r;],
  184.                 [ac_cv_struct_rusage=yes],
  185.                 [ac_cv_struct_rusage=no])])
  186. if test $ac_cv_struct_rusage = yes; then
  187.   AC_DEFINE(HAVE_STRUCT_RUSAGE)
  188. fi])
  189.  
  190. dnl Checks wether major(), minor() and makedev() are defined in
  191. dnl 'sys/mkdev.h' or in 'sys/sysmacros.h. Defines MAJOR_IN_MKDEV or
  192. dnl MAJOR_IN_SYSMACROS or nothing.
  193. AC_DEFUN(AC_HEADER_MAKEDEV,
  194. [AC_CACHE_CHECK([for header file containing  major(), minor() and makedev()],
  195.                ac_cv_header_makedev,
  196. [ac_cv_header_makedev=none
  197. AC_TRY_COMPILE([#include <sys/types.h>
  198. #include <sys/mkdev.h>],
  199.                [int i = major(0); i = minor(0); i = makedev(0,0);],
  200.                 [ac_cv_header_makedev=sys/mkdev.h])
  201. if test $ac_cv_header_makedev = none; then
  202.   AC_TRY_COMPILE([#include <sys/types.h>
  203. #include <sys/sysmacros.h>],
  204.                  [int i = major(0); i = minor(0); i = makedev(0,0);],
  205.                  [ac_cv_header_makedev=sys/sysmacros.h])
  206. fi])
  207. if test $ac_cv_header_makedev = sys/mkdev.h; then
  208.   AC_DEFINE(MAJOR_IN_MKDEV)
  209. fi
  210. if test $ac_cv_header_makedev = sys/sysmacros.h; then
  211.   AC_DEFINE(MAJOR_IN_SYSMACROS)
  212. fi])
  213.  
  214. dnl Checks for USG derived STDIO that uses _filbuf()
  215. dnl Defines HAVE__FILBUF on success.
  216. AC_DEFUN(AC_HEADER__FILBUF,
  217. [AC_CACHE_CHECK([for _filbuf()], ac_cv_header__filbuf,
  218.                 [AC_TRY_LINK([#include <stdio.h>],
  219. [FILE    *f;
  220. int     flag;
  221. int     count;
  222. char    *ptr;
  223. char    c = 0;
  224. f = fopen("confdefs.h", "r");
  225. _filbuf(f);
  226. _flsbuf(c, f);
  227. flag  = f->_flag & _IONBF;
  228. flag |= f->_flag & _IOERR;
  229. flag |= f->_flag & _IOEOF;
  230. count = f->_cnt;
  231. ptr = (char *)f->_ptr;
  232. fclose(f);],
  233.                 [ac_cv_header__filbuf=yes],
  234.                 [ac_cv_header__filbuf=no])])
  235. if test $ac_cv_header__filbuf = yes; then
  236.   AC_DEFINE(HAVE__FILBUF)
  237. fi])
  238.  
  239. dnl Checks for USG derived STDIO that uses __filbuf()
  240. dnl Defines HAVE___FILBUF on success.
  241. AC_DEFUN(AC_HEADER___FILBUF,
  242. [AC_CACHE_CHECK([for __filbuf()], ac_cv_header___filbuf,
  243.                 [AC_TRY_LINK([#include <stdio.h>],
  244. [FILE    *f;
  245. int     flag;
  246. int     count;
  247. char    *ptr;
  248. char    c = 0;
  249. f = fopen("confdefs.h", "r");
  250. __filbuf(f);
  251. __flsbuf(c, f);
  252. flag  = f->_flag & _IONBF;
  253. flag |= f->_flag & _IOERR;
  254. flag |= f->_flag & _IOEOF;
  255. count = f->_cnt;
  256. ptr = (char *)f->_ptr;
  257. fclose(f);],
  258.                 [ac_cv_header___filbuf=yes],
  259.                 [ac_cv_header___filbuf=no])])
  260. if test $ac_cv_header___filbuf = yes; then
  261.   AC_DEFINE(HAVE___FILBUF)
  262. fi])
  263.  
  264. dnl Checks for USG derived STDIO
  265. dnl Defines HAVE_USG_STDIO on success.
  266. AC_DEFUN(AC_HEADER_USG_STDIO,
  267. [AC_REQUIRE([AC_HEADER__FILBUF])AC_REQUIRE([AC_HEADER___FILBUF])dnl
  268. AC_CACHE_CHECK([for USG derived STDIO], ac_cv_header_usg_stdio,
  269.                 [AC_TRY_LINK([#include <stdio.h>],
  270. [FILE    *f;
  271. int     flag;
  272. int     count;
  273. char    *ptr;
  274. char    c = 0;
  275. f = fopen("confdefs.h", "r");
  276. #ifdef    HAVE___FILBUF
  277. __filbuf(f);
  278. __flsbuf(c, f);
  279. #else
  280. #    ifdef    HAVE__FILBUF
  281. _filbuf(f);
  282. _flsbuf(c, f);
  283. #    else
  284. no filbuf()
  285. #    endif
  286. #endif
  287. flag  = f->_flag & _IONBF;
  288. flag |= f->_flag & _IOERR;
  289. flag |= f->_flag & _IOEOF;
  290. count = f->_cnt;
  291. ptr = (char *)f->_ptr;
  292. fclose(f);],
  293.                 [ac_cv_header_usg_stdio=yes],
  294.                 [ac_cv_header_usg_stdio=no])])
  295. if test $ac_cv_header_usg_stdio = yes; then
  296.   AC_DEFINE(HAVE_USG_STDIO)
  297. fi])
  298.  
  299. dnl Checks for errno definition in <errno.h>
  300. dnl Defines HAVE_ERRNO_DEF on success.
  301. AC_DEFUN(AC_HEADER_ERRNO_DEF,
  302. [AC_CACHE_CHECK([for errno definition in errno.h], ac_cv_header_errno_def,
  303.                 [AC_TRY_COMPILE([#include <errno.h>],
  304. [errno = 0;],
  305.                 [ac_cv_header_errno_def=yes],
  306.                 [ac_cv_header_errno_def=no])])
  307. if test $ac_cv_header_errno_def = yes; then
  308.   AC_DEFINE(HAVE_ERRNO_DEF)
  309. fi])
  310.  
  311. dnl Checks for UNIX-98 compliant <inttypes.h>
  312. dnl Defines HAVE_INTTYPES_H on success.
  313. AC_DEFUN(AC_HEADER_INTTYPES,
  314. [AC_CACHE_CHECK([for UNIX-98 compliant inttypes.h], ac_cv_header_inttypes,
  315.                 [AC_TRY_COMPILE([#include <inttypes.h>],
  316. [int8_t c; uint8_t uc; int16_t s; uint16_t us; int32_t i; uint32_t ui;
  317. int64_t ll; uint64_t ull;
  318. intptr_t ip; uintptr_t uip;],
  319.                 [ac_cv_header_inttypes=yes],
  320.                 [ac_cv_header_inttypes=no])])
  321. if test $ac_cv_header_inttypes = yes; then
  322.   AC_DEFINE(HAVE_INTTYPES_H)
  323. fi])
  324.  
  325. dnl Checks for type time_t
  326. dnl Defines time_t to long on failure.
  327. AC_DEFUN(AC_TYPE_TIME_T,
  328. [AC_REQUIRE([AC_HEADER_TIME])dnl
  329. AC_CACHE_CHECK([for time_t], ac_cv_type_time_t,
  330.                 [AC_TRY_COMPILE([
  331. #include <sys/types.h>
  332. #ifdef    TIME_WITH_SYS_TIME_H
  333. #    include <sys/time.h>
  334. #    include <time.h>
  335. #else
  336. #ifdef    HAVE_SYS_TIME_H
  337. #    include <sys/time.h>
  338. #else
  339. #    include <time.h>
  340. #endif
  341. #endif], [time_t t;],
  342.                 [ac_cv_type_time_t=yes],
  343.                 [ac_cv_type_time_t=no])])
  344. if test $ac_cv_type_time_t = no; then
  345.   AC_DEFINE(time_t, long)
  346. fi])
  347.  
  348. dnl Checks for type socklen_t
  349. dnl Defines socklen_t to int on failure.
  350. AC_DEFUN(AC_TYPE_SOCKLEN_T,
  351. [AC_REQUIRE([AC_HEADER_STDC])dnl
  352. AC_MSG_CHECKING(for socklen_t)
  353. AC_CACHE_VAL(ac_cv_type_socklen_t,
  354. [AC_EGREP_CPP(dnl
  355. changequote(<<,>>)dnl
  356. <<(^|[^a-zA-Z_0-9])socklen_t[^a-zA-Z_0-9]>>dnl
  357. changequote([,]), [#include <sys/types.h>
  358. #if STDC_HEADERS
  359. #include <stdlib.h>
  360. #include <stddef.h>
  361. #endif
  362. #include <sys/socket.h>], ac_cv_type_socklen_t=yes, ac_cv_type_socklen_t=no)])dnl
  363. AC_MSG_RESULT($ac_cv_type_socklen_t)
  364. if test $ac_cv_type_socklen_t = no; then
  365.   AC_DEFINE(socklen_t, int)
  366. fi])
  367.  
  368. dnl Checks for type long long
  369. dnl Defines HAVE_LONGLONG on success.
  370. AC_DEFUN(AC_TYPE_LONGLONG,
  371. [AC_CACHE_CHECK([for type long long], ac_cv_type_longlong,
  372.                 [AC_TRY_COMPILE([], [long long i;],
  373.                 [ac_cv_type_longlong=yes],
  374.                 [ac_cv_type_longlong=no])])
  375. if test $ac_cv_type_longlong = yes; then
  376.   AC_DEFINE(HAVE_LONGLONG)
  377. fi])
  378.  
  379. dnl Checks if C-compiler orders bitfields htol
  380. dnl Defines BITFIELDS_HTOL on success.
  381. AC_DEFUN(AC_C_BITFIELDS,
  382. [AC_CACHE_CHECK([whether bitorder in bitfields is htol], ac_cv_c_bitfields_htol,
  383.                 [AC_TRY_RUN([
  384. struct {
  385.     unsigned char    x1:4;
  386.     unsigned char    x2:4;
  387. } a;
  388. int
  389. main()
  390. {
  391. char    *cp;
  392.  
  393. cp = (char *)&a;
  394. *cp = 0x12;
  395. exit(a.x1 == 2);}],
  396.                 [ac_cv_c_bitfields_htol=yes],
  397.                 [ac_cv_c_bitfields_htol=no])])
  398. if test $ac_cv_c_bitfields_htol = yes; then
  399.   AC_DEFINE(BITFIELDS_HTOL)
  400. fi])
  401.  
  402. dnl Checks if C-compiler understands prototypes
  403. dnl Defines PROTOTYPES on success.
  404. AC_DEFUN(AC_TYPE_PROTOTYPES,
  405. [AC_CACHE_CHECK([for prototypes], ac_cv_type_prototypes,
  406.                 [AC_TRY_RUN([
  407. doit(int i, ...)
  408. {return 0;}
  409. int
  410. main(int ac, char *av[])
  411. { doit(1, 2, 3);
  412. exit(0);}],
  413.                 [ac_cv_type_prototypes=yes],
  414.                 [ac_cv_type_prototypes=no])])
  415. if test $ac_cv_type_prototypes = yes; then
  416.   AC_DEFINE(PROTOTYPES)
  417. fi])
  418.  
  419. dnl Checks for type size_t
  420. dnl Defines HAVE_SIZE_T_ on success.
  421. AC_DEFUN(AC_TYPE_SIZE_T_,
  422. [AC_CACHE_CHECK([for type size_t], ac_cv_type_size_t_,
  423.                 [AC_TRY_COMPILE([#include <sys/types.h>], [size_t s;],
  424.                 [ac_cv_type_size_t_=yes],
  425.                 [ac_cv_type_size_t_=no])])
  426. if test $ac_cv_type_size_t_ = yes; then
  427.   AC_DEFINE(HAVE_SIZE_T)
  428. else
  429.   AC_DEFINE(NO_SIZE_T)
  430. fi])
  431.  
  432. dnl Checks if type char is unsigned
  433. dnl Defines CHAR_IS_UNSIGNED on success.
  434. AC_DEFUN(AC_TYPE_CHAR,
  435. [AC_CACHE_CHECK([if char is unsigned], ac_cv_type_char_unsigned,
  436.                 [AC_TRY_RUN([
  437. int
  438. main()
  439. {
  440.     char c;
  441.  
  442.     c = -1;
  443.     exit(c < 0);}],
  444.         [ac_cv_type_char_unsigned=yes],
  445.         [ac_cv_type_char_unsigned=no],
  446.         [ac_cv_type_char_unsigned=no])]) 
  447. if test $ac_cv_type_char_unsigned = yes; then
  448.   AC_DEFINE(CHAR_IS_UNSIGNED)
  449. fi])
  450.  
  451. dnl Checks if function/macro va_copy() is available
  452. dnl Defines HAVE_VA_COPY on success.
  453. AC_DEFUN(AC_FUNC_VA_COPY,
  454. [AC_CACHE_CHECK([for va_copy], ac_cv_func_va_copy,
  455.                 [AC_TRY_LINK([
  456. #ifdef    HAVE_STDARG_H
  457. #    include <stdarg.h>
  458. #else
  459. #    include <varargs.h>
  460. #endif], 
  461.         [
  462. va_list a, b;
  463.  
  464. va_copy(a, b);],
  465.                 [ac_cv_func_va_copy=yes],
  466.                 [ac_cv_func_va_copy=no])])
  467. if test $ac_cv_func_va_copy = yes; then
  468.   AC_DEFINE(HAVE_VA_COPY)
  469. fi])
  470.  
  471. dnl Checks if function/macro __va_copy() is available
  472. dnl Defines HAVE__VA_COPY on success.
  473. AC_DEFUN(AC_FUNC__VA_COPY,
  474. [AC_CACHE_CHECK([for __va_copy], ac_cv_func__va_copy,
  475.                 [AC_TRY_LINK([
  476. #ifdef    HAVE_STDARG_H
  477. #    include <stdarg.h>
  478. #else
  479. #    include <varargs.h>
  480. #endif], 
  481.         [
  482. va_list a, b;
  483.  
  484. __va_copy(a, b);],
  485.  
  486.                 [ac_cv_func__va_copy=yes],
  487.                 [ac_cv_func__va_copy=no])])
  488. if test $ac_cv_func__va_copy = yes; then
  489.   AC_DEFINE(HAVE__VA_COPY)
  490. fi])
  491.  
  492. dnl Checks if va_list is an array
  493. dnl Defines VA_LIST_IS_ARRAY on success.
  494. AC_DEFUN(AC_TYPE_VA_LIST,
  495. [AC_CACHE_CHECK([if va_list is an array], ac_cv_type_va_list_array,
  496.                 [AC_TRY_LINK([
  497. #ifdef    HAVE_STDARG_H
  498. #    include <stdarg.h>
  499. #else
  500. #    include <varargs.h>
  501. #endif
  502. ],
  503.     [
  504. va_list a, b;
  505.  
  506. a = b;],
  507.         [ac_cv_type_va_list_array=no],
  508.         [ac_cv_type_va_list_array=yes])]) 
  509. if test $ac_cv_type_va_list_array = yes; then
  510.   AC_DEFINE(VA_LIST_IS_ARRAY)
  511. fi])
  512.  
  513. dnl Checks if quotactl is present as ioctl
  514. dnl Defines HAVE_QUOTAIOCTL on success.
  515. AC_DEFUN(AC_FUNC_QUOTAIOCTL,
  516. [AC_CACHE_CHECK([if quotactl is an ioctl], ac_cv_func_quotaioctl,
  517.                 [AC_TRY_LINK([#include <sys/types.h>
  518. #include <sys/fs/ufs_quota.h>],
  519.         [struct quotctl q; ioctl(0, Q_QUOTACTL, &q)],
  520.         [ac_cv_func_quotaioctl=yes],
  521.         [ac_cv_func_quotaioctl=no])]) 
  522. if test $ac_cv_func_quotaioctl = yes; then
  523.   AC_DEFINE(HAVE_QUOTAIOCTL)
  524. fi])
  525.  
  526. dnl Checks if function __dtoa() is available
  527. dnl Defines HAVE_DTOA on success.
  528. AC_DEFUN(AC_FUNC_DTOA,
  529. [AC_CACHE_CHECK([for __dtoa], ac_cv_func_dtoa,
  530.                 [AC_TRY_LINK([extern  char *__dtoa();], 
  531. [int decpt; int sign; char *ep; char *bp;
  532. bp = __dtoa(0.0, 2, 6, &decpt, &sign, &ep);],
  533.                 [ac_cv_func_dtoa=yes],
  534.                 [ac_cv_func_dtoa=no])])
  535. if test $ac_cv_func_dtoa = yes; then
  536.   AC_DEFINE(HAVE_DTOA)
  537. fi])
  538.  
  539. dnl Checks if reentrant __dtoa() exists (needs a result prt)
  540. dnl Defines HAVE_DTOA_R on success.
  541. AC_DEFUN(AC_FUNC_DTOA_R,
  542. [AC_REQUIRE([AC_FUNC_DTOA])dnl
  543. AC_CACHE_CHECK([for __dtoa that needs result ptr], ac_cv_func_dtoa_r,
  544.                 [AC_TRY_RUN([
  545. extern    char *__dtoa();
  546. int
  547. main()
  548. {
  549. #ifdef    HAVE_DTOA
  550.     int    decpt, sign;
  551.     char    *bp;
  552.     char    *ep;
  553.     char    *result;
  554.  
  555.     result = 0;
  556.     bp = __dtoa(1.9, 2, 5, &decpt, &sign, &ep, &result);
  557.     exit(result == 0);
  558. #else
  559.     exit(1);
  560. #endif
  561. }],
  562.                 [ac_cv_func_dtoa_r=yes],
  563.                 [ac_cv_func_dtoa_r=no])])
  564. if test $ac_cv_func_dtoa_r = yes; then
  565.   AC_DEFINE(HAVE_DTOA_R)
  566. fi])
  567.  
  568. dnl Checks if working ecvt() exists
  569. dnl Defines HAVE_ECVT on success.
  570. AC_DEFUN(AC_FUNC_ECVT,
  571. [AC_CACHE_CHECK([for working ecvt() ], ac_cv_func_ecvt,
  572.                 [AC_TRY_RUN([
  573. extern    char *ecvt();
  574.  
  575. sprintf(s)
  576.     char    *s;
  577. {
  578.     strcpy(s, "DEAD");
  579. }
  580.  
  581. int
  582. main()
  583. {
  584.     int a, b;
  585.  
  586. /*    exit (strcmp("DEAD", ecvt(1.9, 2, &a, &b)) == 0);*/
  587.     exit (strcmp("19", ecvt(1.9, 2, &a, &b)) != 0);
  588. }],
  589.                 [ac_cv_func_ecvt=yes],
  590.                 [ac_cv_func_ecvt=no])])
  591. if test $ac_cv_func_ecvt = yes; then
  592.   AC_DEFINE(HAVE_ECVT)
  593. fi])
  594.  
  595. dnl Checks if working fcvt() exists
  596. dnl Defines HAVE_FCVT on success.
  597. AC_DEFUN(AC_FUNC_FCVT,
  598. [AC_CACHE_CHECK([for working fcvt() ], ac_cv_func_fcvt,
  599.                 [AC_TRY_RUN([
  600. extern    char *fcvt();
  601.  
  602. sprintf(s)
  603.     char    *s;
  604. {
  605.     strcpy(s, "DEAD");
  606. }
  607.  
  608. int
  609. main()
  610. {
  611.     int a, b;
  612.  
  613. /*    exit (strcmp("DEAD", fcvt(1.9, 2, &a, &b)) == 0);*/
  614.     exit (strcmp("190", fcvt(1.9, 2, &a, &b)) != 0);
  615. }],
  616.                 [ac_cv_func_fcvt=yes],
  617.                 [ac_cv_func_fcvt=no])])
  618. if test $ac_cv_func_fcvt = yes; then
  619.   AC_DEFINE(HAVE_FCVT)
  620. fi])
  621.  
  622. dnl Checks if working gcvt() exists
  623. dnl Defines HAVE_GCVT on success.
  624. AC_DEFUN(AC_FUNC_GCVT,
  625. [AC_CACHE_CHECK([for working gcvt() ], ac_cv_func_gcvt,
  626.                 [AC_TRY_RUN([
  627. extern    char *gcvt();
  628.  
  629. sprintf(s)
  630.     char    *s;
  631. {
  632.     strcpy(s, "DEAD");
  633. }
  634.  
  635. int
  636. main()
  637. {
  638.     char    buf[32];
  639.  
  640. /*    exit (strcmp("DEAD", gcvt(1.9, 10, buf)) == 0);*/
  641.     exit (strcmp("1.9", gcvt(1.9, 10, buf)) != 0);
  642. }],
  643.                 [ac_cv_func_gcvt=yes],
  644.                 [ac_cv_func_gcvt=no])])
  645. if test $ac_cv_func_gcvt = yes; then
  646.   AC_DEFINE(HAVE_GCVT)
  647. fi])
  648.  
  649. dnl Checks if function uname() is available
  650. dnl Defines HAVE_UNAME on success.
  651. AC_DEFUN(AC_FUNC_UNAME,
  652. [AC_CACHE_CHECK([for uname], ac_cv_func_uname,
  653.                 [AC_TRY_LINK([#include <sys/utsname.h>], 
  654. [struct    utsname un;
  655. uname(&un);],
  656.                 [ac_cv_func_uname=yes],
  657.                 [ac_cv_func_uname=no])])
  658. if test $ac_cv_func_uname = yes; then
  659.   AC_DEFINE(HAVE_UNAME)
  660. fi])
  661.  
  662. dnl Checks if function mlockall() is available
  663. dnl beware HP-UX 10.x it contains a bad mlockall() in libc
  664. dnl Defines HAVE_MLOCKALL on success.
  665. AC_DEFUN(AC_FUNC_MLOCKALL,
  666. [AC_CACHE_CHECK([for mlockall], ac_cv_func_mlockall,
  667.                 [AC_TRY_RUN([
  668. #include <sys/types.h>
  669. #include <sys/mman.h>
  670. #include <errno.h>
  671.  
  672. int
  673. main()
  674. {
  675.     if (mlockall(MCL_CURRENT|MCL_FUTURE) < 0) {
  676.         if (errno == EPERM || errno ==  EACCES)
  677.             exit(0);
  678.         exit(-1);
  679.     }
  680.     exit(0);
  681. }
  682. ],
  683.                 [ac_cv_func_mlockall=yes],
  684.                 [ac_cv_func_mlockall=no])])
  685. if test $ac_cv_func_mlockall = yes; then
  686.   AC_DEFINE(HAVE_MLOCKALL)
  687. fi])
  688.  
  689. AC_DEFUN(jsAC_FUNC_MMAP,
  690. [AC_REQUIRE([AC_MMAP_SIZEP])dnl
  691. AC_CHECK_HEADERS(unistd.h)
  692. AC_CHECK_FUNCS(getpagesize)
  693. AC_CACHE_CHECK(for working mmap, ac_cv_func_mmap_fixed_mapped,
  694. [AC_TRY_RUN([
  695. /* Thanks to Mike Haertel and Jim Avera for this test.
  696.    Here is a matrix of mmap possibilities:
  697.     mmap private not fixed
  698.     mmap private fixed at somewhere currently unmapped
  699.     mmap private fixed at somewhere already mapped
  700.     mmap shared not fixed
  701.     mmap shared fixed at somewhere currently unmapped
  702.     mmap shared fixed at somewhere already mapped
  703.    For private mappings, we should verify that changes cannot be read()
  704.    back from the file, nor mmap's back from the file at a different
  705.    address.  (There have been systems where private was not correctly
  706.    implemented like the infamous i386 svr4.0, and systems where the
  707.    VM page cache was not coherent with the filesystem buffer cache
  708.    like early versions of FreeBSD and possibly contemporary NetBSD.)
  709.    For shared mappings, we should conversely verify that changes get
  710.    propogated back to all the places they're supposed to be.
  711.  
  712.    Grep wants private fixed already mapped.
  713.    The main things grep needs to know about mmap are:
  714.    * does it exist and is it safe to write into the mmap'd area
  715.    * how to use it (BSD variants)  */
  716. #include <sys/types.h>
  717. #include <fcntl.h>
  718. #include <sys/mman.h>
  719.  
  720. /*
  721.  * Needed for Apollo Domain/OS and may be for others?
  722.  */
  723. #ifdef    _MMAP_WITH_SIZEP
  724. #    define    mmap_sizeparm(s)    (&(s))
  725. #else
  726. #    define    mmap_sizeparm(s)    (s)
  727. #endif
  728.  
  729. /* This mess was copied from the GNU getpagesize.h.  */
  730. #ifndef HAVE_GETPAGESIZE
  731. # ifdef HAVE_UNISTD_H
  732. #  include <unistd.h>
  733. # endif
  734.  
  735. /* Assume that all systems that can run configure have sys/param.h.  */
  736. # ifndef HAVE_SYS_PARAM_H
  737. #  define HAVE_SYS_PARAM_H 1
  738. # endif
  739.  
  740. # ifdef _SC_PAGESIZE
  741. #  define getpagesize() sysconf(_SC_PAGESIZE)
  742. # else /* no _SC_PAGESIZE */
  743. #  ifdef HAVE_SYS_PARAM_H
  744. #   include <sys/param.h>
  745. #   ifdef EXEC_PAGESIZE
  746. #    define getpagesize() EXEC_PAGESIZE
  747. #   else /* no EXEC_PAGESIZE */
  748. #    ifdef NBPG
  749. #     define getpagesize() NBPG * CLSIZE
  750. #     ifndef CLSIZE
  751. #      define CLSIZE 1
  752. #     endif /* no CLSIZE */
  753. #    else /* no NBPG */
  754. #     ifdef NBPC
  755. #      define getpagesize() NBPC
  756. #     else /* no NBPC */
  757. #      ifdef PAGESIZE
  758. #       define getpagesize() PAGESIZE
  759. #      endif /* PAGESIZE */
  760. #     endif /* no NBPC */
  761. #    endif /* no NBPG */
  762. #   endif /* no EXEC_PAGESIZE */
  763. #  else /* no HAVE_SYS_PARAM_H */
  764. #   define getpagesize() 8192    /* punt totally */
  765. #  endif /* no HAVE_SYS_PARAM_H */
  766. # endif /* no _SC_PAGESIZE */
  767.  
  768. #endif /* no HAVE_GETPAGESIZE */
  769.  
  770. #ifdef __cplusplus
  771. extern "C" { void *malloc(unsigned); }
  772. #else
  773. char *malloc();
  774. #endif
  775.  
  776. int
  777. main()
  778. {
  779.     char *data, *data2, *data3;
  780.     int i, pagesize;
  781.     int fd;
  782.  
  783.     pagesize = getpagesize();
  784.  
  785.     /*
  786.      * First, make a file with some known garbage in it.
  787.      */
  788.     data = malloc(pagesize);
  789.     if (!data)
  790.         exit(1);
  791.     for (i = 0; i < pagesize; ++i)
  792.         *(data + i) = rand();
  793.     umask(0);
  794.     fd = creat("conftestmmap", 0600);
  795.     if (fd < 0)
  796.         exit(1);
  797.     if (write(fd, data, pagesize) != pagesize)
  798.         exit(1);
  799.     close(fd);
  800.  
  801.     /*
  802.      * Next, try to mmap the file at a fixed address which
  803.      * already has something else allocated at it.  If we can,
  804.      * also make sure that we see the same garbage.
  805.      */
  806.     fd = open("conftestmmap", O_RDWR);
  807.     if (fd < 0)
  808.         exit(1);
  809.     data2 = malloc(2 * pagesize);
  810.     if (!data2)
  811.         exit(1);
  812.     data2 += (pagesize - ((int) data2 & (pagesize - 1))) & (pagesize - 1);
  813.     if (data2 != mmap(data2, mmap_sizeparm(pagesize), PROT_READ | PROT_WRITE,
  814.         MAP_PRIVATE | MAP_FIXED, fd, 0L))
  815.         exit(1);
  816.     for (i = 0; i < pagesize; ++i)
  817.         if (*(data + i) != *(data2 + i))
  818.             exit(1);
  819.  
  820.     /*
  821.      * Finally, make sure that changes to the mapped area
  822.      * do not percolate back to the file as seen by read().
  823.      * (This is a bug on some variants of i386 svr4.0.)
  824.      */
  825.     for (i = 0; i < pagesize; ++i)
  826.         *(data2 + i) = *(data2 + i) + 1;
  827.     data3 = malloc(pagesize);
  828.     if (!data3)
  829.         exit(1);
  830.     if (read(fd, data3, pagesize) != pagesize)
  831.         exit(1);
  832.     for (i = 0; i < pagesize; ++i)
  833.         if (*(data + i) != *(data3 + i))
  834.             exit(1);
  835.     close(fd);
  836.     unlink("conftestmmap");
  837.     exit(0);
  838. }
  839. ], ac_cv_func_mmap_fixed_mapped=yes, ac_cv_func_mmap_fixed_mapped=no,
  840. ac_cv_func_mmap_fixed_mapped=no)])
  841. if test $ac_cv_func_mmap_fixed_mapped = yes; then
  842.   AC_DEFINE(HAVE_MMAP)
  843. fi
  844. ])
  845.  
  846. AC_DEFUN(AC_MMAP_SIZEP,
  847. [AC_CHECK_HEADERS(unistd.h)
  848. AC_CHECK_FUNCS(getpagesize)
  849. AC_CACHE_CHECK(for mmap that needs ptr to size, ac_cv_func_mmap_sizep,
  850. [AC_TRY_RUN([
  851. #include <sys/types.h>
  852. #include <fcntl.h>
  853. #include <signal.h>
  854. #include <setjmp.h>
  855. #include <sys/mman.h>
  856.  
  857. #ifndef MAP_FILE
  858. #define MAP_FILE   0        /* Needed on Apollo Domain/OS */
  859. #endif
  860.  
  861. /* This mess was copied from the GNU getpagesize.h.  */
  862. #ifndef HAVE_GETPAGESIZE
  863. # ifdef HAVE_UNISTD_H
  864. #  include <unistd.h>
  865. # endif
  866.  
  867. /* Assume that all systems that can run configure have sys/param.h.  */
  868. # ifndef HAVE_SYS_PARAM_H
  869. #  define HAVE_SYS_PARAM_H 1
  870. # endif
  871.  
  872. # ifdef _SC_PAGESIZE
  873. #  define getpagesize() sysconf(_SC_PAGESIZE)
  874. # else /* no _SC_PAGESIZE */
  875. #  ifdef HAVE_SYS_PARAM_H
  876. #   include <sys/param.h>
  877. #   ifdef EXEC_PAGESIZE
  878. #    define getpagesize() EXEC_PAGESIZE
  879. #   else /* no EXEC_PAGESIZE */
  880. #    ifdef NBPG
  881. #     define getpagesize() NBPG * CLSIZE
  882. #     ifndef CLSIZE
  883. #      define CLSIZE 1
  884. #     endif /* no CLSIZE */
  885. #    else /* no NBPG */
  886. #     ifdef NBPC
  887. #      define getpagesize() NBPC
  888. #     else /* no NBPC */
  889. #      ifdef PAGESIZE
  890. #       define getpagesize() PAGESIZE
  891. #      endif /* PAGESIZE */
  892. #     endif /* no NBPC */
  893. #    endif /* no NBPG */
  894. #   endif /* no EXEC_PAGESIZE */
  895. #  else /* no HAVE_SYS_PARAM_H */
  896. #   define getpagesize() 8192    /* punt totally */
  897. #  endif /* no HAVE_SYS_PARAM_H */
  898. # endif /* no _SC_PAGESIZE */
  899.  
  900. #endif /* no HAVE_GETPAGESIZE */
  901.  
  902. #ifdef __cplusplus
  903. extern "C" { void *malloc(unsigned); }
  904. #else
  905. char *malloc();
  906. #endif
  907.  
  908. jmp_buf jenv;
  909.  
  910. int
  911. intr()
  912. {
  913.     signal(SIGSEGV, intr);
  914.     longjmp(jenv, 1);
  915. }
  916.  
  917. int
  918. main()
  919. {
  920.     char *data, *data2;
  921.     int i, pagesize, ps;
  922.     int fd;
  923.  
  924.     pagesize = getpagesize();
  925.  
  926.     /*
  927.      * First, make a file with some known garbage in it.
  928.      */
  929.     data = malloc(pagesize);
  930.     if (!data)
  931.         exit(1);
  932.     for (i = 0; i < pagesize; ++i)
  933.         *(data + i) = rand();
  934.     umask(0);
  935.     fd = creat("conftestmmap", 0600);
  936.     if (fd < 0)
  937.         exit(1);
  938.     if (write(fd, data, pagesize) != pagesize)
  939.         exit(1);
  940.     close(fd);
  941.  
  942.     /*
  943.      * Next, try to mmap the file at a fixed address which
  944.      * already has something else allocated at it.  If we can,
  945.      * also make sure that we see the same garbage.
  946.      */
  947.     fd = open("conftestmmap", O_RDWR);
  948.     if (fd < 0)
  949.         exit(1);
  950.  
  951.     /*
  952.      * Keep a copy, Apollo modifies the value...
  953.      */
  954.     ps = pagesize;
  955.  
  956.     /*
  957.      * Apollo mmap() is not a syscall but a library function and fails
  958.      * if it tries to dereference 'ps'. We must use setjmp in order to
  959.      * catch the failure.
  960.      */
  961.     signal(SIGSEGV, intr);
  962.     if (setjmp(jenv) == 0) {
  963.         data2 = mmap(0, ps, PROT_READ, MAP_FILE | MAP_PRIVATE, fd, 0L);
  964.     } else {
  965.         data2 = (char *)-1;
  966.     }
  967.     if (data2 != (char *)-1)
  968.         exit(1);
  969.  
  970.     signal(SIGSEGV, intr);
  971.     if (setjmp(jenv) == 0) {
  972.         data2 = mmap(0, &ps, PROT_READ, MAP_FILE | MAP_PRIVATE, fd, 0L);
  973.     } else {
  974.         data2 = (char *)-1;
  975.     }
  976.     if (data2 == (char *)-1)
  977.         exit(1);
  978.  
  979.     for (i = 0; i < pagesize; ++i)
  980.         if (*(data + i) != *(data2 + i))
  981.             exit(1);
  982.  
  983.     close(fd);
  984.     unlink("conftestmmap");
  985.     exit(0);
  986. }
  987. ], ac_cv_func_mmap_sizep=yes, ac_cv_func_mmap_sizep=no,
  988. ac_cv_func_mmap_sizep=no)])
  989. if test $ac_cv_func_mmap_sizep = yes; then
  990.   AC_DEFINE(_MMAP_WITH_SIZEP)
  991. fi
  992. ])
  993.  
  994. dnl Checks if mmap() works to get shared memory
  995. dnl Defines HAVE_SMMAP on success.
  996. AC_DEFUN(AC_FUNC_SMMAP,
  997. [AC_CACHE_CHECK([if mmap works to get shared memory], ac_cv_func_smmap,
  998.                 [AC_TRY_RUN([
  999. #include <sys/types.h>
  1000. #include <sys/mman.h>
  1001.  
  1002. #ifndef    MAP_ANONYMOUS
  1003. #    ifdef    MAP_ANON
  1004. #        define MAP_ANONYMOUS MAP_ANON
  1005. #    endif
  1006. #endif
  1007.  
  1008. /*
  1009.  * Needed for Apollo Domain/OS and may be for others?
  1010.  */
  1011. #ifdef    _MMAP_WITH_SIZEP
  1012. #    define    mmap_sizeparm(s)    (&(s))
  1013. #else
  1014. #    define    mmap_sizeparm(s)    (s)
  1015. #endif
  1016.  
  1017. char *
  1018. mkshare()
  1019. {
  1020.         int     size = 8192;
  1021.         int     f;
  1022.         char    *addr;
  1023.  
  1024. #ifdef  MAP_ANONYMOUS   /* HP/UX */
  1025.         f = -1;
  1026.         addr = mmap(0, mmap_sizeparm(size), PROT_READ|PROT_WRITE, MAP_SHARED|MAP_ANONYMOUS, f, 0);
  1027. #else
  1028.         if ((f = open("/dev/zero", 2)) < 0)
  1029.                 exit(1);
  1030.         addr = mmap(0, mmap_sizeparm(size), PROT_READ|PROT_WRITE, MAP_SHARED, f, 0);
  1031. #endif
  1032.         if (addr == (char *)-1)
  1033.                 exit(1);
  1034.         close(f);
  1035.  
  1036.         return (addr);
  1037. }
  1038.  
  1039. int
  1040. main()
  1041. {
  1042.         char    *addr;
  1043.         
  1044.         addr = mkshare();
  1045.         *addr = 'I';
  1046.  
  1047.         switch (fork()) {
  1048.  
  1049.         case -1:
  1050.                 printf("help\n"); exit(1);
  1051.  
  1052.         case 0: /* child */
  1053.                 *addr = 'N';
  1054.                 _exit(0);
  1055.                 break;
  1056.         default: /* parent */
  1057.                 wait(0);
  1058.                 sleep(1);
  1059.                 break;
  1060.         }
  1061.  
  1062.         if (*addr != 'N')
  1063.                 exit(1);
  1064.         exit(0);
  1065. }
  1066. ], 
  1067.                 [ac_cv_func_smmap=yes],
  1068.                 [ac_cv_func_smmap=no],
  1069.                 [ac_cv_func_smmap=no])])
  1070. if test $ac_cv_func_smmap = yes; then
  1071.   AC_DEFINE(HAVE_SMMAP)
  1072. fi])
  1073.  
  1074. dnl Checks if sys_siglist[] exists
  1075. dnl Defines HAVE_SYS_SIGLIST on success.
  1076. AC_DEFUN(AC_FUNC_SYS_SIGLIST,
  1077. [AC_CACHE_CHECK([for sys_siglist], ac_cv_func_sys_siglist,
  1078.                 [AC_TRY_RUN([
  1079. int
  1080. main()
  1081. { extern char *sys_siglist[];
  1082. if (sys_siglist[1] == 0)
  1083.     exit(1);
  1084. exit(0);}],
  1085.                 [ac_cv_func_sys_siglist=yes],
  1086.                 [ac_cv_func_sys_siglist=no])])
  1087. if test $ac_cv_func_sys_siglist = yes; then
  1088.   AC_DEFINE(HAVE_SYS_SIGLIST)
  1089. fi])
  1090.  
  1091. dnl Checks for maximum number of bits in minor device number
  1092. AC_DEFUN(AC_CHECK_MINOR_BITS,
  1093. [AC_REQUIRE([AC_HEADER_MAKEDEV])dnl
  1094. changequote(<<, >>)dnl
  1095. define(<<AC_MACRO_NAME>>, DEV_MINOR_BITS)dnl
  1096. dnl The cache variable name.
  1097. define(<<AC_CV_NAME>>, ac_cv_dev_minor_bits)dnl
  1098. changequote([, ])dnl
  1099. AC_MSG_CHECKING(bits in minor device number)
  1100. AC_CACHE_VAL(AC_CV_NAME,
  1101. [AC_TRY_RUN([#include <stdio.h>
  1102. #include <sys/types.h>
  1103. #ifdef major
  1104. #    define _FOUND_MAJOR_
  1105. #endif
  1106.  
  1107. #ifdef MAJOR_IN_MKDEV
  1108. #    include <sys/mkdev.h>
  1109. #    define _FOUND_MAJOR_
  1110. #endif
  1111.  
  1112. #ifndef _FOUND_MAJOR_
  1113. #    ifdef MAJOR_IN_SYSMACROS
  1114. #        include <sys/sysmacros.h>
  1115. #        define _FOUND_MAJOR_
  1116. #    endif
  1117. #endif
  1118.  
  1119. #ifndef _FOUND_MAJOR_
  1120. #    if defined(hpux) || defined(__hpux__) || defined(__hpux)
  1121. #        include <sys/mknod.h>
  1122. #        define _FOUND_MAJOR_
  1123. #    endif
  1124. #endif
  1125.  
  1126. #ifndef _FOUND_MAJOR_
  1127. #    define major(dev)        (((dev) >> 8) & 0xFF)
  1128. #    define minor(dev)        ((dev) & 0xFF)
  1129. #    define makedev(majo, mino)    (((majo) << 8) | (mino))
  1130. #endif
  1131. int
  1132. main()
  1133. {
  1134.     long    l = 1;
  1135.     int    i;
  1136.     int    m;
  1137.     int    c = 0;
  1138.     FILE    *f=fopen("conftestval", "w");
  1139.  
  1140.     if (!f) exit(1);
  1141.  
  1142.     for (i=1, m=0; i <= 32; i++, l<<=1) {
  1143.         if (minor(l) == 0 && c == 0)
  1144.             c = m;
  1145.         if (minor(l) != 0)
  1146.             m = i;
  1147.     }
  1148.     fprintf(f, "%d\n", m);
  1149.     exit(0);
  1150. }], AC_CV_NAME=`cat conftestval`, AC_CV_NAME=0, ifelse([$2], , , AC_CV_NAME=$2))])dnl
  1151. AC_MSG_RESULT($AC_CV_NAME)
  1152. AC_DEFINE_UNQUOTED(AC_MACRO_NAME, $AC_CV_NAME)
  1153. undefine([AC_MACRO_NAME])dnl
  1154. undefine([AC_CV_NAME])dnl
  1155. ])
  1156.  
  1157. dnl Checks for maximum number of bits in minor device numbers are non contiguous
  1158. dnl Defines DEV_MINOR_NONCONTIG on success.
  1159. AC_DEFUN(AC_CHECK_MINOR_NONCONTIG,
  1160. [AC_REQUIRE([AC_HEADER_MAKEDEV])dnl
  1161. AC_CACHE_CHECK([whether bits in minor device numbers are non contiguous], ac_cv_dev_minor_noncontig,
  1162.                 [AC_TRY_RUN([
  1163. #include <sys/types.h>
  1164. #ifdef major
  1165. #    define _FOUND_MAJOR_
  1166. #endif
  1167.  
  1168. #ifdef MAJOR_IN_MKDEV
  1169. #    include <sys/mkdev.h>
  1170. #    define _FOUND_MAJOR_
  1171. #endif
  1172.  
  1173. #ifndef _FOUND_MAJOR_
  1174. #    ifdef MAJOR_IN_SYSMACROS
  1175. #        include <sys/sysmacros.h>
  1176. #        define _FOUND_MAJOR_
  1177. #    endif
  1178. #endif
  1179.  
  1180. #ifndef _FOUND_MAJOR_
  1181. #    if defined(hpux) || defined(__hpux__) || defined(__hpux)
  1182. #        include <sys/mknod.h>
  1183. #        define _FOUND_MAJOR_
  1184. #    endif
  1185. #endif
  1186.  
  1187. #ifndef _FOUND_MAJOR_
  1188. #    define major(dev)        (((dev) >> 8) & 0xFF)
  1189. #    define minor(dev)        ((dev) & 0xFF)
  1190. #    define makedev(majo, mino)    (((majo) << 8) | (mino))
  1191. #endif
  1192. int
  1193. main()
  1194. {
  1195.     long    l = 1;
  1196.     int    i;
  1197.     int    m;
  1198.     int    c = 0;
  1199.  
  1200.     for (i=1, m=0; i <= 32; i++, l<<=1) {
  1201.         if (minor(l) == 0 && c == 0)
  1202.             c = m;
  1203.         if (minor(l) != 0)
  1204.             m = i;
  1205.     }
  1206. exit (m == c);}],
  1207.                 [ac_cv_dev_minor_noncontig=yes],
  1208.                 [ac_cv_dev_minor_noncontig=no])])
  1209. if test $ac_cv_dev_minor_noncontig = yes; then
  1210.   AC_DEFINE(DEV_MINOR_NONCONTIG)
  1211. fi])
  1212.  
  1213. dnl Checks if we may not define our own malloc()
  1214. dnl Defines NO_USER_MALLOC if we cannot.
  1215. AC_DEFUN(AC_USER_MALLOC,
  1216. [AC_CACHE_CHECK([if we may not define our own malloc()], ac_cv_no_user_malloc,
  1217.                 [AC_TRY_LINK([
  1218. char * malloc(x)
  1219.     int     x; 
  1220. {
  1221.     return ((char *)0);
  1222. }],
  1223. [],
  1224.                 [ac_cv_no_user_malloc=no],
  1225.                 [ac_cv_no_user_malloc=yes])])
  1226. if test $ac_cv_no_user_malloc = yes; then
  1227.   AC_DEFINE(NO_USER_MALLOC)
  1228. fi])
  1229.  
  1230. dnl Checks if BSD-4.2 compliant getpgrp() exists
  1231. dnl Defines HAVE_BSD_GETPGRP on success.
  1232. AC_DEFUN(AC_FUNC_BSD_GETPGRP,
  1233. [AC_CACHE_CHECK([for BSD compliant getpgrp], ac_cv_func_bsd_getpgrp,
  1234.                 [AC_TRY_RUN([
  1235. int
  1236. main()
  1237. { long p;
  1238. /*
  1239.  * POSIX getpgrp() has void parameter...
  1240.  */
  1241.     p = getpgrp(-1);
  1242.     if (p == getpgrp(1) && p == getpgrp(getpid()))
  1243.         exit(1);
  1244. exit(0);}],
  1245.                 [ac_cv_func_bsd_getpgrp=yes],
  1246.                 [ac_cv_func_bsd_getpgrp=no])])
  1247. if test $ac_cv_func_bsd_getpgrp = yes; then
  1248.   AC_DEFINE(HAVE_BSD_GETPGRP)
  1249. fi])
  1250.  
  1251. dnl Checks if BSD-4.2 compliant setpgrp() exists
  1252. dnl Defines HAVE_BSD_SETPGRP on success.
  1253. AC_DEFUN(AC_FUNC_BSD_SETPGRP,
  1254. [AC_REQUIRE([AC_HEADER_ERRNO_DEF])dnl
  1255. AC_CACHE_CHECK([for BSD compliant setpgrp], ac_cv_func_bsd_setpgrp,
  1256.                 [AC_TRY_RUN([
  1257. #include <errno.h>
  1258. #ifndef    HAVE_ERRNO_DEF
  1259. extern    int    errno;
  1260. #endif
  1261. int
  1262. main()
  1263. { errno = 0;
  1264. /*
  1265.  * Force illegal pid on BSD
  1266.  */
  1267. if (setpgrp(-1, 100) < 0 && errno == ESRCH)
  1268.     exit(0);
  1269. exit(1);}],
  1270.                 [ac_cv_func_bsd_setpgrp=yes],
  1271.                 [ac_cv_func_bsd_setpgrp=no])])
  1272. if test $ac_cv_func_bsd_setpgrp = yes; then
  1273.   AC_DEFINE(HAVE_BSD_SETPGRP)
  1274. fi])
  1275.  
  1276. dnl Checks if select() needs more than sys/time.h & sys/types.h
  1277. dnl Defines SELECT_NONSTD_HDR on success.
  1278. AC_DEFUN(AC_HEADER_SELECT_NONSTD,
  1279. [AC_CACHE_CHECK([if select needs nonstd include files], ac_cv_header_slect_nonstd_hdr,
  1280.                 [AC_TRY_COMPILE([#include <sys/types.h>
  1281. #include <sys/time.h>],
  1282.             [fd_set rfd; FD_ZERO(&rfd); select(1, &rfd, 0, 0, 0);],
  1283.                 [ac_cv_header_slect_nonstd_hdr=no],
  1284.                 [ac_cv_header_slect_nonstd_hdr=yes])])
  1285. if test $ac_cv_header_slect_nonstd_hdr = yes; then
  1286.   AC_DEFINE(SELECT_NONSTD_HDR)
  1287. fi])
  1288.  
  1289. dnl Checks if select() needs sys/select.h
  1290. dnl Defines NEED_SYS_SELECT_H on success.
  1291. AC_DEFUN(AC_HEADER_SYS_SELECT,
  1292. [AC_REQUIRE([AC_HEADER_SELECT_NONSTD])dnl
  1293. AC_CACHE_CHECK([if sys/select.h is needed for select], ac_cv_header_need_sys_select_h,
  1294.                 [AC_TRY_COMPILE([#include <sys/types.h>
  1295. #include <sys/time.h>
  1296. #include <sys/select.h>
  1297. #ifndef    SELECT_NONSTD_HDR
  1298. do not compile if we do not need nonstandard headers
  1299. #endif],
  1300.             [fd_set rfd; FD_ZERO(&rfd); select(1, &rfd, 0, 0, 0);],
  1301.                 [ac_cv_header_need_sys_select_h=yes],
  1302.                 [ac_cv_header_need_sys_select_h=no])])
  1303. if test $ac_cv_header_need_sys_select_h = yes; then
  1304.   AC_DEFINE(NEED_SYS_SELECT_H)
  1305. fi])
  1306.  
  1307. dnl Checks if file locking via fcntl() is available
  1308. dnl Defines HAVE_FCNTL_LOCKF on success.
  1309. AC_DEFUN(AC_FUNC_FCNTL_LOCKF,
  1310. [AC_CACHE_CHECK([for file locking via fcntl], ac_cv_func_fcntl_lock,
  1311.                 [AC_TRY_LINK([
  1312. #include <sys/types.h>
  1313. #include <fcntl.h>], 
  1314.         [
  1315. struct flock fl;
  1316. fcntl(0, F_SETLK, &fl);],
  1317.                 [ac_cv_func_fcntl_lock=yes],
  1318.                 [ac_cv_func_fcntl_lock=no])])
  1319. if test $ac_cv_func_fcntl_lock = yes; then
  1320.   AC_DEFINE(HAVE_FCNTL_LOCKF)
  1321. fi])
  1322.  
  1323.  
  1324. dnl XXXXXXXXXXXXXXXXXX Begin Stolen from GNU tar XXXXXXXXXXXXXXXXXXXXXXXXXXX
  1325. dnl One line has been changed to:    [ac_save_CC="${CC-cc}"
  1326.  
  1327.  
  1328. #serial 18
  1329.  
  1330. dnl By default, many hosts won't let programs access large files;
  1331. dnl one must use special compiler options to get large-file access to work.
  1332. dnl For more details about this brain damage please see:
  1333. dnl http://www.sas.com/standards/large.file/x_open.20Mar96.html
  1334.  
  1335. dnl Written by Paul Eggert <eggert@twinsun.com>.
  1336.  
  1337. dnl Internal subroutine of AC_SYS_LARGEFILE.
  1338. dnl AC_SYS_LARGEFILE_TEST_INCLUDES
  1339. AC_DEFUN(AC_SYS_LARGEFILE_TEST_INCLUDES,
  1340.   [[#include <sys/types.h>
  1341.     /* Check that off_t can represent 2**63 - 1 correctly.
  1342.        We can't simply "#define LARGE_OFF_T 9223372036854775807",
  1343.        since some C++ compilers masquerading as C compilers
  1344.        incorrectly reject 9223372036854775807.  */
  1345. #   define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
  1346.     int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
  1347.             && LARGE_OFF_T % 2147483647 == 1)
  1348.                ? 1 : -1];
  1349.   ]])
  1350.  
  1351. dnl Internal subroutine of AC_SYS_LARGEFILE.
  1352. dnl AC_SYS_LARGEFILE_MACRO_VALUE(C-MACRO, VALUE, CACHE-VAR, COMMENT, INCLUDES, FUNCTION-BODY)
  1353. AC_DEFUN(AC_SYS_LARGEFILE_MACRO_VALUE,
  1354.   [AC_CACHE_CHECK([for $1 value needed for large files], $3,
  1355.      [$3=no
  1356.       AC_TRY_COMPILE([$5],
  1357.     [$6], 
  1358.     ,
  1359.     [AC_TRY_COMPILE([#define $1 $2]
  1360. [$5]
  1361.        ,
  1362.        [$6],
  1363.        [$3=$2])])])
  1364.    if test "[$]$3" != no; then
  1365.      AC_DEFINE_UNQUOTED([$1], [$]$3, [$4])
  1366.    fi])
  1367.  
  1368. AC_DEFUN(AC_SYS_LARGEFILE,
  1369.   [AC_ARG_ENABLE(largefile,
  1370.      [  --disable-largefile     omit support for large files])
  1371.    if test "$enable_largefile" != no; then
  1372.  
  1373.      AC_CACHE_CHECK([for special C compiler options needed for large files],
  1374.        ac_cv_sys_largefile_CC,
  1375.        [ac_cv_sys_largefile_CC=no
  1376.         if test "$GCC" != yes; then
  1377.       # IRIX 6.2 and later do not support large files by default,
  1378.       # so use the C compiler's -n32 option if that helps.
  1379.       AC_TRY_COMPILE(AC_SYS_LARGEFILE_TEST_INCLUDES, , ,
  1380.         [ac_save_CC="${CC-cc}"
  1381.          CC="$CC -n32"
  1382.          AC_TRY_COMPILE(AC_SYS_LARGEFILE_TEST_INCLUDES, ,
  1383.            ac_cv_sys_largefile_CC=' -n32')
  1384.          CC="$ac_save_CC"])
  1385.         fi])
  1386.      if test "$ac_cv_sys_largefile_CC" != no; then
  1387.        CC="$CC$ac_cv_sys_largefile_CC"
  1388.      fi
  1389.  
  1390.      AC_SYS_LARGEFILE_MACRO_VALUE(_FILE_OFFSET_BITS, 64,
  1391.        ac_cv_sys_file_offset_bits,
  1392.        [Number of bits in a file offset, on hosts where this is settable.],
  1393.        AC_SYS_LARGEFILE_TEST_INCLUDES)
  1394.      AC_SYS_LARGEFILE_MACRO_VALUE(_LARGE_FILES, 1,
  1395.        ac_cv_sys_large_files,
  1396.        [Define for large files, on AIX-style hosts.],
  1397.        AC_SYS_LARGEFILE_TEST_INCLUDES)
  1398.    fi
  1399.   ])
  1400.  
  1401.  
  1402. AC_DEFUN(AC_FUNC_FSEEKO,
  1403.   [AC_SYS_LARGEFILE_MACRO_VALUE(_LARGEFILE_SOURCE, 1,
  1404.      ac_cv_sys_largefile_source,
  1405.      [Define to make fseeko visible on some hosts (e.g. glibc 2.2).],
  1406.      [#include <stdio.h>], [return !fseeko;])
  1407.    # We used to try defining _XOPEN_SOURCE=500 too, to work around a bug
  1408.    # in glibc 2.1.3, but that breaks too many other things.
  1409.    # If you want fseeko and ftello with glibc, upgrade to a fixed glibc.
  1410.  
  1411.    AC_CACHE_CHECK([for fseeko], ac_cv_func_fseeko,
  1412.      [ac_cv_func_fseeko=no
  1413.       AC_TRY_LINK([#include <stdio.h>],
  1414.         [return fseeko && fseeko (stdin, 0, 0);],
  1415.     [ac_cv_func_fseeko=yes])])
  1416.    if test $ac_cv_func_fseeko != no; then
  1417.      AC_DEFINE(HAVE_FSEEKO, 1,
  1418.        [Define if fseeko (and presumably ftello) exists and is declared.])
  1419.    fi])
  1420.  
  1421.  
  1422. dnl XXXXXXXXXXXXXXXXXX End Stolen from GNU tar XXXXXXXXXXXXXXXXXXXXXXXXXXXXX
  1423.  
  1424. AC_DEFUN(AC_HAVE_LARGEFILES,
  1425. [AC_CACHE_CHECK([if system supports Large Files at all], ac_cv_largefiles,
  1426.          [AC_TRY_COMPILE([#include <stdio.h>
  1427. #include <sys/types.h>],
  1428.              [
  1429. /*
  1430.  * Check that off_t can represent 2**63 - 1 correctly.
  1431.  * We can't simply "#define LARGE_OFF_T 9223372036854775807",
  1432.  * since some C++ compilers masquerading as C compilers
  1433.  * incorrectly reject 9223372036854775807.
  1434.  */
  1435. #   define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
  1436.     int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
  1437.             && LARGE_OFF_T % 2147483647 == 1)
  1438.                ? 1 : -1];
  1439. return !ftello;],
  1440.              [ac_cv_largefiles=yes],
  1441.              [ac_cv_largefiles=no])])
  1442.     if test $ac_cv_largefiles = yes; then
  1443.         AC_DEFINE(HAVE_LARGEFILES)
  1444.     fi])
  1445.