This is a patch for comment on the approach - tested on x86_64-darwi21
 thoughts?
 Iain
 
 --- 8< ---

Testing on Darwin revealed that the GLIBCXX_ZONEINFO_DIR was not doing quite
the right thing (we ended up with ${withval} in the config.h file).

This patch proposes revising the behaviour of the configure flag thus:

--with-libstdcxx-zoneinfo-dir=
 unspecified : Set _GLIBCXX_ZONEINFO_DIR to a default suitable for $host
         yes : Set _GLIBCXX_ZONEINFO_DIR to a default suitable for $host
         no  : Do not set _GLIBCXX_ZONEINFO_DIR
 /some/path  : set _GLIBCXX_ZONEINFO_DIR = "/some/path"

Signed-off-by: Iain Sandoe <i...@sandoe.co.uk>

libstdc++-v3/ChangeLog:

        * acinclude.m4 (GLIBCXX_ZONEINFO_DIR): Revise configure flag
        handling.
        * configure: Regenerate.
        * src/c++20/tzdb.cc: Add a comment that an unset _GLIBCXX_ZONEINFO_DIR
        implies that the configuration specified that no directory should be
        used.
---
 libstdc++-v3/acinclude.m4      | 21 ++++++++++++++-------
 libstdc++-v3/configure         | 28 +++++++++++++++++++---------
 libstdc++-v3/src/c++20/tzdb.cc |  1 +
 3 files changed, 34 insertions(+), 16 deletions(-)

diff --git a/libstdc++-v3/acinclude.m4 b/libstdc++-v3/acinclude.m4
index f73946a4918..3653822aed4 100644
--- a/libstdc++-v3/acinclude.m4
+++ b/libstdc++-v3/acinclude.m4
@@ -5153,18 +5153,25 @@ AC_DEFUN([GLIBCXX_ZONEINFO_DIR], [
   AC_ARG_WITH([libstdcxx-zoneinfo-dir],
     AC_HELP_STRING([--with-libstdcxx-zoneinfo-dir],
                   [the directory to search for tzdata files]),
-    [zoneinfo_dir="${withval}"
-     AC_DEFINE(_GLIBCXX_ZONEINFO_DIR, "${withval}",
-       [Define if a non-default location should be used for tzdata files.])
-    ],
-    [
+    [],[with_libstdcxx_zoneinfo_dir=yes])
+
+  # Pick a default when no specific path is set.
+  if test x${with_libstdcxx_zoneinfo_dir} = xyes; then
     case "$host" in
       # *-*-aix*) zoneinfo_dir="/usr/share/lib/zoneinfo" ;;
+      *-*-darwin2*) zoneinfo_dir="/usr/share/lib/zoneinfo.default" ;;
       *) zoneinfo_dir="/usr/share/zoneinfo" ;;
     esac
-    ])
-
+  elif test x${with_libstdcxx_zoneinfo_dir} = xno; then
+    zoneinfo_dir=none
+  else
+    zoneinfo_dir=${with_libstdcxx_zoneinfo_dir}
+  fi
   AC_MSG_NOTICE([zoneinfo data directory: ${zoneinfo_dir}])
+  if test x${zoneinfo_dir} != xnone; then
+    AC_DEFINE_UNQUOTED(_GLIBCXX_ZONEINFO_DIR, "${zoneinfo_dir}",
+       [Define if a non-default location should be used for tzdata files.])
+  fi
 ])
 
 # Macros from the top-level gcc directory.

diff --git a/libstdc++-v3/src/c++20/tzdb.cc b/libstdc++-v3/src/c++20/tzdb.cc
index 5f5c4199f65..c4311d0902a 100644
--- a/libstdc++-v3/src/c++20/tzdb.cc
+++ b/libstdc++-v3/src/c++20/tzdb.cc
@@ -52,6 +52,7 @@
 # endif
 #endif
 
+// This is a bit odd; the configure-time setting was 'no zoneinfo directory'
 #ifndef _GLIBCXX_ZONEINFO_DIR
 # define _GLIBCXX_ZONEINFO_DIR "/usr/share/zoneinfo"
 #endif
-- 
2.37.1 (Apple Git-137.1)

Reply via email to