diff m4/acinclude.m4 @ 15134:edae65062740

build: Move unordered_map header tests to acinclude.m4 and add caching of results. * configure.ac: Remove unordered_map header tests * m4/acinclude.m4: New OCTAVE_UNORDERED_MAP_HEADERS macro which checks and caches results of undordered_map and tr1_namespace checks.
author Rik <rik@octave.org>
date Thu, 09 Aug 2012 08:29:50 -0700
parents f91eac1bc66d
children 4388f6518440
line wrap: on
line diff
--- a/m4/acinclude.m4
+++ b/m4/acinclude.m4
@@ -73,6 +73,34 @@
 AC_SUBST(ARFLAGS)
 ])
 dnl
+dnl Check for unordered map headers and whether tr1 namespace is
+dnl required.
+dnl
+AC_DEFUN([OCTAVE_UNORDERED_MAP_HEADERS], [
+AC_CHECK_HEADERS([unordered_map], [], [
+  AC_CHECK_HEADERS([tr1/unordered_map])])
+AC_CACHE_CHECK([whether unordered_map requires tr1 namespace],
+  [octave_cv_header_require_tr1_namespace],
+  [AC_LANG_PUSH(C++)
+  octave_cv_header_require_tr1_namespace=no
+  if test "$ac_cv_header_unordered_map" = "yes"; then
+    ## Have <unordered_map>, but still have to check whether
+    ## tr1 namespace is required (like MSVC, for instance).
+    AC_COMPILE_IFELSE([
+      AC_LANG_PROGRAM([
+        #include <unordered_map>
+      ], [
+        std::unordered_map<int,int> m;
+      ])], octave_cv_header_require_tr1_namespace=no, octave_cv_header_require_tr1_namespace=yes)
+  elif test "$ac_cv_header_tr1_unordered_map" = "yes"; then
+    octave_cv_header_require_tr1_namespace=yes
+  fi
+  AC_LANG_POP(C++)])
+  if test "$octave_cv_header_require_tr1_namespace" = "yes"; then
+    AC_DEFINE(USE_UNORDERED_MAP_WITH_TR1, 1, [Define to 1 if unordered_map requires the use of tr1 namespace.])
+  fi
+])
+dnl
 dnl Check if the compiler supports placement delete.
 dnl
 AC_DEFUN([OCTAVE_PLACEMENT_DELETE],
@@ -122,7 +150,6 @@
 fi
 AC_LANG_POP(C++)
 ])
-
 dnl
 dnl Check if the C++ library has functions to set real and imaginary
 dnl parts of complex numbers independently.