ac_compiler_gnu=$ac_cv_c_compiler_gnu
-if test -n "$ac_ct_CXX"; then
+# Check if it actually found a C++ compiler.
+ac_ext=cpp
+ac_cpp='$CXXCPP $CPPFLAGS'
+ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
+
+
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+int
+main ()
+{
+
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_cxx_try_compile "$LINENO"; then :
have_cxx=yes
else
have_cxx=no
fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+
+
+if test "$have_cxx" = yes; then
+
+# Detect option needed for C++11
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $CXX option to accept ISO C++11" >&5
+$as_echo_n "checking for $CXX option to accept ISO C++11... " >&6; }
+if ${pgac_cv_prog_cxx_cxx11+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ pgac_cv_prog_cxx_cxx11=no
+pgac_save_CXX=$CXX
+ac_ext=cpp
+ac_cpp='$CXXCPP $CPPFLAGS'
+ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
+
+for pgac_arg in '' '-std=gnu++11' '-std=c++11'; do
+ CXX="$pgac_save_CXX $pgac_arg"
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+#if !defined __cplusplus || __cplusplus < 201103L
+# error "Compiler does not advertise C++11 conformance"
+#endif
+_ACEOF
+if ac_fn_cxx_try_compile "$LINENO"; then :
+ pgac_cv_prog_cxx_cxx11=$pgac_arg
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+ test x"$pgac_cv_prog_cxx_cxx11" != x"no" && break
+done
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+CXX=$pgac_save_CXX
+fi
+
+
+if test x"$pgac_cv_prog_cxx_cxx11" = x"no"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5
+$as_echo "unsupported" >&6; }
+ { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: C++ compiler \"$CXX\" does not support C++11" >&5
+$as_echo "$as_me: WARNING: C++ compiler \"$CXX\" does not support C++11" >&2;}
+ have_cxx=no
+elif test x"$pgac_cv_prog_cxx_cxx11" = x""; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: none needed" >&5
+$as_echo "none needed" >&6; }
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $pgac_cv_prog_cxx_cxx11" >&5
+$as_echo "$pgac_cv_prog_cxx_cxx11" >&6; }
+ CXX="$CXX $pgac_cv_prog_cxx_cxx11"
+fi
+
+fi # have_cxx
# Check if it's Intel's compiler, which (usually) pretends to be gcc,
_ACEOF
-
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for C++ printf format archetype" >&5
$as_echo_n "checking for C++ printf format archetype... " >&6; }
if ${pgac_cv_cxx_printf_archetype+:} false; then :
AC_PROG_CXX([$pgac_cxx_list])
-if test -n "$ac_ct_CXX"; then
- have_cxx=yes
-else
+# Check if it actually found a C++ compiler.
+AC_LANG_PUSH([C++])
+AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [])],
+ [have_cxx=yes],
+ [have_cxx=no])
+AC_LANG_POP([C++])
+AC_SUBST(have_cxx)
+
+if test "$have_cxx" = yes; then
+
+# Detect option needed for C++11
+AC_MSG_CHECKING([for $CXX option to accept ISO C++11])
+AC_CACHE_VAL([pgac_cv_prog_cxx_cxx11],
+[pgac_cv_prog_cxx_cxx11=no
+pgac_save_CXX=$CXX
+AC_LANG_PUSH([C++])
+for pgac_arg in '' '-std=gnu++11' '-std=c++11'; do
+ CXX="$pgac_save_CXX $pgac_arg"
+ AC_COMPILE_IFELSE([AC_LANG_SOURCE([[#if !defined __cplusplus || __cplusplus < 201103L
+# error "Compiler does not advertise C++11 conformance"
+#endif]])], [[pgac_cv_prog_cxx_cxx11=$pgac_arg]])
+ test x"$pgac_cv_prog_cxx_cxx11" != x"no" && break
+done
+AC_LANG_POP([C++])
+CXX=$pgac_save_CXX])
+
+if test x"$pgac_cv_prog_cxx_cxx11" = x"no"; then
+ AC_MSG_RESULT([unsupported])
+ AC_MSG_WARN([C++ compiler "$CXX" does not support C++11])
have_cxx=no
+elif test x"$pgac_cv_prog_cxx_cxx11" = x""; then
+ AC_MSG_RESULT([none needed])
+else
+ AC_MSG_RESULT([$pgac_cv_prog_cxx_cxx11])
+ CXX="$CXX $pgac_cv_prog_cxx_cxx11"
fi
-AC_SUBST(have_cxx)
+
+fi # have_cxx
+
# Check if it's Intel's compiler, which (usually) pretends to be gcc,
# but has idiosyncrasies of its own. We assume icc will define
endif
+# Do we need an option to enable C++11?
+cxx11_test = '''
+#if !defined __cplusplus || __cplusplus < 201103L
+# error "Compiler does not advertise C++11 conformance"
+#endif
+'''
+
+if have_cxx and not cxx.compiles(cxx11_test, name: 'C++11')
+ cxx11_ok = false
+ if cxx.get_id() == 'msvc'
+ cxx11_test_args = ['/std:c++14'] # oldest version supported
+ else
+ cxx11_test_args = ['-std=gnu++11', '-std=c++11']
+ endif
+ foreach arg : cxx11_test_args
+ if cxx.compiles(cxx11_test, name: 'C++11 with @0@'.format(arg), args: [arg])
+ cxx11_ok = true
+ cxxflags += arg
+ break
+ endif
+ endforeach
+ if not cxx11_ok
+ error('C++ compiler does not support C++11')
+ endif
+endif
+
+
postgres_inc = [include_directories(postgres_inc_d)]
test_lib_d = postgres_lib_d
test_c_args = cppflags + cflags