|
23.4.3 Caching resultsAutoconf provides a caching facility, whereby the results of a test may be stored in a cache file. The cache file is itself a Bourne shell script which is sourced by the `configure' script to set any `cache variables' to values that are present in the cache file. The next time `configure' is run, the cache will be consulted for a prior result. If there is a prior result, the value is re-used and the code that performs that test is skipped. This speeds up subsequent runs of `configure' and configuration of deep trees, which can share a cache file in the top-level directory (see section 3. How to run configure and make). A custom macro is not required to do caching, though it is considered best practice. Sometimes it doesn't make sense for a macro to do caching--tests for system aspects which may frequently change should not be cached. For example, a test for free disk space should not employ caching as it is a dynamic characteristic. The `AC_CACHE_CHECK' macro is a convient wrapper for caching the results of tests. You simply provide a description of the test, the name of a cache variable to store the test result to, and the body of the test. If the test has not been run before, the cache will be primed with the result. If the result is already in the cache, then the cache variable will be set and the test will be skipped. Note that the name of the cache variable must contain `_cv_' in order to be saved correctly. Here is the code for an Autoconf macro that ties together many of the concepts introduced in this chapter:
|