@@ -29,10 +29,29 @@ endif
2929endif
3030
3131
32- SHLIB_LINK =$(TCL_LIB_SPEC )
3332ifneq ($(PORTNAME ) , win32)
34- SHLIB_LINK +=$(TCL_LIBS ) -lc
35- endif
33+
34+ SHLIB_LINK =$(TCL_LIB_SPEC ) $(TCL_LIBS ) -lc
35+
36+ else # win32
37+
38+ # Tcl on win32 ships with import libraries only for Microsoft Visual C++,
39+ # which are not compatible with mingw gcc. Therefore we need to build a
40+ # new import library to link with.
41+
42+ tclwithver =$(subst -l,,$(filter -l% ,$(TCL_LIB_SPEC ) ) )
43+ TCLDLL =$(subst -L,,$(filter -L% ,$(TCL_LIB_SPEC ) ) ) /$(tclwithver ) .dll
44+
45+ OBJS += lib$(tclwithver ) .a
46+
47+ lib$(tclwithver ) .a :$(tclwithver ) .def
48+ dlltool --dllname$(tclwithver ) .dll --def$(tclwithver ) .def --output-lib lib$(tclwithver ) .a
49+
50+ $(tclwithver ) .def :$(TCLDLL )
51+ pexports$^ > $@
52+
53+ endif # win32
54+
3655
3756NAME = pltcl
3857
@@ -96,4 +115,7 @@ endif # TCL_SHARED_BUILD = 0
96115clean distclean maintainer-clean : clean-lib
97116rm -f$(OBJS )
98117rm -rf$(pg_regress_clean_files )
118+ ifeq ($(PORTNAME ) , win32)
119+ rm -f $(tclwithver).def
120+ endif
99121$(MAKE) -C modules $@