📄 acspecific.m4
字号:
dnl Macros that test for specific features.dnl This file is part of Autoconf.dnl Copyright (C) 1992, 93, 94, 95, 96, 1998 Free Software Foundation, Inc.dnldnl This program is free software; you can redistribute it and/or modifydnl it under the terms of the GNU General Public License as published bydnl the Free Software Foundation; either version 2, or (at your option)dnl any later version.dnldnl This program is distributed in the hope that it will be useful,dnl but WITHOUT ANY WARRANTY; without even the implied warranty ofdnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See thednl GNU General Public License for more details.dnldnl You should have received a copy of the GNU General Public Licensednl along with this program; if not, write to the Free Softwarednl Foundation, Inc., 59 Temple Place - Suite 330, Boston, MAdnl 02111-1307, USA.dnldnl As a special exception, the Free Software Foundation gives unlimiteddnl permission to copy, distribute and modify the configure scripts thatdnl are the output of Autoconf. You need not follow the terms of the GNUdnl General Public License when using or distributing such scripts, evendnl though portions of the text of Autoconf appear in them. The GNUdnl General Public License (GPL) does govern all other use of the materialdnl that constitutes the Autoconf program.dnldnl Certain portions of the Autoconf source text are designed to be copieddnl (in certain cases, depending on the input) into the output ofdnl Autoconf. We call these the "data" portions. The rest of the Autoconfdnl source text consists of comments plus executable code that decides whichdnl of the data portions to output in any given case. We call thesednl comments and executable code the "non-data" portions. Autoconf neverdnl copies any of the non-data portions into its output.dnldnl This special exception to the GPL applies to versions of Autoconfdnl released by the Free Software Foundation. When you make anddnl distribute a modified version of Autoconf, you may extend this specialdnl exception to the GPL to apply to your modified version as well, *unless*dnl your modified version has the potential to copy into its output somednl of the text that was the non-data portion of the version that you starteddnl with. (In other words, unless your change moves or copies text fromdnl the non-data portions to the data portions.) If your modification hasdnl such potential, you must delete any notice of this special exceptiondnl to the GPL from your modified version.dnldnl Written by David MacKenzie, with help fromdnl Franc,ois Pinard, Karl Berry, Richard Pixley, Ian Lance Taylor,dnl Roland McGrath, Noah Friedman, david d zuhn, and many others.dnl ### Checks for programsdnl Check whether to use -n, \c, or newline-tab to separatednl checking messages from result messages.dnl Idea borrowed from dist 3.0.dnl Internal use only.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 ghazi@caip.rutgers.edu. if (echo -n testing; echo 1,2,3) | sed s/-n/xn/ | grep xn >/dev/null; then ac_n= ac_c='' ac_t=' ' else ac_n=-n ac_c= ac_t= fielse ac_n= ac_c='\c' ac_t=fi])AC_DEFUN(AC_PROG_CC,[AC_BEFORE([$0], [AC_PROG_CPP])dnlAC_CHECK_PROG(CC, gcc, gcc)if test -z "$CC"; then AC_CHECK_PROG(CC, cc, cc, , , /usr/ucb/cc) if test -z "$CC"; then case "`uname -s`" in *win32* | *WIN32*) AC_CHECK_PROG(CC, cl, cl) ;; esac fi test -z "$CC" && AC_MSG_ERROR([no acceptable cc found in \$PATH])fiAC_PROG_CC_WORKSAC_PROG_CC_GNUif test $ac_cv_prog_gcc = yes; then GCC=yeselse GCC=fidnl Check whether -g works, even if CFLAGS is set, in case the packagednl plays around with CFLAGS (such as to build both debugging anddnl normal versions of a library), tasteless as that idea is.ac_test_CFLAGS="${CFLAGS+set}"ac_save_CFLAGS="$CFLAGS"CFLAGS=AC_PROG_CC_Gif test "$ac_test_CFLAGS" = set; then CFLAGS="$ac_save_CFLAGS"elif test $ac_cv_prog_cc_g = yes; then if test "$GCC" = yes; then CFLAGS="-g -O2" else CFLAGS="-g" fielse if test "$GCC" = yes; then CFLAGS="-O2" else CFLAGS= fifi])AC_DEFUN(AC_PROG_CXX,[AC_BEFORE([$0], [AC_PROG_CXXCPP])dnlAC_CHECK_PROGS(CXX, $CCC c++ g++ gcc CC cxx cc++ cl, gcc)AC_PROG_CXX_WORKSAC_PROG_CXX_GNUif test $ac_cv_prog_gxx = yes; then GXX=yeselse GXX=fidnl Check whether -g works, even if CXXFLAGS is set, in case the packagednl plays around with CXXFLAGS (such as to build both debugging anddnl normal versions of a library), tasteless as that idea is.ac_test_CXXFLAGS="${CXXFLAGS+set}"ac_save_CXXFLAGS="$CXXFLAGS"CXXFLAGS=AC_PROG_CXX_Gif test "$ac_test_CXXFLAGS" = set; then CXXFLAGS="$ac_save_CXXFLAGS"elif test $ac_cv_prog_cxx_g = yes; then if test "$GXX" = yes; then CXXFLAGS="-g -O2" else CXXFLAGS="-g" fielse if test "$GXX" = yes; then CXXFLAGS="-O2" else CXXFLAGS= fifi])dnl Determine a Fortran 77 compiler to use. If `F77' is not already setdnl in the environment, check for `g77', `f77' and `f2c', in that order.dnl Set the output variable `F77' to the name of the compiler found.dnl dnl If using `g77' (the GNU Fortran 77 compiler), then `AC_PROG_F77'dnl will set the shell variable `G77' to `yes', and empty otherwise. Ifdnl the output variable `FFLAGS' was not already set in the environment,dnl then set it to `-g -02' for `g77' (or `-O2' where `g77' does notdnl accept `-g'). Otherwise, set `FFLAGS' to `-g' for all other Fortrandnl 77 compilers.dnl dnl AC_PROG_F77()AC_DEFUN(AC_PROG_F77,[AC_BEFORE([$0], [AC_PROG_CPP])dnlif test -z "$F77"; then AC_CHECK_PROGS(F77, g77 f77 f2c) test -z "$F77" && AC_MSG_ERROR([no acceptable Fortran 77 compiler found in \$PATH])fiAC_PROG_F77_WORKSAC_PROG_F77_GNUif test $ac_cv_prog_g77 = yes; then G77=yesdnl Check whether -g works, even if FFLAGS is set, in case the packagednl plays around with FFLAGS (such as to build both debugging anddnl normal versions of a library), tasteless as that idea is. ac_test_FFLAGS="${FFLAGS+set}" ac_save_FFLAGS="$FFLAGS" FFLAGS= AC_PROG_F77_G if test "$ac_test_FFLAGS" = set; then FFLAGS="$ac_save_FFLAGS" elif test $ac_cv_prog_f77_g = yes; then FFLAGS="-g -O2" else FFLAGS="-O2" fielse G77= test "${FFLAGS+set}" = set || FFLAGS="-g"fi])AC_DEFUN(AC_PROG_CC_WORKS,[AC_MSG_CHECKING([whether the C compiler ($CC $CFLAGS $LDFLAGS) works])AC_LANG_SAVEAC_LANG_CAC_TRY_COMPILER([main(){return(0);}], ac_cv_prog_cc_works, ac_cv_prog_cc_cross)AC_LANG_RESTOREAC_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.])fiAC_MSG_CHECKING([whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler])AC_MSG_RESULT($ac_cv_prog_cc_cross)cross_compiling=$ac_cv_prog_cc_cross])AC_DEFUN(AC_PROG_CXX_WORKS,[AC_MSG_CHECKING([whether the C++ compiler ($CXX $CXXFLAGS $LDFLAGS) works])AC_LANG_SAVEAC_LANG_CPLUSPLUSAC_TRY_COMPILER([int main(){return(0);}], ac_cv_prog_cxx_works, ac_cv_prog_cxx_cross)AC_LANG_RESTOREAC_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.])fiAC_MSG_CHECKING([whether the C++ compiler ($CXX $CXXFLAGS $LDFLAGS) is a cross-compiler])AC_MSG_RESULT($ac_cv_prog_cxx_cross)cross_compiling=$ac_cv_prog_cxx_cross])dnl Test whether the Fortran 77 compiler can compile and link a trivialdnl Fortran program. Also, test whether the Fortran 77 compiler is adnl cross-compiler (which may realistically be the case if the Fortrandnl compiler is `g77').dnl dnl AC_PROG_F77_WORKS()AC_DEFUN(AC_PROG_F77_WORKS,[AC_MSG_CHECKING([whether the Fortran 77 compiler ($F77 $FFLAGS $LDFLAGS) works])AC_LANG_SAVEAC_LANG_FORTRAN77AC_TRY_COMPILER(dnl[ program conftest end], ac_cv_prog_f77_works, ac_cv_prog_f77_cross)AC_LANG_RESTOREAC_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.])fiAC_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])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;#endifEOFif AC_TRY_COMMAND(${CC-cc} -E conftest.c) | egrep yes >/dev/null 2>&1; then ac_cv_prog_gcc=yeselse ac_cv_prog_gcc=nofi])])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;#endifEOFif AC_TRY_COMMAND(${CXX-g++} -E conftest.C) | egrep yes >/dev/null 2>&1; then ac_cv_prog_gxx=yeselse ac_cv_prog_gxx=nofi])])dnl Test whether for Fortran 77 compiler is `g77' (the GNU Fortran 77dnl Compiler). This test depends on whether the Fortran 77 compiler candnl do CPP pre-processing.dnl dnl AC_PROG_F77_GNU()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#endifEOFif AC_TRY_COMMAND($F77 -E conftest.fpp) | egrep yes >/dev/null 2>&1; then ac_cv_prog_g77=yeselse ac_cv_prog_g77=nofi])])AC_DEFUN(AC_PROG_CC_G,[AC_CACHE_CHECK(whether ${CC-cc} accepts -g, ac_cv_prog_cc_g,[echo 'void f(){}' > conftest.cif test -z "`${CC-cc} -g -c conftest.c 2>&1`"; then ac_cv_prog_cc_g=yeselse ac_cv_prog_cc_g=nofirm -f conftest*])])AC_DEFUN(AC_PROG_CXX_G,[AC_CACHE_CHECK(whether ${CXX-g++} accepts -g, ac_cv_prog_cxx_g,[echo 'void f(){}' > conftest.ccif test -z "`${CXX-g++} -g -c conftest.cc 2>&1`"; then ac_cv_prog_cxx_g=yeselse ac_cv_prog_cxx_g=nofirm -f conftest*])])dnl Test whether the Fortran 77 compiler can accept the `-g' option todnl enable debugging.dnl dnl AC_PROG_F77_G()AC_DEFUN(AC_PROG_F77_G,[AC_CACHE_CHECK(whether $F77 accepts -g, ac_cv_prog_f77_g,[cat > conftest.f << EOF program conftest endEOFif test -z "`$F77 -g -c conftest.f 2>&1`"; then ac_cv_prog_f77_g=yeselse ac_cv_prog_f77_g=nofirm -f conftest*])])AC_DEFUN(AC_PROG_GCC_TRADITIONAL,[AC_REQUIRE([AC_PROG_CC])dnlAC_REQUIRE([AC_PROG_CPP])dnlif test $ac_cv_prog_gcc = yes; then AC_CACHE_CHECK(whether ${CC-cc} needs -traditional, ac_cv_prog_gcc_traditional,[ ac_pattern="Autoconf.*'x'" AC_EGREP_CPP($ac_pattern, [#include <sgtty.h>Autoconf TIOCGETP], ac_cv_prog_gcc_traditional=yes, ac_cv_prog_gcc_traditional=no) if test $ac_cv_prog_gcc_traditional = no; then AC_EGREP_CPP($ac_pattern, [#include <termio.h>Autoconf TCGETA], ac_cv_prog_gcc_traditional=yes) fi]) if test $ac_cv_prog_gcc_traditional = yes; then CC="$CC -traditional" fifi])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)fiset dummy $CC; ac_cc="`echo [$]2 |changequote(, )dnl sed -e 's/[^a-zA-Z0-9_]/_/g' -e 's/^[0-9]/_/'`"changequote([, ])dnlAC_CACHE_VAL(ac_cv_prog_cc_${ac_cc}_c_o,[echo 'foo(){}' > conftest.c# 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);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 fi fielse eval ac_cv_prog_cc_${ac_cc}_c_o=nofirm -f conftest*])dnlif eval "test \"`echo '$ac_cv_prog_cc_'${ac_cc}_c_o`\" = yes"; then AC_MSG_RESULT(yes)else AC_MSG_RESULT(no) AC_DEFINE(NO_MINUS_C_MINUS_O)fi])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.dnldnl The usefulness of this macro is questionable, as I can't really seednl why anyone would use it. The only reason I include it is fordnl completeness, since a similar test exists for the C compiler.dnl dnl AC_PROG_F77_C_OAC_DEFUN(AC_PROG_F77_C_O,[AC_BEFORE([$0], [AC_PROG_F77])dnlAC_MSG_CHECKING(whether $F77 understand -c and -o together)set dummy $F77; ac_f77="`echo [$]2 |changequote(, )dnlsed -e 's/[^a-zA-Z0-9_]/_/g' -e 's/^[0-9]/_/'`"changequote([, ])dnlAC_CACHE_VAL(ac_cv_prog_f77_${ac_f77}_c_o,[cat > conftest.f << EOF program conftest endEOF# 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.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 eval ac_cv_prog_f77_${ac_f77}_c_o=yeselse eval ac_cv_prog_f77_${ac_f77}_c_o=nofirm -f conftest*])dnlif eval "test \"`echo '$ac_cv_prog_f77_'${ac_f77}_c_o`\" = yes"; then AC_MSG_RESULT(yes)else AC_MSG_RESULT(no) AC_DEFINE(F77_NO_MINUS_C_MINUS_O)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -