From 2d5fb03073276130d92505f9a24dd9dc154afadf Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=D0=90=D0=BB=D0=B5=D0=BA=D1=81=D0=B5=D0=B9?=
 <alexey.pawlow@gmail.com>
Date: Thu, 17 Jun 2021 18:51:15 +0530
Subject: [PATCH 005/N] Add default configuration for MINGW
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Co-authored-by: Алексей <alexey.pawlow@gmail.com>
Co-authored-by: Christoph Reiter <reiter.christoph@gmail.com>
---
 Misc/config_mingw  | 12 ++++++++++++
 Misc/cross_mingw32 | 11 +++++++++++
 configure.ac       | 22 ++++++++++++++++++++++
 3 files changed, 45 insertions(+)
 create mode 100644 Misc/config_mingw
 create mode 100644 Misc/cross_mingw32

diff --git a/Misc/config_mingw b/Misc/config_mingw
new file mode 100644
index 0000000..513065d
--- /dev/null
+++ b/Misc/config_mingw
@@ -0,0 +1,12 @@
+# configure defaults for mingw* hosts
+
+# mingw functions to ignore
+ac_cv_func_ftruncate=ignore	# implement it as _chsize
+
+# mingw-w64 functions to ignore
+ac_cv_func_truncate=ignore
+ac_cv_func_alarm=ignore
+
+# files to ignore
+ac_cv_file__dev_ptmx=ignore #NOTE: under MSYS environment device exist
+ac_cv_file__dev_ptc=no
diff --git a/Misc/cross_mingw32 b/Misc/cross_mingw32
new file mode 100644
index 0000000..03fde9e
--- /dev/null
+++ b/Misc/cross_mingw32
@@ -0,0 +1,11 @@
+# configure defaults for mingw32 host if cross-build
+
+ac_cv_little_endian_double=yes
+ac_cv_big_endian_double=no
+ac_cv_mixed_endian_double=no
+
+ac_cv_tanh_preserves_zero_sign=yes
+
+ac_cv_wchar_t_signed=no
+
+ac_cv_have_size_t_format=no
diff --git a/configure.ac b/configure.ac
index 1083bce..9d7864f 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1233,6 +1233,28 @@ AC_CACHE_CHECK([for -Wl,--no-as-needed], [ac_cv_wl_no_as_needed], [
 ])
 AC_SUBST([NO_AS_NEEDED])
 
+# initialize default configuration
+py_config=
+case $host in
+  *-*-mingw*) py_config=mingw ;;
+esac
+if test -n "$py_config" ; then
+  AC_MSG_NOTICE([loading configure defaults from .../Misc/config_$py_config"])
+  . "$srcdir/Misc/config_$py_config"
+fi
+
+# initialize defaults for cross-builds
+if test "$cross_compiling" = yes; then
+  py_config=$host_os
+  case $py_config in
+    mingw32*) py_config=mingw32 ;;
+  esac
+  if test -f "$srcdir/Misc/cross_$py_config" ; then
+    AC_MSG_NOTICE([loading cross defaults from .../Misc/cross_$py_config"])
+    . "$srcdir/Misc/cross_$py_config"
+  fi
+fi
+
 AC_MSG_CHECKING([for the Android API level])
 cat > conftest.c <<EOF
 #ifdef __ANDROID__
