Next: Writing Test Programs, Up: Writing Tests [Contents][Index]
TODO: somewhere else there was a mention of the “current language”,
which is probably referring to this. is this important if we aren’t
writing our own tests?
Autoconf-generated configure scripts check for the C compiler and
its features by default. Packages that use other programming languages
(maybe more than one, e.g., C and C++) need to test features of the
compilers for the respective languages. The following macros determine
which programming language is used in the subsequent tests in
configure.ac.
Do compilation tests using the compiler, preprocessor, and file extensions for the specified language.
Supported languages are:
Do compilation tests using CC and CPP and use extension
.c for test programs. Use compilation flags: CPPFLAGS with
CPP, and both CPPFLAGS and CFLAGS with CC.
Do compilation tests using CXX and CXXCPP and use
extension .C for test programs. Use compilation flags:
CPPFLAGS with CXXCPP, and both CPPFLAGS and
CXXFLAGS with CXX.
Do compilation tests using F77 and use extension .f for
test programs. Use compilation flags: FFLAGS.
Do compilation tests using FC and use extension .f (or
whatever has been set by AC_FC_SRCEXT) for test programs. Use
compilation flags: FCFLAGS.
Compile and execute tests using ERLC and ERL and use extension
.erl for test Erlang modules. Use compilation flags: ERLCFLAGS.
Do compilation tests using OBJC and OBJCPP and use
extension .m for test programs. Use compilation flags:
CPPFLAGS with OBJCPP, and both CPPFLAGS and
OBJCFLAGS with OBJC.
Do compilation tests using OBJCXX and OBJCXXCPP and use
extension .mm for test programs. Use compilation flags:
CPPFLAGS with OBJCXXCPP, and both CPPFLAGS and
OBJCXXFLAGS with OBJCXX.
Do compilation tests using GOC and use extension .go for
test programs. Use compilation flags GOFLAGS.
Remember the current language (as set by AC_LANG) on a stack, and
then select the language. Use this macro and AC_LANG_POP
in macros that need to temporarily switch to a particular language.
Select the language that is saved on the top of the stack, as set by
AC_LANG_PUSH, and remove it from the stack.
If given, language specifies the language we just quit. It is a good idea to specify it when it’s known (which should be the case…), since Autoconf detects inconsistencies.
AC_LANG_PUSH([Fortran 77]) # Perform some tests on Fortran 77. # … AC_LANG_POP([Fortran 77])
Check statically that the current language is language. You should use this in your language specific macros to avoid that they be called with an inappropriate language.
This macro runs only at autoconf time, and incurs no cost at
configure time. Sadly enough and because Autoconf is a two
layer language 5, the macros
AC_LANG_PUSH and AC_LANG_POP cannot be “optimizing”,
therefore as much as possible you ought to avoid using them to wrap
your code, rather, require from the user to run the macro with a
correct current language, and check it with AC_LANG_ASSERT.
And anyway, that may help the user understand she is running a Fortran
macro while expecting a result about her Fortran 77 compiler...
Ensure that whichever preprocessor would currently be used for tests has
been found. Calls AC_REQUIRE (see Prerequisite Macros) with an
argument of either AC_PROG_CPP or AC_PROG_CXXCPP,
depending on which language is current.
Because M4 is not aware of Sh code, especially conditionals, some optimizations that look nice statically may produce incorrect results at runtime.
Next: Writing Test Programs, Up: Writing Tests [Contents][Index]