diff --git a/Modules/_localemodule.c b/Modules/_localemodule.c index 23c38e14d997d1..dfb6c7e607853c 100644 --- a/Modules/_localemodule.c +++ b/Modules/_localemodule.c @@ -12,6 +12,13 @@ This software comes with no warranty. Use at your own risk. #define PY_SSIZE_T_CLEAN #include "Python.h" #include "pycore_fileutils.h" +#ifdef __MINGW32__ +/* The header libintl.h and library libintl may exist on mingw host. + * To be compatible with MSVC build we has to undef some defines. + */ +#undef HAVE_LIBINTL_H +#undef HAVE_BIND_TEXTDOMAIN_CODESET +#endif #include #include diff --git a/configure.ac b/configure.ac index 382a81807b6e82..125488030bf299 100644 --- a/configure.ac +++ b/configure.ac @@ -3651,10 +3651,19 @@ AC_SEARCH_LIBS(sem_init, pthread rt posix4) fi # check if we need libintl for locale functions +case $host in + *-*-mingw*) + dnl Native windows build don't use libintl (see _localemodule.c). + dnl Also we don't like setup.py to add "intl" library to the list + dnl when build _locale module. + ;; + *) AC_CHECK_LIB(intl, textdomain, [AC_DEFINE(WITH_LIBINTL, 1, [Define to 1 if libintl is needed for locale functions.]) LIBS="-lintl $LIBS"]) + ;; +esac # checks for system dependent C++ extensions support case "$ac_sys_system" in