autoconf/acspecific.m4

3564 lines
106 KiB
Plaintext
Raw Normal View History

dnl This file is part of Autoconf. -*- Autoconf -*-
1993-10-16 06:51:22 +08:00
dnl Macros that test for specific features.
1999-10-30 22:17:20 +08:00
dnl Copyright (C) 1992, 93, 94, 95, 96, 98, 1999 Free Software Foundation, Inc.
1993-10-16 06:51:22 +08:00
dnl
1994-10-19 08:30:26 +08:00
dnl This program is free software; you can redistribute it and/or modify
1993-10-16 06:51:22 +08:00
dnl it under the terms of the GNU General Public License as published by
dnl the Free Software Foundation; either version 2, or (at your option)
dnl any later version.
dnl
1994-10-19 08:30:26 +08:00
dnl This program is distributed in the hope that it will be useful,
1993-10-16 06:51:22 +08:00
dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
dnl GNU General Public License for more details.
dnl
dnl You should have received a copy of the GNU General Public License
1994-10-19 08:30:26 +08:00
dnl along with this program; if not, write to the Free Software
1996-06-13 01:55:25 +08:00
dnl Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
dnl 02111-1307, USA.
1993-10-16 06:51:22 +08:00
dnl
1994-10-19 00:52:41 +08:00
dnl As a special exception, the Free Software Foundation gives unlimited
dnl permission to copy, distribute and modify the configure scripts that
dnl are the output of Autoconf. You need not follow the terms of the GNU
dnl General Public License when using or distributing such scripts, even
dnl though portions of the text of Autoconf appear in them. The GNU
dnl General Public License (GPL) does govern all other use of the material
dnl that constitutes the Autoconf program.
dnl
dnl Certain portions of the Autoconf source text are designed to be copied
dnl (in certain cases, depending on the input) into the output of
dnl Autoconf. We call these the "data" portions. The rest of the Autoconf
dnl source text consists of comments plus executable code that decides which
dnl of the data portions to output in any given case. We call these
dnl comments and executable code the "non-data" portions. Autoconf never
dnl copies any of the non-data portions into its output.
dnl
dnl This special exception to the GPL applies to versions of Autoconf
dnl released by the Free Software Foundation. When you make and
dnl distribute a modified version of Autoconf, you may extend this special
1994-10-19 08:30:26 +08:00
dnl exception to the GPL to apply to your modified version as well, *unless*
1994-10-19 00:52:41 +08:00
dnl your modified version has the potential to copy into its output some
1994-10-19 13:42:23 +08:00
dnl of the text that was the non-data portion of the version that you started
1994-10-19 00:52:41 +08:00
dnl with. (In other words, unless your change moves or copies text from
dnl the non-data portions to the data portions.) If your modification has
dnl such potential, you must delete any notice of this special exception
dnl to the GPL from your modified version.
1994-09-28 06:05:22 +08:00
dnl
1993-10-16 06:51:22 +08:00
dnl Written by David MacKenzie, with help from
dnl Franc,ois Pinard, Karl Berry, Richard Pixley, Ian Lance Taylor,
1994-10-27 06:42:11 +08:00
dnl Roland McGrath, Noah Friedman, david d zuhn, and many others.
dnl ### Checks for programs
1994-08-11 07:54:30 +08:00
dnl Check whether to use -n, \c, or newline-tab to separate
dnl checking messages from result messages.
dnl Idea borrowed from dist 3.0.
dnl Internal use only.
1994-08-13 10:19:11 +08:00
AC_DEFUN(AC_PROG_ECHO_N,
[if (echo "testing\c"; echo 1,2,3) | grep c >/dev/null; then
# Stardent Vistra SVR4 grep lacks -e, says Kaveh Ghazi
1994-08-26 09:15:45 +08:00
if (echo -n testing; echo 1,2,3) | sed s/-n/xn/ | grep xn >/dev/null; then
1994-08-11 07:54:30 +08:00
ac_n= ac_c='
' ac_t=' '
else
ac_n=-n ac_c= ac_t=
fi
else
ac_n= ac_c='\c' ac_t=
1994-08-13 10:19:11 +08:00
fi
])
1999-10-30 22:17:20 +08:00
dnl AC_PROG_CC([COMPILER ...])
dnl --------------------------
dnl COMPILER ... is a space separated list of C compilers to search for.
dnl This just gives the user an opportunity to specify an alternative
dnl search list for the C compiler.
1994-08-13 10:19:11 +08:00
AC_DEFUN(AC_PROG_CC,
[AC_BEFORE([$0], [AC_PROG_CPP])dnl
1999-10-30 22:17:20 +08:00
AC_ARG_VAR([CFLAGS], [Extra flags for the C compiler])
ifelse([$1], ,
[
AC_CHECK_PROG(CC, gcc, gcc)
if test -z "$CC"; then
1999-10-30 22:17:20 +08:00
AC_CHECK_PROG(CC, cc, cc, , , /usr/ucb/cc)
if test -z "$CC"; then
AC_CHECK_PROGS(CC, cl)
fi
fi
1999-10-30 22:17:20 +08:00
], [AC_CHECK_PROGS(CC, [$1])])
test -z "$CC" && AC_MSG_ERROR([no acceptable cc found in \$PATH])
1994-06-23 02:22:34 +08:00
1996-11-14 08:42:10 +08:00
AC_PROG_CC_WORKS
AC_PROG_CC_GNU
1994-08-27 06:27:25 +08:00
if test $ac_cv_prog_gcc = yes; then
GCC=yes
else
GCC=
fi
dnl Check whether -g works, even if CFLAGS is set, in case the package
dnl plays around with CFLAGS (such as to build both debugging and
dnl normal versions of a library), tasteless as that idea is.
ac_test_CFLAGS="${CFLAGS+set}"
ac_save_CFLAGS="$CFLAGS"
CFLAGS=
AC_PROG_CC_G
if test "$ac_test_CFLAGS" = set; then
CFLAGS="$ac_save_CFLAGS"
elif test $ac_cv_prog_cc_g = yes; then
if test "$GCC" = yes; then
1996-11-12 15:17:30 +08:00
CFLAGS="-g -O2"
else
CFLAGS="-g"
1994-09-07 11:06:34 +08:00
fi
1994-08-27 06:27:25 +08:00
else
if test "$GCC" = yes; then
CFLAGS="-O2"
else
CFLAGS=
fi
1994-08-27 06:27:25 +08:00
fi
])
1999-10-30 22:17:20 +08:00
dnl AC_PROG_CXX([LIST-OF-COMPILERS])
dnl --------------------------------
dnl LIST-OF-COMPILERS is a space separated list of C++ compilers to search
dnl for (if not specified, a default list is used). This just gives the
dnl user an opportunity to specify an alternative search list for the C++
dnl compiler.
1994-08-13 10:19:11 +08:00
AC_DEFUN(AC_PROG_CXX,
[AC_BEFORE([$0], [AC_PROG_CXXCPP])dnl
1999-10-30 22:17:20 +08:00
AC_CHECK_PROGS(CXX, $CCC m4_default([$1], [c++ g++ gpp CC cxx cc++ cl]), g++)
1994-06-23 02:22:34 +08:00
1996-11-14 08:42:10 +08:00
AC_PROG_CXX_WORKS
AC_PROG_CXX_GNU
1994-08-27 06:27:25 +08:00
if test $ac_cv_prog_gxx = yes; then
GXX=yes
else
GXX=
fi
dnl Check whether -g works, even if CXXFLAGS is set, in case the package
dnl plays around with CXXFLAGS (such as to build both debugging and
dnl normal versions of a library), tasteless as that idea is.
ac_test_CXXFLAGS="${CXXFLAGS+set}"
ac_save_CXXFLAGS="$CXXFLAGS"
CXXFLAGS=
AC_PROG_CXX_G
if test "$ac_test_CXXFLAGS" = set; then
CXXFLAGS="$ac_save_CXXFLAGS"
elif test $ac_cv_prog_cxx_g = yes; then
if test "$GXX" = yes; then
1996-11-12 15:17:30 +08:00
CXXFLAGS="-g -O2"
else
CXXFLAGS="-g"
1994-09-07 11:06:34 +08:00
fi
1994-08-27 06:27:25 +08:00
else
if test "$GXX" = yes; then
CXXFLAGS="-O2"
else
CXXFLAGS=
fi
1994-08-27 06:27:25 +08:00
fi
])
dnl AC_PROG_F77([COMPILERS...])
dnl ---------------------------
dnl COMPILERS is a space separated list of Fortran 77 compilers to search
dnl for.
1999-01-05 11:18:40 +08:00
AC_DEFUN(AC_PROG_F77,
[AC_BEFORE([$0], [AC_PROG_CPP])dnl
1999-10-30 22:17:20 +08:00
AC_CHECK_PROGS(F77,
m4_default([$1], [g77 f77 xlf cf77 fl32 fort77 f90 xlf90 f2c]))
1999-01-05 11:18:40 +08:00
AC_PROG_F77_WORKS
AC_PROG_F77_GNU
if test $ac_cv_prog_g77 = yes; then
G77=yes
dnl Check whether -g works, even if FFLAGS is set, in case the package
dnl plays around with FFLAGS (such as to build both debugging and
dnl normal versions of a library), tasteless as that idea is.
ac_test_FFLAGS="${FFLAGS+set}"
ac_save_FFLAGS="$FFLAGS"
FFLAGS=
1999-01-05 11:18:40 +08:00
AC_PROG_F77_G
if test "$ac_test_FFLAGS" = set; then
FFLAGS="$ac_save_FFLAGS"
1999-01-05 11:18:40 +08:00
elif test $ac_cv_prog_f77_g = yes; then
FFLAGS="-g -O2"
else
FFLAGS="-O2"
fi
else
G77=
test "${FFLAGS+set}" = set || FFLAGS="-g"
fi
])
1999-10-30 22:17:20 +08:00
dnl AC_PROG_CC_WORKS
dnl ----------------
AC_DEFUN(AC_PROG_CC_WORKS,
[AC_MSG_CHECKING([whether the C compiler ($CC $CFLAGS $CPPFLAGS $LDFLAGS) works])
AC_LANG_SAVE
AC_LANG_C
1999-10-30 22:17:20 +08:00
AC_TRY_COMPILER([int main(){return(0);}],
ac_cv_prog_cc_works, ac_cv_prog_cc_cross)
AC_LANG_RESTORE
AC_MSG_RESULT($ac_cv_prog_cc_works)
if test $ac_cv_prog_cc_works = no; then
AC_MSG_ERROR([installation or configuration problem: C compiler cannot create executables.], 77)
fi
AC_MSG_CHECKING([whether the C compiler ($CC $CFLAGS $CPPFLAGS $LDFLAGS) is a cross-compiler])
AC_MSG_RESULT($ac_cv_prog_cc_cross)
cross_compiling=$ac_cv_prog_cc_cross
])
1999-10-30 22:17:20 +08:00
dnl AC_PROG_CXX_WORKS
dnl -----------------
AC_DEFUN(AC_PROG_CXX_WORKS,
[AC_MSG_CHECKING([whether the C++ compiler ($CXX $CXXFLAGS $CPPFLAGS $LDFLAGS) works])
AC_LANG_SAVE
AC_LANG_CPLUSPLUS
1999-10-30 22:17:20 +08:00
AC_TRY_COMPILER([int main(){return(0);}],
ac_cv_prog_cxx_works, ac_cv_prog_cxx_cross)
AC_LANG_RESTORE
AC_MSG_RESULT($ac_cv_prog_cxx_works)
if test $ac_cv_prog_cxx_works = no; then
AC_MSG_ERROR([installation or configuration problem: C++ compiler cannot create executables.], 77)
fi
AC_MSG_CHECKING([whether the C++ compiler ($CXX $CXXFLAGS $CPPFLAGS $LDFLAGS) is a cross-compiler])
AC_MSG_RESULT($ac_cv_prog_cxx_cross)
cross_compiling=$ac_cv_prog_cxx_cross
])dnl AC_PROG_CXX_WORKS
1999-10-30 22:17:20 +08:00
dnl AC_PROG_F77_WORKS
dnl -----------------
1999-01-05 11:18:40 +08:00
dnl Test whether the Fortran 77 compiler can compile and link a trivial
dnl Fortran program. Also, test whether the Fortran 77 compiler is a
dnl cross-compiler (which may realistically be the case if the Fortran
dnl compiler is `g77').
1999-01-05 11:18:40 +08:00
AC_DEFUN(AC_PROG_F77_WORKS,
[AC_MSG_CHECKING([whether the Fortran 77 compiler ($F77 $FFLAGS $LDFLAGS) works])
AC_LANG_SAVE
AC_LANG_FORTRAN77
AC_TRY_COMPILER(
[ program conftest
end
1999-01-05 11:18:40 +08:00
], ac_cv_prog_f77_works, ac_cv_prog_f77_cross)
AC_LANG_RESTORE
1999-01-05 11:18:40 +08:00
AC_MSG_RESULT($ac_cv_prog_f77_works)
if test $ac_cv_prog_f77_works = no; then
AC_MSG_ERROR([installation or configuration problem: Fortran 77 compiler cannot create executables.], 77)
fi
1999-01-05 11:18:40 +08:00
AC_MSG_CHECKING([whether the Fortran 77 compiler ($F77 $FFLAGS $LDFLAGS) is a cross-compiler])
AC_MSG_RESULT($ac_cv_prog_f77_cross)
cross_compiling=$ac_cv_prog_f77_cross
])dnl AC_PROG_F77_WORKS
1999-10-30 22:17:20 +08:00
dnl AC_PROG_CC_GNU
dnl --------------
AC_DEFUN(AC_PROG_CC_GNU,
[AC_CACHE_CHECK(whether we are using GNU C, ac_cv_prog_gcc,
[dnl The semicolon is to pacify NeXT's syntax-checking cpp.
cat >conftest.c <<EOF
#ifdef __GNUC__
yes;
#endif
EOF
if AC_TRY_COMMAND(${CC-cc} -E conftest.c) | egrep yes >/dev/null 2>&1; then
ac_cv_prog_gcc=yes
else
ac_cv_prog_gcc=no
fi])dnl
])
1999-10-30 22:17:20 +08:00
dnl AC_PROG_CXX_GNU
dnl ---------------
AC_DEFUN(AC_PROG_CXX_GNU,
[AC_CACHE_CHECK(whether we are using GNU C++, ac_cv_prog_gxx,
[dnl The semicolon is to pacify NeXT's syntax-checking cpp.
cat >conftest.C <<EOF
#ifdef __GNUC__
yes;
#endif
EOF
if AC_TRY_COMMAND(${CXX-g++} -E conftest.C) | egrep yes >/dev/null 2>&1; then
ac_cv_prog_gxx=yes
else
ac_cv_prog_gxx=no
fi])dnl
])
1999-10-30 22:17:20 +08:00
dnl AC_PROG_F77_GNU
dnl ---------------
1999-01-05 11:18:40 +08:00
dnl Test whether for Fortran 77 compiler is `g77' (the GNU Fortran 77
dnl Compiler). This test depends on whether the Fortran 77 compiler can
dnl do CPP pre-processing.
AC_DEFUN(AC_PROG_F77_GNU,
[AC_CACHE_CHECK(whether we are using GNU Fortran 77, ac_cv_prog_g77,
[cat >conftest.fpp <<EOF
#ifdef __GNUC__
yes
#endif
EOF
1999-01-05 11:18:40 +08:00
if AC_TRY_COMMAND($F77 -E conftest.fpp) | egrep yes >/dev/null 2>&1; then
ac_cv_prog_g77=yes
else
ac_cv_prog_g77=no
fi])])
1999-10-30 22:17:20 +08:00
dnl AC_PROG_CC_G
dnl ------------
AC_DEFUN(AC_PROG_CC_G,
[AC_CACHE_CHECK(whether ${CC-cc} accepts -g, ac_cv_prog_cc_g,
[echo 'void f(){}' >conftest.c
if test -z "`${CC-cc} -g -c conftest.c 2>&1`"; then
ac_cv_prog_cc_g=yes
else
ac_cv_prog_cc_g=no
fi
rm -f conftest*
])])
1999-10-30 22:17:20 +08:00
dnl AC_PROG_CXX_G
dnl -------------
AC_DEFUN(AC_PROG_CXX_G,
[AC_CACHE_CHECK(whether ${CXX-g++} accepts -g, ac_cv_prog_cxx_g,
[echo 'void f(){}' >conftest.cc
if test -z "`${CXX-g++} -g -c conftest.cc 2>&1`"; then
ac_cv_prog_cxx_g=yes
else
ac_cv_prog_cxx_g=no
fi
rm -f conftest*
])])
1999-10-30 22:17:20 +08:00
dnl AC_PROG_F77_G
dnl -------------
1999-01-05 11:18:40 +08:00
dnl Test whether the Fortran 77 compiler can accept the `-g' option to
dnl enable debugging.
1999-01-05 11:18:40 +08:00
AC_DEFUN(AC_PROG_F77_G,
[AC_CACHE_CHECK(whether $F77 accepts -g, ac_cv_prog_f77_g,
[cat >conftest.f <<EOF
program conftest
end
EOF
1999-01-05 11:18:40 +08:00
if test -z "`$F77 -g -c conftest.f 2>&1`"; then
ac_cv_prog_f77_g=yes
else
1999-01-05 11:18:40 +08:00
ac_cv_prog_f77_g=no
fi
rm -f conftest*
])])
dnl AC_PROG_GCC_TRADITIONAL
dnl -----------------------
1994-08-13 10:19:11 +08:00
AC_DEFUN(AC_PROG_GCC_TRADITIONAL,
[AC_REQUIRE([AC_PROG_CC])dnl
AC_REQUIRE([AC_PROG_CPP])dnl
if test $ac_cv_prog_gcc = yes; then
1995-06-29 04:19:08 +08:00
AC_CACHE_CHECK(whether ${CC-cc} needs -traditional,
ac_cv_prog_gcc_traditional,
1994-06-23 02:22:34 +08:00
[ ac_pattern="Autoconf.*'x'"
1994-08-24 14:41:01 +08:00
AC_EGREP_CPP($ac_pattern, [#include <sgtty.h>
Autoconf TIOCGETP],
1994-06-23 02:22:34 +08:00
ac_cv_prog_gcc_traditional=yes, ac_cv_prog_gcc_traditional=no)
1993-10-16 06:51:22 +08:00
if test $ac_cv_prog_gcc_traditional = no; then
1994-08-24 14:41:01 +08:00
AC_EGREP_CPP($ac_pattern, [#include <termio.h>
Autoconf TCGETA],
ac_cv_prog_gcc_traditional=yes)
1995-06-29 04:19:08 +08:00
fi])
if test $ac_cv_prog_gcc_traditional = yes; then
CC="$CC -traditional"
fi
1993-10-16 06:51:22 +08:00
fi
])dnl AC_PROG_GCC_TRADITIONAL
1999-10-30 22:17:20 +08:00
dnl AC_PROG_CC_C_O
dnl --------------
1994-08-13 10:19:11 +08:00
AC_DEFUN(AC_PROG_CC_C_O,
[if test "x$CC" != xcc; then
AC_MSG_CHECKING(whether $CC and cc understand -c and -o together)
else
AC_MSG_CHECKING(whether cc understands -c and -o together)
fi
set dummy $CC; ac_cc=`echo [$]2 |
changequote(, )dnl
sed -e 's/[^a-zA-Z0-9_]/_/g' -e 's/^[0-9]/_/'`
changequote([, ])dnl
AC_CACHE_VAL(ac_cv_prog_cc_${ac_cc}_c_o,
[echo 'foo(){}' >conftest.c
1993-10-16 06:51:22 +08:00
# Make sure it works both with $CC and with simple cc.
# We do the test twice because some compilers refuse to overwrite an
# existing .o file with -o, though they will create one.
ac_try='${CC-cc} -c conftest.c -o conftest.o 1>&AC_FD_CC'
if AC_TRY_EVAL(ac_try) &&
test -f conftest.o && AC_TRY_EVAL(ac_try);
1993-10-16 06:51:22 +08:00
then
eval ac_cv_prog_cc_${ac_cc}_c_o=yes
if test "x$CC" != xcc; then
# Test first that cc exists at all.
if AC_TRY_COMMAND(cc -c conftest.c 1>&AC_FD_CC); then
ac_try='cc -c conftest.c -o conftest.o 1>&AC_FD_CC'
if AC_TRY_EVAL(ac_try) &&
test -f conftest.o && AC_TRY_EVAL(ac_try);
then
# cc works too.
:
else
# cc exists but doesn't like -o.
eval ac_cv_prog_cc_${ac_cc}_c_o=no
fi
1993-10-16 06:51:22 +08:00
fi
fi
else
eval ac_cv_prog_cc_${ac_cc}_c_o=no
1993-10-16 06:51:22 +08:00
fi
rm -f conftest*
])dnl
1994-08-11 00:47:42 +08:00
if eval "test \"`echo '$ac_cv_prog_cc_'${ac_cc}_c_o`\" = yes"; then
AC_MSG_RESULT(yes)
else
AC_MSG_RESULT(no)
1999-10-30 22:17:20 +08:00
AC_DEFINE(NO_MINUS_C_MINUS_O, 1,
[Define if your C compiler doesn't accept -c and -o together.])
fi
1999-10-30 22:17:20 +08:00
])dnl AC_PROG_CC_C_O
dnl AC_PROG_F77_C_O
dnl ---------------
1999-01-05 11:18:40 +08:00
dnl Test if the Fortran 77 compiler accepts the options `-c' and `-o'
dnl simultaneously, and define `F77_NO_MINUS_C_MINUS_O' if it does not.
dnl
dnl The usefulness of this macro is questionable, as I can't really see
dnl why anyone would use it. The only reason I include it is for
dnl completeness, since a similar test exists for the C compiler.
1999-01-05 11:18:40 +08:00
AC_DEFUN(AC_PROG_F77_C_O,
[AC_BEFORE([$0], [AC_PROG_F77])dnl
AC_MSG_CHECKING(whether $F77 understand -c and -o together)
set dummy $F77; ac_f77=`echo [$]2 |
changequote(, )dnl
sed -e 's/[^a-zA-Z0-9_]/_/g' -e 's/^[0-9]/_/'`
changequote([, ])dnl
1999-01-05 11:18:40 +08:00
AC_CACHE_VAL(ac_cv_prog_f77_${ac_f77}_c_o,
[cat >conftest.f <<EOF
program conftest
end
EOF
# We do the `AC_TRY_EVAL' test twice because some compilers refuse to
# overwrite an existing `.o' file with `-o', although they will create
# one.
1999-01-05 11:18:40 +08:00
ac_try='$F77 $FFLAGS -c conftest.f -o conftest.o 1>&AC_FD_CC'
if AC_TRY_EVAL(ac_try) && test -f conftest.o && AC_TRY_EVAL(ac_try); then
1999-01-05 11:18:40 +08:00
eval ac_cv_prog_f77_${ac_f77}_c_o=yes
else
1999-01-05 11:18:40 +08:00
eval ac_cv_prog_f77_${ac_f77}_c_o=no
fi
rm -f conftest*
])dnl
1999-01-05 11:18:40 +08:00
if eval "test \"`echo '$ac_cv_prog_f77_'${ac_f77}_c_o`\" = yes"; then
AC_MSG_RESULT(yes)
else
AC_MSG_RESULT(no)
1999-10-30 22:17:20 +08:00
AC_DEFINE(F77_NO_MINUS_C_MINUS_O, 1,
[Define if your Fortran 77 compiler doesn't accept -c and -o together.])
fi
])dnl AC_PROG_F77_C_O
dnl AC_PROG_CC_STDC
dnl ---------------
dnl If the C compiler in not in ANSI C mode by default, try to add an
dnl option to output variable @code{CC} to make it so. This macro tries
dnl various options that select ANSI C on some system or another. It
dnl considers the compiler to be in ANSI C mode if it handles function
dnl prototypes correctly.
AC_DEFUN(AC_PROG_CC_STDC,
[AC_REQUIRE([AC_PROG_CC])dnl
AC_BEFORE([$0], [AC_C_INLINE])dnl
AC_BEFORE([$0], [AC_C_CONST])dnl
dnl Force this before AC_PROG_CPP. Some cpp's, eg on HPUX, require
dnl a magic option to avoid problems with ANSI preprocessor commands
dnl like #elif.
dnl FIXME: can't do this because then AC_AIX won't work due to a
dnl circular dependency.
dnl AC_BEFORE([$0], [AC_PROG_CPP])
AC_MSG_CHECKING(for ${CC-cc} option to accept ANSI C)
AC_CACHE_VAL(ac_cv_prog_cc_stdc,
[ac_cv_prog_cc_stdc=no
ac_save_CC="$CC"
# Don't try gcc -ansi; that turns off useful extensions and
# breaks some systems' header files.
# AIX -qlanglvl=ansi
# Ultrix and OSF/1 -std1
# HP-UX 10.20 and later -Ae
# HP-UX older versions -Aa -D_HPUX_SOURCE
# SVR4 -Xc -D__EXTENSIONS__
for ac_arg in "" -qlanglvl=ansi -std1 -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__"
do
CC="$ac_save_CC $ac_arg"
AC_TRY_COMPILE(
[#include <stdarg.h>
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
/* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */
struct buf { int x; };
FILE * (*rcsopen) (struct buf *, struct stat *, int);
static char *e (p, i)
char **p;
int i;
{
return p[i];
}
static char *f (char * (*g) (char **, int), char **p, ...)
{
char *s;
va_list v;
va_start (v,p);
s = g (p, va_arg (v,int));
va_end (v);
return s;
}
int test (int i, double x);
struct s1 {int (*f) (int a);};
struct s2 {int (*f) (double a);};
int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int);
int argc;
char **argv;],
[return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1];],
[ac_cv_prog_cc_stdc="$ac_arg"; break])
done
CC="$ac_save_CC"
])
if test -z "$ac_cv_prog_cc_stdc"; then
AC_MSG_RESULT([none needed])
else
AC_MSG_RESULT($ac_cv_prog_cc_stdc)
fi
case "x$ac_cv_prog_cc_stdc" in
x|xno) ;;
*) CC="$CC $ac_cv_prog_cc_stdc" ;;
esac
])dnl AC_PROG_CC_STDC
dnl AC_PROG_GNU_M4
dnl --------------
dnl Check for GNU m4, at least 1.3 (supports frozen files).
AC_DEFUN(AC_PROG_GNU_M4,
[AC_PATH_PROGS(M4, gm4 gnum4 m4, m4)
AC_CACHE_CHECK(whether m4 supports frozen files, ac_cv_prog_gnu_m4,
[ac_cv_prog_gnu_m4=no
if test x"$M4" != x; then
case `$M4 --help < /dev/null 2>&1` in
*reload-state*) ac_cv_prog_gnu_m4=yes ;;
esac
fi])])
1999-10-30 22:17:20 +08:00
dnl AC_PROG_MAKE_SET
dnl ----------------
dnl Define SET_MAKE to set ${MAKE} if make doesn't.
1994-08-13 10:19:11 +08:00
AC_DEFUN(AC_PROG_MAKE_SET,
[AC_MSG_CHECKING(whether ${MAKE-make} sets \${MAKE})
set dummy ${MAKE-make}; ac_make=`echo "[$]2" | sed 'y%./+-%__p_%'`
AC_CACHE_VAL(ac_cv_prog_make_${ac_make}_set,
[cat >conftestmake <<\EOF
all:
@echo 'ac_maketemp="${MAKE}"'
EOF
changequote(, )dnl
# GNU make sometimes prints "make[1]: Entering...", which would confuse us.
eval `${MAKE-make} -f conftestmake 2>/dev/null | grep temp=`
changequote([, ])dnl
if test -n "$ac_maketemp"; then
1994-07-20 06:14:03 +08:00
eval ac_cv_prog_make_${ac_make}_set=yes
else
1994-07-20 06:14:03 +08:00
eval ac_cv_prog_make_${ac_make}_set=no
fi
rm -f conftestmake])dnl
1994-08-11 00:47:42 +08:00
if eval "test \"`echo '$ac_cv_prog_make_'${ac_make}_set`\" = yes"; then
AC_MSG_RESULT(yes)
SET_MAKE=
else
1994-08-11 00:47:42 +08:00
AC_MSG_RESULT(no)
SET_MAKE="MAKE=${MAKE-make}"
fi
AC_SUBST([SET_MAKE])dnl
])
1994-08-13 10:19:11 +08:00
AC_DEFUN(AC_PROG_RANLIB,
[AC_CHECK_PROG(RANLIB, ranlib, ranlib, :)])
1995-02-10 06:44:35 +08:00
dnl Check for mawk first since it's generally faster.
1994-08-13 10:19:11 +08:00
AC_DEFUN(AC_PROG_AWK,
[AC_CHECK_PROGS(AWK, mawk gawk nawk awk, )])
1999-10-30 22:17:20 +08:00
dnl AC_PROG_SED
dnl -----------
dnl Check whether the first sed in the path supports long scripts.
dnl Set the variable $ac_cv_prog_sed_max_cmd to the maximum number
dnl of commands to put in a sed script, `infinite' meaning a priori
dnl infinite.
dnl This macro is not documented on purpose.
AC_DEFUN(AC_PROG_SED,
1999-10-30 22:17:20 +08:00
[AC_CACHE_CHECK([for max sed script length], ac_cv_prog_sed_max_cmd,
[echo >conftest.s "\
s/0/1/;s/1/2/;s/2/3/;s/3/4/;s/4/5/;s/5/6/;s/6/7/;s/7/8/;s/8/9/;s/9/0/;s/9/O/;"
dnl 2^4 = 16 lines of 10 commands.
for ac_cnt in 0 1 2 3
do
cat conftest.s conftest.s >conftest.s1
mv conftest.s1 conftest.s
done
if test "`echo 0 | sed -f conftest.s`" != 0; then
dnl HP-UX sed dies with scripts longer than 100 commands.
ac_cv_prog_sed_max_cmd=100
else
ac_cv_prog_sed_max_cmd=infinite
fi
])dnl
])
dnl AC_PROG_BINSH
dnl -------------
dnl Check the maximum length of an here document.
dnl FIXME: Is this test really reliable?
AC_DEFUN(AC_PROG_BINSH,
1999-10-30 22:17:20 +08:00
[AC_CACHE_CHECK([for max here document length], ac_cv_prog_binsh_max_heredoc,
[echo >conftest.s1 "\
ac_test='This is a sample string to test here documents.'"
dnl 2^8 = 256 lines
for ac_cnt in 0 1 2 3 4 5 6 7
do
cat conftest.s1 conftest.s1 >conftest.sh
mv conftest.sh conftest.s1
done
echo 'cat >conftest.s1 <<CEOF' >conftest.sh
cat conftest.s1 >>conftest.sh
echo 'echo "Success"' >>conftest.sh
echo 'CEOF' >>conftest.sh
$SHELL ./conftest.sh
if test "`$SHELL ./conftest.s1`" != Success; then
dnl Some people say to limit oneself to 12, which seems incredibly small.
ac_cv_prog_binsh_max_heredoc=12
else
ac_cv_prog_binsh_max_heredoc=infinite
fi
])dnl
])dnl AC_PROG_BINSH
dnl AC_PROG_YACC
dnl ------------
1994-08-13 10:19:11 +08:00
AC_DEFUN(AC_PROG_YACC,
[AC_CHECK_PROGS(YACC, 'bison -y' byacc, yacc)])
1999-10-30 22:17:20 +08:00
dnl AC_PROG_CPP
dnl -----------
1994-08-13 10:19:11 +08:00
AC_DEFUN(AC_PROG_CPP,
[AC_MSG_CHECKING(how to run the C preprocessor)
1994-08-26 12:59:56 +08:00
# On Suns, sometimes $CPP names a directory.
if test -n "$CPP" && test -d "$CPP"; then
CPP=
fi
1993-10-16 06:51:22 +08:00
if test -z "$CPP"; then
AC_CACHE_VAL(ac_cv_prog_CPP,
[ # This must be in double quotes, not single quotes, because CPP may get
# substituted into the Makefile and "${CC-cc}" will confuse make.
1993-10-16 06:51:22 +08:00
CPP="${CC-cc} -E"
# On the NeXT, cc -E runs the code through the compiler's parser,
# not just through cpp.
dnl Use a header file that comes with gcc, so configuring glibc
dnl with a fresh cross-compiler works.
AC_TRY_CPP([#include <assert.h>
1993-12-07 12:40:53 +08:00
Syntax Error], ,
CPP="${CC-cc} -E -traditional-cpp"
AC_TRY_CPP([#include <assert.h>
Syntax Error], ,
CPP="${CC-cc} -nologo -E"
AC_TRY_CPP([#include <assert.h>
Syntax Error], , CPP=/lib/cpp)))
ac_cv_prog_CPP="$CPP"])dnl
CPP="$ac_cv_prog_CPP"
else
ac_cv_prog_CPP="$CPP"
1993-10-16 06:51:22 +08:00
fi
1994-08-11 00:47:42 +08:00
AC_MSG_RESULT($CPP)
1993-10-16 06:51:22 +08:00
AC_SUBST(CPP)dnl
1999-10-30 22:17:20 +08:00
])dnl AC_PROG_CPP
1999-10-30 22:17:20 +08:00
dnl AC_PROG_CXXCPP
dnl --------------
1994-08-13 10:19:11 +08:00
AC_DEFUN(AC_PROG_CXXCPP,
[AC_MSG_CHECKING(how to run the C++ preprocessor)
if test -z "$CXXCPP"; then
AC_CACHE_VAL(ac_cv_prog_CXXCPP,
[AC_LANG_SAVE()dnl
AC_LANG_CPLUSPLUS()dnl
1994-11-04 03:52:24 +08:00
CXXCPP="${CXX-g++} -E"
AC_TRY_CPP([#include <stdlib.h>], , CXXCPP=/lib/cpp)
ac_cv_prog_CXXCPP="$CXXCPP"
AC_LANG_RESTORE()dnl
])dnl
CXXCPP="$ac_cv_prog_CXXCPP"
fi
1994-08-11 00:47:42 +08:00
AC_MSG_RESULT($CXXCPP)
AC_SUBST(CXXCPP)dnl
])
2000-01-28 18:44:30 +08:00
dnl Require finding the C or C++ preprocessor, whichever is the
dnl current language.
1994-08-13 10:19:11 +08:00
AC_DEFUN(AC_REQUIRE_CPP,
[AC_LANG_CASE(C, [AC_REQUIRE([AC_PROG_CPP])],
[AC_REQUIRE([AC_PROG_CXXCPP])])])
2000-01-28 18:44:30 +08:00
1999-10-30 22:17:20 +08:00
dnl AC_PROG_LEX
dnl -----------
1994-08-13 10:19:11 +08:00
AC_DEFUN(AC_PROG_LEX,
[AC_CHECK_PROG(LEX, flex, flex, lex)
1993-10-16 06:51:22 +08:00
if test -z "$LEXLIB"
then
case "$LEX" in
1994-10-23 10:08:04 +08:00
flex*) ac_lib=fl ;;
*) ac_lib=l ;;
1993-10-16 06:51:22 +08:00
esac
1995-02-08 06:41:14 +08:00
AC_CHECK_LIB($ac_lib, yywrap, LEXLIB="-l$ac_lib")
1993-10-16 06:51:22 +08:00
fi
AC_SUBST(LEXLIB)])
2000-01-28 18:44:30 +08:00
1999-10-30 22:17:20 +08:00
dnl AC_DECL_YYTEXT
dnl --------------
1995-02-10 06:44:35 +08:00
dnl Check if lex declares yytext as a char * by default, not a char[].
1999-10-30 22:17:20 +08:00
dnl FIXME: Why the heck is there the following line?
1995-02-10 06:44:35 +08:00
undefine([AC_DECL_YYTEXT])
1994-08-13 10:19:11 +08:00
AC_DEFUN(AC_DECL_YYTEXT,
[AC_REQUIRE_CPP()dnl
AC_REQUIRE([AC_PROG_LEX])dnl
1995-06-29 04:19:08 +08:00
AC_CACHE_CHECK(lex output file root, ac_cv_prog_lex_root,
1995-02-10 06:44:35 +08:00
[# The minimal lex program is just a single line: %%. But some broken lexes
# (Solaris, I think it was) want two %% lines, so accommodate them.
echo '%%
%%' | $LEX
if test -f lex.yy.c; then
ac_cv_prog_lex_root=lex.yy
elif test -f lexyy.c; then
ac_cv_prog_lex_root=lexyy
else
AC_MSG_ERROR(cannot find output from $LEX; giving up)
1995-06-29 04:19:08 +08:00
fi])
1995-02-10 06:44:35 +08:00
LEX_OUTPUT_ROOT=$ac_cv_prog_lex_root
AC_SUBST(LEX_OUTPUT_ROOT)dnl
1995-06-29 04:19:08 +08:00
AC_CACHE_CHECK(whether yytext is a pointer, ac_cv_prog_lex_yytext_pointer,
[# POSIX says lex can declare yytext either as a pointer or an array; the
# default is implementation-dependent. Figure out which it is, since
# not all implementations provide the %pointer and %array declarations.
ac_cv_prog_lex_yytext_pointer=no
1995-02-07 07:31:34 +08:00
echo 'extern char *yytext;' >>$LEX_OUTPUT_ROOT.c
ac_save_LIBS="$LIBS"
LIBS="$LIBS $LEXLIB"
1995-02-07 07:31:34 +08:00
AC_TRY_LINK(`cat $LEX_OUTPUT_ROOT.c`, , ac_cv_prog_lex_yytext_pointer=yes)
LIBS="$ac_save_LIBS"
rm -f "${LEX_OUTPUT_ROOT}.c"
])
1995-11-18 04:31:31 +08:00
dnl
if test $ac_cv_prog_lex_yytext_pointer = yes; then
1999-10-30 22:17:20 +08:00
AC_DEFINE(YYTEXT_POINTER, 1,
[Define if `lex' declares `yytext' as a `char *' by default,
not a `char[]'.])
1993-10-16 06:51:22 +08:00
fi
1999-10-30 22:17:20 +08:00
])dnl AC_DECL_YYTEXT
2000-01-28 18:44:30 +08:00
dnl AC_PROG_INSTALL
dnl ---------------
1994-08-13 10:19:11 +08:00
AC_DEFUN(AC_PROG_INSTALL,
1994-06-23 02:22:34 +08:00
[AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT])dnl
1994-09-07 11:06:34 +08:00
# Find a good install program. We prefer a C program (faster),
# so one script is as good as another. But avoid the broken or
# incompatible versions:
1994-08-23 14:01:14 +08:00
# SysV /etc/install, /usr/sbin/install
# SunOS /usr/etc/install
# IRIX /sbin/install
# AIX /bin/install
# AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag
1994-08-23 14:01:14 +08:00
# AFS /usr/afsws/bin/install, which mishandles nonexistent args
# SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff"
# ./install, which can be erroneously created by make from ./install.sh.
AC_MSG_CHECKING(for a BSD compatible install)
if test -z "$INSTALL"; then
1994-06-23 02:22:34 +08:00
AC_CACHE_VAL(ac_cv_path_install,
[ IFS="${IFS= }"; ac_save_IFS="$IFS"; IFS=":"
for ac_dir in $PATH; do
1995-02-10 06:44:35 +08:00
# Account for people who put trailing slashes in PATH elements.
case "$ac_dir/" in
/|./|.//|/etc/*|/usr/sbin/*|/usr/etc/*|/sbin/*|/usr/afsws/bin/*|/usr/ucb/*) ;;
1993-10-16 06:51:22 +08:00
*)
1994-09-07 23:07:09 +08:00
# OSF1 and SCO ODT 3.0 have their own names for install.
# Don't use installbsd from OSF since it installs stuff as root
# by default.
for ac_prog in ginstall scoinst install; do
if test -f $ac_dir/$ac_prog; then
if test $ac_prog = install &&
grep dspmsg $ac_dir/$ac_prog >/dev/null 2>&1; then
# AIX install. It has an incompatible calling convention.
:
elif test $ac_prog = install &&
grep pwplus $ac_dir/$ac_prog >/dev/null 2>&1; then
# program-specific install script used by HP pwplus--don't use.
:
else
1994-06-23 02:22:34 +08:00
ac_cv_path_install="$ac_dir/$ac_prog -c"
break 2
fi
1993-10-16 06:51:22 +08:00
fi
done
1993-10-16 06:51:22 +08:00
;;
esac
done
1996-11-20 13:09:56 +08:00
IFS="$ac_save_IFS"
1995-06-23 11:39:38 +08:00
])dnl
if test "${ac_cv_path_install+set}" = set; then
INSTALL="$ac_cv_path_install"
else
# As a last resort, use the slow shell script. We don't cache a
# path for INSTALL within a source directory, because that will
# break other packages using the cache if that directory is
# removed, or if the path is relative.
INSTALL="$ac_install_sh"
fi
1993-10-16 06:51:22 +08:00
fi
1994-08-25 11:45:07 +08:00
dnl We do special magic for INSTALL instead of AC_SUBST, to get
dnl relative paths right.
1994-08-11 00:47:42 +08:00
AC_MSG_RESULT($INSTALL)
1994-05-18 03:25:23 +08:00
# Use test -z because SunOS4 sh mishandles braces in ${var-val}.
# It thinks the first close brace ends the variable substitution.
test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}'
1993-10-16 06:51:22 +08:00
AC_SUBST(INSTALL_PROGRAM)dnl
test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL}'
AC_SUBST(INSTALL_SCRIPT)dnl
test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644'
1993-10-16 06:51:22 +08:00
AC_SUBST(INSTALL_DATA)dnl
])dnl AC_PROG_INSTALL
2000-01-28 18:44:30 +08:00
dnl AC_PROG_LN_S
dnl ------------
1994-08-13 10:19:11 +08:00
AC_DEFUN(AC_PROG_LN_S,
[AC_MSG_CHECKING(whether ln -s works)
AC_CACHE_VAL(ac_cv_prog_LN_S,
[rm -f conftestdata
1993-10-16 06:51:22 +08:00
if ln -s X conftestdata 2>/dev/null
then
rm -f conftestdata
ac_cv_prog_LN_S="ln -s"
else
ac_cv_prog_LN_S=ln
fi])dnl
LN_S="$ac_cv_prog_LN_S"
if test "$ac_cv_prog_LN_S" = "ln -s"; then
1994-08-11 00:47:42 +08:00
AC_MSG_RESULT(yes)
1993-10-16 06:51:22 +08:00
else
1994-08-11 00:47:42 +08:00
AC_MSG_RESULT(no)
1993-10-16 06:51:22 +08:00
fi
AC_SUBST(LN_S)dnl
2000-01-28 18:44:30 +08:00
])dnl AC_PROG_LN_S
AC_DEFUNCT(AC_RSH, [; replace it with equivalent code])
dnl ### Checks for header files
2000-01-28 18:44:30 +08:00
dnl AC_HEADER_STDC
dnl --------------
1994-08-13 10:19:11 +08:00
AC_DEFUN(AC_HEADER_STDC,
[AC_REQUIRE_CPP()dnl
1995-06-29 04:19:08 +08:00
AC_CACHE_CHECK(for ANSI C header files, ac_cv_header_stdc,
[AC_TRY_CPP([#include <stdlib.h>
1993-10-16 06:51:22 +08:00
#include <stdarg.h>
#include <string.h>
#include <float.h>
], ac_cv_header_stdc=yes, ac_cv_header_stdc=no)
if test $ac_cv_header_stdc = yes; then
# SunOS 4.x string.h does not declare mem*, contrary to ANSI.
AC_EGREP_HEADER(memchr, string.h, , ac_cv_header_stdc=no)
fi
if test $ac_cv_header_stdc = yes; then
# ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI.
AC_EGREP_HEADER(free, stdlib.h, , ac_cv_header_stdc=no)
fi
if test $ac_cv_header_stdc = yes; then
# /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi.
AC_TRY_RUN(
[#include <ctype.h>
#if ((' ' & 0x0FF) == 0x020)
# define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
# define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c))
#else
# define ISLOWER(c) (('a' <= (c) && (c) <= 'i') \
|| ('j' <= (c) && (c) <= 'r') \
|| ('s' <= (c) && (c) <= 'z'))
# define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c))
#endif
#define XOR(e, f) (((e) && !(f)) || (!(e) && (f)))
int
main ()
{
int i;
for (i = 0; i < 256; i++)
if (XOR (islower (i), ISLOWER (i))
|| toupper (i) != TOUPPER (i))
exit(2);
exit (0);
}], , ac_cv_header_stdc=no, :)
1995-06-29 04:19:08 +08:00
fi])
if test $ac_cv_header_stdc = yes; then
1999-10-30 22:17:20 +08:00
AC_DEFINE(STDC_HEADERS, 1, [Define if you have the ANSI C header files.])
1994-08-13 10:19:11 +08:00
fi
])dnl AC_HEADER_STDC
dnl AC_HEADER_MAJOR
dnl ---------------
1994-08-13 10:19:11 +08:00
AC_DEFUN(AC_HEADER_MAJOR,
[AC_CACHE_CHECK(whether sys/types.h defines makedev,
1995-06-29 04:19:08 +08:00
ac_cv_header_sys_types_h_makedev,
[AC_TRY_LINK([#include <sys/types.h>
], [return makedev(0, 0);],
1994-08-25 11:45:07 +08:00
ac_cv_header_sys_types_h_makedev=yes, ac_cv_header_sys_types_h_makedev=no)
1995-06-29 04:19:08 +08:00
])
1994-08-25 11:45:07 +08:00
if test $ac_cv_header_sys_types_h_makedev = no; then
1999-10-30 22:17:20 +08:00
AC_CHECK_HEADER(sys/mkdev.h,
[AC_DEFINE(MAJOR_IN_MKDEV, 1,
[Define if `major', `minor', and `makedev' are
declared in <mkdev.h>.])])
1994-08-25 11:45:07 +08:00
if test $ac_cv_header_sys_mkdev_h = no; then
1999-10-30 22:17:20 +08:00
AC_CHECK_HEADER(sys/sysmacros.h,
[AC_DEFINE(MAJOR_IN_SYSMACROS, 1,
[Define if `major', `minor', and `makedev' are
declared in <sysmacros.h>.])])
1994-08-25 11:45:07 +08:00
fi
1993-10-16 06:51:22 +08:00
fi
])dnl AC_HEADER_MAJOR
1999-10-30 22:17:20 +08:00
dnl AC_CHECK_HEADER_DIRENT(HEADER-FILE, ACTION-IF-FOUND)
dnl ----------------------------------------------------
1994-09-07 11:06:34 +08:00
dnl Like AC_CHECK_HEADER, except also make sure that HEADER-FILE
dnl defines the type `DIR'. dirent.h on NextStep 3.2 doesn't.
AC_DEFUN(AC_CHECK_HEADER_DIRENT,
[ac_safe=`echo "$1" | sed 'y%./+-%__p_%'`
1994-09-07 11:06:34 +08:00
AC_MSG_CHECKING([for $1 that defines DIR])
AC_CACHE_VAL(ac_cv_header_dirent_$ac_safe,
1994-10-23 10:08:04 +08:00
[AC_TRY_COMPILE([#include <sys/types.h>
#include <$1>
], [DIR *dirp = 0;],
1994-09-07 11:06:34 +08:00
eval "ac_cv_header_dirent_$ac_safe=yes",
eval "ac_cv_header_dirent_$ac_safe=no")])dnl
if eval "test \"`echo '$ac_cv_header_dirent_'$ac_safe`\" = yes"; then
AC_MSG_RESULT(yes)
$2
else
AC_MSG_RESULT(no)
fi
])
2000-01-28 18:44:30 +08:00
1999-10-30 22:17:20 +08:00
dnl AC_CHECK_HEADERS_DIRENT(HEADER-FILE... [, ACTION])
dnl --------------------------------------------------
1994-09-07 11:06:34 +08:00
dnl Like AC_CHECK_HEADERS, except succeed only for a HEADER-FILE that
dnl defines `DIR'.
define(AC_CHECK_HEADERS_DIRENT,
1994-09-07 11:06:34 +08:00
[for ac_hdr in $1
do
AC_CHECK_HEADER_DIRENT($ac_hdr,
1994-09-07 11:06:34 +08:00
[changequote(, )dnl
ac_tr_hdr=HAVE_`echo $ac_hdr | sed 'y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%'`
1994-09-07 11:06:34 +08:00
changequote([, ])dnl
AC_DEFINE_UNQUOTED($ac_tr_hdr) $2])dnl
1994-09-07 11:06:34 +08:00
done])
1999-10-30 22:17:20 +08:00
AC_DEFUN(AC_HEADER_DIRENT,
[ac_header_dirent=no
AC_CHECK_HEADERS_DIRENT(dirent.h sys/ndir.h sys/dir.h ndir.h,
[ac_header_dirent=$ac_hdr; break])
# Two versions of opendir et al. are in -ldir and -lx on SCO Xenix.
if test $ac_header_dirent = dirent.h; then
AC_CHECK_LIB(dir, opendir, LIBS="$LIBS -ldir")
else
AC_CHECK_LIB(x, opendir, LIBS="$LIBS -lx")
fi
])
1999-10-30 22:17:20 +08:00
dnl AC_HEADER_STAT
dnl --------------
dnl FIXME: Shouldn't this be named AC_HEADER_SYS_STAT?
1994-08-13 10:19:11 +08:00
AC_DEFUN(AC_HEADER_STAT,
1995-06-29 04:19:08 +08:00
[AC_CACHE_CHECK(whether stat file-mode macros are broken,
ac_cv_header_stat_broken,
[AC_EGREP_CPP([You lose], [#include <sys/types.h>
#include <sys/stat.h>
1995-02-22 04:39:40 +08:00
#if defined(S_ISBLK) && defined(S_IFDIR)
1994-08-26 10:47:25 +08:00
# if S_ISBLK (S_IFDIR)
You lose.
1994-08-26 10:47:25 +08:00
# endif
1995-02-22 04:39:40 +08:00
#endif
#if defined(S_ISBLK) && defined(S_IFCHR)
# if S_ISBLK (S_IFCHR)
You lose.
1994-08-26 10:47:25 +08:00
# endif
#endif
1994-08-26 10:47:25 +08:00
1995-02-22 04:39:40 +08:00
#if defined(S_ISLNK) && defined(S_IFREG)
1994-08-26 10:47:25 +08:00
# if S_ISLNK (S_IFREG)
You lose.
1994-08-26 10:47:25 +08:00
# endif
#endif
1994-08-26 10:47:25 +08:00
1995-02-22 04:39:40 +08:00
#if defined(S_ISSOCK) && defined(S_IFREG)
1994-08-26 10:47:25 +08:00
# if S_ISSOCK (S_IFREG)
You lose.
1994-08-26 10:47:25 +08:00
# endif
#endif
1995-06-29 04:19:08 +08:00
], ac_cv_header_stat_broken=yes, ac_cv_header_stat_broken=no)])
if test $ac_cv_header_stat_broken = yes; then
1999-10-30 22:17:20 +08:00
AC_DEFINE(STAT_MACROS_BROKEN, 1,
[Define if the `S_IS*' macros in <sys/stat.h> do not
work properly.])
fi
])dnl AC_HEADER_STAT
2000-01-28 18:44:30 +08:00
1999-10-30 22:17:20 +08:00
dnl AC_DECL_SYS_SIGLIST
dnl -------------------
1994-08-13 10:19:11 +08:00
AC_DEFUN(AC_DECL_SYS_SIGLIST,
1995-06-29 04:19:08 +08:00
[AC_CACHE_CHECK([for sys_siglist declaration in signal.h or unistd.h],
ac_cv_decl_sys_siglist,
1994-10-23 10:08:04 +08:00
[AC_TRY_COMPILE([#include <sys/types.h>
#include <signal.h>
/* NetBSD declares sys_siglist in unistd.h. */
#ifdef HAVE_UNISTD_H
# include <unistd.h>
1999-10-30 22:17:20 +08:00
#endif
], [char *msg = *(sys_siglist + 1);],
1995-06-29 04:19:08 +08:00
ac_cv_decl_sys_siglist=yes, ac_cv_decl_sys_siglist=no)])
if test $ac_cv_decl_sys_siglist = yes; then
1999-10-30 22:17:20 +08:00
AC_DEFINE(SYS_SIGLIST_DECLARED, 1,
[Define if `sys_siglist' is declared by <signal.h> or <unistd.h>.])
fi
1999-10-30 22:17:20 +08:00
])dnl AC_DECL_SYS_SIGLIST
dnl AC_HEADER_SYS_WAIT
dnl ------------------
AC_DEFUN(AC_HEADER_SYS_WAIT,
1995-06-29 04:19:08 +08:00
[AC_CACHE_CHECK([for sys/wait.h that is POSIX.1 compatible],
ac_cv_header_sys_wait_h,
[AC_TRY_COMPILE(
[#include <sys/types.h>
#include <sys/wait.h>
#ifndef WEXITSTATUS
# define WEXITSTATUS(stat_val) ((unsigned)(stat_val) >> 8)
#endif
#ifndef WIFEXITED
# define WIFEXITED(stat_val) (((stat_val) & 255) == 0)
#endif],
[ int s;
wait (&s);
s = WIFEXITED (s) ? WEXITSTATUS (s) : 1;],
1995-06-29 04:19:08 +08:00
ac_cv_header_sys_wait_h=yes, ac_cv_header_sys_wait_h=no)])
if test $ac_cv_header_sys_wait_h = yes; then
1999-10-30 22:17:20 +08:00
AC_DEFINE(HAVE_SYS_WAIT_H, 1,
[Define if you have <sys/wait.h> that is POSIX.1 compatible.])
fi
])dnl AC_HEADER_SYS_WAIT
1999-10-30 22:17:20 +08:00
dnl A few hasbeen'd macros.
AC_DEFUNCT(AC_UNISTD_H, [; instead use AC_CHECK_HEADERS(unistd.h)])
1999-10-30 22:17:20 +08:00
AC_DEFUNCT(AC_USG,
[; instead use AC_CHECK_HEADERS(string.h) and HAVE_STRING_H])
1999-10-30 22:17:20 +08:00
dnl If memchr and the like aren't declared in <string.h>, include <memory.h>.
dnl To avoid problems, don't check for gcc2 built-ins.
AC_DEFUNCT(AC_MEMORY_H,
[; instead use AC_CHECK_HEADERS(memory.h) and HAVE_MEMORY_H])
1999-10-30 22:17:20 +08:00
AC_DEFUNCT(AC_DIR_HEADER, [; instead use AC_HEADER_DIRENT])
1999-10-30 22:17:20 +08:00
dnl ### Checks for typedefs
dnl AC_TYPE_GETGROUPS
dnl -----------------
1994-08-13 10:19:11 +08:00
AC_DEFUN(AC_TYPE_GETGROUPS,
[AC_REQUIRE([AC_TYPE_UID_T])dnl
1995-06-29 04:19:08 +08:00
AC_CACHE_CHECK(type of array argument to getgroups, ac_cv_type_getgroups,
1994-08-24 14:41:01 +08:00
[AC_TRY_RUN(
changequote(<<, >>)dnl
<<
/* Thanks to Mike Rendell for this test. */
1993-10-16 06:51:22 +08:00
#include <sys/types.h>
#define NGID 256
#undef MAX
#define MAX(x, y) ((x) > (y) ? (x) : (y))
int
1993-10-16 06:51:22 +08:00
main()
{
gid_t gidset[NGID];
int i, n;
union { gid_t gval; long lval; } val;
val.lval = -1;
for (i = 0; i < NGID; i++)
gidset[i] = val.gval;
n = getgroups (sizeof (gidset) / MAX (sizeof (int), sizeof (gid_t)) - 1,
gidset);
/* Exit non-zero if getgroups seems to require an array of ints. This
happens when gid_t is short but getgroups modifies an array of ints. */
exit ((n > 0 && gidset[n] != val.gval) ? 1 : 0);
}>>,
changequote([, ])dnl
1994-09-17 10:09:38 +08:00
ac_cv_type_getgroups=gid_t, ac_cv_type_getgroups=int,
ac_cv_type_getgroups=cross)
if test $ac_cv_type_getgroups = cross; then
dnl When we can't run the test program (we are cross compiling), presume
dnl that <unistd.h> has either an accurate prototype for getgroups or none.
dnl Old systems without prototypes probably use int.
AC_EGREP_HEADER([getgroups.*int.*gid_t], unistd.h,
ac_cv_type_getgroups=gid_t, ac_cv_type_getgroups=int)
1995-06-29 04:19:08 +08:00
fi])
1999-10-30 22:17:20 +08:00
AC_DEFINE_UNQUOTED(GETGROUPS_T, $ac_cv_type_getgroups,
[Define to the type of elements in the array set by
`getgroups'. Usually this is either `int' or `gid_t'.])
])dnl AC_TYPE_GETGROUPS
1994-08-13 10:19:11 +08:00
AC_DEFUN(AC_TYPE_UID_T,
1995-06-29 04:19:08 +08:00
[AC_CACHE_CHECK(for uid_t in sys/types.h, ac_cv_type_uid_t,
[AC_EGREP_HEADER(uid_t, sys/types.h,
1995-06-29 04:19:08 +08:00
ac_cv_type_uid_t=yes, ac_cv_type_uid_t=no)])
if test $ac_cv_type_uid_t = no; then
1999-10-30 22:17:20 +08:00
AC_DEFINE(uid_t, int, [Define to `int' if <sys/types.h> doesn't define.])
AC_DEFINE(gid_t, int, [Define to `int' if <sys/types.h> doesn't define.])
fi
])
1994-08-13 10:19:11 +08:00
AC_DEFUN(AC_TYPE_SIZE_T,
[AC_CHECK_TYPE(size_t, unsigned)])
1994-08-13 10:19:11 +08:00
AC_DEFUN(AC_TYPE_PID_T,
[AC_CHECK_TYPE(pid_t, int)])
1994-08-13 10:19:11 +08:00
AC_DEFUN(AC_TYPE_OFF_T,
[AC_CHECK_TYPE(off_t, long)])
1994-08-13 10:19:11 +08:00
AC_DEFUN(AC_TYPE_MODE_T,
[AC_CHECK_TYPE(mode_t, int)])
1999-10-30 22:17:20 +08:00
dnl AC_TYPE_SIGNAL
dnl --------------
dnl Note that identifiers starting with SIG are reserved by ANSI C.
1994-08-13 10:19:11 +08:00
AC_DEFUN(AC_TYPE_SIGNAL,
1995-06-29 04:19:08 +08:00
[AC_CACHE_CHECK([return type of signal handlers], ac_cv_type_signal,
1994-10-23 10:08:04 +08:00
[AC_TRY_COMPILE([#include <sys/types.h>
1993-10-16 06:51:22 +08:00
#include <signal.h>
#ifdef signal
#undef signal
#endif
1995-02-08 06:41:14 +08:00
#ifdef __cplusplus
1995-11-23 01:42:19 +08:00
extern "C" void (*signal (int, void (*)(int)))(int);
#else
void (*signal ()) ();
1995-02-08 06:41:14 +08:00
#endif
1995-11-23 01:42:19 +08:00
],
1995-06-29 04:19:08 +08:00
[int i;], ac_cv_type_signal=void, ac_cv_type_signal=int)])
1999-10-30 22:17:20 +08:00
AC_DEFINE_UNQUOTED(RETSIGTYPE, $ac_cv_type_signal,
[Define as the return type of signal handlers
(`int' or `void').])
])
dnl ### Checks for functions
1999-10-30 22:17:20 +08:00
dnl AC_FUNC_CLOSEDIR_VOID
dnl ---------------------
dnl Check whether closedir returns void, and #define CLOSEDIR_VOID in
dnl that case.
1994-09-09 04:42:23 +08:00
AC_DEFUN(AC_FUNC_CLOSEDIR_VOID,
[AC_REQUIRE([AC_HEADER_DIRENT])dnl
1995-06-29 04:19:08 +08:00
AC_CACHE_CHECK(whether closedir returns void, ac_cv_func_closedir_void,
[AC_TRY_RUN(
[#include <sys/types.h>
1994-09-09 04:42:23 +08:00
#include <$ac_header_dirent>
int closedir ();
int
main ()
{
exit (closedir (opendir (".")) != 0);
}],
1999-10-30 22:17:20 +08:00
ac_cv_func_closedir_void=no,
ac_cv_func_closedir_void=yes,
ac_cv_func_closedir_void=yes)])
1994-09-09 04:42:23 +08:00
if test $ac_cv_func_closedir_void = yes; then
1999-10-30 22:17:20 +08:00
AC_DEFINE(CLOSEDIR_VOID, 1,
[Define if the `closedir' function returns void instead of `int'.])
1994-09-09 04:42:23 +08:00
fi
])
2000-01-28 18:44:30 +08:00
dnl AC_FUNC_FNMATCH
dnl ---------------
dnl We look for fnmatch.h to avoid that the test fails in C++.
AC_DEFUN(AC_FUNC_FNMATCH,
[AC_CHECK_HEADERS(fnmatch.h)
AC_CACHE_CHECK(for working fnmatch, ac_cv_func_fnmatch_works,
# Some versions of Solaris or SCO have a broken fnmatch function.
# So we run a test program. If we are cross-compiling, take no chance.
# Thanks to John Oleynick and Franc,ois Pinard for this test.
[AC_TRY_RUN(
[#if HAVE_FNMATCH_H
# include <fnmatch.h>
#endif
int
main()
{
exit (fnmatch ("a*", "abc", 0) != 0);
}],
1996-11-12 12:48:04 +08:00
ac_cv_func_fnmatch_works=yes, ac_cv_func_fnmatch_works=no,
ac_cv_func_fnmatch_works=no)])
if test $ac_cv_func_fnmatch_works = yes; then
1999-10-30 22:17:20 +08:00
AC_DEFINE(HAVE_FNMATCH, 1,
[Define if your system has a working `fnmatch' function.])
fi
])dnl AC_FUNC_FNMATCH
1999-10-30 22:17:20 +08:00
dnl AC_FUNC_MMAP
dnl ------------
1994-08-13 10:19:11 +08:00
AC_DEFUN(AC_FUNC_MMAP,
[AC_CHECK_HEADERS(unistd.h)
AC_CHECK_FUNCS(getpagesize)
1996-11-12 12:48:04 +08:00
AC_CACHE_CHECK(for working mmap, ac_cv_func_mmap_fixed_mapped,
[AC_TRY_RUN([
/* Thanks to Mike Haertel and Jim Avera for this test.
Here is a matrix of mmap possibilities:
mmap private not fixed
mmap private fixed at somewhere currently unmapped
mmap private fixed at somewhere already mapped
mmap shared not fixed
mmap shared fixed at somewhere currently unmapped
mmap shared fixed at somewhere already mapped
For private mappings, we should verify that changes cannot be read()
back from the file, nor mmap's back from the file at a different
address. (There have been systems where private was not correctly
implemented like the infamous i386 svr4.0, and systems where the
1999-10-30 22:17:20 +08:00
VM page cache was not coherent with the file system buffer cache
like early versions of FreeBSD and possibly contemporary NetBSD.)
For shared mappings, we should conversely verify that changes get
propogated back to all the places they're supposed to be.
Grep wants private fixed already mapped.
The main things grep needs to know about mmap are:
* does it exist and is it safe to write into the mmap'd area
* how to use it (BSD variants) */
#include <sys/types.h>
#include <fcntl.h>
#include <sys/mman.h>
/* This mess was copied from the GNU getpagesize.h. */
#ifndef HAVE_GETPAGESIZE
# ifdef HAVE_UNISTD_H
# include <unistd.h>
# endif
/* Assume that all systems that can run configure have sys/param.h. */
# ifndef HAVE_SYS_PARAM_H
# define HAVE_SYS_PARAM_H 1
1994-08-26 10:47:25 +08:00
# endif
# ifdef _SC_PAGESIZE
# define getpagesize() sysconf(_SC_PAGESIZE)
# else /* no _SC_PAGESIZE */
# ifdef HAVE_SYS_PARAM_H
# include <sys/param.h>
# ifdef EXEC_PAGESIZE
# define getpagesize() EXEC_PAGESIZE
# else /* no EXEC_PAGESIZE */
# ifdef NBPG
# define getpagesize() NBPG * CLSIZE
# ifndef CLSIZE
# define CLSIZE 1
# endif /* no CLSIZE */
# else /* no NBPG */
# ifdef NBPC
# define getpagesize() NBPC
# else /* no NBPC */
# ifdef PAGESIZE
# define getpagesize() PAGESIZE
# endif /* PAGESIZE */
# endif /* no NBPC */
# endif /* no NBPG */
# endif /* no EXEC_PAGESIZE */
# else /* no HAVE_SYS_PARAM_H */
# define getpagesize() 8192 /* punt totally */
# endif /* no HAVE_SYS_PARAM_H */
# endif /* no _SC_PAGESIZE */
#endif /* no HAVE_GETPAGESIZE */
1994-08-26 10:47:25 +08:00
#ifdef __cplusplus
extern "C" { void *malloc(unsigned); }
1994-08-26 10:47:25 +08:00
#else
char *malloc();
1994-08-26 10:47:25 +08:00
#endif
int
2000-01-28 18:44:30 +08:00
main ()
{
2000-01-28 18:44:30 +08:00
char *data, *data2, *data3;
int i, pagesize;
int fd;
pagesize = getpagesize ();
/* First, make a file with some known garbage in it. */
data = malloc (pagesize);
if (!data)
exit (1);
for (i = 0; i < pagesize; ++i)
*(data + i) = rand ();
umask (0);
fd = creat ("conftestmmap", 0600);
if (fd < 0)
exit (1);
if (write (fd, data, pagesize) != pagesize)
exit (1);
close (fd);
/* Next, try to mmap the file at a fixed address which already has
something else allocated at it. If we can, also make sure that
we see the same garbage. */
fd = open ("conftestmmap", O_RDWR);
if (fd < 0)
exit (1);
data2 = malloc (2 * pagesize);
if (!data2)
exit (1);
data2 += (pagesize - ((int) data2 & (pagesize - 1))) & (pagesize - 1);
if (data2 != mmap (data2, pagesize, PROT_READ | PROT_WRITE,
MAP_PRIVATE | MAP_FIXED, fd, 0L))
exit (1);
for (i = 0; i < pagesize; ++i)
if (*(data + i) != *(data2 + i))
exit (1);
/* Finally, make sure that changes to the mapped area do not
percolate back to the file as seen by read(). (This is a bug on
some variants of i386 svr4.0.) */
for (i = 0; i < pagesize; ++i)
*(data2 + i) = *(data2 + i) + 1;
data3 = malloc (pagesize);
if (!data3)
exit (1);
if (read (fd, data3, pagesize) != pagesize)
exit (1);
for (i = 0; i < pagesize; ++i)
if (*(data + i) != *(data3 + i))
exit (1);
close (fd);
unlink ("conftestmmap");
exit (0);
}], ac_cv_func_mmap_fixed_mapped=yes, ac_cv_func_mmap_fixed_mapped=no,
1996-11-12 12:48:04 +08:00
ac_cv_func_mmap_fixed_mapped=no)])
if test $ac_cv_func_mmap_fixed_mapped = yes; then
1999-10-30 22:17:20 +08:00
AC_DEFINE(HAVE_MMAP, 1,
[Define if you have a working `mmap' system call.])
fi
1999-10-30 22:17:20 +08:00
])dnl AC_FUNC_MMAP
1999-10-30 22:17:20 +08:00
dnl AC_FUNC_GETPGRP
dnl ---------------
1995-02-10 06:44:35 +08:00
AC_DEFUN(AC_FUNC_GETPGRP,
1995-06-29 04:19:08 +08:00
[AC_CACHE_CHECK(whether getpgrp takes no argument, ac_cv_func_getpgrp_void,
2000-01-28 18:44:30 +08:00
[AC_TRY_RUN(
[/*
1995-02-10 06:44:35 +08:00
* If this system has a BSD-style getpgrp(),
* which takes a pid argument, exit unsuccessfully.
*
* Snarfed from Chet Ramey's bash pgrp.c test program
*/
#include <stdio.h>
#include <sys/types.h>
int pid;
int pg1, pg2, pg3, pg4;
int ng, np, s, child;
int
main ()
1995-02-10 06:44:35 +08:00
{
pid = getpid();
pg1 = getpgrp(0);
pg2 = getpgrp();
pg3 = getpgrp(pid);
pg4 = getpgrp(1);
/*
* If all of these values are the same, it's pretty sure that
* we're on a system that ignores getpgrp's first argument.
*/
if (pg2 == pg4 && pg1 == pg3 && pg2 == pg3)
exit(0);
child = fork();
if (child < 0)
exit(1);
else if (child == 0) {
np = getpid();
/*
* If this is Sys V, this will not work; pgrp will be
* set to np because setpgrp just changes a pgrp to be
* the same as the pid.
*/
setpgrp(np, pg1);
ng = getpgrp(0); /* Same result for Sys V and BSD */
if (ng == pg1) {
exit(1);
} else {
exit(0);
}
} else {
wait(&s);
exit(s>>8);
}
}], ac_cv_func_getpgrp_void=yes, ac_cv_func_getpgrp_void=no,
1995-02-10 06:44:35 +08:00
AC_MSG_ERROR(cannot check getpgrp if cross compiling))
])
if test $ac_cv_func_getpgrp_void = yes; then
1999-10-30 22:17:20 +08:00
AC_DEFINE(GETPGRP_VOID, 1,
[Define if the `getpgrp' function takes no argument.])
1995-02-10 06:44:35 +08:00
fi
1999-10-30 22:17:20 +08:00
])dnl AC_FUNC_GETPGRP
1995-02-10 06:44:35 +08:00
dnl AC_FUNC_SETPGRP
dnl ---------------
AC_DEFUN(AC_FUNC_SETPGRP,
[AC_CACHE_CHECK(whether setpgrp takes no argument, ac_cv_func_setpgrp_void,
AC_TRY_RUN(
[#ifdef HAVE_UNISTD_H
# include <unistd.h>
#endif
/* If this system has a BSD-style setpgrp, which takes arguments, exit
successfully. */
int
main ()
{
if (setpgrp (1,1) == -1)
exit (0);
else
exit (1);
}], ac_cv_func_setpgrp_void=no, ac_cv_func_setpgrp_void=yes,
AC_MSG_ERROR(cannot check setpgrp if cross compiling))
)
if test $ac_cv_func_setpgrp_void = yes; then
1999-10-30 22:17:20 +08:00
AC_DEFINE(SETPGRP_VOID, 1,
[Define if the `setpgrp' function takes no argument.])
fi
])dnl AC_FUNC_SETPGRP
dnl AC_FUNC_VPRINTF
dnl ---------------
1999-10-30 22:17:20 +08:00
dnl Why the heck is that _doprnt does not define HAVE__DOPRNT???
dnl That the logical name! In addition, why doesn't it use
dnl AC_CHECK_FUNCS(vprintf)? Because old Autoconf uses sh for loops.
dnl FIXME: To be changed in Autoconf 3?
1994-08-13 10:19:11 +08:00
AC_DEFUN(AC_FUNC_VPRINTF,
1999-10-30 22:17:20 +08:00
[AC_CHECK_FUNC(vprintf,
AC_DEFINE(HAVE_VPRINTF, 1,
[Define if you have the `vprintf' function.]))
1994-06-23 02:22:34 +08:00
if test "$ac_cv_func_vprintf" != yes; then
1999-10-30 22:17:20 +08:00
AC_CHECK_FUNC(_doprnt,
AC_DEFINE(HAVE_DOPRNT, 1,
[Define if you don't have `vprintf' but do have
`_doprnt.']))
1993-10-16 06:51:22 +08:00
fi
])
dnl AC_FUNC_VFORK
dnl -------------
1994-08-13 10:19:11 +08:00
AC_DEFUN(AC_FUNC_VFORK,
[AC_REQUIRE([AC_TYPE_PID_T])dnl
1999-10-30 22:17:20 +08:00
AC_CHECK_HEADER(vfork.h,
AC_DEFINE(HAVE_VFORK_H, 1,
[Define if you have <vfork.h>.]))
1996-11-12 12:48:04 +08:00
AC_CACHE_CHECK(for working vfork, ac_cv_func_vfork_works,
1995-03-07 08:19:27 +08:00
[AC_TRY_RUN([/* Thanks to Paul Eggert for this test. */
1993-10-16 06:51:22 +08:00
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#ifdef HAVE_UNISTD_H
# include <unistd.h>
1993-10-16 06:51:22 +08:00
#endif
#ifdef HAVE_VFORK_H
# include <vfork.h>
1993-10-16 06:51:22 +08:00
#endif
1995-03-07 08:19:27 +08:00
/* On some sparc systems, changes by the child to local and incoming
argument registers are propagated back to the parent.
The compiler is told about this with #include <vfork.h>,
but some compilers (e.g. gcc -O) don't grok <vfork.h>.
Test for this by using a static variable whose address
is put into a register that is clobbered by the vfork. */
static
#ifdef __cplusplus
sparc_address_test (int arg)
# else
sparc_address_test (arg) int arg;
#endif
{
static pid_t child;
if (!child) {
child = vfork ();
1996-11-14 08:42:10 +08:00
if (child < 0) {
perror ("vfork");
1996-11-14 08:42:10 +08:00
_exit(2);
}
if (!child) {
arg = getpid();
write(-1, "", 0);
_exit (arg);
}
}
}
int
main ()
{
1993-10-16 06:51:22 +08:00
pid_t parent = getpid ();
pid_t child;
sparc_address_test ();
1993-10-16 06:51:22 +08:00
child = vfork ();
if (child == 0) {
/* Here is another test for sparc vfork register problems.
This test uses lots of local variables, at least
1993-10-16 06:51:22 +08:00
as many local variables as main has allocated so far
including compiler temporaries. 4 locals are enough for
1995-03-07 08:19:27 +08:00
gcc 1.40.3 on a Solaris 4.1.3 sparc, but we use 8 to be safe.
1993-10-16 06:51:22 +08:00
A buggy compiler should reuse the register of parent
for one of the local variables, since it will think that
parent can't possibly be used any more in this routine.
Assigning to the local variable will thus munge parent
in the parent process. */
pid_t
p = getpid(), p1 = getpid(), p2 = getpid(), p3 = getpid(),
p4 = getpid(), p5 = getpid(), p6 = getpid(), p7 = getpid();
/* Convince the compiler that p..p7 are live; otherwise, it might
use the same hardware register for all 8 local variables. */
if (p != p1 || p != p2 || p != p3 || p != p4
|| p != p5 || p != p6 || p != p7)
_exit(1);
/* On some systems (e.g. IRIX 3.3),
vfork doesn't separate parent from child file descriptors.
If the child closes a descriptor before it execs or exits,
this munges the parent's descriptor as well.
Test for this by closing stdout in the child. */
_exit(close(fileno(stdout)) != 0);
} else {
int status;
struct stat st;
while (wait(&status) != child)
;
exit(
/* Was there some problem with vforking? */
child < 0
/* Did the child fail? (This shouldn't happen.) */
|| status
/* Did the vfork/compiler bug occur? */
|| parent != getpid()
/* Did the file descriptor bug occur? */
|| fstat(fileno(stdout), &st) != 0
);
}
1995-11-23 01:42:19 +08:00
}],
ac_cv_func_vfork_works=yes, ac_cv_func_vfork_works=no, AC_CHECK_FUNC(vfork)
ac_cv_func_vfork_works=$ac_cv_func_vfork)])
if test "x$ac_cv_func_vfork_works" = xno; then
1999-10-30 22:17:20 +08:00
AC_DEFINE(vfork, fork, [Define as `fork' if `vfork' does not work.])
fi
])dnl AC_FUNC_VFORK
dnl AC_FUNC_WAIT3
dnl -------------
1994-08-13 10:19:11 +08:00
AC_DEFUN(AC_FUNC_WAIT3,
1996-11-12 12:48:04 +08:00
[AC_CACHE_CHECK(for wait3 that fills in rusage, ac_cv_func_wait3_rusage,
[AC_TRY_RUN(
[#include <sys/types.h>
1993-10-16 06:51:22 +08:00
#include <sys/time.h>
#include <sys/resource.h>
#include <stdio.h>
/* HP-UX has wait3 but does not fill in rusage at all. */
int
main()
{
1993-10-16 06:51:22 +08:00
struct rusage r;
int i;
/* Use a field that we can force nonzero --
voluntary context switches.
For systems like NeXT and OSF/1 that don't set it,
1995-02-07 07:31:34 +08:00
also use the system CPU time. And page faults (I/O) for Linux. */
1993-10-16 06:51:22 +08:00
r.ru_nvcsw = 0;
r.ru_stime.tv_sec = 0;
r.ru_stime.tv_usec = 0;
1995-02-07 07:31:34 +08:00
r.ru_majflt = r.ru_minflt = 0;
1993-10-16 06:51:22 +08:00
switch (fork()) {
case 0: /* Child. */
sleep(1); /* Give up the CPU. */
_exit(0);
case -1: _exit(0); /* What can we do? */
default: /* Parent. */
wait3(&i, 0, &r);
1995-02-08 06:41:14 +08:00
sleep(2); /* Avoid "text file busy" from rm on fast HP-UX machines. */
1995-02-07 07:31:34 +08:00
exit(r.ru_nvcsw == 0 && r.ru_majflt == 0 && r.ru_minflt == 0
1993-10-16 06:51:22 +08:00
&& r.ru_stime.tv_sec == 0 && r.ru_stime.tv_usec == 0);
}
1996-11-12 12:48:04 +08:00
}], ac_cv_func_wait3_rusage=yes, ac_cv_func_wait3_rusage=no,
ac_cv_func_wait3_rusage=no)])
if test $ac_cv_func_wait3_rusage = yes; then
1999-10-30 22:17:20 +08:00
AC_DEFINE(HAVE_WAIT3, 1,
[Define if you have the `wait3' system call.])
fi
1999-10-30 22:17:20 +08:00
])dnl AC_FUNC_WAIT3
dnl AC_FUNC_ALLOCA
dnl --------------
1994-08-13 10:19:11 +08:00
AC_DEFUN(AC_FUNC_ALLOCA,
1994-08-27 09:27:32 +08:00
[AC_REQUIRE_CPP()dnl Set CPP; we run AC_EGREP_CPP conditionally.
# The Ultrix 4.2 mips builtin alloca declared by alloca.h only works
1993-10-16 06:51:22 +08:00
# for constant arguments. Useless!
AC_CACHE_CHECK([for working alloca.h], ac_cv_working_alloca_h,
[AC_TRY_LINK([#include <alloca.h>], [char *p = alloca(2 * sizeof(int));],
ac_cv_working_alloca_h=yes, ac_cv_working_alloca_h=no)])
if test $ac_cv_working_alloca_h = yes; then
1999-10-30 22:17:20 +08:00
AC_DEFINE(HAVE_ALLOCA_H, 1,
[Define if you have <alloca.h> and it should be used
(not on Ultrix).])
fi
1996-11-12 12:48:04 +08:00
AC_CACHE_CHECK([for alloca], ac_cv_func_alloca_works,
2000-01-28 18:44:30 +08:00
[AC_TRY_LINK(
[#ifdef __GNUC__
1994-08-26 10:47:25 +08:00
# define alloca __builtin_alloca
1993-10-16 06:51:22 +08:00
#else
# ifdef _MSC_VER
# include <malloc.h>
# define alloca _alloca
1994-08-26 10:47:25 +08:00
# else
# if HAVE_ALLOCA_H
# include <alloca.h>
1994-08-26 10:47:25 +08:00
# else
# ifdef _AIX
#pragma alloca
# else
# ifndef alloca /* predefined by HP cc +Olibcalls */
1993-10-16 06:51:22 +08:00
char *alloca ();
# endif
1994-08-26 10:47:25 +08:00
# endif
# endif
# endif
1994-06-23 02:22:34 +08:00
#endif
], [char *p = (char *) alloca(1);],
1996-11-12 12:48:04 +08:00
ac_cv_func_alloca_works=yes, ac_cv_func_alloca_works=no)])
if test $ac_cv_func_alloca_works = yes; then
1999-10-30 22:17:20 +08:00
AC_DEFINE(HAVE_ALLOCA, 1,
[Define if you have `alloca', as a function or macro.])
fi
1996-11-12 12:48:04 +08:00
if test $ac_cv_func_alloca_works = no; then
1993-10-16 06:51:22 +08:00
# The SVR3 libPW and SVR4 libucb both contain incompatible functions
# that cause trouble. Some versions do not even contain alloca or
# contain a buggy version. If you still want to use their alloca,
# use ar to extract alloca.o from them instead of compiling alloca.c.
ALLOCA=alloca.${ac_objext}
1999-10-30 22:17:20 +08:00
AC_DEFINE(C_ALLOCA, 1, [Define if using `alloca.c'.])
1993-10-16 06:51:22 +08:00
1995-06-29 04:19:08 +08:00
AC_CACHE_CHECK(whether alloca needs Cray hooks, ac_cv_os_cray,
1994-08-11 00:47:42 +08:00
[AC_EGREP_CPP(webecray,
[#if defined(CRAY) && ! defined(CRAY2)
webecray
#else
wenotbecray
#endif
1995-06-29 04:19:08 +08:00
], ac_cv_os_cray=yes, ac_cv_os_cray=no)])
1994-08-11 00:47:42 +08:00
if test $ac_cv_os_cray = yes; then
for ac_func in _getb67 GETB67 getb67; do
1999-10-30 22:17:20 +08:00
AC_CHECK_FUNC($ac_func,
[AC_DEFINE_UNQUOTED(CRAY_STACKSEG_END, $ac_func,
[Define to one of _getb67, GETB67, getb67
for Cray-2 and Cray-YMP systems.
This function is required for alloca.c
support on those systems.])
break])
1995-03-07 09:27:46 +08:00
done
1994-08-11 00:47:42 +08:00
fi
1995-06-29 04:19:08 +08:00
AC_CACHE_CHECK(stack direction for C alloca, ac_cv_c_stack_direction,
[AC_TRY_RUN([find_stack_direction ()
1993-10-16 06:51:22 +08:00
{
static char *addr = 0;
auto char dummy;
if (addr == 0)
{
addr = &dummy;
return find_stack_direction ();
}
else
return (&dummy > addr) ? 1 : -1;
}
int
1993-10-16 06:51:22 +08:00
main ()
{
exit (find_stack_direction() < 0);
}], ac_cv_c_stack_direction=1, ac_cv_c_stack_direction=-1,
1995-06-29 04:19:08 +08:00
ac_cv_c_stack_direction=0)])
1994-07-25 11:33:46 +08:00
AC_DEFINE_UNQUOTED(STACK_DIRECTION, $ac_cv_c_stack_direction)
1993-10-16 06:51:22 +08:00
fi
AC_SUBST(ALLOCA)dnl
1999-10-30 22:17:20 +08:00
])dnl AC_FUNC_ALLOCA
dnl AC_FUNC_GETLOADAVG
dnl ------------------
1994-08-13 10:19:11 +08:00
AC_DEFUN(AC_FUNC_GETLOADAVG,
1995-02-22 04:39:40 +08:00
[ac_have_func=no # yes means we've found a way to get the load average.
1993-10-16 06:51:22 +08:00
1994-02-06 02:35:44 +08:00
# Some systems with -lutil have (and need) -lkvm as well, some do not.
1995-02-22 04:39:40 +08:00
# On Solaris, -lkvm requires nlist from -lelf, so check that first
# to get the right answer into the cache.
AC_CHECK_LIB(elf, elf_begin, LIBS="-lelf $LIBS")
AC_CHECK_LIB(kvm, kvm_open, LIBS="-lkvm $LIBS")
AC_CHECK_LIB(kstat, kstat_open)
# Check for the 4.4BSD definition of getloadavg.
1995-02-08 06:41:14 +08:00
AC_CHECK_LIB(util, getloadavg,
[LIBS="-lutil $LIBS" ac_have_func=yes ac_cv_func_getloadavg_setgid=yes])
1993-10-16 06:51:22 +08:00
if test $ac_have_func = no; then
1995-02-22 04:39:40 +08:00
# There is a commonly available library for RS/6000 AIX.
# Since it is not a standard part of AIX, it might be installed locally.
1996-12-11 08:49:47 +08:00
ac_getloadavg_LIBS="$LIBS"; LIBS="-L/usr/local/lib $LIBS"
1995-02-22 04:39:40 +08:00
AC_CHECK_LIB(getloadavg, getloadavg,
1996-11-12 12:48:04 +08:00
LIBS="-lgetloadavg $LIBS", LIBS="$ac_getloadavg_LIBS")
1993-10-16 06:51:22 +08:00
fi
# Make sure it is really in the library, if we think we found it.
1993-10-16 06:51:22 +08:00
AC_REPLACE_FUNCS(getloadavg)
if test $ac_cv_func_getloadavg = yes; then
1999-10-30 22:17:20 +08:00
AC_DEFINE(HAVE_GETLOADAVG, 1,
[Define if your system has its own `getloadavg' function.])
1995-02-22 04:39:40 +08:00
ac_have_func=yes
else
1995-02-22 04:39:40 +08:00
# Figure out what our getloadavg.c needs.
ac_have_func=no
AC_CHECK_HEADER(sys/dg_sys_info.h,
1999-10-30 22:17:20 +08:00
[ac_have_func=yes;
AC_DEFINE(DGUX, 1, [Define for DGUX with <sys/dg_sys_info.h>.])
AC_CHECK_LIB(dgc, dg_sys_info)])
1995-02-22 04:39:40 +08:00
# We cannot check for <dwarf.h>, because Solaris 2 does not use dwarf (it
# uses stabs), but it is still SVR4. We cannot check for <elf.h> because
# Irix 4.0.5F has the header but not the library.
if test $ac_have_func = no && test $ac_cv_lib_elf_elf_begin = yes; then
1999-10-30 22:17:20 +08:00
ac_have_func=yes;
AC_DEFINE(SVR4, 1,
[Define on System V Release 4.])
1995-02-22 04:39:40 +08:00
fi
1993-10-16 06:51:22 +08:00
1995-02-22 04:39:40 +08:00
if test $ac_have_func = no; then
AC_CHECK_HEADER(inq_stats/cpustats.h,
1999-10-30 22:17:20 +08:00
[ac_have_func=yes;
AC_DEFINE(UMAX, 1,
[Define for Encore UMAX.])
AC_DEFINE(UMAX4_3, 1,
[Define for Encore UMAX 4.3 that has <inq_status/cpustats.h>
instead of <sys/cpustats.h>.])])
1995-02-22 04:39:40 +08:00
fi
1993-10-16 06:51:22 +08:00
1995-02-22 04:39:40 +08:00
if test $ac_have_func = no; then
AC_CHECK_HEADER(sys/cpustats.h,
[ac_have_func=yes; AC_DEFINE(UMAX)])
fi
if test $ac_have_func = no; then
AC_CHECK_HEADERS(mach/mach.h)
fi
AC_CHECK_HEADER(nlist.h,
1999-10-30 22:17:20 +08:00
[AC_DEFINE(NLIST_STRUCT, 1, [Define if you have <nlist.h>.])
1995-06-29 04:19:08 +08:00
AC_CACHE_CHECK([for n_un in struct nlist], ac_cv_struct_nlist_n_un,
[AC_TRY_COMPILE([#include <nlist.h>
],
[struct nlist n; n.n_un.n_name = 0;],
ac_cv_struct_nlist_n_un=yes, ac_cv_struct_nlist_n_un=no)])
1995-02-22 04:39:40 +08:00
if test $ac_cv_struct_nlist_n_un = yes; then
1999-10-30 22:17:20 +08:00
AC_DEFINE(NLIST_NAME_UNION, 1,
[Define if your `struct nlist' has an `n_un' member.])
1995-02-22 04:39:40 +08:00
fi
])dnl
1995-02-08 06:41:14 +08:00
fi # Do not have getloadavg in system libraries.
# Some definitions of getloadavg require that the program be installed setgid.
dnl FIXME Don't hardwire the path of getloadavg.c in the top-level directory.
1995-06-29 04:19:08 +08:00
AC_CACHE_CHECK(whether getloadavg requires setgid,
ac_cv_func_getloadavg_setgid,
[AC_EGREP_CPP([Yowza Am I SETGID yet],
[#include "$srcdir/getloadavg.c"
1993-10-16 06:51:22 +08:00
#ifdef LDAV_PRIVILEGED
Yowza Am I SETGID yet
#endif],
1995-06-29 04:19:08 +08:00
ac_cv_func_getloadavg_setgid=yes, ac_cv_func_getloadavg_setgid=no)])
if test $ac_cv_func_getloadavg_setgid = yes; then
1999-10-30 22:17:20 +08:00
NEED_SETGID=true;
AC_DEFINE(GETLOADAVG_PRIVILEGED, 1,
[Define if the `getloadavg' function needs to be run setuid
or setgid.])
1995-02-08 06:41:14 +08:00
else
NEED_SETGID=false
fi
1995-02-08 06:41:14 +08:00
AC_SUBST(NEED_SETGID)dnl
1993-10-16 06:51:22 +08:00
1995-02-08 06:41:14 +08:00
if test $ac_cv_func_getloadavg_setgid = yes; then
1995-06-29 04:19:08 +08:00
AC_CACHE_CHECK(group of /dev/kmem, ac_cv_group_kmem,
[changequote(, )dnl
1993-10-16 06:51:22 +08:00
# On Solaris, /dev/kmem is a symlink. Get info on the real file.
ac_ls_output=`ls -lgL /dev/kmem 2>/dev/null`
1993-10-16 06:51:22 +08:00
# If we got an error (system does not support symlinks), try without -L.
test -z "$ac_ls_output" && ac_ls_output=`ls -lg /dev/kmem`
ac_cv_group_kmem=`echo $ac_ls_output \
1993-10-16 06:51:22 +08:00
| sed -ne 's/[ ][ ]*/ /g;
s/^.[sSrwx-]* *[0-9]* *\([^0-9]*\) *.*/\1/;
/ /s/.* //;p;'`
changequote([, ])dnl
1995-06-29 04:19:08 +08:00
])
KMEM_GROUP=$ac_cv_group_kmem
1993-10-16 06:51:22 +08:00
fi
AC_SUBST(KMEM_GROUP)dnl
])dnl AC_FUNC_GETLOADAVG
dnl AC_FUNC_UTIME_NULL
dnl ------------------
1994-08-13 10:19:11 +08:00
AC_DEFUN(AC_FUNC_UTIME_NULL,
1995-06-29 04:19:08 +08:00
[AC_CACHE_CHECK(whether utime accepts a null argument, ac_cv_func_utime_null,
[rm -f conftestdata; >conftestdata
1993-10-16 06:51:22 +08:00
# Sequent interprets utime(file, 0) to mean use start of epoch. Wrong.
AC_TRY_RUN(
[#include <sys/types.h>
1993-10-16 06:51:22 +08:00
#include <sys/stat.h>
int
main()
{
struct stat s, t;
exit (!(stat ("conftestdata", &s) == 0
&& utime ("conftestdata", (long *)0) == 0
&& stat ("conftestdata", &t) == 0
&& t.st_mtime >= s.st_mtime
&& t.st_mtime - s.st_mtime < 120));
1994-09-06 04:12:21 +08:00
}], ac_cv_func_utime_null=yes, ac_cv_func_utime_null=no,
ac_cv_func_utime_null=no)
1995-06-29 04:19:08 +08:00
rm -f core core.* *.core])
if test $ac_cv_func_utime_null = yes; then
1999-10-30 22:17:20 +08:00
AC_DEFINE(HAVE_UTIME_NULL, 1,
[Define if `utime(file, NULL)' sets file's timestamp to the
present.])
fi
])dnl AC_FUNC_UTIME_NULL
dnl AC_FUNC_STRCOLL
dnl ---------------
1994-08-13 10:19:11 +08:00
AC_DEFUN(AC_FUNC_STRCOLL,
1996-11-18 23:28:02 +08:00
[AC_CACHE_CHECK(for working strcoll, ac_cv_func_strcoll_works,
[AC_TRY_RUN([#include <string.h>
int
1993-10-16 06:51:22 +08:00
main ()
{
exit (strcoll ("abc", "def") >= 0 ||
strcoll ("ABC", "DEF") >= 0 ||
strcoll ("123", "456") >= 0);
1996-11-12 12:48:04 +08:00
}], ac_cv_func_strcoll_works=yes, ac_cv_func_strcoll_works=no,
ac_cv_func_strcoll_works=no)])
if test $ac_cv_func_strcoll_works = yes; then
1999-10-30 22:17:20 +08:00
AC_DEFINE(HAVE_STRCOLL, 1,
[Define if you have the `strcoll' function and it is properly
defined.])
fi
])dnl AC_FUNC_STRCOLL
dnl AC_FUNC_SETVBUF_REVERSED
dnl ------------------------
1994-08-13 10:19:11 +08:00
AC_DEFUN(AC_FUNC_SETVBUF_REVERSED,
1995-06-29 04:19:08 +08:00
[AC_CACHE_CHECK(whether setvbuf arguments are reversed,
ac_cv_func_setvbuf_reversed,
[AC_TRY_RUN([#include <stdio.h>
1993-10-16 06:51:22 +08:00
/* If setvbuf has the reversed format, exit 0. */
int
main ()
{
1993-10-16 06:51:22 +08:00
/* This call has the arguments reversed.
A reversed system may check and see that the address of main
is not _IOLBF, _IONBF, or _IOFBF, and return nonzero. */
if (setvbuf(stdout, _IOLBF, (char *) main, BUFSIZ) != 0)
exit(1);
putc('\r', stdout);
exit(0); /* Non-reversed systems segv here. */
}], ac_cv_func_setvbuf_reversed=yes, ac_cv_func_setvbuf_reversed=no)
1995-06-29 04:19:08 +08:00
rm -f core core.* *.core])
if test $ac_cv_func_setvbuf_reversed = yes; then
1999-10-30 22:17:20 +08:00
AC_DEFINE(SETVBUF_REVERSED, 1,
[Define if the `setvbuf' function takes the buffering type as
its second argument and the buffer pointer as the third, as on
System V before release 3.])
fi
])dnl AC_FUNC_SETVBUF_REVERSED
dnl AC_FUNC_GETMNTENT
dnl -----------------
1994-09-09 04:42:23 +08:00
AC_DEFUN(AC_FUNC_GETMNTENT,
1995-07-26 13:30:39 +08:00
[# getmntent is in -lsun on Irix 4, -lseq on Dynix/PTX, -lgen on Unixware.
1995-02-08 06:41:14 +08:00
AC_CHECK_LIB(sun, getmntent, LIBS="-lsun $LIBS",
1995-07-26 13:30:39 +08:00
[AC_CHECK_LIB(seq, getmntent, LIBS="-lseq $LIBS",
[AC_CHECK_LIB(gen, getmntent, LIBS="-lgen $LIBS")])])
1999-10-30 22:17:20 +08:00
AC_CHECK_FUNC(getmntent,
[AC_DEFINE(HAVE_GETMNTENT, 1,
[Define if you have the `getmntent' function.])])])
1994-09-09 04:42:23 +08:00
dnl AC_FUNC_MKTIME
dnl --------------
AC_DEFUN(AC_FUNC_MKTIME,
[AC_REQUIRE([AC_HEADER_TIME])dnl
AC_CHECK_HEADERS(sys/time.h unistd.h)
AC_CHECK_FUNCS(alarm)
AC_CACHE_CHECK([for working mktime], ac_cv_func_working_mktime,
[AC_TRY_RUN(
changequote(<<, >>)dnl
<</* Test program from Paul Eggert (eggert@twinsun.com)
and Tony Leneis (tony@plaza.ds.adp.com). */
#if TIME_WITH_SYS_TIME
# include <sys/time.h>
# include <time.h>
#else
# if HAVE_SYS_TIME_H
# include <sys/time.h>
# else
# include <time.h>
# endif
#endif
#if HAVE_UNISTD_H
# include <unistd.h>
#endif
#if !HAVE_ALARM
# define alarm(X) /* empty */
#endif
/* Work around redefinition to rpl_putenv by other config tests. */
#undef putenv
static time_t time_t_max;
/* Values we'll use to set the TZ environment variable. */
static const char *const tz_strings[] = {
(const char *) 0, "TZ=GMT0", "TZ=JST-9",
"TZ=EST+3EDT+2,M10.1.0/00:00:00,M2.3.0/00:00:00"
};
#define N_STRINGS (sizeof (tz_strings) / sizeof (tz_strings[0]))
/* Fail if mktime fails to convert a date in the spring-forward gap.
Based on a problem report from Andreas Jaeger. */
static void
spring_forward_gap ()
{
/* glibc (up to about 1998-10-07) failed this test) */
struct tm tm;
/* Use the portable POSIX.1 specification "TZ=PST8PDT,M4.1.0,M10.5.0"
instead of "TZ=America/Vancouver" in order to detect the bug even
on systems that don't support the Olson extension, or don't have the
full zoneinfo tables installed. */
putenv ("TZ=PST8PDT,M4.1.0,M10.5.0");
tm.tm_year = 98;
tm.tm_mon = 3;
tm.tm_mday = 5;
tm.tm_hour = 2;
tm.tm_min = 0;
tm.tm_sec = 0;
tm.tm_isdst = -1;
if (mktime (&tm) == (time_t)-1)
exit (1);
}
static void
mktime_test (now)
time_t now;
{
struct tm *lt;
if ((lt = localtime (&now)) && mktime (lt) != now)
exit (1);
now = time_t_max - now;
if ((lt = localtime (&now)) && mktime (lt) != now)
exit (1);
}
static void
irix_6_4_bug ()
{
/* Based on code from Ariel Faigon. */
struct tm tm;
tm.tm_year = 96;
tm.tm_mon = 3;
tm.tm_mday = 0;
tm.tm_hour = 0;
tm.tm_min = 0;
tm.tm_sec = 0;
tm.tm_isdst = -1;
mktime (&tm);
if (tm.tm_mon != 2 || tm.tm_mday != 31)
exit (1);
}
static void
bigtime_test (j)
int j;
{
struct tm tm;
time_t now;
tm.tm_year = tm.tm_mon = tm.tm_mday = tm.tm_hour = tm.tm_min = tm.tm_sec = j;
now = mktime (&tm);
if (now != (time_t) -1)
{
struct tm *lt = localtime (&now);
if (! (lt
&& lt->tm_year == tm.tm_year
&& lt->tm_mon == tm.tm_mon
&& lt->tm_mday == tm.tm_mday
&& lt->tm_hour == tm.tm_hour
&& lt->tm_min == tm.tm_min
&& lt->tm_sec == tm.tm_sec
&& lt->tm_yday == tm.tm_yday
&& lt->tm_wday == tm.tm_wday
&& ((lt->tm_isdst < 0 ? -1 : 0 < lt->tm_isdst)
== (tm.tm_isdst < 0 ? -1 : 0 < tm.tm_isdst))))
exit (1);
}
}
int
main ()
{
time_t t, delta;
int i, j;
/* This test makes some buggy mktime implementations loop.
Give up after 60 seconds; a mktime slower than that
isn't worth using anyway. */
alarm (60);
for (time_t_max = 1; 0 < time_t_max; time_t_max *= 2)
continue;
time_t_max--;
delta = time_t_max / 997; /* a suitable prime number */
for (i = 0; i < N_STRINGS; i++)
{
if (tz_strings[i])
putenv (tz_strings[i]);
for (t = 0; t <= time_t_max - delta; t += delta)
mktime_test (t);
mktime_test ((time_t) 60 * 60);
mktime_test ((time_t) 60 * 60 * 24);
for (j = 1; 0 < j; j *= 2)
bigtime_test (j);
bigtime_test (j - 1);
}
irix_6_4_bug ();
spring_forward_gap ();
exit (0);
}>>,
changequote([, ])dnl
ac_cv_func_working_mktime=yes, ac_cv_func_working_mktime=no,
ac_cv_func_working_mktime=no)])
if test $ac_cv_func_working_mktime = no; then
LIBOBJS="$LIBOBJS mktime.${ac_objext}"
fi
])dnl AC_FUNC_MKTIME
dnl AC_FUNC_STRFTIME
dnl ----------------
1994-09-09 04:42:23 +08:00
AC_DEFUN(AC_FUNC_STRFTIME,
1999-10-30 22:17:20 +08:00
[AC_CHECK_FUNC(strftime,
[AC_DEFINE(HAVE_STRFTIME, 1,
[Define if you have the `strftime' function.])],
1994-09-09 04:42:23 +08:00
[# strftime is in -lintl on SCO UNIX.
1999-10-30 22:17:20 +08:00
AC_CHECK_LIB(intl, strftime,
[AC_DEFINE(HAVE_STRFTIME, 1,
[Define if you have the `strftime' function.])
LIBS="-lintl $LIBS"])])dnl
])dnl AC_FUNC_STRFTIME
1994-09-09 04:42:23 +08:00
dnl AC_FUNC_MEMCMP
dnl --------------
1994-09-10 04:13:30 +08:00
AC_DEFUN(AC_FUNC_MEMCMP,
1996-11-12 12:48:04 +08:00
[AC_CACHE_CHECK(for 8-bit clean memcmp, ac_cv_func_memcmp_clean,
[AC_TRY_RUN(
[int
1994-09-10 04:13:30 +08:00
main()
{
char c0 = 0x40, c1 = 0x80, c2 = 0x81;
exit (memcmp(&c0, &c2, 1) < 0
&& memcmp(&c1, &c2, 1) < 0 ? 0 : 1);
}], ac_cv_func_memcmp_clean=yes, ac_cv_func_memcmp_clean=no,
1996-11-12 12:48:04 +08:00
ac_cv_func_memcmp_clean=no)])
test $ac_cv_func_memcmp_clean = no && LIBOBJS="$LIBOBJS memcmp.${ac_objext}"
1994-09-10 04:13:30 +08:00
AC_SUBST(LIBOBJS)dnl
])dnl AC_FUNC_MEMCMP
dnl AC_FUNC_SELECT_ARGTYPES
dnl -----------------------
AC_DEFUN(AC_FUNC_SELECT_ARGTYPES,
[AC_MSG_CHECKING([types of arguments for select()])
AC_CACHE_VAL(ac_cv_func_select_arg234,dnl
[AC_CACHE_VAL(ac_cv_func_select_arg1,dnl
[AC_CACHE_VAL(ac_cv_func_select_arg5,dnl
[for ac_cv_func_select_arg234 in 'fd_set *' 'int *' 'void *'; do
for ac_cv_func_select_arg1 in 'int' 'size_t' 'unsigned long' 'unsigned'; do
for ac_cv_func_select_arg5 in 'struct timeval *' 'const struct timeval *'; do
AC_TRY_COMPILE(dnl
[#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
#ifdef HAVE_SYS_TIME_H
#include <sys/time.h>
#endif
#ifdef HAVE_SYS_SELECT_H
#include <sys/select.h>
#endif
#ifdef HAVE_SYS_SOCKET_H
#include <sys/socket.h>
#endif
extern select ($ac_cv_func_select_arg1,$ac_cv_func_select_arg234,$ac_cv_func_select_arg234,$ac_cv_func_select_arg234,$ac_cv_func_select_arg5);],,dnl
[ac_not_found=no ; break 3],ac_not_found=yes)
done
done
done
])dnl AC_CACHE_VAL
])dnl AC_CACHE_VAL
])dnl AC_CACHE_VAL
if test "$ac_not_found" = yes; then
1999-10-30 22:17:20 +08:00
ac_cv_func_select_arg1=int
ac_cv_func_select_arg234='int *'
ac_cv_func_select_arg5='struct timeval *'
fi
AC_MSG_RESULT([$ac_cv_func_select_arg1,$ac_cv_func_select_arg234,$ac_cv_func_select_arg5])
1999-10-30 22:17:20 +08:00
AC_DEFINE_UNQUOTED(SELECT_TYPE_ARG1, $ac_cv_func_select_arg1,
[Define to the type of arg1 for `select'.])
AC_DEFINE_UNQUOTED(SELECT_TYPE_ARG234, ($ac_cv_func_select_arg234),
[Define to the type of args 2, 3 and 4 for `select'.])
AC_DEFINE_UNQUOTED(SELECT_TYPE_ARG5, ($ac_cv_func_select_arg5),
[Define to the type of arg5 for `select'.])
])dnl AC_FUNC_SELECT_ARGTYPES
1994-09-10 04:16:17 +08:00
dnl ### Checks for structure members
dnl AC_HEADER_TIME
dnl --------------
1994-08-13 10:19:11 +08:00
AC_DEFUN(AC_HEADER_TIME,
1995-06-29 04:19:08 +08:00
[AC_CACHE_CHECK([whether time.h and sys/time.h may both be included],
ac_cv_header_time,
1994-10-23 10:08:04 +08:00
[AC_TRY_COMPILE([#include <sys/types.h>
1993-10-16 06:51:22 +08:00
#include <sys/time.h>
#include <time.h>
],
1995-06-29 04:19:08 +08:00
[struct tm *tp;], ac_cv_header_time=yes, ac_cv_header_time=no)])
if test $ac_cv_header_time = yes; then
1999-10-30 22:17:20 +08:00
AC_DEFINE(TIME_WITH_SYS_TIME, 1,
[Define if you can safely include both <sys/time.h> and <time.h>.])
fi
])dnl AC_HEADER_TIME
dnl AC_STRUCT_TM
dnl ------------
dnl FIXME: This macro is badly named, it should be AC_CHECK_TYPE_STRUCT_TM.
dnl Or something else, but what? AC_CHECK_TYPE_STRUCT_TM_IN_SYS_TIME?
1994-08-29 08:08:38 +08:00
AC_DEFUN(AC_STRUCT_TM,
1995-06-29 04:19:08 +08:00
[AC_CACHE_CHECK([whether struct tm is in sys/time.h or time.h],
ac_cv_struct_tm,
1994-10-23 10:08:04 +08:00
[AC_TRY_COMPILE([#include <sys/types.h>
#include <time.h>
],
1994-08-29 08:08:38 +08:00
[struct tm *tp; tp->tm_sec;],
1995-06-29 04:19:08 +08:00
ac_cv_struct_tm=time.h, ac_cv_struct_tm=sys/time.h)])
1994-08-29 08:08:38 +08:00
if test $ac_cv_struct_tm = sys/time.h; then
1999-10-30 22:17:20 +08:00
AC_DEFINE(TM_IN_SYS_TIME, 1,
[Define if your <sys/time.h> declares `struct tm'.])
1994-08-29 08:08:38 +08:00
fi
])dnl AC_STRUCT_TM
dnl AC_STRUCT_TIMEZONE
dnl ------------------
1994-08-13 10:19:11 +08:00
AC_DEFUN(AC_STRUCT_TIMEZONE,
[AC_REQUIRE([AC_STRUCT_TM])dnl
AC_CHECK_MEMBERS((struct tm.tm_zone),,,[#include <sys/types.h>
#include <$ac_cv_struct_tm>
])
if test "$ac_cv_member_struct_tm_tm_zone" = yes; then
1999-10-30 22:17:20 +08:00
AC_DEFINE(HAVE_TM_ZONE, 1,
[Define if your `struct tm' has `tm_zone'. Deprecated, use
`HAVE_STRUCT_TM_TM_ZONE' instead.])
else
1995-06-29 04:19:08 +08:00
AC_CACHE_CHECK(for tzname, ac_cv_var_tzname,
[AC_TRY_LINK(
changequote(<<, >>)dnl
1993-10-16 06:51:22 +08:00
<<#include <time.h>
#ifndef tzname /* For SGI. */
extern char *tzname[]; /* RS6000 and others reject char **tzname. */
#endif>>,
changequote([, ])dnl
1995-06-29 04:19:08 +08:00
[atoi(*tzname);], ac_cv_var_tzname=yes, ac_cv_var_tzname=no)])
if test $ac_cv_var_tzname = yes; then
1999-10-30 22:17:20 +08:00
AC_DEFINE(HAVE_TZNAME, 1,
[Define if you don't have `tm_zone' but do have the external
array `tzname'.])
fi
1993-10-16 06:51:22 +08:00
fi
])dnl AC_STRUCT_TIMEZONE
dnl FIXME: The following three macros should no longer be supported in the
dnl future. They made sense when there was no means to directly check for
dnl members of aggregates. In the future, they will be remove, that's why
dnl they are obsoleted.
dnl AC_STRUCT_ST_BLKSIZE
dnl --------------------
1999-10-30 22:17:20 +08:00
AC_DEFUN(AC_STRUCT_ST_BLKSIZE,
[AC_OBSOLETE([$0], [; replace it with
AC_CHECK_MEMBERS((struct stat.st_blksize))
Please note that it will define `HAVE_STRUCT_STAT_ST_BLKSIZE',
and not `HAVE_ST_BLKSIZE'.])dnl
AC_CHECK_MEMBERS((struct stat.st_blksize),
[AC_DEFINE(HAVE_ST_BLKSIZE, 1,
[Define if your `struct stat' has
`st_blksize'. Deprecated, use
`HAVE_STRUCT_STAT_ST_BLKSIZE' instead.])],,
[#include <sys/types.h>
#include <sys/stat.h>
])dnl
])dnl AC_STRUCT_ST_BLKSIZE
1999-10-30 22:17:20 +08:00
dnl AC_STRUCT_ST_BLOCKS
dnl -------------------
dnl If `struct stat' contains an `st_blocks' member, define
dnl HAVE_STRUCT_STAT_ST_BLOCKS. Otherwise, add `fileblocks.o' to the
dnl output variable LIBOBJS. We still define HAVE_ST_BLOCKS for backward
dnl compatibility. In the future, we will activate specializations for
dnl this macro, so don't obsolete it right now.
dnl
dnl AC_OBSOLETE([$0], [; replace it with
dnl AC_CHECK_MEMBERS((struct stat.st_blocks), LIBOBJS="$LIBOBJS fileblocks.${ac_objext}")
dnl Please note that it will define `HAVE_STRUCT_STAT_ST_BLOCKS',
dnl and not `HAVE_ST_BLOCKS'.])dnl
dnl
1994-08-13 10:19:11 +08:00
AC_DEFUN(AC_STRUCT_ST_BLOCKS,
[AC_CHECK_MEMBERS((struct stat.st_blocks),
[AC_DEFINE(HAVE_ST_BLOCKS, 1,
[Define if your `struct stat' has
`st_blocks'. Deprecated, use
`HAVE_STRUCT_STAT_ST_BLOCKS' instead.])],
[LIBOBJS="$LIBOBJS fileblocks.${ac_objext}"
AC_SUBST(LIBOBJS)],
[#include <sys/types.h>
#include <sys/stat.h>
])dnl
])dnl AC_STRUCT_ST_BLOCKS
dnl AC_STRUCT_ST_RDEV
dnl -----------------
1994-08-13 10:19:11 +08:00
AC_DEFUN(AC_STRUCT_ST_RDEV,
[AC_OBSOLETE([$0], [; replace it with
AC_CHECK_MEMBERS((struct stat.st_rdev))
Please note that it will define `HAVE_STRUCT_STAT_ST_RDEV',
and not `HAVE_ST_RDEV'.])dnl
AC_CHECK_MEMBERS((struct stat.st_rdev),
[AC_DEFINE(HAVE_ST_RDEV, 1,
[Define if your `struct stat' has `st_rdev'.
Deprecated, use
`HAVE_STRUCT_STAT_ST_RDEV' instead.])],,
[#include <sys/types.h>
#include <sys/stat.h>
])dnl
])dnl AC_STRUCT_ST_RDEV
dnl ### Checks for compiler characteristics
1994-08-13 10:19:11 +08:00
AC_DEFUN(AC_C_CROSS,
[AC_OBSOLETE([$0], [; it has been merged into AC_PROG_CC])])
dnl AC_C_CHAR_UNSIGNED
dnl ------------------
1994-08-13 10:19:11 +08:00
AC_DEFUN(AC_C_CHAR_UNSIGNED,
1995-06-29 04:19:08 +08:00
[AC_CACHE_CHECK(whether char is unsigned, ac_cv_c_char_unsigned,
1994-09-10 04:13:30 +08:00
[if test "$GCC" = yes; then
# GCC predefines this symbol on systems where it applies.
AC_EGREP_CPP(yes,
[#ifdef __CHAR_UNSIGNED__
yes
#endif
], ac_cv_c_char_unsigned=yes, ac_cv_c_char_unsigned=no)
else
AC_TRY_RUN(
1993-10-16 06:51:22 +08:00
[/* volatile prevents gcc2 from optimizing the test away on sparcs. */
1994-09-10 04:13:30 +08:00
#if !defined(__STDC__) || __STDC__ != 1
# define volatile
1993-10-16 06:51:22 +08:00
#endif
int
main()
{
volatile char c = 255;
exit(c < 0);
1994-09-10 04:13:30 +08:00
}], ac_cv_c_char_unsigned=yes, ac_cv_c_char_unsigned=no)
1995-06-29 04:19:08 +08:00
fi])
1994-08-11 08:36:21 +08:00
if test $ac_cv_c_char_unsigned = yes && test "$GCC" != yes; then
AC_DEFINE(__CHAR_UNSIGNED__)
fi
1999-10-30 22:17:20 +08:00
])dnl AC_C_CHAR_UNSIGNED
dnl AC_C_LONG_DOUBLE
dnl ----------------
1994-08-13 10:19:11 +08:00
AC_DEFUN(AC_C_LONG_DOUBLE,
1995-06-29 04:19:08 +08:00
[AC_CACHE_CHECK(for long double, ac_cv_c_long_double,
[if test "$GCC" = yes; then
ac_cv_c_long_double=yes
1993-10-16 06:51:22 +08:00
else
AC_TRY_RUN(
[int
main()
{
/* The Stardent Vistra knows sizeof(long double), but does not
support it. */
long double foo = 0.0;
/* On Ultrix 4.3 cc, long double is 4 and double is 8. */
exit(sizeof(long double) < sizeof(double));
}],
ac_cv_c_long_double=yes, ac_cv_c_long_double=no)
1995-06-29 04:19:08 +08:00
fi])
if test $ac_cv_c_long_double = yes; then
1999-10-30 22:17:20 +08:00
AC_DEFINE(HAVE_LONG_DOUBLE, 1,
[Define if the `long double' type works.])
1993-10-16 06:51:22 +08:00
fi
])dnl AC_C_LONG_DOUBLE
AC_DEFUNCT(AC_INT_16_BITS, [; instead use AC_CHECK_SIZEOF(int)])
AC_DEFUNCT(AC_LONG_64_BITS, [; instead use AC_CHECK_SIZEOF(long)])
dnl AC_C_BIGENDIAN
dnl --------------
1994-08-13 10:19:11 +08:00
AC_DEFUN(AC_C_BIGENDIAN,
1995-06-29 04:19:08 +08:00
[AC_CACHE_CHECK(whether byte ordering is bigendian, ac_cv_c_bigendian,
[ac_cv_c_bigendian=unknown
# See if sys/param.h defines the BYTE_ORDER macro.
AC_TRY_COMPILE([#include <sys/types.h>
#include <sys/param.h>
],
[#if !BYTE_ORDER || !BIG_ENDIAN || !LITTLE_ENDIAN
bogus endian macros
#endif
],
[# It does; now see whether it defined to BIG_ENDIAN or not.
AC_TRY_COMPILE([#include <sys/types.h>
#include <sys/param.h>
], [#if BYTE_ORDER != BIG_ENDIAN
not big endian
#endif
], ac_cv_c_bigendian=yes, ac_cv_c_bigendian=no)])
if test $ac_cv_c_bigendian = unknown; then
AC_TRY_RUN(
[int
main ()
{
1993-10-16 06:51:22 +08:00
/* Are we little or big endian? From Harbison&Steele. */
union
{
long l;
char c[sizeof (long)];
} u;
u.l = 1;
exit (u.c[sizeof (long) - 1] == 1);
}], ac_cv_c_bigendian=no, ac_cv_c_bigendian=yes)
1995-06-29 04:19:08 +08:00
fi])
if test $ac_cv_c_bigendian = yes; then
1999-10-30 22:17:20 +08:00
AC_DEFINE(WORDS_BIGENDIAN, 1,
[Define if your processor stores words with the most significant
byte first (like Motorola and SPARC, unlike Intel and VAX).])
fi
])dnl AC_C_BIGENDIAN
dnl AC_C_INLINE
dnl -----------
1995-02-10 06:44:35 +08:00
dnl Do nothing if the compiler accepts the inline keyword.
dnl Otherwise define inline to __inline__ or __inline if one of those work,
dnl otherwise define inline to be empty.
1994-08-13 10:19:11 +08:00
AC_DEFUN(AC_C_INLINE,
1995-06-29 04:19:08 +08:00
[AC_CACHE_CHECK([for inline], ac_cv_c_inline,
1995-02-10 06:44:35 +08:00
[ac_cv_c_inline=no
for ac_kw in inline __inline__ __inline; do
AC_TRY_COMPILE(, [} $ac_kw int foo() {], [ac_cv_c_inline=$ac_kw; break])
1995-02-10 06:44:35 +08:00
done
1995-06-29 04:19:08 +08:00
])
1995-02-10 06:44:35 +08:00
case "$ac_cv_c_inline" in
inline | yes) ;;
1999-10-30 22:17:20 +08:00
no) AC_DEFINE(inline,,
[Define as `__inline' if that's what the C compiler calls it,
or to nothing if it is not supported.]) ;;
*) AC_DEFINE_UNQUOTED(inline, $ac_cv_c_inline,
[Define as `__inline' if that's what the C compiler
calls it, or to nothing if it is not supported.]) ;;
1995-02-10 06:44:35 +08:00
esac
])dnl AC_C_INLINE
dnl AC_C_CONST
dnl ----------
1994-08-13 10:19:11 +08:00
AC_DEFUN(AC_C_CONST,
1994-08-11 00:47:42 +08:00
[dnl This message is consistent in form with the other checking messages,
dnl and with the result message.
1995-06-29 04:19:08 +08:00
AC_CACHE_CHECK([for working const], ac_cv_c_const,
1994-10-23 10:08:04 +08:00
[AC_TRY_COMPILE(,
1994-08-24 14:41:01 +08:00
changequote(<<, >>)dnl
<< /* Ultrix mips cc rejects this. */
typedef int charset[2]; const charset x = {0, 0};
/* SunOS 4.1.1 cc rejects this. */
char const *const *ccp;
char **p;
/* NEC SVR4.0.2 mips cc rejects this. */
struct point {int x, y;};
static struct point const zero = {0,0};
/* AIX XL C 1.02.0.0 rejects this.
It does not let you subtract one const X* pointer from another in
an arm of an if-expression whose if-part is not a constant
expression */
const char *g = "string";
ccp = &g + (g ? g-g : 0);
/* HPUX 7.0 cc rejects these. */
++ccp;
p = (char**) ccp;
ccp = (char const *const *) p;
{ /* SCO 3.2v4 cc rejects this. */
char *t;
char const *s = 0 ? (char *) 0 : (char const *) 0;
*t++ = 0;
}
{ /* Someone thinks the Sun supposedly-ANSI compiler will reject this. */
int x[] = {25, 17};
const int *foo = &x[0];
++foo;
}
{ /* Sun SC1.0 ANSI compiler rejects this -- but not the above. */
typedef const int *iptr;
iptr p = 0;
++p;
}
{ /* AIX XL C 1.02.0.0 rejects this saying
"k.c", line 2.27: 1506-025 (S) Operand must be a modifiable lvalue. */
struct s { int j; const int *ap[3]; };
struct s *b; b->j = 5;
}
{ /* ULTRIX-32 V3.1 (Rev 9) vcc rejects this */
const int foo = 10;
}>>,
changequote([, ])dnl
ac_cv_c_const=yes, ac_cv_c_const=no)])
if test $ac_cv_c_const = no; then
1999-10-30 22:17:20 +08:00
AC_DEFINE(const,,
[Define to empty if the keyword `const' does not work.])
fi
])dnl AC_C_CONST
1999-10-30 22:17:20 +08:00
dnl AC_C_VOLATILE
dnl -------------
dnl Note that, unlike const, #defining volatile to be the empty string can
dnl actually turn a correct program into an incorrect one, since removing
dnl uses of volatile actually grants the compiler permission to perform
dnl optimizations that could break the user's code. So, do not #define
dnl volatile away unless it is really necessary to allow the user's code
dnl to compile cleanly. Benign compiler failures should be tolerated.
AC_DEFUN(AC_C_VOLATILE,
[AC_CACHE_CHECK([for working volatile], ac_cv_c_volatile,
1999-10-30 22:17:20 +08:00
[AC_TRY_COMPILE(,[
volatile int x;
1999-10-30 22:17:20 +08:00
int * volatile y;],
ac_cv_c_volatile=yes, ac_cv_c_volatile=no)])
if test $ac_cv_c_volatile = no; then
1999-10-30 22:17:20 +08:00
AC_DEFINE(volatile,,
[Define to empty if the keyword `volatile' does not work.
Warning: valid code using `volatile' can become incorrect
without. Disable with care.])
fi
])
1999-10-30 22:17:20 +08:00
dnl AC_C_STRINGIZE
dnl --------------
dnl Checks if `#' can be used to glue strings together at the CPP level.
dnl Defines HAVE_STRINGIZE if positive.
AC_DEFUN(AC_C_STRINGIZE,
[AC_REQUIRE([AC_PROG_CPP])dnl
AC_MSG_CHECKING([for preprocessor stringizing operator])
AC_CACHE_VAL(ac_cv_c_stringize,
AC_EGREP_CPP([#teststring],[
#define x(y) #y
char *s = x(teststring);
], ac_cv_c_stringize=no, ac_cv_c_stringize=yes))
1999-10-30 22:17:20 +08:00
if test "${ac_cv_c_stringize}" = yes; then
AC_DEFINE(HAVE_STRINGIZE, 1,
[Define if cpp supports the ANSI # stringizing operator.])
fi
AC_MSG_RESULT([${ac_cv_c_stringize}])
])dnl AC_C_STRINGIZE
dnl AC_C_PROTOTYPES
dnl ---------------
dnl Check if the C compiler supports prototypes, included if it needs
dnl options.
AC_DEFUN(AC_C_PROTOTYPES,
[AC_REQUIRE([AC_PROG_CC_STDC])dnl
AC_REQUIRE([AC_PROG_CPP])dnl
AC_MSG_CHECKING([for function prototypes])
if test "$ac_cv_prog_cc_stdc" != no; then
AC_MSG_RESULT(yes)
AC_DEFINE(PROTOTYPES, 1,
[Define if the compiler supports function prototypes.])
else
AC_MSG_RESULT(no)
fi
])dnl AC_C_PROTOTYPES
AC_DEFUNCT(AC_ARG_ARRAY, [; don't do unportable things with arguments])
dnl Check the object extension used by the compiler: typically .o or
dnl .obj. If this is called, some other behaviour will change,
dnl determined by ac_objext.
AC_DEFUN(AC_OBJEXT,
[AC_MSG_CHECKING([for object suffix])
AC_CACHE_VAL(ac_cv_objext,
[rm -f conftest*
echo 'int i = 1;' >conftest.$ac_ext
if AC_TRY_EVAL(ac_compile); then
for ac_file in conftest.*; do
case $ac_file in
*.c) ;;
*) ac_cv_objext=`echo $ac_file | sed -e s/conftest.//` ;;
esac
done
else
AC_MSG_ERROR([installation or configuration problem; compiler does not work])
fi
rm -f conftest*])
AC_MSG_RESULT($ac_cv_objext)
OBJEXT=$ac_cv_objext
ac_objext=$ac_cv_objext
AC_SUBST(OBJEXT)])
1999-10-30 22:17:20 +08:00
dnl AC_F77_LIBRARY_LDFLAGS
dnl ----------------------
dnl
dnl Determine the linker flags (e.g. "-L" and "-l") for the Fortran 77
dnl intrinsic and run-time libraries that are required to successfully
dnl link a Fortran 77 program or shared library. The output variable
dnl FLIBS is set to these flags.
1999-10-30 22:17:20 +08:00
dnl
dnl This macro is intended to be used in those situations when it is
dnl necessary to mix, e.g. C++ and Fortran 77, source code into a single
dnl program or shared library.
1999-10-30 22:17:20 +08:00
dnl
dnl For example, if object files from a C++ and Fortran 77 compiler must
dnl be linked together, then the C++ compiler/linker must be used for
dnl linking (since special C++-ish things need to happen at link time
dnl like calling global constructors, instantiating templates, enabling
dnl exception support, etc.).
1999-10-30 22:17:20 +08:00
dnl
dnl However, the Fortran 77 intrinsic and run-time libraries must be
dnl linked in as well, but the C++ compiler/linker doesn't know how to
dnl add these Fortran 77 libraries. Hence, the macro
1999-10-30 22:17:20 +08:00
dnl "AC_F77_LIBRARY_LDFLAGS" was created to determine these Fortran 77
dnl libraries.
dnl
dnl This macro was packaged in its current form by Matthew D. Langston
dnl <langston@SLAC.Stanford.EDU>. However, nearly all of this macro
1999-10-30 22:17:20 +08:00
dnl came from the "OCTAVE_FLIBS" macro in "octave-2.0.13/aclocal.m4",
dnl and full credit should go to John W. Eaton for writing this
dnl extremely useful macro. Thank you John.
1999-10-30 22:17:20 +08:00
dnl We have to "pushdef" this macro for now, because I haven't checked
dnl this version of the macro into the Autoconf repository yet. --MDL
AC_DEFUN(AC_F77_LIBRARY_LDFLAGS,
1999-10-30 22:17:20 +08:00
[
AC_CACHE_CHECK([for Fortran 77 libraries],
ac_cv_flibs,
[
AC_REQUIRE([AC_PROG_F77])dnl
AC_REQUIRE([AC_CYGWIN])dnl
1999-10-30 22:17:20 +08:00
AC_LANG_SAVE
AC_LANG_FORTRAN77
# This is the simplest of all Fortran 77 programs.
cat >conftest.$ac_ext <<EOF
1999-10-30 22:17:20 +08:00
end
EOF
# Save the "compiler output file descriptor" to FD 8.
exec 8>&AC_FD_CC
# Temporarily redirect compiler output to stdout, since this is what
# we want to capture in "f77_link_output".
exec AC_FD_CC>&1
# Compile and link our simple test program by passing the "-v" flag
# to the Fortran 77 compiler in order to get "verbose" output that
# we can then parse for the Fortran 77 linker flags. I don't know
# what to do if your compiler doesn't have -v.
FFLAGS_SAVE="$FFLAGS"
FFLAGS="$FFLAGS -v"
f77_link_output=`eval $ac_link 2>&1 | grep -v 'Driving:'`
FFLAGS="$FFLAGS_SAVE"
# Restore the "compiler output file descriptor".
exec AC_FD_CC>&8
rm -f conftest.*
AC_LANG_RESTORE
# This will ultimately be our output variable.
FLIBS=
changequote(, )dnl
# If we are using xlf then replace all the commas with spaces.
if test `echo $f77_link_output | grep xlfentry >/dev/null 2>&1`; then
1999-10-30 22:17:20 +08:00
f77_link_output=`echo $f77_link_output | sed 's/,/ /g'`
fi
# The "save_arg" variable will be set to the current option
# (i.e. something beginning with a "-") when we come across an
# option that we think will take an argument (e.g. -L
# /usr/local/lib/foo). When "save_arg" is set, we append "arg" to
# "seen" without any further examination.
save_arg=
# This is just a "list" (i.e. space delimited elements) of flags
# that we've already seen. This just help us not add the same
# linker flags twice to "FLIBS".
seen=
# The basic algorithm is that if "arg" makes it all the way through
# down to the bottom of the the "for" loop, then it is added to
# "FLIBS".
for arg in $f77_link_output; do
# Assume that none of the options that take arguments expect the
# argument to start with a "-". If we ever see this case, then
# reset "previous_arg" so that we don't try and process "arg" as
# an argument.
previous_arg="$save_arg"
test -n "`echo $arg | sed -n -e '/^-/!p'`" && previous_arg=
case "$previous_arg" in
'')
case "$arg" in
/*.a)
# Append to "seen" if it's not already there.
changequote([, ])dnl
AC_LIST_MEMBER_OF($arg, $seen, arg=, seen="$seen $arg")
changequote(, )dnl
;;
-bI:*)
# Append to "seen" if it's not already there.
changequote([, ])dnl
AC_LIST_MEMBER_OF($arg, $seen, arg=, [AC_LINKER_OPTION([$arg], seen)])
changequote(, )dnl
;;
# Ignore these flags.
-lang* | -lcrt0.o | -l[cm] | -lgcc | -LANG:=*)
arg=
;;
-lkernel32)
# Only ignore this flag under the Cygwin
# environment.
if test x"$CYGWIN" = xyes; then arg=; else seen="$seen $arg"; fi
;;
-[LRu])
# These flags, when seen by themselves, take an
# argument.
save_arg=$arg
arg=
;;
-YP,*)
temp_arg=
for i in `echo $arg | sed -e 's%^P,%-L%' -e 's%:% -L%g'`; do
# Append to "seen" if it's not already
# there.
changequote([, ])dnl
AC_LIST_MEMBER_OF($i, $seen, temp_arg="$temp_arg $i", seen="$seen $i")
changequote(, )dnl
done
arg="$temp_arg"
;;
-[lLR]*)
# Append to "seen" if it's not already there.
changequote([, ])dnl
AC_LIST_MEMBER_OF($arg, $seen, arg=, seen="$seen $arg")
changequote(, )dnl
;;
*)
# Ignore everything else.
arg=
;;
esac
;;
-[LRu])
arg="$previous_arg $arg"
;;
esac
# If "arg" has survived up until this point, then put it in
# "FLIBS".
test -n "$arg" && FLIBS="$FLIBS $arg"
done
# Assumption: We only see "LD_RUN_PATH" on Solaris systems. If this
# is seen, then we insist that the "run path" must be an absolute
# path (i.e. it must begin with a "/").
ld_run_path=`echo $f77_link_output | sed -n -e 's%^.*LD_RUN_PATH *= *\(/[^ ]*\).*$%\1%p'`
test -n "$ld_run_path" && FLIBS="$ld_run_path $FLIBS"
changequote([, ])dnl
ac_cv_flibs="$FLIBS"
])
AC_SUBST(FLIBS)
])
dnl Test for the name mangling scheme used by the Fortran 77 compiler.
dnl Two variables are set by this macro:
dnl
1999-10-30 22:17:20 +08:00
dnl f77_case: Set to either "upper" or "lower", depending on the
dnl case of the name mangling.
dnl
1999-10-30 22:17:20 +08:00
dnl f77_underscore: Set to either "no", "single" or "double", depending
dnl on how underscores (i.e. "_") are appended to
dnl identifiers, if at all.
dnl
dnl If no underscores are appended, then the value is
dnl "no".
dnl
1999-10-30 22:17:20 +08:00
dnl If a single underscore is appended, even with
dnl identifiers which already contain an underscore
dnl somewhere in their name, then the value is
dnl "single".
dnl
1999-10-30 22:17:20 +08:00
dnl If a single underscore is appended *and* two
dnl underscores are appended to identifiers which
dnl already contain an underscore somewhere in their
dnl name, then the value is "double".
dnl
1999-10-30 22:17:20 +08:00
dnl AC_F77_NAME_MANGLING()
AC_DEFUN(AC_F77_NAME_MANGLING,
[
AC_CACHE_CHECK([for Fortran 77 name-mangling scheme],
ac_cv_f77_mangling,
[
AC_REQUIRE([AC_PROG_CC])dnl
AC_REQUIRE([AC_PROG_F77])dnl
1999-10-30 22:17:20 +08:00
AC_LANG_SAVE
AC_LANG_FORTRAN77
cat >conftest.$ac_ext <<EOF
1999-10-30 22:17:20 +08:00
subroutine foobar()
return
end
subroutine foo_bar()
return
end
EOF
if AC_TRY_EVAL(ac_compile); then
mv conftest.${ac_objext} cf77_test.${ac_objext}
AC_LANG_SAVE
AC_LANG_C
ac_save_LIBS="$LIBS"
LIBS="cf77_test.${ac_objext} $LIBS"
f77_case=
f77_underscore=
AC_TRY_LINK_FUNC(foobar,
f77_case=lower
f77_underscore=no
foo_bar=foo_bar_,
AC_TRY_LINK_FUNC(foobar_,
f77_case=lower
f77_underscore=single
foo_bar=foo_bar__,
AC_TRY_LINK_FUNC(FOOBAR,
f77_case=upper
f77_underscore=no
foo_bar=FOO_BAR_,
AC_TRY_LINK_FUNC(FOOBAR_,
f77_case=upper
f77_underscore=single
foo_bar=FOO_BAR__))))
AC_TRY_LINK_FUNC(${foo_bar}, f77_underscore=double)
if test x"$f77_case" = x || test x"$f77_underscore" = x; then
1999-10-30 22:17:20 +08:00
ac_cv_f77_mangling="unknown"
else
ac_cv_f77_mangling="$f77_case case, $f77_underscore underscores"
fi
LIBS="$ac_save_LIBS"
AC_LANG_RESTORE
rm -f conftest*
rm -f cf77_test*
else
1999-10-30 22:17:20 +08:00
echo "configure: failed program was:" >&AC_FD_CC
cat conftest.$ac_ext >&AC_FD_CC
fi
1999-10-30 22:17:20 +08:00
dnl We need to pop the language stack twice.
dnl FIXME: Why? You've done it above, AFAICT.
AC_LANG_RESTORE()dnl
AC_LANG_RESTORE()dnl
1999-10-30 22:17:20 +08:00
])])
dnl AC_F77_WRAPPERS
dnl ---------------
1999-10-30 22:17:20 +08:00
dnl Defines C macros F77_FUNC(name,NAME) and F77_FUNC_(name,NAME) to
dnl properly mangle the names of C identifiers, and C identifiers with
dnl underscores, respectively, so that they match the name mangling
dnl scheme used by the Fortran 77 compiler.
AC_DEFUN(AC_F77_WRAPPERS,
[
AC_CACHE_CHECK([if we can define Fortran 77 name-mangling macros],
ac_cv_f77_wrappers,
[
dnl Be optimistic at first.
ac_cv_f77_wrappers="yes"
AC_REQUIRE([AC_F77_NAME_MANGLING])dnl
1999-10-30 22:17:20 +08:00
case "$f77_case" in
lower)
case "$f77_underscore" in
no)
AC_DEFINE([F77_FUNC(name,NAME)], [name])
AC_DEFINE([F77_FUNC_(name,NAME)], [name])
;;
single)
AC_DEFINE([F77_FUNC(name,NAME)], [name ## _])
AC_DEFINE([F77_FUNC_(name,NAME)], [name ## _])
;;
double)
AC_DEFINE([F77_FUNC(name,NAME)], [name ## _])
AC_DEFINE([F77_FUNC_(name,NAME)], [name ## __])
;;
*)
AC_MSG_WARN(unknown Fortran 77 name-mangling scheme)
;;
esac
;;
upper)
case "$f77_underscore" in
no)
AC_DEFINE([F77_FUNC(name,NAME)], [NAME])
AC_DEFINE([F77_FUNC_(name,NAME)], [NAME])
;;
single)
AC_DEFINE([F77_FUNC(name,NAME)], [NAME ## _])
AC_DEFINE([F77_FUNC_(name,NAME)], [NAME ## _])
;;
double)
AC_DEFINE([F77_FUNC(name,NAME)], [NAME ## _])
AC_DEFINE([F77_FUNC_(name,NAME)], [NAME ## __])
;;
*)
AC_MSG_WARN(unknown Fortran 77 name-mangling scheme)
;;
esac
1999-10-30 22:17:20 +08:00
;;
*)
1999-10-30 22:17:20 +08:00
AC_MSG_WARN(unknown Fortran 77 name-mangling scheme)
;;
esac
])])
dnl ### Checks for operating system services
AC_DEFUN(AC_SYS_INTERPRETER,
1994-08-26 10:08:08 +08:00
[# Pull the hash mark out of the macro call to avoid m4 problems.
ac_msg="whether #! works in shell scripts"
1995-06-29 04:19:08 +08:00
AC_CACHE_CHECK($ac_msg, ac_cv_sys_interpreter,
1995-02-07 07:31:34 +08:00
[echo '#! /bin/cat
1993-10-16 06:51:22 +08:00
exit 69
' >conftest
1993-10-16 06:51:22 +08:00
chmod u+x conftest
1994-08-26 09:15:45 +08:00
(SHELL=/bin/sh; export SHELL; ./conftest >/dev/null)
1993-10-16 06:51:22 +08:00
if test $? -ne 69; then
ac_cv_sys_interpreter=yes
1993-10-16 06:51:22 +08:00
else
ac_cv_sys_interpreter=no
fi
1995-06-29 04:19:08 +08:00
rm -f conftest])
1999-01-05 11:18:40 +08:00
interpval="$ac_cv_sys_interpreter"
])
AC_DEFUNCT(AC_HAVE_POUNDBANG, [;use AC_SYS_INTERPRETER, taking no arguments])
1994-08-13 10:19:11 +08:00
AC_DEFUN(AC_SYS_LONG_FILE_NAMES,
1995-06-29 04:19:08 +08:00
[AC_CACHE_CHECK(for long file names, ac_cv_sys_long_file_names,
[ac_cv_sys_long_file_names=yes
1993-10-16 06:51:22 +08:00
# Test for long file names in all the places we know might matter:
# . the current directory, where building will happen
# $prefix/lib where we will be installing things
# $exec_prefix/lib likewise
# eval it to expand exec_prefix.
# $TMPDIR if set, where it might want to write temporary files
# if $TMPDIR is not set:
# /tmp where it might want to write temporary files
# /var/tmp likewise
# /usr/tmp likewise
if test -n "$TMPDIR" && test -d "$TMPDIR" && test -w "$TMPDIR"; then
ac_tmpdirs="$TMPDIR"
else
ac_tmpdirs='/tmp /var/tmp /usr/tmp'
fi
for ac_dir in . $ac_tmpdirs `eval echo $prefix/lib $exec_prefix/lib` ; do
test -d $ac_dir || continue
1994-05-18 03:25:23 +08:00
test -w $ac_dir || continue # It is less confusing to not echo anything here.
(echo 1 >$ac_dir/conftest9012345) 2>/dev/null
(echo 2 >$ac_dir/conftest9012346) 2>/dev/null
val=`cat $ac_dir/conftest9012345 2>/dev/null`
if test ! -f $ac_dir/conftest9012345 || test "$val" != 1; then
ac_cv_sys_long_file_names=no
1994-08-26 09:15:45 +08:00
rm -f $ac_dir/conftest9012345 $ac_dir/conftest9012346 2>/dev/null
break
fi
1994-08-26 09:15:45 +08:00
rm -f $ac_dir/conftest9012345 $ac_dir/conftest9012346 2>/dev/null
1995-06-29 04:19:08 +08:00
done])
if test $ac_cv_sys_long_file_names = yes; then
1999-10-30 22:17:20 +08:00
AC_DEFINE(HAVE_LONG_FILE_NAMES, 1,
[Define if you support file names longer than 14 characters.])
fi
])
dnl AC_SYS_RESTARTABLE_SYSCALLS
dnl ---------------------------
1994-08-13 10:19:11 +08:00
AC_DEFUN(AC_SYS_RESTARTABLE_SYSCALLS,
1995-06-29 04:19:08 +08:00
[AC_CACHE_CHECK(for restartable system calls, ac_cv_sys_restartable_syscalls,
[AC_TRY_RUN(
1993-10-16 06:51:22 +08:00
[/* Exit 0 (true) if wait returns something other than -1,
i.e. the pid of the child, which means that wait was restarted
after getting the signal. */
#include <sys/types.h>
#include <signal.h>
ucatch (isig) { }
int
main ()
{
1993-10-16 06:51:22 +08:00
int i = fork (), status;
if (i == 0) { sleep (3); kill (getppid (), SIGINT); sleep (3); exit (0); }
signal (SIGINT, ucatch);
status = wait(&i);
if (status == -1) wait(&i);
exit (status == -1);
}], ac_cv_sys_restartable_syscalls=yes, ac_cv_sys_restartable_syscalls=no)])
if test $ac_cv_sys_restartable_syscalls = yes; then
1999-10-30 22:17:20 +08:00
AC_DEFINE(HAVE_RESTARTABLE_SYSCALLS, 1,
[Define if system calls automatically restart after interruption
by a signal.])
fi
])dnl AC_SYS_RESTARTABLE_SYSCALLS
dnl AC_PATH_X
dnl ---------
1994-08-13 10:19:11 +08:00
AC_DEFUN(AC_PATH_X,
[AC_REQUIRE_CPP()dnl Set CPP; we run AC_PATH_X_DIRECT conditionally.
1994-08-24 04:24:36 +08:00
# If we find X, set shell vars x_includes and x_libraries to the
# paths, otherwise set no_x=yes.
# Uses ac_ vars as temps to allow command line to override cache and checks.
# --without-x overrides everything else, but does not touch the cache.
AC_MSG_CHECKING(for X)
1994-09-06 04:12:21 +08:00
AC_ARG_WITH(x, [ --with-x use the X Window System])
# $have_x is `yes', `no', `disabled', or empty when we do not yet know.
1994-08-24 04:24:36 +08:00
if test "x$with_x" = xno; then
# The user explicitly disabled X.
have_x=disabled
else
1994-08-24 04:24:36 +08:00
if test "x$x_includes" != xNONE && test "x$x_libraries" != xNONE; then
# Both variables are already set.
have_x=yes
1994-08-24 04:24:36 +08:00
else
AC_CACHE_VAL(ac_cv_have_x,
1994-08-24 04:24:36 +08:00
[# One or both of the vars are not set, and there is no cached value.
ac_x_includes=NO ac_x_libraries=NO
AC_PATH_X_XMKMF
AC_PATH_X_DIRECT
if test "$ac_x_includes" = NO || test "$ac_x_libraries" = NO; then
# Didn't find X anywhere. Cache the known absence of X.
ac_cv_have_x="have_x=no"
1994-08-24 04:24:36 +08:00
else
# Record where we found X for the cache.
ac_cv_have_x="have_x=yes \
ac_x_includes=$ac_x_includes ac_x_libraries=$ac_x_libraries"
1994-08-24 04:24:36 +08:00
fi])dnl
fi
eval "$ac_cv_have_x"
1994-08-24 04:24:36 +08:00
fi # $with_x != no
if test "$have_x" != yes; then
AC_MSG_RESULT($have_x)
no_x=yes
1994-08-24 04:24:36 +08:00
else
# If each of the values was on the command line, it overrides each guess.
1994-08-24 04:24:36 +08:00
test "x$x_includes" = xNONE && x_includes=$ac_x_includes
test "x$x_libraries" = xNONE && x_libraries=$ac_x_libraries
# Update the cache value to reflect the command line values.
ac_cv_have_x="have_x=yes \
ac_x_includes=$x_includes ac_x_libraries=$x_libraries"
1994-08-24 04:24:36 +08:00
AC_MSG_RESULT([libraries $x_libraries, headers $x_includes])
fi
])
dnl Internal subroutine of AC_PATH_X.
dnl Set ac_x_includes and/or ac_x_libraries.
1994-08-13 10:19:11 +08:00
AC_DEFUN(AC_PATH_X_XMKMF,
1994-08-24 04:24:36 +08:00
[rm -fr conftestdir
1993-10-16 06:51:22 +08:00
if mkdir conftestdir; then
cd conftestdir
# Make sure to not put "make" in the Imakefile rules, since we grep it out.
cat >Imakefile <<'EOF'
1993-10-16 06:51:22 +08:00
acfindx:
@echo 'ac_im_incroot="${INCROOT}"; ac_im_usrlibdir="${USRLIBDIR}"; ac_im_libdir="${LIBDIR}"'
1993-10-16 06:51:22 +08:00
EOF
if (xmkmf) >/dev/null 2>/dev/null && test -f Makefile; then
# GNU make sometimes prints "make[1]: Entering...", which would confuse us.
1995-11-23 01:42:19 +08:00
eval `${MAKE-make} acfindx 2>/dev/null | grep -v make`
1993-10-16 06:51:22 +08:00
# Open Windows xmkmf reportedly sets LIBDIR instead of USRLIBDIR.
for ac_extension in a so sl; do
if test ! -f $ac_im_usrlibdir/libX11.$ac_extension &&
test -f $ac_im_libdir/libX11.$ac_extension; then
ac_im_usrlibdir=$ac_im_libdir; break
fi
done
1996-11-09 15:15:16 +08:00
# Screen out bogus values from the imake configuration. They are
# bogus both because they are the default anyway, and because
# using them would break gcc on systems where it needs fixed includes.
case "$ac_im_incroot" in
1993-10-16 06:51:22 +08:00
/usr/include) ;;
1995-02-08 06:41:14 +08:00
*) test -f "$ac_im_incroot/X11/Xos.h" && ac_x_includes="$ac_im_incroot" ;;
1993-10-16 06:51:22 +08:00
esac
case "$ac_im_usrlibdir" in
1993-10-16 06:51:22 +08:00
/usr/lib | /lib) ;;
1995-02-08 06:41:14 +08:00
*) test -d "$ac_im_usrlibdir" && ac_x_libraries="$ac_im_usrlibdir" ;;
1993-10-16 06:51:22 +08:00
esac
fi
cd ..
rm -fr conftestdir
fi
])
dnl Internal subroutine of AC_PATH_X.
dnl Set ac_x_includes and/or ac_x_libraries.
1994-08-13 10:19:11 +08:00
AC_DEFUN(AC_PATH_X_DIRECT,
[if test "$ac_x_includes" = NO; then
# Guess where to find include files, by looking for this one X11 .h file.
test -z "$x_direct_test_include" && x_direct_test_include=X11/Intrinsic.h
# First, try using that file with no special directory specified.
AC_TRY_CPP([#include <$x_direct_test_include>],
[# We can compile using X headers with no special include directory.
ac_x_includes=],
[# Look for the header file in a standard set of common directories.
1996-11-09 15:15:16 +08:00
# Check X11 before X11Rn because it is often a symlink to the current release.
for ac_dir in \
/usr/X11/include \
1993-12-07 12:40:53 +08:00
/usr/X11R6/include \
/usr/X11R5/include \
/usr/X11R4/include \
\
/usr/include/X11 \
1993-12-07 12:40:53 +08:00
/usr/include/X11R6 \
/usr/include/X11R5 \
/usr/include/X11R4 \
\
/usr/local/X11/include \
1993-12-07 12:40:53 +08:00
/usr/local/X11R6/include \
/usr/local/X11R5/include \
/usr/local/X11R4/include \
\
/usr/local/include/X11 \
1993-12-07 12:40:53 +08:00
/usr/local/include/X11R6 \
/usr/local/include/X11R5 \
/usr/local/include/X11R4 \
\
/usr/X386/include \
/usr/x386/include \
/usr/XFree86/include/X11 \
\
/usr/include \
/usr/local/include \
/usr/unsupported/include \
/usr/athena/include \
/usr/local/x11r5/include \
/usr/lpp/Xamples/include \
\
/usr/openwin/include \
/usr/openwin/share/include \
1993-10-16 06:51:22 +08:00
; \
do
1994-08-11 07:54:30 +08:00
if test -r "$ac_dir/$x_direct_test_include"; then
ac_x_includes=$ac_dir
1993-10-16 06:51:22 +08:00
break
fi
1994-08-24 04:24:36 +08:00
done])
fi # $ac_x_includes = NO
1993-10-16 06:51:22 +08:00
if test "$ac_x_libraries" = NO; then
# Check for the libraries.
test -z "$x_direct_test_library" && x_direct_test_library=Xt
test -z "$x_direct_test_function" && x_direct_test_function=XtMalloc
# See if we find them without any special options.
# Don't add to $LIBS permanently.
ac_save_LIBS="$LIBS"
LIBS="-l$x_direct_test_library $LIBS"
AC_TRY_LINK(, [${x_direct_test_function}()],
[LIBS="$ac_save_LIBS"
# We can link X programs with no special library path.
ac_x_libraries=],
[LIBS="$ac_save_LIBS"
# First see if replacing the include by lib works.
1996-11-09 15:15:16 +08:00
# Check X11 before X11Rn because it is often a symlink to the current release.
for ac_dir in `echo "$ac_x_includes" | sed s/include/lib/` \
/usr/X11/lib \
1993-12-07 12:40:53 +08:00
/usr/X11R6/lib \
/usr/X11R5/lib \
/usr/X11R4/lib \
\
/usr/lib/X11 \
1993-12-07 12:40:53 +08:00
/usr/lib/X11R6 \
/usr/lib/X11R5 \
/usr/lib/X11R4 \
\
/usr/local/X11/lib \
1993-12-07 12:40:53 +08:00
/usr/local/X11R6/lib \
/usr/local/X11R5/lib \
/usr/local/X11R4/lib \
\
/usr/local/lib/X11 \
1993-12-07 12:40:53 +08:00
/usr/local/lib/X11R6 \
/usr/local/lib/X11R5 \
/usr/local/lib/X11R4 \
\
/usr/X386/lib \
/usr/x386/lib \
/usr/XFree86/lib/X11 \
\
/usr/lib \
/usr/local/lib \
/usr/unsupported/lib \
/usr/athena/lib \
/usr/local/x11r5/lib \
/usr/lpp/Xamples/lib \
1996-11-09 15:15:16 +08:00
/lib/usr/lib/X11 \
\
/usr/openwin/lib \
/usr/openwin/share/lib \
1993-12-07 12:40:53 +08:00
; \
1993-10-16 06:51:22 +08:00
do
1996-11-09 15:15:16 +08:00
dnl Don't even attempt the hair of trying to link an X program!
for ac_extension in a so sl; do
1994-08-11 07:54:30 +08:00
if test -r $ac_dir/lib${x_direct_test_library}.$ac_extension; then
ac_x_libraries=$ac_dir
1993-10-16 06:51:22 +08:00
break 2
fi
done
done])
fi # $ac_x_libraries = NO
])
dnl Find additional X libraries, magic flags, etc.
1994-08-13 10:19:11 +08:00
AC_DEFUN(AC_PATH_XTRA,
[AC_REQUIRE([AC_PATH_X])dnl
if test "$no_x" = yes; then
1994-05-18 03:25:23 +08:00
# Not all programs may use this symbol, but it does not hurt to define it.
1999-10-30 22:17:20 +08:00
AC_DEFINE(X_DISPLAY_MISSING, 1,
[Define if the X Window System is missing or not being used.])
X_CFLAGS= X_PRE_LIBS= X_LIBS= X_EXTRA_LIBS=
1994-08-24 04:24:36 +08:00
else
if test -n "$x_includes"; then
X_CFLAGS="$X_CFLAGS -I$x_includes"
fi
1994-08-24 04:24:36 +08:00
# It would also be nice to do this for all -L options, not just this one.
if test -n "$x_libraries"; then
X_LIBS="$X_LIBS -L$x_libraries"
dnl FIXME banish uname from this macro!
1996-11-09 15:15:16 +08:00
# For Solaris; some versions of Sun CC require a space after -R and
1996-11-14 08:42:10 +08:00
# others require no space. Words are not sufficient . . . .
case "`(uname -sr) 2>/dev/null`" in
"SunOS 5"*)
AC_MSG_CHECKING(whether -R must be followed by a space)
ac_xsave_LIBS="$LIBS"; LIBS="$LIBS -R$x_libraries"
AC_TRY_LINK(, , ac_R_nospace=yes, ac_R_nospace=no)
if test $ac_R_nospace = yes; then
AC_MSG_RESULT(no)
X_LIBS="$X_LIBS -R$x_libraries"
else
LIBS="$ac_xsave_LIBS -R $x_libraries"
AC_TRY_LINK(, , ac_R_space=yes, ac_R_space=no)
if test $ac_R_space = yes; then
AC_MSG_RESULT(yes)
X_LIBS="$X_LIBS -R $x_libraries"
else
AC_MSG_RESULT(neither works)
fi
fi
LIBS="$ac_xsave_LIBS"
esac
fi
# Check for system-dependent libraries X programs must link with.
# Do this before checking for the system-independent R6 libraries
# (-lICE), since we may need -lsocket or whatever for X linking.
1994-08-24 04:24:36 +08:00
if test "$ISC" = yes; then
1995-02-08 22:58:30 +08:00
X_EXTRA_LIBS="$X_EXTRA_LIBS -lnsl_s -linet"
1994-08-24 04:24:36 +08:00
else
# Martyn.Johnson@cl.cam.ac.uk says this is needed for Ultrix, if the X
# libraries were built with DECnet support. And Karl Berry says
1994-08-24 04:24:36 +08:00
# the Alpha needs dnet_stub (dnet does not exist).
1995-02-08 22:58:30 +08:00
AC_CHECK_LIB(dnet, dnet_ntoa, [X_EXTRA_LIBS="$X_EXTRA_LIBS -ldnet"])
if test $ac_cv_lib_dnet_dnet_ntoa = no; then
1994-08-24 04:24:36 +08:00
AC_CHECK_LIB(dnet_stub, dnet_ntoa,
1996-11-14 08:42:10 +08:00
[X_EXTRA_LIBS="$X_EXTRA_LIBS -ldnet_stub"])
1994-08-24 04:24:36 +08:00
fi
1994-08-28 08:24:09 +08:00
# msh@cis.ufl.edu says -lnsl (and -lsocket) are needed for his 386/AT,
# to get the SysV transport functions.
# chad@anasazi.com says the Pyramis MIS-ES running DC/OSx (SVR4)
# needs -lnsl.
# The nsl library prevents programs from opening the X display
# on Irix 5.2, according to dickey@clark.net.
AC_CHECK_FUNC(gethostbyname)
if test $ac_cv_func_gethostbyname = no; then
AC_CHECK_LIB(nsl, gethostbyname, X_EXTRA_LIBS="$X_EXTRA_LIBS -lnsl")
fi
1994-08-24 04:24:36 +08:00
# lieder@skyler.mavd.honeywell.com says without -lsocket,
# socket/setsockopt and other routines are undefined under SCO ODT
# 2.0. But -lsocket is broken on IRIX 5.2 (and is not necessary
# on later versions), says simon@lia.di.epfl.ch: it contains
# gethostby* variants that don't use the nameserver (or something).
# -lsocket must be given before -lnsl if both are needed.
# We assume that if connect needs -lnsl, so does gethostbyname.
AC_CHECK_FUNC(connect)
if test $ac_cv_func_connect = no; then
AC_CHECK_LIB(socket, connect, X_EXTRA_LIBS="-lsocket $X_EXTRA_LIBS", ,
$X_EXTRA_LIBS)
fi
# gomez@mi.uni-erlangen.de says -lposix is necessary on A/UX.
AC_CHECK_FUNC(remove)
if test $ac_cv_func_remove = no; then
AC_CHECK_LIB(posix, remove, X_EXTRA_LIBS="$X_EXTRA_LIBS -lposix")
fi
# BSDI BSD/OS 2.1 needs -lipc for XOpenDisplay.
AC_CHECK_FUNC(shmat)
if test $ac_cv_func_shmat = no; then
AC_CHECK_LIB(ipc, shmat, X_EXTRA_LIBS="$X_EXTRA_LIBS -lipc")
1994-08-24 04:24:36 +08:00
fi
fi
# Check for libraries that X11R6 Xt/Xaw programs need.
ac_save_LDFLAGS="$LDFLAGS"
1996-11-14 08:42:10 +08:00
test -n "$x_libraries" && LDFLAGS="$LDFLAGS -L$x_libraries"
# SM needs ICE to (dynamically) link under SunOS 4.x (so we have to
# check for ICE first), but we must link in the order -lSM -lICE or
# we get undefined symbols. So assume we have SM if we have ICE.
# These have to be linked with before -lX11, unlike the other
# libraries we check for below, so use a different variable.
# --interran@uluru.Stanford.EDU, Karl Berry
AC_CHECK_LIB(ICE, IceConnectionNumber,
[X_PRE_LIBS="$X_PRE_LIBS -lSM -lICE"], , $X_EXTRA_LIBS)
LDFLAGS="$ac_save_LDFLAGS"
fi
AC_SUBST(X_CFLAGS)dnl
1994-10-12 01:23:26 +08:00
AC_SUBST(X_PRE_LIBS)dnl
AC_SUBST(X_LIBS)dnl
AC_SUBST(X_EXTRA_LIBS)dnl
])
1999-01-05 11:18:40 +08:00
dnl The old Cygwin32 macro is deprecated.
AC_DEFUN(AC_CYGWIN32,
1999-01-05 11:18:40 +08:00
[AC_OBSOLETE([$0], [; instead use AC_CYGWIN])dnl
AC_CYGWIN])
dnl Check for Cygwin. This is a way to set the right value for
dnl EXEEXT.
AC_DEFUN(AC_CYGWIN,
[AC_CACHE_CHECK(for Cygwin environment, ac_cv_cygwin,
[AC_TRY_COMPILE(,
[#ifndef __CYGWIN__
# define __CYGWIN__ __CYGWIN32__
1999-01-05 11:18:40 +08:00
#endif
return __CYGWIN__;],
ac_cv_cygwin=yes, ac_cv_cygwin=no)])
1999-01-05 11:18:40 +08:00
CYGWIN=
test "$ac_cv_cygwin" = yes && CYGWIN=yes])
dnl Check for mingw32. This is another way to set the right value for
dnl EXEEXT.
AC_DEFUN(AC_MINGW32,
[AC_CACHE_CHECK(for mingw32 environment, ac_cv_mingw32,
[AC_TRY_COMPILE(,[return __MINGW32__;],
ac_cv_mingw32=yes, ac_cv_mingw32=no)])
MINGW32=
test "$ac_cv_mingw32" = yes && MINGW32=yes])
dnl Check for EMX on OS/2. This is another way to set the right value
dnl for EXEEXT.
AC_DEFUN(AC_EMXOS2,
[AC_CACHE_CHECK(for EMX OS/2 environment, ac_cv_emxos2,
[AC_TRY_COMPILE(,[return __EMX__;],
ac_cv_emxos2=yes, ac_cv_emxos2=no)])
EMXOS2=
test "$ac_cv_emxos2" = yes && EMXOS2=yes])
dnl AC_EXEEXT
dnl ---------
dnl Check for the extension used for executables. This knows that we
1999-01-05 11:18:40 +08:00
dnl add .exe for Cygwin or mingw32. Otherwise, it compiles a test
dnl executable. If this is called, the executable extensions will be
dnl automatically used by link commands run by the configure script.
AC_DEFUN(AC_EXEEXT,
[AC_REQUIRE([AC_CYGWIN])dnl
AC_REQUIRE([AC_MINGW32])dnl
AC_REQUIRE([AC_EMXOS2])dnl
AC_MSG_CHECKING([for executable suffix])
AC_CACHE_VAL(ac_cv_exeext,
[if test "$CYGWIN" = yes || test "$MINGW32" = yes || test "$EMXOS2" = yes; then
ac_cv_exeext=.exe
else
rm -f conftest*
echo 'int main () { return 0; }' >conftest.$ac_ext
ac_cv_exeext=
if AC_TRY_EVAL(ac_link); then
for file in conftest.*; do
case $file in
*.c | *.C | *.o | *.obj | *.xcoff) ;;
*) ac_cv_exeext=`echo $file | sed -e s/conftest//` ;;
esac
done
else
AC_MSG_ERROR([installation or configuration problem: compiler cannot create executables.])
fi
rm -f conftest*
test x"${ac_cv_exeext}" = x && ac_cv_exeext=no
fi])
EXEEXT=""
test x"${ac_cv_exeext}" != xno && EXEEXT=${ac_cv_exeext}
AC_MSG_RESULT(${ac_cv_exeext})
dnl Setting ac_exeext will implicitly change the ac_link command.
ac_exeext=$EXEEXT
AC_SUBST(EXEEXT)dnl
])dnl AC_EXEEXT
dnl ### Checks for UNIX variants
1994-09-10 04:13:30 +08:00
dnl These are kludges which should be replaced by a single POSIX check.
1995-02-08 06:41:14 +08:00
dnl They aren't cached, to discourage their use.
1994-09-10 04:13:30 +08:00
AC_DEFUN(AC_AIX,
1994-10-23 10:08:04 +08:00
[AC_BEFORE([$0], [AC_TRY_COMPILE])dnl
AC_BEFORE([$0], [AC_TRY_RUN])dnl
1994-08-11 00:47:42 +08:00
AC_MSG_CHECKING(for AIX)
AC_EGREP_CPP(yes,
1993-10-16 06:51:22 +08:00
[#ifdef _AIX
yes
#endif
1999-10-30 22:17:20 +08:00
],
[AC_MSG_RESULT(yes)
AC_DEFINE(_ALL_SOURCE)],
AC_MSG_RESULT(no))
])dnl AC_AIX
1994-09-10 04:13:30 +08:00
AC_DEFUN(AC_MINIX,
1994-10-23 10:08:04 +08:00
[AC_BEFORE([$0], [AC_TRY_COMPILE])dnl
AC_BEFORE([$0], [AC_TRY_RUN])dnl
AC_CHECK_HEADER(minix/config.h, MINIX=yes, MINIX=)
if test "$MINIX" = yes; then
1999-10-30 22:17:20 +08:00
AC_DEFINE(_POSIX_SOURCE, 1,
[Define if you need to in order for `stat' and other things to
work.])
AC_DEFINE(_POSIX_1_SOURCE, 2,
[Define if the system does not provide POSIX.1 features except
with this defined.])
AC_DEFINE(_MINIX, 1,
[Define if on MINIX.])
1993-10-16 06:51:22 +08:00
fi
1999-10-30 22:17:20 +08:00
])dnl AC_MINIX
1994-09-10 04:13:30 +08:00
AC_DEFUN(AC_ISC_POSIX,
[AC_REQUIRE([AC_PROG_CC])dnl
AC_BEFORE([$0], [AC_TRY_COMPILE])dnl
AC_BEFORE([$0], [AC_TRY_RUN])dnl
AC_MSG_CHECKING(for POSIXized ISC)
1993-10-16 06:51:22 +08:00
if test -d /etc/conf/kconfig.d &&
grep _POSIX_VERSION [/usr/include/sys/unistd.h] >/dev/null 2>&1
then
1994-08-11 00:47:42 +08:00
AC_MSG_RESULT(yes)
ISC=yes # If later tests want to check for ISC.
1999-10-30 22:17:20 +08:00
AC_DEFINE(_POSIX_SOURCE, 1,
[Define if you need to in order for stat and other things to
work.])
1994-06-23 02:22:34 +08:00
if test "$GCC" = yes; then
1993-10-16 06:51:22 +08:00
CC="$CC -posix"
else
CC="$CC -Xp"
fi
else
1994-08-11 00:47:42 +08:00
AC_MSG_RESULT(no)
ISC=
1993-10-16 06:51:22 +08:00
fi
1999-10-30 22:17:20 +08:00
])dnl AC_ISC_POSIX
AC_DEFUNCT(AC_XENIX_DIR, [; instead use AC_HEADER_DIRENT])
AC_DEFUNCT(AC_DYNIX_SEQ, [; instead use AC_FUNC_GETMNTENT])
AC_DEFUNCT(AC_IRIX_SUN,
[; instead use AC_FUNC_GETMNTENT or AC_CHECK_LIB(sun, getpwnam)])
AC_DEFUNCT(AC_SCO_INTL, [; instead use AC_FUNC_STRFTIME])