use AC_CACHE_CHECK instead of AC_MSG_CHECKING + check to avoid unnecessary checking for cached tests

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@43252 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2006-11-10 01:00:17 +00:00
parent 224d4f6d7c
commit d92b393c90

View File

@@ -2131,13 +2131,27 @@ if test "$wxUSE_STD_STRING" = "yes" -o "$wxUSE_STL" = "yes"; then
fi fi
dnl check if <string> declares std::[w]string dnl check if <string> declares std::[w]string
AC_MSG_CHECKING([for $std_string in <string>]) AC_CACHE_CHECK([for $std_string in <string>],
wx_cv_class_stdstring,
[
AC_TRY_COMPILE([#include <string>], AC_TRY_COMPILE([#include <string>],
[$std_string foo;], [$std_string foo;],
[AC_MSG_RESULT(yes) wx_cv_class_stdstring=yes,
AC_DEFINE(HAVE_STD_WSTRING)], wx_cv_class_stdstring=no
[AC_MSG_RESULT(no) )
AC_MSG_CHECKING([if std::basic_string<$char_type> works]) ]
)
if test "$wx_cv_class_stdstring" = yes; then
if test "$wxUSE_UNICODE" = "yes"; then
AC_DEFINE(HAVE_STD_WSTRING)
fi
dnl we don't need HAVE_STD_STRING, we just suppose it's available if
dnl wxUSE_STD_STRING==yes
else
AC_CACHE_CHECK([if std::basic_string<$char_type> works],
wx_cv_class_stdbasicstring,
[
AC_TRY_COMPILE([ AC_TRY_COMPILE([
#ifdef HAVE_WCHAR_H #ifdef HAVE_WCHAR_H
# ifdef __CYGWIN__ # ifdef __CYGWIN__
@@ -2153,8 +2167,13 @@ if test "$wxUSE_STD_STRING" = "yes" -o "$wxUSE_STL" = "yes"; then
], ],
[std::basic_string<$char_type> foo; [std::basic_string<$char_type> foo;
const $char_type* dummy = foo.c_str();], const $char_type* dummy = foo.c_str();],
[AC_MSG_RESULT(yes)], wx_cv_class_stdbasicstring=yes,
[AC_MSG_RESULT([no]) wx_cv_class_stdbasicstring=no
)
]
)
if test "$wx_cv_class_stdbasicstring" != yes; then
if test "$wxUSE_STL" = "yes"; then if test "$wxUSE_STL" = "yes"; then
AC_MSG_ERROR([Can't use --enable-stl without $std_string or std::basic_string<$char_type>]) AC_MSG_ERROR([Can't use --enable-stl without $std_string or std::basic_string<$char_type>])
elif grep wxUSE_STD_STRING $wx_arg_cache_file >/dev/null; then elif grep wxUSE_STD_STRING $wx_arg_cache_file >/dev/null; then
@@ -2163,9 +2182,8 @@ if test "$wxUSE_STD_STRING" = "yes" -o "$wxUSE_STL" = "yes"; then
AC_MSG_WARN([No $std_string or std::basic_string<$char_type>, switching to --disable-std_string]) AC_MSG_WARN([No $std_string or std::basic_string<$char_type>, switching to --disable-std_string])
wxUSE_STD_STRING=no wxUSE_STD_STRING=no
fi fi
] fi
) fi
])
fi fi
if test "$wxUSE_STD_IOSTREAM" = "yes"; then if test "$wxUSE_STD_IOSTREAM" = "yes"; then
@@ -2184,8 +2202,9 @@ fi
if test "$wxUSE_STL" = "yes"; then if test "$wxUSE_STL" = "yes"; then
dnl check for basic STL functionality dnl check for basic STL functionality
AC_MSG_CHECKING([for basic STL functionality]) AC_CACHE_CHECK([for basic STL functionality],
AC_TRY_COMPILE([#include <string> wx_cv_lib_stl,
[AC_TRY_COMPILE([#include <string>
#include <functional> #include <functional>
#include <algorithm> #include <algorithm>
#include <vector> #include <vector>
@@ -2195,13 +2214,18 @@ if test "$wxUSE_STL" = "yes"; then
std::vector<int>::iterator it = std::vector<int>::iterator it =
std::find_if(moo.begin(), moo.end(), std::find_if(moo.begin(), moo.end(),
std::bind2nd(std::less<int>(), 3));], std::bind2nd(std::less<int>(), 3));],
[AC_MSG_RESULT([yes])], wx_cv_lib_stl=yes,
[AC_MSG_RESULT([no]) wx_cv_lib_stl=no,
AC_MSG_ERROR([Basic STL functionality missing])]) )
if test "$wx_cv_lib_stl" != yes; then
AC_MSG_ERROR([Can't use --enable-stl as basic STL functionality is missing])
fi
dnl check for compliant std::string::compare dnl check for compliant std::string::compare
AC_MSG_CHECKING([for compliant std::string::compare]) AC_CACHE_CHECK([for compliant std::string::compare],
AC_TRY_COMPILE([#include <string>], wx_cv_func_stdstring_compare,
[AC_TRY_COMPILE([#include <string>],
[std::string foo, bar; [std::string foo, bar;
foo.compare(bar); foo.compare(bar);
foo.compare(1, 1, bar); foo.compare(1, 1, bar);
@@ -2209,34 +2233,51 @@ if test "$wxUSE_STL" = "yes"; then
foo.compare(""); foo.compare("");
foo.compare(1, 1, ""); foo.compare(1, 1, "");
foo.compare(1, 1, "", 2);], foo.compare(1, 1, "", 2);],
[AC_MSG_RESULT(yes) wx_cv_func_stdstring_compare=yes,
AC_DEFINE(HAVE_STD_STRING_COMPARE)], wx_cv_func_stdstring_compare=no
[AC_MSG_RESULT(no)]) )]
)
if test "$wx_cv_func_stdstring_compare" = yes; then
AC_DEFINE(HAVE_STD_STRING_COMPARE)
fi
dnl check for hash_map and hash_set headers dnl check for hash_map and hash_set headers
AC_CHECK_HEADER([hash_map], AC_CHECK_HEADER([hash_map],
[AC_MSG_CHECKING([for hash_map and hash_set]) [AC_CACHE_CHECK([for standard hash_map and hash_set],
AC_TRY_COMPILE([#include <hash_map> wx_cv_class_stdhashmapset,
[AC_TRY_COMPILE([#include <hash_map>
#include <hash_set>], #include <hash_set>],
[std::hash_map<double*, char*, std::hash<double*>, std::equal_to<double*> > test1; [std::hash_map<double*, char*, std::hash<double*>, std::equal_to<double*> > test1;
std::hash_set<char*, std::hash<char*>, std::equal_to<char*> > test2;], std::hash_set<char*, std::hash<char*>, std::equal_to<char*> > test2;],
[AC_MSG_RESULT(yes) wx_cv_class_stdhashmapset=yes,
wx_cv_class_stdhashmapset=no)
]
)]
)
if test "$wx_cv_class_stdhashmapset" = yes; then
AC_DEFINE(HAVE_HASH_MAP) AC_DEFINE(HAVE_HASH_MAP)
AC_DEFINE(HAVE_STD_HASH_MAP)], AC_DEFINE(HAVE_STD_HASH_MAP)
[AC_MSG_RESULT(no)]) fi
])
AC_CHECK_HEADER([ext/hash_map], AC_CHECK_HEADER([ext/hash_map],
[AC_MSG_CHECKING([for hash_map and hash_set]) [AC_CACHE_CHECK([for GNU hash_map and hash_set],
AC_TRY_COMPILE([#include <ext/hash_map> wx_cv_class_gnuhashmapset,
[AC_TRY_COMPILE([#include <ext/hash_map>
#include <ext/hash_set>], #include <ext/hash_set>],
[__gnu_cxx::hash_map<double*, char*, __gnu_cxx::hash<double*>, std::equal_to<double*> > test1; [__gnu_cxx::hash_map<double*, char*, __gnu_cxx::hash<double*>, std::equal_to<double*> > test1;
__gnu_cxx::hash_set<char*, __gnu_cxx::hash<char*>, std::equal_to<char*> > test2;], __gnu_cxx::hash_set<char*, __gnu_cxx::hash<char*>, std::equal_to<char*> > test2;],
[AC_MSG_RESULT(yes) wx_cv_class_gnuhashmapset=yes,
wx_cv_class_gnuhashmapset=no)
]
)]
)
if test "$wx_cv_class_gnuhashmapset" = yes; then
AC_DEFINE(HAVE_EXT_HASH_MAP) AC_DEFINE(HAVE_EXT_HASH_MAP)
AC_DEFINE(HAVE_GNU_CXX_HASH_MAP)], AC_DEFINE(HAVE_GNU_CXX_HASH_MAP)
[AC_MSG_RESULT(no)]) fi
])
fi fi
dnl pop C++ dnl pop C++