mirror of
git://git.sv.gnu.org/autoconf
synced 2024-12-03 02:00:36 +08:00
32876525ac
generates too many bug reports. * lib/autoconf/general.m4 (_AC_RUN_IFELSE): Pass the right exit status when executing the ACTION-IF-FALSE. * tests/base.at (AC_TRY_*): Rename as... (AC_TRY_COMMAND): this. (AC_RUN_IFELSE): New. * tests/compile.at (Extensions, C keywords) (AC_PROG_CPP requires AC_PROG_CC, GNU Fortran 77) (Broken/missing compilers, AC_PROG_CPP with warnings) (AC_PROG_CPP without warnings, AC_PROG_CPP via CC): Move to... * tests/c.at (Extensions, C keywords) (Broken/missing compilers, AC_PROG_CPP with warnings) (AC_PROG_CPP without warnings, AC_PROG_CPP via CC) (AC_PROG_CPP requires AC_PROG_CC): here and... * tests/fortran.at (GNU Fortran 77): there. * doc/autoconf.texi (autoconf Invocation): Fix the example: AC_TRY_RUN is about compilation, not shell commands. (Test Programs): AC_TRY_RUN works as used to be advertised.
212 lines
4.8 KiB
Plaintext
212 lines
4.8 KiB
Plaintext
# -*- Autotest -*-
|
|
|
|
AT_BANNER([C low level compiling/preprocessing macros.])
|
|
|
|
# Copyright 2000, 2001 Free Software Foundation, Inc.
|
|
#
|
|
# This program is free software; you can redistribute it and/or modify
|
|
# it under the terms of the GNU General Public License as published by
|
|
# the Free Software Foundation; either version 2, or (at your option)
|
|
# any later version.
|
|
#
|
|
# This program is distributed in the hope that it will be useful,
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
# GNU General Public License for more details.
|
|
#
|
|
# You should have received a copy of the GNU General Public License
|
|
# along with this program; if not, write to the Free Software
|
|
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
|
|
# 02111-1307, USA.
|
|
|
|
|
|
# Since the macros which compile are required by most tests, check
|
|
# them first. But remember that looking for a compiler is even more
|
|
# primitive, so check those first.
|
|
|
|
|
|
## ------------ ##
|
|
## Extensions. ##
|
|
## ------------ ##
|
|
|
|
# As far as we know only `foo', `foo.exe' are possible executable,
|
|
# and `foo.o', `foo.obj' are possible object files. Autoconf must not
|
|
# know that, but it is OK for the test suite to take this into account.
|
|
AT_CHECK_MACRO([Extensions],
|
|
[[AC_PROG_CC
|
|
case $ac_exeext in
|
|
'' | '.exe' ) ;;
|
|
* ) AC_MSG_ERROR([suspicious executable suffix: $ac_exeext]);;
|
|
esac
|
|
|
|
case $ac_objext in
|
|
'o' | 'obj' ) ;;
|
|
* ) AC_MSG_ERROR([suspicious object suffix: $ac_objext]);;
|
|
esac
|
|
AS_EXIT([0])
|
|
]])
|
|
|
|
|
|
|
|
## -------------------------- ##
|
|
## Broken/missing compilers. ##
|
|
## -------------------------- ##
|
|
|
|
|
|
# Check that Autoconf correctly diagnoses broken compilers, and in
|
|
# particular, if it does not exit 77, the test suite is in trouble...
|
|
# FIXME: Once a precise message decided, check stderr of configure.
|
|
AT_SETUP([Broken/missing compilers])
|
|
|
|
AT_DATA([configure.ac],
|
|
[[AC_INIT
|
|
CC=no-such-compiler
|
|
AC_PROG_CC
|
|
]])
|
|
|
|
AT_CHECK_AUTOCONF
|
|
AT_CHECK_CONFIGURE([], 77, ignore, ignore)
|
|
|
|
AT_CLEANUP
|
|
|
|
|
|
## ------------ ##
|
|
## C keywords. ##
|
|
## ------------ ##
|
|
|
|
# GCC supports `const', `volatile', and `inline'.
|
|
AT_CHECK_MACRO([C keywords],
|
|
[[AC_PROG_CC
|
|
AC_C_CONST
|
|
AC_C_INLINE
|
|
AC_C_VOLATILE
|
|
case $GCC,$ac_cv_c_const,$ac_cv_c_inline,$ac_cv_c_volatile in
|
|
yes,*no*)
|
|
AC_MSG_ERROR([failed to detect `const', `inline' or `volatile' support]);;
|
|
esac
|
|
]])
|
|
|
|
|
|
|
|
## --------------------------------- ##
|
|
## AC_PROG_CPP requires AC_PROG_CC. ##
|
|
## --------------------------------- ##
|
|
|
|
# Must invoke AC_PROG_CC.
|
|
AT_CHECK_MACRO([AC_PROG_CPP requires AC_PROG_CC],
|
|
[[AC_PROG_CPP
|
|
test -z "$CC" &&
|
|
AC_MSG_ERROR([looked for a C preprocessor without looking for a compiler])
|
|
]])
|
|
|
|
|
|
|
|
## --------------------------- ##
|
|
## AC_PROG_CPP with warnings. ##
|
|
## --------------------------- ##
|
|
|
|
|
|
# It's Ok for strict preprocessors to produce warnings.
|
|
|
|
AT_SETUP([AC_PROG_CPP with warnings])
|
|
|
|
AT_DATA([mycpp],
|
|
[[#! /bin/sh
|
|
echo noise >&2
|
|
exec ${1+"$@"}
|
|
]])
|
|
|
|
chmod +x mycpp
|
|
|
|
_AT_CHECK_AC_MACRO(
|
|
[[AC_PROG_CPP
|
|
# If the preprocessor is not strict, just ignore
|
|
test "x$ac_c_preproc_warn_flag" = xyes &&
|
|
AC_MSG_ERROR([preprocessor has no warning option], 77)
|
|
CPP="./mycpp $CPP"
|
|
AC_CHECK_HEADERS(stdio.h autoconf_io.h)]])
|
|
|
|
AT_CHECK_DEFINES(
|
|
[/* #undef HAVE_AUTOCONF_IO_H */
|
|
#define HAVE_STDIO_H 1
|
|
])
|
|
|
|
AT_CLEANUP
|
|
|
|
|
|
## ------------------------------ ##
|
|
## AC_PROG_CPP without warnings. ##
|
|
## ------------------------------ ##
|
|
|
|
AT_SETUP([AC_PROG_CPP without warnings])
|
|
|
|
# Ignore if /lib/cpp doesn't work
|
|
AT_CHECK([/lib/cpp </dev/null || exit 77], [], [ignore], [ignore])
|
|
|
|
# A cpp which exit status is meaningless.
|
|
AT_DATA([mycpp],
|
|
[[#! /bin/sh
|
|
/lib/cpp ${1+"$@"}
|
|
exit 0
|
|
]])
|
|
|
|
chmod +x mycpp
|
|
|
|
_AT_CHECK_AC_MACRO(
|
|
[[CPP=./mycpp
|
|
AC_PROG_CPP
|
|
test "x$ac_c_preproc_warn_flag" != xyes &&
|
|
AC_MSG_ERROR([failed to detect preprocessor warning option])
|
|
AC_CHECK_HEADERS(stdio.h autoconf_io.h)]])
|
|
|
|
AT_CHECK_DEFINES(
|
|
[/* #undef HAVE_AUTOCONF_IO_H */
|
|
#define HAVE_STDIO_H 1
|
|
])
|
|
|
|
AT_CLEANUP
|
|
|
|
|
|
|
|
## -------------------- ##
|
|
## AC_PROG_CPP via CC. ##
|
|
## -------------------- ##
|
|
|
|
|
|
# It's Ok for strict preprocessors to produce warnings.
|
|
|
|
AT_SETUP([AC_PROG_CPP via CC])
|
|
|
|
# Ignore if /lib/cpp doesn't work
|
|
AT_CHECK([/lib/cpp </dev/null || exit 77], [], [ignore], [ignore])
|
|
|
|
AT_DATA([mycc],
|
|
[[#! /bin/sh
|
|
echo "Annoying copyright message" >&2
|
|
exec "$@"
|
|
]])
|
|
|
|
chmod +x mycc
|
|
|
|
# We go through the following contortions, in order to have the
|
|
# configure script go down the same codepaths as it would during a
|
|
# normal CPP selection check. If we explicitly set CPP, it goes down
|
|
# a different codepath.
|
|
_AT_CHECK_AC_MACRO(
|
|
[[AC_PROG_CC
|
|
CC="./mycc $CC"
|
|
AC_PROG_CPP
|
|
# The test $CC compiler should have been selected.
|
|
test "$CPP" != "$CC -E" &&
|
|
AC_MSG_ERROR([error messages on stderr cause the preprocessor selection to fail])
|
|
|
|
# Exercise CPP.
|
|
AC_CHECK_HEADERS(stdio.h autoconf_io.h)]])
|
|
|
|
AT_CHECK_DEFINES(
|
|
[/* #undef HAVE_AUTOCONF_IO_H */
|
|
#define HAVE_STDIO_H 1
|
|
])
|
|
|
|
AT_CLEANUP
|