From 0ff5f856a38d56035957951b1457715858c6b0ab 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 c2b1e6c..d4e8b5f 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1552,6 +1552,11 @@ if test $enable_shared = "yes"; then
           LDLIBRARY='libpython$(LDVERSION).dll.a'
           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)'
@@ -1602,6 +1607,9 @@ else # shared is disabled
           BLDLIBRARY='$(LIBRARY)'
           LDLIBRARY='libpython$(LDVERSION).dll.a'
           ;;
+    MINGW*)
+          LDLIBRARY='libpython$(LDVERSION).a'
+          ;;
   esac
 fi
 
@@ -3545,6 +3553,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
@@ -6934,7 +6946,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
 
