Feb
2
2010
Defeating the AC_CHECK_HEADER cache
The AC_CHECK_HEADER macro caches its result, so if you want to call it again with a different CPPFLAGS it will just remember the result of the first execution.
If you want to defeat this cache, as I did, this is the pattern:
header=foo.h
cache_var=AS_TR_SH([ac_cv_header_$header])
...
AC_CHECK_HEADER([$header])
...
CPPFLAGS="-I/opt/local/include"
$as_unset $cache_var
AC_CHECK_HEADER([$header])
...
AS_TR_SH does the escaping (giving ac_cv_header_foo_h in this case), $as_unset is the portable way to unset a shell variable in autotools.
Incidentally, if you don’t restore CPPFLAGS to its original user-set value, I will hunt you down and shave your head.