dnl
dnl stl is a pain:
dnl someone decided to use namespaces
dnl
dnl MIPSpro Compiler: Version 7.2.1 on Irix 6.5
dnl wants "use namespace stl"
dnl As of 25-Jul-03 we NO LONGER support that.
dnl
dnl The standard seems to be "use namespace std"
dnl (supposedly gcc 3.0 works this way).
dnl
dnl As of gcc 3.2, using namespace std is REQUIRED,
dnl and not just for stl, but for streams and other standard C++ stuff.
dnl
dnl Sigh.
dnl
dnl


AC_LANG_SAVE
AC_LANG_CPLUSPLUS

cpp_namespace=no
stl_namespace=no

if test x$cpp_namespace = xno
then
	AC_MSG_CHECKING(if C++ libraries work without any namespace)
	AC_TRY_COMPILE(
	#include <iostream>
	,
		cout.fail();
	,
		AC_MSG_RESULT(yes)
		cpp_namespace="none"
	,
		AC_MSG_RESULT(no)
	)
fi
dnl
if test x$cpp_namespace = xno
then
	AC_MSG_CHECKING(if C++ libraries work with namespace std)
	AC_TRY_COMPILE(
	#include <iostream>
	using namespace std;
	,
		cout.fail();
	,
		AC_MSG_RESULT(yes)
		cpp_namespace=std
	,
		AC_MSG_RESULT(no)
	)
fi
dnl

dnl
dnl do same check for stl
dnl
if test x$stl_namespace = xno
then
	AC_MSG_CHECKING(if STL works without any namespace)
	AC_TRY_COMPILE(
	#include <list>
	,
		list<int> test;
	,
		AC_MSG_RESULT(yes)
		stl_namespace="none"
	,
		AC_MSG_RESULT(no)
	)
fi
dnl
if test x$stl_namespace = xno
then
	AC_MSG_CHECKING(if STL works with namespace std)
	AC_TRY_COMPILE(
	#include <list>
	using namespace std;
	,
		list<int> test;
	,
		AC_MSG_RESULT(yes)
		stl_namespace=std
	,
		AC_MSG_RESULT(no)
	)
fi
dnl
if test x$stl_namespace = xno
then
	AC_MSG_CHECKING(if STL works with namespace stl)
	AC_TRY_COMPILE(
	#include <list>
	using namespace stl;
	,
		list<int> test;
	,
		AC_MSG_RESULT(yes)
		stl_namespace=stl
	,
		AC_MSG_RESULT(no)
	)
fi


AC_LANG_RESTORE

AC_MSG_CHECKING(should use STL)
AC_ARG_ENABLE(stl,
	[--enable-stl		include code that needs the Standard Template Library],[
	enable_stl=$enableval
	AC_MSG_RESULT([user specified $enable_stl])
],[
if test x$stl_namespace = xno
then
	enable_stl=no
	AC_MSG_RESULT([no, couldn't find STL])
else
	if test x$stl_namespace != x$cpp_namespace
	then
		dnl Give up, too hard.
		dnl MIPS people can upgrade their compiler.
		enable_stl=no
		AC_MSG_RESULT([std/STL namespaces are too hard for your system, abandoning STL])
	else
		enable_stl=yes
		AC_MSG_RESULT([yes])
	fi
fi
])


if test x$enable_stl = xno
then
	V_STLOBJ=""
	V_NS_TCL_LIB_STL=""
else
	V_STLOBJ='$(OBJ_STL)'
	V_NS_TCL_LIB_STL='$(NS_TCL_LIB_STL)'
	AC_DEFINE(HAVE_STL)
fi
if test x$cpp_namespace != xnone
then
	AC_DEFINE(CPP_REQUIRES_NAMESPACE)
fi
CPP_NAMESPACE=$cpp_namespace
AC_SUBST(CPP_NAMESPACE)

dnl this also seems to require that the makefile include
dnl -DCPP_NAMESPACE=@CPP_NAMESPACE@ in the compilation flags :-(



