aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--common/relationship/makefile1
-rw-r--r--configure.ac12
-rw-r--r--libcommon/common/config-vc.h6
-rw-r--r--libcommon/common/config.h.in1
-rw-r--r--libcommon/common/makefile11
-rw-r--r--m4/cxx11.m438
6 files changed, 64 insertions, 5 deletions
diff --git a/common/relationship/makefile b/common/relationship/makefile
index b6a8e94..f422860 100644
--- a/common/relationship/makefile
+++ b/common/relationship/makefile
@@ -98,6 +98,7 @@ $(call include,$(bld_root)/meta/vc9proj.make)
$(call include,$(bld_root)/meta/vc10proj.make)
$(call include,$(bld_root)/meta/automake.make)
+
$(call include,$(odb_rules))
$(call include,$(bld_root)/cxx/cxx-d.make)
$(call include,$(bld_root)/cxx/cxx-o.make)
diff --git a/configure.ac b/configure.ac
index 259551d..109b4cc 100644
--- a/configure.ac
+++ b/configure.ac
@@ -33,6 +33,14 @@ THREADS
AM_CONDITIONAL([ODB_TESTS_THREADS], [test x$threads != xnone])
+# Check for C++11.
+#
+CXX11([HAVE_CXX11], [Compiling in the C++11 mode.])
+
+# Check for TR1 <memory> availability.
+#
+TR1_MEMORY
+
# Check for the ODB compiler.
#
ODB_COMPILER([], [AC_MSG_ERROR([odb compiler is not found; consider setting ODB variable or using --with-odb=DIR])])
@@ -41,10 +49,6 @@ ODB_COMPILER([], [AC_MSG_ERROR([odb compiler is not found; consider setting ODB
#
LIBODB([], [AC_MSG_ERROR([libodb is not found; consider using --with-libodb=DIR])])
-# Check for TR1 <memory> availability.
-#
-TR1_MEMORY
-
# Check for boost.
#
odb_tests_boost=yes
diff --git a/libcommon/common/config-vc.h b/libcommon/common/config-vc.h
index 3c150cc..7031e35 100644
--- a/libcommon/common/config-vc.h
+++ b/libcommon/common/config-vc.h
@@ -10,4 +10,10 @@
#define HAVE_TR1_MEMORY
+/* VC++10 has C++11 always enabled.
+ */
+#if _MSC_VER >= 1600
+# define HAVE_CXX11
+#endif
+
#endif /* LIBCOMMON_COMMON_CONFIG_VC_H */
diff --git a/libcommon/common/config.h.in b/libcommon/common/config.h.in
index 4bce49a..ed600ac 100644
--- a/libcommon/common/config.h.in
+++ b/libcommon/common/config.h.in
@@ -14,6 +14,7 @@
#undef DATABASE_ORACLE
#undef DATABASE_MSSQL
#undef HAVE_TR1_MEMORY
+#undef HAVE_CXX11
#undef LIBCOMMON_STATIC_LIB
#endif /* LIBCOMMON_COMMON_CONFIG_H */
diff --git a/libcommon/common/makefile b/libcommon/common/makefile
index 63aaea9..0742caf 100644
--- a/libcommon/common/makefile
+++ b/libcommon/common/makefile
@@ -40,7 +40,11 @@ $(cxx_obj) $(cxx_od): $(common.l.cpp-options) $(out_base)/config.h
$(common.l.cpp-options): value := -I$(out_root)/libcommon -I$(src_root)/libcommon
$(common.l.cpp-options): $(odb_db.l.cpp-options) $(odb.l.cpp-options)
-$(out_base)/config.h: $(dcf_root)/configuration-dynamic.make | $(out_base)/.
+$(call include,$(bld_root)/cxx/standard.make) # cxx_standard
+
+ifdef db_id
+ifdef cxx_standard
+$(out_base)/config.h: | $(out_base)/.
@echo '/* file : libcommon/common/config.h' >$@
@echo ' * note : automatically generated' >>$@
@echo ' */' >>$@
@@ -59,9 +63,14 @@ else ifeq ($(db_id),oracle)
else ifeq ($(db_id),mssql)
@echo '#define DATABASE_MSSQL 1' >>$@
endif
+ifeq ($(cxx_standard),c++11)
+ @echo '#define HAVE_CXX11 1' >>$@
+endif
@echo '#define HAVE_TR1_MEMORY 1' >>$@
@echo '' >>$@
@echo '#endif /* LIBCOMMON_COMMON_CONFIG_H */' >>$@
+endif
+endif
$(call include-dep,$(cxx_od),$(cxx_obj),$(out_base)/config.h)
diff --git a/m4/cxx11.m4 b/m4/cxx11.m4
new file mode 100644
index 0000000..774f20d
--- /dev/null
+++ b/m4/cxx11.m4
@@ -0,0 +1,38 @@
+dnl file : m4/cxx11.m4
+dnl copyright : Copyright (c) 2009-2012 Code Synthesis Tools CC
+dnl license : GNU GPL v2; see accompanying LICENSE file
+dnl
+dnl CXX11(MACRO, DESCRIPTION)
+dnl
+dnl Check if we are compiling in the C++11 mode. If we are, define MACRO as
+dnl both a macro and conditional as well as set the cxx11 variable to 'yes'.
+dnl
+AC_DEFUN([CXX11],
+[
+cxx11=no
+
+AC_MSG_CHECKING([whether we are in C++11 mode])
+
+CXX_LIBTOOL_LINK_IFELSE(
+AC_LANG_SOURCE([[
+#include <memory>
+
+int
+main ()
+{
+ std::shared_ptr<int> p (new int (10));
+ *p = 11;
+}
+]]),
+[cxx11=yes])
+
+if test x"$cxx11" = xyes; then
+ AC_MSG_RESULT([yes])
+ AC_DEFINE([$1], [1], [$2])
+else
+ AC_MSG_RESULT([no])
+fi
+
+AM_CONDITIONAL([$1], [test x$cxx11 = xyes])
+
+])dnl