home *** CD-ROM | disk | FTP | other *** search
/ Fresh Fish 4 / FreshFish_May-June1994.bin / gnu / lib / autoconf / acspecific.m4 < prev    next >
Encoding:
M4 Source File  |  1994-04-26  |  41.2 KB  |  1,408 lines

  1. dnl Macros that test for specific features.
  2. dnl This file is part of Autoconf.
  3. dnl Copyright (C) 1992, 1993, 1994 Free Software Foundation, Inc.
  4. dnl
  5. dnl This program is free software; you can redistribute it and/or modify
  6. dnl it under the terms of the GNU General Public License as published by
  7. dnl the Free Software Foundation; either version 2, or (at your option)
  8. dnl any later version.
  9. dnl
  10. dnl This program is distributed in the hope that it will be useful,
  11. dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13. dnl GNU General Public License for more details.
  14. dnl
  15. dnl You should have received a copy of the GNU General Public License
  16. dnl along with this program; if not, write to the Free Software
  17. dnl Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  18. dnl
  19. dnl Written by David MacKenzie, with help from
  20. dnl Franc,ois Pinard, Karl Berry, Richard Pixley, Ian Lance Taylor,
  21. dnl Roland McGrath, and Noah Friedman.
  22. dnl
  23. dnl
  24. dnl checks for programs
  25. dnl
  26. dnl
  27. define(AC_PROG_CC,
  28. [AC_BEFORE([$0], [AC_PROG_CPP])AC_PROVIDE([$0])AC_PROGRAM_CHECK(CC, gcc, gcc, cc)
  29. # Find out if we are using GNU C, under whatever name.
  30. cat > conftest.c <<EOF
  31. #ifdef __GNUC__
  32.   yes
  33. #endif
  34. EOF
  35. ${CC-cc} -E conftest.c > conftest.out 2>&1
  36. if egrep yes conftest.out >/dev/null 2>&1; then
  37.   GCC=1 # For later tests.
  38. fi
  39. rm -f conftest*
  40. ])dnl
  41. dnl
  42. define(AC_PROG_CXX,
  43. [AC_BEFORE([$0], [AC_PROG_CXXCPP])AC_PROVIDE([$0])AC_PROGRAMS_CHECK(CXX, $CCC c++ g++ gcc CC, gcc)
  44. # Find out if we are using GNU C++, under whatever name.
  45. cat > conftest.C <<EOF
  46. #ifdef __GNUC__
  47.   yes
  48. #endif
  49. EOF
  50. ${CXX-gcc} -E conftest.C > conftest.out 2>&1
  51. if egrep yes conftest.out >/dev/null 2>&1; then
  52.   GXX=1 # For later tests.
  53. fi
  54. rm -f conftest*
  55. ])dnl
  56. dnl
  57. define(AC_GCC_TRADITIONAL,
  58. [AC_REQUIRE([AC_PROG_CC])AC_REQUIRE([AC_PROG_CPP])if test -n "$GCC"; then
  59.   AC_CHECKING(whether -traditional is needed)
  60. changequote(,)dnl
  61.   ac_pattern="Autoconf.*'x'"
  62. changequote([,])dnl
  63.   ac_prog='#include <sgtty.h>
  64. Autoconf TIOCGETP'
  65.   AC_PROGRAM_EGREP($ac_pattern, $ac_prog, ac_need_trad=1)
  66.  
  67.   if test -z "$ac_need_trad"; then
  68.     ac_prog='#include <termio.h>
  69. Autoconf TCGETA'
  70.     AC_PROGRAM_EGREP($ac_pattern, $ac_prog, ac_need_trad=1)
  71.   fi
  72.   test -n "$ac_need_trad" && CC="$CC -traditional"
  73. fi
  74. ])dnl
  75. dnl
  76. define(AC_MINUS_C_MINUS_O,
  77. [AC_CHECKING(whether $CC and cc understand -c and -o together)
  78. /bin/echo 'foo(){}' > conftest.c
  79. # Make sure it works both with $CC and with simple cc.
  80. # We do the test twice because some compilers refuse to overwrite an
  81. # existing .o file with -o, though they will create one.
  82. if ${CC-cc} -c conftest.c -o conftest.o >/dev/null 2>&1 \
  83.  && test -f conftest.o && ${CC-cc} -c conftest.c -o conftest.o >/dev/null 2>&1
  84. then
  85.   # Test first that cc exists at all.
  86.   if cc -c conftest.c >/dev/null 2>&1
  87.   then
  88.     if cc -c conftest.c -o conftest2.o >/dev/null 2>&1 && \
  89.        test -f conftest2.o && cc -c conftest.c -o conftest2.o >/dev/null 2>&1
  90.     then
  91.       :
  92.     else
  93.       AC_DEFINE(NO_MINUS_C_MINUS_O)
  94.     fi
  95.   fi
  96. else
  97.   AC_DEFINE(NO_MINUS_C_MINUS_O)
  98. fi
  99. rm -f conftest*
  100. ])dnl
  101. dnl
  102. dnl Define SET_MAKE to set ${MAKE} if make doesn't.
  103. define(AC_SET_MAKE,
  104. [cat > conftestmake <<'EOF'
  105. all:
  106.     @/bin/echo 'ac_maketemp="${MAKE}"'
  107. EOF
  108. changequote(,)dnl
  109. # GNU make sometimes prints "make[1]: Entering...", which would confuse us.
  110. eval `${MAKE-make} -f conftestmake 2>/dev/null | grep temp=`
  111. changequote([,])dnl
  112. if test -n "$ac_maketemp"; then SET_MAKE=
  113. else SET_MAKE="MAKE=${MAKE-make}"; fi
  114. AC_SUBST([SET_MAKE])dnl
  115. ])dnl
  116. dnl
  117. define(AC_PROG_RANLIB, [AC_PROGRAM_CHECK(RANLIB, ranlib, ranlib, :)])dnl
  118. dnl
  119. define(AC_PROG_AWK, [AC_PROGRAMS_CHECK(AWK, mawk gawk nawk awk,)])dnl
  120. dnl
  121. define(AC_PROG_YACC,[AC_PROGRAMS_CHECK(YACC, 'bison -y' byacc, yacc)])dnl
  122. dnl
  123. define(AC_PROG_CPP,
  124. [AC_PROVIDE([$0])AC_CHECKING(how to run the C preprocessor)
  125. if test -z "$CPP"; then
  126.   # This must be in double quotes, not single quotes, because CPP may get
  127.   # substituted into the Makefile and ``${CC-cc}'' will simply confuse
  128.   # make.  It must be expanded now.
  129.   CPP="${CC-cc} -E"
  130. dnl On the NeXT, cc -E runs the code through the compiler's parser,
  131. dnl not just through cpp.
  132.   AC_TEST_CPP([#include <stdio.h>
  133. Syntax Error], ,
  134.   CPP="${CC-cc} -E -traditional-cpp"
  135.   AC_TEST_CPP([#include <stdio.h>
  136. Syntax Error], ,CPP=/lib/cpp))
  137. fi
  138. AC_VERBOSE(setting CPP to $CPP)
  139. AC_SUBST(CPP)dnl
  140. ])dnl
  141. dnl
  142. define(AC_PROG_CXXCPP,
  143. [AC_PROVIDE([$0])AC_CHECKING(how to run the C++ preprocessor)
  144. AC_LANG_SAVE[]dnl
  145. AC_LANG_CPLUSPLUS[]dnl
  146. if test -z "$CXXCPP"; then
  147.   CXXCPP="${CXX-c++} -E"
  148.   AC_TEST_CPP([#include <stdlib.h>], , CXXCPP=/lib/cpp)
  149. fi
  150. AC_VERBOSE(setting CXXCPP to $CXXCPP)
  151. AC_LANG_RESTORE[]dnl
  152. AC_SUBST(CXXCPP)dnl
  153. ])dnl
  154. dnl
  155. dnl Require finding the C or C++ preprocessor, whichever is the
  156. dnl current language.
  157. define(AC_REQUIRE_CPP,
  158. [ifelse(AC_LANG,C,[AC_REQUIRE([AC_PROG_CPP])],[AC_REQUIRE([AC_PROG_CXXCPP])])])dnl
  159. dnl
  160. define(AC_PROG_LEX,
  161. [AC_PROVIDE([$0])AC_PROGRAM_CHECK(LEX, flex, flex, lex)
  162. if test -z "$LEXLIB"
  163. then
  164.   case "$LEX" in
  165.   flex*) AC_HAVE_LIBRARY(fl, LEXLIB="-lfl") ;;
  166.   *) LEXLIB="-ll" ;;
  167.   esac
  168. fi
  169. AC_VERBOSE(setting LEXLIB to $LEXLIB)
  170. AC_SUBST(LEXLIB)])dnl
  171. dnl
  172. define(AC_YYTEXT_POINTER,[dnl
  173. AC_REQUIRE_CPP()AC_REQUIRE([AC_PROG_LEX])dnl
  174. AC_CHECKING(for yytext declaration)
  175. # POSIX says lex can declare yytext either as a pointer or an array; the
  176. # default is implementation-dependent. Figure out which it is, since
  177. # not all implementations provide the %pointer and %array declarations.
  178. #
  179. # The minimal lex program is just a single line: %%.  But some broken lexes
  180. # (Solaris, I think it was) want two %% lines, so accommodate them.
  181.   /bin/echo '%%
  182. %%' | ${LEX}
  183. if test -f lex.yy.c; then
  184.   LEX_OUTPUT_ROOT=lex.yy
  185. elif test -f lexyy.c; then
  186.   LEX_OUTPUT_ROOT=lexyy
  187. else
  188.   # Don't know what to do here.
  189.   AC_ERROR(cannot find output from $LEX, giving up on yytext declaration)
  190.   LEX_OUTPUT_ROOT=
  191. fi
  192. if test -n "$LEX_OUTPUT_ROOT"; then
  193.   /bin/echo 'extern char *yytext; main () { exit (0); }' >>$LEX_OUTPUT_ROOT.c
  194.   ac_save_LIBS="$LIBS"
  195.   LIBS="$LIBS $LEXLIB"
  196.   AC_TEST_PROGRAM(`cat $LEX_OUTPUT_ROOT.c`, AC_DEFINE(YYTEXT_POINTER))
  197.   LIBS="$ac_save_LIBS"
  198.   rm -f "${LEX_OUTPUT_ROOT}.c"
  199. fi
  200. AC_SUBST(LEX_OUTPUT_ROOT)dnl
  201. ])dnl
  202. dnl
  203. define(AC_PROG_INSTALL,
  204. [# Make sure to not get the incompatible SysV /etc/install and
  205. # /usr/sbin/install, which might be in PATH before a BSD-like install,
  206. # or the SunOS /usr/etc/install directory, or the AIX /bin/install,
  207. # or the AFS install, which mishandles nonexistent args, or
  208. # /usr/ucb/install on SVR4, which tries to use the nonexistent group
  209. # `staff', or /sbin/install on IRIX which has incompatible command-line
  210. # syntax.  Sigh.
  211. #
  212. #     On most BSDish systems install is in /usr/bin, not /usr/ucb
  213. #     anyway.
  214. # This turns out not to be true, so the mere pathname isn't an indication
  215. # of whether the program works.  What we really need is a set of tests for
  216. # the install program to see if it actually works in all the required ways.
  217. #
  218. # Avoid using ./install, which might have been erroneously created
  219. # by make from ./install.sh.
  220. if test "z${INSTALL}" = "z" ; then
  221.   AC_CHECKING(for a BSD compatible install)
  222.   IFS="${IFS=     }"; ac_save_ifs="$IFS"; IFS="${IFS}:"
  223.   for ac_dir in $PATH; do
  224.     case "$ac_dir" in
  225.     ''|.|/gnu/etc|/sbin|/usr/sbin|/usr/etc|/usr/afsws/bin|/usr/ucb) ;;
  226.     *)
  227.       # OSF1 and SCO ODT 3.0 have their own names for install.
  228.       for ac_prog in installbsd scoinst install; do
  229.         if test -f $ac_dir/$ac_prog; then
  230.       if test $ac_prog = install &&
  231.             grep dspmsg $ac_dir/$ac_prog >/dev/null 2>&1; then
  232.         # AIX install.  It has an incompatible calling convention.
  233.         # OSF/1 installbsd also uses dspmsg, but is usable.
  234.         :
  235.       else
  236.         INSTALL="$ac_dir/$ac_prog -c"
  237.         INSTALL_PROGRAM='${INSTALL}'
  238.         INSTALL_DATA='${INSTALL} -m 644'
  239.         break 2
  240.       fi
  241.     fi
  242.       done
  243.       ;;
  244.     esac
  245.   done
  246.   IFS="$ac_save_ifs"
  247. fi
  248. if test -z "$INSTALL"; then
  249.   if test -f ${srcdir}/install.sh; then
  250.     # As a last resort, use the slow shell script.
  251.     INSTALL=AC_PROG_INSTALL_INSTALL_SH
  252.   else
  253.     AC_WARN(${srcdir}/install.sh not found; using cp)
  254.     INSTALL=cp
  255.   fi
  256. fi
  257. AC_SUBST(INSTALL)dnl
  258. AC_VERBOSE(setting INSTALL to $INSTALL)
  259. # Use test -z because SunOS4 sh mishandles ${INSTALL_PROGRAM-'${INSTALL}'}.
  260. # It thinks the first close brace ends the variable substitution.
  261. test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}'
  262. AC_SUBST(INSTALL_PROGRAM)dnl
  263. AC_VERBOSE(setting INSTALL_PROGRAM to $INSTALL_PROGRAM)
  264. test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL}'
  265. AC_SUBST(INSTALL_DATA)dnl
  266. AC_VERBOSE(setting INSTALL_DATA to $INSTALL_DATA)
  267. ])dnl
  268. dnl Defined separately so a configure.in can redefine if necessary.
  269. dnl We want the top-level source directory, not the subdir's srcdir.
  270. dnl This relies on top_srcdir being substituted after INSTALL.
  271. define(AC_PROG_INSTALL_INSTALL_SH, ['@top_srcdir@/install.sh -c'])dnl
  272. dnl
  273. define(AC_LN_S,
  274. [AC_CHECKING(for ln -s)
  275. rm -f conftestdata
  276. if ln -s X conftestdata 2>/dev/null
  277. then
  278.   rm -f conftestdata
  279.   LN_S="ln -s"
  280. else
  281.   LN_S=ln
  282. fi
  283. AC_SUBST(LN_S)
  284. ])dnl
  285. dnl
  286. define(AC_RSH,
  287. [AC_CHECKING(for remote shell)
  288. if test -f /gnu/bin/remsh || test -f /gnu/bin/rsh || test -f /gnu/bin/nsh; then
  289.   RTAPELIB=rtapelib.o
  290. else
  291. dnl The rmt executable doesn't currently build on AmigaDOS because
  292. dnl setsockopt() is missing, so disable rmt features.  -fnf
  293.   AC_DEFINE(NO_REMOTE)
  294. fi
  295. AC_SUBST(RTAPELIB)dnl
  296. ])dnl
  297. dnl
  298. dnl
  299. dnl checks for header files
  300. dnl
  301. dnl
  302. define(AC_STDC_HEADERS,
  303. [AC_REQUIRE_CPP()dnl
  304. AC_CHECKING(for ANSI C header files)
  305. AC_TEST_CPP([#include <stdlib.h>
  306. #include <stdarg.h>
  307. #include <string.h>
  308. #include <float.h>],
  309. [# SunOS 4.x string.h does not declare mem*, contrary to ANSI.
  310. AC_HEADER_EGREP(memchr, string.h,
  311. # SGI's /bin/cc from Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi.
  312. AC_TEST_PROGRAM([#include <ctype.h>
  313. #define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
  314. #define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c))
  315. #define XOR(e,f) (((e) && !(f)) || (!(e) && (f)))
  316. int main () { int i; for (i = 0; i < 256; i++)
  317. if (XOR (islower (i), ISLOWER (i)) || toupper (i) != TOUPPER (i)) exit(2);
  318. exit (0); }
  319. ],
  320. [# ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI.
  321. AC_HEADER_EGREP(free, stdlib.h, AC_DEFINE(STDC_HEADERS))]))])
  322. ])dnl
  323. dnl
  324. define(AC_UNISTD_H, [AC_OBSOLETE([$0], [; instead use AC_HAVE_HEADERS(unistd.h)])AC_HEADER_CHECK(unistd.h,
  325.   AC_DEFINE(HAVE_UNISTD_H))])dnl
  326. dnl
  327. define(AC_USG,
  328. [AC_OBSOLETE([$0], [; instead use AC_HAVE_HEADERS(string.h) and HAVE_STRING_H])AC_COMPILE_CHECK([BSD string and memory functions],
  329. [#include <strings.h>], [rindex(0, 0); bzero(0, 0);], , AC_DEFINE(USG))])dnl
  330. dnl
  331. dnl
  332. dnl If memchr and the like aren't declared in <string.h>, include <memory.h>.
  333. dnl To avoid problems, don't check for gcc2 built-ins.
  334. define(AC_MEMORY_H,
  335. [AC_OBSOLETE([$0], [; instead use AC_HAVE_HEADERS(memory.h) and HAVE_MEMORY_H])AC_CHECKING(whether string.h declares mem functions)
  336. AC_HEADER_EGREP(memchr, string.h, ,
  337.   AC_HEADER_CHECK(memory.h, AC_DEFINE(NEED_MEMORY_H)))]
  338. )dnl
  339. dnl
  340. define(AC_MAJOR_HEADER,
  341. [AC_COMPILE_CHECK([major, minor and makedev header],
  342. [#include <sys/types.h>],
  343. [return makedev(0, 0);], ac_makedev=1)
  344. if test -z "$ac_makedev"; then
  345. AC_HEADER_CHECK(sys/mkdev.h, AC_DEFINE(MAJOR_IN_MKDEV) ac_makedev=1)
  346. fi
  347. if test -z "$ac_makedev"; then
  348. AC_HEADER_CHECK(sys/sysmacros.h, AC_DEFINE(MAJOR_IN_SYSMACROS))
  349. fi]
  350. )dnl
  351. dnl
  352. define(AC_DIR_HEADER,
  353. [AC_PROVIDE([$0])AC_CHECKING(for directory library header)
  354. ac_dir_header=
  355. AC_DIR_HEADER_CHECK(dirent.h, DIRENT)
  356. AC_DIR_HEADER_CHECK(sys/ndir.h, SYSNDIR)
  357. AC_DIR_HEADER_CHECK(sys/dir.h, SYSDIR)
  358. AC_DIR_HEADER_CHECK(ndir.h, NDIR)
  359.  
  360. AC_CHECKING(for closedir return value)
  361. AC_TEST_PROGRAM([#include <sys/types.h>
  362. #include <$ac_dir_header>
  363. int closedir(); main() { exit(closedir(opendir(".")) != 0); }], ,
  364. AC_DEFINE(VOID_CLOSEDIR))
  365. ])dnl
  366. dnl Subroutine of AC_DIR_HEADER.
  367. dnl ??? I tried to put this define inside AC_DIR_HEADER, but when I did
  368. dnl that, $1 and $2 did not get expanded. --roland
  369. dnl Check if $1 is the winning directory library header file.
  370. dnl It must not only exist, but also correctly define the `DIR' type.
  371. dnl If it is really winning, define $2 and set shell var `ac_dir_header' to $1.
  372. define(AC_DIR_HEADER_CHECK, [dnl
  373. if test -z "$ac_dir_header"; then
  374.   AC_COMPILE_CHECK($1, [#include <sys/types.h>
  375. #include <]$1[>],
  376.              [DIR *dirp = 0;],
  377.            AC_DEFINE($2) ac_dir_header=$1)dnl
  378. fi])dnl
  379. dnl
  380. dnl
  381. dnl checks for typedefs
  382. dnl
  383. dnl
  384. define(AC_GETGROUPS_T,
  385. [AC_REQUIRE([AC_UID_T])dnl
  386. AC_CHECKING(for type of array argument to getgroups)
  387. changequote(,)dnl
  388. dnl Do not put single quotes in the C program text!!
  389. ac_prog='/* Thanks to Mike Rendell for this test.  */
  390. #include <sys/types.h>
  391. #define NGID 256
  392. #undef MAX
  393. #define MAX(x,y) ((x) > (y) ? (x) : (y))
  394. main()
  395. {
  396.   gid_t gidset[NGID];
  397.   int i, n;
  398.   union { gid_t gval; long lval; }  val;
  399.  
  400.   val.lval = -1;
  401.   for (i = 0; i < NGID; i++)
  402.     gidset[i] = val.gval;
  403.   n = getgroups (sizeof (gidset) / MAX (sizeof (int), sizeof (gid_t)) - 1,
  404.                  gidset);
  405.   /* Exit non-zero if getgroups seems to require an array of ints.  This
  406.      happens when gid_t is short but getgroups modifies an array of ints.  */
  407.   exit ((n > 0 && gidset[n] != val.gval) ? 1 : 0);
  408. }'
  409. changequote([,])dnl
  410. AC_TEST_PROGRAM([$ac_prog],
  411.         AC_DEFINE(GETGROUPS_T, gid_t),
  412.         AC_DEFINE(GETGROUPS_T, int))
  413. ])dnl
  414. dnl
  415. define(AC_UID_T,
  416. [AC_PROVIDE([$0])AC_CHECKING(for uid_t in sys/types.h)
  417. AC_HEADER_EGREP(uid_t, sys/types.h, ,
  418.   AC_DEFINE(uid_t, int) AC_DEFINE(gid_t, int))])dnl
  419. dnl
  420. define(AC_SIZE_T,
  421. [AC_CHECKING(for size_t in sys/types.h)
  422. AC_HEADER_EGREP(size_t, sys/types.h, , AC_DEFINE(size_t, unsigned))])dnl
  423. dnl
  424. define(AC_PID_T,
  425. [AC_PROVIDE([$0])AC_CHECKING(for pid_t in sys/types.h)
  426. AC_HEADER_EGREP(pid_t, sys/types.h, , AC_DEFINE(pid_t, int))])dnl
  427. dnl
  428. define(AC_OFF_T,
  429. [AC_PROVIDE([$0])AC_CHECKING(for off_t in sys/types.h)
  430. AC_HEADER_EGREP(off_t, sys/types.h, , AC_DEFINE(off_t, long))])dnl
  431. dnl
  432. define(AC_MODE_T,
  433. [AC_CHECKING(for mode_t in sys/types.h)
  434. AC_HEADER_EGREP(mode_t, sys/types.h, , AC_DEFINE(mode_t, int))])dnl
  435. dnl
  436. define(AC_RETSIGTYPE,
  437. [AC_PROVIDE([$0])AC_COMPILE_CHECK([return type of signal handlers],
  438. [#include <sys/types.h>
  439. #include <signal.h>
  440. #ifdef signal
  441. #undef signal
  442. #endif
  443. extern void (*signal ()) ();],
  444. [int i;],
  445. [AC_DEFINE(RETSIGTYPE, void)],
  446. [AC_DEFINE(RETSIGTYPE, int)])]
  447. )dnl
  448. dnl
  449. dnl
  450. dnl checks for functions
  451. dnl
  452. dnl
  453. define(AC_MMAP, [
  454. AC_CHECKING(for working mmap)
  455. AC_TEST_PROGRAM([/* Thanks to Mike Haertel and Jim Avera for this test. */
  456. #include <sys/types.h>
  457. #include <fcntl.h>
  458. #include <sys/mman.h>
  459.  
  460. #ifdef BSD
  461. #ifndef BSD4_1
  462. #define HAVE_GETPAGESIZE
  463. #endif
  464. #endif
  465. #ifndef HAVE_GETPAGESIZE
  466. #include <sys/param.h>
  467. #ifdef EXEC_PAGESIZE
  468. #define getpagesize() EXEC_PAGESIZE
  469. #else
  470. #ifdef NBPG
  471. #define getpagesize() NBPG * CLSIZE
  472. #ifndef CLSIZE
  473. #define CLSIZE 1
  474. #endif /* no CLSIZE */
  475. #else /* no NBPG */
  476. #define getpagesize() NBPC
  477. #endif /* no NBPG */
  478. #endif /* no EXEC_PAGESIZE */
  479. #endif /* not HAVE_GETPAGESIZE */
  480.  
  481. #ifdef __osf__
  482. #define valloc malloc
  483. #endif
  484.  
  485. extern char *valloc();
  486. extern char *malloc();
  487.  
  488. int
  489. main()
  490. {
  491.   char *buf1, *buf2, *buf3;
  492.   int i = getpagesize(), j;
  493.   int i2 = getpagesize()*2;
  494.   int fd;
  495.  
  496.   buf1 = valloc(i2);
  497.   buf2 = valloc(i);
  498.   buf3 = malloc(i2);
  499.   for (j = 0; j < i2; ++j)
  500.     *(buf1 + j) = rand();
  501.   fd = open("conftestmmap", O_CREAT | O_RDWR, 0666);
  502.   write(fd, buf1, i2);
  503.   mmap(buf2, i, PROT_READ | PROT_WRITE, MAP_FIXED | MAP_PRIVATE, fd, 0);
  504.   for (j = 0; j < i; ++j)
  505.     if (*(buf1 + j) != *(buf2 + j))
  506.       exit(1);
  507.   lseek(fd, (long)i, 0);
  508.   read(fd, buf2, i); /* read into mapped memory -- file should not change */
  509.   /* (it does in i386 SVR4.0 - Jim Avera) */
  510.   lseek(fd, (long)0, 0);
  511.   read(fd, buf3, i2);
  512.   for (j = 0; j < i2; ++j)
  513.     if (*(buf1 + j) != *(buf3 + j))
  514.       exit(1);
  515.   exit(0);
  516. }
  517. ], AC_DEFINE(HAVE_MMAP))
  518. ])dnl
  519. dnl
  520. define(AC_VPRINTF,
  521. [AC_COMPILE_CHECK([vprintf], , [vprintf();], AC_DEFINE(HAVE_VPRINTF),
  522. ac_vprintf_missing=1)
  523. if test -n "$ac_vprintf_missing"; then
  524. AC_COMPILE_CHECK([_doprnt], , [_doprnt();], AC_DEFINE(HAVE_DOPRNT))
  525. fi
  526. ])dnl
  527. dnl
  528. define(AC_VFORK,
  529. [AC_REQUIRE([AC_PID_T])AC_HEADER_CHECK(vfork.h, AC_DEFINE(HAVE_VFORK_H))
  530. AC_CHECKING(for working vfork)
  531. AC_REQUIRE([AC_RETSIGTYPE])
  532. AC_TEST_PROGRAM([/* Thanks to Paul Eggert for this test.  */
  533. #include <stdio.h>
  534. #include <sys/types.h>
  535. #include <sys/stat.h>
  536. #include <signal.h>
  537. #ifdef HAVE_UNISTD_H
  538. #include <unistd.h>
  539. #endif
  540. #ifdef HAVE_VFORK_H
  541. #include <vfork.h>
  542. #endif
  543. static int signalled;
  544. static RETSIGTYPE catch (s) int s; { signalled = 1; }
  545. main() {
  546.   pid_t parent = getpid ();
  547.   pid_t child;
  548.  
  549. #ifdef __amigados__
  550.   /* Force this test to succeed for AmigaDOS, which has a fairly good
  551.      vfork() emulation, but doesn't support fork() at all.  -fnf */
  552.   exit (0);
  553. #endif
  554.   signal (SIGINT, catch);
  555.  
  556.   child = vfork ();
  557.  
  558.   if (child == 0) {
  559.     /* On sparc systems, changes by the child to local and incoming
  560.        argument registers are propagated back to the parent.
  561.        The compiler is told about this with #include <vfork.h>,
  562.        but some compilers (e.g. gcc -O) don't grok <vfork.h>.
  563.        Test for this by using lots of local variables, at least
  564.        as many local variables as main has allocated so far
  565.        including compiler temporaries.  4 locals are enough for
  566.        gcc 1.40.3 on a sparc, but we use 8 to be safe.
  567.        A buggy compiler should reuse the register of parent
  568.        for one of the local variables, since it will think that
  569.        parent can't possibly be used any more in this routine.
  570.        Assigning to the local variable will thus munge parent
  571.        in the parent process.  */
  572.     pid_t
  573.       p = getpid(), p1 = getpid(), p2 = getpid(), p3 = getpid(),
  574.       p4 = getpid(), p5 = getpid(), p6 = getpid(), p7 = getpid();
  575.     /* Convince the compiler that p..p7 are live; otherwise, it might
  576.        use the same hardware register for all 8 local variables.  */
  577.     if (p != p1 || p != p2 || p != p3 || p != p4
  578.     || p != p5 || p != p6 || p != p7)
  579.       _exit(1);
  580.  
  581.     /* On some systems (e.g. SunOS 5.2), if the parent is catching
  582.        a signal, the child ignores the signal before execing,
  583.        and the parent later receives that signal, the parent dumps core.
  584.        Test for this by ignoring SIGINT in the child.  */
  585.     signal (SIGINT, SIG_IGN);
  586.  
  587.     /* On some systems (e.g. IRIX 3.3),
  588.        vfork doesn't separate parent from child file descriptors.
  589.        If the child closes a descriptor before it execs or exits,
  590.        this munges the parent's descriptor as well.
  591.        Test for this by closing stdout in the child.  */
  592.     _exit(close(fileno(stdout)) != 0);
  593.   } else {
  594.     int status;
  595.     struct stat st;
  596.  
  597.     while (wait(&status) != child)
  598.       ;
  599.     exit(
  600.      /* Was there some problem with vforking?  */
  601.      child < 0
  602.  
  603.      /* Did the child fail?  (This shouldn't happen.)  */
  604.      || status
  605.  
  606.      /* Did the vfork/compiler bug occur?  */
  607.      || parent != getpid()
  608.  
  609.      /* Did the signal handling bug occur?  */
  610.      || kill(parent, SIGINT) != 0
  611.      || signalled != 1
  612.  
  613.      /* Did the file descriptor bug occur?  */
  614.      || fstat(fileno(stdout), &st) != 0
  615.      );
  616.   }
  617. }], , AC_DEFINE(vfork, fork))
  618. ])dnl
  619. dnl
  620. define(AC_WAIT3,
  621. [AC_CHECKING(for wait3 that fills in rusage)
  622. AC_TEST_PROGRAM([#include <sys/types.h>
  623. #include <sys/time.h>
  624. #include <sys/resource.h>
  625. #include <stdio.h>
  626. /* HP-UX has wait3 but does not fill in rusage at all.  */
  627. main() {
  628.   struct rusage r;
  629.   int i;
  630.   /* Use a field that we can force nonzero --
  631.      voluntary context switches.
  632.      For systems like NeXT and OSF/1 that don't set it,
  633.      also use the system CPU time.  */
  634.   r.ru_nvcsw = 0;
  635.   r.ru_stime.tv_sec = 0;
  636.   r.ru_stime.tv_usec = 0;
  637.   switch (fork()) {
  638.   case 0: /* Child.  */
  639.     sleep(1); /* Give up the CPU.  */
  640.     _exit(0);
  641.   case -1: _exit(0); /* What can we do?  */
  642.   default: /* Parent.  */
  643.     wait3(&i, 0, &r);
  644.     exit(r.ru_nvcsw == 0
  645.      && r.ru_stime.tv_sec == 0 && r.ru_stime.tv_usec == 0);
  646.   }
  647. }], AC_DEFINE(HAVE_WAIT3))
  648. ])dnl
  649. dnl
  650. define(AC_ALLOCA,
  651. [# The Ultrix 4.2 mips builtin alloca declared by alloca.h only works
  652. # for constant arguments.  Useless!
  653. AC_COMPILE_CHECK(working alloca.h, [#include <alloca.h>],
  654.   [char *p = alloca(2 * sizeof(int));], AC_DEFINE(HAVE_ALLOCA_H))
  655. ac_decl="#ifdef __GNUC__
  656. #define alloca __builtin_alloca
  657. #else
  658. #if HAVE_ALLOCA_H
  659. #include <alloca.h>
  660. #else
  661. #ifdef _AIX
  662.  #pragma alloca
  663. #else
  664. char *alloca ();
  665. #endif
  666. #endif
  667. #endif
  668. "
  669. AC_COMPILE_CHECK([alloca], $ac_decl,
  670. [char *p = (char *) alloca(1);], [AC_DEFINE([HAVE_ALLOCA])], [dnl
  671. ac_alloca_missing=1
  672. AC_PROGRAM_EGREP(winnitude, [
  673. #if defined(CRAY) && ! defined(CRAY2)
  674. winnitude
  675. #else
  676. lossage
  677. #endif
  678. ],
  679. AC_FUNC_CHECK([_getb67],AC_DEFINE([CRAY_STACKSEG_END],[_getb67]),
  680. AC_FUNC_CHECK([GETB67],AC_DEFINE([CRAY_STACKSEG_END],[GETB67]),
  681. AC_FUNC_CHECK([getb67],AC_DEFINE([CRAY_STACKSEG_END],[getb67])))))
  682. ])
  683. if test -n "$ac_alloca_missing"; then
  684.   # The SVR3 libPW and SVR4 libucb both contain incompatible functions
  685.   # that cause trouble.  Some versions do not even contain alloca or
  686.   # contain a buggy version.  If you still want to use their alloca,
  687.   # use ar to extract alloca.o from them instead of compiling alloca.c.
  688.   ALLOCA=alloca.o
  689.   AC_DEFINE(C_ALLOCA)
  690.  
  691.   AC_CHECKING(stack direction for C alloca)
  692.   AC_TEST_PROGRAM([find_stack_direction ()
  693. {
  694.   static char *addr = 0;
  695.   auto char dummy;
  696.   if (addr == 0)
  697.     {
  698.       addr = &dummy;
  699.       return find_stack_direction ();
  700.     }
  701.   else
  702.     return (&dummy > addr) ? 1 : -1;
  703. }
  704. main ()
  705. {
  706.   exit (find_stack_direction() < 0);
  707. }], dnl
  708. AC_DEFINE(STACK_DIRECTION,1), AC_DEFINE(STACK_DIRECTION,-1), dnl
  709. AC_DEFINE(STACK_DIRECTION,0))
  710. fi
  711. AC_SUBST(ALLOCA)dnl
  712. ])dnl
  713. dnl
  714. define(AC_GETLOADAVG,
  715. [# Some definitions of getloadavg require that the program be installed setgid.
  716. AC_SUBST(NEED_SETGID)NEED_SETGID=false
  717. ac_need_func=true
  718.  
  719. # Check for the 4.4BSD definition of getloadavg.
  720. AC_HAVE_LIBRARY(util, LIBS="$LIBS -lutil" ac_need_func=false)
  721. # Some systems with -lutil have (and need) -lkvm as well, some do not.
  722. AC_HAVE_LIBRARY(kvm, LIBS="$LIBS -lkvm")
  723.  
  724. if $ac_need_func; then
  725. # There is a commonly available library for RS/6000 AIX.
  726. # Since it is not a standard part of AIX, it might be installed locally.
  727. LIBS_old="$LIBS"
  728. LIBS="-L/local/lib $LIBS"
  729. AC_HAVE_LIBRARY(getloadavg, LIBS="$LIBS -lgetloadavg" ac_need_func=false,
  730.     LIBS="$LIBS_old")
  731. fi
  732.  
  733. # Make sure it is really in the library, if we think we found it at all.
  734. AC_REPLACE_FUNCS(getloadavg)
  735.  
  736. case "$LIBOBJS" in
  737. *getloadavg*)
  738. ac_need_func=true
  739. AC_HEADER_CHECK(sys/dg_sys_info.h, [dnl
  740. AC_DEFINE(DGUX) ac_need_func=false
  741. # Some versions of DGUX need -ldgc for dg_sys_info.
  742. AC_HAVE_LIBRARY(dgc)])
  743. if $ac_need_func; then
  744. # We cannot check for <dwarf.h>, because Solaris 2 does not use dwarf (it
  745. # uses stabs), but it's still SVR4.  We cannot check for <elf.h> because
  746. # Irix 4.0.5F has the header but not the library.
  747. AC_HAVE_LIBRARY(elf, AC_DEFINE(SVR4) LIBS="$LIBS -lelf" ac_need_func=false
  748.   AC_HAVE_LIBRARY(kvm, LIBS="$LIBS -lkvm"))
  749. fi
  750. if $ac_need_func; then
  751. AC_HEADER_CHECK(inq_stats/cpustats.h, AC_DEFINE(UMAX4_3) AC_DEFINE(UMAX)
  752.   ac_need_func=false)
  753. fi
  754. if $ac_need_func; then
  755. AC_HEADER_CHECK(sys/cpustats.h, AC_DEFINE(UMAX) ac_need_func=false)
  756. fi
  757. if $ac_need_func; then
  758. AC_HAVE_HEADERS(mach/mach.h)
  759. fi
  760.  
  761. AC_HEADER_CHECK(nlist.h,
  762. [AC_DEFINE(NLIST_STRUCT)
  763. AC_COMPILE_CHECK(n_un in struct nlist, [#include <nlist.h>],
  764. [struct nlist n; n.n_un.n_name = 0;],
  765. AC_DEFINE(NLIST_NAME_UNION))])dnl
  766.  
  767. # Figure out whether we will need to install setgid.
  768. AC_PROGRAM_EGREP([Yowza Am I SETGID yet], [dnl
  769. #include "${srcdir}/getloadavg.c"
  770. #ifdef LDAV_PRIVILEGED
  771. Yowza Am I SETGID yet
  772. #endif], [AC_DEFINE(GETLOADAVG_PRIVILEGED) NEED_SETGID=true])dnl
  773. ;;
  774.  
  775. *) AC_DEFINE(HAVE_GETLOADAVG) ;;
  776. esac
  777.  
  778. if $NEED_SETGID; then
  779.   AC_SUBST(KMEM_GROUP)# Figure out what group owns /dev/kmem.
  780.   # The installed program will need to be setgid and owned by that group.
  781. changequote(,)dnl
  782.   # On Solaris, /dev/kmem is a symlink.  Get info on the real file.
  783.   ac_ls_output=`ls -lgL /dev/kmem 2>/dev/null`
  784.   # If we got an error (system does not support symlinks), try without -L.
  785.   test -z "$ac_ls_output" && ac_ls_output=`ls -lg /dev/kmem`
  786.   KMEM_GROUP=`/bin/echo $ac_ls_output \
  787.     | sed -ne 's/[     ][     ]*/ /g;
  788.            s/^.[sSrwx-]* *[0-9]* *\([^0-9]*\)  *.*/\1/;
  789.            / /s/.* //;p;'`
  790. changequote([,])dnl
  791. fi
  792. ])dnl
  793. dnl
  794. define(AC_UTIME_NULL,
  795. [AC_CHECKING(utime with null argument)
  796. rm -f conftestdata; > conftestdata
  797. # Sequent interprets utime(file, 0) to mean use start of epoch.  Wrong.
  798. AC_TEST_PROGRAM([#include <sys/types.h>
  799. #include <sys/stat.h>
  800. main() {
  801. struct stat s, t;
  802. exit(!(stat ("conftestdata", &s) == 0 && utime("conftestdata", (long *)0) == 0
  803. && stat("conftestdata", &t) == 0 && t.st_mtime >= s.st_mtime
  804. && t.st_mtime - s.st_mtime < 120));
  805. }], AC_DEFINE(HAVE_UTIME_NULL))
  806. rm -f core
  807. ])dnl
  808. dnl
  809. define(AC_STRCOLL, [AC_CHECKING(for strcoll)
  810. AC_TEST_PROGRAM([#include <string.h>
  811. main ()
  812. {
  813.   exit (strcoll ("abc", "def") >= 0 ||
  814.     strcoll ("ABC", "DEF") >= 0 ||
  815.     strcoll ("123", "456") >= 0);
  816. }], AC_DEFINE(HAVE_STRCOLL))])dnl
  817. dnl
  818. define(AC_SETVBUF_REVERSED,
  819. [AC_TEST_PROGRAM([#include <stdio.h>
  820. /* If setvbuf has the reversed format, exit 0. */
  821. main () {
  822. #ifdef __amigados__
  823.   /* AmigaDOS is a non-reversed system.  Instead of the test program
  824.      getting a segfault (no memory protection), it causes enforcer hits
  825.      or other nastiness, so don't run the test program, just exit with
  826.      status 1 to indicate that it is non-reversed.  -fnf */
  827.   exit(1);
  828. #endif
  829.   /* This call has the arguments reversed.
  830.      A reversed system may check and see that the address of main
  831.      is not _IOLBF, _IONBF, or _IOFBF, and return nonzero.  */
  832.   if (setvbuf(stdout, _IOLBF, (char *) main, BUFSIZ) != 0)
  833.     exit(1);
  834.   putc('\r', stdout);
  835.   exit(0);            /* Non-reversed systems segv here.  */
  836. }], AC_DEFINE(SETVBUF_REVERSED))
  837. rm -f core
  838. ])dnl
  839. dnl
  840. dnl
  841. dnl checks for structure members
  842. dnl
  843. dnl
  844. define(AC_STRUCT_TM,
  845. [AC_PROVIDE([$0])AC_COMPILE_CHECK([struct tm in time.h],
  846. [#include <sys/types.h>
  847. #include <time.h>],
  848. [struct tm *tp; tp->tm_sec;], , AC_DEFINE(TM_IN_SYS_TIME))])dnl
  849. dnl
  850. define(AC_TIME_WITH_SYS_TIME,
  851. [AC_COMPILE_CHECK([whether time.h and sys/time.h may both be included],
  852. [#include <sys/types.h>
  853. #include <sys/time.h>
  854. #include <time.h>],
  855. [struct tm *tp;], AC_DEFINE(TIME_WITH_SYS_TIME))])dnl
  856. dnl
  857. define(AC_TIMEZONE,
  858. [AC_REQUIRE([AC_STRUCT_TM])ac_decl='#include <sys/types.h>
  859. '
  860. case "$DEFS" in
  861.   *TM_IN_SYS_TIME*) ac_decl="$ac_decl
  862. #include <sys/time.h>
  863. " ;;
  864.   *) ac_decl="$ac_decl
  865. #include <time.h>
  866. " ;;
  867. esac
  868. AC_COMPILE_CHECK([tm_zone in struct tm], $ac_decl,
  869. [struct tm tm; tm.tm_zone;], AC_DEFINE(HAVE_TM_ZONE), ac_no_tm_zone=1)
  870. if test -n "$ac_no_tm_zone"; then
  871. AC_COMPILE_CHECK(tzname, changequote(<<,>>)dnl
  872. <<#include <time.h>
  873. #ifndef tzname /* For SGI.  */
  874. extern char *tzname[]; /* RS6000 and others want it this way.  */
  875. #endif>>, changequote([,])dnl
  876. [atoi(*tzname);], AC_DEFINE(HAVE_TZNAME))
  877. fi
  878. ])dnl
  879. dnl
  880. define(AC_ST_BLOCKS,
  881. [AC_COMPILE_CHECK([st_blocks in struct stat],
  882. [#include <sys/types.h>
  883. #include <sys/stat.h>], [struct stat s; s.st_blocks;],
  884. AC_DEFINE(HAVE_ST_BLOCKS), LIBOBJS="$LIBOBJS fileblocks.o")dnl
  885. AC_SUBST(LIBOBJS)dnl
  886. ])dnl
  887. dnl
  888. define(AC_ST_BLKSIZE,
  889. [AC_COMPILE_CHECK([st_blksize in struct stat],
  890. [#include <sys/types.h>
  891. #include <sys/stat.h>], [struct stat s; s.st_blksize;],
  892. AC_DEFINE(HAVE_ST_BLKSIZE))])dnl
  893. dnl
  894. define(AC_ST_RDEV,
  895. [AC_COMPILE_CHECK([st_rdev in struct stat],
  896. [#include <sys/types.h>
  897. #include <sys/stat.h>], [struct stat s; s.st_rdev;],
  898. AC_DEFINE(HAVE_ST_RDEV))])dnl
  899. dnl
  900. dnl
  901. dnl checks for compiler characteristics
  902. dnl
  903. dnl
  904. define(AC_CROSS_CHECK,
  905. [AC_PROVIDE([$0])AC_CHECKING(whether cross-compiling)
  906. # If we cannot run a trivial program, we must be cross compiling.
  907. AC_TEST_PROGRAM([main(){exit(0);}], , cross_compiling=1)
  908. ])dnl
  909. dnl
  910. define(AC_CHAR_UNSIGNED,
  911. [AC_CHECKING(for unsigned characters)
  912. AC_TEST_PROGRAM(
  913. [/* volatile prevents gcc2 from optimizing the test away on sparcs.  */
  914. #if !__STDC__
  915. #define volatile
  916. #endif
  917. main() {
  918. #ifdef __CHAR_UNSIGNED__
  919.   exit(1); /* No need to redefine it.  */
  920. #else
  921.   volatile char c = 255; exit(c < 0);
  922. #endif
  923. }], AC_DEFINE(__CHAR_UNSIGNED__))]
  924. )dnl
  925. dnl
  926. define(AC_LONG_DOUBLE,
  927. [AC_REQUIRE([AC_PROG_CC])dnl
  928. AC_CHECKING(for long double)
  929. if test -n "$GCC"; then
  930. AC_DEFINE(HAVE_LONG_DOUBLE)
  931. else
  932. AC_TEST_PROGRAM([int main() {
  933. /* The Stardent Vistra knows sizeof(long double), but does not support it.  */
  934. long double foo = 0.0;
  935. /* On Ultrix 4.3 cc, long double is 4 and double is 8.  */
  936. exit(sizeof(long double) < sizeof(double)); }],
  937. AC_DEFINE(HAVE_LONG_DOUBLE))
  938. fi
  939. ])dnl
  940. dnl
  941. define(AC_INT_16_BITS,
  942. [AC_OBSOLETE([$0], [; instead use AC_SIZEOF_TYPE(int, sizevar)])
  943. AC_CHECKING(integer size)
  944. AC_TEST_PROGRAM([main() { exit(sizeof(int) != 2); }],
  945.  AC_DEFINE(INT_16_BITS))
  946. ])dnl
  947. dnl
  948. define(AC_LONG_64_BITS,
  949. [AC_OBSOLETE([$0], [; instead use AC_SIZEOF_TYPE(long, sizevar)])
  950. AC_CHECKING(for 64-bit long ints)
  951. AC_TEST_PROGRAM([main() { exit(sizeof(long int) != 8); }],
  952.  AC_DEFINE(LONG_64_BITS))
  953. ])dnl
  954. dnl
  955. define(AC_WORDS_BIGENDIAN,
  956. [AC_CHECKING(byte ordering)
  957. AC_TEST_PROGRAM([main () {
  958.   /* Are we little or big endian?  From Harbison&Steele.  */
  959.   union
  960.   {
  961.     long l;
  962.     char c[sizeof (long)];
  963.   } u;
  964.   u.l = 1;
  965.   exit (u.c[sizeof (long) - 1] == 1);
  966. }], , AC_DEFINE(WORDS_BIGENDIAN))
  967. ])dnl
  968. dnl
  969. define(AC_ARG_ARRAY,
  970. [AC_CHECKING(whether the address of an argument can be used as an array)
  971. AC_TEST_PROGRAM([main() {
  972. /* Return 0 iff arg arrays are ok.  */
  973. exit(!x(1, 2, 3, 4));
  974. }
  975. x(a, b, c, d) {
  976.   return y(a, &b);
  977. }
  978. /* Return 1 iff arg arrays are ok.  */
  979. y(a, b) int *b; {
  980.   return a == 1 && b[0] == 2 && b[1] == 3 && b[2] == 4;
  981. }], , AC_DEFINE(NO_ARG_ARRAY))
  982. rm -f core
  983. ])dnl
  984. dnl
  985. define(AC_INLINE,
  986. [AC_REQUIRE([AC_PROG_CC])if test -n "$GCC"; then
  987. AC_COMPILE_CHECK([inline], , [} inline foo() {], , AC_DEFINE(inline, __inline))
  988. fi
  989. ])dnl
  990. define(AC_CONST,
  991. [changequote(,)dnl
  992. dnl Do not put single quotes in the C program text!!
  993. ac_prog='/* Ultrix mips cc rejects this.  */
  994. typedef int charset[2]; const charset x;
  995. /* SunOS 4.1.1 cc rejects this.  */
  996. char const *const *ccp;
  997. char **p;
  998. /* AIX XL C 1.02.0.0 rejects this.
  999.    It does not let you subtract one const X* pointer from another in an arm
  1000.    of an if-expression whose if-part is not a constant expression */
  1001. const char *g = "string";
  1002. ccp = &g + (g ? g-g : 0);
  1003. /* HPUX 7.0 cc rejects these. */
  1004. ++ccp;
  1005. p = (char**) ccp;
  1006. ccp = (char const *const *) p;
  1007. { /* SCO 3.2v4 cc rejects this.  */
  1008.   char *t;
  1009.   char const *s = 0 ? (char *) 0 : (char const *) 0;
  1010.  
  1011.   *t++ = 0;
  1012. }
  1013. { /* Someone thinks the Sun supposedly-ANSI compiler will reject this.  */
  1014.   int x[] = {25,17};
  1015.   const int *foo = &x[0];
  1016.   ++foo;
  1017. }
  1018. { /* Sun SC1.0 ANSI compiler rejects this -- but not the above. */
  1019.   typedef const int *iptr;
  1020.   iptr p = 0;
  1021.   ++p;
  1022. }
  1023. { /* AIX XL C 1.02.0.0 rejects this saying
  1024.      "k.c", line 2.27: 1506-025 (S) Operand must be a modifiable lvalue. */
  1025.   struct s { int j; const int *ap[3]; };
  1026.   struct s *b; b->j = 5;
  1027. }
  1028. { /* ULTRIX-32 V3.1 (Rev 9) vcc rejects this */
  1029.   const int foo = 10;
  1030. }'
  1031. changequote([,])dnl
  1032. AC_COMPILE_CHECK([dnl Do not "break" this again.
  1033. lack of working const], , [$ac_prog], , AC_DEFINE(const,))])dnl
  1034. dnl
  1035. dnl
  1036. dnl checks for operating system services
  1037. dnl
  1038. dnl
  1039. define(AC_HAVE_POUNDBANG, [dnl
  1040. AC_CHECKING(whether \`#!' works in shell scripts)
  1041. /bin/echo '#!/bin/cat
  1042. exit 69
  1043. ' > conftest
  1044. chmod u+x conftest
  1045. (SHELL=/bin/sh; export SHELL; ./conftest > /dev/null)
  1046. if test $? -ne 69; then
  1047.    :; $1
  1048. else
  1049.    :; $2
  1050. fi
  1051. rm -f conftest
  1052. ])dnl
  1053. define(AC_REMOTE_TAPE,
  1054. [AC_CHECKING(for remote tape and socket header files)
  1055. AC_HEADER_CHECK(sys/mtio.h, AC_DEFINE(HAVE_SYS_MTIO_H) ac_have_mtio_h=1)
  1056. if test -n "$ac_have_mtio_h"; then
  1057. AC_TEST_CPP([#include <sgtty.h>
  1058. #include <sys/socket.h>], PROGS="$PROGS")
  1059. fi
  1060. ])dnl
  1061. dnl
  1062. define(AC_LONG_FILE_NAMES,
  1063. [AC_CHECKING(for long file names)
  1064. ac_some_dir_failed=false
  1065. # Test for long file names in all the places we know might matter:
  1066. #      .        the current directory, where building will happen
  1067. #      /tmp        where it might want to write temporary files
  1068. #      /var/tmp        likewise
  1069. #      /usr/tmp        likewise
  1070. #      $prefix/lib    where we will be installing things
  1071. #      $exec_prefix/lib    likewise
  1072. # eval it to expand exec_prefix.
  1073. for ac_dir in `eval /bin/echo . /tmp $prefix/lib $exec_prefix/lib` ; do
  1074.   test -d $ac_dir || continue
  1075.   test -w $ac_dir || continue # It's less confusing to not echo anything here.
  1076.   (/bin/echo 1 > $ac_dir/conftest9012345) 2>/dev/null
  1077.   (/bin/echo 2 > $ac_dir/conftest9012346) 2>/dev/null
  1078.   val=`cat $ac_dir/conftest9012345 2>/dev/null`
  1079.   test -f $ac_dir/conftest9012345 && test "$val" = 1 || ac_some_dir_failed=true
  1080.   rm -f $ac_dir/conftest9012345 $ac_dir/conftest9012346 2> /dev/null
  1081. done
  1082. $ac_some_dir_failed || AC_DEFINE(HAVE_LONG_FILE_NAMES)
  1083. ])dnl
  1084. dnl
  1085. define(AC_RESTARTABLE_SYSCALLS,
  1086. [AC_CHECKING(for restartable system calls)
  1087. AC_TEST_PROGRAM(
  1088. [/* Exit 0 (true) if wait returns something other than -1,
  1089.    i.e. the pid of the child, which means that wait was restarted
  1090.    after getting the signal.  */
  1091. #include <sys/types.h>
  1092. #include <signal.h>
  1093. ucatch (isig) { }
  1094. main () {
  1095.   int i = fork (), status;
  1096.   if (i == 0) { sleep (3); kill (getppid (), SIGINT); sleep (3); exit (0); }
  1097.   signal (SIGINT, ucatch);
  1098.   status = wait(&i);
  1099.   if (status == -1) wait(&i);
  1100.   exit (status == -1);
  1101. }
  1102. ], AC_DEFINE(HAVE_RESTARTABLE_SYSCALLS))
  1103. ])dnl
  1104. dnl
  1105. define(AC_FIND_X,
  1106. [AC_REQUIRE_CPP()dnl Set CPP; we run AC_FIND_X_DIRECT conditionally.
  1107. AC_PROVIDE([$0])# If we find X, set shell vars x_includes and x_libraries to the paths.
  1108. no_x=true
  1109. if test "x$with_x" != xno; then
  1110. AC_FIND_X_XMKMF
  1111. if test -z "$ac_im_usrlibdir"; then
  1112. AC_FIND_X_DIRECT
  1113. fi
  1114. test -n "$x_includes" && AC_VERBOSE(X11 headers are in $x_includes)
  1115. test -n "$x_libraries" && AC_VERBOSE(X11 libraries are in $x_libraries)
  1116. fi
  1117. ])dnl
  1118. dnl
  1119. dnl Internal subroutine of AC_FIND_X.
  1120. define(AC_FIND_X_XMKMF,
  1121. [AC_CHECKING(for X include and library files with xmkmf)
  1122. rm -fr conftestdir
  1123. if mkdir conftestdir; then
  1124.   cd conftestdir
  1125.   # Make sure to not put "make" in the Imakefile rules, since we grep it out.
  1126.   cat > Imakefile <<'EOF'
  1127. acfindx:
  1128.     @/bin/echo 'ac_im_incroot="${INCROOT}"; ac_im_usrlibdir="${USRLIBDIR}"; ac_im_libdir="${LIBDIR}"'
  1129. EOF
  1130.   if (xmkmf) >/dev/null 2>/dev/null && test -f Makefile; then
  1131.     no_x=
  1132.     # GNU make sometimes prints "make[1]: Entering...", which would confuse us.
  1133.     eval `make acfindx 2>/dev/null | grep -v make`
  1134.     # Open Windows xmkmf reportedly sets LIBDIR instead of USRLIBDIR.
  1135.     if test ! -f $ac_im_usrlibdir/libX11.a && test -f $ac_im_libdir/libX11.a
  1136.     then
  1137.       ac_im_usrlibdir=$ac_im_libdir
  1138.     fi
  1139.     case "$ac_im_incroot" in
  1140.     /gnu/include) ;;
  1141.     *) test -z "$x_includes" && x_includes="$ac_im_incroot" ;;
  1142.     esac
  1143.     case "$ac_im_usrlibdir" in
  1144.     /usr/lib | /lib) ;;
  1145.     *) test -z "$x_libraries" && x_libraries="$ac_im_usrlibdir" ;;
  1146.     esac
  1147.   fi
  1148.   cd ..
  1149.   rm -fr conftestdir
  1150. fi
  1151. ])dnl
  1152. dnl
  1153. dnl Internal subroutine of AC_FIND_X.
  1154. define(AC_FIND_X_DIRECT,
  1155. [AC_CHECKING(for X include and library files directly)
  1156. if test ".$x_direct_test_library" = . ; then
  1157.    x_direct_test_library='Xt'
  1158. fi
  1159. if test ".$x_direct_test_include" = . ; then
  1160.    x_direct_test_include='X11/Intrinsic.h'
  1161. fi
  1162. AC_TEST_CPP([#include <$x_direct_test_include>], no_x=,
  1163.   for ac_dir in               \
  1164.     /usr/X11R6/include        \
  1165.     /usr/X11R5/include        \
  1166.     /usr/X11R4/include        \
  1167.                               \
  1168.     /gnu/include/X11R6        \
  1169.     /gnu/include/X11R5        \
  1170.     /gnu/include/X11R4        \
  1171.                               \
  1172.     /usr/local/X11R6/include  \
  1173.     /usr/local/X11R5/include  \
  1174.     /usr/local/X11R4/include  \
  1175.                               \
  1176.     /usr/local/include/X11R6  \
  1177.     /usr/local/include/X11R5  \
  1178.     /usr/local/include/X11R4  \
  1179.                               \
  1180.     /usr/X11/include          \
  1181.     /gnu/include/X11          \
  1182.     /usr/local/X11/include    \
  1183.     /usr/local/include/X11    \
  1184.                               \
  1185.     /usr/X386/include         \
  1186.     /usr/x386/include         \
  1187.     /usr/XFree86/include/X11  \
  1188.                               \
  1189.     /gnu/include              \
  1190.     /usr/local/include        \
  1191.     /usr/unsupported/include  \
  1192.     /usr/athena/include       \
  1193.     /usr/local/x11r5/include  \
  1194.     /usr/lpp/Xamples/include  \
  1195.                               \
  1196.     /usr/openwin/include      \
  1197.     /usr/openwin/share/include \
  1198.     ; \
  1199.   do
  1200.     if test -r "$ac_dir/$x_direct_test_include"; then
  1201.       test -z "$x_includes" && x_includes=$ac_dir
  1202.       no_x=
  1203.       break
  1204.     fi
  1205.   done)
  1206.  
  1207. # Check for the libraries.  First see if replacing the `include' by
  1208. # `lib' works.
  1209. AC_HAVE_LIBRARY("$x_direct_test_library", no_x=,
  1210. for ac_dir in `/bin/echo "$x_includes" | sed s/include/lib/` \
  1211.     /usr/X11R6/lib        \
  1212.     /usr/X11R5/lib        \
  1213.     /usr/X11R4/lib        \
  1214.                           \
  1215.     /usr/lib/X11R6        \
  1216.     /usr/lib/X11R5        \
  1217.     /usr/lib/X11R4        \
  1218.                           \
  1219.     /usr/local/X11R6/lib  \
  1220.     /usr/local/X11R5/lib  \
  1221.     /usr/local/X11R4/lib  \
  1222.                           \
  1223.     /usr/local/lib/X11R6  \
  1224.     /usr/local/lib/X11R5  \
  1225.     /usr/local/lib/X11R4  \
  1226.                           \
  1227.     /usr/X11/lib          \
  1228.     /usr/lib/X11          \
  1229.     /usr/local/X11/lib    \
  1230.     /usr/local/lib/X11    \
  1231.                           \
  1232.     /usr/X386/lib         \
  1233.     /usr/x386/lib         \
  1234.     /usr/XFree86/lib/X11  \
  1235.                           \
  1236.     /usr/lib              \
  1237.     /usr/local/lib        \
  1238.     /usr/unsupported/lib  \
  1239.     /usr/athena/lib       \
  1240.     /usr/local/x11r5/lib  \
  1241.     /usr/lpp/Xamples/lib  \
  1242.                           \
  1243.     /usr/openwin/lib      \
  1244.     /usr/openwin/share/lib \
  1245.     ; \
  1246. do
  1247.   for ac_extension in a so sl; do
  1248.     if test -r $ac_dir/lib${x_direct_test_library}.$ac_extension; then
  1249.       test -z "$x_libraries" && x_libraries=$ac_dir
  1250.       no_x=
  1251.       break 2
  1252.     fi
  1253.   done
  1254. done)])dnl
  1255. dnl
  1256. dnl Find additional X libraries, magic flags, etc.
  1257. define(AC_FIND_XTRA, [AC_REQUIRE([AC_ISC_POSIX])AC_REQUIRE([AC_FIND_X])
  1258. AC_CHECKING(for additional X libraries and flags)
  1259. if test -n "$x_includes"; then
  1260.   X_CFLAGS="$X_CFLAGS -I$x_includes"
  1261. elif test -n "$no_x"; then 
  1262.   # Not all programs may use this symbol, but it won't hurt to define it.
  1263.   X_CFLAGS="$X_CFLAGS -DX_DISPLAY_MISSING"
  1264. fi
  1265.  
  1266. # It would be nice to have a more robust check for the -R ld option than
  1267. # just checking for Solaris.
  1268. # It would also be nice to do this for all -L options, not just this one.
  1269. if test -n "$x_libraries"; then
  1270.   X_LIBS="$X_LIBS -L$x_libraries"
  1271.   if test "`(uname) 2>/dev/null`" = SunOS \
  1272.      && uname -r | grep '^5' >/dev/null; then
  1273.     X_LIBS="$X_LIBS -R$x_libraries"
  1274.   fi
  1275. fi
  1276.  
  1277. # Check for additional X libraries.
  1278.  
  1279. if test -n "$ISC"; then
  1280.   X_EXTRA_LIBS="$X_EXTRA_LIBS -lnsl_s -linet"
  1281. else
  1282.   # Martyn.Johnson@cl.cam.ac.uk says this is needed for Ultrix, if the X
  1283.   # libraries were built with DECnet support.  And karl@cs.umb.edu's Alpha
  1284.   # needs dnet_stub (dnet doesn't exist).
  1285.   AC_HAVE_LIBRARY(dnet,
  1286.     [X_EXTRA_LIBS="$X_EXTRA_LIBS -ldnet"
  1287.      ac_have_dnet=t])
  1288.   if test -z "$ac_have_dnet"; then
  1289.     AC_HAVE_LIBRARY(dnet_stub, [X_EXTRA_LIBS="$X_EXTRA_LIBS -ldnet_stub"])
  1290.   fi
  1291.   # lieder@skyler.mavd.honeywell.com says without -lsocket,
  1292.   # socket/setsockopt and other routines are undefined under SCO ODT 2.0.
  1293.   # But -lsocket is broken on IRIX, according to simon@lia.di.epfl.ch.
  1294.   if test "`(uname) 2>/dev/null`" != IRIX; then
  1295.     AC_HAVE_LIBRARY(socket, [X_EXTRA_LIBS="$X_EXTRA_LIBS -lsocket"])
  1296.   fi
  1297. fi
  1298. #
  1299. AC_VERBOSE(X compiler flags: $X_CFLAGS)
  1300. AC_VERBOSE(X library flags: $X_LIBS)
  1301. AC_VERBOSE(extra X libraries: $X_EXTRA_LIBS)
  1302. AC_SUBST(X_CFLAGS)dnl
  1303. AC_SUBST(X_LIBS)dnl
  1304. AC_SUBST(X_EXTRA_LIBS)dnl
  1305. ])dnl
  1306. dnl
  1307. dnl
  1308. dnl checks for UNIX variants
  1309. dnl
  1310. dnl
  1311. define(AC_AIX,
  1312. [AC_CHECKING(for AIX)
  1313. AC_BEFORE([$0], [AC_COMPILE_CHECK])AC_BEFORE([$0], [AC_TEST_PROGRAM])AC_BEFORE([$0], [AC_HEADER_EGREP])AC_BEFORE([$0], [AC_TEST_CPP])AC_PROGRAM_EGREP(yes,
  1314. [#ifdef _AIX
  1315.   yes
  1316. #endif
  1317. ], AC_DEFINE(_ALL_SOURCE))
  1318. ])dnl
  1319. dnl
  1320. define(AC_MINIX,
  1321. [AC_BEFORE([$0], [AC_COMPILE_CHECK])AC_BEFORE([$0], [AC_TEST_PROGRAM])AC_BEFORE([$0], [AC_HEADER_EGREP])AC_BEFORE([$0], [AC_TEST_CPP])AC_HEADER_CHECK(minix/config.h, MINIX=1)
  1322. # The Minix shell can't assign to the same variable on the same line!
  1323. if test -n "$MINIX"; then
  1324.   AC_DEFINE(_POSIX_SOURCE)
  1325.   AC_DEFINE(_POSIX_1_SOURCE, 2)
  1326.   AC_DEFINE(_MINIX)
  1327. fi
  1328. ])dnl
  1329. dnl
  1330. define(AC_ISC_POSIX,
  1331. [AC_PROVIDE([$0])AC_BEFORE([$0], [AC_COMPILE_CHECK])AC_BEFORE([$0], [AC_TEST_PROGRAM])AC_BEFORE([$0], [AC_HEADER_EGREP])AC_BEFORE([$0], [AC_TEST_CPP])AC_CHECKING(for POSIXized ISC)
  1332. if test -d /gnu/etc/conf/kconfig.d &&
  1333.   grep _POSIX_VERSION [/gnu/include/sys/unistd.h] >/dev/null 2>&1
  1334. then
  1335.   ISC=1 # If later tests want to check for ISC.
  1336.   AC_DEFINE(_POSIX_SOURCE)
  1337.   if test -n "$GCC"; then
  1338.     CC="$CC -posix"
  1339.   else
  1340.     CC="$CC -Xp"
  1341.   fi
  1342. fi
  1343. ])dnl
  1344. dnl
  1345. define(AC_XENIX_DIR,
  1346. [AC_REQUIRE([AC_DIR_HEADER])AC_CHECKING(for Xenix)
  1347. AC_PROGRAM_EGREP(yes,
  1348. [#if defined(M_XENIX) && !defined(M_UNIX)
  1349.   yes
  1350. #endif
  1351. ], XENIX=1)
  1352. if test -n "$XENIX"; then
  1353.   LIBS="$LIBS -lx"
  1354.   case "$DEFS" in
  1355.   *SYSNDIR*) ;;
  1356.   *) LIBS="-ldir $LIBS" ;; # Make sure -ldir precedes any -lx.
  1357.   esac
  1358. fi
  1359. ])dnl
  1360. dnl
  1361. define(AC_SCO_INTL,
  1362. [AC_HAVE_LIBRARY(intl, LIBS="$LIBS -lintl")
  1363. ])dnl
  1364. dnl
  1365. define(AC_IRIX_SUN,
  1366. [AC_HAVE_LIBRARY(sun, LIBS="$LIBS -lsun")
  1367. ])dnl
  1368. dnl
  1369. define(AC_DYNIX_SEQ,
  1370. [AC_HAVE_LIBRARY(seq, LIBS="$LIBS -lseq")
  1371. ])dnl
  1372. dnl
  1373. define(AC_STAT_MACROS_BROKEN,[AC_CHECKING(for broken stat file mode macros)
  1374. AC_PROGRAM_EGREP([You lose], [#include <sys/types.h>
  1375. #include <sys/stat.h>
  1376. #ifdef S_ISBLK
  1377. #if S_ISBLK (S_IFDIR)
  1378. You lose.
  1379. #endif
  1380. #ifdef S_IFCHR
  1381. #if S_ISBLK (S_IFCHR)
  1382. You lose.
  1383. #endif
  1384. #endif /* S_IFCHR */
  1385. #endif /* S_ISBLK */
  1386. #ifdef S_ISLNK
  1387. #if S_ISLNK (S_IFREG)
  1388. You lose.
  1389. #endif
  1390. #endif /* S_ISLNK */
  1391. #ifdef S_ISSOCK
  1392. #if S_ISSOCK (S_IFREG)
  1393. You lose.
  1394. #endif
  1395. #endif /* S_ISSOCK */
  1396. ], AC_DEFINE(STAT_MACROS_BROKEN))])dnl
  1397. dnl
  1398. dnl
  1399. define(AC_SYS_SIGLIST_DECLARED,[dnl
  1400. AC_COMPILE_CHECK(sys_siglist declaration in signal.h or unistd.h,
  1401.          [#include <signal.h>
  1402. /* NetBSD declares sys_siglist in <unistd.h>.  */
  1403. #ifdef HAVE_UNISTD_H
  1404. #include <unistd.h>
  1405. #endif], [char *msg = *(sys_siglist + 1);],
  1406.          AC_DEFINE(SYS_SIGLIST_DECLARED))])dnl
  1407. dnl
  1408.