From 3fd22b7b86ebad8fbd4b66da3d63e6d9c1ca829c Mon Sep 17 00:00:00 2001
From: Boris Kolpackov <boris@codesynthesis.com>
Date: Mon, 13 Dec 2010 11:38:49 +0200
Subject: Detect TR1 <memory> availability

Also use the wrapper header from libodb.
---
 common/inverse/makefile               |  3 +--
 common/inverse/test.hxx               |  7 +++++-
 common/inverse/tr1-memory.hxx         | 41 -----------------------------------
 common/lazy-ptr/test.hxx              |  7 +++---
 common/lazy-ptr/tr1-memory.hxx        | 41 -----------------------------------
 common/relationship/makefile          |  3 +--
 common/relationship/test.hxx          |  7 +++++-
 common/relationship/tr1-memory.hxx    | 41 -----------------------------------
 common/template/Makefile.am           |  3 ++-
 common/template/template-vc10.vcxproj | 12 +++++-----
 common/template/template-vc9.vcproj   | 10 ++++-----
 11 files changed, 31 insertions(+), 144 deletions(-)
 delete mode 100644 common/inverse/tr1-memory.hxx
 delete mode 100644 common/lazy-ptr/tr1-memory.hxx
 delete mode 100644 common/relationship/tr1-memory.hxx

(limited to 'common')

diff --git a/common/inverse/makefile b/common/inverse/makefile
index b7480fc..05871d1 100644
--- a/common/inverse/makefile
+++ b/common/inverse/makefile
@@ -53,13 +53,12 @@ name := $(notdir $(src_base))
 $(dist): db_id := @database@
 $(dist): sources := $(cxx_tun)
 $(dist): headers := $(odb_hdr)
-$(dist): export extra_headers := tr1-memory.hxx
 $(dist): data_dist := test.std
 $(dist): export name := $(name)
 $(dist): export extra_dist := $(data_dist) $(call vc9projs,$(name)) \
 $(call vc10projs,$(name))
 $(dist):
-	$(call dist-data,$(sources) $(headers) $(extra_headers) $(data_dist))
+	$(call dist-data,$(sources) $(headers) $(data_dist))
 	$(call meta-automake,../template/Makefile.am)
 	$(call meta-vc9projs,../template/template,$(name))
 	$(call meta-vc10projs,../template/template,$(name))
diff --git a/common/inverse/test.hxx b/common/inverse/test.hxx
index e57cb78..7dcb17e 100644
--- a/common/inverse/test.hxx
+++ b/common/inverse/test.hxx
@@ -6,14 +6,19 @@
 #ifndef TEST_HXX
 #define TEST_HXX
 
+#include <common/config.hxx> // HAVE_TR1_MEMORY
+
 #include <set>
 #include <vector>
 #include <string>
 #include <memory>
-#include "tr1-memory.hxx"
 
 #include <odb/core.hxx>
 
+#ifdef HAVE_TR1_MEMORY
+#  include <odb/tr1/memory.hxx>
+#endif
+
 struct obj1;
 struct obj2;
 struct obj3;
diff --git a/common/inverse/tr1-memory.hxx b/common/inverse/tr1-memory.hxx
deleted file mode 100644
index 44d369a..0000000
--- a/common/inverse/tr1-memory.hxx
+++ /dev/null
@@ -1,41 +0,0 @@
-// file      : common/inverse/tr1-memory.hxx
-// author    : Boris Kolpackov <boris@codesynthesis.com>
-// copyright : not copyrighted - public domain
-
-#ifndef TR1_MEMORY_HXX
-#define TR1_MEMORY_HXX
-
-//@@ tmp
-#define HAVE_TR1_MEMORY
-
-//
-// Try to include TR1 <memory> in a compiler-specific manner. Fall-back
-// on the Boost TR1 implementation if the compiler does not support TR1.
-//
-
-#include <cstddef> // __GLIBCXX__, _HAS_TR1
-
-// GNU C++ or Intel C++ using libstd++.
-//
-#if defined (__GNUC__) && __GNUC__ >= 4 && defined (__GLIBCXX__)
-#  include <tr1/memory>
-//
-// IBM XL C++.
-//
-#elif defined (__xlC__) && __xlC__ >= 0x0900
-#  define __IBMCPP_TR1__
-#  include <memory>
-//
-// VC++ or Intel C++ using VC++ standard library.
-//
-#elif defined (_MSC_VER) && \
-  (_MSC_VER == 1500 && defined (_HAS_TR1) || _MSC_VER > 1500)
-#  include <memory>
-//
-// Boost fall-back.
-//
-#else
-#  include <boost/tr1/memory.hpp>
-#endif
-
-#endif // TR1_MEMORY_HXX
diff --git a/common/lazy-ptr/test.hxx b/common/lazy-ptr/test.hxx
index 8b75c46..9c671c1 100644
--- a/common/lazy-ptr/test.hxx
+++ b/common/lazy-ptr/test.hxx
@@ -6,17 +6,18 @@
 #ifndef TEST_HXX
 #define TEST_HXX
 
+#include <common/config.hxx> // HAVE_TR1_MEMORY
+
 #include <vector>
 #include <string>
 #include <memory>
 
-#include "tr1-memory.hxx"
-
 #include <odb/core.hxx>
 #include <odb/lazy-ptr.hxx>
 
 #ifdef HAVE_TR1_MEMORY
-#include <odb/tr1/lazy-ptr.hxx>
+#  include <odb/tr1/memory.hxx>
+#  include <odb/tr1/lazy-ptr.hxx>
 #endif
 
 // Raw pointer.
diff --git a/common/lazy-ptr/tr1-memory.hxx b/common/lazy-ptr/tr1-memory.hxx
deleted file mode 100644
index 8965861..0000000
--- a/common/lazy-ptr/tr1-memory.hxx
+++ /dev/null
@@ -1,41 +0,0 @@
-// file      : common/lazy-ptr/tr1-memory.hxx
-// author    : Boris Kolpackov <boris@codesynthesis.com>
-// copyright : not copyrighted - public domain
-
-#ifndef TR1_MEMORY_HXX
-#define TR1_MEMORY_HXX
-
-//@@ tmp
-#define HAVE_TR1_MEMORY
-
-//
-// Try to include TR1 <memory> in a compiler-specific manner. Fall-back
-// on the Boost TR1 implementation if the compiler does not support TR1.
-//
-
-#include <cstddef> // __GLIBCXX__, _HAS_TR1
-
-// GNU C++ or Intel C++ using libstd++.
-//
-#if defined (__GNUC__) && __GNUC__ >= 4 && defined (__GLIBCXX__)
-#  include <tr1/memory>
-//
-// IBM XL C++.
-//
-#elif defined (__xlC__) && __xlC__ >= 0x0900
-#  define __IBMCPP_TR1__
-#  include <memory>
-//
-// VC++ or Intel C++ using VC++ standard library.
-//
-#elif defined (_MSC_VER) && \
-  (_MSC_VER == 1500 && defined (_HAS_TR1) || _MSC_VER > 1500)
-#  include <memory>
-//
-// Boost fall-back.
-//
-#else
-#  include <boost/tr1/memory.hpp>
-#endif
-
-#endif // TR1_MEMORY_HXX
diff --git a/common/relationship/makefile b/common/relationship/makefile
index 7ed60cf..36c3c48 100644
--- a/common/relationship/makefile
+++ b/common/relationship/makefile
@@ -53,13 +53,12 @@ name := $(notdir $(src_base))
 $(dist): db_id := @database@
 $(dist): sources := $(cxx_tun)
 $(dist): headers := $(odb_hdr)
-$(dist): export extra_headers := tr1-memory.hxx
 $(dist): data_dist := test.std
 $(dist): export name := $(name)
 $(dist): export extra_dist := $(data_dist) $(call vc9projs,$(name)) \
 $(call vc10projs,$(name))
 $(dist):
-	$(call dist-data,$(sources) $(headers) $(extra_headers) $(data_dist))
+	$(call dist-data,$(sources) $(headers) $(data_dist))
 	$(call meta-automake,../template/Makefile.am)
 	$(call meta-vc9projs,../template/template,$(name))
 	$(call meta-vc10projs,../template/template,$(name))
diff --git a/common/relationship/test.hxx b/common/relationship/test.hxx
index cafdc99..486c417 100644
--- a/common/relationship/test.hxx
+++ b/common/relationship/test.hxx
@@ -6,15 +6,20 @@
 #ifndef TEST_HXX
 #define TEST_HXX
 
