home *** CD-ROM | disk | FTP | other *** search
/ Geek Gadgets 1 / ADE-1.bin / ade-dist / autoconf-2.10-src.tgz / tar.out / fsf / autoconf / acspecific.m4 < prev    next >
M4 Source File  |  1996-10-03  |  61KB  |  2,029 lines

  1. dnl Macros that test for specific features.
  2. dnl This file is part of Autoconf.
  3. dnl Copyright (C) 1992, 1993, 1994, 1995, 1996 Free Software Foundation, Inc.
  4. dnl
  5. dnl This program is free software; you can redistribute it and/or modify
  6. dnl it under the terms of the GNU General Public License as published by
  7. dnl the Free Software Foundation; either version 2, or (at your option)
  8. dnl any later version.
  9. dnl
  10. dnl This program is distributed in the hope that it will be useful,
  11. dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13. dnl GNU General Public License for more details.
  14. dnl
  15. dnl You should have received a copy of the GNU General Public License
  16. dnl along with this program; if not, write to the Free Software
  17. dnl Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  18. dnl
  19. dnl As a special exception, the Free Software Foundation gives unlimited
  20. dnl permission to copy, distribute and modify the configure scripts that
  21. dnl are the output of Autoconf.  You need not follow the terms of the GNU
  22. dnl General Public License when using or distributing such scripts, even
  23. dnl though portions of the text of Autoconf appear in them.  The GNU
  24. dnl General Public License (GPL) does govern all other use of the material
  25. dnl that constitutes the Autoconf program.
  26. dnl
  27. dnl Certain portions of the Autoconf source text are designed to be copied
  28. dnl (in certain cases, depending on the input) into the output of
  29. dnl Autoconf.  We call these the "data" portions.  The rest of the Autoconf
  30. dnl source text consists of comments plus executable code that decides which
  31. dnl of the data portions to output in any given case.  We call these
  32. dnl comments and executable code the "non-data" portions.  Autoconf never
  33. dnl copies any of the non-data portions into its output.
  34. dnl
  35. dnl This special exception to the GPL applies to versions of Autoconf
  36. dnl released by the Free Software Foundation.  When you make and
  37. dnl distribute a modified version of Autoconf, you may extend this special
  38. dnl exception to the GPL to apply to your modified version as well, *unless*
  39. dnl your modified version has the potential to copy into its output some
  40. dnl of the text that was the non-data portion of the version that you started
  41. dnl with.  (In other words, unless your change moves or copies text from
  42. dnl the non-data portions to the data portions.)  If your modification has
  43. dnl such potential, you must delete any notice of this special exception
  44. dnl to the GPL from your modified version.
  45. dnl
  46. dnl Written by David MacKenzie, with help from
  47. dnl Franc,ois Pinard, Karl Berry, Richard Pixley, Ian Lance Taylor,
  48. dnl Roland McGrath, Noah Friedman, david d zuhn, and many others.
  49.  
  50.  
  51. dnl ### Checks for programs
  52.  
  53.  
  54. dnl Check whether to use -n, \c, or newline-tab to separate
  55. dnl checking messages from result messages.
  56. dnl Idea borrowed from dist 3.0.
  57. dnl Internal use only.
  58. AC_DEFUN(AC_PROG_ECHO_N,
  59. [if (echo "testing\c"; echo 1,2,3) | grep c >/dev/null; then
  60.   # Stardent Vistra SVR4 grep lacks -e, says ghazi@caip.rutgers.edu.
  61.   if (echo -n testing; echo 1,2,3) | sed s/-n/xn/ | grep xn >/dev/null; then
  62.     ac_n= ac_c='
  63. ' ac_t='    '
  64.   else
  65.     ac_n=-n ac_c= ac_t=
  66.   fi
  67. else
  68.   ac_n= ac_c='\c' ac_t=
  69. fi
  70. ])
  71.  
  72. AC_DEFUN(AC_PROG_CC,
  73. [AC_BEFORE([$0], [AC_PROG_CPP])dnl
  74. AC_CHECK_PROG(CC, gcc, gcc)
  75. if test -z "$CC"; then
  76.   AC_CHECK_PROG(CC, cc, cc, , , /usr/ucb/cc)
  77.   test -z "$CC" && AC_MSG_ERROR([no acceptable cc found in \$PATH])
  78. fi
  79.  
  80. AC_CACHE_CHECK(whether we are using GNU C, ac_cv_prog_gcc,
  81. [dnl The semicolon is to pacify NeXT's syntax-checking cpp.
  82. cat > conftest.c <<EOF
  83. #ifdef __GNUC__
  84.   yes;
  85. #endif
  86. EOF
  87. if AC_TRY_COMMAND(${CC-cc} -E conftest.c) | egrep yes >/dev/null 2>&1; then
  88.   ac_cv_prog_gcc=yes
  89. else
  90.   ac_cv_prog_gcc=no
  91. fi])
  92. if test $ac_cv_prog_gcc = yes; then
  93.   GCC=yes
  94.   if test "${CFLAGS+set}" != set; then
  95.     AC_CACHE_CHECK(whether ${CC-cc} accepts -g, ac_cv_prog_gcc_g,
  96. [echo 'void f(){}' > conftest.c
  97. if test -z "`${CC-cc} -g -c conftest.c 2>&1`"; then
  98.   ac_cv_prog_gcc_g=yes
  99. else
  100.   ac_cv_prog_gcc_g=no
  101. fi
  102. rm -f conftest*
  103. ])
  104.     if test $ac_cv_prog_gcc_g = yes; then
  105.       CFLAGS="-g -O2"
  106.     else
  107.       CFLAGS="-O2"
  108.     fi
  109.   fi
  110. else
  111.   GCC=
  112.   test "${CFLAGS+set}" = set || CFLAGS="-g"
  113. fi
  114. ])
  115.  
  116. AC_DEFUN(AC_PROG_CXX,
  117. [AC_BEFORE([$0], [AC_PROG_CXXCPP])dnl
  118. AC_CHECK_PROGS(CXX, $CCC c++ g++ gcc CC cxx, gcc)
  119.  
  120. AC_CACHE_CHECK(whether we are using GNU C++, ac_cv_prog_gxx,
  121. [dnl The semicolon is to pacify NeXT's syntax-checking cpp.
  122. cat > conftest.C <<EOF
  123. #ifdef __GNUC__
  124.   yes;
  125. #endif
  126. EOF
  127. if AC_TRY_COMMAND(${CXX-g++} -E conftest.C) | egrep yes >/dev/null 2>&1; then
  128.   ac_cv_prog_gxx=yes
  129. else
  130.   ac_cv_prog_gxx=no
  131. fi])
  132. if test $ac_cv_prog_gxx = yes; then
  133.   GXX=yes
  134.   if test "${CXXFLAGS+set}" != set; then
  135.     AC_CACHE_CHECK(whether ${CXX-g++} accepts -g, ac_cv_prog_gxx_g,
  136. [echo 'void f(){}' > conftest.cc
  137. if test -z "`${CXX-g++} -g -c conftest.cc 2>&1`"; then
  138.   ac_cv_prog_gxx_g=yes
  139. else
  140.   ac_cv_prog_gxx_g=no
  141. fi
  142. rm -f conftest*
  143. ])
  144. dnl
  145.     if test $ac_cv_prog_gxx_g = yes; then
  146.       CXXFLAGS="-g -O2"
  147.     else
  148.       CXXFLAGS="-O2"
  149.     fi
  150.   fi
  151. else
  152.   GXX=
  153.   test "${CXXFLAGS+set}" = set || CXXFLAGS="-g"
  154. fi
  155. ])
  156.  
  157. AC_DEFUN(AC_PROG_GCC_TRADITIONAL,
  158. [AC_REQUIRE([AC_PROG_CC])dnl
  159. AC_REQUIRE([AC_PROG_CPP])dnl
  160. if test $ac_cv_prog_gcc = yes; then
  161.     AC_CACHE_CHECK(whether ${CC-cc} needs -traditional,
  162.       ac_cv_prog_gcc_traditional,
  163. [  ac_pattern="Autoconf.*'x'"
  164.   AC_EGREP_CPP($ac_pattern, [#include <sgtty.h>
  165. Autoconf TIOCGETP],
  166.   ac_cv_prog_gcc_traditional=yes, ac_cv_prog_gcc_traditional=no)
  167.  
  168.   if test $ac_cv_prog_gcc_traditional = no; then
  169.     AC_EGREP_CPP($ac_pattern, [#include <termio.h>
  170. Autoconf TCGETA],
  171.     ac_cv_prog_gcc_traditional=yes)
  172.   fi])
  173.   if test $ac_cv_prog_gcc_traditional = yes; then
  174.     CC="$CC -traditional"
  175.   fi
  176. fi
  177. ])
  178.  
  179. AC_DEFUN(AC_PROG_CC_C_O,
  180. [if test "x$CC" != xcc; then
  181.   AC_MSG_CHECKING(whether $CC and cc understand -c and -o together)
  182. else
  183.   AC_MSG_CHECKING(whether cc understands -c and -o together)
  184. fi
  185. set dummy $CC; ac_cc="`echo [$]2 |
  186. changequote(, )dnl
  187.                sed -e 's/[^a-zA-Z0-9_]/_/g' -e 's/^[0-9]/_/'`"
  188. changequote([, ])dnl
  189. AC_CACHE_VAL(ac_cv_prog_cc_${ac_cc}_c_o,
  190. [echo 'foo(){}' > conftest.c
  191. # Make sure it works both with $CC and with simple cc.
  192. # We do the test twice because some compilers refuse to overwrite an
  193. # existing .o file with -o, though they will create one.
  194. ac_try='${CC-cc} -c conftest.c -o conftest.o 1>&AC_FD_CC'
  195. if AC_TRY_EVAL(ac_try) &&
  196.    test -f conftest.o && AC_TRY_EVAL(ac_try);
  197. then
  198.   eval ac_cv_prog_cc_${ac_cc}_c_o=yes
  199.   if test "x$CC" != xcc; then
  200.     # Test first that cc exists at all.
  201.     if AC_TRY_COMMAND(cc -c conftest.c 1>&AC_FD_CC); then
  202.       ac_try='cc -c conftest.c -o conftest.o 1>&AC_FD_CC'
  203.       if AC_TRY_EVAL(ac_try) &&
  204.      test -f conftest.o && AC_TRY_EVAL(ac_try);
  205.       then
  206.         # cc works too.
  207.         :
  208.       else
  209.         # cc exists but doesn't like -o.
  210.         eval ac_cv_prog_cc_${ac_cc}_c_o=no
  211.       fi
  212.     fi
  213.   fi
  214. else
  215.   eval ac_cv_prog_cc_${ac_cc}_c_o=no
  216. fi
  217. rm -f conftest*
  218. ])dnl
  219. if eval "test \"`echo '$ac_cv_prog_cc_'${ac_cc}_c_o`\" = yes"; then
  220.   AC_MSG_RESULT(yes)
  221. else
  222.   AC_MSG_RESULT(no)
  223.   AC_DEFINE(NO_MINUS_C_MINUS_O)
  224. fi
  225. ])
  226.  
  227. dnl Define SET_MAKE to set ${MAKE} if make doesn't.
  228. AC_DEFUN(AC_PROG_MAKE_SET,
  229. [AC_MSG_CHECKING(whether ${MAKE-make} sets \${MAKE})
  230. set dummy ${MAKE-make}; ac_make=[$]2
  231. AC_CACHE_VAL(ac_cv_prog_make_${ac_make}_set,
  232. [cat > conftestmake <<\EOF
  233. all:
  234.     @echo 'ac_maketemp="${MAKE}"'
  235. EOF
  236. changequote(, )dnl
  237. # GNU make sometimes prints "make[1]: Entering...", which would confuse us.
  238. eval `${MAKE-make} -f conftestmake 2>/dev/null | grep temp=`
  239. changequote([, ])dnl
  240. if test -n "$ac_maketemp"; then
  241.   eval ac_cv_prog_make_${ac_make}_set=yes
  242. else
  243.   eval ac_cv_prog_make_${ac_make}_set=no
  244. fi
  245. rm -f conftestmake])dnl
  246. if eval "test \"`echo '$ac_cv_prog_make_'${ac_make}_set`\" = yes"; then
  247.   AC_MSG_RESULT(yes)
  248.   SET_MAKE=
  249. else
  250.   AC_MSG_RESULT(no)
  251.   SET_MAKE="MAKE=${MAKE-make}"
  252. fi
  253. AC_SUBST([SET_MAKE])dnl
  254. ])
  255.  
  256. AC_DEFUN(AC_PROG_RANLIB,
  257. [AC_CHECK_PROG(RANLIB, ranlib, ranlib, :)])
  258.  
  259. dnl Check for mawk first since it's generally faster.
  260. AC_DEFUN(AC_PROG_AWK,
  261. [AC_CHECK_PROGS(AWK, mawk gawk nawk awk, )])
  262.  
  263. AC_DEFUN(AC_PROG_YACC,
  264. [AC_CHECK_PROGS(YACC, 'bison -y' byacc, yacc)])
  265.  
  266. AC_DEFUN(AC_PROG_CPP,
  267. [AC_MSG_CHECKING(how to run the C preprocessor)
  268. # On Suns, sometimes $CPP names a directory.
  269. if test -n "$CPP" && test -d "$CPP"; then
  270.   CPP=
  271. fi
  272. if test -z "$CPP"; then
  273. AC_CACHE_VAL(ac_cv_prog_CPP,
  274. [  # This must be in double quotes, not single quotes, because CPP may get
  275.   # substituted into the Makefile and "${CC-cc}" will confuse make.
  276.   CPP="${CC-cc} -E"
  277.   # On the NeXT, cc -E runs the code through the compiler's parser,
  278.   # not just through cpp.
  279. dnl Use a header file that comes with gcc, so configuring glibc
  280. dnl with a fresh cross-compiler works.
  281.   AC_TRY_CPP([#include <assert.h>
  282. Syntax Error], ,
  283.   CPP="${CC-cc} -E -traditional-cpp"
  284.   AC_TRY_CPP([#include <assert.h>
  285. Syntax Error], , CPP=/lib/cpp))
  286.   ac_cv_prog_CPP="$CPP"])dnl
  287.   CPP="$ac_cv_prog_CPP"
  288. else
  289.   ac_cv_prog_CPP="$CPP"
  290. fi
  291. AC_MSG_RESULT($CPP)
  292. AC_SUBST(CPP)dnl
  293. ])
  294.  
  295. AC_DEFUN(AC_PROG_CXXCPP,
  296. [AC_MSG_CHECKING(how to run the C++ preprocessor)
  297. if test -z "$CXXCPP"; then
  298. AC_CACHE_VAL(ac_cv_prog_CXXCPP,
  299. [AC_LANG_SAVE[]dnl
  300. AC_LANG_CPLUSPLUS[]dnl
  301.   CXXCPP="${CXX-g++} -E"
  302.   AC_TRY_CPP([#include <stdlib.h>], , CXXCPP=/lib/cpp)
  303.   ac_cv_prog_CXXCPP="$CXXCPP"
  304. AC_LANG_RESTORE[]dnl
  305. fi])dnl
  306. CXXCPP="$ac_cv_prog_CXXCPP"
  307. AC_MSG_RESULT($CXXCPP)
  308. AC_SUBST(CXXCPP)dnl
  309. ])
  310.  
  311. dnl Require finding the C or C++ preprocessor, whichever is the
  312. dnl current language.
  313. AC_DEFUN(AC_REQUIRE_CPP,
  314. [ifelse(AC_LANG, C, [AC_REQUIRE([AC_PROG_CPP])], [AC_REQUIRE([AC_PROG_CXXCPP])])])
  315.  
  316. AC_DEFUN(AC_PROG_LEX,
  317. [AC_CHECK_PROG(LEX, flex, flex, lex)
  318. if test -z "$LEXLIB"
  319. then
  320.   case "$LEX" in
  321.   flex*) ac_lib=fl ;;
  322.   *) ac_lib=l ;;
  323.   esac
  324.   AC_CHECK_LIB($ac_lib, yywrap, LEXLIB="-l$ac_lib")
  325. fi
  326. AC_SUBST(LEXLIB)])
  327.  
  328. dnl Check if lex declares yytext as a char * by default, not a char[].
  329. undefine([AC_DECL_YYTEXT])
  330. AC_DEFUN(AC_DECL_YYTEXT,
  331. [AC_REQUIRE_CPP()dnl
  332. AC_REQUIRE([AC_PROG_LEX])dnl
  333. AC_CACHE_CHECK(lex output file root, ac_cv_prog_lex_root,
  334. [# The minimal lex program is just a single line: %%.  But some broken lexes
  335. # (Solaris, I think it was) want two %% lines, so accommodate them.
  336. echo '%%
  337. %%' | $LEX
  338. if test -f lex.yy.c; then
  339.   ac_cv_prog_lex_root=lex.yy
  340. elif test -f lexyy.c; then
  341.   ac_cv_prog_lex_root=lexyy
  342. else
  343.   AC_MSG_ERROR(cannot find output from $LEX; giving up)
  344. fi])
  345. LEX_OUTPUT_ROOT=$ac_cv_prog_lex_root
  346. AC_SUBST(LEX_OUTPUT_ROOT)dnl
  347.  
  348. AC_CACHE_CHECK(whether yytext is a pointer, ac_cv_prog_lex_yytext_pointer,
  349. [# POSIX says lex can declare yytext either as a pointer or an array; the
  350. # default is implementation-dependent. Figure out which it is, since
  351. # not all implementations provide the %pointer and %array declarations.
  352. ac_cv_prog_lex_yytext_pointer=no
  353. echo 'extern char *yytext;' >>$LEX_OUTPUT_ROOT.c
  354. ac_save_LIBS="$LIBS"
  355. LIBS="$LIBS $LEXLIB"
  356. AC_TRY_LINK(`cat $LEX_OUTPUT_ROOT.c`, , ac_cv_prog_lex_yytext_pointer=yes)
  357. LIBS="$ac_save_LIBS"
  358. rm -f "${LEX_OUTPUT_ROOT}.c"])
  359. dnl
  360. if test $ac_cv_prog_lex_yytext_pointer = yes; then
  361.   AC_DEFINE(YYTEXT_POINTER)
  362. fi
  363. ])
  364.  
  365. AC_DEFUN(AC_PROG_INSTALL,
  366. [AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT])dnl
  367. # Find a good install program.  We prefer a C program (faster),
  368. # so one script is as good as another.  But avoid the broken or
  369. # incompatible versions:
  370. # SysV /etc/install, /usr/sbin/install
  371. # SunOS /usr/etc/install
  372. # IRIX /sbin/install
  373. # AIX /bin/install
  374. # AmigaOS /c/install
  375. # AFS /usr/afsws/bin/install, which mishandles nonexistent args
  376. # SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff"
  377. # ./install, which can be erroneously created by make from ./install.sh.
  378. AC_MSG_CHECKING(for a BSD compatible install)
  379. if test -z "$INSTALL"; then
  380. AC_CACHE_VAL(ac_cv_path_install,
  381. [  IFS="${IFS=     }"; ac_save_ifs="$IFS"; IFS="${IFS}:"
  382.   for ac_dir in $PATH; do
  383.     # Account for people who put trailing slashes in PATH elements.
  384.     case "$ac_dir/" in
  385.     /|./|.//|/etc/*|/c/*|/usr/sbin/*|/usr/etc/*|/sbin/*|/usr/afsws/bin/*|/usr/ucb/*) ;;
  386.     *)
  387.       # OSF1 and SCO ODT 3.0 have their own names for install.
  388.       for ac_prog in ginstall installbsd scoinst install; do
  389.         if test -f $ac_dir/$ac_prog; then
  390.       if test $ac_prog = install &&
  391.             grep dspmsg $ac_dir/$ac_prog >/dev/null 2>&1; then
  392.         # AIX install.  It has an incompatible calling convention.
  393.         # OSF/1 installbsd also uses dspmsg, but is usable.
  394.         :
  395.       else
  396.         ac_cv_path_install="$ac_dir/$ac_prog -c"
  397.         break 2
  398.       fi
  399.     fi
  400.       done
  401.       ;;
  402.     esac
  403.   done
  404.   IFS="$ac_save_ifs"
  405. ])dnl
  406.   if test "${ac_cv_path_install+set}" = set; then
  407.     INSTALL="$ac_cv_path_install"
  408.   else
  409.     # As a last resort, use the slow shell script.  We don't cache a
  410.     # path for INSTALL within a source directory, because that will
  411.     # break other packages using the cache if that directory is
  412.     # removed, or if the path is relative.
  413.     INSTALL="$ac_install_sh"
  414.   fi
  415. fi
  416. dnl We do special magic for INSTALL instead of AC_SUBST, to get
  417. dnl relative paths right.
  418. AC_MSG_RESULT($INSTALL)
  419.  
  420. # Use test -z because SunOS4 sh mishandles braces in ${var-val}.
  421. # It thinks the first close brace ends the variable substitution.
  422. test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}'
  423. AC_SUBST(INSTALL_PROGRAM)dnl
  424.  
  425. test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644'
  426. AC_SUBST(INSTALL_DATA)dnl
  427. ])
  428.  
  429. AC_DEFUN(AC_PROG_LN_S,
  430. [AC_MSG_CHECKING(whether ln -s works)
  431. AC_CACHE_VAL(ac_cv_prog_LN_S,
  432. [rm -f conftestdata
  433. if ln -s X conftestdata 2>/dev/null
  434. then
  435.   rm -f conftestdata
  436.   ac_cv_prog_LN_S="ln -s"
  437. else
  438.   ac_cv_prog_LN_S=ln
  439. fi])dnl
  440. LN_S="$ac_cv_prog_LN_S"
  441. if test "$ac_cv_prog_LN_S" = "ln -s"; then
  442.   AC_MSG_RESULT(yes)
  443. else
  444.   AC_MSG_RESULT(no)
  445. fi
  446. AC_SUBST(LN_S)dnl
  447. ])
  448.  
  449. define(AC_RSH,
  450. [errprint(__file__:__line__: [$0] has been removed; replace it with equivalent code
  451. )m4exit(4)])
  452.  
  453.  
  454. dnl ### Checks for header files
  455.  
  456.  
  457. AC_DEFUN(AC_HEADER_STDC,
  458. [AC_REQUIRE_CPP()dnl
  459. AC_CACHE_CHECK(for ANSI C header files, ac_cv_header_stdc,
  460. [AC_TRY_CPP([#include <stdlib.h>
  461. #include <stdarg.h>
  462. #include <string.h>
  463. #include <float.h>], ac_cv_header_stdc=yes, ac_cv_header_stdc=no)
  464.  
  465. if test $ac_cv_header_stdc = yes; then
  466.   # SunOS 4.x string.h does not declare mem*, contrary to ANSI.
  467. AC_EGREP_HEADER(memchr, string.h, , ac_cv_header_stdc=no)
  468. fi
  469.  
  470. if test $ac_cv_header_stdc = yes; then
  471.   # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI.
  472. AC_EGREP_HEADER(free, stdlib.h, , ac_cv_header_stdc=no)
  473. fi
  474.  
  475. if test $ac_cv_header_stdc = yes; then
  476.   # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi.
  477. AC_TRY_RUN([#include <ctype.h>
  478. #define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
  479. #define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c))
  480. #define XOR(e, f) (((e) && !(f)) || (!(e) && (f)))
  481. int main () { int i; for (i = 0; i < 256; i++)
  482. if (XOR (islower (i), ISLOWER (i)) || toupper (i) != TOUPPER (i)) exit(2);
  483. exit (0); }
  484. ], , ac_cv_header_stdc=no, :)
  485. fi])
  486. if test $ac_cv_header_stdc = yes; then
  487.   AC_DEFINE(STDC_HEADERS)
  488. fi
  489. ])
  490.  
  491. AC_DEFUN(AC_UNISTD_H,
  492. [AC_OBSOLETE([$0], [; instead use AC_CHECK_HEADERS(unistd.h)])dnl
  493. AC_CHECK_HEADER(unistd.h, AC_DEFINE(HAVE_UNISTD_H))])
  494.  
  495. AC_DEFUN(AC_USG,
  496. [AC_OBSOLETE([$0],
  497.   [; instead use AC_CHECK_HEADERS(string.h) and HAVE_STRING_H])dnl
  498. AC_MSG_CHECKING([for BSD string and memory functions])
  499. AC_TRY_LINK([#include <strings.h>], [rindex(0, 0); bzero(0, 0);],
  500.   [AC_MSG_RESULT(yes)], [AC_MSG_RESULT(no); AC_DEFINE(USG)])])
  501.  
  502.  
  503. dnl If memchr and the like aren't declared in <string.h>, include <memory.h>.
  504. dnl To avoid problems, don't check for gcc2 built-ins.
  505. AC_DEFUN(AC_MEMORY_H,
  506. [AC_OBSOLETE([$0], [; instead use AC_CHECK_HEADERS(memory.h) and HAVE_MEMORY_H])dnl
  507. AC_MSG_CHECKING(whether string.h declares mem functions)
  508. AC_EGREP_HEADER(memchr, string.h, ac_found=yes, ac_found=no)
  509. AC_MSG_RESULT($ac_found)
  510. if test $ac_found = no; then
  511.   AC_CHECK_HEADER(memory.h, [AC_DEFINE(NEED_MEMORY_H)])
  512. fi
  513. ])
  514.  
  515. AC_DEFUN(AC_HEADER_MAJOR,
  516. [AC_CACHE_CHECK(whether sys/types.h defines makedev,
  517.   ac_cv_header_sys_types_h_makedev,
  518. [AC_TRY_LINK([#include <sys/types.h>], [return makedev(0, 0);],
  519.   ac_cv_header_sys_types_h_makedev=yes, ac_cv_header_sys_types_h_makedev=no)
  520. ])
  521.  
  522. if test $ac_cv_header_sys_types_h_makedev = no; then
  523. AC_CHECK_HEADER(sys/mkdev.h, [AC_DEFINE(MAJOR_IN_MKDEV)])
  524.  
  525.   if test $ac_cv_header_sys_mkdev_h = no; then
  526. AC_CHECK_HEADER(sys/sysmacros.h, [AC_DEFINE(MAJOR_IN_SYSMACROS)])
  527.   fi
  528. fi
  529. ])
  530.  
  531. AC_DEFUN(AC_HEADER_DIRENT,
  532. [ac_header_dirent=no
  533. AC_CHECK_HEADERS_DIRENT(dirent.h sys/ndir.h sys/dir.h ndir.h,
  534.   [ac_header_dirent=$ac_hdr; break])
  535. # Two versions of opendir et al. are in -ldir and -lx on SCO Xenix.
  536. if test $ac_header_dirent = dirent.h; then
  537. AC_CHECK_LIB(dir, opendir, LIBS="$LIBS -ldir")
  538. else
  539. AC_CHECK_LIB(x, opendir, LIBS="$LIBS -lx")
  540. fi
  541. ])
  542.  
  543. dnl Like AC_CHECK_HEADER, except also make sure that HEADER-FILE
  544. dnl defines the type `DIR'.  dirent.h on NextStep 3.2 doesn't.
  545. dnl AC_CHECK_HEADER_DIRENT(HEADER-FILE, ACTION-IF-FOUND)
  546. AC_DEFUN(AC_CHECK_HEADER_DIRENT,
  547. [ac_safe=`echo "$1" | tr './\055' '___'`
  548. AC_MSG_CHECKING([for $1 that defines DIR])
  549. AC_CACHE_VAL(ac_cv_header_dirent_$ac_safe,
  550. [AC_TRY_COMPILE([#include <sys/types.h>
  551. #include <$1>], [DIR *dirp = 0;],
  552.   eval "ac_cv_header_dirent_$ac_safe=yes",
  553.   eval "ac_cv_header_dirent_$ac_safe=no")])dnl
  554. if eval "test \"`echo '$ac_cv_header_dirent_'$ac_safe`\" = yes"; then
  555.   AC_MSG_RESULT(yes)
  556.   $2
  557. else
  558.   AC_MSG_RESULT(no)
  559. fi
  560. ])
  561.  
  562. dnl Like AC_CHECK_HEADERS, except succeed only for a HEADER-FILE that
  563. dnl defines `DIR'.
  564. dnl AC_CHECK_HEADERS_DIRENT(HEADER-FILE... [, ACTION])
  565. define(AC_CHECK_HEADERS_DIRENT,
  566. [for ac_hdr in $1
  567. do
  568. AC_CHECK_HEADER_DIRENT($ac_hdr,
  569. [changequote(, )dnl
  570.   ac_tr_hdr=HAVE_`echo $ac_hdr | tr 'abcdedfghijklmnopqrstuvwxyz./\055' 'ABCDEDFGHIJKLMNOPQRSTUVWXYZ___'`
  571. changequote([, ])dnl
  572.   AC_DEFINE_UNQUOTED($ac_tr_hdr) $2])dnl
  573. done])
  574.  
  575. AC_DEFUN(AC_DIR_HEADER,
  576. [AC_OBSOLETE([$0], [; instead use AC_HEADER_DIRENT])dnl
  577. ac_header_dirent=no
  578. for ac_hdr in dirent.h sys/ndir.h sys/dir.h ndir.h; do
  579.   AC_CHECK_HEADER_DIRENT($ac_hdr, [ac_header_dirent=$ac_hdr; break])
  580. done
  581.  
  582. case "$ac_header_dirent" in
  583. dirent.h) AC_DEFINE(DIRENT) ;;
  584. sys/ndir.h) AC_DEFINE(SYSNDIR) ;;
  585. sys/dir.h) AC_DEFINE(SYSDIR) ;;
  586. ndir.h) AC_DEFINE(NDIR) ;;
  587. esac
  588.  
  589. AC_CACHE_CHECK(whether closedir returns void, ac_cv_func_closedir_void,
  590. [AC_TRY_RUN([#include <sys/types.h>
  591. #include <$ac_header_dirent>
  592. int closedir(); main() { exit(closedir(opendir(".")) != 0); }],
  593.   ac_cv_func_closedir_void=no, ac_cv_func_closedir_void=yes, ac_cv_func_closedir_void=yes)])
  594. if test $ac_cv_func_closedir_void = yes; then
  595.   AC_DEFINE(VOID_CLOSEDIR)
  596. fi
  597. ])
  598.  
  599. AC_DEFUN(AC_HEADER_STAT,
  600. [AC_CACHE_CHECK(whether stat file-mode macros are broken,
  601.   ac_cv_header_stat_broken,
  602. [AC_EGREP_CPP([You lose], [#include <sys/types.h>
  603. #include <sys/stat.h>
  604.  
  605. #if defined(S_ISBLK) && defined(S_IFDIR)
  606. # if S_ISBLK (S_IFDIR)
  607. You lose.
  608. # endif
  609. #endif
  610.  
  611. #if defined(S_ISBLK) && defined(S_IFCHR)
  612. # if S_ISBLK (S_IFCHR)
  613. You lose.
  614. # endif
  615. #endif
  616.  
  617. #if defined(S_ISLNK) && defined(S_IFREG)
  618. # if S_ISLNK (S_IFREG)
  619. You lose.
  620. # endif
  621. #endif
  622.  
  623. #if defined(S_ISSOCK) && defined(S_IFREG)
  624. # if S_ISSOCK (S_IFREG)
  625. You lose.
  626. # endif
  627. #endif
  628. ], ac_cv_header_stat_broken=yes, ac_cv_header_stat_broken=no)])
  629. if test $ac_cv_header_stat_broken = yes; then
  630.   AC_DEFINE(STAT_MACROS_BROKEN)
  631. fi
  632. ])
  633.  
  634. AC_DEFUN(AC_DECL_SYS_SIGLIST,
  635. [AC_CACHE_CHECK([for sys_siglist declaration in signal.h or unistd.h],
  636.   ac_cv_decl_sys_siglist,
  637. [AC_TRY_COMPILE([#include <sys/types.h>
  638. #include <signal.h>
  639. /* NetBSD declares sys_siglist in unistd.h.  */
  640. #ifdef HAVE_UNISTD_H
  641. #include <unistd.h>
  642. #endif], [char *msg = *(sys_siglist + 1);],
  643.   ac_cv_decl_sys_siglist=yes, ac_cv_decl_sys_siglist=no)])
  644. if test $ac_cv_decl_sys_siglist = yes; then
  645.   AC_DEFINE(SYS_SIGLIST_DECLARED)
  646. fi
  647. ])
  648.  
  649. AC_DEFUN(AC_HEADER_SYS_WAIT,
  650. [AC_CACHE_CHECK([for sys/wait.h that is POSIX.1 compatible],
  651.   ac_cv_header_sys_wait_h,
  652. [AC_TRY_COMPILE([#include <sys/types.h>
  653. #include <sys/wait.h>
  654. #ifndef WEXITSTATUS
  655. #define WEXITSTATUS(stat_val) ((unsigned)(stat_val) >> 8)
  656. #endif
  657. #ifndef WIFEXITED
  658. #define WIFEXITED(stat_val) (((stat_val) & 255) == 0)
  659. #endif], [int s;
  660. wait (&s);
  661. s = WIFEXITED (s) ? WEXITSTATUS (s) : 1;],
  662. ac_cv_header_sys_wait_h=yes, ac_cv_header_sys_wait_h=no)])
  663. if test $ac_cv_header_sys_wait_h = yes; then
  664.   AC_DEFINE(HAVE_SYS_WAIT_H)
  665. fi
  666. ])
  667.  
  668.  
  669. dnl ### Checks for typedefs
  670.  
  671.  
  672. AC_DEFUN(AC_TYPE_GETGROUPS,
  673. [AC_REQUIRE([AC_TYPE_UID_T])dnl
  674. AC_CACHE_CHECK(type of array argument to getgroups, ac_cv_type_getgroups,
  675. [AC_TRY_RUN(
  676. changequote(<<, >>)dnl
  677. <<
  678. /* Thanks to Mike Rendell for this test.  */
  679. #include <sys/types.h>
  680. #define NGID 256
  681. #undef MAX
  682. #define MAX(x, y) ((x) > (y) ? (x) : (y))
  683. main()
  684. {
  685.   gid_t gidset[NGID];
  686.   int i, n;
  687.   union { gid_t gval; long lval; }  val;
  688.  
  689.   val.lval = -1;
  690.   for (i = 0; i < NGID; i++)
  691.     gidset[i] = val.gval;
  692.   n = getgroups (sizeof (gidset) / MAX (sizeof (int), sizeof (gid_t)) - 1,
  693.                  gidset);
  694.   /* Exit non-zero if getgroups seems to require an array of ints.  This
  695.      happens when gid_t is short but getgroups modifies an array of ints.  */
  696.   exit ((n > 0 && gidset[n] != val.gval) ? 1 : 0);
  697. }
  698. >>,
  699. changequote([, ])dnl
  700.   ac_cv_type_getgroups=gid_t, ac_cv_type_getgroups=int,
  701.   ac_cv_type_getgroups=cross)
  702. if test $ac_cv_type_getgroups = cross; then
  703.   dnl When we can't run the test program (we are cross compiling), presume
  704.   dnl that <unistd.h> has either an accurate prototype for getgroups or none.
  705.   dnl Old systems without prototypes probably use int.
  706.   AC_EGREP_HEADER([getgroups.*int.*gid_t], unistd.h,
  707.           ac_cv_type_getgroups=gid_t, ac_cv_type_getgroups=int)
  708. fi])
  709. AC_DEFINE_UNQUOTED(GETGROUPS_T, $ac_cv_type_getgroups)
  710. ])
  711.  
  712. AC_DEFUN(AC_TYPE_UID_T,
  713. [AC_CACHE_CHECK(for uid_t in sys/types.h, ac_cv_type_uid_t,
  714. [AC_EGREP_HEADER(uid_t, sys/types.h,
  715.   ac_cv_type_uid_t=yes, ac_cv_type_uid_t=no)])
  716. if test $ac_cv_type_uid_t = no; then
  717.   AC_DEFINE(uid_t, int)
  718.   AC_DEFINE(gid_t, int)
  719. fi
  720. ])
  721.  
  722. AC_DEFUN(AC_TYPE_SIZE_T,
  723. [AC_CHECK_TYPE(size_t, unsigned)])
  724.  
  725. AC_DEFUN(AC_TYPE_PID_T,
  726. [AC_CHECK_TYPE(pid_t, int)])
  727.  
  728. AC_DEFUN(AC_TYPE_OFF_T,
  729. [AC_CHECK_TYPE(off_t, long)])
  730.  
  731. AC_DEFUN(AC_TYPE_MODE_T,
  732. [AC_CHECK_TYPE(mode_t, int)])
  733.  
  734. dnl Note that identifiers starting with SIG are reserved by ANSI C.
  735. AC_DEFUN(AC_TYPE_SIGNAL,
  736. [AC_CACHE_CHECK([return type of signal handlers], ac_cv_type_signal,
  737. [AC_TRY_COMPILE([#include <sys/types.h>
  738. #include <signal.h>
  739. #ifdef signal
  740. #undef signal
  741. #endif
  742. #ifdef __cplusplus
  743. extern "C" void (*signal (int, void (*)(int)))(int);
  744. #else
  745. void (*signal ()) ();
  746. #endif
  747. ],
  748. [int i;], ac_cv_type_signal=void, ac_cv_type_signal=int)])
  749. AC_DEFINE_UNQUOTED(RETSIGTYPE, $ac_cv_type_signal)
  750. ])
  751.  
  752.  
  753. dnl ### Checks for functions
  754.  
  755.  
  756. AC_DEFUN(AC_FUNC_CLOSEDIR_VOID,
  757. [AC_REQUIRE([AC_HEADER_DIRENT])dnl
  758. AC_CACHE_CHECK(whether closedir returns void, ac_cv_func_closedir_void,
  759. [AC_TRY_RUN([#include <sys/types.h>
  760. #include <$ac_header_dirent>
  761. int closedir(); main() { exit(closedir(opendir(".")) != 0); }],
  762.   ac_cv_func_closedir_void=no, ac_cv_func_closedir_void=yes, ac_cv_func_closedir_void=yes)])
  763. if test $ac_cv_func_closedir_void = yes; then
  764.   AC_DEFINE(CLOSEDIR_VOID)
  765. fi
  766. ])
  767.  
  768. AC_DEFUN(AC_FUNC_MMAP,
  769. [AC_CHECK_FUNCS(valloc getpagesize)
  770. AC_CACHE_CHECK(for working mmap, ac_cv_func_mmap,
  771. [AC_TRY_RUN([
  772. /* Thanks to Mike Haertel and Jim Avera for this test. */
  773. #include <sys/types.h>
  774. #include <fcntl.h>
  775. #include <sys/mman.h>
  776.  
  777. #ifndef HAVE_GETPAGESIZE
  778. # include <sys/param.h>
  779. # ifdef EXEC_PAGESIZE
  780. #  define getpagesize() EXEC_PAGESIZE
  781. # else
  782. #  ifdef NBPG
  783. #   define getpagesize() NBPG * CLSIZE
  784. #   ifndef CLSIZE
  785. #    define CLSIZE 1
  786. #   endif
  787. #  else
  788. #   ifdef NBPC
  789. #    define getpagesize() NBPC
  790. #   else
  791. #    define getpagesize() PAGESIZE /* SVR4 */
  792. #   endif
  793. #  endif
  794. # endif
  795. #endif
  796.  
  797. #ifndef HAVE_VALLOC
  798. # define valloc malloc
  799. #endif
  800.  
  801. #ifdef __cplusplus
  802. extern "C" { void *valloc(unsigned), *malloc(unsigned); }
  803. #else
  804. char *valloc(), *malloc();
  805. #endif
  806.  
  807. int
  808. main()
  809. {
  810.   char *buf1, *buf2, *buf3;
  811.   int i = getpagesize(), j;
  812.   int i2 = i * 2;
  813.   int fd;
  814.  
  815.   buf1 = (char *)valloc(i2);
  816.   buf2 = (char *)valloc(i);
  817.   buf3 = (char *)malloc(i2);
  818.   for (j = 0; j < i2; ++j)
  819.     *(buf1 + j) = rand();
  820.   fd = open("conftestmmap", O_CREAT | O_RDWR, 0666);
  821.   write(fd, buf1, i2);
  822.   mmap(buf2, i, PROT_READ | PROT_WRITE, MAP_FIXED | MAP_PRIVATE, fd, 0);
  823.   for (j = 0; j < i; ++j)
  824.     if (*(buf1 + j) != *(buf2 + j))
  825.       exit(1);
  826.   lseek(fd, (long)i, 0);
  827.   read(fd, buf2, i); /* read into mapped memory -- file should not change */
  828.   /* (it does in i386 SVR4.0 - Jim Avera, jima@netcom.com) */
  829.   lseek(fd, (long)0, 0);
  830.   read(fd, buf3, i2);
  831.   for (j = 0; j < i2; ++j)
  832.     if (*(buf1 + j) != *(buf3 + j))
  833.       exit(1);
  834.   exit(0);
  835. }
  836. ], ac_cv_func_mmap=yes, ac_cv_func_mmap=no, ac_cv_func_mmap=no)])
  837. if test $ac_cv_func_mmap = yes; then
  838.   AC_DEFINE(HAVE_MMAP)
  839. fi
  840. ])
  841.  
  842. AC_DEFUN(AC_FUNC_GETPGRP,
  843. [AC_CACHE_CHECK(whether getpgrp takes no argument, ac_cv_func_getpgrp_void,
  844. [AC_TRY_RUN([
  845. /*
  846.  * If this system has a BSD-style getpgrp(),
  847.  * which takes a pid argument, exit unsuccessfully.
  848.  *
  849.  * Snarfed from Chet Ramey's bash pgrp.c test program
  850.  */
  851. #include <stdio.h>
  852. #include <sys/types.h>
  853.  
  854. int     pid;
  855. int     pg1, pg2, pg3, pg4;
  856. int     ng, np, s, child;
  857.  
  858. main()
  859. {
  860.         pid = getpid();
  861.         pg1 = getpgrp(0);
  862.         pg2 = getpgrp();
  863.         pg3 = getpgrp(pid);
  864.         pg4 = getpgrp(1);
  865.  
  866.         /*
  867.          * If all of these values are the same, it's pretty sure that
  868.          * we're on a system that ignores getpgrp's first argument.
  869.          */
  870.         if (pg2 == pg4 && pg1 == pg3 && pg2 == pg3)
  871.                 exit(0);
  872.  
  873. #ifdef __amigaos__
  874.         child = vfork();
  875. #else
  876.         child = fork();
  877. #endif
  878.         if (child < 0)
  879.                 exit(1);
  880.         else if (child == 0) {
  881.                 np = getpid();
  882.                 /*
  883.                  * If this is Sys V, this will not work; pgrp will be
  884.                  * set to np because setpgrp just changes a pgrp to be
  885.                  * the same as the pid.
  886.                  */
  887.                 setpgrp(np, pg1);
  888.                 ng = getpgrp(0);        /* Same result for Sys V and BSD */
  889.                 if (ng == pg1) {
  890.                         exit(1);
  891.                 } else {
  892.                         exit(0);
  893.                 }
  894.         } else {
  895.                 wait(&s);
  896.                 exit(s>>8);
  897.         }
  898. }
  899. ], ac_cv_func_getpgrp_void=yes, ac_cv_func_getpgrp_void=no,
  900.    AC_MSG_ERROR(cannot check getpgrp if cross compiling))
  901. ])
  902. if test $ac_cv_func_getpgrp_void = yes; then
  903.   AC_DEFINE(GETPGRP_VOID)
  904. fi
  905. ])
  906.  
  907. AC_DEFUN(AC_FUNC_VPRINTF,
  908. [AC_CHECK_FUNC(vprintf, AC_DEFINE(HAVE_VPRINTF))
  909. if test "$ac_cv_func_vprintf" != yes; then
  910. AC_CHECK_FUNC(_doprnt, AC_DEFINE(HAVE_DOPRNT))
  911. fi
  912. ])
  913.  
  914. AC_DEFUN(AC_FUNC_VFORK,
  915. [AC_REQUIRE([AC_TYPE_PID_T])dnl
  916. AC_CHECK_HEADER(vfork.h, AC_DEFINE(HAVE_VFORK_H))
  917. AC_CACHE_CHECK(for working vfork, ac_cv_func_vfork,
  918. [AC_TRY_RUN([/* Thanks to Paul Eggert for this test.  */
  919. #include <stdio.h>
  920. #include <sys/types.h>
  921. #include <sys/stat.h>
  922. #ifdef HAVE_UNISTD_H
  923. #include <unistd.h>
  924. #endif
  925. #ifdef HAVE_VFORK_H
  926. #include <vfork.h>
  927. #endif
  928. /* On some sparc systems, changes by the child to local and incoming
  929.    argument registers are propagated back to the parent.
  930.    The compiler is told about this with #include <vfork.h>,
  931.    but some compilers (e.g. gcc -O) don't grok <vfork.h>.
  932.    Test for this by using a static variable whose address
  933.    is put into a register that is clobbered by the vfork.  */
  934. static
  935. #ifdef __cplusplus
  936. sparc_address_test (int arg)
  937. #else
  938. sparc_address_test (arg) int arg;
  939. #endif
  940. {
  941.   static pid_t child;
  942.   if (!child) {
  943.     child = vfork ();
  944.     if (child < 0)
  945.       perror ("vfork");
  946.     if (!child) {
  947.       arg = getpid();
  948.       write(-1, "", 0);
  949.       _exit (arg);
  950.     }
  951.   }
  952. }
  953. main() {
  954.   pid_t parent = getpid ();
  955.   pid_t child;
  956.  
  957.   sparc_address_test ();
  958.  
  959. #ifdef __amigaos__
  960.   /* Force this test to succeed for AmigaOS, which has a fairly good
  961.      vfork() emulation, but doesn't support fork() at all.  -fnf */
  962.   exit (0);
  963. #endif
  964.  
  965.   child = vfork ();
  966.  
  967.   if (child == 0) {
  968.     /* Here is another test for sparc vfork register problems.
  969.        This test uses lots of local variables, at least
  970.        as many local variables as main has allocated so far
  971.        including compiler temporaries.  4 locals are enough for
  972.        gcc 1.40.3 on a Solaris 4.1.3 sparc, but we use 8 to be safe.
  973.        A buggy compiler should reuse the register of parent
  974.        for one of the local variables, since it will think that
  975.        parent can't possibly be used any more in this routine.
  976.        Assigning to the local variable will thus munge parent
  977.        in the parent process.  */
  978.     pid_t
  979.       p = getpid(), p1 = getpid(), p2 = getpid(), p3 = getpid(),
  980.       p4 = getpid(), p5 = getpid(), p6 = getpid(), p7 = getpid();
  981.     /* Convince the compiler that p..p7 are live; otherwise, it might
  982.        use the same hardware register for all 8 local variables.  */
  983.     if (p != p1 || p != p2 || p != p3 || p != p4
  984.     || p != p5 || p != p6 || p != p7)
  985.       _exit(1);
  986.  
  987.     /* On some systems (e.g. IRIX 3.3),
  988.        vfork doesn't separate parent from child file descriptors.
  989.        If the child closes a descriptor before it execs or exits,
  990.        this munges the parent's descriptor as well.
  991.        Test for this by closing stdout in the child.  */
  992.     _exit(close(fileno(stdout)) != 0);
  993.   } else {
  994.     int status;
  995.     struct stat st;
  996.  
  997.     while (wait(&status) != child)
  998.       ;
  999.     exit(
  1000.      /* Was there some problem with vforking?  */
  1001.      child < 0
  1002.  
  1003.      /* Did the child fail?  (This shouldn't happen.)  */
  1004.      || status
  1005.  
  1006.      /* Did the vfork/compiler bug occur?  */
  1007.      || parent != getpid()
  1008.  
  1009.      /* Did the file descriptor bug occur?  */
  1010.      || fstat(fileno(stdout), &st) != 0
  1011.      );
  1012.   }
  1013. }],
  1014. ac_cv_func_vfork=yes, ac_cv_func_vfork=no, AC_CHECK_FUNC(vfork))])
  1015. if test $ac_cv_func_vfork = no; then
  1016.   AC_DEFINE(vfork, fork)
  1017. fi
  1018. ])
  1019.  
  1020. AC_DEFUN(AC_FUNC_WAIT3,
  1021. [AC_CACHE_CHECK(for wait3 that fills in rusage, ac_cv_func_wait3_rsuage,
  1022. [AC_TRY_RUN([#include <sys/types.h>
  1023. #include <sys/time.h>
  1024. #include <sys/resource.h>
  1025. #include <stdio.h>
  1026. /* HP-UX has wait3 but does not fill in rusage at all.  */
  1027. main() {
  1028.   struct rusage r;
  1029.   int i;
  1030.   /* Use a field that we can force nonzero --
  1031.      voluntary context switches.
  1032.      For systems like NeXT and OSF/1 that don't set it,
  1033.      also use the system CPU time.  And page faults (I/O) for Linux.  */
  1034.   r.ru_nvcsw = 0;
  1035.   r.ru_stime.tv_sec = 0;
  1036.   r.ru_stime.tv_usec = 0;
  1037.   r.ru_majflt = r.ru_minflt = 0;
  1038. #ifdef __amigaos__
  1039.   switch (vfork()) {
  1040. #else
  1041.   switch (fork()) {
  1042. #endif
  1043.   case 0: /* Child.  */
  1044.     sleep(1); /* Give up the CPU.  */
  1045.     _exit(0);
  1046.   case -1: _exit(0); /* What can we do?  */
  1047.   default: /* Parent.  */
  1048.     wait3(&i, 0, &r);
  1049.     sleep(2); /* Avoid "text file busy" from rm on fast HP-UX machines.  */
  1050.     exit(r.ru_nvcsw == 0 && r.ru_majflt == 0 && r.ru_minflt == 0
  1051.      && r.ru_stime.tv_sec == 0 && r.ru_stime.tv_usec == 0);
  1052.   }
  1053. }], ac_cv_func_wait3_rsuage=yes, ac_cv_func_wait3_rsuage=no, ac_cv_func_wait3_rsuage=no)])
  1054. if test $ac_cv_func_wait3_rsuage = yes; then
  1055.   AC_DEFINE(HAVE_WAIT3)
  1056. fi
  1057. ])
  1058.  
  1059. AC_DEFUN(AC_FUNC_ALLOCA,
  1060. [AC_REQUIRE_CPP()dnl Set CPP; we run AC_EGREP_CPP conditionally.
  1061. # The Ultrix 4.2 mips builtin alloca declared by alloca.h only works
  1062. # for constant arguments.  Useless!
  1063. AC_CACHE_CHECK([for working alloca.h], ac_cv_header_alloca_h,
  1064. [AC_TRY_LINK([#include <alloca.h>], [char *p = alloca(2 * sizeof(int));],
  1065.   ac_cv_header_alloca_h=yes, ac_cv_header_alloca_h=no)])
  1066. if test $ac_cv_header_alloca_h = yes; then
  1067.   AC_DEFINE(HAVE_ALLOCA_H)
  1068. fi
  1069.  
  1070. AC_CACHE_CHECK([for alloca], ac_cv_func_alloca,
  1071. [AC_TRY_LINK([
  1072. #ifdef __GNUC__
  1073. # define alloca __builtin_alloca
  1074. #else
  1075. # if HAVE_ALLOCA_H
  1076. #  include <alloca.h>
  1077. # else
  1078. #  ifdef _AIX
  1079.  #pragma alloca
  1080. #  else
  1081. #   ifndef alloca /* predefined by HP cc +Olibcalls */
  1082. char *alloca ();
  1083. #   endif
  1084. #  endif
  1085. # endif
  1086. #endif
  1087. ], [char *p = (char *) alloca(1);],
  1088.   ac_cv_func_alloca=yes, ac_cv_func_alloca=no)])
  1089. if test $ac_cv_func_alloca = yes; then
  1090.   AC_DEFINE(HAVE_ALLOCA)
  1091. fi
  1092.  
  1093. if test $ac_cv_func_alloca = no; then
  1094.   # The SVR3 libPW and SVR4 libucb both contain incompatible functions
  1095.   # that cause trouble.  Some versions do not even contain alloca or
  1096.   # contain a buggy version.  If you still want to use their alloca,
  1097.   # use ar to extract alloca.o from them instead of compiling alloca.c.
  1098.   ALLOCA=alloca.o
  1099.   AC_DEFINE(C_ALLOCA)
  1100.  
  1101. AC_CACHE_CHECK(whether alloca needs Cray hooks, ac_cv_os_cray,
  1102. [AC_EGREP_CPP(webecray,
  1103. [#if defined(CRAY) && ! defined(CRAY2)
  1104. webecray
  1105. #else
  1106. wenotbecray
  1107. #endif
  1108. ], ac_cv_os_cray=yes, ac_cv_os_cray=no)])
  1109. if test $ac_cv_os_cray = yes; then
  1110. for ac_func in _getb67 GETB67 getb67; do
  1111.   AC_CHECK_FUNC($ac_func, [AC_DEFINE_UNQUOTED(CRAY_STACKSEG_END, $ac_func)
  1112.   break])
  1113. done
  1114. fi
  1115.  
  1116. AC_CACHE_CHECK(stack direction for C alloca, ac_cv_c_stack_direction,
  1117. [AC_TRY_RUN([find_stack_direction ()
  1118. {
  1119.   static char *addr = 0;
  1120.   auto char dummy;
  1121.   if (addr == 0)
  1122.     {
  1123.       addr = &dummy;
  1124.       return find_stack_direction ();
  1125.     }
  1126.   else
  1127.     return (&dummy > addr) ? 1 : -1;
  1128. }
  1129. main ()
  1130. {
  1131.   exit (find_stack_direction() < 0);
  1132. }], ac_cv_c_stack_direction=1, ac_cv_c_stack_direction=-1,
  1133.   ac_cv_c_stack_direction=0)])
  1134. AC_DEFINE_UNQUOTED(STACK_DIRECTION, $ac_cv_c_stack_direction)
  1135. fi
  1136. AC_SUBST(ALLOCA)dnl
  1137. ])
  1138.  
  1139. AC_DEFUN(AC_FUNC_GETLOADAVG,
  1140. [ac_have_func=no # yes means we've found a way to get the load average.
  1141.  
  1142. # Some systems with -lutil have (and need) -lkvm as well, some do not.
  1143. # On Solaris, -lkvm requires nlist from -lelf, so check that first
  1144. # to get the right answer into the cache.
  1145. AC_CHECK_LIB(elf, elf_begin, LIBS="-lelf $LIBS")
  1146. AC_CHECK_LIB(kvm, kvm_open, LIBS="-lkvm $LIBS")
  1147. # Check for the 4.4BSD definition of getloadavg.
  1148. AC_CHECK_LIB(util, getloadavg,
  1149.   [LIBS="-lutil $LIBS" ac_have_func=yes ac_cv_func_getloadavg_setgid=yes])
  1150.  
  1151. if test $ac_have_func = no; then
  1152.   # There is a commonly available library for RS/6000 AIX.
  1153.   # Since it is not a standard part of AIX, it might be installed locally.
  1154.   ac_save_LIBS="$LIBS" LIBS="-L/local/lib $LIBS"
  1155.   AC_CHECK_LIB(getloadavg, getloadavg,
  1156.     LIBS="-lgetloadavg $LIBS", LIBS="$ac_save_LIBS")
  1157. fi
  1158.  
  1159. # Make sure it is really in the library, if we think we found it.
  1160. AC_REPLACE_FUNCS(getloadavg)
  1161.  
  1162. if test $ac_cv_func_getloadavg = yes; then
  1163.   AC_DEFINE(HAVE_GETLOADAVG)
  1164.   ac_have_func=yes
  1165. else
  1166.   # Figure out what our getloadavg.c needs.
  1167.   ac_have_func=no
  1168.   AC_CHECK_HEADER(sys/dg_sys_info.h,
  1169.   [ac_have_func=yes; AC_DEFINE(DGUX)
  1170.   AC_CHECK_LIB(dgc, dg_sys_info)])
  1171.  
  1172.   # We cannot check for <dwarf.h>, because Solaris 2 does not use dwarf (it
  1173.   # uses stabs), but it is still SVR4.  We cannot check for <elf.h> because
  1174.   # Irix 4.0.5F has the header but not the library.
  1175.   if test $ac_have_func = no && test $ac_cv_lib_elf_elf_begin = yes; then
  1176.     ac_have_func=yes; AC_DEFINE(SVR4)
  1177.   fi
  1178.  
  1179.   if test $ac_have_func = no; then
  1180.     AC_CHECK_HEADER(inq_stats/cpustats.h,
  1181.     [ac_have_func=yes; AC_DEFINE(UMAX)
  1182.     AC_DEFINE(UMAX4_3)])
  1183.   fi
  1184.  
  1185.   if test $ac_have_func = no; then
  1186.     AC_CHECK_HEADER(sys/cpustats.h,
  1187.     [ac_have_func=yes; AC_DEFINE(UMAX)])
  1188.   fi
  1189.  
  1190.   if test $ac_have_func = no; then
  1191.     AC_CHECK_HEADERS(mach/mach.h)
  1192.   fi
  1193.  
  1194.   AC_CHECK_HEADER(nlist.h,
  1195.   [AC_DEFINE(NLIST_STRUCT)
  1196.   AC_CACHE_CHECK([for n_un in struct nlist], ac_cv_struct_nlist_n_un,
  1197.   [AC_TRY_COMPILE([#include <nlist.h>],
  1198.   [struct nlist n; n.n_un.n_name = 0;],
  1199.   ac_cv_struct_nlist_n_un=yes, ac_cv_struct_nlist_n_un=no)])
  1200.   if test $ac_cv_struct_nlist_n_un = yes; then
  1201.     AC_DEFINE(NLIST_NAME_UNION)
  1202.   fi
  1203.   ])dnl
  1204. fi # Do not have getloadavg in system libraries.
  1205.  
  1206. # Some definitions of getloadavg require that the program be installed setgid.
  1207. dnl FIXME Don't hardwire the path of getloadavg.c in the top-level directory.
  1208. AC_CACHE_CHECK(whether getloadavg requires setgid,
  1209.   ac_cv_func_getloadavg_setgid,
  1210. [AC_EGREP_CPP([Yowza Am I SETGID yet],
  1211. [#include "$srcdir/getloadavg.c"
  1212. #ifdef LDAV_PRIVILEGED
  1213. Yowza Am I SETGID yet
  1214. #endif],
  1215.   ac_cv_func_getloadavg_setgid=yes, ac_cv_func_getloadavg_setgid=no)])
  1216. if test $ac_cv_func_getloadavg_setgid = yes; then
  1217.   NEED_SETGID=true; AC_DEFINE(GETLOADAVG_PRIVILEGED)
  1218. else
  1219.   NEED_SETGID=false
  1220. fi
  1221. AC_SUBST(NEED_SETGID)dnl
  1222.  
  1223. if test $ac_cv_func_getloadavg_setgid = yes; then
  1224.   AC_CACHE_CHECK(group of /dev/kmem, ac_cv_group_kmem,
  1225. [changequote(, )dnl
  1226.   # On Solaris, /dev/kmem is a symlink.  Get info on the real file.
  1227.   ac_ls_output=`ls -lgL /dev/kmem 2>/dev/null`
  1228.   # If we got an error (system does not support symlinks), try without -L.
  1229.   test -z "$ac_ls_output" && ac_ls_output=`ls -lg /dev/kmem`
  1230.   ac_cv_group_kmem=`echo $ac_ls_output \
  1231.     | sed -ne 's/[     ][     ]*/ /g;
  1232.            s/^.[sSrwx-]* *[0-9]* *\([^0-9]*\)  *.*/\1/;
  1233.            / /s/.* //;p;'`
  1234. changequote([, ])dnl
  1235. ])
  1236.   KMEM_GROUP=$ac_cv_group_kmem
  1237. fi
  1238. AC_SUBST(KMEM_GROUP)dnl
  1239. ])
  1240.  
  1241. AC_DEFUN(AC_FUNC_UTIME_NULL,
  1242. [AC_CACHE_CHECK(whether utime accepts a null argument, ac_cv_func_utime_null,
  1243. [rm -f conftestdata; > conftestdata
  1244. # Sequent interprets utime(file, 0) to mean use start of epoch.  Wrong.
  1245. AC_TRY_RUN([#include <sys/types.h>
  1246. #include <sys/stat.h>
  1247. main() {
  1248. struct stat s, t;
  1249. exit(!(stat ("conftestdata", &s) == 0 && utime("conftestdata", (long *)0) == 0
  1250. && stat("conftestdata", &t) == 0 && t.st_mtime >= s.st_mtime
  1251. && t.st_mtime - s.st_mtime < 120));
  1252. }], ac_cv_func_utime_null=yes, ac_cv_func_utime_null=no,
  1253.   ac_cv_func_utime_null=no)
  1254. rm -f core core.* *.core])
  1255. if test $ac_cv_func_utime_null = yes; then
  1256.   AC_DEFINE(HAVE_UTIME_NULL)
  1257. fi
  1258. ])
  1259.  
  1260. AC_DEFUN(AC_FUNC_STRCOLL,
  1261. [AC_CACHE_CHECK(for strcoll, ac_cv_func_strcoll,
  1262. [AC_TRY_RUN([#include <string.h>
  1263. main ()
  1264. {
  1265.   exit (strcoll ("abc", "def") >= 0 ||
  1266.     strcoll ("ABC", "DEF") >= 0 ||
  1267.     strcoll ("123", "456") >= 0);
  1268. }], ac_cv_func_strcoll=yes, ac_cv_func_strcoll=no, ac_cv_func_strcoll=no)])
  1269. if test $ac_cv_func_strcoll = yes; then
  1270.   AC_DEFINE(HAVE_STRCOLL)
  1271. fi
  1272. ])
  1273.  
  1274. AC_DEFUN(AC_FUNC_SETVBUF_REVERSED,
  1275. [AC_CACHE_CHECK(whether setvbuf arguments are reversed,
  1276.   ac_cv_func_setvbuf_reversed,
  1277. [AC_TRY_RUN([#include <stdio.h>
  1278. /* If setvbuf has the reversed format, exit 0. */
  1279. main () {
  1280. #ifdef __amigaos__
  1281.   /* AmigaOS is a non-reversed system.  Instead of the test program
  1282.      getting a segfault (no memory protection), it causes enforcer hits
  1283.      or other nastiness, so don't run the test program, just exit with
  1284.      status 1 to indicate that it is non-reversed.  -fnf */
  1285.   exit(1);
  1286. #endif
  1287.   /* This call has the arguments reversed.
  1288.      A reversed system may check and see that the address of main
  1289.      is not _IOLBF, _IONBF, or _IOFBF, and return nonzero.  */
  1290.   if (setvbuf(stdout, _IOLBF, (char *) main, BUFSIZ) != 0)
  1291.     exit(1);
  1292.   putc('\r', stdout);
  1293.   exit(0);            /* Non-reversed systems segv here.  */
  1294. }], ac_cv_func_setvbuf_reversed=yes, ac_cv_func_setvbuf_reversed=no)
  1295. rm -f core core.* *.core])
  1296. if test $ac_cv_func_setvbuf_reversed = yes; then
  1297.   AC_DEFINE(SETVBUF_REVERSED)
  1298. fi
  1299. ])
  1300.  
  1301. AC_DEFUN(AC_FUNC_GETMNTENT,
  1302. [# getmntent is in -lsun on Irix 4, -lseq on Dynix/PTX, -lgen on Unixware.
  1303. AC_CHECK_LIB(sun, getmntent, LIBS="-lsun $LIBS",
  1304.   [AC_CHECK_LIB(seq, getmntent, LIBS="-lseq $LIBS",
  1305.     [AC_CHECK_LIB(gen, getmntent, LIBS="-lgen $LIBS")])])
  1306. AC_CHECK_FUNC(getmntent, [AC_DEFINE(HAVE_GETMNTENT)])])
  1307.  
  1308. AC_DEFUN(AC_FUNC_STRFTIME,
  1309. [# strftime is in -lintl on SCO UNIX.
  1310. AC_CHECK_LIB(intl, strftime, LIBS="-lintl $LIBS")
  1311. AC_CHECK_FUNC(strftime, [AC_DEFINE(HAVE_STRFTIME)])])
  1312.  
  1313. AC_DEFUN(AC_FUNC_MEMCMP,
  1314. [AC_CACHE_CHECK(for 8-bit clean memcmp, ac_cv_func_memcmp,
  1315. [AC_TRY_RUN([
  1316. main()
  1317. {
  1318.   char c0 = 0x40, c1 = 0x80, c2 = 0x81;
  1319.   exit(memcmp(&c0, &c2, 1) < 0 && memcmp(&c1, &c2, 1) < 0 ? 0 : 1);
  1320. }
  1321. ], ac_cv_func_memcmp=yes, ac_cv_func_memcmp=no, ac_cv_func_memcmp=no)])
  1322. test $ac_cv_func_memcmp = no && LIBOBJS="$LIBOBJS memcmp.o"
  1323. AC_SUBST(LIBOBJS)dnl
  1324. ])
  1325.  
  1326.  
  1327. dnl ### Checks for structure members
  1328.  
  1329.  
  1330. AC_DEFUN(AC_HEADER_TIME,
  1331. [AC_CACHE_CHECK([whether time.h and sys/time.h may both be included],
  1332.   ac_cv_header_time,
  1333. [AC_TRY_COMPILE([#include <sys/types.h>
  1334. #include <sys/time.h>
  1335. #include <time.h>],
  1336. [struct tm *tp;], ac_cv_header_time=yes, ac_cv_header_time=no)])
  1337. if test $ac_cv_header_time = yes; then
  1338.   AC_DEFINE(TIME_WITH_SYS_TIME)
  1339. fi
  1340. ])
  1341.  
  1342. AC_DEFUN(AC_STRUCT_TM,
  1343. [AC_CACHE_CHECK([whether struct tm is in sys/time.h or time.h],
  1344.   ac_cv_struct_tm,
  1345. [AC_TRY_COMPILE([#include <sys/types.h>
  1346. #include <time.h>],
  1347. [struct tm *tp; tp->tm_sec;],
  1348.   ac_cv_struct_tm=time.h, ac_cv_struct_tm=sys/time.h)])
  1349. if test $ac_cv_struct_tm = sys/time.h; then
  1350.   AC_DEFINE(TM_IN_SYS_TIME)
  1351. fi
  1352. ])
  1353.  
  1354. AC_DEFUN(AC_STRUCT_TIMEZONE,
  1355. [AC_REQUIRE([AC_STRUCT_TM])dnl
  1356. AC_CACHE_CHECK([for tm_zone in struct tm], ac_cv_struct_tm_zone,
  1357. [AC_TRY_COMPILE([#include <sys/types.h>
  1358. #include <$ac_cv_struct_tm>], [struct tm tm; tm.tm_zone;],
  1359.   ac_cv_struct_tm_zone=yes, ac_cv_struct_tm_zone=no)])
  1360. if test "$ac_cv_struct_tm_zone" = yes; then
  1361.   AC_DEFINE(HAVE_TM_ZONE)
  1362. else
  1363.   AC_CACHE_CHECK(for tzname, ac_cv_var_tzname,
  1364. [AC_TRY_LINK(
  1365. changequote(<<, >>)dnl
  1366. <<#include <time.h>
  1367. #ifndef tzname /* For SGI.  */
  1368. extern char *tzname[]; /* RS6000 and others reject char **tzname.  */
  1369. #endif>>,
  1370. changequote([, ])dnl
  1371. [atoi(*tzname);], ac_cv_var_tzname=yes, ac_cv_var_tzname=no)])
  1372.   if test $ac_cv_var_tzname = yes; then
  1373.     AC_DEFINE(HAVE_TZNAME)
  1374.   fi
  1375. fi
  1376. ])
  1377.  
  1378. AC_DEFUN(AC_STRUCT_ST_BLOCKS,
  1379. [AC_CACHE_CHECK([for st_blocks in struct stat], ac_cv_struct_st_blocks,
  1380. [AC_TRY_COMPILE([#include <sys/types.h>
  1381. #include <sys/stat.h>], [struct stat s; s.st_blocks;],
  1382. ac_cv_struct_st_blocks=yes, ac_cv_struct_st_blocks=no)])
  1383. if test $ac_cv_struct_st_blocks = yes; then
  1384.   AC_DEFINE(HAVE_ST_BLOCKS)
  1385. else
  1386.   LIBOBJS="$LIBOBJS fileblocks.o"
  1387. fi
  1388. AC_SUBST(LIBOBJS)dnl
  1389. ])
  1390.  
  1391. AC_DEFUN(AC_STRUCT_ST_BLKSIZE,
  1392. [AC_CACHE_CHECK([for st_blksize in struct stat], ac_cv_struct_st_blksize,
  1393. [AC_TRY_COMPILE([#include <sys/types.h>
  1394. #include <sys/stat.h>], [struct stat s; s.st_blksize;],
  1395. ac_cv_struct_st_blksize=yes, ac_cv_struct_st_blksize=no)])
  1396. if test $ac_cv_struct_st_blksize = yes; then
  1397.   AC_DEFINE(HAVE_ST_BLKSIZE)
  1398. fi
  1399. ])
  1400.  
  1401. AC_DEFUN(AC_STRUCT_ST_RDEV,
  1402. [AC_CACHE_CHECK([for st_rdev in struct stat], ac_cv_struct_st_rdev,
  1403. [AC_TRY_COMPILE([#include <sys/types.h>
  1404. #include <sys/stat.h>], [struct stat s; s.st_rdev;],
  1405. ac_cv_struct_st_rdev=yes, ac_cv_struct_st_rdev=no)])
  1406. if test $ac_cv_struct_st_rdev = yes; then
  1407.   AC_DEFINE(HAVE_ST_RDEV)
  1408. fi
  1409. ])
  1410.  
  1411.  
  1412. dnl ### Checks for compiler characteristics
  1413.  
  1414.  
  1415. AC_DEFUN(AC_C_CROSS,
  1416. [# If we cannot run a trivial program, we must be cross compiling.
  1417. AC_CACHE_CHECK(whether cross-compiling, ac_cv_c_cross,
  1418. [AC_TRY_RUN([main(){return(0);}],
  1419.   ac_cv_c_cross=no, ac_cv_c_cross=yes, ac_cv_c_cross=yes)])
  1420. cross_compiling=$ac_cv_c_cross
  1421. ])
  1422.  
  1423. AC_DEFUN(AC_C_CHAR_UNSIGNED,
  1424. [AC_CACHE_CHECK(whether char is unsigned, ac_cv_c_char_unsigned,
  1425. [if test "$GCC" = yes; then
  1426.   # GCC predefines this symbol on systems where it applies.
  1427. AC_EGREP_CPP(yes,
  1428. [#ifdef __CHAR_UNSIGNED__
  1429.   yes
  1430. #endif
  1431. ], ac_cv_c_char_unsigned=yes, ac_cv_c_char_unsigned=no)
  1432. else
  1433. AC_TRY_RUN(
  1434. [/* volatile prevents gcc2 from optimizing the test away on sparcs.  */
  1435. #if !defined(__STDC__) || __STDC__ != 1
  1436. #define volatile
  1437. #endif
  1438. main() {
  1439.   volatile char c = 255; exit(c < 0);
  1440. }], ac_cv_c_char_unsigned=yes, ac_cv_c_char_unsigned=no)
  1441. fi])
  1442. if test $ac_cv_c_char_unsigned = yes && test "$GCC" != yes; then
  1443.   AC_DEFINE(__CHAR_UNSIGNED__)
  1444. fi
  1445. ])
  1446.  
  1447. AC_DEFUN(AC_C_LONG_DOUBLE,
  1448. [AC_CACHE_CHECK(for long double, ac_cv_c_long_double,
  1449. [if test "$GCC" = yes; then
  1450.   ac_cv_c_long_double=yes
  1451. else
  1452. AC_TRY_RUN([int main() {
  1453. /* The Stardent Vistra knows sizeof(long double), but does not support it.  */
  1454. long double foo = 0.0;
  1455. /* On Ultrix 4.3 cc, long double is 4 and double is 8.  */
  1456. exit(sizeof(long double) < sizeof(double)); }],
  1457. ac_cv_c_long_double=yes, ac_cv_c_long_double=no)
  1458. fi])
  1459. if test $ac_cv_c_long_double = yes; then
  1460.   AC_DEFINE(HAVE_LONG_DOUBLE)
  1461. fi
  1462. ])
  1463.  
  1464. AC_DEFUN(AC_INT_16_BITS,
  1465. [AC_OBSOLETE([$0], [; instead use AC_CHECK_SIZEOF(int)])dnl
  1466. AC_MSG_CHECKING(whether int is 16 bits)
  1467. AC_TRY_RUN([main() { exit(sizeof(int) != 2); }],
  1468.  [AC_MSG_RESULT(yes)
  1469.  AC_DEFINE(INT_16_BITS)], AC_MSG_RESULT(no))
  1470. ])
  1471.  
  1472. AC_DEFUN(AC_LONG_64_BITS,
  1473. [AC_OBSOLETE([$0], [; instead use AC_CHECK_SIZEOF(long)])dnl
  1474. AC_MSG_CHECKING(whether long int is 64 bits)
  1475. AC_TRY_RUN([main() { exit(sizeof(long int) != 8); }],
  1476.  [AC_MSG_RESULT(yes)
  1477.  AC_DEFINE(LONG_64_BITS)], AC_MSG_RESULT(no))
  1478. ])
  1479.  
  1480. AC_DEFUN(AC_C_BIGENDIAN,
  1481. [AC_CACHE_CHECK(whether byte ordering is bigendian, ac_cv_c_bigendian,
  1482. [ac_cv_c_bigendian=unknown
  1483. # See if sys/param.h defines the BYTE_ORDER macro.
  1484. AC_TRY_COMPILE([#include <sys/types.h>
  1485. #include <sys/param.h>], [
  1486. #if !BYTE_ORDER || !BIG_ENDIAN || !LITTLE_ENDIAN
  1487.  bogus endian macros
  1488. #endif], [# It does; now see whether it defined to BIG_ENDIAN or not.
  1489. AC_TRY_COMPILE([#include <sys/types.h>
  1490. #include <sys/param.h>], [
  1491. #if BYTE_ORDER != BIG_ENDIAN
  1492.  not big endian
  1493. #endif], ac_cv_c_bigendian=yes, ac_cv_c_bigendian=no)])
  1494. if test $ac_cv_c_bigendian = unknown; then
  1495. AC_TRY_RUN([main () {
  1496.   /* Are we little or big endian?  From Harbison&Steele.  */
  1497.   union
  1498.   {
  1499.     long l;
  1500.     char c[sizeof (long)];
  1501.   } u;
  1502.   u.l = 1;
  1503.   exit (u.c[sizeof (long) - 1] == 1);
  1504. }], ac_cv_c_bigendian=no, ac_cv_c_bigendian=yes)
  1505. fi])
  1506. if test $ac_cv_c_bigendian = yes; then
  1507.   AC_DEFINE(WORDS_BIGENDIAN)
  1508. fi
  1509. ])
  1510.  
  1511. dnl Do nothing if the compiler accepts the inline keyword.
  1512. dnl Otherwise define inline to __inline__ or __inline if one of those work,
  1513. dnl otherwise define inline to be empty.
  1514. AC_DEFUN(AC_C_INLINE,
  1515. [AC_CACHE_CHECK([for inline], ac_cv_c_inline,
  1516. [ac_cv_c_inline=no
  1517. for ac_kw in inline __inline__ __inline; do
  1518.   AC_TRY_COMPILE(, [} $ac_kw foo() {], [ac_cv_c_inline=$ac_kw; break])
  1519. done
  1520. ])
  1521. case "$ac_cv_c_inline" in
  1522.   inline | yes) ;;
  1523.   no) AC_DEFINE(inline, ) ;;
  1524.   *)  AC_DEFINE_UNQUOTED(inline, $ac_cv_c_inline) ;;
  1525. esac
  1526. ])
  1527.  
  1528. AC_DEFUN(AC_C_CONST,
  1529. [dnl This message is consistent in form with the other checking messages,
  1530. dnl and with the result message.
  1531. AC_CACHE_CHECK([for working const], ac_cv_c_const,
  1532. [AC_TRY_COMPILE(,
  1533. changequote(<<, >>)dnl
  1534. <<
  1535. /* Ultrix mips cc rejects this.  */
  1536. typedef int charset[2]; const charset x;
  1537. /* SunOS 4.1.1 cc rejects this.  */
  1538. char const *const *ccp;
  1539. char **p;
  1540. /* NEC SVR4.0.2 mips cc rejects this.  */
  1541. struct point {int x, y;};
  1542. static struct point const zero = {0,0};
  1543. /* AIX XL C 1.02.0.0 rejects this.
  1544.    It does not let you subtract one const X* pointer from another in an arm
  1545.    of an if-expression whose if-part is not a constant expression */
  1546. const char *g = "string";
  1547. ccp = &g + (g ? g-g : 0);
  1548. /* HPUX 7.0 cc rejects these. */
  1549. ++ccp;
  1550. p = (char**) ccp;
  1551. ccp = (char const *const *) p;
  1552. { /* SCO 3.2v4 cc rejects this.  */
  1553.   char *t;
  1554.   char const *s = 0 ? (char *) 0 : (char const *) 0;
  1555.  
  1556.   *t++ = 0;
  1557. }
  1558. { /* Someone thinks the Sun supposedly-ANSI compiler will reject this.  */
  1559.   int x[] = {25, 17};
  1560.   const int *foo = &x[0];
  1561.   ++foo;
  1562. }
  1563. { /* Sun SC1.0 ANSI compiler rejects this -- but not the above. */
  1564.   typedef const int *iptr;
  1565.   iptr p = 0;
  1566.   ++p;
  1567. }
  1568. { /* AIX XL C 1.02.0.0 rejects this saying
  1569.      "k.c", line 2.27: 1506-025 (S) Operand must be a modifiable lvalue. */
  1570.   struct s { int j; const int *ap[3]; };
  1571.   struct s *b; b->j = 5;
  1572. }
  1573. { /* ULTRIX-32 V3.1 (Rev 9) vcc rejects this */
  1574.   const int foo = 10;
  1575. }
  1576. >>,
  1577. changequote([, ])dnl
  1578. ac_cv_c_const=yes, ac_cv_c_const=no)])
  1579. if test $ac_cv_c_const = no; then
  1580.   AC_DEFINE(const, )
  1581. fi
  1582. ])
  1583.  
  1584. define(AC_ARG_ARRAY,
  1585. [errprint(__file__:__line__: [$0] has been removed; don't do unportable things with arguments
  1586. )m4exit(4)])
  1587.  
  1588.  
  1589. dnl ### Checks for operating system services
  1590.  
  1591.  
  1592. AC_DEFUN(AC_SYS_INTERPRETER,
  1593. [# Pull the hash mark out of the macro call to avoid m4 problems.
  1594. ac_msg="whether #! works in shell scripts"
  1595. AC_CACHE_CHECK($ac_msg, ac_cv_sys_interpreter,
  1596. [echo '#! /bin/cat
  1597. exit 69
  1598. ' > conftest
  1599. chmod u+x conftest
  1600. (SHELL=/bin/sh; export SHELL; ./conftest >/dev/null)
  1601. if test $? -ne 69; then
  1602.    ac_cv_sys_interpreter=yes
  1603. else
  1604.    ac_cv_sys_interpreter=no
  1605. fi
  1606. rm -f conftest])
  1607. ])
  1608.  
  1609. define(AC_HAVE_POUNDBANG,
  1610. [errprint(__file__:__line__: [$0 has been replaced by AC_SYS_INTERPRETER, taking no arguments
  1611. ])m4exit(4)])
  1612.  
  1613. AC_DEFUN(AC_SYS_LONG_FILE_NAMES,
  1614. [AC_CACHE_CHECK(for long file names, ac_cv_sys_long_file_names,
  1615. [ac_cv_sys_long_file_names=yes
  1616. # Test for long file names in all the places we know might matter:
  1617. #      .        the current directory, where building will happen
  1618. #      /tmp        where it might want to write temporary files
  1619. #      /var/tmp        likewise
  1620. #      /usr/tmp        likewise
  1621. #      $prefix/lib    where we will be installing things
  1622. #      $exec_prefix/lib    likewise
  1623. # eval it to expand exec_prefix.
  1624. for ac_dir in `eval echo . /tmp /var/tmp /usr/tmp $prefix/lib $exec_prefix/lib` ; do
  1625.   test -d $ac_dir || continue
  1626.   test -w $ac_dir || continue # It is less confusing to not echo anything here.
  1627.   (echo 1 > $ac_dir/conftest9012345) 2>/dev/null
  1628.   (echo 2 > $ac_dir/conftest9012346) 2>/dev/null
  1629.   val=`cat $ac_dir/conftest9012345 2>/dev/null`
  1630.   if test ! -f $ac_dir/conftest9012345 || test "$val" != 1; then
  1631.     ac_cv_sys_long_file_names=no
  1632.     rm -f $ac_dir/conftest9012345 $ac_dir/conftest9012346 2>/dev/null
  1633.     break
  1634.   fi
  1635.   rm -f $ac_dir/conftest9012345 $ac_dir/conftest9012346 2>/dev/null
  1636. done])
  1637. if test $ac_cv_sys_long_file_names = yes; then
  1638.   AC_DEFINE(HAVE_LONG_FILE_NAMES)
  1639. fi
  1640. ])
  1641.  
  1642. AC_DEFUN(AC_SYS_RESTARTABLE_SYSCALLS,
  1643. [AC_CACHE_CHECK(for restartable system calls, ac_cv_sys_restartable_syscalls,
  1644. [AC_TRY_RUN(
  1645. [/* Exit 0 (true) if wait returns something other than -1,
  1646.    i.e. the pid of the child, which means that wait was restarted
  1647.    after getting the signal.  */
  1648. #include <sys/types.h>
  1649. #include <signal.h>
  1650. ucatch (isig) { }
  1651. main () {
  1652. #ifdef __amigaos__
  1653.   int i = vfork (), status;
  1654. #else
  1655.   int i = fork (), status;
  1656. #endif
  1657.   if (i == 0) { sleep (3); kill (getppid (), SIGINT); sleep (3); exit (0); }
  1658.   signal (SIGINT, ucatch);
  1659.   status = wait(&i);
  1660.   if (status == -1) wait(&i);
  1661.   exit (status == -1);
  1662. }
  1663. ], ac_cv_sys_restartable_syscalls=yes, ac_cv_sys_restartable_syscalls=no)])
  1664. if test $ac_cv_sys_restartable_syscalls = yes; then
  1665.   AC_DEFINE(HAVE_RESTARTABLE_SYSCALLS)
  1666. fi
  1667. ])
  1668.  
  1669. AC_DEFUN(AC_PATH_X,
  1670. [AC_REQUIRE_CPP()dnl Set CPP; we run AC_PATH_X_DIRECT conditionally.
  1671. # If we find X, set shell vars x_includes and x_libraries to the
  1672. # paths, otherwise set no_x=yes.
  1673. # Uses ac_ vars as temps to allow command line to override cache and checks.
  1674. # --without-x overrides everything else, but does not touch the cache.
  1675. AC_MSG_CHECKING(for X)
  1676.  
  1677. AC_ARG_WITH(x, [  --with-x                use the X Window System])
  1678. # $have_x is `yes', `no', `disabled', or empty when we do not yet know.
  1679. if test "x$with_x" = xno; then
  1680.   # The user explicitly disabled X.
  1681.   have_x=disabled
  1682. else
  1683.   if test "x$x_includes" != xNONE && test "x$x_libraries" != xNONE; then
  1684.     # Both variables are already set.
  1685.     have_x=yes
  1686.   else
  1687. AC_CACHE_VAL(ac_cv_have_x,
  1688. [# One or both of the vars are not set, and there is no cached value.
  1689. ac_x_includes=NO ac_x_libraries=NO
  1690. AC_PATH_X_XMKMF
  1691. AC_PATH_X_DIRECT
  1692. if test "$ac_x_includes" = NO || test "$ac_x_libraries" = NO; then
  1693.   # Didn't find X anywhere.  Cache the known absence of X.
  1694.   ac_cv_have_x="have_x=no"
  1695. else
  1696.   # Record where we found X for the cache.
  1697.   ac_cv_have_x="have_x=yes \
  1698.             ac_x_includes=$ac_x_includes ac_x_libraries=$ac_x_libraries"
  1699. fi])dnl
  1700.   fi
  1701.   eval "$ac_cv_have_x"
  1702. fi # $with_x != no
  1703.  
  1704. if test "$have_x" != yes; then
  1705.   AC_MSG_RESULT($have_x)
  1706.   no_x=yes
  1707. else
  1708.   # If each of the values was on the command line, it overrides each guess.
  1709.   test "x$x_includes" = xNONE && x_includes=$ac_x_includes
  1710.   test "x$x_libraries" = xNONE && x_libraries=$ac_x_libraries
  1711.   # Update the cache value to reflect the command line values.
  1712.   ac_cv_have_x="have_x=yes \
  1713.         ac_x_includes=$x_includes ac_x_libraries=$x_libraries"
  1714.   AC_MSG_RESULT([libraries $x_libraries, headers $x_includes])
  1715. fi
  1716. ])
  1717.  
  1718. dnl Internal subroutine of AC_PATH_X.
  1719. dnl Set ac_x_includes and/or ac_x_libraries.
  1720. AC_DEFUN(AC_PATH_X_XMKMF,
  1721. [rm -fr conftestdir
  1722. if mkdir conftestdir; then
  1723.   cd conftestdir
  1724.   # Make sure to not put "make" in the Imakefile rules, since we grep it out.
  1725.   cat > Imakefile <<'EOF'
  1726. acfindx:
  1727.     @echo 'ac_im_incroot="${INCROOT}"; ac_im_usrlibdir="${USRLIBDIR}"; ac_im_libdir="${LIBDIR}"'
  1728. EOF
  1729.   if (xmkmf) >/dev/null 2>/dev/null && test -f Makefile; then
  1730.     # GNU make sometimes prints "make[1]: Entering...", which would confuse us.
  1731.     eval `${MAKE-make} acfindx 2>/dev/null | grep -v make`
  1732.     # Open Windows xmkmf reportedly sets LIBDIR instead of USRLIBDIR.
  1733.     for ac_extension in a so sl; do
  1734.       if test ! -f $ac_im_usrlibdir/libX11.$ac_extension &&
  1735.         test -f $ac_im_libdir/libX11.$ac_extension; then
  1736.         ac_im_usrlibdir=$ac_im_libdir; break
  1737.       fi
  1738.     done
  1739.     # Screen out bogus values from the imake configuration.
  1740.     case "$ac_im_incroot" in
  1741.     /ade/include) ;;
  1742.     *) test -f "$ac_im_incroot/X11/Xos.h" && ac_x_includes="$ac_im_incroot" ;;
  1743.     esac
  1744.     case "$ac_im_usrlibdir" in
  1745.     /ade/lib) ;;
  1746.     *) test -d "$ac_im_usrlibdir" && ac_x_libraries="$ac_im_usrlibdir" ;;
  1747.     esac
  1748.   fi
  1749.   cd ..
  1750.   # AmigaOS hack - give lock on conftestdir time to expire before rm -fr.
  1751.   sleep 2
  1752.   rm -fr conftestdir
  1753. fi
  1754. ])
  1755.  
  1756. dnl Internal subroutine of AC_PATH_X.
  1757. dnl Set ac_x_includes and/or ac_x_libraries.
  1758. AC_DEFUN(AC_PATH_X_DIRECT,
  1759. [if test "$ac_x_includes" = NO; then
  1760.   # Guess where to find include files, by looking for this one X11 .h file.
  1761.   test -z "$x_direct_test_include" && x_direct_test_include=X11/Intrinsic.h
  1762.  
  1763.   # First, try using that file with no special directory specified.
  1764. AC_TRY_CPP([#include <$x_direct_test_include>],
  1765. [# We can compile using X headers with no special include directory.
  1766. ac_x_includes=],
  1767. [# Look for the header file in a standard set of common directories.
  1768.   for ac_dir in               \
  1769.     /ade/X11R6/include        \
  1770.     /ade/X11R5/include        \
  1771.     /ade/X11R4/include        \
  1772.                               \
  1773.     /ade/include/X11R6        \
  1774.     /ade/include/X11R5        \
  1775.     /ade/include/X11R4        \
  1776.                               \
  1777.     /local/X11R6/include  \
  1778.     /local/X11R5/include  \
  1779.     /local/X11R4/include  \
  1780.                               \
  1781.     /local/include/X11R6  \
  1782.     /local/include/X11R5  \
  1783.     /local/include/X11R4  \
  1784.                               \
  1785.     /ade/X11/include          \
  1786.     /ade/include/X11          \
  1787.     /local/X11/include    \
  1788.     /local/include/X11    \
  1789.                               \
  1790.     /ade/X386/include         \
  1791.     /ade/x386/include         \
  1792.     /ade/XFree86/include/X11  \
  1793.                               \
  1794.     /ade/include              \
  1795.     /local/include        \
  1796.     /ade/unsupported/include  \
  1797.     /ade/athena/include       \
  1798.     /local/x11r5/include  \
  1799.     /ade/lpp/Xamples/include  \
  1800.                               \
  1801.     /ade/openwin/include      \
  1802.     /ade/openwin/share/include \
  1803.     ; \
  1804.   do
  1805.     if test -r "$ac_dir/$x_direct_test_include"; then
  1806.       ac_x_includes=$ac_dir
  1807.       break
  1808.     fi
  1809.   done])
  1810. fi # $ac_x_includes = NO
  1811.  
  1812. if test "$ac_x_libraries" = NO; then
  1813.   # Check for the libraries.
  1814.  
  1815.   test -z "$x_direct_test_library" && x_direct_test_library=Xt
  1816.   test -z "$x_direct_test_function" && x_direct_test_function=XtMalloc
  1817.  
  1818.   # See if we find them without any special options.
  1819.   # Don't add to $LIBS permanently.
  1820.   ac_save_LIBS="$LIBS"
  1821.   LIBS="-l$x_direct_test_library $LIBS"
  1822. AC_TRY_LINK(, [${x_direct_test_function}()],
  1823. [LIBS="$ac_save_LIBS"
  1824. # We can link X programs with no special library path.
  1825. ac_x_libraries=],
  1826. [LIBS="$ac_save_LIBS"
  1827. # First see if replacing the include by lib works.
  1828. for ac_dir in `echo "$ac_x_includes" | sed s/include/lib/` \
  1829.     /ade/X11R6/lib        \
  1830.     /ade/X11R5/lib        \
  1831.     /ade/X11R4/lib        \
  1832.                           \
  1833.     /ade/lib/X11R6        \
  1834.     /ade/lib/X11R5        \
  1835.     /ade/lib/X11R4        \
  1836.                           \
  1837.     /local/X11R6/lib  \
  1838.     /local/X11R5/lib  \
  1839.     /local/X11R4/lib  \
  1840.                           \
  1841.     /local/lib/X11R6  \
  1842.     /local/lib/X11R5  \
  1843.     /local/lib/X11R4  \
  1844.                           \
  1845.     /ade/X11/lib          \
  1846.     /ade/lib/X11          \
  1847.     /local/X11/lib    \
  1848.     /local/lib/X11    \
  1849.                           \
  1850.     /ade/X386/lib         \
  1851.     /ade/x386/lib         \
  1852.     /ade/XFree86/lib/X11  \
  1853.                           \
  1854.     /ade/lib              \
  1855.     /local/lib        \
  1856.     /ade/unsupported/lib  \
  1857.     /ade/athena/lib       \
  1858.     /local/x11r5/lib  \
  1859.     /ade/lpp/Xamples/lib  \
  1860.                           \
  1861.     /ade/openwin/lib      \
  1862.     /ade/openwin/share/lib \
  1863.     ; \
  1864. do
  1865. dnl XXX Shouldn't this really use AC_TRY_LINK to be portable & robust??
  1866.   for ac_extension in a so sl; do
  1867.     if test -r $ac_dir/lib${x_direct_test_library}.$ac_extension; then
  1868.       ac_x_libraries=$ac_dir
  1869.       break 2
  1870.     fi
  1871.   done
  1872. done])
  1873. fi # $ac_x_libraries = NO
  1874. ])
  1875.  
  1876. dnl Find additional X libraries, magic flags, etc.
  1877. AC_DEFUN(AC_PATH_XTRA,
  1878. [AC_REQUIRE([AC_ISC_POSIX])dnl
  1879. AC_REQUIRE([AC_PATH_X])dnl
  1880. if test "$no_x" = yes; then
  1881.   # Not all programs may use this symbol, but it does not hurt to define it.
  1882.   X_CFLAGS="$X_CFLAGS -DX_DISPLAY_MISSING"
  1883. else
  1884.   if test -n "$x_includes"; then
  1885.     X_CFLAGS="$X_CFLAGS -I$x_includes"
  1886.   fi
  1887.  
  1888.   # It would be nice to have a more robust check for the -R ld option than
  1889.   # just checking for Solaris.
  1890.   # It would also be nice to do this for all -L options, not just this one.
  1891.   if test -n "$x_libraries"; then
  1892.     X_LIBS="$X_LIBS -L$x_libraries"
  1893.     if test "`(uname) 2>/dev/null`" = SunOS &&
  1894.       uname -r | grep '^5' >/dev/null; then
  1895.       X_LIBS="$X_LIBS -R $x_libraries"
  1896.     fi
  1897.   fi
  1898.  
  1899.   # Check for libraries that X11R6 Xt/Xaw programs need.
  1900.  
  1901.   ac_save_LDFLAGS="$LDFLAGS"
  1902.   LDFLAGS="$LDFLAGS -L$x_libraries"
  1903.   # SM needs ICE to (dynamically) link under SunOS 4.x (so we have to
  1904.   # check for ICE first), but we must link in the order -lSM -lICE or
  1905.   # we get undefined symbols.  So assume we have SM if we have ICE.
  1906.   # These have to be linked with before -lX11, unlike the other
  1907.   # libraries we check for below, so use a different variable.
  1908.   #  --interran@uluru.Stanford.EDU, kb@cs.umb.edu.
  1909.   AC_CHECK_LIB(ICE, IceConnectionNumber,
  1910.     [X_PRE_LIBS="$X_PRE_LIBS -lSM -lICE"])
  1911.   LDFLAGS="$ac_save_LDFLAGS"
  1912.  
  1913.   # Check for system-dependent libraries X programs must link with.
  1914.  
  1915.   if test "$ISC" = yes; then
  1916.     X_EXTRA_LIBS="$X_EXTRA_LIBS -lnsl_s -linet"
  1917.   else
  1918.     # Martyn.Johnson@cl.cam.ac.uk says this is needed for Ultrix, if the X
  1919.     # libraries were built with DECnet support.  And karl@cs.umb.edu says
  1920.     # the Alpha needs dnet_stub (dnet does not exist).
  1921.     AC_CHECK_LIB(dnet, dnet_ntoa, [X_EXTRA_LIBS="$X_EXTRA_LIBS -ldnet"])
  1922.     if test $ac_cv_lib_dnet_dnet_ntoa = no; then
  1923.       AC_CHECK_LIB(dnet_stub, dnet_ntoa,
  1924.         [X_EXTRA_LIBS="$X_EXTRA_LIBS -ldnet_stub"])
  1925.     fi
  1926.  
  1927.     # msh@cis.ufl.edu says -lnsl (and -lsocket) are needed for his 386/AT,
  1928.     # to get the SysV transport functions.
  1929.     # Not sure which flavor of 386 UNIX this is, but it seems harmless to
  1930.     # check for it.
  1931.     AC_CHECK_LIB(nsl, t_accept, [X_EXTRA_LIBS="$X_EXTRA_LIBS -lnsl"])
  1932.  
  1933.     # lieder@skyler.mavd.honeywell.com says without -lsocket,
  1934.     # socket/setsockopt and other routines are undefined under SCO ODT 2.0.
  1935.     # But -lsocket is broken on IRIX, according to simon@lia.di.epfl.ch.
  1936.     if test "`(uname) 2>/dev/null`" != IRIX; then
  1937.       AC_CHECK_LIB(socket, socket, [X_EXTRA_LIBS="$X_EXTRA_LIBS -lsocket"])
  1938.     fi
  1939.   fi
  1940. fi
  1941. AC_SUBST(X_CFLAGS)dnl
  1942. AC_SUBST(X_PRE_LIBS)dnl
  1943. AC_SUBST(X_LIBS)dnl
  1944. AC_SUBST(X_EXTRA_LIBS)dnl
  1945. ])
  1946.  
  1947.  
  1948. dnl ### Checks for UNIX variants
  1949. dnl These are kludges which should be replaced by a single POSIX check.
  1950. dnl They aren't cached, to discourage their use.
  1951.  
  1952.  
  1953. AC_DEFUN(AC_AIX,
  1954. [AC_BEFORE([$0], [AC_TRY_COMPILE])dnl
  1955. AC_BEFORE([$0], [AC_TRY_LINK])dnl
  1956. AC_BEFORE([$0], [AC_TRY_RUN])dnl
  1957. AC_MSG_CHECKING(for AIX)
  1958. AC_EGREP_CPP(yes,
  1959. [#ifdef _AIX
  1960.   yes
  1961. #endif
  1962. ], [AC_MSG_RESULT(yes); AC_DEFINE(_ALL_SOURCE)], AC_MSG_RESULT(no))
  1963. ])
  1964.  
  1965. AC_DEFUN(AC_MINIX,
  1966. [AC_BEFORE([$0], [AC_TRY_COMPILE])dnl
  1967. AC_BEFORE([$0], [AC_TRY_LINK])dnl
  1968. AC_BEFORE([$0], [AC_TRY_RUN])dnl
  1969. AC_CHECK_HEADER(minix/config.h, MINIX=yes, MINIX=)
  1970. if test "$MINIX" = yes; then
  1971.   AC_DEFINE(_POSIX_SOURCE)
  1972.   AC_DEFINE(_POSIX_1_SOURCE, 2)
  1973.   AC_DEFINE(_MINIX)
  1974. fi
  1975. ])
  1976.  
  1977. AC_DEFUN(AC_ISC_POSIX,
  1978. [AC_BEFORE([$0], [AC_TRY_COMPILE])dnl
  1979. AC_BEFORE([$0], [AC_TRY_LINK])dnl
  1980. AC_BEFORE([$0], [AC_TRY_RUN])dnl
  1981. AC_MSG_CHECKING(for POSIXized ISC)
  1982. if test -d /etc/conf/kconfig.d &&
  1983.   grep _POSIX_VERSION [/usr/include/sys/unistd.h] >/dev/null 2>&1
  1984. then
  1985.   AC_MSG_RESULT(yes)
  1986.   ISC=yes # If later tests want to check for ISC.
  1987.   AC_DEFINE(_POSIX_SOURCE)
  1988.   if test "$GCC" = yes; then
  1989.     CC="$CC -posix"
  1990.   else
  1991.     CC="$CC -Xp"
  1992.   fi
  1993. else
  1994.   AC_MSG_RESULT(no)
  1995.   ISC=
  1996. fi
  1997. ])
  1998.  
  1999. AC_DEFUN(AC_XENIX_DIR,
  2000. [AC_OBSOLETE([$0], [; instead use AC_HEADER_DIRENT])dnl
  2001. AC_REQUIRE([AC_DIR_HEADER])dnl
  2002. AC_MSG_CHECKING(for Xenix)
  2003. AC_EGREP_CPP(yes,
  2004. [#if defined(M_XENIX) && !defined(M_UNIX)
  2005.   yes
  2006. #endif
  2007. ], [AC_MSG_RESULT(yes); XENIX=yes], [AC_MSG_RESULT(no); XENIX=])
  2008. if test "$XENIX" = yes; then
  2009.   # Make sure -ldir precedes -lx.
  2010.   test $ac_header_dirent = dirent.h && LIBS="-ldir $LIBS"
  2011.   LIBS="$LIBS -lx"
  2012. fi
  2013. ])
  2014.  
  2015. AC_DEFUN(AC_DYNIX_SEQ,
  2016. [AC_OBSOLETE([$0], [; instead use AC_FUNC_GETMNTENT])dnl
  2017. AC_CHECK_LIB(seq, getmntent, LIBS="-lseq $LIBS")
  2018. ])
  2019.  
  2020. AC_DEFUN(AC_IRIX_SUN,
  2021. [AC_OBSOLETE([$0], [; instead use AC_FUNC_GETMNTENT or AC_CHECK_LIB(sun, getpwnam)])dnl
  2022. AC_CHECK_LIB(sun, getmntent, LIBS="-lsun $LIBS")
  2023. ])
  2024.  
  2025. AC_DEFUN(AC_SCO_INTL,
  2026. [AC_OBSOLETE([$0], [; instead use AC_FUNC_STRFTIME])dnl
  2027. AC_CHECK_LIB(intl, strftime, LIBS="-lintl $LIBS")
  2028. ])
  2029.