Counter Strike : Global Offensive Source Code
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

72 lines
3.3 KiB

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