Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit b961920

Browse files
committed
Final part of SF patch #102409 by jlt63: Cygwin Python DLL and Shared
Extension Patch. These are the changes to the Modules Makefile and makesetup script for Cygwin.
1 parent aef734b commit b961920

2 files changed

Lines changed: 23 additions & 1 deletion

File tree

Modules/Makefile.pre.in

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ SYSLIBS= $(LIBM) $(LIBC)
105105

106106
LIBRARY= ../libpython$(VERSION).a
107107
LDLIBRARY= ../@LDLIBRARY@
108+
@SET_DLLLIBRARY@
108109

109110
# === Rules ===
110111

@@ -127,6 +128,14 @@ link: $(MAINOBJ)
127128
$(LDLIBRARY) $(MODLIBS) $(LIBS) $(SYSLIBS) -o python$(EXE) $(LDLAST)
128129
mv python$(EXE) ../python$(EXE)
129130

131+
# This rule builds the Cygwin Python DLL
132+
$(DLLLIBRARY): $(LIBRARY)
133+
test -d cygwin || mkdir cygwin
134+
(cd cygwin; ar x ../$^)
135+
dlltool --export-all --output-def $(basename $@).def cygwin/*.o
136+
$(LDSHARED) -Wl,--out-implib=$(LDLIBRARY) -o $@ $(basename $@).def cygwin/*.o $(MODLIBS) $(LIBS) $(SYSLIBS)
137+
rm -fr cygwin
138+
130139
clean:
131140
-rm -f *.o python$(EXE) core *~ [@,#]* *.old *.orig *.rej
132141
-rm -f add2lib hassignal

Modules/makesetup

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,18 @@ esac
7979
NL='\
8080
'
8181

82+
# Setup to link with extra libraries when makeing shared extensions.
83+
# Currently, only Cygwin needs this baggage.
84+
case `uname -s` in
85+
CYGWIN*) if test $srcdir = .
86+
then
87+
ExtraLibDir=..
88+
else
89+
ExtraLibDir='$(LIBPL)'
90+
fi
91+
ExtraLibs="-L$ExtraLibDir -lpython\$(VERSION)";;
92+
esac
93+
8294
# Main loop
8395
for i in ${*-Setup}
8496
do
@@ -149,6 +161,7 @@ sed -e 's/[ ]*#.*//' -e '/^[ ]*$/d' |
149161
*.so) libs="$libs $arg";;
150162
*.sl) libs="$libs $arg";;
151163
/*.o) libs="$libs $arg";;
164+
*.def) libs="$libs $arg";;
152165
*.o) srcs="$srcs `basename $arg .o`.c";;
153166
*.[cC]) srcs="$srcs $arg";;
154167
*.cc) srcs="$srcs $arg";;
@@ -213,7 +226,7 @@ sed -e 's/[ ]*#.*//' -e '/^[ ]*$/d' |
213226
no) SHAREDMODS="$SHAREDMODS $file";;
214227
esac
215228
rule="$file: $objs"
216-
rule="$rule; \$(LDSHARED) $objs $libs -o $file"
229+
rule="$rule; \$(LDSHARED) $objs $libs $ExtraLibs -o $file"
217230
echo "$rule" >>$rulesf
218231
done
219232
done

0 commit comments

Comments
 (0)