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:
- ‘C’
- Do compilation tests using
CC
andCPP
and use extension .c for test programs. Use compilation flags:CPPFLAGS
withCPP
, and bothCPPFLAGS
andCFLAGS
withCC
.- ‘C++’
- Do compilation tests using
CXX
andCXXCPP
and use extension .C for test programs. Use compilation flags:CPPFLAGS
withCXXCPP
, and bothCPPFLAGS
andCXXFLAGS
withCXX
.- ‘Fortran 77’
- Do compilation tests using
F77
and use extension .f for test programs. Use compilation flags:FFLAGS
.- ‘Fortran’
- Do compilation tests using
FC
and use extension .f (or whatever has been set byAC_FC_SRCEXT
) for test programs. Use compilation flags:FCFLAGS
.- ‘Erlang’
- Compile and execute tests using
ERLC
andERL
and use extension .erl for test Erlang modules. Use compilation flags:ERLCFLAGS
.- ‘Objective C’
- Do compilation tests using
OBJC
andOBJCPP
and use extension .m for test programs. Use compilation flags:CPPFLAGS
withOBJCPP
, and bothCPPFLAGS
andOBJCFLAGS
withOBJC
.- ‘Objective C++’
- Do compilation tests using
OBJCXX
andOBJCXXCPP
and use extension .mm for test programs. Use compilation flags:CPPFLAGS
withOBJCXXCPP
, and bothCPPFLAGS
andOBJCXXFLAGS
withOBJCXX
.
Remember the current language (as set by
AC_LANG
) on a stack, and then select the language. Use this macro andAC_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 1, the macros
AC_LANG_PUSH
andAC_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 withAC_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 eitherAC_PROG_CPP
orAC_PROG_CXXCPP
, depending on which language is current.
[1] Because M4 is not aware of Sh code, especially conditionals, some optimizations that look nice statically may produce incorrect results at runtime.