home *** CD-ROM | disk | FTP | other *** search
/ Il CD di internet / CD.iso / SOURCE / D / CLISP / CLISPSRC.TAR / clisp-1995-01-01 / src / autoconf-1.7 / acspecific.m4 < prev    next >
Encoding:
M4 Source File  |  1994-08-22  |  33.1 KB  |  1,196 lines

  1. dnl Macros that test for specific features.
  2. dnl This file is part of Autoconf.
  3. dnl Copyright (C) 1992, 1993 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 Changed by Bruno Haible, 22 August 1994
  24. dnl
  25. dnl
  26. dnl checks for programs
  27. dnl
  28. dnl
  29. define(AC_PROG_CC,
  30. [AC_BEFORE([$0], [AC_PROG_CPP])AC_PROVIDE([$0])AC_PROGRAM_CHECK(CC, gcc, gcc, cc)
  31. # Find out if we are using GNU C, under whatever name.
  32. cat > conftest.c <<EOF
  33. #ifdef __GNUC__
  34.   yes
  35. #endif
  36. EOF
  37. ${CC-cc} -E conftest.c > conftest.out 2>&1
  38. if egrep yes conftest.out >/dev/null 2>&1; then
  39.   GCC=1 # For later tests.
  40.   CC="$CC -O"
  41. fi
  42. rm -f conftest*
  43. ])dnl
  44. dnl
  45. define(AC_GCC_TRADITIONAL,
  46. [AC_REQUIRE([AC_PROG_CC])AC_REQUIRE([AC_PROG_CPP])if test -n "$GCC"; then
  47.   AC_MSG_CHECKING(whether -traditional is needed)
  48. changequote(,)dnl
  49.   pattern="Autoconf.*'x'"
  50. changequote([,])dnl
  51.   prog='#include <sgtty.h>
  52. Autoconf TIOCGETP'
  53.   AC_PROGRAM_EGREP($pattern, $prog, need_trad=1)dnl
  54.   if test -z "$need_trad"; then
  55.     prog='#include <termio.h>
  56. Autoconf TCGETA'
  57.     AC_PROGRAM_EGREP($pattern, $prog, need_trad=1)dnl
  58.   fi
  59.   if test -z "$need_trad"; then
  60.     # On some USL SVR4 systems, gcc's fixinc.svr4 modifies <signal.h> and
  61.     # <sys/signal.h> in such a way that "#include <signal.h>" results in a
  62.     # syntax error because of `sigset_t' if gcc is called with __STDC__=1
  63.     # but __STRICT_ANSI__ undefined. Remedy: use -traditional.
  64.     prog='
  65. #include <sys/types.h>
  66. #include <signal.h>
  67. int main() { exit(0); }'
  68.     echo "$prog" > conftest.c
  69.     if eval $compile; then
  70.       :
  71.     else
  72.       prog='
  73. #undef __STDC__
  74. #include <sys/types.h>
  75. #include <signal.h>
  76. int main() { exit(0); }'
  77.       echo "$prog" > conftest.c
  78.       if eval $compile; then
  79.         need_trad=1
  80.       fi
  81.     fi
  82.     rm -f conftest*
  83.   fi
  84.   if test -n "$need_trad"; then
  85.     AC_MSG_RESULT(yes)
  86.     CC="$CC -traditional"
  87.   else
  88.     AC_MSG_RESULT(no)
  89.   fi
  90. fi
  91. ])dnl
  92. dnl
  93. define(AC_MINUS_C_MINUS_O,
  94. [AC_MSG_CHECKING(whether $CC and cc understand -c and -o together)
  95. echo 'foo(){}' > conftest.c
  96. # Make sure it works both with $CC and with simple cc.
  97. # We do the test twice because some compilers refuse to overwrite an
  98. # existing .o file with -o, though they will create one.
  99. if ${CC-cc} -c conftest.c -o conftest.o >/dev/null 2>&1 \
  100.  && test -f conftest.o && ${CC-cc} -c conftest.c -o conftest.o >/dev/null 2>&1
  101. then
  102.   # Test first that cc exists at all.
  103.   if cc -c conftest.c >/dev/null 2>&1
  104.   then
  105.     if cc -c conftest.c -o conftest2.o >/dev/null 2>&1 && \
  106.        test -f conftest2.o && cc -c conftest.c -o conftest2.o >/dev/null 2>&1
  107.     then
  108.       AC_MSG_RESULT(yes)
  109.     else
  110.       AC_MSG_RESULT(no)
  111.       AC_DEFINE(NO_MINUS_C_MINUS_O)
  112.     fi
  113.   fi
  114. else
  115.   AC_MSG_RESULT(no)
  116.   AC_DEFINE(NO_MINUS_C_MINUS_O)
  117. fi
  118. rm -f conftest*
  119. ])dnl
  120. dnl
  121. define(AC_PROG_RANLIB, [AC_PROGRAM_CHECK(RANLIB, ranlib, ranlib, :)])dnl
  122. dnl
  123. define(AC_PROG_AWK, [AC_PROGRAMS_CHECK(AWK, mawk gawk nawk awk,)])dnl
  124. dnl
  125. define(AC_PROG_YACC,[AC_PROGRAMS_CHECK(YACC, 'bison -y' byacc, yacc)])dnl
  126. dnl
  127. define(AC_PROG_CPP,
  128. [AC_PROVIDE([$0])dnl
  129. AC_MSG_CHECKING(how to run the C preprocessor)
  130. if test -z "$CPP"; then
  131.   # This must be in double quotes, not single quotes, because CPP may get
  132.   # substituted into the Makefile and ``${CC-cc}'' will simply confuse
  133.   # make.  It must be expanded now.
  134.   CPP="${CC-cc} -E"
  135.   if test -n "$GCC"; then
  136.     # Suppress warning messages.
  137.     dnl # When using gcc -traditional on machines that have <sys/cdefs.h>,
  138.     dnl # the "-Dconst=" from AC_CONST and the "#define const __const" from
  139.     dnl # <sys/cdefs.h> generate a warning. Unless suppressed, this warning
  140.     dnl # causes later tests using AC_TEST_CPP to fail.
  141.     CPP="$CPP -w"
  142.   fi
  143.   if test -f /coherent; then
  144.     dnl # Coherent's "cc -E" prints it error messages to stdout instead of
  145.     dnl # to stderr. This variable is for the AC_TEST_CPP macro.
  146.     COHERENT=' || echo coherent'
  147.   fi
  148. dnl On the NeXT, cc -E appears to run the code through the compiler's parser,
  149. dnl not just through cpp. On NeXTstep 3.1 the same holds for /lib/cpp; use
  150. dnl "cc -E -traditional-cpp" instead.
  151.   AC_TEST_CPP([#include <stdio.h>
  152. Syntax Error], have_cpp=1)
  153.   if test -z "$have_cpp"; then
  154.     CPP="${CC-cc} -E -traditional-cpp"
  155.     AC_TEST_CPP([#include <stdio.h>
  156. Syntax Error], CC="${CC-cc} -traditional-cpp", CPP=/lib/cpp)
  157.   fi
  158. fi
  159. AC_MSG_RESULT($CPP)
  160. AC_SUBST(CPP)dnl
  161. ])dnl
  162. dnl
  163. define(AC_PROG_LEX,
  164. [AC_PROVIDE([$0])AC_PROGRAM_CHECK(LEX, flex, flex, lex)
  165. if test -z "$LEXLIB"
  166. then
  167.   case "$LEX" in
  168.   flex*) AC_HAVE_LIBRARY(fl, LEXLIB="-lfl") ;;
  169.   *) LEXLIB="-ll" ;;
  170.   esac
  171. fi
  172. AC_SUBST(LEXLIB)])dnl
  173. dnl
  174. define(AC_DECLARE_YYTEXT,
  175. [AC_REQUIRE([AC_PROG_CPP])AC_REQUIRE([AC_PROG_LEX])dnl
  176. echo checking how to declare yytext
  177. # Figure out what yytext is by creating a minimal parser and
  178. # examining the (preprocessed, in case macros are used) output.
  179. if test "z${DECLARE_YYTEXT}" = "z"; then
  180. changequote(,)dnl
  181.   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.     echo "Can't find output from $LEX; assuming lex.yy.c." 1>&2
  190.     LEX_OUTPUT_ROOT=lex.yy
  191.   fi
  192.   AC_SUBST(LEX_OUTPUT_ROOT)dnl
  193.   DECLARE_YYTEXT=`eval ${CPP} "${LEX_OUTPUT_ROOT}.c" |
  194.     sed -n '/extern.*yytext[^a-zA-Z0-9_]/s/^.*extern/extern/p'`
  195.   rm -f "${LEX_OUTPUT_ROOT}.c"
  196. changequote([,])dnl
  197. fi
  198. AC_DEFINE_UNQUOTED(DECLARE_YYTEXT, \"$DECLARE_YYTEXT\")dnl
  199. ])dnl
  200. dnl
  201. define(AC_PROG_INSTALL,
  202. [# Make sure to not get the incompatible SysV /etc/install and
  203. # /usr/sbin/install, which might be in PATH before a BSD-like install,
  204. # or the SunOS /usr/etc/install directory, or the AIX /bin/install,
  205. # or the AFS install, which mishandles nonexistent args, or
  206. # /usr/ucb/install on SVR4, which tries to use the nonexistent group
  207. # `staff'.  On most BSDish systems install is in /usr/bin, not /usr/ucb
  208. # anyway.  Sigh.
  209. if test "z${INSTALL}" = "z" ; then
  210.   AC_MSG_CHECKING(for install)
  211.   IFS="${IFS=     }"; saveifs="$IFS"; IFS="${IFS}:"
  212.   for dir in $PATH; do
  213.     test -z "$dir" && dir=.
  214.     case $dir in
  215.     /etc|/usr/sbin|/usr/etc|/usr/afsws/bin|/usr/ucb) ;;
  216.     *)
  217.       if test -f $dir/installbsd; then
  218.     INSTALL="$dir/installbsd -c" # OSF1
  219.     INSTALL_PROGRAM='$(INSTALL)'
  220.     INSTALL_DATA='$(INSTALL) -m 644'
  221.     break
  222.       fi
  223.       if test -f $dir/install; then
  224.     if grep dspmsg $dir/install >/dev/null 2>&1; then
  225.       : # AIX
  226.     else
  227.       INSTALL="$dir/install -c"
  228.       INSTALL_PROGRAM='$(INSTALL)'
  229.       INSTALL_DATA='$(INSTALL) -m 644'
  230.       break
  231.     fi
  232.       fi
  233.       ;;
  234.     esac
  235.   done
  236.   IFS="$saveifs"
  237.   AC_MSG_RESULT(${INSTALL-cp})
  238. fi
  239. INSTALL=${INSTALL-cp}
  240. AC_SUBST(INSTALL)dnl
  241. INSTALL_PROGRAM=${INSTALL_PROGRAM-'$(INSTALL)'}
  242. AC_SUBST(INSTALL_PROGRAM)dnl
  243. INSTALL_DATA=${INSTALL_DATA-'$(INSTALL)'}
  244. AC_SUBST(INSTALL_DATA)dnl
  245. ])dnl
  246. dnl
  247. define(AC_LN_S,
  248. [AC_MSG_CHECKING(for ln -s)
  249. rm -f conftestdata
  250. if ln -s X conftestdata 2>/dev/null
  251. then
  252.   rm -f conftestdata
  253.   AC_MSG_RESULT(yes)
  254.   LN_S="ln -s"
  255. else
  256.   AC_MSG_RESULT(no)
  257.   LN_S=ln
  258. fi
  259. AC_SUBST(LN_S)
  260. ])dnl
  261. dnl
  262. define(AC_RSH,
  263. [echo checking for remote shell
  264. if test -f /usr/ucb/rsh || test -f /usr/bin/remsh || test -f /usr/bin/rsh ||
  265.   test -f /usr/bsd/rsh || test -f /usr/bin/nsh; then
  266.   RTAPELIB=rtapelib.o
  267. else
  268.   AC_HEADER_CHECK(netdb.h, AC_DEFINE(HAVE_NETDB_H) RTAPELIB=rtapelib.o,
  269.     AC_DEFINE(NO_REMOTE))dnl
  270. fi
  271. AC_SUBST(RTAPELIB)dnl
  272. ])dnl
  273. dnl
  274. dnl
  275. dnl checks for header files
  276. dnl
  277. dnl
  278. define(AC_STDC_HEADERS,
  279. [AC_REQUIRE([AC_PROG_CPP])dnl
  280. AC_MSG_CHECKING(for ANSI C header files)
  281. AC_TEST_CPP([#include <stdlib.h>
  282. #include <stdarg.h>
  283. #include <string.h>
  284. #include <float.h>], , missing_stdc_headers=1)
  285. if test -z "$missing_stdc_headers"; then
  286. # SunOS 4.x string.h does not declare mem*, contrary to ANSI.
  287. AC_HEADER_EGREP(memchr, string.h, , missing_stdc_headers=1)dnl
  288. fi
  289. if test -z "$missing_stdc_headers"; then
  290. # SGI's /bin/cc from Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi.
  291. AC_TEST_PROGRAM([#include <ctype.h>
  292. #define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
  293. #define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c))
  294. #define XOR(e,f) (((e) && !(f)) || (!(e) && (f)))
  295. int main () { int i; for (i = 0; i < 256; i++)
  296. if (XOR (islower (i), ISLOWER (i)) || toupper (i) != TOUPPER (i)) exit(2);
  297. exit (0); }
  298. ],AC_MSG_RESULT(yes)
  299. AC_DEFINE(STDC_HEADERS),
  300. AC_MSG_RESULT(no))
  301. fi
  302. ])dnl
  303. dnl
  304. define(AC_UNISTD_H, [AC_OBSOLETE([$0], [; instead use AC_HAVE_HEADERS(unistd.h)])dnl
  305. AC_HEADER_CHECK(unistd.h,
  306.   AC_DEFINE(HAVE_UNISTD_H))])dnl
  307. dnl
  308. define(AC_USG,
  309. [AC_OBSOLETE([$0], [; instead use AC_HAVE_HEADERS(string.h) and HAVE_STRING_H])dnl
  310. AC_COMPILE_CHECK([BSD string and memory functions],
  311. [#include <strings.h>], [rindex(0, 0); bzero(0, 0);], , AC_DEFINE(USG))])dnl
  312. dnl
  313. dnl
  314. dnl If memchr and the like aren't declared in <string.h>, include <memory.h>.
  315. dnl To avoid problems, don't check for gcc2 built-ins.
  316. define(AC_MEMORY_H,
  317. [AC_OBSOLETE([$0], [; instead use AC_HAVE_HEADERS(memory.h) and HAVE_MEMORY_H])dnl
  318. echo checking whether string.h declares mem functions
  319. AC_HEADER_EGREP(memchr, string.h, ,
  320.   AC_HEADER_CHECK(memory.h, AC_DEFINE(NEED_MEMORY_H)))]
  321. )dnl
  322. dnl
  323. define(AC_MAJOR_HEADER,
  324. [AC_COMPILE_CHECK([major, minor and makedev header],
  325. [#include <sys/types.h>],
  326. [return makedev(0, 0);], makedev=1)
  327. if test -z "$makedev"; then
  328. AC_HEADER_CHECK(sys/mkdev.h, AC_DEFINE(MAJOR_IN_MKDEV) makedev=1)dnl
  329. fi
  330. if test -z "$makedev"; then
  331. AC_HEADER_CHECK(sys/sysmacros.h, AC_DEFINE(MAJOR_IN_SYSMACROS))dnl
  332. fi]
  333. )dnl
  334. dnl
  335. define(AC_DIR_HEADER,
  336. [AC_PROVIDE([$0])dnl
  337. echo checking for directory library header
  338. dirheader=
  339. AC_DIR_HEADER_CHECK(dirent.h, DIRENT)
  340. AC_DIR_HEADER_CHECK(sys/ndir.h, SYSNDIR)
  341. AC_DIR_HEADER_CHECK(sys/dir.h, SYSDIR)
  342. AC_DIR_HEADER_CHECK(ndir.h, NDIR)
  343.  
  344. AC_MSG_CHECKING(for closedir return value)
  345. AC_TEST_PROGRAM([#include <sys/types.h>
  346. #include <$dirheader>
  347. extern
  348. #ifdef __cplusplus
  349. "C"
  350. #endif
  351. #ifdef __STDC__
  352. int closedir (DIR* dirp);
  353. #else
  354. int closedir();
  355. #endif
  356. main() { exit(closedir(opendir(".")) != 0); }], AC_MSG_RESULT(int),
  357. AC_MSG_RESULT(void)
  358. AC_DEFINE(VOID_CLOSEDIR))
  359. ])dnl
  360. dnl Subroutine of AC_DIR_HEADER.
  361. dnl ??? I tried to put this define inside AC_DIR_HEADER, but when I did
  362. dnl that, $1 and $2 did not get expanded. --roland
  363. dnl Check if $1 is the winning directory library header file.
  364. dnl It must not only exist, but also correctly define the `DIR' type.
  365. dnl If it is really winning, define $2 and set shell var `dirheader' to $1.
  366. define(AC_DIR_HEADER_CHECK, [dnl
  367. if test -z "$dirheader"; then
  368.   AC_COMPILE_CHECK($1, [#include <sys/types.h>
  369. #include <]$1[>],
  370.              [DIR *dirp = 0;],
  371.            AC_DEFINE($2)
  372. dirheader=$1)dnl
  373. fi])dnl
  374. dnl
  375. dnl
  376. dnl checks for typedefs
  377. dnl
  378. dnl
  379. define(AC_GETGROUPS_T,
  380. [AC_REQUIRE([AC_UID_T])dnl
  381. AC_MSG_CHECKING(for type of array argument to getgroups)
  382. changequote(,)dnl
  383. dnl Do not put single quotes in the C program text!!
  384. prog='/* Thanks to Mike Rendell for this test.  */
  385. #include <sys/types.h>
  386. #define NGID 256
  387. #undef MAX
  388. #define MAX(x,y) ((x) > (y) ? (x) : (y))
  389. main()
  390. {
  391.   gid_t gidset[NGID];
  392.   int i, n;
  393.   union { gid_t gval; long lval; }  val;
  394.  
  395.   val.lval = -1;
  396.   for (i = 0; i < NGID; i++)
  397.     gidset[i] = val.gval;
  398.   n = getgroups (sizeof (gidset) / MAX (sizeof (int), sizeof (gid_t)) - 1,
  399.                  gidset);
  400.   /* Exit non-zero if getgroups seems to require an array of ints.  This
  401.      happens when gid_t is short but getgroups modifies an array of ints.  */
  402.   exit ((n > 0 && gidset[n] != val.gval) ? 1 : 0);
  403. }'
  404. changequote([,])dnl
  405. AC_TEST_PROGRAM([$prog],
  406.         AC_MSG_RESULT(gid_t*)
  407.         AC_DEFINE(GETGROUPS_T, gid_t),
  408.         AC_MSG_RESULT(int*)
  409.         AC_DEFINE(GETGROUPS_T, int))
  410. ])dnl
  411. dnl
  412. define(AC_UID_T,
  413. [AC_PROVIDE([$0])AC_MSG_CHECKING(for uid_t in sys/types.h)
  414. AC_HEADER_EGREP(uid_t, sys/types.h, AC_MSG_RESULT(yes),
  415. AC_MSG_RESULT(no)
  416. AC_DEFINE(uid_t, int)
  417. AC_DEFINE(gid_t, int))])dnl
  418. dnl
  419. define(AC_SIZE_T,
  420. [AC_MSG_CHECKING(for size_t in sys/types.h)
  421. AC_HEADER_EGREP(size_t, sys/types.h, AC_MSG_RESULT(yes),
  422. AC_MSG_RESULT(no)
  423. AC_DEFINE(size_t, unsigned))])dnl
  424. dnl
  425. define(AC_PID_T,
  426. [AC_PROVIDE([$0])AC_MSG_CHECKING(for pid_t in sys/types.h)
  427. AC_HEADER_EGREP(pid_t, sys/types.h, AC_MSG_RESULT(yes),
  428. AC_MSG_RESULT(no)
  429. AC_DEFINE(pid_t, int))])dnl
  430. dnl
  431. define(AC_OFF_T,
  432. [AC_PROVIDE([$0])AC_MSG_CHECKING(for off_t in sys/types.h)
  433. AC_HEADER_EGREP(off_t, sys/types.h, AC_MSG_RESULT(yes),
  434. AC_MSG_RESULT(no)
  435. AC_DEFINE(off_t, long))])dnl
  436. dnl
  437. define(AC_MODE_T,
  438. [AC_MSG_CHECKING(for mode_t in sys/types.h)
  439. AC_HEADER_EGREP(mode_t, sys/types.h, AC_MSG_RESULT(yes),
  440. AC_MSG_RESULT(no)
  441. AC_DEFINE(mode_t, int))])dnl
  442. dnl
  443. define(AC_RETSIGTYPE,
  444. [AC_PROVIDE([$0])dnl
  445. AC_MSG_CHECKING(return type of signal handlers)
  446. AC_COMPILE_CHECK(,
  447. [#include <sys/types.h>
  448. #include <signal.h>
  449. #ifdef signal
  450. #undef signal
  451. #endif
  452. extern
  453. #ifdef __cplusplus
  454. "C"
  455. #endif
  456. void (*signal ()) ();],
  457. [int i;], retsigtype=void, retsigtype=int)
  458. AC_MSG_RESULT($retsigtype)
  459. AC_DEFINE_UNQUOTED(RETSIGTYPE,$retsigtype)
  460. ])dnl
  461. dnl
  462. dnl
  463. dnl checks for functions
  464. dnl
  465. dnl
  466. define(AC_VPRINTF,
  467. [AC_COMPILE_CHECK([vprintf], , [vprintf();], AC_DEFINE(HAVE_VPRINTF),
  468. vprintf_missing=1)
  469. if test -n "$vprintf_missing"; then
  470. AC_COMPILE_CHECK([_doprnt], , [_doprnt();], AC_DEFINE(HAVE_DOPRNT))
  471. fi
  472. ])dnl
  473. dnl
  474. define(AC_VFORK,
  475. [AC_REQUIRE([AC_PID_T])AC_HEADER_CHECK(vfork.h, AC_DEFINE(HAVE_VFORK_H))dnl
  476. AC_MSG_CHECKING(for working vfork)
  477. AC_REQUIRE([AC_RETSIGTYPE])dnl
  478. AC_TEST_PROGRAM([/* Thanks to Paul Eggert for this test.  */
  479. #include <stdio.h>
  480. #include <sys/types.h>
  481. #include <sys/stat.h>
  482. #include <signal.h>
  483. #ifdef HAVE_UNISTD_H
  484. #include <unistd.h>
  485. #endif
  486. #ifdef HAVE_VFORK_H
  487. #include <vfork.h>
  488. #endif
  489. static int signalled;
  490. static RETSIGTYPE
  491. #ifdef __STDC__
  492. catch (int s)
  493. #else
  494. catch (s) int s;
  495. #endif
  496. { signalled = 1; }
  497. main() {
  498.   pid_t parent = getpid();
  499.   pid_t child;
  500.   signal (SIGINT, catch);
  501.   child = vfork ();
  502.   if (child == 0) {
  503.     /* On sparc systems, changes by the child to local and incoming
  504.        argument registers are propagated back to the parent.
  505.        The compiler is told about this with #include <vfork.h>,
  506.        but some compilers (e.g. gcc -O) don't grok <vfork.h>.
  507.        Test for this by using lots of local variables, at least
  508.        as many local variables as main has allocated so far
  509.        including compiler temporaries.  4 locals are enough for
  510.        gcc 1.40.3 on a sparc, but we use 8 to be safe.
  511.        A buggy compiler should reuse the register of parent
  512.        for one of the local variables, since it will think that
  513.        parent can't possibly be used any more in this routine.
  514.        Assigning to the local variable will thus munge parent
  515.        in the parent process.  */
  516.     pid_t
  517.       p = getpid(), p1 = getpid(), p2 = getpid(), p3 = getpid(),
  518.       p4 = getpid(), p5 = getpid(), p6 = getpid(), p7 = getpid();
  519.     /* Convince the compiler that p..p7 are live; otherwise, it might
  520.        use the same hardware register for all 8 local variables.  */
  521.     if (p != p1 || p != p2 || p != p3 || p != p4
  522.     || p != p5 || p != p6 || p != p7)
  523.       _exit(1);
  524.     /* On some systems (e.g. SunOS 5.2), if the parent is catching
  525.        a signal, the child ignores the signal before execing,
  526.        and the parent later receives that signal, the parent dumps core.
  527.        Test for this by ignoring SIGINT in the child.  */
  528.     signal (SIGINT, SIG_IGN);
  529.     /* On some systems (e.g. IRIX 3.3),
  530.        vfork doesn't separate parent from child file descriptors.
  531.        If the child closes a descriptor before it execs or exits,
  532.        this munges the parent's descriptor as well.
  533.        Test for this by closing stdout in the child.  */
  534.     _exit(close(fileno(stdout)) != 0);
  535.   } else {
  536.     int status;
  537.     struct stat st;
  538.     while (wait(&status) != child) ;
  539.     exit(
  540.      /* Was there some problem with vforking?  */
  541.      child < 0
  542.      /* Did the child fail?  (This shouldn't happen.)  */
  543.      || status
  544.      /* Did the vfork/compiler bug occur?  */
  545.      || parent != getpid()
  546.      /* Did the signal handling bug occur?  */
  547.      || kill(parent, SIGINT) != 0
  548.      || signalled != 1
  549.      /* Did the file descriptor bug occur?  */
  550.      || fstat(fileno(stdout), &st) != 0
  551.      );
  552.   }
  553. }], AC_MSG_RESULT(yes),
  554. rm -f core
  555. AC_MSG_RESULT(no)
  556. AC_DEFINE(vfork, fork))
  557. ])dnl
  558. dnl
  559. define(AC_WAIT3,
  560. [AC_MSG_CHECKING(for wait3 that fills in rusage)
  561. AC_TEST_PROGRAM([#include <sys/types.h>
  562. #include <sys/time.h>
  563. #include <sys/resource.h>
  564. #include <stdio.h>
  565. /* HP-UX has wait3 but does not fill in rusage at all.  */
  566. main() {
  567.   struct rusage r;
  568.   int i;
  569.   /* Use a field that we can force nonzero --
  570.      voluntary context switches.
  571.      For systems like NeXT and OSF/1 that don't set it,
  572.      also use the system CPU time.  */
  573.   r.ru_nvcsw = 0;
  574.   r.ru_stime.tv_sec = 0;
  575.   r.ru_stime.tv_usec = 0;
  576.   switch (fork()) {
  577.   case 0: /* Child.  */
  578.     sleep(1); /* Give up the CPU.  */
  579.     _exit(0);
  580.   case -1: _exit(0); /* What can we do?  */
  581.   default: /* Parent.  */
  582.     wait3(&i, 0, &r);
  583.     exit(r.ru_nvcsw == 0
  584.      && r.ru_stime.tv_sec == 0 && r.ru_stime.tv_usec == 0);
  585.   }
  586. }], AC_MSG_RESULT(yes)
  587. AC_DEFINE(HAVE_WAIT3),
  588. AC_MSG_RESULT(no))
  589. ])dnl
  590. dnl
  591. define(AC_ALLOCA,
  592. [# The Ultrix 4.2 mips builtin alloca declared by alloca.h only works
  593. # for constant arguments.  Useless!
  594. AC_COMPILE_CHECK(working alloca.h, [#include <alloca.h>],
  595.   [char *p = alloca(2 * sizeof(int));], AC_DEFINE(HAVE_ALLOCA_H))
  596. decl="#ifdef __GNUC__
  597. #define alloca __builtin_alloca
  598. #else
  599. #if HAVE_ALLOCA_H
  600. #include <alloca.h>
  601. #else
  602. #ifdef _AIX
  603.  #pragma alloca
  604. #else
  605. char *alloca ();
  606. #endif
  607. #endif
  608. #endif
  609. "
  610. AC_COMPILE_CHECK([alloca], $decl,
  611. [char *p = (char *) alloca(1);], , [dnl
  612. alloca_missing=1
  613. AC_PROGRAM_EGREP(winnitude, [
  614. #if defined(CRAY) && ! defined(CRAY2)
  615. winnitude
  616. #else
  617. lossage
  618. #endif
  619. ],
  620. AC_FUNC_CHECK([_getb67],AC_DEFINE([CRAY_STACKSEG_END],[_getb67]),
  621. AC_FUNC_CHECK([GETB67],AC_DEFINE([CRAY_STACKSEG_END],[GETB67]),
  622. AC_FUNC_CHECK([getb67],AC_DEFINE([CRAY_STACKSEG_END],[getb67])))))
  623. ])
  624. if test -n "$alloca_missing"; then
  625.   # The SVR3 libPW and SVR4 libucb both contain incompatible functions
  626.   # that cause trouble.  Some versions do not even contain alloca or
  627.   # contain a buggy version.  If you still want to use their alloca,
  628.   # use ar to extract alloca.o from them instead of compiling alloca.c.
  629.   ALLOCA=alloca.o
  630.   AC_DEFINE(C_ALLOCA)
  631.  
  632.   echo 'checking stack direction for C alloca'
  633.   AC_TEST_PROGRAM([find_stack_direction ()
  634. {
  635.   static char *addr = 0;
  636.   auto char dummy;
  637.   if (addr == 0)
  638.     {
  639.       addr = &dummy;
  640.       return find_stack_direction ();
  641.     }
  642.   else
  643.     return (&dummy > addr) ? 1 : -1;
  644. }
  645. main ()
  646. {
  647.   exit (find_stack_direction() < 0);
  648. }], dnl
  649. AC_DEFINE(STACK_DIRECTION,1), AC_DEFINE(STACK_DIRECTION,-1), dnl
  650. AC_DEFINE(STACK_DIRECTION,0))
  651. fi
  652. AC_SUBST(ALLOCA)dnl
  653. ])dnl
  654. dnl
  655. define(AC_GETLOADAVG,
  656. [# Some definitions of getloadavg require that the program be installed setgid.
  657. AC_SUBST(NEED_SETGID)NEED_SETGID=false
  658. need_func=true
  659.  
  660. # Check for the 4.4BSD definition of getloadavg.
  661. AC_HAVE_LIBRARY(util, AC_HAVE_LIBRARY(kvm,
  662. LIBS="$LIBS -lutil -lkvm" need_func=false))
  663.  
  664. if $need_func; then
  665. # There is a commonly available library for RS/6000 AIX.
  666. # Since it is not a standard part of AIX, it might be installed locally.
  667. LIBS_old="$LIBS"
  668. LIBS="-L/usr/local/lib $LIBS"
  669. AC_HAVE_LIBRARY(getloadavg, LIBS="$LIBS -lgetloadavg" need_func=false,
  670.     LIBS="$LIBS_old")
  671. fi
  672.  
  673. # Make sure it is really in the library, if we think we found it at all.
  674. AC_REPLACE_FUNCS(getloadavg)
  675.  
  676. case "$LIBOBJS" in
  677. *getloadavg*)
  678. need_func=true
  679. AC_HEADER_CHECK(sys/dg_sys_info.h, [dnl
  680. AC_DEFINE(DGUX) need_func=false
  681. # Some versions of DGUX need -ldgc for dg_sys_info.
  682. AC_HAVE_LIBRARY(dgc)])dnl
  683. if $need_func; then
  684. # We cannot check for <dwarf.h>, because Solaris 2 does not use dwarf (it
  685. # uses stabs), but it's still SVR4.  We cannot check for <elf.h> because
  686. # Irix 4.0.5F has the header but not the library.
  687. AC_HAVE_LIBRARY(elf, AC_DEFINE(SVR4) LIBS="$LIBS -lelf" need_func=false
  688.   AC_HAVE_LIBRARY(kvm, LIBS="$LIBS -lkvm"))dnl
  689. fi
  690. if $need_func; then
  691. AC_HEADER_CHECK(inq_stats/cpustats.h, AC_DEFINE(UMAX4_3) AC_DEFINE(UMAX)
  692.   need_func=false)dnl
  693. fi
  694. if $need_func; then
  695. AC_HEADER_CHECK(sys/cpustats.h, AC_DEFINE(UMAX) need_func=false)dnl
  696. fi
  697. if $need_func; then
  698. AC_HAVE_HEADERS(mach/mach.h)
  699. fi
  700.  
  701. AC_HEADER_CHECK(nlist.h,
  702. [AC_DEFINE(NLIST_STRUCT)
  703. AC_COMPILE_CHECK(n_un in struct nlist, [#include <nlist.h>],
  704. [struct nlist n; n.n_un.n_name = 0;],
  705. AC_DEFINE(NLIST_NAME_UNION))])dnl
  706.  
  707. # Figure out whether we will need to install setgid.
  708. AC_PROGRAM_EGREP([Yowza Am I SETGID yet], [dnl
  709. #include "${srcdir}/getloadavg.c"
  710. #ifdef LDAV_PRIVILEGED
  711. Yowza Am I SETGID yet
  712. #endif], [AC_DEFINE(GETLOADAVG_PRIVILEGED) NEED_SETGID=true])dnl
  713. ;;
  714.  
  715. *) AC_DEFINE(HAVE_GETLOADAVG) ;;
  716. esac
  717.  
  718. if $NEED_SETGID; then
  719.   AC_SUBST(KMEM_GROUP)# Figure out what group owns /dev/kmem.
  720.   # The installed program will need to be setgid and owned by that group.
  721. changequote(,)dnl
  722.   # On Solaris, /dev/kmem is a symlink.  Get info on the real file.
  723.   ls_output=`ls -lgL /dev/kmem 2>/dev/null`
  724.   # If we got an error (system does not support symlinks), try without -L.
  725.   test -z "$ls_output" && ls_output=`ls -lg /dev/kmem`
  726.   KMEM_GROUP=`echo $ls_output \
  727.     | sed -ne 's/[     ][     ]*/ /g;
  728.            s/^.[sSrwx-]* *[0-9]* *\([^0-9]*\)  *.*/\1/;
  729.            / /s/.* //;p;'`
  730. changequote([,])dnl
  731. fi
  732. ])dnl
  733. dnl
  734. define(AC_UTIME_NULL,
  735. [AC_MSG_CHECKING(utime with null argument)
  736. rm -f conftestdata; > conftestdata
  737. # Sequent interprets utime(file, 0) to mean use start of epoch.  Wrong.
  738. AC_TEST_PROGRAM([#include <sys/types.h>
  739. #include <sys/stat.h>
  740. main() {
  741. struct stat s, t;
  742. exit(!(stat ("conftestdata", &s) == 0 && utime("conftestdata", (long *)0) == 0
  743. && stat("conftestdata", &t) == 0 && t.st_mtime >= s.st_mtime
  744. && t.st_mtime - s.st_mtime < 120));
  745. }], AC_MSG_RESULT(yes)
  746. AC_DEFINE(HAVE_UTIME_NULL),
  747. AC_MSG_RESULT(no))
  748. rm -f core
  749. ])dnl
  750. dnl
  751. define(AC_STRCOLL, [AC_MSG_CHECKING(for strcoll)
  752. AC_TEST_PROGRAM([#include <string.h>
  753. main ()
  754. {
  755.   exit (strcoll ("abc", "def") >= 0 ||
  756.     strcoll ("ABC", "DEF") >= 0 ||
  757.     strcoll ("123", "456") >= 0);
  758. }], AC_MSG_RESULT(yes)
  759. AC_DEFINE(HAVE_STRCOLL),
  760. AC_MSG_RESULT(no))])dnl
  761. dnl
  762. define(AC_SETVBUF_REVERSED,
  763. [AC_TEST_PROGRAM([#include <stdio.h>
  764. /* If setvbuf has the reversed format, exit 0. */
  765. main () {
  766.   /* This call has the arguments reversed.
  767.      A reversed system may check and see that the address of main
  768.      is not _IOLBF, _IONBF, or _IOFBF, and return nonzero.  */
  769.   if (setvbuf(stdout, _IOLBF, (char *) main, BUFSIZ) != 0)
  770.     exit(1);
  771.   putc('\r', stdout);
  772.   exit(0);            /* Non-reversed systems segv here.  */
  773. }], AC_DEFINE(SETVBUF_REVERSED))
  774. rm -f core
  775. ])dnl
  776. dnl
  777. dnl
  778. dnl checks for structure members
  779. dnl
  780. dnl
  781. define(AC_STRUCT_TM,
  782. [AC_PROVIDE([$0])AC_COMPILE_CHECK([struct tm in time.h],
  783. [#include <sys/types.h>
  784. #include <time.h>],
  785. [struct tm *tp; tp->tm_sec;], , AC_DEFINE(TM_IN_SYS_TIME))])dnl
  786. dnl
  787. define(AC_TIME_WITH_SYS_TIME,
  788. [AC_COMPILE_CHECK([whether time.h and sys/time.h may both be included],
  789. [#include <sys/types.h>
  790. #include <sys/time.h>
  791. #include <time.h>],
  792. [struct tm *tp;], AC_DEFINE(TIME_WITH_SYS_TIME))])dnl
  793. dnl
  794. define(AC_TIMEZONE,
  795. [AC_REQUIRE([AC_STRUCT_TM])decl='#include <sys/types.h>
  796. '
  797. case "$DEFS" in
  798.   *TM_IN_SYS_TIME*) decl="$decl
  799. #include <sys/time.h>
  800. " ;;
  801.   *) decl="$decl
  802. #include <time.h>
  803. " ;;
  804. esac
  805. AC_COMPILE_CHECK([tm_zone in struct tm], $decl,
  806. [struct tm tm; tm.tm_zone;], AC_DEFINE(HAVE_TM_ZONE), no_tm_zone=1)
  807. if test -n "$no_tm_zone"; then
  808. AC_COMPILE_CHECK(tzname, changequote(<<,>>)dnl
  809. <<#include <time.h>
  810. #ifndef tzname /* For SGI.  */
  811. extern char *tzname[]; /* RS6000 and others want it this way.  */
  812. #endif>>, changequote([,])dnl
  813. [atoi(*tzname);], AC_DEFINE(HAVE_TZNAME))
  814. fi
  815. ])dnl
  816. dnl
  817. define(AC_ST_BLOCKS,
  818. [AC_COMPILE_CHECK([st_blocks in struct stat],
  819. [#include <sys/types.h>
  820. #include <sys/stat.h>], [struct stat s; s.st_blocks;],
  821. AC_DEFINE(HAVE_ST_BLOCKS), LIBOBJS="$LIBOBJS fileblocks.o")dnl
  822. AC_SUBST(LIBOBJS)dnl
  823. ])dnl
  824. dnl
  825. define(AC_ST_BLKSIZE,
  826. [AC_COMPILE_CHECK([st_blksize in struct stat],
  827. [#include <sys/types.h>
  828. #include <sys/stat.h>], [struct stat s; s.st_blksize;],
  829. AC_DEFINE(HAVE_ST_BLKSIZE))])dnl
  830. dnl
  831. define(AC_ST_RDEV,
  832. [AC_COMPILE_CHECK([st_rdev in struct stat],
  833. [#include <sys/types.h>
  834. #include <sys/stat.h>], [struct stat s; s.st_rdev;],
  835. AC_DEFINE(HAVE_ST_RDEV))])dnl
  836. dnl
  837. dnl
  838. dnl checks for compiler characteristics
  839. dnl
  840. dnl
  841. define(AC_CROSS_CHECK,
  842. [AC_PROVIDE([$0])AC_MSG_CHECKING(whether cross-compiling)
  843. # If we cannot run a trivial program, we must be cross compiling.
  844. AC_TEST_PROGRAM([main(){exit(0);}], AC_MSG_RESULT(no),
  845. AC_MSG_RESULT(yes)
  846. cross_compiling=1)
  847. ])dnl
  848. dnl
  849. define(AC_CHAR_UNSIGNED,
  850. [AC_MSG_CHECKING(whether characters are unsigned)
  851. AC_TEST_PROGRAM(
  852. [/* volatile prevents gcc2 from optimizing the test away on sparcs.  */
  853. #if !__STDC__
  854. #define volatile
  855. #endif
  856. main() { volatile char c = 255; exit(c < 0); }],
  857. AC_MSG_RESULT(yes)
  858. AC_DEFINE(__CHAR_UNSIGNED__),
  859. AC_MSG_RESULT(no))]
  860. )dnl
  861. dnl
  862. define(AC_LONG_DOUBLE,
  863. [AC_REQUIRE([AC_PROG_CC])dnl
  864. AC_MSG_CHECKING(for long double)
  865. if test -n "$GCC"; then
  866. AC_MSG_RESULT(yes)
  867. AC_DEFINE(HAVE_LONG_DOUBLE)
  868. else
  869. AC_TEST_PROGRAM([int main() {
  870. /* On Ultrix 4.3 cc, long double is 4 and double is 8.  */
  871. exit(sizeof(long double) < sizeof(double)); }],
  872. AC_MSG_RESULT(yes)
  873. AC_DEFINE(HAVE_LONG_DOUBLE),
  874. AC_MSG_RESULT(no))
  875. fi
  876. ])dnl
  877. dnl
  878. define(AC_INT_16_BITS,
  879. [echo checking integer size
  880. AC_TEST_PROGRAM([main() { exit(sizeof(int) != 2); }],
  881.  AC_DEFINE(INT_16_BITS))
  882. ])dnl
  883. dnl
  884. define(AC_LONG_64_BITS,
  885. [echo checking for 64-bit long ints
  886. AC_TEST_PROGRAM([main() { exit(sizeof(long int) != 8); }],
  887.  AC_DEFINE(LONG_64_BITS))
  888. ])dnl
  889. dnl
  890. define(AC_WORDS_BIGENDIAN,
  891. [echo checking byte ordering
  892. AC_TEST_PROGRAM([main () {
  893.   /* Are we little or big endian?  From Harbison&Steele.  */
  894.   union
  895.   {
  896.     long l;
  897.     char c[sizeof (long)];
  898.   } u;
  899.   u.l = 1;
  900.   exit (u.c[sizeof (long) - 1] == 1);
  901. }], , AC_DEFINE(WORDS_BIGENDIAN))
  902. ])dnl
  903. dnl
  904. define(AC_ARG_ARRAY,
  905. [AC_MSG_CHECKING(whether the address of an argument can be used as an array)
  906. AC_TEST_PROGRAM([main() {
  907. /* Return 0 iff arg arrays are ok.  */
  908. exit(!x(1, 2, 3, 4));
  909. }
  910. x(a, b, c, d) {
  911.   return y(a, &b);
  912. }
  913. /* Return 1 iff arg arrays are ok.  */
  914. y(a, b) int *b; {
  915.   return a == 1 && b[0] == 2 && b[1] == 3 && b[2] == 4;
  916. }], AC_MSG_RESULT(yes),
  917. AC_MSG_RESULT(no)
  918. AC_DEFINE(NO_ARG_ARRAY))
  919. rm -f core
  920. ])dnl
  921. dnl
  922. define(AC_INLINE,
  923. [AC_REQUIRE([AC_PROG_CC])if test -n "$GCC"; then
  924. AC_COMPILE_CHECK([inline], , [} inline foo() {], , AC_DEFINE(inline, __inline))dnl
  925. fi
  926. ])dnl
  927. define(AC_CONST,
  928. [changequote(,)dnl
  929. dnl Do not put single quotes in the C program text!!
  930. prog='/* Ultrix mips cc rejects this.  */
  931. typedef int charset[2]; const charset x;
  932. /* SunOS 4.1.1 cc rejects this.  */
  933. char const *const *ccp;
  934. char **p;
  935. /* AIX XL C 1.02.0.0 rejects this.
  936.    It does not let you subtract one const X* pointer from another in an arm
  937.    of an if-expression whose if-part is not a constant expression */
  938. const char *g = "string";
  939. ccp = &g + (g ? g-g : 0);
  940. /* HPUX 7.0 cc rejects these. */
  941. ++ccp;
  942. p = (char**) ccp;
  943. ccp = (char const *const *) p;
  944. { /* SCO 3.2v4 cc rejects this.  */
  945.   char *t;
  946.   char const *s = 0 ? (char *) 0 : (char const *) 0;
  947.   *t++ = 0;
  948. }
  949. { /* Someone thinks the Sun supposedly-ANSI compiler will reject this.  */
  950.   int x[] = {25,17};
  951.   const int *foo = &x[0];
  952.   ++foo;
  953. }
  954. { /* Sun SC1.0 ANSI compiler rejects this -- but not the above. */
  955.   typedef const int *iptr;
  956.   iptr p = 0;
  957.   ++p;
  958. }
  959. { /* AIX XL C 1.02.0.0 rejects this saying
  960.      "k.c", line 2.27: 1506-025 (S) Operand must be a modifiable lvalue. */
  961.   struct s { int j; const int *ap[3]; };
  962.   struct s *b; b->j = 5;
  963. }
  964. { /* ULTRIX-32 V3.1 (Rev 9) vcc rejects this */
  965.   const int foo = 10;
  966. }'
  967. changequote([,])dnl
  968. AC_COMPILE_CHECK([working const], , [$prog], , AC_DEFINE(const,))])dnl
  969. dnl
  970. dnl
  971. dnl checks for operating system services
  972. dnl
  973. dnl
  974. define(AC_HAVE_POUNDBANG, [dnl
  975. echo "checking if \`#!' works in shell scripts"
  976. echo '#!/bin/cat
  977. exit 69
  978. ' > conftest
  979. chmod u+x conftest
  980. (SHELL=/bin/sh; export SHELL; ./conftest > /dev/null)
  981. if test $? -ne 69; then
  982.    :; $1
  983. else
  984.    :; $2
  985. fi
  986. rm -f conftest
  987. ])dnl
  988. define(AC_REMOTE_TAPE,
  989. [echo checking for remote tape and socket header files
  990. AC_HEADER_CHECK(sys/mtio.h, AC_DEFINE(HAVE_SYS_MTIO_H) have_mtio=1)dnl
  991. if test -n "$have_mtio"; then
  992. AC_TEST_CPP([#include <sgtty.h>
  993. #include <sys/socket.h>], PROGS="$PROGS rmt")
  994. fi
  995. ])dnl
  996. dnl
  997. define(AC_LONG_FILE_NAMES,
  998. [echo checking for long file names
  999. some_dir_failed=false
  1000. # Test for long file names in all the places we know might matter:
  1001. #      .        the current directory, where building will happen
  1002. #      /tmp        where it might want to write temporary files
  1003. #      /var/tmp        likewise
  1004. #      /usr/tmp        likewise
  1005. #      $prefix/lib    where we will be installing things
  1006. #      $exec_prefix/lib    likewise
  1007. # eval it to expand exec_prefix.
  1008. for dir in `eval echo . /tmp /var/tmp /usr/tmp $prefix/lib $exec_prefix/lib` ; do
  1009.   test -d $dir || continue
  1010.   test -w $dir || continue # It's less confusing to not echo anything here.
  1011.   (echo 1 > $dir/conftest9012345) 2>/dev/null
  1012.   (echo 2 > $dir/conftest9012346) 2>/dev/null
  1013.   val=`cat $dir/conftest9012345 2>/dev/null`
  1014.   test -f $dir/conftest9012345 && test "$val" = 1 || some_dir_failed=true
  1015.   rm -f $dir/conftest9012345 $dir/conftest9012346 2> /dev/null
  1016. done
  1017. $some_dir_failed || AC_DEFINE(HAVE_LONG_FILE_NAMES)
  1018. ])dnl
  1019. dnl
  1020. define(AC_RESTARTABLE_SYSCALLS,
  1021. [echo checking for restartable system calls
  1022. AC_TEST_PROGRAM(
  1023. [/* Exit 0 (true) if wait returns something other than -1,
  1024.    i.e. the pid of the child, which means that wait was restarted
  1025.    after getting the signal.  */
  1026. #include <sys/types.h>
  1027. #include <signal.h>
  1028. ucatch (isig) { }
  1029. main () {
  1030.   int i = fork (), status;
  1031.   if (i == 0) { sleep (3); kill (getppid (), SIGINT); sleep (3); exit (0); }
  1032.   signal (SIGINT, ucatch);
  1033.   status = wait(&i);
  1034.   if (status == -1) wait(&i);
  1035.   exit (status == -1);
  1036. }
  1037. ], AC_DEFINE(HAVE_RESTARTABLE_SYSCALLS))
  1038. ])dnl
  1039. dnl
  1040. define(AC_FIND_X,
  1041. [# If we find X, set shell vars x_includes and x_libraries to the paths.
  1042. AC_MSG_CHECKING(for X include and library files with xmkmf)
  1043. rm -fr conftestdir
  1044. if mkdir conftestdir; then
  1045.   cd conftestdir
  1046.   cat > Imakefile <<EOF
  1047. acfindx:
  1048.     @echo "x_includes=\$(INCROOT); x_libraries=\$(USRLIBDIR)"
  1049. EOF
  1050.   if xmkmf >/dev/null 2>/dev/null && test -f Makefile; then
  1051.     eval `make acfindx`
  1052.   fi
  1053.   cd ..
  1054.   rm -fr conftestdir
  1055. fi
  1056. if test -n "$x_includes" && test -n "$x_libraries"; then
  1057.   AC_MSG_RESULT(yes)
  1058. else
  1059.   AC_MSG_RESULT(no)
  1060. fi
  1061. ])dnl
  1062. dnl
  1063. dnl
  1064. dnl checks for UNIX variants
  1065. dnl
  1066. dnl
  1067. define(AC_AIX,
  1068. [AC_MSG_CHECKING(for AIX)
  1069. 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,
  1070. [#ifdef _AIX
  1071.   yes
  1072. #endif
  1073. ], AC_MSG_RESULT(yes)
  1074. AC_DEFINE(_ALL_SOURCE),
  1075. AC_MSG_RESULT(no))dnl
  1076. ])dnl
  1077. dnl
  1078. define(AC_MINIX,
  1079. [AC_BEFORE([$0], [AC_COMPILE_CHECK])AC_BEFORE([$0], [AC_TEST_PROGRAM])AC_BEFORE([$0], [AC_HEADER_EGREP])AC_BEFORE([$0], [AC_TEST_CPP])dnl
  1080. AC_HEADER_CHECK(minix/config.h, MINIX=1)dnl
  1081. # The Minix shell can't assign to the same variable on the same line!
  1082. if test -n "$MINIX"; then
  1083.   AC_DEFINE(_POSIX_SOURCE)
  1084.   AC_DEFINE(_POSIX_1_SOURCE, 2)
  1085.   AC_DEFINE(_MINIX)
  1086. fi
  1087. ])dnl
  1088. dnl
  1089. define(AC_ISC_POSIX,
  1090. [AC_BEFORE([$0], [AC_COMPILE_CHECK])AC_BEFORE([$0], [AC_TEST_PROGRAM])AC_BEFORE([$0], [AC_HEADER_EGREP])AC_BEFORE([$0], [AC_TEST_CPP])dnl
  1091. AC_MSG_CHECKING(for POSIXized ISC)
  1092. if test -d /etc/conf/kconfig.d &&
  1093.   grep _POSIX_VERSION [/usr/include/sys/unistd.h] >/dev/null 2>&1
  1094. then
  1095.   AC_MSG_RESULT(yes)
  1096.   ISC=1 # If later tests want to check for ISC.
  1097.   AC_DEFINE(_POSIX_SOURCE)
  1098.   if test -n "$GCC"; then
  1099.     CC="$CC -posix"
  1100.   else
  1101.     CC="$CC -Xp"
  1102.   fi
  1103. else
  1104.   AC_MSG_RESULT(no)
  1105. fi
  1106. ])dnl
  1107. dnl
  1108. define(AC_XENIX_DIR,
  1109. [AC_REQUIRE([AC_DIR_HEADER])dnl
  1110. AC_MSG_CHECKING(for Xenix)
  1111. AC_PROGRAM_EGREP(yes,
  1112. [#if defined(M_XENIX) && !defined(M_UNIX)
  1113.   yes
  1114. #endif
  1115. ], XENIX=1)dnl
  1116. if test -n "$XENIX"; then
  1117.   AC_MSG_RESULT(yes)
  1118.   LIBS="$LIBS -lx"
  1119.   case "$DEFS" in
  1120.   *SYSNDIR*) ;;
  1121.   *) LIBS="-ldir $LIBS" ;; # Make sure -ldir precedes any -lx.
  1122.   esac
  1123. else
  1124.   AC_MSG_RESULT(no)
  1125. fi
  1126. ])dnl
  1127. dnl
  1128. define(AC_SCO_INTL,
  1129. [AC_MSG_CHECKING(for SCO UNIX libintl)
  1130. AC_PROGRAM_EGREP(yes,
  1131. [#if defined(M_UNIX)
  1132.   yes
  1133. #endif
  1134. ], SCO_UNIX=1)dnl
  1135. if test -n "$SCO_UNIX" && test -f /lib/libintl.a; then
  1136.   AC_MSG_RESULT(yes)
  1137.   LIBS="$LIBS -lintl" # For strftime.
  1138. else
  1139.   AC_MSG_RESULT(no)
  1140. fi
  1141. ])dnl
  1142. dnl
  1143. define(AC_IRIX_SUN,
  1144. [AC_MSG_CHECKING(for IRIX libsun)
  1145. if test -f /usr/lib/libsun.a; then
  1146.   AC_MSG_RESULT(yes)
  1147.   LIBS="$LIBS -lsun"
  1148. else
  1149.   AC_MSG_RESULT(no)
  1150. fi
  1151. ])dnl
  1152. dnl
  1153. define(AC_DYNIX_SEQ,
  1154. [AC_MSG_CHECKING(for DYNIX/ptx libseq)
  1155. AC_PROGRAM_EGREP(yes,
  1156. [#if defined(_SEQUENT_)
  1157.   yes
  1158. #endif
  1159. ], SEQUENT=1)dnl
  1160. if test -n "$SEQUENT" && test -f /usr/lib/libseq.a; then
  1161.   AC_MSG_RESULT(yes)
  1162.   LIBS="$LIBS -lseq"
  1163. else
  1164.   AC_MSG_RESULT(no)
  1165. fi
  1166. ])dnl
  1167. dnl
  1168. define(AC_STAT_MACROS_BROKEN,
  1169. [AC_MSG_CHECKING(for working stat file mode macros)
  1170. AC_PROGRAM_EGREP([You lose], [#include <sys/types.h>
  1171. #include <sys/stat.h>
  1172. #ifdef S_ISBLK
  1173. #if S_ISBLK (S_IFDIR)
  1174. You lose.
  1175. #endif
  1176. #ifdef S_IFCHR
  1177. #if S_ISBLK (S_IFCHR)
  1178. You lose.
  1179. #endif
  1180. #endif /* S_IFCHR */
  1181. #endif /* S_ISBLK */
  1182. #ifdef S_ISLNK
  1183. #if S_ISLNK (S_IFREG)
  1184. You lose.
  1185. #endif
  1186. #endif /* S_ISLNK */
  1187. #ifdef S_ISSOCK
  1188. #if S_ISSOCK (S_IFREG)
  1189. You lose.
  1190. #endif
  1191. #endif /* S_ISSOCK */
  1192. ], AC_MSG_RESULT(no)
  1193. AC_DEFINE(STAT_MACROS_BROKEN),
  1194. AC_MSG_RESULT(yes))])dnl
  1195. dnl
  1196.