home *** CD-ROM | disk | FTP | other *** search
/ Il CD di internet / CD.iso / SOURCE / D / CLISP / CLISPSRC.TAR / clisp-1995-01-01 / src / autoconf-2.1 / acspecific.m4 < prev    next >
Encoding:
M4 Source File  |  1994-12-30  |  59.8 KB  |  2,025 lines

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