~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to m4/shared_ptr.m4

  • Committer: Monty Taylor
  • Date: 2009-03-09 20:27:13 UTC
  • mto: (923.2.1 mordred)
  • mto: This revision was merged to the branch mainline in revision 928.
  • Revision ID: mtaylor@orisndriz05-20090309202713-uoubacswdcs20kg5
Added check for shared_ptr in advance of actually thinking about using it. I think this should cover all platforms we care about... but let's doublecheck.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# We check two things: where is the memory include file, and in what
 
2
# namespace does shared_ptr reside.
 
3
# We include AC_COMPILE_IFELSE for all the combinations we've seen in the
 
4
# wild:
 
5
 
6
#  GCC 4.3: namespace: std::  #include <memory>
 
7
#  GCC 4.2: namespace: tr1::  #include <tr1/memory>
 
8
#  GCC 4.2: namespace: boost::  #include <boost/shared_ptr.hpp>
 
9
#
 
10
# We define one of HAVE_HAVE_TR1_SHARED_PTR or HAVE_BOOST_SHARED_PTR
 
11
# depending on location, and SHARED_PTR_NAMESPACE to be the namespace in
 
12
# which shared_ptr is defined.
 
13
#
 
14
 
 
15
AC_DEFUN([AC_CXX_SHARED_PTR],[
 
16
  AC_REQUIRE([AC_CXX_CHECK_STANDARD])
 
17
  AC_LANG_PUSH(C++)
 
18
  AC_CHECK_HEADERS(memory tr1/memory boost/shared_ptr.hpp)
 
19
  AC_CACHE_CHECK([the location of shared_ptr header file],
 
20
    [ac_cv_shared_ptr_h],[
 
21
      for namespace in std tr1 boost
 
22
      do
 
23
        AC_COMPILE_IFELSE(
 
24
          [AC_LANG_PROGRAM([[
 
25
#if defined(HAVE_MEMORY) || defined(HAVE_TR1_MEMORY)
 
26
# if defined(HAVE_MEMORY)
 
27
#  include <memory>
 
28
# endif
 
29
# if defined(HAVE_TR1_MEMORY)
 
30
#  include <tr1/memory>
 
31
# endif
 
32
#else
 
33
# if defined(HAVE_BOOST_SHARED_PTR_HPP)
 
34
#  include <boost/shared_ptr.hpp>
 
35
# endif
 
36
#endif
 
37
#include <string>
 
38
 
 
39
using $namespace::shared_ptr;
 
40
using namespace std;
 
41
            ]],[[
 
42
shared_ptr<string> test_ptr(new string("test string"));
 
43
            ]])],
 
44
            [
 
45
              ac_cv_shared_ptr_namespace="${namespace}"
 
46
              break
 
47
            ],[ac_cv_shared_ptr_namespace=no])
 
48
       done
 
49
  ])
 
50
  if test "$ac_cv_shared_ptr_namespace" = no
 
51
  then
 
52
    AC_MSG_ERROR([a usable shared_ptr implementation is required. If you are on Solaris, please install boost, either via pkg install boost, or pkg-get -i boost. If you are elsewhere, please file a bug])
 
53
  fi
 
54
  AC_DEFINE_UNQUOTED([SHARED_PTR_NAMESPACE],
 
55
                     ${ac_cv_shared_ptr_namespace},
 
56
                     [The namespace in which SHARED_PTR can be found])
 
57
  AC_LANG_POP()
 
58
])