[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
Sometimes you need to find out how a system performs at run time, such as whether a given function has a certain capability or bug. If you can, make such checks when your program runs instead of when it is configured. You can check for things like the machine's endianness when your program initializes itself.
If you really need to test for a run-time behavior while configuring,
you can write a test program to determine the result, and compile and
run it using AC_RUN_IFELSE
. Avoid running test programs if
possible, because this prevents people from configuring your package for
cross-compiling.
The input can be made by AC_LANG_PROGRAM
and friends. This
macro uses CFLAGS
or CXXFLAGS
, CPPFLAGS
,
LDFLAGS
, and LIBS
If the compiler being used does not produce executables that run on the
system where configure
is being run, then the test program is
not run. If the optional shell commands action-if-cross-compiling
are given, they are run instead. Otherwise, configure
prints
an error message and exits.
In the action-if-false section, the exit status of the program is available in the shell variable `$?', but be very careful to limit yourself to positive values smaller than 127; bigger values should be saved into a file by the program. Note also that you have simply no guarantee that this exit status is issued by the program, or by the failure of its compilation. In other words, use this feature if sadist only, it was reestablished because the Autoconf maintainers grew tired of receiving "bug reports".
It is customary to report unexpected failures with
AC_MSG_FAILURE
.
Try to provide a pessimistic default value to use when cross-compiling
makes run-time tests impossible. You do this by passing the optional
last argument to AC_RUN_IFELSE
. autoconf
prints a
warning message when creating configure
each time it
encounters a call to AC_RUN_IFELSE
with no
action-if-cross-compiling argument given. You may ignore the
warning, though users will not be able to configure your package for
cross-compiling. A few of the macros distributed with Autoconf produce
this warning message.
To configure for cross-compiling you can also choose a value for those parameters based on the canonical system name (see section 11. Manual Configuration). Alternatively, set up a test results cache file with the correct values for the host system (see section 7.3 Caching Results).
To provide a default for calls of AC_RUN_IFELSE
that are embedded
in other macros, including a few of the ones that come with Autoconf,
you can test whether the shell variable cross_compiling
is set to
`yes', and then use an alternate method to get the results instead
of calling the macros.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |