You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

2867 lines
85 KiB

25 years ago
  1. dnl Macros that test for specific features.
  2. dnl This file is part of Autoconf.
  3. dnl Copyright (C) 1992, 93, 94, 95, 96, 1998 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., 59 Temple Place - Suite 330, Boston, MA
  18. dnl 02111-1307, USA.
  19. dnl
  20. dnl As a special exception, the Free Software Foundation gives unlimited
  21. dnl permission to copy, distribute and modify the configure scripts that
  22. dnl are the output of Autoconf. You need not follow the terms of the GNU
  23. dnl General Public License when using or distributing such scripts, even
  24. dnl though portions of the text of Autoconf appear in them. The GNU
  25. dnl General Public License (GPL) does govern all other use of the material
  26. dnl that constitutes the Autoconf program.
  27. dnl
  28. dnl Certain portions of the Autoconf source text are designed to be copied
  29. dnl (in certain cases, depending on the input) into the output of
  30. dnl Autoconf. We call these the "data" portions. The rest of the Autoconf
  31. dnl source text consists of comments plus executable code that decides which
  32. dnl of the data portions to output in any given case. We call these
  33. dnl comments and executable code the "non-data" portions. Autoconf never
  34. dnl copies any of the non-data portions into its output.
  35. dnl
  36. dnl This special exception to the GPL applies to versions of Autoconf
  37. dnl released by the Free Software Foundation. When you make and
  38. dnl distribute a modified version of Autoconf, you may extend this special
  39. dnl exception to the GPL to apply to your modified version as well, *unless*
  40. dnl your modified version has the potential to copy into its output some
  41. dnl of the text that was the non-data portion of the version that you started
  42. dnl with. (In other words, unless your change moves or copies text from
  43. dnl the non-data portions to the data portions.) If your modification has
  44. dnl such potential, you must delete any notice of this special exception
  45. dnl to the GPL from your modified version.
  46. dnl
  47. dnl Written by David MacKenzie, with help from
  48. dnl Franc,ois Pinard, Karl Berry, Richard Pixley, Ian Lance Taylor,
  49. dnl Roland McGrath, Noah Friedman, david d zuhn, and many others.
  50. dnl
  51. dnl Changed by Bruno Haible, 18 January 1999
  52. dnl ### Checks for programs
  53. dnl Check whether to use -n, \c, or newline-tab to separate
  54. dnl checking messages from result messages.
  55. dnl Idea borrowed from dist 3.0.
  56. dnl Internal use only.
  57. AC_DEFUN(AC_PROG_ECHO_N,
  58. [if (echo "testing\c"; echo 1,2,3) | grep c >/dev/null; then
  59. # Stardent Vistra SVR4 grep lacks -e, says ghazi@caip.rutgers.edu.
  60. if (echo -n testing; echo 1,2,3) | sed s/-n/xn/ | grep xn >/dev/null; then
  61. ac_n= ac_c='
  62. ' ac_t=' ' ac_tt=
  63. else
  64. ac_n=-n ac_c= ac_t= ac_tt='
  65. '
  66. fi
  67. else
  68. ac_n= ac_c='\c' ac_t= ac_tt='
  69. '
  70. fi
  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. if test -z "$CC"; then
  78. case "`uname -s`" in
  79. *win32* | *WIN32*)
  80. AC_CHECK_PROG(CC, cl, cl) ;;
  81. esac
  82. fi
  83. test -z "$CC" && AC_MSG_ERROR([no acceptable cc found in \$PATH])
  84. fi
  85. AC_PROG_CC_WORKS
  86. AC_PROG_CC_GNU
  87. if test $ac_cv_prog_gcc = yes; then
  88. GCC=yes
  89. else
  90. GCC=
  91. fi
  92. dnl Check whether -g works, even if CFLAGS is set, in case the package
  93. dnl plays around with CFLAGS (such as to build both debugging and
  94. dnl normal versions of a library), tasteless as that idea is.
  95. ac_test_CFLAGS="${CFLAGS+set}"
  96. ac_save_CFLAGS="$CFLAGS"
  97. CFLAGS=
  98. dnl AC_PROG_CC_G
  99. if test "$ac_test_CFLAGS" = set; then
  100. CFLAGS="$ac_save_CFLAGS"
  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 elif test $ac_cv_prog_cc_g = yes; then
  107. dnl if test "$GCC" = yes; then
  108. dnl CFLAGS="-g -O2"
  109. dnl else
  110. dnl CFLAGS="-g"
  111. dnl fi
  112. else
  113. if test "$GCC" = yes; then
  114. dnl CFLAGS="-O"
  115. # Add "-O" to both the CC and CPP commands, to eliminate possible confusion
  116. # that results from __OPTIMIZE__ being defined for CC but not CPP.
  117. changequote(, )dnl
  118. if echo "$CC " | grep ' -O[1-9 ]' > /dev/null 2>&1; then
  119. changequote([, ])dnl
  120. : # already optimizing
  121. else
  122. CC="$CC -O"
  123. ac_cv_prog_CC="$CC"
  124. fi
  125. else
  126. CFLAGS=
  127. fi
  128. fi
  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 cc++ cl, gcc)
  133. AC_PROG_CXX_WORKS
  134. AC_PROG_CXX_GNU
  135. if test $ac_cv_prog_gxx = yes; then
  136. GXX=yes
  137. else
  138. GXX=
  139. fi
  140. dnl Check whether -g works, even if CXXFLAGS is set, in case the package
  141. dnl plays around with CXXFLAGS (such as to build both debugging and
  142. dnl normal versions of a library), tasteless as that idea is.
  143. ac_test_CXXFLAGS="${CXXFLAGS+set}"
  144. ac_save_CXXFLAGS="$CXXFLAGS"
  145. CXXFLAGS=
  146. dnl AC_PROG_CXX_G
  147. if test "$ac_test_CXXFLAGS" = set; then
  148. CXXFLAGS="$ac_save_CXXFLAGS"
  149. dnl # This doesn't work on Linux (libc-4.5.26): Because of differences between
  150. dnl # the shared and the static libraries there are less symbols available
  151. dnl # without -g than with -g. It is therefore better to run the configuration
  152. dnl # without -g and to add -g afterwards than the contrary. So don't add
  153. dnl # -g to the CFLAGS now.
  154. dnl elif test $ac_cv_prog_cxx_g = yes; then
  155. dnl if test "$GXX" = yes; then
  156. dnl CXXFLAGS="-g -O2"
  157. dnl else
  158. dnl CXXFLAGS="-g"
  159. dnl fi
  160. else
  161. if test "$GXX" = yes; then
  162. dnl CXXFLAGS="-O"
  163. # Add "-O" to both the CXX and CXXCPP commands, to eliminate possible confu-
  164. # sion that results from __OPTIMIZE__ being defined for CXX but not CXXCPP.
  165. changequote(, )dnl
  166. if echo "$CXX " | grep ' -O[1-9 ]' > /dev/null; then
  167. changequote([, ])dnl
  168. : # already optimizing
  169. else
  170. CXX="$CXX -O"
  171. ac_cv_prog_CXX="$CXX"
  172. fi
  173. else
  174. CXXFLAGS=
  175. fi
  176. fi
  177. ])
  178. dnl Determine a Fortran 77 compiler to use. If `F77' is not already set
  179. dnl in the environment, check for `g77', `f77' and `f2c', in that order.
  180. dnl Set the output variable `F77' to the name of the compiler found.
  181. dnl
  182. dnl If using `g77' (the GNU Fortran 77 compiler), then `AC_PROG_F77'
  183. dnl will set the shell variable `G77' to `yes', and empty otherwise. If
  184. dnl the output variable `FFLAGS' was not already set in the environment,
  185. dnl then set it to `-g -02' for `g77' (or `-O2' where `g77' does not
  186. dnl accept `-g'). Otherwise, set `FFLAGS' to `-g' for all other Fortran
  187. dnl 77 compilers.
  188. dnl
  189. dnl AC_PROG_F77()
  190. AC_DEFUN(AC_PROG_F77,
  191. [AC_BEFORE([$0], [AC_PROG_CPP])dnl
  192. if test -z "$F77"; then
  193. AC_CHECK_PROGS(F77, g77 f77 f2c)
  194. test -z "$F77" && AC_MSG_ERROR([no acceptable Fortran 77 compiler found in \$PATH])
  195. fi
  196. AC_PROG_F77_WORKS
  197. AC_PROG_F77_GNU
  198. if test $ac_cv_prog_g77 = yes; then
  199. G77=yes
  200. dnl Check whether -g works, even if FFLAGS is set, in case the package
  201. dnl plays around with FFLAGS (such as to build both debugging and
  202. dnl normal versions of a library), tasteless as that idea is.
  203. ac_test_FFLAGS="${FFLAGS+set}"
  204. ac_save_FFLAGS="$FFLAGS"
  205. FFLAGS=
  206. AC_PROG_F77_G
  207. if test "$ac_test_FFLAGS" = set; then
  208. FFLAGS="$ac_save_FFLAGS"
  209. elif test $ac_cv_prog_f77_g = yes; then
  210. FFLAGS="-g -O2"
  211. else
  212. FFLAGS="-O2"
  213. fi
  214. else
  215. G77=
  216. test "${FFLAGS+set}" = set || FFLAGS="-g"
  217. fi
  218. ])
  219. AC_DEFUN(AC_PROG_CC_WORKS,
  220. [AC_MSG_CHECKING([whether the C compiler ($CC $CFLAGS $LDFLAGS) works])
  221. AC_LANG_SAVE
  222. AC_LANG_C
  223. AC_TRY_COMPILER([int main(){return(0);}], ac_cv_prog_cc_works, ac_cv_prog_cc_cross)
  224. AC_LANG_RESTORE
  225. AC_MSG_RESULT($ac_cv_prog_cc_works)
  226. if test $ac_cv_prog_cc_works = no; then
  227. AC_MSG_ERROR([installation or configuration problem: C compiler cannot create executables.])
  228. fi
  229. AC_MSG_CHECKING([whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler])
  230. AC_MSG_RESULT($ac_cv_prog_cc_cross)
  231. cross_compiling=$ac_cv_prog_cc_cross
  232. ])
  233. AC_DEFUN(AC_PROG_CXX_WORKS,
  234. [AC_MSG_CHECKING([whether the C++ compiler ($CXX $CXXFLAGS $LDFLAGS) works])
  235. AC_LANG_SAVE
  236. AC_LANG_CPLUSPLUS
  237. AC_TRY_COMPILER([int main(){return(0);}], ac_cv_prog_cxx_works, ac_cv_prog_cxx_cross)
  238. AC_LANG_RESTORE
  239. AC_MSG_RESULT($ac_cv_prog_cxx_works)
  240. if test $ac_cv_prog_cxx_works = no; then
  241. AC_MSG_ERROR([installation or configuration problem: C++ compiler cannot create executables.])
  242. fi
  243. AC_MSG_CHECKING([whether the C++ compiler ($CXX $CXXFLAGS $LDFLAGS) is a cross-compiler])
  244. AC_MSG_RESULT($ac_cv_prog_cxx_cross)
  245. cross_compiling=$ac_cv_prog_cxx_cross
  246. ])
  247. dnl Test whether the Fortran 77 compiler can compile and link a trivial
  248. dnl Fortran program. Also, test whether the Fortran 77 compiler is a
  249. dnl cross-compiler (which may realistically be the case if the Fortran
  250. dnl compiler is `g77').
  251. dnl
  252. dnl AC_PROG_F77_WORKS()
  253. AC_DEFUN(AC_PROG_F77_WORKS,
  254. [AC_MSG_CHECKING([whether the Fortran 77 compiler ($F77 $FFLAGS $LDFLAGS) works])
  255. AC_LANG_SAVE
  256. AC_LANG_FORTRAN77
  257. AC_TRY_COMPILER(dnl
  258. [ program conftest
  259. end
  260. ], ac_cv_prog_f77_works, ac_cv_prog_f77_cross)
  261. AC_LANG_RESTORE
  262. AC_MSG_RESULT($ac_cv_prog_f77_works)
  263. if test $ac_cv_prog_f77_works = no; then
  264. AC_MSG_ERROR([installation or configuration problem: Fortran 77 compiler cannot create executables.])
  265. fi
  266. AC_MSG_CHECKING([whether the Fortran 77 compiler ($F77 $FFLAGS $LDFLAGS) is a cross-compiler])
  267. AC_MSG_RESULT($ac_cv_prog_f77_cross)
  268. cross_compiling=$ac_cv_prog_f77_cross
  269. ])
  270. AC_DEFUN(AC_PROG_CC_GNU,
  271. [AC_CACHE_CHECK(whether we are using GNU C, ac_cv_prog_gcc,
  272. [dnl The semicolon is to pacify NeXT's syntax-checking cpp.
  273. cat > conftest.c <<EOF
  274. #ifdef __GNUC__
  275. yes;
  276. #endif
  277. EOF
  278. if AC_TRY_COMMAND(${CC-cc} -E conftest.c) | egrep yes >/dev/null 2>&1; then
  279. ac_cv_prog_gcc=yes
  280. else
  281. ac_cv_prog_gcc=no
  282. fi])])
  283. AC_DEFUN(AC_PROG_CXX_GNU,
  284. [AC_CACHE_CHECK(whether we are using GNU C++, ac_cv_prog_gxx,
  285. [dnl The semicolon is to pacify NeXT's syntax-checking cpp.
  286. cat > conftest.C <<EOF
  287. #ifdef __GNUC__
  288. yes;
  289. #endif
  290. EOF
  291. if AC_TRY_COMMAND(${CXX-g++} -E conftest.C) | egrep yes >/dev/null 2>&1; then
  292. ac_cv_prog_gxx=yes
  293. else
  294. ac_cv_prog_gxx=no
  295. fi])])
  296. dnl Test whether for Fortran 77 compiler is `g77' (the GNU Fortran 77
  297. dnl Compiler). This test depends on whether the Fortran 77 compiler can
  298. dnl do CPP pre-processing.
  299. dnl
  300. dnl AC_PROG_F77_GNU()
  301. AC_DEFUN(AC_PROG_F77_GNU,
  302. [AC_CACHE_CHECK(whether we are using GNU Fortran 77, ac_cv_prog_g77,
  303. [cat > conftest.fpp <<EOF
  304. #ifdef __GNUC__
  305. yes
  306. #endif
  307. EOF
  308. if AC_TRY_COMMAND($F77 -E conftest.fpp) | egrep yes >/dev/null 2>&1; then
  309. ac_cv_prog_g77=yes
  310. else
  311. ac_cv_prog_g77=no
  312. fi])])
  313. AC_DEFUN(AC_PROG_CC_G,
  314. [AC_CACHE_CHECK(whether ${CC-cc} accepts -g, ac_cv_prog_cc_g,
  315. [echo 'void f(){}' > conftest.c
  316. if test -z "`${CC-cc} -g -c conftest.c 2>&1`"; then
  317. ac_cv_prog_cc_g=yes
  318. else
  319. ac_cv_prog_cc_g=no
  320. fi
  321. rm -f conftest*
  322. ])])
  323. AC_DEFUN(AC_PROG_CXX_G,
  324. [AC_CACHE_CHECK(whether ${CXX-g++} accepts -g, ac_cv_prog_cxx_g,
  325. [echo 'void f(){}' > conftest.cc
  326. if test -z "`${CXX-g++} -g -c conftest.cc 2>&1`"; then
  327. ac_cv_prog_cxx_g=yes
  328. else
  329. ac_cv_prog_cxx_g=no
  330. fi
  331. rm -f conftest*
  332. ])])
  333. dnl Test whether the Fortran 77 compiler can accept the `-g' option to
  334. dnl enable debugging.
  335. dnl
  336. dnl AC_PROG_F77_G()
  337. AC_DEFUN(AC_PROG_F77_G,
  338. [AC_CACHE_CHECK(whether $F77 accepts -g, ac_cv_prog_f77_g,
  339. [cat > conftest.f << EOF
  340. program conftest
  341. end
  342. EOF
  343. if test -z "`$F77 -g -c conftest.f 2>&1`"; then
  344. ac_cv_prog_f77_g=yes
  345. else
  346. ac_cv_prog_f77_g=no
  347. fi
  348. rm -f conftest*
  349. ])])
  350. AC_DEFUN(AC_PROG_GCC_TRADITIONAL,
  351. [AC_REQUIRE([AC_PROG_CC])dnl
  352. AC_REQUIRE([AC_PROG_CPP])dnl
  353. if test $ac_cv_prog_gcc = yes; then
  354. AC_CACHE_CHECK(whether -traditional is needed for ${CC-cc} on this system,
  355. ac_cv_prog_gcc_traditional,
  356. [ ac_pattern="Autoconf.*'x'"
  357. AC_EGREP_CPP($ac_pattern, [#include <sgtty.h>
  358. Autoconf TIOCGETP],
  359. ac_cv_prog_gcc_traditional=yes, ac_cv_prog_gcc_traditional=no)
  360. if test $ac_cv_prog_gcc_traditional = no; then
  361. AC_EGREP_CPP($ac_pattern, [#include <termio.h>
  362. Autoconf TCGETA],
  363. ac_cv_prog_gcc_traditional=yes)
  364. fi
  365. if test $ac_cv_prog_gcc_traditional = no; then
  366. # On some USL SVR4 systems, gcc's fixinc.svr4 modifies <signal.h> and
  367. # <sys/signal.h> in such a way that "#include <signal.h>" results in a
  368. # syntax error because of `sigset_t' if gcc is called with __STDC__=1
  369. # but __STRICT_ANSI__ undefined. Remedy: use -traditional.
  370. ac_prog='
  371. #include <sys/types.h>
  372. #include <signal.h>
  373. #ifdef __cplusplus
  374. extern "C" void exit(int);
  375. #endif
  376. int main() { exit(0); }'
  377. echo "$ac_prog" > conftest.c
  378. if eval $ac_link; then
  379. :
  380. else
  381. ac_prog='
  382. #undef __STDC__
  383. #include <sys/types.h>
  384. #include <signal.h>
  385. #ifdef __cplusplus
  386. extern "C" void exit(int);
  387. #endif
  388. int main() { exit(0); }'
  389. echo "$ac_prog" > conftest.c
  390. if eval $ac_link; then
  391. ac_cv_prog_gcc_traditional=yes
  392. fi
  393. fi
  394. rm -f conftest*
  395. fi])
  396. if test $ac_cv_prog_gcc_traditional = yes; then
  397. CC="$CC -traditional"
  398. fi
  399. fi
  400. ])
  401. AC_DEFUN(AC_PROG_CC_C_O,
  402. [if test "x$CC" != xcc; then
  403. AC_MSG_CHECKING(whether $CC and cc understand -c and -o together)
  404. else
  405. AC_MSG_CHECKING(whether cc understands -c and -o together)
  406. fi
  407. set dummy $CC; ac_cc="`echo [$]2 |
  408. changequote(, )dnl
  409. sed -e 's/[^a-zA-Z0-9_]/_/g' -e 's/^[0-9]/_/'`"
  410. changequote([, ])dnl
  411. AC_CACHE_VAL(ac_cv_prog_cc_${ac_cc}_c_o,
  412. [echo 'foo(){}' > conftest.c
  413. # Make sure it works both with $CC and with simple cc.
  414. # We do the test twice because some compilers refuse to overwrite an
  415. # existing .o file with -o, though they will create one.
  416. ac_try='${CC-cc} -c conftest.c -o conftest.o 1>&AC_FD_CC'
  417. if AC_TRY_EVAL(ac_try) &&
  418. test -f conftest.o && AC_TRY_EVAL(ac_try);
  419. then
  420. eval ac_cv_prog_cc_${ac_cc}_c_o=yes
  421. if test "x$CC" != xcc; then
  422. # Test first that cc exists at all.
  423. if AC_TRY_COMMAND(cc -c conftest.c 1>&AC_FD_CC); then
  424. ac_try='cc -c conftest.c -o conftest.o 1>&AC_FD_CC'
  425. if AC_TRY_EVAL(ac_try) &&
  426. test -f conftest.o && AC_TRY_EVAL(ac_try);
  427. then
  428. # cc works too.
  429. :
  430. else
  431. # cc exists but doesn't like -o.
  432. eval ac_cv_prog_cc_${ac_cc}_c_o=no
  433. fi
  434. fi
  435. fi
  436. else
  437. eval ac_cv_prog_cc_${ac_cc}_c_o=no
  438. fi
  439. rm -f conftest*
  440. ])dnl
  441. if eval "test \"`echo '$ac_cv_prog_cc_'${ac_cc}_c_o`\" = yes"; then
  442. AC_MSG_RESULT(yes)
  443. else
  444. AC_MSG_RESULT(no)
  445. AC_DEFINE(NO_MINUS_C_MINUS_O)
  446. fi
  447. ])
  448. dnl Test if the Fortran 77 compiler accepts the options `-c' and `-o'
  449. dnl simultaneously, and define `F77_NO_MINUS_C_MINUS_O' if it does not.
  450. dnl
  451. dnl The usefulness of this macro is questionable, as I can't really see
  452. dnl why anyone would use it. The only reason I include it is for
  453. dnl completeness, since a similar test exists for the C compiler.
  454. dnl
  455. dnl AC_PROG_F77_C_O
  456. AC_DEFUN(AC_PROG_F77_C_O,
  457. [AC_BEFORE([$0], [AC_PROG_F77])dnl
  458. AC_MSG_CHECKING(whether $F77 understand -c and -o together)
  459. set dummy $F77; ac_f77="`echo [$]2 |
  460. changequote(, )dnl
  461. sed -e 's/[^a-zA-Z0-9_]/_/g' -e 's/^[0-9]/_/'`"
  462. changequote([, ])dnl
  463. AC_CACHE_VAL(ac_cv_prog_f77_${ac_f77}_c_o,
  464. [cat > conftest.f << EOF
  465. program conftest
  466. end
  467. EOF
  468. # We do the `AC_TRY_EVAL' test twice because some compilers refuse to
  469. # overwrite an existing `.o' file with `-o', although they will create
  470. # one.
  471. ac_try='$F77 $FFLAGS -c conftest.f -o conftest.o 1>&AC_FD_CC'
  472. if AC_TRY_EVAL(ac_try) && test -f conftest.o && AC_TRY_EVAL(ac_try); then
  473. eval ac_cv_prog_f77_${ac_f77}_c_o=yes
  474. else
  475. eval ac_cv_prog_f77_${ac_f77}_c_o=no
  476. fi
  477. rm -f conftest*
  478. ])dnl
  479. if eval "test \"`echo '$ac_cv_prog_f77_'${ac_f77}_c_o`\" = yes"; then
  480. AC_MSG_RESULT(yes)
  481. else
  482. AC_MSG_RESULT(no)
  483. AC_DEFINE(F77_NO_MINUS_C_MINUS_O)
  484. fi
  485. ])
  486. dnl Define SET_MAKE to set ${MAKE} if make doesn't.
  487. AC_DEFUN(AC_PROG_MAKE_SET,
  488. [AC_MSG_CHECKING([whether ${MAKE-make} sets \$(MAKE)])
  489. set dummy ${MAKE-make}; ac_make=`echo "[$]2" | sed 'y%./+-%__p_%'`
  490. AC_CACHE_VAL(ac_cv_prog_make_${ac_make}_set,
  491. [cat > conftestmake <<\EOF
  492. all:
  493. @echo 'ac_maketemp="${MAKE}"'
  494. EOF
  495. changequote(, )dnl
  496. # GNU make sometimes prints "make[1]: Entering...", which would confuse us.
  497. eval `${MAKE-make} -f conftestmake 2>/dev/null | grep temp=`
  498. changequote([, ])dnl
  499. if test -n "$ac_maketemp"; then
  500. eval ac_cv_prog_make_${ac_make}_set=yes
  501. else
  502. eval ac_cv_prog_make_${ac_make}_set=no
  503. fi
  504. rm -f conftestmake])dnl
  505. if eval "test \"`echo '$ac_cv_prog_make_'${ac_make}_set`\" = yes"; then
  506. AC_MSG_RESULT(yes)
  507. SET_MAKE=
  508. else
  509. AC_MSG_RESULT(no)
  510. SET_MAKE="MAKE=${MAKE-make}"
  511. fi
  512. AC_SUBST([SET_MAKE])dnl
  513. ])
  514. AC_DEFUN(AC_PROG_RANLIB,
  515. [AC_CHECK_PROG(RANLIB, ranlib, ranlib, :)])
  516. dnl Check for mawk first since it's generally faster.
  517. AC_DEFUN(AC_PROG_AWK,
  518. [AC_CHECK_PROGS(AWK, mawk gawk nawk awk, )])
  519. AC_DEFUN(AC_PROG_YACC,
  520. [AC_CHECK_PROGS(YACC, 'bison -y' byacc, yacc)])
  521. AC_DEFUN(AC_PROG_CPP,
  522. [AC_MSG_CHECKING(how to run the C preprocessor)
  523. # On Suns, sometimes $CPP names a directory.
  524. if test -n "$CPP" && test -d "$CPP"; then
  525. CPP=
  526. fi
  527. if test -z "$CPP"; then
  528. AC_CACHE_VAL(ac_cv_prog_CPP,
  529. [ # This must be in double quotes, not single quotes, because CPP may get
  530. # substituted into the Makefile and "${CC-cc}" will confuse make.
  531. CPP="${CC-cc} -E"
  532. if test -n "$GCC"; then
  533. dnl This is already part of AC_PROG_CC.
  534. dnl # Use the same optimization flags than for CC, because some things may
  535. dnl # depend upon __OPTIMIZE__.
  536. dnl CPP="$CPP -O"
  537. # Suppress warning messages.
  538. dnl # When using gcc -traditional on machines that have <sys/cdefs.h>,
  539. dnl # the "-Dconst=" from AC_C_CONST and the "#define const __const" from
  540. dnl # <sys/cdefs.h> generate a warning. Unless suppressed, this warning
  541. dnl # causes later tests using AC_TRY_CPP to fail.
  542. CPP="$CPP -w"
  543. fi
  544. # On the NeXT, cc -E runs the code through the compiler's parser,
  545. # not just through cpp. On NeXTstep 3.1 the same holds for /lib/cpp; use
  546. # "cc -E -traditional-cpp" instead.
  547. dnl Use a header file that comes with gcc, so configuring glibc
  548. dnl with a fresh cross-compiler works.
  549. AC_TRY_CPP([#include <assert.h>
  550. Syntax Error], ac_have_cpp=1)
  551. if test -z "$ac_have_cpp"; then
  552. CPP="${CC-cc} -E -traditional-cpp"
  553. AC_TRY_CPP([#include <assert.h>
  554. Syntax Error], ac_have_cpp=1)
  555. if test -n "$ac_have_cpp"; then
  556. CC="${CC-cc} -traditional-cpp"
  557. else
  558. CPP="${CC-cc} -nologo -E"
  559. AC_TRY_CPP([#include <assert.h>
  560. Syntax Error], ac_have_cpp=1)
  561. if test -n "$ac_have_cpp"; then
  562. CC="${CC-cc} -nologo"
  563. else
  564. CPP=/lib/cpp
  565. fi
  566. fi
  567. fi
  568. ac_cv_prog_CC="$CC"
  569. ac_cv_prog_CPP="$CPP"])dnl
  570. CPP="$ac_cv_prog_CPP"
  571. else
  572. ac_cv_prog_CPP="$CPP"
  573. fi
  574. AC_MSG_RESULT($CPP)
  575. AC_SUBST(CPP)dnl
  576. ])
  577. AC_DEFUN(AC_PROG_CXXCPP,
  578. [AC_MSG_CHECKING(how to run the C++ preprocessor)
  579. if test -z "$CXXCPP"; then
  580. AC_CACHE_VAL(ac_cv_prog_CXXCPP,
  581. [AC_LANG_SAVE[]dnl
  582. AC_LANG_CPLUSPLUS[]dnl
  583. CXXCPP="${CXX-g++} -E"
  584. AC_TRY_CPP([#include <stdlib.h>], , CXXCPP=/lib/cpp)
  585. ac_cv_prog_CXXCPP="$CXXCPP"
  586. AC_LANG_RESTORE[]dnl
  587. fi])dnl
  588. CXXCPP="$ac_cv_prog_CXXCPP"
  589. AC_MSG_RESULT($CXXCPP)
  590. AC_SUBST(CXXCPP)dnl
  591. ])
  592. dnl Require finding the C or C++ preprocessor, whichever is the
  593. dnl current language.
  594. AC_DEFUN(AC_REQUIRE_CPP,
  595. [ifelse(AC_LANG, C, [AC_REQUIRE([AC_PROG_CPP])], [AC_REQUIRE([AC_PROG_CXXCPP])])])
  596. AC_DEFUN(AC_PROG_LEX,
  597. [AC_CHECK_PROG(LEX, flex, flex, lex)
  598. if test -z "$LEXLIB"
  599. then
  600. case "$LEX" in
  601. flex*) ac_lib=fl ;;
  602. *) ac_lib=l ;;
  603. esac
  604. AC_CHECK_LIB($ac_lib, yywrap, LEXLIB="-l$ac_lib")
  605. fi
  606. AC_SUBST(LEXLIB)])
  607. dnl Check if lex declares yytext as a char * by default, not a char[].
  608. undefine([AC_DECL_YYTEXT])
  609. AC_DEFUN(AC_DECL_YYTEXT,
  610. [AC_REQUIRE_CPP()dnl
  611. AC_REQUIRE([AC_PROG_LEX])dnl
  612. AC_CACHE_CHECK(lex output file root, ac_cv_prog_lex_root,
  613. [# The minimal lex program is just a single line: %%. But some broken lexes
  614. # (Solaris, I think it was) want two %% lines, so accommodate them.
  615. echo '%%
  616. %%' | $LEX
  617. if test -f lex.yy.c; then
  618. ac_cv_prog_lex_root=lex.yy
  619. elif test -f lexyy.c; then
  620. ac_cv_prog_lex_root=lexyy
  621. else
  622. AC_MSG_ERROR(cannot find output from $LEX; giving up)
  623. fi])
  624. LEX_OUTPUT_ROOT=$ac_cv_prog_lex_root
  625. AC_SUBST(LEX_OUTPUT_ROOT)dnl
  626. AC_CACHE_CHECK(whether yytext is a pointer, ac_cv_prog_lex_yytext_pointer,
  627. [# POSIX says lex can declare yytext either as a pointer or an array; the
  628. # default is implementation-dependent. Figure out which it is, since
  629. # not all implementations provide the %pointer and %array declarations.
  630. ac_cv_prog_lex_yytext_pointer=no
  631. echo 'extern char *yytext;' >>$LEX_OUTPUT_ROOT.c
  632. ac_save_LIBS="$LIBS"
  633. LIBS="$LIBS $LEXLIB"
  634. AC_TRY_LINK(`cat $LEX_OUTPUT_ROOT.c`, , ac_cv_prog_lex_yytext_pointer=yes)
  635. LIBS="$ac_save_LIBS"
  636. rm -f "${LEX_OUTPUT_ROOT}.c"
  637. ])
  638. if test $ac_cv_prog_lex_yytext_pointer = yes; then
  639. AC_DEFINE(YYTEXT_POINTER)
  640. fi
  641. ])
  642. AC_DEFUN(AC_PROG_INSTALL,
  643. [AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT])dnl
  644. # Find a good install program. We prefer a C program (faster),
  645. # so one script is as good as another. But avoid the broken or
  646. # incompatible versions:
  647. # SysV /etc/install, /usr/sbin/install
  648. # SunOS /usr/etc/install
  649. # IRIX /sbin/install
  650. # AIX /bin/install
  651. # AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag
  652. # AFS /usr/afsws/bin/install, which mishandles nonexistent args
  653. # SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff"
  654. # ./install, which can be erroneously created by make from ./install.sh.
  655. AC_MSG_CHECKING(for a BSD compatible install)
  656. if test -z "$INSTALL"; then
  657. AC_CACHE_VAL(ac_cv_path_install,
  658. [ IFS="${IFS= }"; ac_save_IFS="$IFS"; IFS=":"
  659. for ac_dir in $PATH; do
  660. # Account for people who put trailing slashes in PATH elements.
  661. case "$ac_dir/" in
  662. /|./|.//|/etc/*|/usr/sbin/*|/usr/etc/*|/sbin/*|/usr/afsws/bin/*|/usr/ucb/*) ;;
  663. *)
  664. # OSF1 and SCO ODT 3.0 have their own names for install.
  665. # Don't use installbsd from OSF since it installs stuff as root
  666. # by default.
  667. for ac_prog in ginstall scoinst install; do
  668. if test -f $ac_dir/$ac_prog; then
  669. if test $ac_prog = install &&
  670. grep dspmsg $ac_dir/$ac_prog >/dev/null 2>&1; then
  671. # AIX install. It has an incompatible calling convention.
  672. :
  673. else
  674. if test $ac_prog = installbsd &&
  675. grep src/bos $ac_dir/$ac_prog >/dev/null 2>&1; then
  676. # AIX installbsd doesn't work without option "-g".
  677. :
  678. else
  679. ac_cv_path_install="$ac_dir/$ac_prog -c"
  680. break 2
  681. fi
  682. fi
  683. fi
  684. done
  685. ;;
  686. esac
  687. done
  688. IFS="$ac_save_IFS"
  689. ])dnl
  690. if test "${ac_cv_path_install+set}" = set; then
  691. INSTALL="$ac_cv_path_install"
  692. else
  693. # As a last resort, use the slow shell script. We don't cache a
  694. # path for INSTALL within a source directory, because that will
  695. # break other packages using the cache if that directory is
  696. # removed, or if the path is relative.
  697. INSTALL="$ac_install_sh"
  698. fi
  699. fi
  700. dnl We do special magic for INSTALL instead of AC_SUBST, to get
  701. dnl relative paths right.
  702. AC_MSG_RESULT($INSTALL)
  703. # Use test -z because SunOS4 sh mishandles braces in ${var-val}.
  704. # It thinks the first close brace ends the variable substitution.
  705. test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}'
  706. AC_SUBST(INSTALL_PROGRAM)dnl
  707. test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL_PROGRAM}'
  708. AC_SUBST(INSTALL_SCRIPT)dnl
  709. test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644'
  710. AC_SUBST(INSTALL_DATA)dnl
  711. ])
  712. AC_DEFUN(AC_PROG_LN_S,
  713. [AC_MSG_CHECKING(whether ln -s works)
  714. AC_CACHE_VAL(ac_cv_prog_LN_S,
  715. [rm -f conftestdata
  716. if ln -s X conftestdata 2>/dev/null
  717. then
  718. rm -f conftestdata
  719. ac_cv_prog_LN_S="ln -s"
  720. else
  721. ac_cv_prog_LN_S=ln
  722. fi])dnl
  723. LN_S="$ac_cv_prog_LN_S"
  724. if test "$ac_cv_prog_LN_S" = "ln -s"; then
  725. AC_MSG_RESULT(yes)
  726. else
  727. AC_MSG_RESULT(no)
  728. fi
  729. AC_SUBST(LN_S)dnl
  730. ])
  731. define(AC_RSH,
  732. [errprint(__file__:__line__: [$0] has been removed; replace it with equivalent code
  733. )m4exit(4)])
  734. dnl ### Checks for header files
  735. AC_DEFUN(AC_HEADER_STDC,
  736. [AC_REQUIRE_CPP()dnl
  737. AC_CACHE_CHECK(for ANSI C header files, ac_cv_header_stdc,
  738. [AC_TRY_CPP([#include <stdlib.h>
  739. #include <stdarg.h>
  740. #include <string.h>
  741. #include <float.h>], ac_cv_header_stdc=yes, ac_cv_header_stdc=no)
  742. if test $ac_cv_header_stdc = yes; then
  743. # SunOS 4.x string.h does not declare mem*, contrary to ANSI.
  744. AC_EGREP_HEADER(memchr, string.h, , ac_cv_header_stdc=no)
  745. fi
  746. if test $ac_cv_header_stdc = yes; then
  747. # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI.
  748. AC_EGREP_HEADER(free, stdlib.h, , ac_cv_header_stdc=no)
  749. fi
  750. if test $ac_cv_header_stdc = yes; then
  751. # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi.
  752. AC_TRY_RUN([#include <ctype.h>
  753. #define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
  754. #define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c))
  755. #define XOR(e, f) (((e) && !(f)) || (!(e) && (f)))
  756. int main () { int i; for (i = 0; i < 256; i++)
  757. if (XOR (islower (i), ISLOWER (i)) || toupper (i) != TOUPPER (i)) exit(2);
  758. exit (0); }
  759. ], , ac_cv_header_stdc=no, :)
  760. fi])
  761. if test $ac_cv_header_stdc = yes; then
  762. AC_DEFINE(STDC_HEADERS)
  763. fi
  764. ])
  765. AC_DEFUN(AC_UNISTD_H,
  766. [AC_OBSOLETE([$0], [; instead use AC_CHECK_HEADERS(unistd.h)])dnl
  767. AC_CHECK_HEADER(unistd.h, AC_DEFINE(HAVE_UNISTD_H))])
  768. AC_DEFUN(AC_USG,
  769. [AC_OBSOLETE([$0],
  770. [; instead use AC_CHECK_HEADERS(string.h) and HAVE_STRING_H])dnl
  771. AC_MSG_CHECKING([for BSD string and memory functions])
  772. AC_TRY_LINK([#include <strings.h>], [rindex(0, 0); bzero(0, 0);],
  773. [AC_MSG_RESULT(yes)], [AC_MSG_RESULT(no); AC_DEFINE(USG)])])
  774. dnl If memchr and the like aren't declared in <string.h>, include <memory.h>.
  775. dnl To avoid problems, don't check for gcc2 built-ins.
  776. AC_DEFUN(AC_MEMORY_H,
  777. [AC_OBSOLETE([$0], [; instead use AC_CHECK_HEADERS(memory.h) and HAVE_MEMORY_H])dnl
  778. AC_MSG_CHECKING(whether string.h declares mem functions)
  779. AC_EGREP_HEADER(memchr, string.h, ac_found=yes, ac_found=no)
  780. AC_MSG_RESULT($ac_found)
  781. if test $ac_found = no; then
  782. AC_CHECK_HEADER(memory.h, [AC_DEFINE(NEED_MEMORY_H)])
  783. fi
  784. ])
  785. AC_DEFUN(AC_HEADER_MAJOR,
  786. [AC_CACHE_CHECK(whether sys/types.h defines makedev,
  787. ac_cv_header_sys_types_h_makedev,
  788. [AC_TRY_LINK([#include <sys/types.h>], [return makedev(0, 0);],
  789. ac_cv_header_sys_types_h_makedev=yes, ac_cv_header_sys_types_h_makedev=no)
  790. ])
  791. if test $ac_cv_header_sys_types_h_makedev = no; then
  792. AC_CHECK_HEADER(sys/mkdev.h, [AC_DEFINE(MAJOR_IN_MKDEV)])
  793. if test $ac_cv_header_sys_mkdev_h = no; then
  794. AC_CHECK_HEADER(sys/sysmacros.h, [AC_DEFINE(MAJOR_IN_SYSMACROS)])
  795. fi
  796. fi
  797. ])
  798. AC_DEFUN(AC_HEADER_DIRENT,
  799. [ac_header_dirent=no
  800. AC_CHECK_HEADERS_DIRENT(dirent.h sys/ndir.h sys/dir.h ndir.h,
  801. [ac_header_dirent=$ac_hdr; break])
  802. # Two versions of opendir et al. are in -ldir and -lx on SCO Xenix.
  803. if test $ac_header_dirent = dirent.h; then
  804. AC_CHECK_LIB(dir, opendir, LIBS="$LIBS -ldir")
  805. else
  806. AC_CHECK_LIB(x, opendir, LIBS="$LIBS -lx")
  807. fi
  808. ])
  809. dnl Like AC_CHECK_HEADER, except also make sure that HEADER-FILE
  810. dnl defines the type `DIR'. dirent.h on NextStep 3.2 doesn't.
  811. dnl AC_CHECK_HEADER_DIRENT(HEADER-FILE, ACTION-IF-FOUND)
  812. AC_DEFUN(AC_CHECK_HEADER_DIRENT,
  813. [ac_safe=`echo "$1" | sed 'y%./+-%__p_%'`
  814. AC_MSG_CHECKING([for $1 that defines DIR])
  815. AC_CACHE_VAL(ac_cv_header_dirent_$ac_safe,
  816. [AC_TRY_COMPILE([#include <sys/types.h>
  817. #include <$1>], [DIR *dirp = 0;],
  818. eval "ac_cv_header_dirent_$ac_safe=yes",
  819. eval "ac_cv_header_dirent_$ac_safe=no")])dnl
  820. if eval "test \"`echo '$ac_cv_header_dirent_'$ac_safe`\" = yes"; then
  821. AC_MSG_RESULT(yes)
  822. $2
  823. else
  824. AC_MSG_RESULT(no)
  825. fi
  826. ])
  827. dnl Like AC_CHECK_HEADERS, except succeed only for a HEADER-FILE that
  828. dnl defines `DIR'.
  829. dnl AC_CHECK_HEADERS_DIRENT(HEADER-FILE... [, ACTION])
  830. define(AC_CHECK_HEADERS_DIRENT,
  831. [for ac_hdr in $1
  832. do
  833. AC_CHECK_HEADER_DIRENT($ac_hdr,
  834. [changequote(, )dnl
  835. ac_tr_hdr=HAVE_`echo $ac_hdr | sed 'y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%'`
  836. changequote([, ])dnl
  837. AC_DEFINE_UNQUOTED($ac_tr_hdr) $2])dnl
  838. done])
  839. AC_DEFUN(AC_DIR_HEADER,
  840. [AC_OBSOLETE([$0], [; instead use AC_HEADER_DIRENT])dnl
  841. ac_header_dirent=no
  842. for ac_hdr in dirent.h sys/ndir.h sys/dir.h ndir.h; do
  843. AC_CHECK_HEADER_DIRENT($ac_hdr, [ac_header_dirent=$ac_hdr; break])
  844. done
  845. case "$ac_header_dirent" in
  846. dirent.h) AC_DEFINE(DIRENT) ;;
  847. sys/ndir.h) AC_DEFINE(SYSNDIR) ;;
  848. sys/dir.h) AC_DEFINE(SYSDIR) ;;
  849. ndir.h) AC_DEFINE(NDIR) ;;
  850. esac
  851. AC_CACHE_CHECK(whether closedir returns void, ac_cv_func_closedir_void,
  852. [AC_TRY_RUN([#include <sys/types.h>
  853. #include <$ac_header_dirent>
  854. int closedir(); int main() { exit(closedir(opendir(".")) != 0); }],
  855. ac_cv_func_closedir_void=no, ac_cv_func_closedir_void=yes, ac_cv_func_closedir_void=yes)])
  856. if test $ac_cv_func_closedir_void = yes; then
  857. AC_DEFINE(VOID_CLOSEDIR)
  858. fi
  859. ])
  860. AC_DEFUN(AC_HEADER_STAT,
  861. [AC_CACHE_CHECK(whether stat file-mode macros are broken,
  862. ac_cv_header_stat_broken,
  863. [AC_EGREP_CPP([You lose], [#include <sys/types.h>
  864. #include <sys/stat.h>
  865. #if defined(S_ISBLK) && defined(S_IFDIR)
  866. # if S_ISBLK (S_IFDIR)
  867. You lose.
  868. # endif
  869. #endif
  870. #if defined(S_ISBLK) && defined(S_IFCHR)
  871. # if S_ISBLK (S_IFCHR)
  872. You lose.
  873. # endif
  874. #endif
  875. #if defined(S_ISLNK) && defined(S_IFREG)
  876. # if S_ISLNK (S_IFREG)
  877. You lose.
  878. # endif
  879. #endif
  880. #if defined(S_ISSOCK) && defined(S_IFREG)
  881. # if S_ISSOCK (S_IFREG)
  882. You lose.
  883. # endif
  884. #endif
  885. ], ac_cv_header_stat_broken=yes, ac_cv_header_stat_broken=no)])
  886. if test $ac_cv_header_stat_broken = yes; then
  887. AC_DEFINE(STAT_MACROS_BROKEN)
  888. fi
  889. ])
  890. AC_DEFUN(AC_DECL_SYS_SIGLIST,
  891. [AC_CACHE_CHECK([for sys_siglist declaration in signal.h or unistd.h],
  892. ac_cv_decl_sys_siglist,
  893. [AC_TRY_COMPILE([#include <sys/types.h>
  894. #include <signal.h>
  895. /* NetBSD declares sys_siglist in unistd.h. */
  896. #ifdef HAVE_UNISTD_H
  897. #include <unistd.h>
  898. #endif], [char *msg = *(sys_siglist + 1);],
  899. ac_cv_decl_sys_siglist=yes, ac_cv_decl_sys_siglist=no)])
  900. if test $ac_cv_decl_sys_siglist = yes; then
  901. AC_DEFINE(SYS_SIGLIST_DECLARED)
  902. fi
  903. ])
  904. AC_DEFUN(AC_HEADER_SYS_WAIT,
  905. [AC_CACHE_CHECK([for sys/wait.h that is POSIX.1 compatible],
  906. ac_cv_header_sys_wait_h,
  907. [AC_TRY_COMPILE([#include <sys/types.h>
  908. #include <sys/wait.h>
  909. #ifndef WEXITSTATUS
  910. #define WEXITSTATUS(stat_val) ((unsigned)(stat_val) >> 8)
  911. #endif
  912. #ifndef WIFEXITED
  913. #define WIFEXITED(stat_val) (((stat_val) & 255) == 0)
  914. #endif], [int s;
  915. wait (&s);
  916. s = WIFEXITED (s) ? WEXITSTATUS (s) : 1;],
  917. ac_cv_header_sys_wait_h=yes, ac_cv_header_sys_wait_h=no)])
  918. if test $ac_cv_header_sys_wait_h = yes; then
  919. AC_DEFINE(HAVE_SYS_WAIT_H)
  920. fi
  921. ])
  922. dnl ### Checks for typedefs
  923. AC_DEFUN(AC_TYPE_GETGROUPS,
  924. [AC_REQUIRE([AC_TYPE_UID_T])dnl
  925. AC_CACHE_CHECK(type of array argument to getgroups, ac_cv_type_getgroups,
  926. [AC_TRY_RUN(
  927. changequote(<<, >>)dnl
  928. <<
  929. /* Thanks to Mike Rendell for this test. */
  930. #include <sys/types.h>
  931. #define NGID 256
  932. #undef MAX
  933. #define MAX(x, y) ((x) > (y) ? (x) : (y))
  934. int main()
  935. {
  936. gid_t gidset[NGID];
  937. int i, n;
  938. union { gid_t gval; long lval; } val;
  939. val.lval = -1;
  940. for (i = 0; i < NGID; i++)
  941. gidset[i] = val.gval;
  942. n = getgroups (sizeof (gidset) / MAX (sizeof (int), sizeof (gid_t)) - 1,
  943. gidset);
  944. /* Exit non-zero if getgroups seems to require an array of ints. This
  945. happens when gid_t is short but getgroups modifies an array of ints. */
  946. exit ((n > 0 && gidset[n] != val.gval) ? 1 : 0);
  947. }
  948. >>,
  949. changequote([, ])dnl
  950. ac_cv_type_getgroups=gid_t, ac_cv_type_getgroups=int,
  951. ac_cv_type_getgroups=cross)
  952. if test $ac_cv_type_getgroups = cross; then
  953. dnl When we can't run the test program (we are cross compiling), presume
  954. dnl that <unistd.h> has either an accurate prototype for getgroups or none.
  955. dnl Old systems without prototypes probably use int.
  956. AC_EGREP_HEADER([getgroups.*int.*gid_t], unistd.h,
  957. ac_cv_type_getgroups=gid_t, ac_cv_type_getgroups=int)
  958. fi])
  959. AC_DEFINE_UNQUOTED(GETGROUPS_T, $ac_cv_type_getgroups)
  960. ])
  961. AC_DEFUN(AC_TYPE_UID_T,
  962. [AC_CACHE_CHECK(for uid_t in sys/types.h, ac_cv_type_uid_t,
  963. [AC_EGREP_HEADER(uid_t, sys/types.h,
  964. ac_cv_type_uid_t=yes, ac_cv_type_uid_t=no)])
  965. if test $ac_cv_type_uid_t = no; then
  966. AC_DEFINE(uid_t, int)
  967. AC_DEFINE(gid_t, int)
  968. fi
  969. ])
  970. AC_DEFUN(AC_TYPE_SIZE_T,
  971. [AC_CHECK_TYPE(size_t, unsigned)])
  972. AC_DEFUN(AC_TYPE_PID_T,
  973. [AC_CHECK_TYPE(pid_t, int)])
  974. AC_DEFUN(AC_TYPE_OFF_T,
  975. [AC_CHECK_TYPE(off_t, long)])
  976. AC_DEFUN(AC_TYPE_MODE_T,
  977. [AC_CHECK_TYPE(mode_t, int)])
  978. dnl Note that identifiers starting with SIG are reserved by ANSI C.
  979. AC_DEFUN(AC_TYPE_SIGNAL,
  980. [AC_CACHE_CHECK([return type of signal handlers], ac_cv_type_signal,
  981. [AC_TRY_COMPILE([#include <sys/types.h>
  982. #include <signal.h>
  983. #ifdef signal
  984. #undef signal
  985. #endif
  986. extern
  987. #ifdef __cplusplus
  988. "C" void (*signal (int, void (*)(int)))(int);
  989. #else
  990. void (*signal ()) ();
  991. #endif
  992. ],
  993. [int i;], ac_cv_type_signal=void, ac_cv_type_signal=int)])
  994. AC_DEFINE_UNQUOTED(RETSIGTYPE, $ac_cv_type_signal)
  995. ])
  996. dnl ### Checks for functions
  997. AC_DEFUN(AC_FUNC_CLOSEDIR_VOID,
  998. [AC_REQUIRE([AC_HEADER_DIRENT])dnl
  999. AC_CACHE_CHECK(whether closedir returns void, ac_cv_func_closedir_void,
  1000. [AC_TRY_RUN([#include <sys/types.h>
  1001. #include <$ac_header_dirent>
  1002. int closedir(); int main() { exit(closedir(opendir(".")) != 0); }],
  1003. ac_cv_func_closedir_void=no, ac_cv_func_closedir_void=yes, ac_cv_func_closedir_void=yes)])
  1004. if test $ac_cv_func_closedir_void = yes; then
  1005. AC_DEFINE(CLOSEDIR_VOID)
  1006. fi
  1007. ])
  1008. AC_DEFUN(AC_FUNC_FNMATCH,
  1009. [AC_CACHE_CHECK(for working fnmatch, ac_cv_func_fnmatch_works,
  1010. # Some versions of Solaris or SCO have a broken fnmatch function.
  1011. # So we run a test program. If we are cross-compiling, take no chance.
  1012. # Thanks to John Oleynick and Franc,ois Pinard for this test.
  1013. [AC_TRY_RUN([int main() { exit (fnmatch ("a*", "abc", 0) != 0); }],
  1014. ac_cv_func_fnmatch_works=yes, ac_cv_func_fnmatch_works=no,
  1015. ac_cv_func_fnmatch_works=no)])
  1016. if test $ac_cv_func_fnmatch_works = yes; then
  1017. AC_DEFINE(HAVE_FNMATCH)
  1018. fi
  1019. ])
  1020. AC_DEFUN(AC_FUNC_MMAP,
  1021. [AC_CHECK_HEADERS(unistd.h)
  1022. AC_CHECK_FUNCS(getpagesize)
  1023. AC_CACHE_CHECK(for working mmap, ac_cv_func_mmap_fixed_mapped,
  1024. [AC_TRY_RUN([
  1025. /* Thanks to Mike Haertel and Jim Avera for this test.
  1026. Here is a matrix of mmap possibilities:
  1027. mmap private not fixed
  1028. mmap private fixed at somewhere currently unmapped
  1029. mmap private fixed at somewhere already mapped
  1030. mmap shared not fixed
  1031. mmap shared fixed at somewhere currently unmapped
  1032. mmap shared fixed at somewhere already mapped
  1033. For private mappings, we should verify that changes cannot be read()
  1034. back from the file, nor mmap's back from the file at a different
  1035. address. (There have been systems where private was not correctly
  1036. implemented like the infamous i386 svr4.0, and systems where the
  1037. VM page cache was not coherent with the filesystem buffer cache
  1038. like early versions of FreeBSD and possibly contemporary NetBSD.)
  1039. For shared mappings, we should conversely verify that changes get
  1040. propogated back to all the places they're supposed to be.
  1041. Grep wants private fixed already mapped.
  1042. The main things grep needs to know about mmap are:
  1043. * does it exist and is it safe to write into the mmap'd area
  1044. * how to use it (BSD variants) */
  1045. #include <sys/types.h>
  1046. #include <fcntl.h>
  1047. #include <sys/mman.h>
  1048. /* This mess was copied from the GNU getpagesize.h. */
  1049. #ifndef HAVE_GETPAGESIZE
  1050. # ifdef HAVE_UNISTD_H
  1051. # include <unistd.h>
  1052. # endif
  1053. /* Assume that all systems that can run configure have sys/param.h. */
  1054. # ifndef HAVE_SYS_PARAM_H
  1055. # define HAVE_SYS_PARAM_H 1
  1056. # endif
  1057. # ifdef _SC_PAGESIZE
  1058. # define getpagesize() sysconf(_SC_PAGESIZE)
  1059. # else /* no _SC_PAGESIZE */
  1060. # ifdef HAVE_SYS_PARAM_H
  1061. # include <sys/param.h>
  1062. # ifdef EXEC_PAGESIZE
  1063. # define getpagesize() EXEC_PAGESIZE
  1064. # else /* no EXEC_PAGESIZE */
  1065. # ifdef NBPG
  1066. # define getpagesize() NBPG * CLSIZE
  1067. # ifndef CLSIZE
  1068. # define CLSIZE 1
  1069. # endif /* no CLSIZE */
  1070. # else /* no NBPG */
  1071. # ifdef NBPC
  1072. # define getpagesize() NBPC
  1073. # else /* no NBPC */
  1074. # ifdef PAGESIZE
  1075. # define getpagesize() PAGESIZE
  1076. # endif /* PAGESIZE */
  1077. # endif /* no NBPC */
  1078. # endif /* no NBPG */
  1079. # endif /* no EXEC_PAGESIZE */
  1080. # else /* no HAVE_SYS_PARAM_H */
  1081. # define getpagesize() 8192 /* punt totally */
  1082. # endif /* no HAVE_SYS_PARAM_H */
  1083. # endif /* no _SC_PAGESIZE */
  1084. #endif /* no HAVE_GETPAGESIZE */
  1085. #ifdef __cplusplus
  1086. extern "C" { void *malloc(unsigned); }
  1087. #else
  1088. char *malloc();
  1089. #endif
  1090. int
  1091. main()
  1092. {
  1093. char *data, *data2, *data3;
  1094. int i, pagesize;
  1095. int fd;
  1096. pagesize = getpagesize();
  1097. /*
  1098. * First, make a file with some known garbage in it.
  1099. */
  1100. data = malloc(pagesize);
  1101. if (!data)
  1102. exit(1);
  1103. for (i = 0; i < pagesize; ++i)
  1104. *(data + i) = rand();
  1105. umask(0);
  1106. fd = creat("conftestmmap", 0600);
  1107. if (fd < 0)
  1108. exit(1);
  1109. if (write(fd, data, pagesize) != pagesize)
  1110. exit(1);
  1111. close(fd);
  1112. /*
  1113. * Next, try to mmap the file at a fixed address which
  1114. * already has something else allocated at it. If we can,
  1115. * also make sure that we see the same garbage.
  1116. */
  1117. fd = open("conftestmmap", O_RDWR);
  1118. if (fd < 0)
  1119. exit(1);
  1120. data2 = malloc(2 * pagesize);
  1121. if (!data2)
  1122. exit(1);
  1123. data2 += (pagesize - ((int) data2 & (pagesize - 1))) & (pagesize - 1);
  1124. if (data2 != mmap(data2, pagesize, PROT_READ | PROT_WRITE,
  1125. MAP_PRIVATE | MAP_FIXED, fd, 0L))
  1126. exit(1);
  1127. for (i = 0; i < pagesize; ++i)
  1128. if (*(data + i) != *(data2 + i))
  1129. exit(1);
  1130. /*
  1131. * Finally, make sure that changes to the mapped area
  1132. * do not percolate back to the file as seen by read().
  1133. * (This is a bug on some variants of i386 svr4.0.)
  1134. */
  1135. for (i = 0; i < pagesize; ++i)
  1136. *(data2 + i) = *(data2 + i) + 1;
  1137. data3 = malloc(pagesize);
  1138. if (!data3)
  1139. exit(1);
  1140. if (read(fd, data3, pagesize) != pagesize)
  1141. exit(1);
  1142. for (i = 0; i < pagesize; ++i)
  1143. if (*(data + i) != *(data3 + i))
  1144. exit(1);
  1145. close(fd);
  1146. unlink("conftestmmap");
  1147. exit(0);
  1148. }
  1149. ], ac_cv_func_mmap_fixed_mapped=yes, ac_cv_func_mmap_fixed_mapped=no,
  1150. ac_cv_func_mmap_fixed_mapped=no)])
  1151. if test $ac_cv_func_mmap_fixed_mapped = yes; then
  1152. AC_DEFINE(HAVE_MMAP)
  1153. fi
  1154. ])
  1155. AC_DEFUN(AC_FUNC_GETPGRP,
  1156. [AC_CACHE_CHECK(whether getpgrp takes no argument, ac_cv_func_getpgrp_void,
  1157. [AC_TRY_RUN([
  1158. /*
  1159. * If this system has a BSD-style getpgrp(),
  1160. * which takes a pid argument, exit unsuccessfully.
  1161. *
  1162. * Snarfed from Chet Ramey's bash pgrp.c test program
  1163. */
  1164. #include <stdio.h>
  1165. #include <sys/types.h>
  1166. int pid;
  1167. int pg1, pg2, pg3, pg4;
  1168. int ng, np, s, child;
  1169. int main()
  1170. {
  1171. pid = getpid();
  1172. pg1 = getpgrp(0);
  1173. pg2 = getpgrp();
  1174. pg3 = getpgrp(pid);
  1175. pg4 = getpgrp(1);
  1176. /*
  1177. * If all of these values are the same, it's pretty sure that
  1178. * we're on a system that ignores getpgrp's first argument.
  1179. */
  1180. if (pg2 == pg4 && pg1 == pg3 && pg2 == pg3)
  1181. exit(0);
  1182. child = fork();
  1183. if (child < 0)
  1184. exit(1);
  1185. else if (child == 0) {
  1186. np = getpid();
  1187. /*
  1188. * If this is Sys V, this will not work; pgrp will be
  1189. * set to np because setpgrp just changes a pgrp to be
  1190. * the same as the pid.
  1191. */
  1192. setpgrp(np, pg1);
  1193. ng = getpgrp(0); /* Same result for Sys V and BSD */
  1194. if (ng == pg1) {
  1195. exit(1);
  1196. } else {
  1197. exit(0);
  1198. }
  1199. } else {
  1200. wait(&s);
  1201. exit(s>>8);
  1202. }
  1203. }
  1204. ], ac_cv_func_getpgrp_void=yes, ac_cv_func_getpgrp_void=no,
  1205. AC_MSG_ERROR(cannot check getpgrp if cross compiling))
  1206. ])
  1207. if test $ac_cv_func_getpgrp_void = yes; then
  1208. AC_DEFINE(GETPGRP_VOID)
  1209. fi
  1210. ])
  1211. AC_DEFUN(AC_FUNC_SETPGRP,
  1212. [AC_CACHE_CHECK(whether setpgrp takes no argument, ac_cv_func_setpgrp_void,
  1213. AC_TRY_RUN([
  1214. #ifdef HAVE_UNISTD_H
  1215. #include <unistd.h>
  1216. #endif
  1217. /*
  1218. * If this system has a BSD-style setpgrp, which takes arguments, exit
  1219. * successfully.
  1220. */
  1221. int main()
  1222. {
  1223. if (setpgrp(1,1) == -1)
  1224. exit(0);
  1225. else
  1226. exit(1);
  1227. }
  1228. ], ac_cv_func_setpgrp_void=no, ac_cv_func_setpgrp_void=yes,
  1229. AC_MSG_ERROR(cannot check setpgrp if cross compiling))
  1230. )
  1231. if test $ac_cv_func_setpgrp_void = yes; then
  1232. AC_DEFINE(SETPGRP_VOID)
  1233. fi
  1234. ])
  1235. AC_DEFUN(AC_FUNC_VPRINTF,
  1236. [AC_CHECK_FUNC(vprintf, AC_DEFINE(HAVE_VPRINTF))
  1237. if test "$ac_cv_func_vprintf" != yes; then
  1238. AC_CHECK_FUNC(_doprnt, AC_DEFINE(HAVE_DOPRNT))
  1239. fi
  1240. ])
  1241. AC_DEFUN(AC_FUNC_VFORK,
  1242. [AC_REQUIRE([AC_TYPE_PID_T])dnl
  1243. AC_CHECK_HEADER(vfork.h, AC_DEFINE(HAVE_VFORK_H))
  1244. AC_CACHE_CHECK(for working vfork, ac_cv_func_vfork_works,
  1245. [AC_TRY_RUN([/* Thanks to Paul Eggert for this test. */
  1246. #include <stdio.h>
  1247. #include <sys/types.h>
  1248. #include <sys/stat.h>
  1249. #ifdef HAVE_UNISTD_H
  1250. #include <unistd.h>
  1251. #endif
  1252. #ifdef HAVE_VFORK_H
  1253. #include <vfork.h>
  1254. #endif
  1255. /* On some sparc systems, changes by the child to local and incoming
  1256. argument registers are propagated back to the parent.
  1257. The compiler is told about this with #include <vfork.h>,
  1258. but some compilers (e.g. gcc -O) don't grok <vfork.h>.
  1259. Test for this by using a static variable whose address
  1260. is put into a register that is clobbered by the vfork. */
  1261. static int
  1262. #ifdef __cplusplus
  1263. sparc_address_test (int arg)
  1264. #else
  1265. sparc_address_test (arg) int arg;
  1266. #endif
  1267. {
  1268. static pid_t child;
  1269. if (!child) {
  1270. child = vfork ();
  1271. if (child < 0) {
  1272. perror ("vfork");
  1273. _exit(2);
  1274. }
  1275. if (!child) {
  1276. arg = getpid();
  1277. write(-1, "", 0);
  1278. _exit (arg);
  1279. }
  1280. }
  1281. }
  1282. int main() {
  1283. pid_t parent = getpid ();
  1284. pid_t child;
  1285. ((int (*)()) sparc_address_test) ();
  1286. child = vfork ();
  1287. if (child == 0) {
  1288. /* Here is another test for sparc vfork register problems.
  1289. This test uses lots of local variables, at least
  1290. as many local variables as main has allocated so far
  1291. including compiler temporaries. 4 locals are enough for
  1292. gcc 1.40.3 on a Solaris 4.1.3 sparc, but we use 8 to be safe.
  1293. A buggy compiler should reuse the register of parent
  1294. for one of the local variables, since it will think that
  1295. parent can't possibly be used any more in this routine.
  1296. Assigning to the local variable will thus munge parent
  1297. in the parent process. */
  1298. pid_t
  1299. p = getpid(), p1 = getpid(), p2 = getpid(), p3 = getpid(),
  1300. p4 = getpid(), p5 = getpid(), p6 = getpid(), p7 = getpid();
  1301. /* Convince the compiler that p..p7 are live; otherwise, it might
  1302. use the same hardware register for all 8 local variables. */
  1303. if (p != p1 || p != p2 || p != p3 || p != p4
  1304. || p != p5 || p != p6 || p != p7)
  1305. _exit(1);
  1306. /* On some systems (e.g. IRIX 3.3),
  1307. vfork doesn't separate parent from child file descriptors.
  1308. If the child closes a descriptor before it execs or exits,
  1309. this munges the parent's descriptor as well.
  1310. Test for this by closing stdout in the child. */
  1311. _exit(close(fileno(stdout)) != 0);
  1312. } else {
  1313. int status;
  1314. struct stat st;
  1315. while (wait(&status) != child)
  1316. ;
  1317. exit(
  1318. /* Was there some problem with vforking? */
  1319. child < 0
  1320. /* Did the child fail? (This shouldn't happen.) */
  1321. || status
  1322. /* Did the vfork/compiler bug occur? */
  1323. || parent != getpid()
  1324. /* Did the file descriptor bug occur? */
  1325. || fstat(fileno(stdout), &st) != 0
  1326. );
  1327. }
  1328. }],
  1329. ac_cv_func_vfork_works=yes, ac_cv_func_vfork_works=no, AC_CHECK_FUNC(vfork)
  1330. ac_cv_func_vfork_works=$ac_cv_func_vfork)])
  1331. if test $ac_cv_func_vfork_works = no; then
  1332. AC_DEFINE(vfork, fork)
  1333. fi
  1334. ])
  1335. AC_DEFUN(AC_FUNC_WAIT3,
  1336. [AC_CACHE_CHECK(for wait3 that fills in rusage, ac_cv_func_wait3_rusage,
  1337. [AC_TRY_RUN([#include <sys/types.h>
  1338. #include <sys/time.h>
  1339. #include <sys/resource.h>
  1340. #include <stdio.h>
  1341. /* HP-UX has wait3 but does not fill in rusage at all. */
  1342. int main() {
  1343. struct rusage r;
  1344. int i;
  1345. /* Use a field that we can force nonzero --
  1346. voluntary context switches.
  1347. For systems like NeXT and OSF/1 that don't set it,
  1348. also use the system CPU time. And page faults (I/O) for Linux. */
  1349. r.ru_nvcsw = 0;
  1350. r.ru_stime.tv_sec = 0;
  1351. r.ru_stime.tv_usec = 0;
  1352. r.ru_majflt = r.ru_minflt = 0;
  1353. switch (fork()) {
  1354. case 0: /* Child. */
  1355. sleep(1); /* Give up the CPU. */
  1356. _exit(0);
  1357. case -1: _exit(0); /* What can we do? */
  1358. default: /* Parent. */
  1359. wait3(&i, 0, &r);
  1360. sleep(2); /* Avoid "text file busy" from rm on fast HP-UX machines. */
  1361. exit(r.ru_nvcsw == 0 && r.ru_majflt == 0 && r.ru_minflt == 0
  1362. && r.ru_stime.tv_sec == 0 && r.ru_stime.tv_usec == 0);
  1363. }
  1364. }], ac_cv_func_wait3_rusage=yes, ac_cv_func_wait3_rusage=no,
  1365. ac_cv_func_wait3_rusage=no)])
  1366. if test $ac_cv_func_wait3_rusage = yes; then
  1367. AC_DEFINE(HAVE_WAIT3)
  1368. fi
  1369. ])
  1370. AC_DEFUN(AC_FUNC_ALLOCA,
  1371. [AC_REQUIRE_CPP()dnl Set CPP; we run AC_EGREP_CPP conditionally.
  1372. # The Ultrix 4.2 mips builtin alloca declared by alloca.h only works
  1373. # for constant arguments. Useless!
  1374. AC_CACHE_CHECK([for working alloca.h], ac_cv_header_alloca_h,
  1375. [AC_TRY_LINK([#include <alloca.h>], [char *p = alloca(2 * sizeof(int));],
  1376. ac_cv_header_alloca_h=yes, ac_cv_header_alloca_h=no)])
  1377. if test $ac_cv_header_alloca_h = yes; then
  1378. AC_DEFINE(HAVE_ALLOCA_H)
  1379. fi
  1380. AC_CACHE_CHECK([for alloca], ac_cv_func_alloca_works,
  1381. [AC_TRY_LINK([
  1382. #ifdef __GNUC__
  1383. # define alloca __builtin_alloca
  1384. #else
  1385. # ifdef _MSC_VER
  1386. # include <malloc.h>
  1387. # define alloca _alloca
  1388. # else
  1389. # if HAVE_ALLOCA_H
  1390. # include <alloca.h>
  1391. # else
  1392. # ifdef _AIX
  1393. #pragma alloca
  1394. # else
  1395. # ifndef alloca /* predefined by HP cc +Olibcalls */
  1396. char *alloca ();
  1397. # endif
  1398. # endif
  1399. # endif
  1400. # endif
  1401. #endif
  1402. ], [char *p = (char *) alloca(1);],
  1403. ac_cv_func_alloca_works=yes, ac_cv_func_alloca_works=no)])
  1404. if test $ac_cv_func_alloca_works = yes; then
  1405. AC_DEFINE(HAVE_ALLOCA)
  1406. fi
  1407. if test $ac_cv_func_alloca_works = no; then
  1408. # The SVR3 libPW and SVR4 libucb both contain incompatible functions
  1409. # that cause trouble. Some versions do not even contain alloca or
  1410. # contain a buggy version. If you still want to use their alloca,
  1411. # use ar to extract alloca.o from them instead of compiling alloca.c.
  1412. ALLOCA=alloca.${ac_objext}
  1413. AC_DEFINE(C_ALLOCA)
  1414. AC_CACHE_CHECK(whether alloca needs Cray hooks, ac_cv_os_cray,
  1415. [AC_EGREP_CPP(webecray,
  1416. [#if defined(CRAY) && ! defined(CRAY2)
  1417. webecray
  1418. #else
  1419. wenotbecray
  1420. #endif
  1421. ], ac_cv_os_cray=yes, ac_cv_os_cray=no)])
  1422. if test $ac_cv_os_cray = yes; then
  1423. for ac_func in _getb67 GETB67 getb67; do
  1424. AC_CHECK_FUNC($ac_func, [AC_DEFINE_UNQUOTED(CRAY_STACKSEG_END, $ac_func)
  1425. break])
  1426. done
  1427. fi
  1428. AC_CACHE_CHECK(stack direction for C alloca, ac_cv_c_stack_direction,
  1429. [AC_TRY_RUN([find_stack_direction ()
  1430. {
  1431. static char *addr = 0;
  1432. auto char dummy;
  1433. if (addr == 0)
  1434. {
  1435. addr = &dummy;
  1436. return find_stack_direction ();
  1437. }
  1438. else
  1439. return (&dummy > addr) ? 1 : -1;
  1440. }
  1441. int main ()
  1442. {
  1443. exit (find_stack_direction() < 0);
  1444. }], ac_cv_c_stack_direction=1, ac_cv_c_stack_direction=-1,
  1445. ac_cv_c_stack_direction=0)])
  1446. AC_DEFINE_UNQUOTED(STACK_DIRECTION, $ac_cv_c_stack_direction)
  1447. fi
  1448. AC_SUBST(ALLOCA)dnl
  1449. ])
  1450. AC_DEFUN(AC_FUNC_GETLOADAVG,
  1451. [ac_have_func=no # yes means we've found a way to get the load average.
  1452. # Some systems with -lutil have (and need) -lkvm as well, some do not.
  1453. # On Solaris, -lkvm requires nlist from -lelf, so check that first
  1454. # to get the right answer into the cache.
  1455. AC_CHECK_LIB(elf, elf_begin, LIBS="-lelf $LIBS")
  1456. AC_CHECK_LIB(kvm, kvm_open, LIBS="-lkvm $LIBS")
  1457. # Check for the 4.4BSD definition of getloadavg.
  1458. AC_CHECK_LIB(util, getloadavg,
  1459. [LIBS="-lutil $LIBS" ac_have_func=yes ac_cv_func_getloadavg_setgid=yes])
  1460. if test $ac_have_func = no; then
  1461. # There is a commonly available library for RS/6000 AIX.
  1462. # Since it is not a standard part of AIX, it might be installed locally.
  1463. ac_getloadavg_LIBS="$LIBS"; LIBS="-L/usr/local/lib $LIBS"
  1464. AC_CHECK_LIB(getloadavg, getloadavg,
  1465. LIBS="-lgetloadavg $LIBS", LIBS="$ac_getloadavg_LIBS")
  1466. fi
  1467. # Make sure it is really in the library, if we think we found it.
  1468. AC_REPLACE_FUNCS(getloadavg)
  1469. if test $ac_cv_func_getloadavg = yes; then
  1470. AC_DEFINE(HAVE_GETLOADAVG)
  1471. ac_have_func=yes
  1472. else
  1473. # Figure out what our getloadavg.c needs.
  1474. ac_have_func=no
  1475. AC_CHECK_HEADER(sys/dg_sys_info.h,
  1476. [ac_have_func=yes; AC_DEFINE(DGUX)
  1477. AC_CHECK_LIB(dgc, dg_sys_info)])
  1478. # We cannot check for <dwarf.h>, because Solaris 2 does not use dwarf (it
  1479. # uses stabs), but it is still SVR4. We cannot check for <elf.h> because
  1480. # Irix 4.0.5F has the header but not the library.
  1481. if test $ac_have_func = no && test $ac_cv_lib_elf_elf_begin = yes; then
  1482. ac_have_func=yes; AC_DEFINE(SVR4)
  1483. fi
  1484. if test $ac_have_func = no; then
  1485. AC_CHECK_HEADER(inq_stats/cpustats.h,
  1486. [ac_have_func=yes; AC_DEFINE(UMAX)
  1487. AC_DEFINE(UMAX4_3)])
  1488. fi
  1489. if test $ac_have_func = no; then
  1490. AC_CHECK_HEADER(sys/cpustats.h,
  1491. [ac_have_func=yes; AC_DEFINE(UMAX)])
  1492. fi
  1493. if test $ac_have_func = no; then
  1494. AC_CHECK_HEADERS(mach/mach.h)
  1495. fi
  1496. AC_CHECK_HEADER(nlist.h,
  1497. [AC_DEFINE(NLIST_STRUCT)
  1498. AC_CACHE_CHECK([for n_un in struct nlist], ac_cv_struct_nlist_n_un,
  1499. [AC_TRY_COMPILE([#include <nlist.h>],
  1500. [struct nlist n; n.n_un.n_name = 0;],
  1501. ac_cv_struct_nlist_n_un=yes, ac_cv_struct_nlist_n_un=no)])
  1502. if test $ac_cv_struct_nlist_n_un = yes; then
  1503. AC_DEFINE(NLIST_NAME_UNION)
  1504. fi
  1505. ])dnl
  1506. fi # Do not have getloadavg in system libraries.
  1507. # Some definitions of getloadavg require that the program be installed setgid.
  1508. dnl FIXME Don't hardwire the path of getloadavg.c in the top-level directory.
  1509. AC_CACHE_CHECK(whether getloadavg requires setgid,
  1510. ac_cv_func_getloadavg_setgid,
  1511. [AC_EGREP_CPP([Yowza Am I SETGID yet],
  1512. [#include "$srcdir/getloadavg.c"
  1513. #ifdef LDAV_PRIVILEGED
  1514. Yowza Am I SETGID yet
  1515. #endif],
  1516. ac_cv_func_getloadavg_setgid=yes, ac_cv_func_getloadavg_setgid=no)])
  1517. if test $ac_cv_func_getloadavg_setgid = yes; then
  1518. NEED_SETGID=true; AC_DEFINE(GETLOADAVG_PRIVILEGED)
  1519. else
  1520. NEED_SETGID=false
  1521. fi
  1522. AC_SUBST(NEED_SETGID)dnl
  1523. if test $ac_cv_func_getloadavg_setgid = yes; then
  1524. AC_CACHE_CHECK(group of /dev/kmem, ac_cv_group_kmem,
  1525. [changequote(, )dnl
  1526. # On Solaris, /dev/kmem is a symlink. Get info on the real file.
  1527. ac_ls_output=`ls -lgL /dev/kmem 2>/dev/null`
  1528. # If we got an error (system does not support symlinks), try without -L.
  1529. test -z "$ac_ls_output" && ac_ls_output=`ls -lg /dev/kmem`
  1530. ac_cv_group_kmem=`echo $ac_ls_output \
  1531. | sed -ne 's/[ ][ ]*/ /g;
  1532. s/^.[sSrwx-]* *[0-9]* *\([^0-9]*\) *.*/\1/;
  1533. / /s/.* //;p;'`
  1534. changequote([, ])dnl
  1535. ])
  1536. KMEM_GROUP=$ac_cv_group_kmem
  1537. fi
  1538. AC_SUBST(KMEM_GROUP)dnl
  1539. ])
  1540. AC_DEFUN(AC_FUNC_UTIME_NULL,
  1541. [AC_CACHE_CHECK(whether utime accepts a null argument, ac_cv_func_utime_null,
  1542. [rm -f conftestdata; > conftestdata
  1543. # Sequent interprets utime(file, 0) to mean use start of epoch. Wrong.
  1544. AC_TRY_RUN([#include <sys/types.h>
  1545. #include <sys/stat.h>
  1546. int main() {
  1547. struct stat s, t;
  1548. exit(!(stat ("conftestdata", &s) == 0 && utime("conftestdata", (long *)0) == 0
  1549. && stat("conftestdata", &t) == 0 && t.st_mtime >= s.st_mtime
  1550. && t.st_mtime - s.st_mtime < 120));
  1551. }], ac_cv_func_utime_null=yes, ac_cv_func_utime_null=no,
  1552. ac_cv_func_utime_null=no)
  1553. rm -f core])
  1554. if test $ac_cv_func_utime_null = yes; then
  1555. AC_DEFINE(HAVE_UTIME_NULL)
  1556. fi
  1557. ])
  1558. AC_DEFUN(AC_FUNC_STRCOLL,
  1559. [AC_CACHE_CHECK(for working strcoll, ac_cv_func_strcoll_works,
  1560. [AC_TRY_RUN([#include <string.h>
  1561. int main ()
  1562. {
  1563. exit (strcoll ("abc", "def") >= 0 ||
  1564. strcoll ("ABC", "DEF") >= 0 ||
  1565. strcoll ("123", "456") >= 0);
  1566. }], ac_cv_func_strcoll_works=yes, ac_cv_func_strcoll_works=no,
  1567. ac_cv_func_strcoll_works=no)])
  1568. if test $ac_cv_func_strcoll_works = yes; then
  1569. AC_DEFINE(HAVE_STRCOLL)
  1570. fi
  1571. ])
  1572. AC_DEFUN(AC_FUNC_SETVBUF_REVERSED,
  1573. [AC_CACHE_CHECK(whether setvbuf arguments are reversed,
  1574. ac_cv_func_setvbuf_reversed,
  1575. [AC_TRY_RUN([#include <stdio.h>
  1576. /* If setvbuf has the reversed format, exit 0. */
  1577. int main () {
  1578. /* This call has the arguments reversed.
  1579. A reversed system may check and see that the address of main
  1580. is not _IOLBF, _IONBF, or _IOFBF, and return nonzero. */
  1581. if (setvbuf(stdout, _IOLBF, (char *) main, BUFSIZ) != 0)
  1582. exit(1);
  1583. putc('\r', stdout);
  1584. exit(0); /* Non-reversed systems segv here. */
  1585. }], ac_cv_func_setvbuf_reversed=yes, ac_cv_func_setvbuf_reversed=no)
  1586. rm -f core])
  1587. if test $ac_cv_func_setvbuf_reversed = yes; then
  1588. AC_DEFINE(SETVBUF_REVERSED)
  1589. fi
  1590. ])
  1591. AC_DEFUN(AC_FUNC_GETMNTENT,
  1592. [# getmntent is in -lsun on Irix 4, -lseq on Dynix/PTX, -lgen on Unixware.
  1593. AC_CHECK_LIB(sun, getmntent, LIBS="-lsun $LIBS",
  1594. [AC_CHECK_LIB(seq, getmntent, LIBS="-lseq $LIBS",
  1595. [AC_CHECK_LIB(gen, getmntent, LIBS="-lgen $LIBS")])])
  1596. AC_CHECK_FUNC(getmntent, [AC_DEFINE(HAVE_GETMNTENT)])])
  1597. AC_DEFUN(AC_FUNC_STRFTIME,
  1598. [AC_CHECK_FUNC(strftime, [AC_DEFINE(HAVE_STRFTIME)],
  1599. [# strftime is in -lintl on SCO UNIX.
  1600. AC_CHECK_LIB(intl, strftime,
  1601. [AC_DEFINE(HAVE_STRFTIME)
  1602. LIBS="-lintl $LIBS"])])])
  1603. AC_DEFUN(AC_FUNC_MEMCMP,
  1604. [AC_CACHE_CHECK(for 8-bit clean memcmp, ac_cv_func_memcmp_clean,
  1605. [AC_TRY_RUN([
  1606. int main()
  1607. {
  1608. char c0 = 0x40, c1 = 0x80, c2 = 0x81;
  1609. exit(memcmp(&c0, &c2, 1) < 0 && memcmp(&c1, &c2, 1) < 0 ? 0 : 1);
  1610. }
  1611. ], ac_cv_func_memcmp_clean=yes, ac_cv_func_memcmp_clean=no,
  1612. ac_cv_func_memcmp_clean=no)])
  1613. test $ac_cv_func_memcmp_clean = no && LIBOBJS="$LIBOBJS memcmp.${ac_objext}"
  1614. AC_SUBST(LIBOBJS)dnl
  1615. ])
  1616. AC_DEFUN(AC_FUNC_SELECT_ARGTYPES,
  1617. [AC_MSG_CHECKING([types of arguments for select()])
  1618. AC_CACHE_VAL(ac_cv_func_select_arg234,dnl
  1619. [AC_CACHE_VAL(ac_cv_func_select_arg1,dnl
  1620. [AC_CACHE_VAL(ac_cv_func_select_arg5,dnl
  1621. [for ac_cv_func_select_arg234 in 'fd_set *' 'int *' 'void *'; do
  1622. for ac_cv_func_select_arg1 in 'int' 'size_t' 'unsigned long' 'unsigned'; do
  1623. for ac_cv_func_select_arg5 in 'struct timeval *' 'const struct timeval *'; do
  1624. AC_TRY_COMPILE(dnl
  1625. [#ifdef HAVE_SYS_TYPES_H
  1626. #include <sys/types.h>
  1627. #endif
  1628. #ifdef HAVE_SYS_TIME_H
  1629. #include <sys/time.h>
  1630. #endif
  1631. #ifdef HAVE_SYS_SELECT_H
  1632. #include <sys/select.h>
  1633. #endif
  1634. #ifdef HAVE_SYS_SOCKET_H
  1635. #include <sys/socket.h>
  1636. #endif
  1637. extern select ($ac_cv_func_select_arg1,$ac_cv_func_select_arg234,$ac_cv_func_select_arg234,$ac_cv_func_select_arg234,$ac_cv_func_select_arg5);],,dnl
  1638. [ac_not_found=no ; break 3],ac_not_found=yes)
  1639. done
  1640. done
  1641. done
  1642. ])dnl AC_CACHE_VAL
  1643. ])dnl AC_CACHE_VAL
  1644. ])dnl AC_CACHE_VAL
  1645. if test "$ac_not_found" = yes; then
  1646. ac_cv_func_select_arg1=int
  1647. ac_cv_func_select_arg234='int *'
  1648. ac_cv_func_select_arg5='struct timeval *'
  1649. fi
  1650. AC_MSG_RESULT([$ac_cv_func_select_arg1,$ac_cv_func_select_arg234,$ac_cv_func_select_arg5])
  1651. AC_DEFINE_UNQUOTED(SELECT_TYPE_ARG1,$ac_cv_func_select_arg1)
  1652. AC_DEFINE_UNQUOTED(SELECT_TYPE_ARG234,($ac_cv_func_select_arg234))
  1653. AC_DEFINE_UNQUOTED(SELECT_TYPE_ARG5,($ac_cv_func_select_arg5))
  1654. ])
  1655. dnl ### Checks for structure members
  1656. AC_DEFUN(AC_HEADER_TIME,
  1657. [AC_CACHE_CHECK([whether time.h and sys/time.h may both be included],
  1658. ac_cv_header_time,
  1659. [AC_TRY_COMPILE([#include <sys/types.h>
  1660. #include <sys/time.h>
  1661. #include <time.h>],
  1662. [struct tm *tp;], ac_cv_header_time=yes, ac_cv_header_time=no)])
  1663. if test $ac_cv_header_time = yes; then
  1664. AC_DEFINE(TIME_WITH_SYS_TIME)
  1665. fi
  1666. ])
  1667. AC_DEFUN(AC_STRUCT_TM,
  1668. [AC_CACHE_CHECK([whether struct tm is in sys/time.h or time.h],
  1669. ac_cv_struct_tm,
  1670. [AC_TRY_COMPILE([#include <sys/types.h>
  1671. #include <time.h>],
  1672. [struct tm *tp; tp->tm_sec;],
  1673. ac_cv_struct_tm=time.h, ac_cv_struct_tm=sys/time.h)])
  1674. if test $ac_cv_struct_tm = sys/time.h; then
  1675. AC_DEFINE(TM_IN_SYS_TIME)
  1676. fi
  1677. ])
  1678. AC_DEFUN(AC_STRUCT_TIMEZONE,
  1679. [AC_REQUIRE([AC_STRUCT_TM])dnl
  1680. AC_CACHE_CHECK([for tm_zone in struct tm], ac_cv_struct_tm_zone,
  1681. [AC_TRY_COMPILE([#include <sys/types.h>
  1682. #include <$ac_cv_struct_tm>], [struct tm tm; tm.tm_zone;],
  1683. ac_cv_struct_tm_zone=yes, ac_cv_struct_tm_zone=no)])
  1684. if test "$ac_cv_struct_tm_zone" = yes; then
  1685. AC_DEFINE(HAVE_TM_ZONE)
  1686. else
  1687. AC_CACHE_CHECK(for tzname, ac_cv_var_tzname,
  1688. [AC_TRY_LINK(
  1689. changequote(<<, >>)dnl
  1690. <<#include <time.h>
  1691. #ifndef tzname /* For SGI. */
  1692. extern char *tzname[]; /* RS6000 and others reject char **tzname. */
  1693. #endif>>,
  1694. changequote([, ])dnl
  1695. [atoi(*tzname);], ac_cv_var_tzname=yes, ac_cv_var_tzname=no)])
  1696. if test $ac_cv_var_tzname = yes; then
  1697. AC_DEFINE(HAVE_TZNAME)
  1698. fi
  1699. fi
  1700. ])
  1701. AC_DEFUN(AC_STRUCT_ST_BLOCKS,
  1702. [AC_CACHE_CHECK([for st_blocks in struct stat], ac_cv_struct_st_blocks,
  1703. [AC_TRY_COMPILE([#include <sys/types.h>
  1704. #include <sys/stat.h>], [struct stat s; s.st_blocks;],
  1705. ac_cv_struct_st_blocks=yes, ac_cv_struct_st_blocks=no)])
  1706. if test $ac_cv_struct_st_blocks = yes; then
  1707. AC_DEFINE(HAVE_ST_BLOCKS)
  1708. else
  1709. LIBOBJS="$LIBOBJS fileblocks.${ac_objext}"
  1710. fi
  1711. AC_SUBST(LIBOBJS)dnl
  1712. ])
  1713. AC_DEFUN(AC_STRUCT_ST_BLKSIZE,
  1714. [AC_CACHE_CHECK([for st_blksize in struct stat], ac_cv_struct_st_blksize,
  1715. [AC_TRY_COMPILE([#include <sys/types.h>
  1716. #include <sys/stat.h>], [struct stat s; s.st_blksize;],
  1717. ac_cv_struct_st_blksize=yes, ac_cv_struct_st_blksize=no)])
  1718. if test $ac_cv_struct_st_blksize = yes; then
  1719. AC_DEFINE(HAVE_ST_BLKSIZE)
  1720. fi
  1721. ])
  1722. AC_DEFUN(AC_STRUCT_ST_RDEV,
  1723. [AC_CACHE_CHECK([for st_rdev in struct stat], ac_cv_struct_st_rdev,
  1724. [AC_TRY_COMPILE([#include <sys/types.h>
  1725. #include <sys/stat.h>], [struct stat s; s.st_rdev;],
  1726. ac_cv_struct_st_rdev=yes, ac_cv_struct_st_rdev=no)])
  1727. if test $ac_cv_struct_st_rdev = yes; then
  1728. AC_DEFINE(HAVE_ST_RDEV)
  1729. fi
  1730. ])
  1731. dnl ### Checks for compiler characteristics
  1732. AC_DEFUN(AC_C_CROSS,
  1733. [AC_OBSOLETE([$0], [; it has been merged into AC_PROG_CC])])
  1734. AC_DEFUN(AC_C_CHAR_UNSIGNED,
  1735. [AC_CACHE_CHECK(whether char is unsigned, ac_cv_c_char_unsigned,
  1736. [if test "$GCC" = yes; then
  1737. # GCC predefines this symbol on systems where it applies.
  1738. AC_EGREP_CPP(yes,
  1739. [#ifdef __CHAR_UNSIGNED__
  1740. yes
  1741. #endif
  1742. ], ac_cv_c_char_unsigned=yes, ac_cv_c_char_unsigned=no)
  1743. else
  1744. AC_TRY_RUN(
  1745. [/* volatile prevents gcc2 from optimizing the test away on sparcs. */
  1746. #if !defined(__STDC__) || __STDC__ != 1
  1747. #define volatile
  1748. #endif
  1749. int main() {
  1750. volatile char c = 255; exit(c < 0);
  1751. }], ac_cv_c_char_unsigned=yes, ac_cv_c_char_unsigned=no)
  1752. fi])
  1753. if test $ac_cv_c_char_unsigned = yes && test "$GCC" != yes; then
  1754. AC_DEFINE(__CHAR_UNSIGNED__)
  1755. fi
  1756. ])
  1757. AC_DEFUN(AC_C_LONG_DOUBLE,
  1758. [AC_CACHE_CHECK(for long double, ac_cv_c_long_double,
  1759. [if test "$GCC" = yes; then
  1760. ac_cv_c_long_double=yes
  1761. else
  1762. AC_TRY_RUN([int main() {
  1763. /* The Stardent Vistra knows sizeof(long double), but does not support it. */
  1764. long double foo = 0.0;
  1765. /* On Ultrix 4.3 cc, long double is 4 and double is 8. */
  1766. exit(sizeof(long double) < sizeof(double)); }],
  1767. ac_cv_c_long_double=yes, ac_cv_c_long_double=no)
  1768. fi])
  1769. if test $ac_cv_c_long_double = yes; then
  1770. AC_DEFINE(HAVE_LONG_DOUBLE)
  1771. fi
  1772. ])
  1773. AC_DEFUN(AC_INT_16_BITS,
  1774. [AC_OBSOLETE([$0], [; instead use AC_CHECK_SIZEOF(int)])dnl
  1775. AC_MSG_CHECKING(whether int is 16 bits)
  1776. AC_TRY_RUN([int main() { exit(sizeof(int) != 2); }],
  1777. [AC_MSG_RESULT(yes)
  1778. AC_DEFINE(INT_16_BITS)], AC_MSG_RESULT(no))
  1779. ])
  1780. AC_DEFUN(AC_LONG_64_BITS,
  1781. [AC_OBSOLETE([$0], [; instead use AC_CHECK_SIZEOF(long)])dnl
  1782. AC_MSG_CHECKING(whether long int is 64 bits)
  1783. AC_TRY_RUN([int main() { exit(sizeof(long int) != 8); }],
  1784. [AC_MSG_RESULT(yes)
  1785. AC_DEFINE(LONG_64_BITS)], AC_MSG_RESULT(no))
  1786. ])
  1787. AC_DEFUN(AC_C_BIGENDIAN,
  1788. [AC_CACHE_CHECK(whether byte ordering is bigendian, ac_cv_c_bigendian,
  1789. [ac_cv_c_bigendian=unknown
  1790. # See if sys/param.h defines the BYTE_ORDER macro.
  1791. AC_TRY_COMPILE([#include <sys/types.h>
  1792. #include <sys/param.h>], [
  1793. #if !BYTE_ORDER || !BIG_ENDIAN || !LITTLE_ENDIAN
  1794. bogus endian macros
  1795. #endif], [# It does; now see whether it defined to BIG_ENDIAN or not.
  1796. AC_TRY_COMPILE([#include <sys/types.h>
  1797. #include <sys/param.h>], [
  1798. #if BYTE_ORDER != BIG_ENDIAN
  1799. not big endian
  1800. #endif], ac_cv_c_bigendian=yes, ac_cv_c_bigendian=no)])
  1801. if test $ac_cv_c_bigendian = unknown; then
  1802. AC_TRY_RUN([int main () {
  1803. /* Are we little or big endian? From Harbison&Steele. */
  1804. union
  1805. {
  1806. long l;
  1807. char c[sizeof (long)];
  1808. } u;
  1809. u.l = 1;
  1810. exit (u.c[sizeof (long) - 1] == 1);
  1811. }], ac_cv_c_bigendian=no, ac_cv_c_bigendian=yes)
  1812. fi])
  1813. if test $ac_cv_c_bigendian = yes; then
  1814. AC_DEFINE(WORDS_BIGENDIAN)
  1815. fi
  1816. ])
  1817. dnl Do nothing if the compiler accepts the inline keyword.
  1818. dnl Otherwise define inline to __inline__ or __inline if one of those work,
  1819. dnl otherwise define inline to be empty.
  1820. AC_DEFUN(AC_C_INLINE,
  1821. [AC_CACHE_CHECK([for inline], ac_cv_c_inline,
  1822. [ac_cv_c_inline=no
  1823. for ac_kw in inline __inline__ __inline; do
  1824. AC_TRY_COMPILE(, [} $ac_kw foo() {], [ac_cv_c_inline=$ac_kw; break])
  1825. done
  1826. ])
  1827. case "$ac_cv_c_inline" in
  1828. inline | yes) ;;
  1829. no) AC_DEFINE(inline, ) ;;
  1830. *) AC_DEFINE_UNQUOTED(inline, $ac_cv_c_inline) ;;
  1831. esac
  1832. ])
  1833. AC_DEFUN(AC_C_CONST,
  1834. [dnl This message is consistent in form with the other checking messages,
  1835. dnl and with the result message.
  1836. AC_CACHE_CHECK([for working const], ac_cv_c_const,
  1837. [AC_TRY_COMPILE(,
  1838. changequote(<<, >>)dnl
  1839. <<
  1840. #ifndef __cplusplus
  1841. /* Ultrix mips cc rejects this. */
  1842. typedef int charset[2]; const charset x;
  1843. #endif
  1844. /* SunOS 4.1.1 cc rejects this. */
  1845. char const *const *ccp;
  1846. char **p;
  1847. /* NEC SVR4.0.2 mips cc rejects this. */
  1848. struct point {int x, y;};
  1849. static struct point const zero = {0,0};
  1850. /* AIX XL C 1.02.0.0 rejects this.
  1851. It does not let you subtract one const X* pointer from another in an arm
  1852. of an if-expression whose if-part is not a constant expression */
  1853. const char *g = "string";
  1854. ccp = &g + (g ? g-g : 0);
  1855. /* HPUX 7.0 cc rejects these. */
  1856. ++ccp;
  1857. p = (char**) ccp;
  1858. ccp = (char const *const *) p;
  1859. { /* SCO 3.2v4 cc rejects this. */
  1860. char *t;
  1861. char const *s = 0 ? (char *) 0 : (char const *) 0;
  1862. *t++ = 0;
  1863. }
  1864. { /* Someone thinks the Sun supposedly-ANSI compiler will reject this. */
  1865. int x[] = {25, 17};
  1866. const int *foo = &x[0];
  1867. ++foo;
  1868. }
  1869. { /* Sun SC1.0 ANSI compiler rejects this -- but not the above. */
  1870. typedef const int *iptr;
  1871. iptr p = 0;
  1872. ++p;
  1873. }
  1874. { /* AIX XL C 1.02.0.0 rejects this saying
  1875. "k.c", line 2.27: 1506-025 (S) Operand must be a modifiable lvalue. */
  1876. struct s { int j; const int *ap[3]; };
  1877. struct s *b; b->j = 5;
  1878. }
  1879. { /* ULTRIX-32 V3.1 (Rev 9) vcc rejects this */
  1880. const int foo = 10;
  1881. }
  1882. >>,
  1883. changequote([, ])dnl
  1884. ac_cv_c_const=yes, ac_cv_c_const=no)])
  1885. if test $ac_cv_c_const = no; then
  1886. AC_DEFINE(const, )
  1887. fi
  1888. ])
  1889. AC_DEFUN(AC_C_STRINGIZE, [
  1890. AC_REQUIRE([AC_PROG_CPP])
  1891. AC_MSG_CHECKING([for preprocessor stringizing operator])
  1892. AC_CACHE_VAL(ac_cv_c_stringize,
  1893. AC_EGREP_CPP([#teststring],[
  1894. #define x(y) #y
  1895. char *s = x(teststring);
  1896. ], ac_cv_c_stringize=no, ac_cv_c_stringize=yes))
  1897. if test "${ac_cv_c_stringize}" = yes
  1898. then
  1899. AC_DEFINE(HAVE_STRINGIZE)
  1900. fi
  1901. AC_MSG_RESULT([${ac_cv_c_stringize}])
  1902. ])dnl
  1903. define(AC_ARG_ARRAY,
  1904. [errprint(__file__:__line__: [$0] has been removed; don't do unportable things with arguments
  1905. )m4exit(4)])
  1906. dnl Check the object extension used by the compiler: typically .o or
  1907. dnl .obj. If this is called, some other behaviour will change,
  1908. dnl determined by ac_objext.
  1909. AC_DEFUN(AC_OBJEXT,
  1910. [AC_MSG_CHECKING([for object suffix])
  1911. AC_CACHE_VAL(ac_cv_objext,
  1912. [rm -f conftest*
  1913. echo 'int i = 1;' > conftest.$ac_ext
  1914. if AC_TRY_EVAL(ac_compile); then
  1915. for ac_file in conftest.*; do
  1916. case $ac_file in
  1917. *.c) ;;
  1918. *) ac_cv_objext=`echo $ac_file | sed -e s/conftest.//` ;;
  1919. esac
  1920. done
  1921. else
  1922. AC_MSG_ERROR([installation or configuration problem; compiler does not work])
  1923. fi
  1924. rm -f conftest*])
  1925. AC_MSG_RESULT($ac_cv_objext)
  1926. OBJEXT=$ac_cv_objext
  1927. ac_objext=$ac_cv_objext
  1928. AC_SUBST(OBJEXT)])
  1929. dnl Determine the linker flags (e.g. `-L' and `-l') for the Fortran 77
  1930. dnl intrinsic and run-time libraries that are required to successfully
  1931. dnl link a Fortran 77 program or shared library. The output variable
  1932. dnl FLIBS is set to these flags.
  1933. dnl
  1934. dnl This macro is intended to be used in those situations when it is
  1935. dnl necessary to mix, e.g. C++ and Fortran 77, source code into a single
  1936. dnl program or shared library.
  1937. dnl
  1938. dnl For example, if object files from a C++ and Fortran 77 compiler must
  1939. dnl be linked together, then the C++ compiler/linker must be used for
  1940. dnl linking (since special C++-ish things need to happen at link time
  1941. dnl like calling global constructors, instantiating templates, enabling
  1942. dnl exception support, etc.).
  1943. dnl
  1944. dnl However, the Fortran 77 intrinsic and run-time libraries must be
  1945. dnl linked in as well, but the C++ compiler/linker doesn't know how to
  1946. dnl add these Fortran 77 libraries. Hence, the macro
  1947. dnl `AC_F77_LIBRARY_LDFLAGS' was created to determine these Fortran 77
  1948. dnl libraries.
  1949. dnl
  1950. dnl This macro was packaged in its current form by Matthew D. Langston
  1951. dnl <langston@SLAC.Stanford.EDU>. However, nearly all of this macro
  1952. dnl came from the `OCTAVE_FLIBS' macro in `octave-2.0.13/aclocal.m4',
  1953. dnl and full credit should go to John W. Eaton for writing this
  1954. dnl extremely useful macro. Thank you John.
  1955. dnl
  1956. dnl AC_F77_LIBRARY_LDFLAGS()
  1957. AC_DEFUN(AC_F77_LIBRARY_LDFLAGS,
  1958. [AC_MSG_CHECKING([for Fortran 77 libraries])
  1959. AC_REQUIRE([AC_PROG_F77])
  1960. AC_REQUIRE([AC_CANONICAL_HOST])
  1961. AC_CACHE_VAL(ac_cv_flibs,
  1962. [changequote(, )dnl
  1963. dnl Write a minimal program and compile it with -v. I don't know what
  1964. dnl to do if your compiler doesn't have -v...
  1965. echo " END" > conftest.f
  1966. foutput=`${F77} -v -o conftest conftest.f 2>&1`
  1967. dnl
  1968. dnl The easiest thing to do for xlf output is to replace all the commas
  1969. dnl with spaces. Try to only do that if the output is really from xlf,
  1970. dnl since doing that causes problems on other systems.
  1971. dnl
  1972. xlf_p=`echo $foutput | grep xlfentry`
  1973. if test -n "$xlf_p"; then
  1974. foutput=`echo $foutput | sed 's/,/ /g'`
  1975. fi
  1976. dnl
  1977. ld_run_path=`echo $foutput | \
  1978. sed -n -e 's/^.*LD_RUN_PATH *= *\([^ ]*\).*/\1/p'`
  1979. dnl
  1980. dnl We are only supposed to find this on Solaris systems...
  1981. dnl Uh, the run path should be absolute, shouldn't it?
  1982. dnl
  1983. case "$ld_run_path" in
  1984. /*)
  1985. if test "$ac_cv_prog_gcc" = yes; then
  1986. ld_run_path="-Xlinker -R -Xlinker $ld_run_path"
  1987. else
  1988. ld_run_path="-R $ld_run_path"
  1989. fi
  1990. ;;
  1991. *)
  1992. ld_run_path=
  1993. ;;
  1994. esac
  1995. dnl
  1996. flibs=
  1997. lflags=
  1998. dnl
  1999. dnl If want_arg is set, we know we want the arg to be added to the list,
  2000. dnl so we don't have to examine it.
  2001. dnl
  2002. want_arg=
  2003. dnl
  2004. for arg in $foutput; do
  2005. old_want_arg=$want_arg
  2006. want_arg=
  2007. dnl
  2008. dnl None of the options that take arguments expect the argument to
  2009. dnl start with a -, so pretend we didn't see anything special.
  2010. dnl
  2011. if test -n "$old_want_arg"; then
  2012. case "$arg" in
  2013. -*)
  2014. old_want_arg=
  2015. ;;
  2016. esac
  2017. fi
  2018. case "$old_want_arg" in
  2019. '')
  2020. case $arg in
  2021. /*.a)
  2022. exists=false
  2023. for f in $lflags; do
  2024. if test x$arg = x$f; then
  2025. exists=true
  2026. fi
  2027. done
  2028. if $exists; then
  2029. arg=
  2030. else
  2031. lflags="$lflags $arg"
  2032. fi
  2033. ;;
  2034. -bI:*)
  2035. exists=false
  2036. for f in $lflags; do
  2037. if test x$arg = x$f; then
  2038. exists=true
  2039. fi
  2040. done
  2041. if $exists; then
  2042. arg=
  2043. else
  2044. if test "$ac_cv_prog_gcc" = yes; then
  2045. lflags="$lflags -Xlinker $arg"
  2046. else
  2047. lflags="$lflags $arg"
  2048. fi
  2049. fi
  2050. ;;
  2051. -lang* | -lcrt0.o | -lc | -lgcc)
  2052. arg=
  2053. ;;
  2054. -[lLR])
  2055. want_arg=$arg
  2056. arg=
  2057. ;;
  2058. -[lLR]*)
  2059. exists=false
  2060. for f in $lflags; do
  2061. if test x$arg = x$f; then
  2062. exists=true
  2063. fi
  2064. done
  2065. if $exists; then
  2066. arg=
  2067. else
  2068. case "$arg" in
  2069. -lkernel32)
  2070. case "$canonical_host_type" in
  2071. *-*-cygwin*)
  2072. arg=
  2073. ;;
  2074. *)
  2075. lflags="$lflags $arg"
  2076. ;;
  2077. esac
  2078. ;;
  2079. -lm)
  2080. ;;
  2081. *)
  2082. lflags="$lflags $arg"
  2083. ;;
  2084. esac
  2085. fi
  2086. ;;
  2087. -u)
  2088. want_arg=$arg
  2089. arg=
  2090. ;;
  2091. -Y)
  2092. want_arg=$arg
  2093. arg=
  2094. ;;
  2095. *)
  2096. arg=
  2097. ;;
  2098. esac
  2099. ;;
  2100. -[lLR])
  2101. arg="$old_want_arg $arg"
  2102. ;;
  2103. -u)
  2104. arg="-u $arg"
  2105. ;;
  2106. -Y)
  2107. dnl
  2108. dnl Should probably try to ensure unique directory options here too.
  2109. dnl This probably only applies to Solaris systems, and then will only
  2110. dnl work with gcc...
  2111. dnl
  2112. arg=`echo $arg | sed -e 's%^P,%%'`
  2113. SAVE_IFS=$IFS
  2114. IFS=:
  2115. list=
  2116. for elt in $arg; do
  2117. list="$list -L$elt"
  2118. done
  2119. IFS=$SAVE_IFS
  2120. arg="$list"
  2121. ;;
  2122. esac
  2123. dnl
  2124. if test -n "$arg"; then
  2125. flibs="$flibs $arg"
  2126. fi
  2127. done
  2128. if test -n "$ld_run_path"; then
  2129. flibs_result="$ld_run_path $flibs"
  2130. else
  2131. flibs_result="$flibs"
  2132. fi
  2133. changequote([, ])dnl
  2134. ac_cv_flibs="$flibs_result"])
  2135. FLIBS="$ac_cv_flibs"
  2136. AC_SUBST(FLIBS)dnl
  2137. AC_MSG_RESULT($FLIBS)
  2138. ])
  2139. dnl ### Checks for operating system services
  2140. AC_DEFUN(AC_SYS_INTERPRETER,
  2141. [# Pull the hash mark out of the macro call to avoid m4 problems.
  2142. ac_msg="whether #! works in shell scripts"
  2143. AC_CACHE_CHECK($ac_msg, ac_cv_sys_interpreter,
  2144. [echo '#! /bin/cat
  2145. exit 69
  2146. ' > conftest
  2147. chmod u+x conftest
  2148. (SHELL=/bin/sh; export SHELL; ./conftest >/dev/null)
  2149. if test $? -ne 69; then
  2150. ac_cv_sys_interpreter=yes
  2151. else
  2152. ac_cv_sys_interpreter=no
  2153. fi
  2154. rm -f conftest])
  2155. interpval="$ac_cv_sys_interpreter"
  2156. ])
  2157. define(AC_HAVE_POUNDBANG,
  2158. [errprint(__file__:__line__: [$0 has been replaced by AC_SYS_INTERPRETER, taking no arguments
  2159. ])m4exit(4)])
  2160. AC_DEFUN(AC_SYS_LONG_FILE_NAMES,
  2161. [AC_CACHE_CHECK(for long file names, ac_cv_sys_long_file_names,
  2162. [ac_cv_sys_long_file_names=yes
  2163. # Test for long file names in all the places we know might matter:
  2164. # . the current directory, where building will happen
  2165. # $prefix/lib where we will be installing things
  2166. # $exec_prefix/lib likewise
  2167. # eval it to expand exec_prefix.
  2168. # $TMPDIR if set, where it might want to write temporary files
  2169. # if $TMPDIR is not set:
  2170. # /tmp where it might want to write temporary files
  2171. # /var/tmp likewise
  2172. # /usr/tmp likewise
  2173. if test -n "$TMPDIR" && test -d "$TMPDIR" && test -w "$TMPDIR"; then
  2174. ac_tmpdirs="$TMPDIR"
  2175. else
  2176. ac_tmpdirs='/tmp /var/tmp /usr/tmp'
  2177. fi
  2178. for ac_dir in . $ac_tmpdirs `eval echo $prefix/lib $exec_prefix/lib` ; do
  2179. test -d $ac_dir || continue
  2180. test -w $ac_dir || continue # It is less confusing to not echo anything here.
  2181. (echo 1 > $ac_dir/conftest9012345) 2>/dev/null
  2182. (echo 2 > $ac_dir/conftest9012346) 2>/dev/null
  2183. val=`cat $ac_dir/conftest9012345 2>/dev/null`
  2184. if test ! -f $ac_dir/conftest9012345 || test "$val" != 1; then
  2185. ac_cv_sys_long_file_names=no
  2186. rm -f $ac_dir/conftest9012345 $ac_dir/conftest9012346 2>/dev/null
  2187. break
  2188. fi
  2189. rm -f $ac_dir/conftest9012345 $ac_dir/conftest9012346 2>/dev/null
  2190. done])
  2191. if test $ac_cv_sys_long_file_names = yes; then
  2192. AC_DEFINE(HAVE_LONG_FILE_NAMES)
  2193. fi
  2194. ])
  2195. AC_DEFUN(AC_SYS_RESTARTABLE_SYSCALLS,
  2196. [AC_CACHE_CHECK(for restartable system calls, ac_cv_sys_restartable_syscalls,
  2197. [AC_TRY_RUN(
  2198. [/* Exit 0 (true) if wait returns something other than -1,
  2199. i.e. the pid of the child, which means that wait was restarted
  2200. after getting the signal. */
  2201. #include <sys/types.h>
  2202. #include <signal.h>
  2203. ucatch (isig) { }
  2204. int main () {
  2205. int i = fork (), status;
  2206. if (i == 0) { sleep (3); kill (getppid (), SIGINT); sleep (3); exit (0); }
  2207. signal (SIGINT, ucatch);
  2208. status = wait(&i);
  2209. if (status == -1) wait(&i);
  2210. exit (status == -1);
  2211. }
  2212. ], ac_cv_sys_restartable_syscalls=yes, ac_cv_sys_restartable_syscalls=no)])
  2213. if test $ac_cv_sys_restartable_syscalls = yes; then
  2214. AC_DEFINE(HAVE_RESTARTABLE_SYSCALLS)
  2215. fi
  2216. ])
  2217. AC_DEFUN(AC_PATH_X,
  2218. [AC_REQUIRE_CPP()dnl Set CPP; we run AC_PATH_X_DIRECT conditionally.
  2219. # If we find X, set shell vars x_includes and x_libraries to the
  2220. # paths, otherwise set no_x=yes.
  2221. # Uses ac_ vars as temps to allow command line to override cache and checks.
  2222. # --without-x overrides everything else, but does not touch the cache.
  2223. AC_MSG_CHECKING(for X)
  2224. AC_ARG_WITH(x, [ --with-x use the X Window System])
  2225. # $have_x is `yes', `no', `disabled', or empty when we do not yet know.
  2226. if test "x$with_x" = xno; then
  2227. # The user explicitly disabled X.
  2228. have_x=disabled
  2229. else
  2230. if test "x$x_includes" != xNONE && test "x$x_libraries" != xNONE; then
  2231. # Both variables are already set.
  2232. have_x=yes
  2233. else
  2234. AC_CACHE_VAL(ac_cv_have_x,
  2235. [# One or both of the vars are not set, and there is no cached value.
  2236. ac_x_includes=NO ac_x_libraries=NO
  2237. AC_PATH_X_XMKMF
  2238. AC_PATH_X_DIRECT
  2239. if test "$ac_x_includes" = NO || test "$ac_x_libraries" = NO; then
  2240. # Didn't find X anywhere. Cache the known absence of X.
  2241. ac_cv_have_x="have_x=no"
  2242. else
  2243. # Record where we found X for the cache.
  2244. ac_cv_have_x="have_x=yes \
  2245. ac_x_includes=$ac_x_includes ac_x_libraries=$ac_x_libraries"
  2246. fi])dnl
  2247. fi
  2248. eval "$ac_cv_have_x"
  2249. fi # $with_x != no
  2250. if test "$have_x" != yes; then
  2251. AC_MSG_RESULT($have_x)
  2252. no_x=yes
  2253. else
  2254. # If each of the values was on the command line, it overrides each guess.
  2255. test "x$x_includes" = xNONE && x_includes=$ac_x_includes
  2256. test "x$x_libraries" = xNONE && x_libraries=$ac_x_libraries
  2257. # Update the cache value to reflect the command line values.
  2258. ac_cv_have_x="have_x=yes \
  2259. ac_x_includes=$x_includes ac_x_libraries=$x_libraries"
  2260. AC_MSG_RESULT([libraries $x_libraries, headers $x_includes])
  2261. fi
  2262. ])
  2263. dnl Internal subroutine of AC_PATH_X.
  2264. dnl Set ac_x_includes and/or ac_x_libraries.
  2265. AC_DEFUN(AC_PATH_X_XMKMF,
  2266. [rm -fr conftestdir
  2267. if mkdir conftestdir; then
  2268. cd conftestdir
  2269. # Make sure to not put "make" in the Imakefile rules, since we grep it out.
  2270. cat > Imakefile <<'EOF'
  2271. acfindx:
  2272. @echo 'ac_im_incroot="${INCROOT}"; ac_im_usrlibdir="${USRLIBDIR}"; ac_im_libdir="${LIBDIR}"'
  2273. EOF
  2274. if (xmkmf) >/dev/null 2>/dev/null && test -f Makefile; then
  2275. # GNU make sometimes prints "make[1]: Entering...", which would confuse us.
  2276. eval `${MAKE-make} acfindx 2>/dev/null | grep -v make`
  2277. # Open Windows xmkmf reportedly sets LIBDIR instead of USRLIBDIR.
  2278. for ac_extension in a so sl; do
  2279. if test ! -f $ac_im_usrlibdir/libX11.$ac_extension &&
  2280. test -f $ac_im_libdir/libX11.$ac_extension; then
  2281. ac_im_usrlibdir=$ac_im_libdir; break
  2282. fi
  2283. done
  2284. # Screen out bogus values from the imake configuration. They are
  2285. # bogus both because they are the default anyway, and because
  2286. # using them would break gcc on systems where it needs fixed includes.
  2287. case "$ac_im_incroot" in
  2288. /usr/include) ;;
  2289. *) test -f "$ac_im_incroot/X11/Xos.h" && ac_x_includes="$ac_im_incroot" ;;
  2290. esac
  2291. case "$ac_im_usrlibdir" in
  2292. /usr/lib | /lib) ;;
  2293. *) test -d "$ac_im_usrlibdir" && ac_x_libraries="$ac_im_usrlibdir" ;;
  2294. esac
  2295. fi
  2296. cd ..
  2297. rm -fr conftestdir
  2298. fi
  2299. ])
  2300. dnl Internal subroutine of AC_PATH_X.
  2301. dnl Set ac_x_includes and/or ac_x_libraries.
  2302. AC_DEFUN(AC_PATH_X_DIRECT,
  2303. [if test "$ac_x_includes" = NO; then
  2304. # Guess where to find include files, by looking for this one X11 .h file.
  2305. test -z "$x_direct_test_include" && x_direct_test_include=X11/Intrinsic.h
  2306. # First, try using that file with no special directory specified.
  2307. AC_TRY_CPP([#include <$x_direct_test_include>],
  2308. [# We can compile using X headers with no special include directory.
  2309. ac_x_includes=],
  2310. [# Look for the header file in a standard set of common directories.
  2311. # Check X11 before X11Rn because it is often a symlink to the current release.
  2312. for ac_dir in \
  2313. /usr/X11/include \
  2314. /usr/X11R6/include \
  2315. /usr/X11R5/include \
  2316. /usr/X11R4/include \
  2317. \
  2318. /usr/include/X11 \
  2319. /usr/include/X11R6 \
  2320. /usr/include/X11R5 \
  2321. /usr/include/X11R4 \
  2322. \
  2323. /usr/local/X11/include \
  2324. /usr/local/X11R6/include \
  2325. /usr/local/X11R5/include \
  2326. /usr/local/X11R4/include \
  2327. \
  2328. /usr/local/include/X11 \
  2329. /usr/local/include/X11R6 \
  2330. /usr/local/include/X11R5 \
  2331. /usr/local/include/X11R4 \
  2332. \
  2333. /usr/X386/include \
  2334. /usr/x386/include \
  2335. /usr/XFree86/include/X11 \
  2336. \
  2337. /usr/include \
  2338. /usr/local/include \
  2339. /usr/unsupported/include \
  2340. /usr/athena/include \
  2341. /usr/local/x11r5/include \
  2342. /usr/lpp/Xamples/include \
  2343. \
  2344. /usr/openwin/include \
  2345. /usr/openwin/share/include \
  2346. ; \
  2347. do
  2348. if test -r "$ac_dir/$x_direct_test_include"; then
  2349. ac_x_includes=$ac_dir
  2350. break
  2351. fi
  2352. done])
  2353. fi # $ac_x_includes = NO
  2354. if test "$ac_x_libraries" = NO; then
  2355. # Check for the libraries.
  2356. test -z "$x_direct_test_library" && x_direct_test_library=Xt
  2357. test -z "$x_direct_test_function" && x_direct_test_function=XtMalloc
  2358. # See if we find them without any special options.
  2359. # Don't add to $LIBS permanently.
  2360. ac_save_LIBS="$LIBS"
  2361. LIBS="-l$x_direct_test_library $LIBS"
  2362. AC_TRY_LINK(, [${x_direct_test_function}()],
  2363. [LIBS="$ac_save_LIBS"
  2364. # We can link X programs with no special library path.
  2365. ac_x_libraries=],
  2366. [LIBS="$ac_save_LIBS"
  2367. # First see if replacing the include by lib works.
  2368. # Check X11 before X11Rn because it is often a symlink to the current release.
  2369. for ac_dir in `echo "$ac_x_includes" | sed s/include/lib/` \
  2370. /usr/X11/lib \
  2371. /usr/X11R6/lib \
  2372. /usr/X11R5/lib \
  2373. /usr/X11R4/lib \
  2374. \
  2375. /usr/lib/X11 \
  2376. /usr/lib/X11R6 \
  2377. /usr/lib/X11R5 \
  2378. /usr/lib/X11R4 \
  2379. \
  2380. /usr/local/X11/lib \
  2381. /usr/local/X11R6/lib \
  2382. /usr/local/X11R5/lib \
  2383. /usr/local/X11R4/lib \
  2384. \
  2385. /usr/local/lib/X11 \
  2386. /usr/local/lib/X11R6 \
  2387. /usr/local/lib/X11R5 \
  2388. /usr/local/lib/X11R4 \
  2389. \
  2390. /usr/X386/lib \
  2391. /usr/x386/lib \
  2392. /usr/XFree86/lib/X11 \
  2393. \
  2394. /usr/lib \
  2395. /usr/local/lib \
  2396. /usr/unsupported/lib \
  2397. /usr/athena/lib \
  2398. /usr/local/x11r5/lib \
  2399. /usr/lpp/Xamples/lib \
  2400. /lib/usr/lib/X11 \
  2401. \
  2402. /usr/openwin/lib \
  2403. /usr/openwin/share/lib \
  2404. ; \
  2405. do
  2406. dnl Don't even attempt the hair of trying to link an X program!
  2407. for ac_extension in a so sl; do
  2408. if test -r $ac_dir/lib${x_direct_test_library}.$ac_extension; then
  2409. ac_x_libraries=$ac_dir
  2410. break 2
  2411. fi
  2412. done
  2413. done])
  2414. fi # $ac_x_libraries = NO
  2415. ])
  2416. dnl Find additional X libraries, magic flags, etc.
  2417. AC_DEFUN(AC_PATH_XTRA,
  2418. [AC_REQUIRE([AC_PATH_X])dnl
  2419. if test "$no_x" = yes; then
  2420. # Not all programs may use this symbol, but it does not hurt to define it.
  2421. AC_DEFINE(X_DISPLAY_MISSING)
  2422. X_CFLAGS= X_PRE_LIBS= X_LIBS= X_EXTRA_LIBS=
  2423. else
  2424. if test -n "$x_includes"; then
  2425. X_CFLAGS="$X_CFLAGS -I$x_includes"
  2426. fi
  2427. # It would also be nice to do this for all -L options, not just this one.
  2428. if test -n "$x_libraries"; then
  2429. X_LIBS="$X_LIBS -L$x_libraries"
  2430. dnl FIXME banish uname from this macro!
  2431. # For Solaris; some versions of Sun CC require a space after -R and
  2432. # others require no space. Words are not sufficient . . . .
  2433. case "`(uname -sr) 2>/dev/null`" in
  2434. "SunOS 5"*)
  2435. AC_MSG_CHECKING(whether -R must be followed by a space)
  2436. ac_xsave_LIBS="$LIBS"; LIBS="$LIBS -R$x_libraries"
  2437. AC_TRY_LINK(, , ac_R_nospace=yes, ac_R_nospace=no)
  2438. if test $ac_R_nospace = yes; then
  2439. AC_MSG_RESULT(no)
  2440. X_LIBS="$X_LIBS -R$x_libraries"
  2441. else
  2442. LIBS="$ac_xsave_LIBS -R $x_libraries"
  2443. AC_TRY_LINK(, , ac_R_space=yes, ac_R_space=no)
  2444. if test $ac_R_space = yes; then
  2445. AC_MSG_RESULT(yes)
  2446. X_LIBS="$X_LIBS -R $x_libraries"
  2447. else
  2448. AC_MSG_RESULT(neither works)
  2449. fi
  2450. fi
  2451. LIBS="$ac_xsave_LIBS"
  2452. esac
  2453. fi
  2454. # Check for system-dependent libraries X programs must link with.
  2455. # Do this before checking for the system-independent R6 libraries
  2456. # (-lICE), since we may need -lsocket or whatever for X linking.
  2457. if test "$ISC" = yes; then
  2458. X_EXTRA_LIBS="$X_EXTRA_LIBS -lnsl_s -linet"
  2459. else
  2460. # Martyn.Johnson@cl.cam.ac.uk says this is needed for Ultrix, if the X
  2461. # libraries were built with DECnet support. And karl@cs.umb.edu says
  2462. # the Alpha needs dnet_stub (dnet does not exist).
  2463. AC_CHECK_LIB(dnet, dnet_ntoa, [X_EXTRA_LIBS="$X_EXTRA_LIBS -ldnet"])
  2464. if test $ac_cv_lib_dnet_dnet_ntoa = no; then
  2465. AC_CHECK_LIB(dnet_stub, dnet_ntoa,
  2466. [X_EXTRA_LIBS="$X_EXTRA_LIBS -ldnet_stub"])
  2467. fi
  2468. # msh@cis.ufl.edu says -lnsl (and -lsocket) are needed for his 386/AT,
  2469. # to get the SysV transport functions.
  2470. # chad@anasazi.com says the Pyramis MIS-ES running DC/OSx (SVR4)
  2471. # needs -lnsl.
  2472. # The nsl library prevents programs from opening the X display
  2473. # on Irix 5.2, according to dickey@clark.net.
  2474. AC_CHECK_FUNC(gethostbyname)
  2475. if test $ac_cv_func_gethostbyname = no; then
  2476. AC_CHECK_LIB(nsl, gethostbyname, X_EXTRA_LIBS="$X_EXTRA_LIBS -lnsl")
  2477. fi
  2478. # lieder@skyler.mavd.honeywell.com says without -lsocket,
  2479. # socket/setsockopt and other routines are undefined under SCO ODT
  2480. # 2.0. But -lsocket is broken on IRIX 5.2 (and is not necessary
  2481. # on later versions), says simon@lia.di.epfl.ch: it contains
  2482. # gethostby* variants that don't use the nameserver (or something).
  2483. # -lsocket must be given before -lnsl if both are needed.
  2484. # We assume that if connect needs -lnsl, so does gethostbyname.
  2485. AC_CHECK_FUNC(connect)
  2486. if test $ac_cv_func_connect = no; then
  2487. AC_CHECK_LIB(socket, connect, X_EXTRA_LIBS="-lsocket $X_EXTRA_LIBS", ,
  2488. $X_EXTRA_LIBS)
  2489. fi
  2490. # gomez@mi.uni-erlangen.de says -lposix is necessary on A/UX.
  2491. AC_CHECK_FUNC(remove)
  2492. if test $ac_cv_func_remove = no; then
  2493. AC_CHECK_LIB(posix, remove, X_EXTRA_LIBS="$X_EXTRA_LIBS -lposix")
  2494. fi
  2495. # BSDI BSD/OS 2.1 needs -lipc for XOpenDisplay.
  2496. AC_CHECK_FUNC(shmat)
  2497. if test $ac_cv_func_shmat = no; then
  2498. AC_CHECK_LIB(ipc, shmat, X_EXTRA_LIBS="$X_EXTRA_LIBS -lipc")
  2499. fi
  2500. fi
  2501. # Check for libraries that X11R6 Xt/Xaw programs need.
  2502. ac_save_LDFLAGS="$LDFLAGS"
  2503. test -n "$x_libraries" && LDFLAGS="$LDFLAGS -L$x_libraries"
  2504. # SM needs ICE to (dynamically) link under SunOS 4.x (so we have to
  2505. # check for ICE first), but we must link in the order -lSM -lICE or
  2506. # we get undefined symbols. So assume we have SM if we have ICE.
  2507. # These have to be linked with before -lX11, unlike the other
  2508. # libraries we check for below, so use a different variable.
  2509. # --interran@uluru.Stanford.EDU, kb@cs.umb.edu.
  2510. AC_CHECK_LIB(ICE, IceConnectionNumber,
  2511. [X_PRE_LIBS="$X_PRE_LIBS -lSM -lICE"], , $X_EXTRA_LIBS)
  2512. LDFLAGS="$ac_save_LDFLAGS"
  2513. fi
  2514. AC_SUBST(X_CFLAGS)dnl
  2515. AC_SUBST(X_PRE_LIBS)dnl
  2516. AC_SUBST(X_LIBS)dnl
  2517. AC_SUBST(X_EXTRA_LIBS)dnl
  2518. ])
  2519. dnl The old Cygwin32 macro is deprecated.
  2520. AC_DEFUN(AC_CYGWIN32,
  2521. [AC_OBSOLETE([$0], [; instead use AC_CYGWIN])dnl
  2522. AC_CYGWIN])
  2523. dnl Check for Cygwin. This is a way to set the right value for
  2524. dnl EXEEXT.
  2525. AC_DEFUN(AC_CYGWIN,
  2526. [AC_CACHE_CHECK(for Cygwin environment, ac_cv_cygwin,
  2527. [AC_TRY_COMPILE(,[
  2528. #ifndef __CYGWIN__
  2529. #define __CYGWIN__ __CYGWIN32__
  2530. #endif
  2531. return __CYGWIN__;],
  2532. ac_cv_cygwin=yes, ac_cv_cygwin=no)
  2533. rm -f conftest*])
  2534. CYGWIN=
  2535. test "$ac_cv_cygwin" = yes && CYGWIN=yes])
  2536. dnl Check for mingw32. This is another way to set the right value for
  2537. dnl EXEEXT.
  2538. AC_DEFUN(AC_MINGW32,
  2539. [AC_CACHE_CHECK(for mingw32 environment, ac_cv_mingw32,
  2540. [AC_TRY_COMPILE(,[return __MINGW32__;],
  2541. ac_cv_mingw32=yes, ac_cv_mingw32=no)
  2542. rm -f conftest*])
  2543. MINGW32=
  2544. test "$ac_cv_mingw32" = yes && MINGW32=yes])
  2545. dnl Check for the extension used for executables. This knows that we
  2546. dnl add .exe for Cygwin or mingw32. Otherwise, it compiles a test
  2547. dnl executable. If this is called, the executable extensions will be
  2548. dnl automatically used by link commands run by the configure script.
  2549. AC_DEFUN(AC_EXEEXT,
  2550. [AC_REQUIRE([AC_CYGWIN])
  2551. AC_REQUIRE([AC_MINGW32])
  2552. AC_MSG_CHECKING([for executable suffix])
  2553. AC_CACHE_VAL(ac_cv_exeext,
  2554. [if test "$CYGWIN" = yes || test "$MINGW32" = yes; then
  2555. ac_cv_exeext=.exe
  2556. else
  2557. rm -f conftest*
  2558. echo 'int main () { return 0; }' > conftest.$ac_ext
  2559. ac_cv_exeext=
  2560. if AC_TRY_EVAL(ac_link); then
  2561. for file in conftest.*; do
  2562. case $file in
  2563. *.c | *.o | *.obj) ;;
  2564. *) ac_cv_exeext=`echo $file | sed -e s/conftest//` ;;
  2565. esac
  2566. done
  2567. else
  2568. AC_MSG_ERROR([installation or configuration problem: compiler cannot create executables.])
  2569. fi
  2570. rm -f conftest*
  2571. test x"${ac_cv_exeext}" = x && ac_cv_exeext=no
  2572. fi])
  2573. EXEEXT=""
  2574. test x"${ac_cv_exeext}" != xno && EXEEXT=${ac_cv_exeext}
  2575. AC_MSG_RESULT(${ac_cv_exeext})
  2576. dnl Setting ac_exeext will implicitly change the ac_link command.
  2577. ac_exeext=$EXEEXT
  2578. AC_SUBST(EXEEXT)])
  2579. dnl ### Checks for UNIX variants
  2580. dnl These are kludges which should be replaced by a single POSIX check.
  2581. dnl They aren't cached, to discourage their use.
  2582. AC_DEFUN(AC_AIX,
  2583. [AC_BEFORE([$0], [AC_TRY_COMPILE])dnl
  2584. AC_BEFORE([$0], [AC_TRY_RUN])dnl
  2585. AC_MSG_CHECKING(for AIX)
  2586. AC_CACHE_VAL(ac_cv_sys_aix,[
  2587. AC_EGREP_CPP(yes,
  2588. [#ifdef _AIX
  2589. yes
  2590. #endif
  2591. ], [ac_cv_sys_aix=yes], [ac_cv_sys_aix=no])])
  2592. AC_MSG_RESULT($ac_cv_sys_aix)
  2593. if test $ac_cv_sys_aix = yes; then
  2594. AC_DEFINE(_ALL_SOURCE)
  2595. fi
  2596. ])
  2597. AC_DEFUN(AC_MINIX,
  2598. [AC_BEFORE([$0], [AC_TRY_COMPILE])dnl
  2599. AC_BEFORE([$0], [AC_TRY_RUN])dnl
  2600. AC_CHECK_HEADER(minix/config.h, MINIX=yes, MINIX=)
  2601. if test "$MINIX" = yes; then
  2602. AC_DEFINE(_POSIX_SOURCE)
  2603. AC_DEFINE(_POSIX_1_SOURCE, 2)
  2604. AC_DEFINE(_MINIX)
  2605. fi
  2606. ])
  2607. AC_DEFUN(AC_ISC_POSIX,
  2608. [AC_REQUIRE([AC_PROG_CC])dnl
  2609. AC_BEFORE([$0], [AC_TRY_COMPILE])dnl
  2610. AC_BEFORE([$0], [AC_TRY_RUN])dnl
  2611. AC_MSG_CHECKING(for POSIXized ISC)
  2612. AC_CACHE_VAL(ac_cv_sys_isc_posix,[
  2613. if test -d /etc/conf/kconfig.d &&
  2614. grep _POSIX_VERSION [/usr/include/sys/unistd.h] >/dev/null 2>&1
  2615. then
  2616. ac_cv_sys_isc_posix=yes
  2617. else
  2618. ac_cv_sys_isc_posix=no
  2619. fi
  2620. ])
  2621. AC_MSG_RESULT($ac_cv_sys_isc_posix)
  2622. if test $ac_cv_sys_isc_posix = yes; then
  2623. ISC=yes # If later tests want to check for ISC.
  2624. AC_DEFINE(_POSIX_SOURCE)
  2625. if test "$GCC" = yes; then
  2626. CC="$CC -posix"
  2627. else
  2628. CC="$CC -Xp"
  2629. fi
  2630. else
  2631. ISC=
  2632. fi
  2633. ])
  2634. AC_DEFUN(AC_XENIX_DIR,
  2635. [AC_OBSOLETE([$0], [; instead use AC_HEADER_DIRENT])dnl
  2636. AC_REQUIRE([AC_DIR_HEADER])dnl
  2637. AC_MSG_CHECKING(for Xenix)
  2638. AC_EGREP_CPP(yes,
  2639. [#if defined(M_XENIX) && !defined(M_UNIX)
  2640. yes
  2641. #endif
  2642. ], [AC_MSG_RESULT(yes); XENIX=yes], [AC_MSG_RESULT(no); XENIX=])
  2643. if test "$XENIX" = yes; then
  2644. # Make sure -ldir precedes -lx.
  2645. test $ac_header_dirent = dirent.h && LIBS="-ldir $LIBS"
  2646. LIBS="$LIBS -lx"
  2647. fi
  2648. ])
  2649. AC_DEFUN(AC_DYNIX_SEQ,
  2650. [AC_OBSOLETE([$0], [; instead use AC_FUNC_GETMNTENT])dnl
  2651. AC_CHECK_LIB(seq, getmntent, LIBS="-lseq $LIBS")
  2652. ])
  2653. AC_DEFUN(AC_IRIX_SUN,
  2654. [AC_OBSOLETE([$0], [; instead use AC_FUNC_GETMNTENT or AC_CHECK_LIB(sun, getpwnam)])dnl
  2655. AC_CHECK_LIB(sun, getmntent, LIBS="-lsun $LIBS")
  2656. ])
  2657. AC_DEFUN(AC_SCO_INTL,
  2658. [AC_OBSOLETE([$0], [; instead use AC_FUNC_STRFTIME])dnl
  2659. AC_CHECK_LIB(intl, strftime, LIBS="-lintl $LIBS")
  2660. ])