From f95f4f4f0be70909eef94a07890681be00b061be Mon Sep 17 00:00:00 2001
From: Naveen M K <naveen521kk@gmail.com>
Date: Mon, 1 Jan 2024 14:48:28 +0530
Subject: [PATCH 108/N] Add `-lpython<version>` while linking stdlib

Generalize the `MINGW` case.
In theory, it should be correct for other system too
and would fix cross-compilation
---
 Modules/makesetup | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/Modules/makesetup b/Modules/makesetup
index f000c9c..5e2ada0 100755
--- a/Modules/makesetup
+++ b/Modules/makesetup
@@ -88,7 +88,7 @@ NL='\
 '
 
 # Setup to link with extra libraries when making shared extensions.
-# Currently, only Cygwin needs this baggage.
+# Currently, only Cygwin and MINGW needs this baggage.
 case `uname -s` in
 CYGWIN*) if test $libdir = .
 	 then
@@ -97,6 +97,9 @@ CYGWIN*) if test $libdir = .
 	 	ExtraLibDir='$(LIBPL)'
 	 fi
 	 ExtraLibs="-L$ExtraLibDir -lpython\$(LDVERSION)";;
+*)
+	 ExtraLibs='$(BLDLIBRARY)'
+	 ExtraLibDepends='$(LIBRARY_DEPS)';;
 esac
 
 # Main loop
@@ -285,7 +288,7 @@ sed -e 's/[ 	]*#.*//' -e '/^[ 	]*$/d' |
 				BUILT_SHARED="$BUILT_SHARED $mod"
 				;;
 			esac
-			rule="$file: $objs"
+			rule="$file: $objs $ExtraLibDepends"
 			rule="$rule; \$(BLDSHARED) $objs $libs $ExtraLibs -o $file"
 			echo "$rule" >>$rulesf
 		done
