From 6f33c7a81b42584c032c7716b3a7a3d2b2bcfb00 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Cl=C3=A9ment=20Chigot?= <clement.chigot@atos.net>
Date: Wed, 27 Jan 2021 13:46:58 +0100
Subject: [PATCH 2/2] libstdc++: configure after locale

---
 libstdc++-v3/configure | 76 ++++++++++++++++++++++++++++--------------
 1 file changed, 51 insertions(+), 25 deletions(-)

diff --git a/libstdc++-v3/configure b/libstdc++-v3/configure
index e64d3eeea2b..798f827fc7b 100755
--- a/libstdc++-v3/configure
+++ b/libstdc++-v3/configure
@@ -16399,7 +16399,7 @@ $as_echo "#define _GLIBCXX_USE_STDIO_PURE 1" >>confdefs.h
 if test "${enable_clocale+set}" = set; then :
   enableval=$enable_clocale;
       case "$enableval" in
-       generic|gnu|ieee_1003.1-2001|newlib|yes|no|auto) ;;
+       generic|gnu|ieee_1003.1-2001|newlib|xpg7|yes|no|auto) ;;
        *) as_fn_error $? "Unknown argument to enable/disable clocale" "$LINENO" 5 ;;
 	  	        esac
 
@@ -16475,8 +16475,8 @@
       vxworks*)
 	enable_clocale_flag=vxworks
 	;;
-      dragonfly* | freebsd*)
-	enable_clocale_flag=dragonfly
+     aix* |  dragonfly* | freebsd*)
+	enable_clocale_flag=xpg7
 	;;
       openbsd*)
 	enable_clocale_flag=newlib
@@ -16639,23 +16639,6 @@
       CTIME_CC=config/locale/generic/time_members.cc
       CLOCALE_INTERNAL_H=config/locale/generic/c++locale_internal.h
       ;;
-    dragonfly)
-      { $as_echo "$as_me:${as_lineno-$LINENO}: result: dragonfly or freebsd" >&5
-$as_echo "dragonfly or freebsd" >&6; }
-
-      CLOCALE_H=config/locale/dragonfly/c_locale.h
-      CLOCALE_CC=config/locale/dragonfly/c_locale.cc
-      CCODECVT_CC=config/locale/dragonfly/codecvt_members.cc
-      CCOLLATE_CC=config/locale/dragonfly/collate_members.cc
-      CCTYPE_CC=config/locale/dragonfly/ctype_members.cc
-      CMESSAGES_H=config/locale/generic/messages_members.h
-      CMESSAGES_CC=config/locale/generic/messages_members.cc
-      CMONEY_CC=config/locale/dragonfly/monetary_members.cc
-      CNUMERIC_CC=config/locale/dragonfly/numeric_members.cc
-      CTIME_H=config/locale/dragonfly/time_members.h
-      CTIME_CC=config/locale/dragonfly/time_members.cc
-      CLOCALE_INTERNAL_H=config/locale/generic/c++locale_internal.h
-      ;;
 
     gnu)
       { $as_echo "$as_me:${as_lineno-$LINENO}: result: gnu" >&5
@@ -16692,6 +16674,25 @@ $as_echo "IEEE 1003.1" >&6; }
       CTIME_CC=config/locale/generic/time_members.cc
       CLOCALE_INTERNAL_H=config/locale/generic/c++locale_internal.h
       ;;
+
+    xpg7)
+      { $as_echo "$as_me:${as_lineno-$LINENO}: result: xpg7" >&5
+$as_echo "xpg7" >&6; }
+
+      CLOCALE_H=config/locale/xpg7/c_locale.h
+      CLOCALE_CC=config/locale/xpg7/c_locale.cc
+      CCODECVT_CC=config/locale/xpg7/codecvt_members.cc
+      CCOLLATE_CC=config/locale/xpg7/collate_members.cc
+      CCTYPE_CC=config/locale/xpg7/ctype_members.cc
+      CMESSAGES_H=config/locale/generic/messages_members.h
+      CMESSAGES_CC=config/locale/generic/messages_members.cc
+      CMONEY_CC=config/locale/xpg7/monetary_members.cc
+      CNUMERIC_CC=config/locale/xpg7/numeric_members.cc
+      CTIME_H=config/locale/xpg7/time_members.h
+      CTIME_CC=config/locale/xpg7/time_members.cc
+      CLOCALE_INTERNAL_H=config/locale/generic/c++locale_internal.h
+      ;;
+
     newlib)
       { $as_echo "$as_me:${as_lineno-$LINENO}: result: newlib" >&5
 $as_echo "newlib" >&6; }
@@ -16814,6 +16815,34 @@ $as_echo "#define _GLIBCXX_USE_NLS 1" >>confdefs.h
 
 
 
+  if test $enable_clocale_flag = xpg7; then
+     for ac_header in xlocale.h
+do :
+  ac_fn_c_check_header_mongrel "$LINENO" "xlocale.h" "ac_cv_header_xlocale_h" "$ac_includes_default"
+if test "x$ac_cv_header_xlocale_h" = xyes; then :
+  cat >>confdefs.h <<_ACEOF
+#define HAVE_XLOCALE_H 1
+_ACEOF
+
+fi
+
+done
+
+
+     for ac_func in strtof_l localeconv_l mbstowcs_l wcsftime_l strftime_l
+do :
+  as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
+ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
+if eval test \"x\$"$as_ac_var"\" = x"yes"; then :
+  cat >>confdefs.h <<_ACEOF
+#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+done
+
+  fi
+
 
   { $as_echo "$as_me:${as_lineno-$LINENO}: checking for std::allocator base class" >&5
 $as_echo_n "checking for std::allocator base class... " >&6; }
-- 
2.25.0