+#include <common/config.hxx> // HAVE_TR1_MEMORY
+
 #include <set>
 #include <map>
 #include <vector>
 #include <string>
 #include <memory>
-#include "tr1-memory.hxx"
 
 #include <odb/core.hxx>
 
+#ifdef HAVE_TR1_MEMORY
+#  include <odb/tr1/memory.hxx>
+#endif
+
 // Raw pointer.
 //
 #pragma db object pointer(obj1*)
diff --git a/common/relationship/tr1-memory.hxx b/common/relationship/tr1-memory.hxx
deleted file mode 100644
index a4ce28a..0000000
--- a/common/relationship/tr1-memory.hxx
+++ /dev/null
@@ -1,41 +0,0 @@
-// file      : common/relationship/tr1-memory.hxx
-// author    : Boris Kolpackov <boris@codesynthesis.com>
-// copyright : not copyrighted - public domain
-
-#ifndef TR1_MEMORY_HXX
-#define TR1_MEMORY_HXX
-
-//@@ tmp
-#define HAVE_TR1_MEMORY
-
-//
-// Try to include TR1 <memory> in a compiler-specific manner. Fall-back
-// on the Boost TR1 implementation if the compiler does not support TR1.
-//
-
-#include <cstddef> // __GLIBCXX__, _HAS_TR1
-
-// GNU C++ or Intel C++ using libstd++.
-//
-#if defined (__GNUC__) && __GNUC__ >= 4 && defined (__GLIBCXX__)
-#  include <tr1/memory>
-//
-// IBM XL C++.
-//
-#elif defined (__xlC__) && __xlC__ >= 0x0900
-#  define __IBMCPP_TR1__
-#  include <memory>
-//
-// VC++ or Intel C++ using VC++ standard library.
-//
-#elif defined (_MSC_VER) && \
-  (_MSC_VER == 1500 && defined (_HAS_TR1) || _MSC_VER > 1500)
-#  include <memory>
-//
-// Boost fall-back.
-//
-#else
-#  include <boost/tr1/memory.hpp>
-#endif
-
-#endif // TR1_MEMORY_HXX
diff --git a/common/template/Makefile.am b/common/template/Makefile.am
index 7338a85..a51fddf 100644
--- a/common/template/Makefile.am
+++ b/common/template/Makefile.am
@@ -22,6 +22,7 @@ CLEANFILES = test-odb.hxx test-odb.ixx test-odb.cxx
 
 ODB = @ODB@
 ODBFLAGS = @ODBFLAGS@
+ODBCPPFLAGS = @ODBCPPFLAGS@
 
 test-odb.hxx: test.hxx
-	$(ODB) $(ODBCPPFLAGS) $(CPPFLAGS) $(ODBFLAGS)  __value__(odb_options) $<
+	$(ODB) $(AM_CPPFLAGS) $(ODBCPPFLAGS) $(CPPFLAGS) $(ODBFLAGS)  __value__(odb_options) $<
diff --git a/common/template/template-vc10.vcxproj b/common/template/template-vc10.vcxproj
index e2950f9..e49d337 100644
--- a/common/template/template-vc10.vcxproj
+++ b/common/template/template-vc10.vcxproj
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="utf-8"?>
+<?xml version="1.0" encoding="utf-8"?>
 <Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
   <ItemGroup Label="ProjectConfigurations">
     <ProjectConfiguration Include="Debug|Win32">
@@ -88,7 +88,7 @@
       </PrecompiledHeader>
       <WarningLevel>Level3</WarningLevel>
       <Optimization>Disabled</Optimization>
-      <PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+      <PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions)</PreprocessorDefinitions>
       <AdditionalIncludeDirectories>..\..\libcommon</AdditionalIncludeDirectories>
       <DisableSpecificWarnings>4068;4355;4800;4290;%(DisableSpecificWarnings)</DisableSpecificWarnings>
     </ClCompile>
@@ -104,7 +104,7 @@
       </PrecompiledHeader>
       <WarningLevel>Level3</WarningLevel>
       <Optimization>Disabled</Optimization>
-      <PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+      <PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions)</PreprocessorDefinitions>
       <AdditionalIncludeDirectories>..\..\libcommon</AdditionalIncludeDirectories>
       <DisableSpecificWarnings>4068;4355;4800;4290;%(DisableSpecificWarnings)</DisableSpecificWarnings>
     </ClCompile>
