From 9c8513aa5f959bac256cf552a977ca5b83d56816 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:24 +0530
Subject: [PATCH 011/N] configure: add options so that shared build is
 possible on MINGW

Co-authored-by: Naveen M K <naveen521kk@gmail.com>
---
 configure.ac | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/configure.ac b/configure.ac
index ac248b6..12fd0c8 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1592,6 +1592,11 @@ if test $enable_shared = "yes"; then
       BLDLIBRARY='-L. -lpython$(LDVERSION)'
       DLLLIBRARY='libpython$(LDVERSION).dll'
       ;;
+    MINGW*)
+      LDLIBRARY='libpython$(LDVERSION).dll.a'
+      DLLLIBRARY='libpython$(LDVERSION).dll'
+      BLDLIBRARY='-L. -lpython$(LDVERSION)'
+      ;;
     SunOS*)
       LDLIBRARY='libpython$(LDVERSION).so'
       BLDLIBRARY='-Wl,-R,$(LIBDIR) -L. -lpython$(LDVERSION)'
@@ -1651,6 +1656,9 @@ else # shared is disabled
       BLDLIBRARY='$(LIBRARY)'
       LDLIBRARY='libpython$(LDVERSION).dll.a'
       ;;
+    MINGW*)
+      LDLIBRARY='libpython$(LDVERSION).a'
+      ;;
   esac
 fi
 AC_MSG_RESULT([$LDLIBRARY])
@@ -3656,6 +3664,10 @@ then
 	CYGWIN*)
 		LDSHARED="gcc -shared -Wl,--enable-auto-image-base"
 		LDCXXSHARED="g++ -shared -Wl,--enable-auto-image-base";;
+	MINGW*)
+		LDSHARED='$(CC) -shared -Wl,--enable-auto-image-base'
+		LDCXXSHARED='$(CXX) -shared -Wl,--enable-auto-image-base'
+		;;
 	*)	LDSHARED="ld";;
 	esac
 fi
@@ -7219,7 +7231,8 @@ case $host in
     dnl "errmap.h" from $srcdir/PC.
     dnl Note we cannot use BASECPPFLAGS as autogenerated pyconfig.h
     dnl has to be before customized located in ../PC.
-    CPPFLAGS="-I\$(srcdir)/PC $CPPFLAGS"
+    dnl (-I. at end is workaround for setup.py logic)
+    CPPFLAGS="-I\$(srcdir)/PC $CPPFLAGS -I."
     ;;
 esac
 
