diff --git a/build/cmake/setup.cmake b/build/cmake/setup.cmake index 9e0e4d24d4..a21a2449a8 100644 --- a/build/cmake/setup.cmake +++ b/build/cmake/setup.cmake @@ -649,6 +649,7 @@ if(wxUSE_FSWATCHER) endif() if(wxUSE_XLOCALE) + check_include_file(xlocale.h HAVE_XLOCALE_H) set(CMAKE_EXTRA_INCLUDE_FILES xlocale.h locale.h) check_type_size(locale_t LOCALE_T) set(CMAKE_EXTRA_INCLUDE_FILES) diff --git a/build/cmake/setup.h.in b/build/cmake/setup.h.in index ab342723f1..4f244d7da4 100644 --- a/build/cmake/setup.h.in +++ b/build/cmake/setup.h.in @@ -1257,6 +1257,9 @@ /* Define if setpriority() is available. */ #cmakedefine HAVE_SETPRIORITY 1 +/* Define if xlocale.h header file exists. */ +#cmakedefine HAVE_XLOCALE_H 1 + /* Define if locale_t is available */ #cmakedefine HAVE_LOCALE_T 1 diff --git a/configure b/configure index 9c1e4bc12d..7266ef5019 100755 --- a/configure +++ b/configure @@ -3217,6 +3217,97 @@ fi as_fn_set_status $ac_retval } # ac_fn_cxx_try_run + +# ac_fn_c_check_header_mongrel LINENO HEADER VAR INCLUDES +# ------------------------------------------------------- +# Tests whether HEADER exists, giving a warning if it cannot be compiled using +# the include files in INCLUDES and setting the cache variable VAR +# accordingly. +ac_fn_c_check_header_mongrel () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + if eval \${$3+:} false; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 +$as_echo_n "checking for $2... " >&6; } +if eval \${$3+:} false; then : + $as_echo_n "(cached) " >&6 +fi +eval ac_res=\$$3 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } +else + # Is the header compilable? +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 usability" >&5 +$as_echo_n "checking $2 usability... " >&6; } +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$4 +#include <$2> +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_header_compiler=yes +else + ac_header_compiler=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_compiler" >&5 +$as_echo "$ac_header_compiler" >&6; } + +# Is the header present? +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 presence" >&5 +$as_echo_n "checking $2 presence... " >&6; } +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include <$2> +_ACEOF +if ac_fn_c_try_cpp "$LINENO"; then : + ac_header_preproc=yes +else + ac_header_preproc=no +fi +rm -f conftest.err conftest.i conftest.$ac_ext +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_preproc" >&5 +$as_echo "$ac_header_preproc" >&6; } + +# So? What about this header? +case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in #(( + yes:no: ) + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&5 +$as_echo "$as_me: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5 +$as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;} + ;; + no:yes:* ) + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: present but cannot be compiled" >&5 +$as_echo "$as_me: WARNING: $2: present but cannot be compiled" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: check for missing prerequisite headers?" >&5 +$as_echo "$as_me: WARNING: $2: check for missing prerequisite headers?" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: see the Autoconf documentation" >&5 +$as_echo "$as_me: WARNING: $2: see the Autoconf documentation" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: section \"Present But Cannot Be Compiled\"" >&5 +$as_echo "$as_me: WARNING: $2: section \"Present But Cannot Be Compiled\"" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5 +$as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;} +( $as_echo "## -------------------------------------- ## +## Report this to wx-dev@googlegroups.com ## +## -------------------------------------- ##" + ) | sed "s/^/$as_me: WARNING: /" >&2 + ;; +esac + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 +$as_echo_n "checking for $2... " >&6; } +if eval \${$3+:} false; then : + $as_echo_n "(cached) " >&6 +else + eval "$3=\$ac_header_compiler" +fi +eval ac_res=\$$3 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } +fi + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + +} # ac_fn_c_check_header_mongrel cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. @@ -32907,6 +32998,19 @@ $as_echo "$as_me: WARNING: I18n code requires wxFile... disabled" >&2;} fi if test "$wxUSE_XLOCALE" = "yes" ; 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 + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for locale_t" >&5 $as_echo_n "checking for locale_t... " >&6; } if ${wx_cv_type_locale_t+:} false; then : @@ -32922,6 +33026,9 @@ ac_compiler_gnu=$ac_cv_cxx_compiler_gnu cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ + #ifdef HAVE_XLOCALE_H + #include + #endif #include #include diff --git a/configure.in b/configure.in index c9a84bb3a6..5af395548d 100644 --- a/configure.in +++ b/configure.in @@ -5757,11 +5757,18 @@ if test "$wxUSE_INTL" = "yes" ; then fi if test "$wxUSE_XLOCALE" = "yes" ; then + dnl Some platforms (e.g. macOS) require an extra header, others (Linux) + dnl don't, but it's simpler to just check for it under all of them. + AC_CHECK_HEADERS([xlocale.h]) + AC_CACHE_CHECK([for locale_t], wx_cv_type_locale_t, [ AC_LANG_PUSH(C++) AC_TRY_COMPILE( [ + #ifdef HAVE_XLOCALE_H + #include + #endif #include #include ], diff --git a/include/wx/xlocale.h b/include/wx/xlocale.h index 9ade3a99f4..476a3a737e 100644 --- a/include/wx/xlocale.h +++ b/include/wx/xlocale.h @@ -40,6 +40,11 @@ typedef _locale_t wxXLocale_t; #define wxXLOCALE_IDENT(name) _ ## name #elif defined(HAVE_LOCALE_T) + // Some systems (notably macOS) require including a separate header for + // locale_t and related functions. + #ifdef HAVE_XLOCALE_H + #include + #endif #include #include #include diff --git a/setup.h.in b/setup.h.in index 1f1955ad4c..981b45e1da 100644 --- a/setup.h.in +++ b/setup.h.in @@ -1267,6 +1267,9 @@ /* Define if setpriority() is available. */ #undef HAVE_SETPRIORITY +/* Define if xlocale.h header file exists. */ +#undef HAVE_XLOCALE_H + /* Define if locale_t is available */ #undef HAVE_LOCALE_T