#note vec.cc has been replaced by vec-cxx.cc due to object filename clash

SUPCXX=	\
	array_type_info.cc \
	atexit_arm.cc \
	bad_alloc.cc \
	bad_cast.cc \
	bad_typeid.cc \
	class_type_info.cc \
	del_op.cc \
	del_opnt.cc \
	del_opv.cc \
	del_opvnt.cc \
	dyncast.cc \
	eh_alloc.cc \
	eh_arm.cc \
	eh_aux_runtime.cc \
	eh_call.cc \
	eh_catch.cc \
	eh_exception.cc \
	eh_globals.cc \
	eh_personality.cc \
	eh_ptr.cc \
	eh_term_handler.cc \
	eh_terminate.cc \
	eh_tm.cc \
	eh_throw.cc \
	eh_type.cc \
	eh_unex_handler.cc \
	enum_type_info.cc \
	function_type_info.cc \
	fundamental_type_info.cc \
	guard.cc \
	guard_error.cc \
	hash_bytes.cc \
	nested_exception.cc \
	new_handler.cc \
	new_op.cc \
	new_opnt.cc \
	new_opv.cc \
	new_opvnt.cc \
	pbase_type_info.cc \
	pmem_type_info.cc \
	pointer_type_info.cc \
	pure.cc \
	si_class_type_info.cc \
	tinfo.cc \
	tinfo2.cc \
	vec-cxx.cc \
	vmi_class_type_info.cc \
	vterminate.cc

gthr.h: ${GCCDIR}/libgcc/gthr.h
	sed -e '/^#pragma/b' \
    	-e '/^#/s/\([ABCDEFGHIJKLMNOPQRSTUVWXYZ_][ABCDEFGHIJKLMNOPQRSTUVWXYZ_]*\)/_GLIBCXX_\1/g' \
    	-e 's/_GLIBCXX_SUPPORTS_WEAK/__GXX_WEAK__/g' \
    	-e 's,^#include "\(.*\)",#include <bits/\1>,g' \
    	< ${GCCDIR}/libgcc/gthr.h > ${.TARGET}

gthr-default.h: ${GCCDIR}/libgcc/gthr-posix.h
	sed -e 's/\(UNUSED\)/_GLIBCXX_\1/g' \
	    -e 's/\(GCC[ABCDEFGHIJKLMNOPQRSTUVWXYZ_]*_H\)/_GLIBCXX_\1/g' \
	    -e 's/SUPPORTS_WEAK/__GXX_WEAK__/g' \
	    -e 's/\([ABCDEFGHIJKLMNOPQRSTUVWXYZ_]*USE_WEAK\)/_GLIBCXX_\1/g' \
	    < ${GCCDIR}/libgcc/gthr-posix.h > ${.TARGET}

CXX_CONFIG_H = ${.CURDIR}/../libstdc++/config.h
ns_version=0
visibility=1
externtemplate=1
SUBST1='s,define __GLIBCXX__,define __GLIBCXX__ ${GCCSHORTDATE},'
SUBST2='s,define _GLIBCXX_INLINE_VERSION, define _GLIBCXX_INLINE_VERSION ${ns_version},'
SUBST3='s,define _GLIBCXX_HAVE_ATTRIBUTE_VISIBILITY, define _GLIBCXX_HAVE_ATTRIBUTE_VISIBILITY ${visibility},'
SUBST4='s,define _GLIBCXX_EXTERN_TEMPLATE$$, define _GLIBCXX_EXTERN_TEMPLATE ${externtemplate},'

c++config.h: ${CXX_CONFIG_H}
	sed -e ${SUBST1} -e ${SUBST2} -e ${SUBST3} -e ${SUBST4} \
	    < ${GCCDIR}/libstdc++-v3/include/bits/c++config > ${.TARGET}
	sed -e 's/HAVE_/_GLIBCXX_HAVE_/g' \
	    -e 's/PACKAGE/_GLIBCXX_PACKAGE/g' \
	    -e 's/VERSION/_GLIBCXX_VERSION/g' \
	    -e 's/WORDS_/_GLIBCXX_WORDS_/g' \
	    -e 's/ICONV_CONST/_GLIBCXX_ICONV_CONST/g' \
	    -e '/[ 	]_GLIBCXX_LONG_DOUBLE_COMPAT[ 	]/d' \
	    < ${CXX_CONFIG_H} >> ${.TARGET}
	echo "" >> ${.TARGET}
	echo "#endif // _GLIBCXX_CXX_CONFIG_H" >> ${.TARGET}
