我已經實現了一個小宏,它完成了工作(至少對我而言)。有了細微的變化也可用於其他無效緩存變量:
# SYNOPSIS
#
# AX_RESET_HEADERS_CACHE(headers ...)
#
# DESCRIPTION
#
# This macro invalidates the headers cache variables created by previous AC_CHECK_HEADER/AC_CHECK_HEADERS checks.
#
AC_DEFUN([AX_RESET_HEADERS_CACHE], [
AS_FOR([AX_var], [ax_var], [$1], [
dnl You can replace "ac_cv_header_" with any prefix from http://www.gnu.org/software/autoconf/manual/html_node/Cache-Variable-Index.html
AS_VAR_PUSHDEF([ax_Var], [ac_cv_header_${ax_var}])
AS_UNSET([ax_Var])
AS_VAR_POPDEF([ax_Var])
])
]) # AX_RESET_HEADERS_CACHE
和使用(在這個循環$ 1 =某些庫(如「NetPBM的」),$ 2 =標題(如「pbm.h ppm.h」 ),$ 3 =地址(例如「/ usr/include/usr/local/include」)):
for ac_test_location in $3
do
dnl Save the current state
ax_probe_library_save_CPPFLAGS=${CPPFLAGS}
CPPFLAGS="$CPPFLAGS -I${ac_test_location}"
AC_MSG_CHECKING([$1 for $2 in ${ac_test_location}])
AS_ECHO()
_AS_ECHO_LOG([CPPFLAGS="${CPPFLAGS}"])
AC_CHECK_HEADERS([$2], [ac_lib_$1=yes], [ac_lib_$1=no])
dnl We have found the location, leave the loop:
if test "${ac_lib_$1}" = "yes"
then
break;
fi
dnl Restore the state to original in case of unsuccessful attempt
CPPFLAGS=${ax_probe_library_save_CPPFLAGS}
AX_RESET_HEADERS_CACHE([$2])
done
沒有答案適合您? – 2011-10-10 21:59:20