OLD | NEW |
(Empty) | |
| 1 # We check two things: where the include file is for |
| 2 # unordered_map/hash_map (we prefer the first form), and what |
| 3 # namespace unordered/hash_map lives in within that include file. We |
| 4 # include AC_TRY_COMPILE for all the combinations we've seen in the |
| 5 # wild. We define HASH_MAP_H to the location of the header file, and |
| 6 # HASH_NAMESPACE to the namespace the class (unordered_map or |
| 7 # hash_map) is in. We define HAVE_UNORDERED_MAP if the class we found |
| 8 # is named unordered_map, or leave it undefined if not. |
| 9 |
| 10 # This also checks if unordered map exists. |
| 11 AC_DEFUN([AC_CXX_STL_HASH], |
| 12 [ |
| 13 AC_MSG_CHECKING(the location of hash_map) |
| 14 AC_LANG_SAVE |
| 15 AC_LANG_CPLUSPLUS |
| 16 ac_cv_cxx_hash_map="" |
| 17 # First try unordered_map, but not on gcc's before 4.2 -- I've |
| 18 # seen unexplainable unordered_map bugs with -O2 on older gcc's. |
| 19 AC_TRY_COMPILE([#if defined(__GNUC__) && (__GNUC__ < 4 || (__GNUC__ == 4 && _
_GNUC_MINOR__ < 2)) |
| 20 # error GCC too old for unordered_map |
| 21 #endif |
| 22 ], |
| 23 [/* no program body necessary */], |
| 24 [stl_hash_old_gcc=no], |
| 25 [stl_hash_old_gcc=yes]) |
| 26 for location in unordered_map tr1/unordered_map; do |
| 27 for namespace in std std::tr1; do |
| 28 if test -z "$ac_cv_cxx_hash_map" -a "$stl_hash_old_gcc" != yes; then |
| 29 # Some older gcc's have a buggy tr1, so test a bit of code. |
| 30 AC_TRY_COMPILE([#include <$location>], |
| 31 [const ${namespace}::unordered_map<int, int> t; |
| 32 return t.find(5) == t.end();], |
| 33 [ac_cv_cxx_hash_map="<$location>"; |
| 34 ac_cv_cxx_hash_namespace="$namespace"; |
| 35 ac_cv_cxx_hash_map_class="unordered_map";]) |
| 36 fi |
| 37 done |
| 38 done |
| 39 # Now try hash_map |
| 40 for location in ext/hash_map hash_map; do |
| 41 for namespace in __gnu_cxx "" std stdext; do |
| 42 if test -z "$ac_cv_cxx_hash_map"; then |
| 43 AC_TRY_COMPILE([#include <$location>], |
| 44 [${namespace}::hash_map<int, int> t], |
| 45 [ac_cv_cxx_hash_map="<$location>"; |
| 46 ac_cv_cxx_hash_namespace="$namespace"; |
| 47 ac_cv_cxx_hash_map_class="hash_map";]) |
| 48 fi |
| 49 done |
| 50 done |
| 51 ac_cv_cxx_hash_set=`echo "$ac_cv_cxx_hash_map" | sed s/map/set/`; |
| 52 ac_cv_cxx_hash_set_class=`echo "$ac_cv_cxx_hash_map_class" | sed s/map/set/`; |
| 53 if test -n "$ac_cv_cxx_hash_map"; then |
| 54 AC_DEFINE(HAVE_HASH_MAP, 1, [define if the compiler has hash_map]) |
| 55 AC_DEFINE(HAVE_HASH_SET, 1, [define if the compiler has hash_set]) |
| 56 AC_DEFINE_UNQUOTED(HASH_MAP_H,$ac_cv_cxx_hash_map, |
| 57 [the location of <unordered_map> or <hash_map>]) |
| 58 AC_DEFINE_UNQUOTED(HASH_SET_H,$ac_cv_cxx_hash_set, |
| 59 [the location of <unordered_set> or <hash_set>]) |
| 60 AC_DEFINE_UNQUOTED(HASH_NAMESPACE,$ac_cv_cxx_hash_namespace, |
| 61 [the namespace of hash_map/hash_set]) |
| 62 AC_DEFINE_UNQUOTED(HASH_MAP_CLASS,$ac_cv_cxx_hash_map_class, |
| 63 [the name of <hash_map>]) |
| 64 AC_DEFINE_UNQUOTED(HASH_SET_CLASS,$ac_cv_cxx_hash_set_class, |
| 65 [the name of <hash_set>]) |
| 66 AC_MSG_RESULT([$ac_cv_cxx_hash_map]) |
| 67 else |
| 68 AC_MSG_RESULT() |
| 69 AC_MSG_WARN([could not find an STL hash_map]) |
| 70 fi |
| 71 ]) |
| 72 |
OLD | NEW |