@@ -122,7 +122,7 @@
       <Optimization>MaxSpeed</Optimization>
       <FunctionLevelLinking>true</FunctionLevelLinking>
       <IntrinsicFunctions>true</IntrinsicFunctions>
-      <PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+      <PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions)</PreprocessorDefinitions>
       <AdditionalIncludeDirectories>..\..\libcommon</AdditionalIncludeDirectories>
       <DisableSpecificWarnings>4068;4355;4800;4290;%(DisableSpecificWarnings)</DisableSpecificWarnings>
     </ClCompile>
@@ -142,7 +142,7 @@
       <Optimization>MaxSpeed</Optimization>
       <FunctionLevelLinking>true</FunctionLevelLinking>
       <IntrinsicFunctions>true</IntrinsicFunctions>
-      <PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+      <PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions)</PreprocessorDefinitions>
       <AdditionalIncludeDirectories>..\..\libcommon</AdditionalIncludeDirectories>
       <DisableSpecificWarnings>4068;4355;4800;4290;%(DisableSpecificWarnings)</DisableSpecificWarnings>
     </ClCompile>
@@ -158,7 +158,7 @@
 __custom_build_entry__(
 test.hxx,
 odb test.hxx,
-odb.exe __xml__(__shell_quotes__(m4_patsubst(__value__(odb_options), @database@, __value__(database)))) test.hxx,
+odb.exe __xml__(__shell_quotes__(m4_patsubst(__value__(odb_options), @database@, __value__(database)) -DHAVE_CONFIG_VC_H -I..\..\libcommon)) test.hxx,
 test-odb.hxx;test-odb.ixx;test-odb.cxx)
   </ItemGroup>
   <ItemGroup>
diff --git a/common/template/template-vc9.vcproj b/common/template/template-vc9.vcproj
index cc6d9cd..d6dbd3b 100644
--- a/common/template/template-vc9.vcproj
+++ b/common/template/template-vc9.vcproj
@@ -46,7 +46,7 @@
 				AdditionalOptions="/wd4068 /wd4355 /wd4800 /wd4290"
 				Optimization="0"
 				AdditionalIncludeDirectories="..\..\libcommon"
-				PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
+				PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;HAVE_CONFIG_VC_H"
 				MinimalRebuild="true"
 				BasicRuntimeChecks="3"
 				RuntimeLibrary="3"
@@ -123,7 +123,7 @@
 				Optimization="2"
 				EnableIntrinsicFunctions="true"
 				AdditionalIncludeDirectories="..\..\libcommon"
-				PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
+				PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;HAVE_CONFIG_VC_H"
 				RuntimeLibrary="2"
 				EnableFunctionLevelLinking="true"
 				UsePrecompiledHeader="0"
@@ -200,7 +200,7 @@
 				AdditionalOptions="/wd4068 /wd4355 /wd4800 /wd4290"
 				Optimization="0"
 				AdditionalIncludeDirectories="..\..\libcommon"
-				PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
+				PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;HAVE_CONFIG_VC_H"
 				MinimalRebuild="true"
 				BasicRuntimeChecks="3"
 				RuntimeLibrary="3"
@@ -278,7 +278,7 @@
 				Optimization="2"
 				EnableIntrinsicFunctions="true"
 				AdditionalIncludeDirectories="..\..\libcommon"
-				PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
+				PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;HAVE_CONFIG_VC_H"
 				RuntimeLibrary="2"
 				EnableFunctionLevelLinking="true"
 				UsePrecompiledHeader="0"
@@ -348,7 +348,7 @@ __source_entries__(extra_sources)
 __file_entry_custom_build__(
 test.hxx,
 odb test.hxx,
-odb.exe __xml__(__shell_quotes__(m4_patsubst(__value__(odb_options), @database@, __value__(database)))) test.hxx,
+odb.exe __xml__(__shell_quotes__(m4_patsubst(__value__(odb_options), @database@, __value__(database)) -DHAVE_CONFIG_VC_H -I..\..\libcommon)) test.hxx,
 test-odb.hxx;test-odb.ixx;test-odb.cxx)
 __file_entry__(test-odb.hxx)
 __file_entry__(test-odb.ixx)
-- 
cgit v1.1