Autoconf provides a set of macros that can be used to generate test source files. They are written to be language generic, i.e., they actually depend on the current language (*note Language Choice::) to "format" the output properly.
- Macro: AC_LANG_CONFTEST (SOURCE)
Save the SOURCE text in the current test source file:
`conftest.EXTENSION' where the EXTENSION depends on the current
language.
Note that the SOURCE is evaluated exactly once, like regular
Autoconf macro arguments, and therefore (i) you may pass a macro
invocation, (ii) if not, be sure to double quote if needed.
- Macro: AC_LANG_SOURCE (SOURCE)
Expands into the SOURCE, with the definition of all the
`AC_DEFINE' performed so far.
For instance executing (observe the double quotation!):
AC_INIT(Autoconf Documentation, 2.59, bug-autoconf@gnu.org)
AC_DEFINE([HELLO_WORLD], ["Hello, World\n"])
AC_LANG_CONFTEST(
[AC_LANG_SOURCE([[const char hw[] = "Hello, World\n";]])])
gcc -E -dD conftest.c -o -
results in:
# 1 "conftest.c"
# 1169 "configure"
# 1 "confdefs.h" 1
#define PACKAGE_NAME "Autoconf Documentation"
#define PACKAGE_TARNAME "autoconf-documentation"
#define PACKAGE_VERSION "2.59"
#define PACKAGE_STRING "Autoconf Documentation 2.59"
#define PACKAGE_BUGREPORT "bug-autoconf@gnu.org"
#define HELLO_WORLD "Hello, World\n"
# 1170 "configure" 2
const char hw[] = "Hello, World\n";
- Macro: AC_LANG_PROGRAM (PROLOGUE, BODY)
Expands into a source file which consists of the PROLOGUE, and
then BODY as body of the main function (e.g., `main' in C). Since
it uses `AC_LANG_SOURCE', the feature of the latter are available.
For instance:
AC_INIT(Autoconf Documentation, 2.59, bug-autoconf@gnu.org)
AC_DEFINE([HELLO_WORLD], ["Hello, World\n"])
AC_LANG_CONFTEST(
[AC_LANG_PROGRAM([[const char hw[] = "Hello, World\n";]],
[[fputs (hw, stdout);]])])
gcc -E -dD conftest.c -o -
results in:
# 1 "conftest.c"
# 1169 "configure"
# 1 "confdefs.h" 1
#define PACKAGE_NAME "Autoconf Documentation"
#define PACKAGE_TARNAME "autoconf-documentation"
#define PACKAGE_VERSION "2.59"
#define PACKAGE_STRING "Autoconf Documentation 2.59"
#define PACKAGE_BUGREPORT "bug-autoconf@gnu.org"
#define HELLO_WORLD "Hello, World\n"
# 1170 "configure" 2
const char hw[] = "Hello, World\n";
int
main ()
{
fputs (hw, stdout);
;
return 0;
}
- Macro: AC_LANG_CALL (PROLOGUE, FUNCTION)
Expands into a source file which consists of the PROLOGUE, and
then a call to the FUNCTION as body of the main function (e.g.,
`main' in C). Since it uses `AC_LANG_PROGRAMS', the feature of
the latter are available.
This function will probably be replaced in the future by a version
which would enable specifying the arguments. The use of this
macro is not encouraged, as it violates strongly the typing system.
- Macro: AC_LANG_FUNC_LINK_TRY (FUNCTION)
Expands into a source file which consists of a pseudo use of the
FUNCTION as body of the main function (e.g., `main' in C): a
simple (function pointer) assignment. Since it uses
`AC_LANG_PROGRAMS', the feature of the latter are available.
As `AC_LANG_CALL', this macro is documented only for completeness.
It is considered to be severely broken, and in the future will be
removed in favor of actual function calls (with properly typed
arguments).
Created Mon Nov 8 17:41:57 2004 on tillpc with info_to_html version 0.9.6.