mirror of
git://git.sv.gnu.org/autoconf
synced 2024-12-03 02:00:36 +08:00
434092f3fb
* aclang.m4 (AC_LANG(C), AC_LANG(C++), AC_LANG(Fortran 77)): Don't use _AC_LANG_ABBREV so that you don't depend upon _AC_LANG. (_AC_LANG_SET): New. (AC_LANG, AC_LANG_PUSH, AC_LANG_POP): Use it. * tests/compile.at: Test AC_LANG, AC_LANG_PUSH & AC_LANG_POP.
230 lines
4.4 KiB
Plaintext
230 lines
4.4 KiB
Plaintext
# -*- autoconf -*-
|
|
|
|
AT_BANNER([Low level compiling/preprocessing macros.])
|
|
|
|
# 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.
|
|
|
|
|
|
## --------- ##
|
|
## AC_LANG. ##
|
|
## --------- ##
|
|
|
|
# Check that AC_LANG is optimizing, i.e., we don't output useless
|
|
# language changes. Still, make sure we do change the language when
|
|
# needed :)
|
|
|
|
AT_SETUP([AC_LANG])
|
|
|
|
AT_DATA([configure.ac],
|
|
[[AC_INIT
|
|
AC_LANG(C)
|
|
AC_LANG(C++)
|
|
AC_LANG(C++)
|
|
AC_LANG(Fortran 77)
|
|
AC_LANG(Fortran 77)
|
|
]])
|
|
|
|
AT_CHECK_AUTOCONF
|
|
AT_CHECK([sed -n 's/^ac_ext=//p' configure], 0,
|
|
[c
|
|
cc
|
|
f
|
|
])
|
|
|
|
AT_CLEANUP
|
|
|
|
|
|
## ------------------------------------- ##
|
|
## AC_LANG, AC_LANG_PUSH & AC_LANG_POP. ##
|
|
## ------------------------------------- ##
|
|
|
|
AT_SETUP([AC_LANG, AC_LANG_PUSH & AC_LANG_POP])
|
|
|
|
AT_DATA([configure.ac],
|
|
[[AC_INIT
|
|
# C
|
|
AC_LANG(C)
|
|
# C
|
|
AC_LANG_PUSH(C)
|
|
# C C
|
|
AC_LANG_PUSH(C++)
|
|
# C++ C C
|
|
AC_LANG(C++)
|
|
# C++ C C
|
|
AC_LANG_PUSH(Fortran 77)
|
|
# F77 C++ C C
|
|
AC_LANG_POP(Fortran 77)
|
|
# C++ C C
|
|
AC_LANG(C++)
|
|
# C++ C C
|
|
AC_LANG_POP(C++)
|
|
# C C
|
|
AC_LANG_POP(C)
|
|
# C
|
|
]])
|
|
|
|
AT_CHECK_AUTOCONF
|
|
AT_CHECK([sed -n 's/^ac_ext=//p' configure], 0,
|
|
[c
|
|
cc
|
|
f
|
|
cc
|
|
c
|
|
])
|
|
|
|
AT_CLEANUP
|
|
|
|
|
|
## ------------ ##
|
|
## 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
|
|
]])
|
|
|
|
|
|
## ------------ ##
|
|
## 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])
|
|
|
|
AT_DATA([mycpp],
|
|
[[#! /bin/sh
|
|
/lib/cpp ${1+"$@"}
|
|
exit 0
|
|
]])
|
|
|
|
chmod +x mycpp
|
|
|
|
_AT_CHECK_AC_MACRO(
|
|
[# Ignore if /lib/cpp doesn't work
|
|
if AC_TRY_COMMAND([/lib/cpp </dev/null >&2]); then :; else
|
|
AC_MSG_ERROR([preprocessor doesn't work], 77)
|
|
fi
|
|
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_TRY_LINK_FUNC. ##
|
|
## ------------------ ##
|
|
|
|
AT_CHECK_MACRO([AC_TRY_LINK_FUNC],
|
|
[AC_TRY_LINK_FUNC(printf,,
|
|
[AC_MSG_ERROR([cannot find `printf'])])
|
|
AC_TRY_LINK_FUNC(Be_doomed_if_your_libc_has_a_function_named_like_this,
|
|
[AC_MSG_ERROR([found a nonexistent function])])])
|
|
|
|
|
|
|
|
## --------------------- ##
|
|
## Fortran 77 Compiler. ##
|
|
## --------------------- ##
|
|
|
|
|
|
AT_CHECK_MACRO([GNU Fortran 77],
|
|
[[AC_LANG(Fortran 77)
|
|
AC_LANG_COMPILER
|
|
|
|
if AC_TRY_COMMAND([$F77 --version | grep GNU >&2]); then
|
|
# Has GNU in --version.
|
|
test "$G77" != yes &&
|
|
AC_MSG_ERROR([failed to recognize GNU Fortran 77 compiler])
|
|
else
|
|
# Has not.
|
|
test "$G77" = yes &&
|
|
AC_MSG_ERROR([incorrectly recognized a GNU Fortran 77 compiler])
|
|
fi
|
|
AS_EXIT(0)]])
|