diff -Naur a/Include/pymath.h b/Include/pymath.h
--- a/Include/pymath.h 2008-08-19 21:42:13.000000000 +0000
+++ b/Include/pymath.h 2009-03-01 04:37:26.000000000 +0000
@@ -102,6 +102,8 @@
* it really can't be implemented correctly (& easily) before C99.
* Override in pyconfig.h if you have a better spelling on your platform.
* Note: PC/pyconfig.h defines Py_IS_INFINITY as _isinf
+ * FIXME: PC/pyconfig.h defines Py_IS_INFINITY as (!_finite(X) && !_isnan(X))
+ * so that above note isn't correct !!!
*/
#ifndef Py_IS_INFINITY
#ifdef HAVE_ISINF
diff -Naur a/Include/pyport.h b/Include/pyport.h
--- a/Include/pyport.h 2009-01-16 04:13:17.000000000 +0000
+++ b/Include/pyport.h 2009-03-01 12:31:57.159139480 +0000
@@ -460,6 +460,126 @@
#endif /* defined(HAVE_OPENPTY) || defined(HAVE_FORKPTY) */
+#ifdef __MINGW32__
+/* FIXME: some of next definitions specific to gcc(mingw build) can be
+ generalized on definitions of _WIN32 or WIN32 and to be common for
+ all windows build instead explicitly to define only for non-autotools
+ based builds (see PC/pyconfig.h for details). */
+#if defined(_WIN64)
+# define MS_WIN64
+#endif
+#if !defined(MS_WIN32) && defined(_WIN32)
+# define MS_WIN32
+#endif
+#if !defined(MS_WIN32) && defined(_WIN32)
+# define MS_WIN32
+#endif
+#if !defined(MS_WINDOWS) && defined(MS_WIN32)
+# define MS_WINDOWS
+#endif
+
+#ifndef PYTHONPATH
+# define PYTHONPATH ".\\Lib;.\\DLLs;.\\lib;.\\lib\\plat-win;.\\lib\\lib-tk"
+#endif
+
+/* python 2.6+ requires Windows 2000 or greater. */
+#define Py_WINVER 0x0500
+
+#if defined(Py_BUILD_CORE) || defined(Py_BUILD_CORE_MODULE)
+/* FIXME if NTDDI_xxx is in use by mingw (see PC/pyconfig.h) */
+#ifndef WINVER
+# define WINVER Py_WINVER
+#endif
+#ifndef _WIN32_WINNT
+# define _WIN32_WINNT Py_WINVER
+#endif
+#endif
+
+#ifdef PLATFORM
+/*NOTE: if compile getplatform.c PLATFORM is set to MACHDEP that is
+ "win" for mingw build (see respective comment in configure.in). */
+# undef PLATFORM
+#endif
+/* always set to "win32" - see PC/pyconfig.h */
+#define PLATFORM "win32"
+
+#if defined(MS_WIN64)
+# define SIZEOF_HKEY 8
+#elif defined(MS_WIN32)
+# define SIZEOF_HKEY 4
+#endif
+
+/*NOTE: mingw has isinf as macro defined in math.h.
+ Since PC/pyconfig.h define Py_IS_INFINITY(X) that cover HAVE_DECL_ISFINITE
+ here for Py_IS_INFINITY we define same as for MSVC build.
+ This makes HAVE_DECL_ISFINITE needless.
+ Also see commants in configure.in and pymath.h. */
+#define Py_IS_INFINITY(X) (!_finite(X) && !_isnan(X))
+
+#ifndef HAVE_LARGEFILE_SUPPORT
+/*
+ FIXME: on windows platforms:
+ - Python use PY_LONG_LONG(!) for Py_off_t (_fileio.c);
+ - HAVE_LARGEFILE_SUPPORT is defined in PC/pyconfig.h;
+ - PC/pyconfig.h define 4 for SIZEOF_OFF_T and 8 for SIZEOF_FPOS_T;
+ - If HAVE_LARGEFILE_SUPPORT isn't defined python will use off_t(!)
+ for Py_off_t (see fileobjects.c and bz2module.c).
+ Since for mingw configure detect 4 for size of "off_t" and 8 - for
+ "fpos_t" we has to define HAVE_LARGEFILE_SUPPORT too.
+ TODO: to test with AC_SYS_LARGEFILE and appropriate updates in
+ python code.
+*/
+# define HAVE_LARGEFILE_SUPPORT
+#endif
+
+#if defined(Py_ENABLE_SHARED)
+# define MS_COREDLL 1 /* deprecated old symbol, but still in use for windows code */
+#else
+# define MS_NO_COREDLL 1
+#endif
+
+#if Py_UNICODE_SIZE == 2
+/* For mingw is 2 but FIXME: What about to raise error in configure if
+ unicode size isn't two ? Did python windows code support ucs4 ? */
+# define Py_WIN_WIDE_FILENAMES
+#endif
+
+/* NOTE: Don't define HAVE_STDDEF_H.
+ * It is defined by PC/pyconfig.h and used by Include/Python.h
+ * (with comment For size_t?) but isn't required for mingw */
+#define Py_SOCKET_FD_CAN_BE_GE_FD_SETSIZE
+
+/* All other defines from PC/pyconfig.h are in autoconf generated
+ pyconfig.h */
+#if 0
+/*FIXME:
+ MSDN:
+ "The getaddrinfo function was added to the ws2_32.dll on Windows XP
+ and later."
+ mingw:
+ getaddrinfo and getnameinfo is defined for WINVER >= 0x0501.
+ PC/pyconfig.h:
+ "Python 2.6+ requires Windows 2000 or greater"
+ So far so good but socketmodule.h define HAVE_GETADDRINFO and
+ HAVE_GETNAMEINFO under very specific condition :
+ # ifdef SIO_GET_MULTICAST_FILTER
+ # include
+ So the question is "Separate SDKs" required for w2k in MSVC build ?
+ TODO: resolve later, may by configure :-/. For now python code will
+ use fake implementation and if user define appropriate value for
+ WINVER - the functionas from C runtime.
+ For details see socketmodule.c .
+ */
+#ifndef HAVE_GETADDRINFO
+# define HAVE_GETADDRINFO
+#endif
+#ifndef HAVE_GETNAMEINFO
+# define HAVE_GETNAMEINFO
+#endif
+#endif
+
+#endif /*def __MINGW32__*/
+
/* On 4.4BSD-descendants, ctype functions serves the whole range of
* wchar_t character set rather than single byte code points only.
* This characteristic can break some operations of string object
@@ -506,10 +626,10 @@
/*
All windows ports, except cygwin, are handled in PC/pyconfig.h.
- Cygwin is the only other autoconf platform requiring special
- linkage handling and it uses __declspec().
+ BeOS, mingw32 and cygwin use autoconf and require special
+ linkage handling and all of these use __declspec().
*/
-#if defined(__CYGWIN__)
+#if defined(__CYGWIN__) || defined(__MINGW32__) || defined(__BEOS__)
# define HAVE_DECLSPEC_DLL
#endif
@@ -527,13 +647,22 @@
# define PyMODINIT_FUNC PyObject*
# endif /* __CYGWIN__ */
# else /* Py_BUILD_CORE */
+ /* FIXME: FAQ.html#3.24 link below is no longer valid */
/* Building an extension module, or an embedded situation */
/* public Python functions and data are imported */
/* Under Cygwin, auto-import functions to prevent compilation */
/* failures similar to http://python.org/doc/FAQ.html#3.24 */
-# if !defined(__CYGWIN__)
+# if !defined(__CYGWIN__) && !defined(__MINGW32__)
# define PyAPI_FUNC(RTYPE) __declspec(dllimport) RTYPE
-# endif /* !__CYGWIN__ */
+# else
+# define PyAPI_FUNC(RTYPE) RTYPE
+# endif /* !__CYGWIN__ !__MINGW32__ */
+ /* NOTE: The issue3945 "compile error in _fileio.c (cygwin)"
+ * was resolved with modification of code.
+ * This issue was resolved for gcc(mingw) with enabling auto
+ * import feature. Since _fileio.c problem now disappear there
+ * is no more reasons to avoid dllimport for gcc(mingw).
+ */
# define PyAPI_DATA(RTYPE) extern __declspec(dllimport) RTYPE
/* module init functions outside the core must be exported */
# if defined(__cplusplus)
diff -Naur a/Lib/ctypes/test/test_as_parameter.py b/Lib/ctypes/test/test_as_parameter.py
--- a/Lib/ctypes/test/test_as_parameter.py 2007-05-03 21:05:51.000000000 +0000
+++ b/Lib/ctypes/test/test_as_parameter.py 2009-03-01 04:37:26.000000000 +0000
@@ -1,6 +1,7 @@
import unittest
from ctypes import *
import _ctypes_test
+import sys
dll = CDLL(_ctypes_test.__file__)
@@ -171,6 +172,11 @@
self.failUnlessEqual((s2h.x, s2h.y), (99*2, 88*3))
def test_struct_return_8H(self):
+ if sys.version.find("mingw") >= 0:
+ # This is known cdecl incompatibility between GCC
+ # and MSVC. It is addressed in GCC issue #36834.
+ # Python libffi detect it and complain.
+ return
class S8I(Structure):
_fields_ = [("a", c_int),
("b", c_int),
diff -Naur a/Lib/ctypes/test/test_functions.py b/Lib/ctypes/test/test_functions.py
--- a/Lib/ctypes/test/test_functions.py 2007-11-02 23:46:40.000000000 +0000
+++ b/Lib/ctypes/test/test_functions.py 2009-03-01 04:37:26.000000000 +0000
@@ -359,6 +359,11 @@
self.failUnlessEqual((s2h.x, s2h.y), (99*2, 88*3))
def test_struct_return_8H(self):
+ if sys.version.find("mingw") >= 0:
+ # This is known cdecl incompatibility between GCC
+ # and MSVC. It is addressed in GCC issue #36834.
+ # Python libffi detect it and complain.
+ return
class S8I(Structure):
_fields_ = [("a", c_int),
("b", c_int),
diff -Naur a/Lib/ctypes/util.py b/Lib/ctypes/util.py
--- a/Lib/ctypes/util.py 2009-01-10 22:42:12.000000000 +0000
+++ b/Lib/ctypes/util.py 2009-03-01 04:37:26.000000000 +0000
@@ -4,6 +4,11 @@
if os.name == "nt":
def _get_build_version():
+ #***********************************************************
+ # NOTE: As example for GCC(mingw) build sys.version return:
+ # 2.6rc2+ (trunk:M, , )
+ # [GCC 3.4.5 (mingw special)]
+ #***********************************************************
"""Return the version of MSVC that was used to build Python.
For Python 2.3 and up, the version number is included in
@@ -27,6 +32,15 @@
return None
def find_msvcrt():
+ #************************************************************
+ # FIXME: For gcc(mingw) runtime don't depend from compiler
+ # version ;). We may use -D__MSVCRT_VERSION__ to detect which
+ # verion is requested by user, but the name of the library
+ # to be default.
+ # As example WXP is with version 7.0 of msvcrt.dll.
+ # Anyway since _get_build_version return 6 in most(standard)
+ # cases this method will return msvcrt{d}. May be not so bad.
+ #************************************************************
"""Return the name of the VC runtime dll"""
version = _get_build_version()
if version is None:
diff -Naur a/Lib/distutils/ccompiler.py b/Lib/distutils/ccompiler.py
--- a/Lib/distutils/ccompiler.py 2008-12-21 00:55:55.000000000 +0000
+++ b/Lib/distutils/ccompiler.py 2009-03-01 04:37:25.000000000 +0000
@@ -1022,6 +1022,8 @@
osname = os.name
if platform is None:
platform = sys.platform
+ if osname == "nt" and sys.version.find('mingw') >= 0:
+ return 'mingw32'
for pattern, compiler in _default_compilers:
if re.match(pattern, platform) is not None or \
re.match(pattern, osname) is not None:
diff -Naur a/Lib/distutils/command/build_ext.py b/Lib/distutils/command/build_ext.py
--- a/Lib/distutils/command/build_ext.py 2009-02-05 22:58:41.000000000 +0000
+++ b/Lib/distutils/command/build_ext.py 2009-03-01 04:37:25.000000000 +0000
@@ -16,7 +16,8 @@
from distutils.util import get_platform
from distutils import log
-if os.name == 'nt':
+# GCC(mingw): os.name is "nt" but build system is posix
+if os.name == 'nt' and sys.version.find('mingw') = 0:
if sys.executable.startswith(os.path.join(sys.exec_prefix, "bin")):
# building third party extensions
self.library_dirs.append(os.path.join(sys.prefix, "lib",
@@ -669,6 +671,35 @@
# pyconfig.h that MSVC groks. The other Windows compilers all seem
# to need it mentioned explicitly, though, so that's what we do.
# Append '_d' to the python import library on debug builds.
+
+ # FIXME: What is purpose of code below ?
+ # The posix build system khow requred libraries to build a module.
+ # The libraries are stored in config(Makefile) variables BLDLIBRARY,
+ # MODLIBS and SHLIBS. Note that some variables may contain linker
+ # flags.
+ # NOTE: For now we will check only GCC(mingw) compiler as is clear
+ # that we build for windows platfrom.
+ # The code for GCC(mingw) is not correct but this is distutils
+ # limitation - we has to pass variables to the linker as is
+ # instead only library names.
+ from distutils.cygwinccompiler import Mingw32CCompiler
+ if isinstance(self.compiler, Mingw32CCompiler):
+ from distutils import sysconfig
+ template = "python%s"
+ if self.debug:
+ template = template + '_d'
+ extra = [(template % (sysconfig.get_config_var('VERSION')))]
+ for lib in sysconfig.get_config_var('BLDLIBRARY').split():
+ if lib.startswith('-l'):
+ extra.append(lib[2:])
+ for lib in sysconfig.get_config_var('MODLIBS').split():
+ if lib.startswith('-l'):
+ extra.append(lib[2:])
+ for lib in sysconfig.get_config_var('SHLIBS').split():
+ if lib.startswith('-l'):
+ extra.append(lib[2:])
+ return ext.libraries + extra
+
if sys.platform == "win32":
from distutils.msvccompiler import MSVCCompiler
if not isinstance(self.compiler, MSVCCompiler):
diff -Naur a/Lib/distutils/cygwinccompiler.py b/Lib/distutils/cygwinccompiler.py
--- a/Lib/distutils/cygwinccompiler.py 2008-08-19 18:57:56.000000000 +0000
+++ b/Lib/distutils/cygwinccompiler.py 2009-03-01 05:11:34.000000000 +0000
@@ -58,6 +58,18 @@
"""Include the appropriate MSVC runtime library if Python was built
with MSVC 7.0 or later.
"""
+ # FIXME: next code is from issue870382
+ # MS C-runtime libraries never support backward compatibility.
+ # Linking to a different library without to specify correct runtime
+ # version for the headers will link renamed functions to msvcrt.
+ # See issue3308: this piece of code is python problem even
+ # with correct w32api headers.
+ # Issue: for MSVC compiler we can get the version and from version
+ # to determine mcvcrt as code below. But what about if python is
+ # build with GCC compiler?
+ # Output of sys.version is information for python build on first
+ # line, on the next line is information for the compiler and the
+ # output lack information for the C-runtime.
msc_pos = sys.version.find('MSC v.')
if msc_pos != -1:
msc_ver = sys.version[msc_pos+6:msc_pos+10]
@@ -75,6 +87,8 @@
return ['msvcr90']
else:
raise ValueError("Unknown MS Compiler version %i " % msc_Ver)
+ else:
+ return []
class CygwinCCompiler (UnixCCompiler):
@@ -83,6 +97,9 @@
obj_extension = ".o"
static_lib_extension = ".a"
shared_lib_extension = ".dll"
+ # FIXME: dylib_... = ".dll.a" is not enought for binutils
+ # loader on win32 platform !!!
+ dylib_lib_extension = ".dll.a"
static_lib_format = "lib%s%s"
shared_lib_format = "%s%s"
exe_extension = ".exe"
@@ -101,6 +118,10 @@
"Compiling may fail because of undefined preprocessor macros."
% details)
+ # Next line of code is problem for cross-compiled enviroment:
+ # NOTE: GCC cross-compiler is prefixed by the -
+ # and by default binaries are installed in same directory
+ # as native compiler.
self.gcc_version, self.ld_version, self.dllwrap_version = \
get_versions()
self.debug_print(self.compiler_type + ": gcc %s, ld %s, dllwrap %s\n" %
@@ -125,6 +146,9 @@
else:
shared_option = "-mdll -static"
+ # FIXME:
+ # Hard-code may override unix-compiler settings and isn't
+ # possible to use Makefile variables to pass correct flags !
# Hard-code GCC because that's what this is all about.
# XXX optimization, warnings etc. should be customizable.
self.set_executables(compiler='gcc -mcygwin -O -Wall',
@@ -269,11 +293,19 @@
if output_dir is None: output_dir = ''
obj_names = []
for src_name in source_filenames:
- # use normcase to make sure '.rc' is really '.rc' and not '.RC'
- (base, ext) = os.path.splitext (os.path.normcase(src_name))
+ # FIXME: "bogus checks for suffix" - as example the commented
+ # by #BOGUS# code break valid assembler suffix ".S" !
+ #BOGUS## use normcase to make sure '.rc' is really '.rc' and not '.RC'
+ #BOGUS#(base, ext) = os.path.splitext (os.path.normcase(src_name))
+ (base, ext) = os.path.splitext (src_name)
+ ext_normcase = os.path.normcase(ext)
+ if ext_normcase in ['.rc','.res']:
+ ext = ext_normcase
if ext not in (self.src_extensions + ['.rc','.res']):
raise UnknownFileError("unknown file type '%s' (from '%s')" % \
(ext, src_name))
+ base = os.path.splitdrive(base)[1] # Chop off the drive
+ base = base[os.path.isabs(base):] # If abs, chop off leading /
if strip_dir:
base = os.path.basename (base)
if ext == '.res' or ext == '.rc':
diff -Naur a/Lib/distutils/sysconfig.py b/Lib/distutils/sysconfig.py
--- a/Lib/distutils/sysconfig.py 2009-02-10 12:41:19.000000000 +0000
+++ b/Lib/distutils/sysconfig.py 2009-03-01 04:37:25.000000000 +0000
@@ -70,7 +70,8 @@
"""
if prefix is None:
prefix = plat_specific and EXEC_PREFIX or PREFIX
- if os.name == "posix":
+ # GCC(mingw): os.name is "nt" but build system is posix
+ if os.name == "posix" or sys.version.find('mingw') >= 0:
if python_build:
base = os.path.dirname(os.path.abspath(sys.executable))
if plat_specific:
@@ -196,7 +197,8 @@
def get_config_h_filename():
"""Return full pathname of installed pyconfig.h file."""
if python_build:
- if os.name == "nt":
+ # GCC(mingw): os.name is "nt" but build system is posix
+ if os.name == "nt" and sys.version.find('mingw') = 0:
+ # GCC(mingw) use posix build system
+ # FIXME: may be modification has to be in get_config_vars ?
+ _init_posix()
+ return
g = {}
# set basic install directories
g['LIBDEST'] = get_python_lib(plat_specific=0, standard_lib=1)
diff -Naur a/Lib/distutils/version.py b/Lib/distutils/version.py
--- a/Lib/distutils/version.py 2009-01-27 18:31:30.000000000 +0000
+++ b/Lib/distutils/version.py 2009-03-01 13:20:27.890641032 +0000
@@ -338,7 +338,12 @@
if isinstance(other, str):
other = LooseVersion(other)
- return cmp(self.version, other.version)
+ if self.version == other.version:
+ return 0
+ if self.version other.version:
+ return 1
# end class LooseVersion
diff -Naur a/Makefile.pre.in b/Makefile.pre.in
--- a/Makefile.pre.in 2009-01-13 22:15:07.000000000 +0000
+++ b/Makefile.pre.in 2009-03-01 04:37:27.000000000 +0000
@@ -179,6 +179,10 @@
PROFILE_TASK= $(srcdir)/Tools/pybench/pybench.py -n 2 --with-gc --with-syscheck
#PROFILE_TASK= $(srcdir)/Lib/test/regrtest.py
+# Don't define HOST_OS as makefile variable !
+@CROSS_ON@RUNPYTHON= HOST_OS=@HOST_OS@ @SYSPYTHON@
+@CROSS_OFF@RUNPYTHON= $(RUNSHARED) ./$(BUILDPYTHON)
+
# === Definitions added by makesetup ===
@@ -186,7 +190,7 @@
# Modules
MODULE_OBJS= \
Modules/config.o \
- Modules/getpath.o \
+ @MODULE_GETPATH@ \
Modules/main.o \
Modules/gcmodule.o
@@ -258,7 +262,7 @@
Python/codecs.o \
Python/errors.o \
Python/frozen.o \
- Python/frozenmain.o \
+ @PYTHON_OBJS_FROZENMAIN@ \
Python/future.o \
Python/getargs.o \
Python/getcompiler.o \
@@ -501,6 +505,7 @@
$(srcdir)/Modules/getbuildinfo.c
$(CC) -c $(PY_CFLAGS) -DSVNVERSION=\"`LC_ALL=C $(SVNVERSION)`\" -o $@ $(srcdir)/Modules/getbuildinfo.c
+# default sys.path calculations
Modules/getpath.o: $(srcdir)/Modules/getpath.c Makefile
$(CC) -c $(PY_CFLAGS) -DPYTHONPATH='"$(PYTHONPATH)"' \
-DPREFIX='"$(prefix)"' \
@@ -509,10 +514,15 @@
-DVPATH='"$(VPATH)"' \
-o $@ $(srcdir)/Modules/getpath.c
+# default sys.path calculations for windows platforms
+PC/getpathp.o: $(srcdir)/PC/getpathp.c
+ $(CC) -c $(PY_CFLAGS) -o $@ $(srcdir)/PC/getpathp.c
+
Modules/python.o: $(srcdir)/Modules/python.c
$(MAINCC) -c $(PY_CFLAGS) -o $@ $(srcdir)/Modules/python.c
+# FIXME: next may fail in cross-compilation environment
$(GRAMMAR_H) $(GRAMMAR_C): $(PGEN) $(GRAMMAR_INPUT)
-@$(INSTALL) -d Include
-$(PGEN) $(GRAMMAR_INPUT) $(GRAMMAR_H) $(GRAMMAR_C)
@@ -980,7 +990,7 @@
# Install the dynamically loadable modules
# This goes into $(exec_prefix)
sharedinstall:
- $(RUNSHARED) ./$(BUILDPYTHON) -E $(srcdir)/setup.py install \
+ $(RUNPYTHON) -E $(srcdir)/setup.py install \
--prefix=$(prefix) \
--install-scripts=$(BINDIR) \
--install-platlib=$(DESTSHARED) \
@@ -1058,8 +1068,8 @@
# This installs a few of the useful scripts in Tools/scripts
scriptsinstall:
- SRCDIR=$(srcdir) $(RUNSHARED) \
- ./$(BUILDPYTHON) $(srcdir)/Tools/scripts/setup.py install \
+ SRCDIR=$(srcdir) \
+ $(RUNPYTHON) $(srcdir)/Tools/scripts/setup.py install \
--prefix=$(prefix) \
--install-scripts=$(BINDIR) \
--root=/$(DESTDIR)
@@ -1195,7 +1205,7 @@
# Perform some verification checks on any modified files.
patchcheck:
- $(RUNSHARED) ./$(BUILDPYTHON) $(srcdir)/Tools/scripts/patchcheck.py
+ $(RUNPYTHON) $(srcdir)/Tools/scripts/patchcheck.py
# Dependencies
diff -Naur a/Modules/Setup.config.in b/Modules/Setup.config.in
--- a/Modules/Setup.config.in 2008-05-25 13:05:15.000000000 +0000
+++ b/Modules/Setup.config.in 2009-03-01 13:19:43.208433760 +0000
@@ -9,5 +9,20 @@
# The signal module
@USE_SIGNAL_MODULE@signal signalmodule.c
+# init system calls(posix/nt/...) for INITFUNC (used by makesetup)
+@INITSYS@ posixmodule.c
+
+# On win32 host(mingw build in MSYS environment) show that site.py
+# fail to load if some modules are not build-in:
+@BUILDIN_WIN32_MODULE@_functools _functoolsmodule.c # Tools for working with functions and callable objects
+@BUILDIN_WIN32_MODULE@_collections _collectionsmodule.c
+@BUILDIN_WIN32_MODULE@time timemodule.c
+@BUILDIN_WIN32_MODULE@operator operator.c # operator.add() and similar goodies
+@BUILDIN_WIN32_MODULE@_locale _localemodule.c # -lintl
+@BUILDIN_WIN32_MODULE@winreg ../PC/winreg.c
+@BUILDIN_WIN32_MODULE@msvcrt ../PC/msvcrtmodule.c
+@BUILDIN_WIN32_MODULE@_subprocess ../PC/_subprocess.c
+
+
# The rest of the modules previously listed in this file are built
# by the setup.py script in Python 2.1 and later.
diff -Naur a/Modules/Setup.dist b/Modules/Setup.dist
--- a/Modules/Setup.dist 2008-11-27 09:53:28.000000000 +0000
+++ b/Modules/Setup.dist 2009-03-01 04:37:28.000000000 +0000
@@ -105,9 +105,10 @@
# This only contains the minimal set of modules required to run the
# setup.py script in the root of the Python source tree.
-posix posixmodule.c # posix (UNIX) system calls
errno errnomodule.c # posix (UNIX) errno values
-pwd pwdmodule.c # this is needed to find out the user's home dir
+#FIXME: setup.py detect this module along with grp and spwd.
+#FIXME: what about to comment ?
+#pwd pwdmodule.c # this is needed to find out the user's home dir
# if $HOME is not set
_sre _sre.c # Fredrik Lundh's new regular expressions
_codecs _codecsmodule.c # access to the builtin codecs and codec registry
diff -Naur a/Modules/_ctypes/_ctypes.c b/Modules/_ctypes/_ctypes.c
--- a/Modules/_ctypes/_ctypes.c 2009-02-02 20:41:29.000000000 +0000
+++ b/Modules/_ctypes/_ctypes.c 2009-03-01 04:37:29.000000000 +0000
@@ -3029,14 +3029,32 @@
funcname -> _funcname@
where n is 0, 4, 8, 12, ..., 128
*/
+ /* TODO: memory leak for mangled_name
+ */
mangled_name = alloca(strlen(name) + 1 + 1 + 1 + 3); /* \0 _ @ %d */
if (!mangled_name)
return NULL;
+ /* FIXME: for stdcall decorated export functions MSVC compiler add
+ * underscore, but GCC compiler create them without.
+ * As well functions from system libraries are without underscore.
+ * This is visible by example for _ctypes_test.pyd module.
+ * Solutions:
+ * - If a python module is build with gcc option --add-stdcall-alias
+ * the module will contain XXX as alias for function XXX@ as result
+ * first search in this method will succeed.
+ * - Distutil may use compiler to create def-file, to modify it as
+ * add underscore alias and with new def file to create module.
+ * - Or may be just to search for function without underscore.
+ */
for (i = 0; i
#endif
diff -Naur a/Modules/_localemodule.c b/Modules/_localemodule.c
--- a/Modules/_localemodule.c 2009-02-01 10:41:18.000000000 +0000
+++ b/Modules/_localemodule.c 2009-03-01 04:37:34.000000000 +0000
@@ -10,6 +10,13 @@
******************************************************************/
#include "Python.h"
+#ifdef __MINGW32__
+/* The header libintl.h and library libintl may exist on mingw host.
+ * To be compatible with MSVC build we has to undef some defines.
+ */
+#undef HAVE_LIBINTL_H
+#undef HAVE_BIND_TEXTDOMAIN_CODESET
+#endif
#include
#include
diff -Naur a/Modules/cmathmodule.c b/Modules/cmathmodule.c
--- a/Modules/cmathmodule.c 2008-07-16 03:43:04.000000000 +0000
+++ b/Modules/cmathmodule.c 2009-03-01 04:37:33.000000000 +0000
@@ -55,6 +55,21 @@
static Py_complex c_tanh(Py_complex);
static PyObject * math_error(void);
+#ifndef TANH_PRESERVES_ZERO_SIGN
+#ifdef __MINGW32__
+/* "math" module has a cross-platform atan2() implemenation, but
+ * "cmath" lack it.
+ * Since atan2() is broken on some msvcrt implementations and mingw32
+ * provide a long double version we will use it as work-arround
+ * independently from define of TANH_PRESERVES_ZERO_SIGN.
+ * NOTE: For mingw host configure override always result after check
+ * so that TANH_PRESERVES_ZERO_SIGN is not defined.
+ */
+static double fake_atan2 (double y, double x) { return atan2l (y, x); }
+#define atan2 fake_atan2
+#endif
+#endif /*ndef TANH_PRESERVES_ZERO_SIGN*/
+
/* Code to deal with special values (infinities, NaNs, etc.). */
/* special_type takes a double and returns an integer code indicating
diff -Naur a/Modules/getaddrinfo.c b/Modules/getaddrinfo.c
--- a/Modules/getaddrinfo.c 2007-02-27 19:06:23.000000000 +0000
+++ b/Modules/getaddrinfo.c 2009-03-01 04:37:29.000000000 +0000
@@ -232,6 +232,9 @@
return YES;
}
+#ifndef EAI_BADHINTS
+# define EAI_BADHINTS EAI_BADFLAGS
+#endif
int
getaddrinfo(const char*hostname, const char*servname,
const struct addrinfo *hints, struct addrinfo **res)
diff -Naur a/Modules/getnameinfo.c b/Modules/getnameinfo.c
--- a/Modules/getnameinfo.c 2007-02-27 19:06:23.000000000 +0000
+++ b/Modules/getnameinfo.c 2009-03-01 04:37:28.000000000 +0000
@@ -48,6 +48,14 @@
#include "addrinfo.h"
#endif
+#ifndef IN_EXPERIMENTAL
+#define IN_EXPERIMENTAL(i) (((i) & 0xe0000000U) == 0xe0000000U)
+#endif
+
+#ifndef IN_LOOPBACKNET
+#define IN_LOOPBACKNET 127
+#endif
+
#define SUCCESS 0
#define YES 1
#define NO 0
diff -Naur a/Modules/mathmodule.c b/Modules/mathmodule.c
--- a/Modules/mathmodule.c 2008-12-21 00:55:55.000000000 +0000
+++ b/Modules/mathmodule.c 2009-03-01 04:37:33.000000000 +0000
@@ -60,6 +60,15 @@
extern double copysign(double, double);
#endif
+#ifdef __MINGW32__
+/* Since ldexp() is broken on some msvcrt implementations and mingw32
+ * provide a long double version we will use it as work-arround.
+ * Broken ldexp return for ldexp(1., INT_MAX) 0(zero) instead inf.
+ */
+static double fake_ldexp (double x, int expn) { return ldexpl (x, expn); }
+#define ldexp fake_ldexp
+#endif
+
/* Call is_error when errno != 0, and where x is the result libm
* returned. is_error will usually set up an exception and return
* true (1), but may return false (0) without setting up an exception.
diff -Naur a/Modules/posixmodule.c b/Modules/posixmodule.c
--- a/Modules/posixmodule.c 2008-12-29 18:23:24.000000000 +0000
+++ b/Modules/posixmodule.c 2009-03-01 04:40:25.000000000 +0000
@@ -128,6 +128,16 @@
#define HAVE_CWAIT 1
#define HAVE_FSYNC 1
#define fsync _commit
+#elif defined(__MINGW32__) /* GCC (mingw special) compiler */
+/*#define HAVE_GETCWD 1 - detected by configure*/
+#define HAVE_SPAWNV 1
+/*#define HAVE_EXECV 1 - detected by configure*/
+#define HAVE_PIPE 1
+#define HAVE_POPEN 1
+#define HAVE_SYSTEM 1
+#define HAVE_CWAIT 1
+#define HAVE_FSYNC 1
+#define fsync _commit
#else
#if defined(PYOS_OS2) && defined(PYCC_GCC) || defined(__VMS)
/* Everything needed is defined in PC/os2emx/pyconfig.h or vms/pyconfig.h */
@@ -252,7 +262,7 @@
#endif
#endif
-#ifdef _MSC_VER
+#if defined(_MSC_VER) || defined(__MINGW32__)
#ifdef HAVE_DIRECT_H
#include
#endif
@@ -338,7 +348,7 @@
*/
#include
static char **environ;
-#elif !defined(_MSC_VER) && ( !defined(__WATCOMC__) || defined(__QNX__) )
+#elif !defined(_MSC_VER) && !defined(__MINGW32__) && ( !defined(__WATCOMC__) || defined(__QNX__) )
extern char **environ;
#endif /* !_MSC_VER */
@@ -6618,6 +6628,13 @@
#endif
#ifdef MS_WINDOWS
+#ifdef __MINGW32__
+/* FIXME: all sample msdn wincrypt programs include this header.
+ * It is required if we use mingw w32api.
+ * Why MSVC builds don't include it ?
+ */
+# include
+#endif
PyDoc_STRVAR(win32_urandom__doc__,
"urandom(n) -> str\n\n\
@@ -7340,7 +7357,7 @@
}
-#if (defined(_MSC_VER) || defined(__WATCOMC__) || defined(__BORLANDC__)) && !defined(__QNX__)
+#if (defined(_MSC_VER) || defined (__MINGW32__) || defined(__WATCOMC__) || defined(__BORLANDC__)) && !defined(__QNX__)
#define INITFUNC PyInit_nt
#define MODNAME "nt"
diff -Naur a/Modules/python.c b/Modules/python.c
--- a/Modules/python.c 2008-10-19 14:15:00.000000000 +0000
+++ b/Modules/python.c 2009-03-01 10:54:30.736930752 +0000
@@ -7,7 +7,7 @@
#include
#endif
-#ifdef MS_WINDOWS
+#if 0
int
wmain(int argc, wchar_t **argv)
{
diff -Naur a/Modules/selectmodule.c b/Modules/selectmodule.c
--- a/Modules/selectmodule.c 2009-02-02 20:41:29.000000000 +0000
+++ b/Modules/selectmodule.c 2009-03-01 04:37:29.000000000 +0000
@@ -108,9 +108,10 @@
v = PyObject_AsFileDescriptor( o );
if (v == -1) goto finally;
-#if defined(_MSC_VER)
+#if defined(_MSC_VER) || defined(__MINGW32__)
+/* FIXME: why not #ifdef Py_SOCKET_FD_CAN_BE_GE_FD_SETSIZE ? */
max = 0; /* not used for Win32 */
-#else /* !_MSC_VER */
+#else /* !_MSC_VER & !__MINGW32__ */
if (v = FD_SETSIZE) {
PyErr_SetString(PyExc_ValueError,
"filedescriptor out of range in select()");
@@ -118,7 +119,7 @@
}
if (v > max)
max = v;
-#endif /* _MSC_VER */
+#endif /* _MSC_VER, __MINGW32__ */
FD_SET(v, set);
/* add object and its file descriptor to the list */
@@ -161,7 +162,8 @@
for (j = 0; fd2obj[j].sentinel >= 0; j++) {
fd = fd2obj[j].fd;
if (FD_ISSET(fd, set)) {
-#ifndef _MSC_VER
+#if !defined(_MSC_VER) && !defined(__MINGW32__)
+/* FIXME: why not #ifndef Py_SOCKET_FD_CAN_BE_GE_FD_SETSIZE ? */
if (fd > FD_SETSIZE) {
PyErr_SetString(PyExc_SystemError,
"filedescriptor out of range returned in select()");
diff -Naur a/Modules/socketmodule.c b/Modules/socketmodule.c
--- a/Modules/socketmodule.c 2009-02-06 02:50:18.000000000 +0000
+++ b/Modules/socketmodule.c 2009-03-01 04:37:34.000000000 +0000
@@ -90,6 +90,15 @@
#endif
#include "Python.h"
+#ifndef HAVE_GETPEERNAME
+/* FIXME: see comments in configure.in. Also PC/pyconfig.h define it.
+ * Since only this module use getpeername why don't remove declaration
+ * from PC/pyconfig.h and define here if is defined MS_WIN32 ?
+ */
+#ifdef __MINGW32__
+# define HAVE_GETPEERNAME
+#endif
+#endif /* ndef HAVE_GETPEERNAME */
#include "structmember.h"
#undef MAX
@@ -300,6 +309,35 @@
/* Do not include addrinfo.h for MSVC7 or greater. 'addrinfo' and
* EAI_* constants are defined in (the already included) ws2tcpip.h.
*/
+#elif defined(__MINGW32__)
+/* FIXME: getaddrinfo(HAVE_GETADDRINFO) depend from WINVER
+ TODO: resolve later(see comments in pyport.h) */
+#if 0
+/* To use getaddrinfo/getnameinfo from runtime for version before 0x0501
+ we has to define those functions (see below).
+ In all cases mingw linker succeed to link binaries.
+ If you enable this code the load of module will fail on w2k
+ with message like this one:
+ "The specified procedure could not be found" */
+# if (_WIN32_WINNT = 0x0501.
+ MSDN say that gai_strerror() exist for w95 and later and
+ getaddrinfo()/getnameinfo() for wxp and later.
+ Since we use fake function to suppress warnign we has to undef. */
+# undef gai_strerror
+#endif
+#endif /*def __MINGW32__*/
#define gai_strerror fake_gai_strerror
#define freeaddrinfo fake_freeaddrinfo
#include "getaddrinfo.c"
@@ -2681,7 +2729,21 @@
Shut down the reading side of the socket (flag == SHUT_RD), the writing side\n\
of the socket (flag == SHUT_WR), or both ends (flag == SHUT_RDWR).");
+#ifndef SIO_RCVALL
+#ifdef __MINGW32__
+/* defined in mstcpip.h, also note "Separate SDKs" required for w2k */
+/* TODO: to test on w2k */
+# define SIO_RCVALL 0x98000001
+# define RCVALL_OFF 0
+# define RCVALL_ON 1
+ /* NOTE: MSDN - this feature is not implemented */
+# define RCVALL_SOCKETLEVELONLY 2
+#endif
+#endif
#if defined(MS_WINDOWS) && defined(SIO_RCVALL)
+/* If isn't defined test_socket.py fail with:
+AttributeError: type object '_socket.socket' has no attribute 'ioctl'
+*/
static PyObject*
sock_ioctl(PySocketSockObject *s, PyObject *arg)
{
diff -Naur a/Objects/fileobject.c b/Objects/fileobject.c
--- a/Objects/fileobject.c 2009-02-02 20:41:29.000000000 +0000
+++ b/Objects/fileobject.c 2009-03-01 05:20:50.000000000 +0000
@@ -13,6 +13,22 @@
#define FUNLOCKFILE(f)
#endif
+#ifdef MS_WINDOWS
+#if !defined(__MINGW32__)
+/* avoid 'warning: "fileno" redefined' */
+#define fileno _fileno
+#endif
+/* can simulate truncate with Win32 API functions; see file_truncate */
+#ifndef HAVE_FTRUNCATE
+/* NOTE: autotool based build check and set it
+ FIXME: why isn't defined in PC/pyconfig.h ?
+ */
+#define HAVE_FTRUNCATE
+#endif
+#define WIN32_LEAN_AND_MEAN
+#include
+#endif
+
/* Newline flags */
#define NEWLINE_UNKNOWN 0 /* No newline seen, yet */
#define NEWLINE_CR 1 /* \r newline seen */
diff -Naur a/PC/msvcrtmodule.c b/PC/msvcrtmodule.c
--- a/PC/msvcrtmodule.c 2008-11-30 22:46:23.000000000 +0000
+++ b/PC/msvcrtmodule.c 2009-03-01 13:04:57.105141936 +0000
@@ -21,9 +21,33 @@
#include
#include
#include
-#include
#include
+#if defined(__MINGW32__)
+#if __MSVCRT_VERSION__ >= 0x0700
+# define _WCONIO_DEFINED
+/* NOTE: Up to version ?.?? mingw don't define functions
+ * listed below. Also it require module to be linked with
+ * ms-vcrt at least verion 7.
+ * To build with different runtimes see:
+ * http://www.mingw.org/wiki/HOWTO_Use_the_GCC_specs_file
+ *
+ * Also note that NT5.1(XP), shiped with msvcrt version 7.0,
+ * contain all those functions, but library name is msvcrt.dll.
+ * So if you like module to run on w2k as is you must define
+ * appropriate __MSVCRT_VERSION__ .
+ * If you like those functions even on w2k you must link
+ * with appropriate runtime and to pack it in distributions.
+ * This is what MSVC build do - it is build and packed
+ * with version 9.0 of Microsoft C-runtime.
+ */
+_CRTIMP wint_t __cdecl __MINGW_NOTHROW _getwch (void);
+_CRTIMP wint_t __cdecl __MINGW_NOTHROW _getwche (void);
+_CRTIMP wint_t __cdecl __MINGW_NOTHROW _putwch (wchar_t);
+_CRTIMP wint_t __cdecl __MINGW_NOTHROW _ungetwch(wint_t);
+#endif /* __MSVCRT_VERSION__ >= 0x0700 */
+#endif
+
#ifdef _MSC_VER
#if _MSC_VER >= 1500
#include
@@ -260,6 +284,7 @@
if (!PyArg_ParseTuple(args, "u:ungetwch", &ch))
return NULL;
+ /* FIXME: why _ungetch is called instead _ungetwch */
if (_ungetch(ch) == EOF)
return PyErr_SetFromErrno(PyExc_IOError);
Py_INCREF(Py_None);
diff -Naur a/PC/winreg.c b/PC/winreg.c
--- a/PC/winreg.c 2009-02-02 20:41:29.000000000 +0000
+++ b/PC/winreg.c 2009-03-01 04:37:25.000000000 +0000
@@ -16,6 +16,18 @@
#include "structmember.h"
#include "windows.h"
+#if defined(__MINGW32__)
+_CRTIMP size_t __cdecl __MINGW_NOTHROW _mbstrlen(const char *s);
+#endif
+
+#if !defined(REG_LEGAL_CHANGE_FILTER)
+#define REG_LEGAL_CHANGE_FILTER \
+ (REG_NOTIFY_CHANGE_NAME |\
+ REG_NOTIFY_CHANGE_ATTRIBUTES |\
+ REG_NOTIFY_CHANGE_LAST_SET |\
+ REG_NOTIFY_CHANGE_SECURITY)
+#endif
+
static BOOL PyHKEY_AsHKEY(PyObject *ob, HKEY *pRes, BOOL bNoneOK);
static PyObject *PyHKEY_FromHKEY(HKEY h);
static BOOL PyHKEY_Close(PyObject *obHandle);
diff -Naur a/Python/dynload_win.c b/Python/dynload_win.c
--- a/Python/dynload_win.c 2009-01-27 23:50:56.000000000 +0000
+++ b/Python/dynload_win.c 2009-03-01 04:37:26.000000000 +0000
@@ -11,9 +11,11 @@
#include "importdl.h"
#include
-// "activation context" magic - see dl_nt.c...
+#ifdef Py_ENABLE_SHARED
+/* "activation context" magic - see dl_nt.c... */
extern ULONG_PTR _Py_ActivateActCtx();
void _Py_DeactivateActCtx(ULONG_PTR cookie);
+#endif
const struct filedescr _PyImport_DynLoadFiletab[] = {
#ifdef _DEBUG
@@ -25,6 +27,10 @@
};
+#if defined(__MINGW32__)
+/* strcasecmp fail to compile on gcc(mingw32 special) */
+# define strcasecmp fake_strcasecmp
+#endif
/* Case insensitive string compare, to avoid any dependencies on particular
C RTL implementations */
@@ -190,11 +196,15 @@
sizeof(pathbuf),
pathbuf,
&dummy)) {
+#ifdef Py_ENABLE_SHARED
ULONG_PTR cookie = _Py_ActivateActCtx();
+#endif
/* XXX This call doesn't exist in Windows CE */
hDLL = LoadLibraryEx(pathname, NULL,
LOAD_WITH_ALTERED_SEARCH_PATH);
+#ifdef Py_ENABLE_SHARED
_Py_DeactivateActCtx(cookie);
+#endif
}
/* restore old error mode settings */
diff -Naur a/Python/fileblocks.c b/Python/fileblocks.c
--- a/Python/fileblocks.c 1970-01-01 00:00:00.000000000 +0000
+++ b/Python/fileblocks.c 2009-03-01 04:37:26.000000000 +0000
@@ -0,0 +1,17 @@
+/*
+-- Macro: AC_STRUCT_ST_BLOCKS
+ If `struct stat' contains an `st_blocks' member, define
+ `HAVE_STRUCT_STAT_ST_BLOCKS'. Otherwise, require an `AC_LIBOBJ'
+ replacement of `fileblocks'.
+*/
+
+#if !HAVE_STRUCT_STAT_ST_BLOCKS
+/* If necessary you may see gnulib for replacement function:
+off_t st_blocks (off_t size)
+You may found code available under GPL2 or GPL3.
+*/
+#else
+/* This declaration is solely to ensure that after preprocessing
+ this file is never empty. */
+typedef int textutils_fileblocks_unused;
+#endif
diff -Naur a/Python/import.c b/Python/import.c
--- a/Python/import.c 2009-02-02 20:41:29.000000000 +0000
+++ b/Python/import.c 2009-03-01 06:38:20.798516552 +0000
@@ -23,9 +23,11 @@
#endif
#ifdef MS_WINDOWS
+#ifndef __MINGW32__
/* for stat.st_mode */
typedef unsigned short mode_t;
#endif
+#endif
extern time_t PyOS_GetLastModificationTime(char *, FILE *);
/* In getmtime.c */
diff -Naur a/Python/pythonrun.c b/Python/pythonrun.c
--- a/Python/pythonrun.c 2009-01-26 22:03:09.000000000 +0000
+++ b/Python/pythonrun.c 2009-03-01 06:39:17.371916088 +0000
@@ -35,8 +35,10 @@
#ifdef MS_WINDOWS
#undef BYTE
#include "windows.h"
+#ifndef __MINGW32__
#define PATH_MAX MAXPATHLEN
#endif
+#endif
#ifndef Py_REF_DEBUG
#define PRINT_TOTAL_REFS()
diff -Naur a/configure b/configure
--- a/configure 2009-01-05 19:53:36.000000000 +0000
+++ b/configure 2009-03-01 06:56:29.070074128 +0000
@@ -1,5 +1,5 @@
#! /bin/sh
-# From configure.in Revision: 68280 .
+# From configure.in Revision: 68442 .
# Guess values for system-dependent variables and create Makefiles.
# Generated by GNU Autoconf 2.61 for python 3.0.
#
@@ -669,6 +669,7 @@
FRAMEWORKALTINSTALLLAST
FRAMEWORKUNIXTOOLSPREFIX
MACHDEP
+INITSYS
SGI_ABI
CONFIGURE_MACOSX_DEPLOYMENT_TARGET
EXPORT_MACOSX_DEPLOYMENT_TARGET
@@ -717,6 +718,7 @@
USE_THREAD_MODULE
LDLAST
THREADOBJ
+BUILDIN_WIN32_MODULE
DLINCLDIR
DYNLOADFILE
MACHDEP_OBJS
@@ -730,6 +732,9 @@
LIBM
LIBC
THREADHEADERS
+PYMOD_BUILDOPT
+PYTHON_OBJS_FROZENMAIN
+MODULE_GETPATH
SRCDIRS
LTLIBOBJS'
ac_subst_files=''
@@ -1811,7 +1816,14 @@
mv confdefs.h.new confdefs.h
+case $host in
+ *-*-mingw*)
+ VERSION=`echo 3.0 | sed -e 's|\.||g'`
+ ;;
+ *)
VERSION=3.0
+ ;;
+esac
SOVERSION=1.0
@@ -2034,6 +2046,15 @@
echo $ECHO_N "checking MACHDEP... $ECHO_C" >&6; }
if test -z "$MACHDEP"
then
+ case $host in
+ *-*-mingw*)
+ ac_sys_system=ignore
+ MACHDEP=win
+ ;;
+ esac
+fi
+if test -z "$MACHDEP"
+then
ac_sys_system=`uname -s`
if test "$ac_sys_system" = "AIX" -o "$ac_sys_system" = "Monterey64" \
-o "$ac_sys_system" = "UnixWare" -o "$ac_sys_system" = "OpenUNIX"; then
@@ -2056,6 +2077,19 @@
esac
fi
+{ echo "$as_me:$LINENO: checking for init system calls" >&5
+echo $ECHO_N "checking for init system calls... $ECHO_C" >&6; }
+
+case $host in
+ # FIXME: May configure lack detection for os2 host system ?
+ #?#*-*-os2*) INITSYS=os2;;
+ *-*-mingw*) INITSYS=nt;;
+ *) INITSYS=posix;;
+esac
+{ echo "$as_me:$LINENO: result: $INITSYS" >&5
+echo "${ECHO_T}$INITSYS" >&6; }
+
+
# Some systems cannot stand _XOPEN_SOURCE being defined at all; they
# disable features if it is defined, without any means to access these
# features as extensions. For these systems, we skip the definition of
@@ -2228,7 +2262,7 @@
if test "${with_gcc+set}" = set; then
withval=$with_gcc;
case $withval in
- no) CC=cc
+ no) CC=${CC:-cc}
without_gcc=yes;;
yes) CC=gcc
without_gcc=no;;
@@ -3949,6 +3983,10 @@
*)
enable_shared="no";;
esac
+ case $host in
+ *-*-mingw*)
+ enable_shared="yes";;
+ esac
fi
{ echo "$as_me:$LINENO: result: $enable_shared" >&5
echo "${ECHO_T}$enable_shared" >&6; }
@@ -4092,6 +4130,12 @@
;;
esac
+ case $host in
+ *-*-mingw*)
+ LDLIBRARY='libpython$(VERSION).dll.a'
+ DLLLIBRARY='libpython$(VERSION).dll'
+ ;;
+ esac
else # shared is disabled
case $ac_sys_system in
CYGWIN*)
@@ -4099,6 +4143,10 @@
LDLIBRARY='libpython$(VERSION).dll.a'
;;
esac
+ case $host in
+ *-*-mingw*)
+ LDLIBRARY='libpython$(VERSION).a';;
+ esac
fi
{ echo "$as_me:$LINENO: result: $LDLIBRARY" >&5
@@ -4446,6 +4494,27 @@
echo "${ECHO_T}no" >&6; }
fi
+# FIXME: We define BUILDEXEEXT and LDLIBRARY above but:
+# For debug versions MSVC build prepend suffix by '_d'.
+# If we support this convention we may modify distutils(TODO).
+# To support different build directories is good "--with-pydebug"
+# to be earlier in the script(why i wrote this?).
+if test "x$Py_DEBUG" = xtrue; then
+ case $host in
+ # Since Makefile.pre.in may isn't suitable for now we will not
+ # change LDLIBRARY.
+ *-*-mingw*)
+ BUILDEXEEXT=_d$BUILDEXEEXT
+ if test x$enable_shared = xyes; then
+ #LDLIBRARY='libpython$(VERSION)_d.dll.a'
+ DLLLIBRARY='libpython$(VERSION)_d.dll'
+ else # shared is disabled
+ #LDLIBRARY='libpython$(VERSION)_d.dll.a';;
+ :
+ fi
+ ;;
+ esac
+fi
# XXX Shouldn't the code above that fiddles with BASECFLAGS and OPT be
# merged with this chunk of code?
@@ -4462,6 +4531,8 @@
# tweak OPT based on compiler and platform, only if the user didn't set
# it on the command line
+# NOTE: If user set OPT at this point script ignore all previously set
+# options (not important - BeOS is depricated for python 2.6+).
if test -z "$OPT"
then
@@ -4584,6 +4655,10 @@
alpha*)
BASECFLAGS="$BASECFLAGS -mieee"
;;
+ *-*-mingw*)
+ #MSVC compatable storage layout for bitfields in structures
+ BASECFLAGS="$BASECFLAGS -mms-bitfields"
+ ;;
esac
case $ac_sys_system in
@@ -4669,7 +4744,9 @@
esac
if test "$Py_DEBUG" = 'true'; then
- :
+ case $host in
+ *-*-mingw*) OPT="-D_DEBUG $OPT";;
+ esac
else
OPT="-DNDEBUG $OPT"
fi
@@ -5185,6 +5262,65 @@
echo "${ECHO_T}$ac_cv_pthread" >&6; }
fi
+if test "x$ac_cv_kpthread" = xno && \
+ test "x$ac_cv_kthread" = xno && \
+ test "x$ac_cv_pthread" = xno && \
+ test "x$ac_cv_pthread_is_default" = xno
+then
+ { echo "$as_me:$LINENO: checking for NT threads" >&5
+echo $ECHO_N "checking for NT threads... $ECHO_C" >&6; }
+ if test "${ac_cv_ntthread+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ cat >conftest.$ac_ext >conftest.$ac_ext
+cat >>conftest.$ac_ext &5
+ (eval "$ac_link") 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } && {
+ test -z "$ac_c_werror_flag" ||
+ test ! -s conftest.err
+ } && test -s conftest$ac_exeext &&
+ $as_test_x conftest$ac_exeext; then
+ ac_cv_ntthread=yes
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ ac_cv_ntthread=no
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
+ conftest$ac_exeext conftest.$ac_ext
+fi
+
+ { echo "$as_me:$LINENO: result: $ac_cv_ntthread" >&5
+echo "${ECHO_T}$ac_cv_ntthread" >&6; }
+fi
+
# If we have set a CC compiler flag for thread support then
# check if it works for CXX, too.
ac_cv_cxx_thread=no
@@ -5206,6 +5342,9 @@
then
CXX="$CXX -pthread"
ac_cv_cxx_thread=yes
+elif test "x$ac_cv_ntthread" = xyes
+then
+ ac_cv_cxx_thread=always
fi
if test $ac_cv_cxx_thread = yes
@@ -5525,6 +5664,7 @@
+
for ac_header in asm/types.h conio.h curses.h direct.h dlfcn.h errno.h \
fcntl.h grp.h \
ieeefp.h io.h langinfo.h libintl.h ncurses.h poll.h process.h pthread.h \
@@ -5536,7 +5676,7 @@
sys/termio.h sys/time.h \
sys/times.h sys/types.h sys/un.h sys/utsname.h sys/wait.h pty.h libutil.h \
sys/resource.h netpacket/packet.h sysexits.h bluetooth.h \
-bluetooth/bluetooth.h linux/tipc.h
+bluetooth/bluetooth.h linux/tipc.h winsock2.h
do
as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
@@ -12906,6 +13046,16 @@
CYGWIN*) SO=.dll;;
*) SO=.so;;
esac
+ case $host in
+ *-*-mingw*)
+ #NOTE: see _PyImport_DynLoadFiletab in dynload_win.c
+ if test "x$Py_DEBUG" = xtrue; then
+ SO=_d.pyd
+ else
+ SO=.pyd
+ fi
+ ;;
+ esac
else
# this might also be a termcap variable, see #610332
echo
@@ -13032,6 +13182,11 @@
atheos*) LDSHARED="gcc -shared";;
*) LDSHARED="ld";;
esac
+ case $host in
+ *-*-mingw*)
+ LDSHARED='$(CC) -shared -Wl,--enable-auto-image-base'
+ ;;
+ esac
fi
{ echo "$as_me:$LINENO: result: $LDSHARED" >&5
echo "${ECHO_T}$LDSHARED" >&6; }
@@ -13133,6 +13288,12 @@
# when running test_compile.py.
LINKFORSHARED='-Wl,-E -N 2048K';;
esac
+ case $host in
+ *-*-mingw*)
+ if test x$enable_shared = xyes; then
+ LINKFORSHARED='-Wl,--out-implib=$(LDLIBRARY)'
+ fi;;
+ esac
fi
{ echo "$as_me:$LINENO: result: $LINKFORSHARED" >&5
echo "${ECHO_T}$LINKFORSHARED" >&6; }
@@ -13151,6 +13312,12 @@
*)
CFLAGSFORSHARED='$(CCSHARED)'
esac
+ case $host in
+ *-*-mingw*)
+ # TODO mingw may needs CCSHARED when building extension DLLs
+ # but not when building the interpreter DLL.
+ CFLAGSFORSHARED='';;
+ esac
fi
{ echo "$as_me:$LINENO: result: $CFLAGSFORSHARED" >&5
echo "${ECHO_T}$CFLAGSFORSHARED" >&6; }
@@ -13830,6 +13997,19 @@
posix_threads=yes
THREADOBJ="Python/thread.o"
+elif test "x$ac_cv_ntthread" = xyes
+then
+ cat >>confdefs.h >confdefs.h site->locale->functools&operator
+ BUILDIN_WIN32_MODULE=
+ ;;
+esac
+
+
# Check for enable-ipv6
@@ -15763,6 +15955,14 @@
fi
;;
esac
+ case $host in
+ *-*-mingw*)
+ # FIXME: it is good to use portable "$OBJEXT" instead "o" but
+ # python build isn't yet ready to use it (see Makefile.pre.in)
+ #DYNLOADFILE="dynload_win.$OBJEXT"
+ DYNLOADFILE="dynload_win.o"
+ ;;
+ esac
fi
{ echo "$as_me:$LINENO: result: $DYNLOADFILE" >&5
echo "${ECHO_T}$DYNLOADFILE" >&6; }
@@ -15780,6 +15980,11 @@
{ echo "$as_me:$LINENO: checking MACHDEP_OBJS" >&5
echo $ECHO_N "checking MACHDEP_OBJS... $ECHO_C" >&6; }
+case $host in
+ *-*-mingw*)
+ extra_machdep_objs="PC/dl_nt.o PC/getpathp.o PC/import_nt.o"
+ ;;
+esac
if test -z "$MACHDEP_OBJS"
then
MACHDEP_OBJS=$extra_machdep_objs
@@ -15881,7 +16086,7 @@
mremap nice pathconf pause plock poll pthread_init \
putenv readlink realpath \
select setegid seteuid setgid \
- setlocale setregid setreuid setsid setpgid setpgrp setuid setvbuf snprintf \
+ setregid setreuid setsid setpgid setpgrp setuid setvbuf snprintf \
sigaction siginterrupt sigrelse strftime strlcpy \
sysconf tcgetpgrp tcsetpgrp tempnam timegm times tmpfile tmpnam tmpnam_r \
truncate uname unsetenv utimes waitpid wait3 wait4 wcscoll wcsxfrm _getpty
@@ -15978,6 +16183,7 @@
done
+
# For some functions, having a definition is not sufficient, since
# we want to take their address.
{ echo "$as_me:$LINENO: checking for chroot" >&5
@@ -18653,9 +18859,19 @@
sed 's/^/| /' conftest.$ac_ext >&5
-{ echo "$as_me:$LINENO: result: no" >&5
+case $host in
+ #FIXME: mingw define getaddinfo if WINVER >= 0x501, i.e. XP or greater.
+ #TODO: mingw require additional check.
+ #*-*-mingw*)
+ # AC_MSG_RESULT([yes])
+ # buggygetaddrinfo=no
+ # ;;
+ *)
+ { echo "$as_me:$LINENO: result: no" >&5
echo "${ECHO_T}no" >&6; }
-buggygetaddrinfo=yes
+ buggygetaddrinfo=yes
+ ;;
+esac
fi
@@ -19894,7 +20110,11 @@
cat >>conftest.$ac_ext
+#ifdef HAVE_WINSOCK2_H
+# include
+#else
+# include
+#endif
int
main ()
{
@@ -19953,8 +20173,15 @@
cat >>conftest.$ac_ext
-# include
+#ifdef HAVE_SYS_TYPES_H
+#include
+#endif
+#ifdef HAVE_SYS_SOCKET_H
+#include
+#endif
+#ifdef HAVE_WINSOCK2_H
+#include
+#endif
int
main ()
{
@@ -21157,6 +21384,9 @@
Darwin) ;;
*) LIBM=-lm
esac
+case $host in
+ *-*-mingw*) LIBM=;;
+esac
{ echo "$as_me:$LINENO: checking for --with-libm=STRING" >&5
echo $ECHO_N "checking for --with-libm=STRING... $ECHO_C" >&6; }
@@ -21279,6 +21509,12 @@
fi
+case $host in
+ *-*-mingw*)
+ # Some MSVC runtimes don't preserve zero sign.
+ # On mingw host we will use always replacemnt function.
+ ac_cv_tanh_preserves_zero_sign=no;;
+esac
{ echo "$as_me:$LINENO: result: $ac_cv_tanh_preserves_zero_sign" >&5
echo "${ECHO_T}$ac_cv_tanh_preserves_zero_sign" >&6; }
if test "$ac_cv_tanh_preserves_zero_sign" = yes
@@ -22029,7 +22265,10 @@
else
if test "$cross_compiling" = yes; then
- ac_cv_wchar_t_signed=yes
+ case $host in
+ *-*-mingw*) ac_cv_wchar_t_signed=no;;
+ *) ac_cv_wchar_t_signed=yes;;
+ esac
else
cat >conftest.$ac_ext &5
echo $ECHO_N "checking for build directories... $ECHO_C" >&6; }
for dir in $SRCDIRS; do
@@ -24918,6 +25186,7 @@
FRAMEWORKALTINSTALLLAST!$FRAMEWORKALTINSTALLLAST$ac_delim
FRAMEWORKUNIXTOOLSPREFIX!$FRAMEWORKUNIXTOOLSPREFIX$ac_delim
MACHDEP!$MACHDEP$ac_delim
+INITSYS!$INITSYS$ac_delim
SGI_ABI!$SGI_ABI$ac_delim
CONFIGURE_MACOSX_DEPLOYMENT_TARGET!$CONFIGURE_MACOSX_DEPLOYMENT_TARGET$ac_delim
EXPORT_MACOSX_DEPLOYMENT_TARGET!$EXPORT_MACOSX_DEPLOYMENT_TARGET$ac_delim
@@ -24961,7 +25230,6 @@
LINKFORSHARED!$LINKFORSHARED$ac_delim
CFLAGSFORSHARED!$CFLAGSFORSHARED$ac_delim
SHLIBS!$SHLIBS$ac_delim
-USE_SIGNAL_MODULE!$USE_SIGNAL_MODULE$ac_delim
_ACEOF
if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 97; then
@@ -25003,10 +25271,12 @@
ac_delim='%!_!# '
for ac_last_try in false false false false false :; do
cat >conf$$subs.sed &5
diff -Naur a/configure.in b/configure.in
--- a/configure.in 2009-01-09 04:17:34.000000000 +0000
+++ b/configure.in 2009-03-01 06:56:36.479947656 +0000
@@ -34,7 +34,15 @@
mv confdefs.h.new confdefs.h
AC_SUBST(VERSION)
+case $host in
+ *-*-mingw*)
+ dnl To be compatible with MSVC build.
+VERSION=`echo PYTHON_VERSION | sed -e 's|\.||g'`
+ ;;
+ *)
VERSION=PYTHON_VERSION
+ ;;
+esac
AC_SUBST(SOVERSION)
SOVERSION=1.0
@@ -214,6 +222,22 @@
AC_MSG_CHECKING(MACHDEP)
if test -z "$MACHDEP"
then
+ dnl set MACHDEP only on certain host systems
+ case $host in
+ *-*-mingw*)
+ dnl we use only case based on "host triplet"
+ ac_sys_system=ignore
+ dnl FIXME: what is correct:
+ dnl - PLATFORM is always "win32" (see define in PC/pyconfig.h )
+ dnl - getplatform.o is build with -DPLATFORM='"$(MACHDEP)"'
+ dnl - the platform specific files go in plat-$(MACHDEP)
+ dnl - but an item in PYTHONPATH is "plat-win" !!! oops
+ MACHDEP=win
+ ;;
+ esac
+fi
+if test -z "$MACHDEP"
+then
ac_sys_system=`uname -s`
if test "$ac_sys_system" = "AIX" -o "$ac_sys_system" = "Monterey64" \
-o "$ac_sys_system" = "UnixWare" -o "$ac_sys_system" = "OpenUNIX"; then
@@ -235,6 +259,17 @@
'') MACHDEP="unknown";;
esac
fi
+
+AC_MSG_CHECKING([for init system calls])
+AC_SUBST(INITSYS)
+case $host in
+ # FIXME: May configure lack detection for os2 host system ?
+ #?#*-*-os2*) INITSYS=os2;;
+ *-*-mingw*) INITSYS=nt;;
+ *) INITSYS=posix;;
+esac
+AC_MSG_RESULT([$INITSYS])
+
# Some systems cannot stand _XOPEN_SOURCE being defined at all; they
# disable features if it is defined, without any means to access these
@@ -607,6 +642,10 @@
*)
enable_shared="no";;
esac
+ case $host in
+ *-*-mingw*)
+ enable_shared="yes";;
+ esac
fi
AC_MSG_RESULT($enable_shared)
@@ -700,6 +739,14 @@
;;
esac
+ case $host in
+ *-*-mingw*)
+ LDLIBRARY='libpython$(VERSION).dll.a'
+ DLLLIBRARY='libpython$(VERSION).dll'
+ dnl setup.py add it for mingw host
+ dnl BLDLIBRARY='-L. -lpython$(VERSION)'
+ ;;
+ esac
else # shared is disabled
case $ac_sys_system in
CYGWIN*)
@@ -707,6 +754,10 @@
LDLIBRARY='libpython$(VERSION).dll.a'
;;
esac
+ case $host in
+ *-*-mingw*)
+ LDLIBRARY='libpython$(VERSION).a';;
+ esac
fi
AC_MSG_RESULT($LDLIBRARY)
@@ -744,6 +795,8 @@
esac
fi
+dnl TODO: to move --with-pydebug earlier in script and to group
+dnl debug related statements togeder (if posible)
# Check for --with-pydebug
AC_MSG_CHECKING(for --with-pydebug)
AC_ARG_WITH(pydebug,
@@ -758,6 +811,29 @@
else AC_MSG_RESULT(no); Py_DEBUG='false'
fi],
[AC_MSG_RESULT(no)])
+# FIXME: We define BUILDEXEEXT and LDLIBRARY above but:
+# For debug versions MSVC build prepend suffix by '_d'.
+# If we support this convention we may modify distutils(TODO).
+# To support different build directories is good "--with-pydebug"
+# to be earlier in the script(why i wrote this?).
+if test "x$Py_DEBUG" = xtrue; then
+ case $host in
+ dnl TODO: This is good to be where we define LDLIBRARY
+ dnl but --with-pydebug is defined too late in the script.
+ # Since Makefile.pre.in may isn't suitable for now we will not
+ # change LDLIBRARY.
+ *-*-mingw*)
+ BUILDEXEEXT=_d$BUILDEXEEXT
+ if test x$enable_shared = xyes; then
+ #LDLIBRARY='libpython$(VERSION)_d.dll.a'
+ DLLLIBRARY='libpython$(VERSION)_d.dll'
+ else # shared is disabled
+ #LDLIBRARY='libpython$(VERSION)_d.dll.a';;
+ :
+ fi
+ ;;
+ esac
+fi
# XXX Shouldn't the code above that fiddles with BASECFLAGS and OPT be
# merged with this chunk of code?
@@ -774,6 +850,8 @@
# tweak OPT based on compiler and platform, only if the user didn't set
# it on the command line
+# NOTE: If user set OPT at this point script ignore all previously set
+# options (not important - BeOS is depricated for python 2.6+).
AC_SUBST(OPT)
if test -z "$OPT"
then
@@ -854,6 +932,10 @@
alpha*)
BASECFLAGS="$BASECFLAGS -mieee"
;;
+ *-*-mingw*)
+ #MSVC compatable storage layout for bitfields in structures
+ BASECFLAGS="$BASECFLAGS -mms-bitfields"
+ ;;
esac
case $ac_sys_system in
@@ -936,8 +1018,15 @@
;;
esac
+dnl NOTE: although Py_DEBUG is set earlier in the script we can't move
+dnl before "# tweak OPT based on compiler" - if user specify environment
+dnl variable OPT we will lost our settings!!!
+dnl FIXME: why script add debug definition to OPT instead to BASECFLAGS?
if test "$Py_DEBUG" = 'true'; then
- :
+ case $host in
+ dnl Same as in PC/pyconfig.h but order in opposite(Py_DEBUG=>-D_DEBUG).
+ *-*-mingw*) OPT="-D_DEBUG $OPT";;
+ esac
else
OPT="-DNDEBUG $OPT"
fi
@@ -1132,6 +1221,20 @@
AC_MSG_RESULT($ac_cv_pthread)
fi
+if test "x$ac_cv_kpthread" = xno && \
+ test "x$ac_cv_kthread" = xno && \
+ test "x$ac_cv_pthread" = xno && \
+ test "x$ac_cv_pthread_is_default" = xno
+then
+ AC_MSG_CHECKING(for NT threads)
+ AC_CACHE_VAL(ac_cv_ntthread,
+ [AC_LINK_IFELSE(
+ AC_LANG_PROGRAM([], [_beginthread(0, 0, 0);]),
+ ac_cv_ntthread=yes,
+ ac_cv_ntthread=no)])
+ AC_MSG_RESULT([$ac_cv_ntthread])
+fi
+
# If we have set a CC compiler flag for thread support then
# check if it works for CXX, too.
ac_cv_cxx_thread=no
@@ -1152,6 +1255,9 @@
then
CXX="$CXX -pthread"
ac_cv_cxx_thread=yes
+elif test "x$ac_cv_ntthread" = xyes
+then
+ ac_cv_cxx_thread=always
fi
if test $ac_cv_cxx_thread = yes
@@ -1193,7 +1299,7 @@
sys/termio.h sys/time.h \
sys/times.h sys/types.h sys/un.h sys/utsname.h sys/wait.h pty.h libutil.h \
sys/resource.h netpacket/packet.h sysexits.h bluetooth.h \
-bluetooth/bluetooth.h linux/tipc.h)
+bluetooth/bluetooth.h linux/tipc.h winsock2.h)
AC_HEADER_DIRENT
AC_HEADER_MAJOR
@@ -1520,6 +1626,16 @@
CYGWIN*) SO=.dll;;
*) SO=.so;;
esac
+ case $host in
+ *-*-mingw*)
+ #NOTE: see _PyImport_DynLoadFiletab in dynload_win.c
+ if test "x$Py_DEBUG" = xtrue; then
+ SO=_d.pyd
+ else
+ SO=.pyd
+ fi
+ ;;
+ esac
else
# this might also be a termcap variable, see #610332
echo
@@ -1640,6 +1756,11 @@
atheos*) LDSHARED="gcc -shared";;
*) LDSHARED="ld";;
esac
+ case $host in
+ *-*-mingw*)
+ LDSHARED='$(CC) -shared -Wl,--enable-auto-image-base'
+ ;;
+ esac
fi
AC_MSG_RESULT($LDSHARED)
BLDSHARED=${BLDSHARED-$LDSHARED}
@@ -1737,6 +1858,12 @@
# when running test_compile.py.
LINKFORSHARED='-Wl,-E -N 2048K';;
esac
+ case $host in
+ *-*-mingw*)
+ if test x$enable_shared = xyes; then
+ LINKFORSHARED='-Wl,--out-implib=$(LDLIBRARY)'
+ fi;;
+ esac
fi
AC_MSG_RESULT($LINKFORSHARED)
@@ -1753,6 +1880,12 @@
*)
CFLAGSFORSHARED='$(CCSHARED)'
esac
+ case $host in
+ *-*-mingw*)
+ # TODO mingw may needs CCSHARED when building extension DLLs
+ # but not when building the interpreter DLL.
+ CFLAGSFORSHARED='';;
+ esac
fi
AC_MSG_RESULT($CFLAGSFORSHARED)
@@ -1920,6 +2053,13 @@
AC_DEFINE(WITH_THREAD)
posix_threads=yes
THREADOBJ="Python/thread.o"
+elif test "x$ac_cv_ntthread" = xyes
+then
+ AC_DEFINE(WITH_THREAD)
+ posix_threads=no
+ THREADOBJ="Python/thread.o"
+ AC_DEFINE(NT_THREADS, 1,
+ [Define to 1 if you want to use native NT threads])
else
if test ! -z "$with_threads" -a -d "$with_threads"
then LDFLAGS="$LDFLAGS -L$with_threads"
@@ -2079,6 +2219,18 @@
fi
+AC_SUBST(BUILDIN_WIN32_MODULE)
+BUILDIN_WIN32_MODULE='#'
+case $host in
+ *-*-mingw*)
+ # On win32 host(mingw build MSYS environment) site.py fail to load
+ # if _functools is not build-in by reason of dependency:
+ # setup->site->locale->functools&operator
+ BUILDIN_WIN32_MODULE=
+ ;;
+esac
+
+
# Check for enable-ipv6
AH_TEMPLATE(ENABLE_IPV6, [Define if --enable-ipv6 is specified])
AC_MSG_CHECKING([if --enable-ipv6 is specified])
@@ -2345,6 +2497,14 @@
fi
;;
esac
+ case $host in
+ *-*-mingw*)
+ # FIXME: it is good to use portable "$OBJEXT" instead "o" but
+ # python build isn't yet ready to use it (see Makefile.pre.in)
+ #DYNLOADFILE="dynload_win.$OBJEXT"
+ DYNLOADFILE="dynload_win.o"
+ ;;
+ esac
fi
AC_MSG_RESULT($DYNLOADFILE)
if test "$DYNLOADFILE" != "dynload_stub.o"
@@ -2357,6 +2517,11 @@
AC_SUBST(MACHDEP_OBJS)
AC_MSG_CHECKING(MACHDEP_OBJS)
+case $host in
+ *-*-mingw*)
+ extra_machdep_objs="PC/dl_nt.o PC/getpathp.o PC/import_nt.o"
+ ;;
+esac
if test -z "$MACHDEP_OBJS"
then
MACHDEP_OBJS=$extra_machdep_objs
@@ -2374,11 +2539,22 @@
mremap nice pathconf pause plock poll pthread_init \
putenv readlink realpath \
select setegid seteuid setgid \
- setlocale setregid setreuid setsid setpgid setpgrp setuid setvbuf snprintf \
+ setregid setreuid setsid setpgid setpgrp setuid setvbuf snprintf \
sigaction siginterrupt sigrelse strftime strlcpy \
sysconf tcgetpgrp tcsetpgrp tempnam timegm times tmpfile tmpnam tmpnam_r \
truncate uname unsetenv utimes waitpid wait3 wait4 wcscoll wcsxfrm _getpty)
+dnl NOTE: On windows platform some functions aren't C functions and require
+dnl additional non-standard decoration and may be libraries.
+dnl As example winsock2 functions, although are based on berkeley sockets
+dnl use stdcall convention. Also they require an additional library ws2_32.
+dnl One of those functions is "getpeername" (see list above)
+dnl and can't be detected by script. Now this impact mingw host platforms.
+dnl Since this function is used only by socketmodule, module include
+dnl necessary headers and is linked with requred libs (see setup.py)
+dnl windows exception will be handled in module code.
+dnl FIXME: If you don't like this, write appropriate check here.
+
# For some functions, having a definition is not sufficient, since
# we want to take their address.
AC_MSG_CHECKING(for chroot)
@@ -2759,8 +2935,18 @@
buggygetaddrinfo=yes,
AC_MSG_RESULT(buggy)
buggygetaddrinfo=yes)], [
-AC_MSG_RESULT(no)
-buggygetaddrinfo=yes
+case $host in
+ #FIXME: mingw define getaddinfo if WINVER >= 0x501, i.e. XP or greater.
+ #TODO: mingw require additional check.
+ #*-*-mingw*)
+ # AC_MSG_RESULT([yes])
+ # buggygetaddrinfo=no
+ # ;;
+ *)
+ AC_MSG_RESULT([no])
+ buggygetaddrinfo=yes
+ ;;
+esac
])
if test "$buggygetaddrinfo" = "yes"; then
@@ -2812,20 +2998,31 @@
AC_MSG_CHECKING(for addrinfo)
AC_CACHE_VAL(ac_cv_struct_addrinfo,
AC_TRY_COMPILE([
-# include ],
+#ifdef HAVE_WINSOCK2_H
+# include
+#else
+# include
+#endif],
[struct addrinfo a],
ac_cv_struct_addrinfo=yes,
ac_cv_struct_addrinfo=no))
AC_MSG_RESULT($ac_cv_struct_addrinfo)
if test $ac_cv_struct_addrinfo = yes; then
- AC_DEFINE(HAVE_ADDRINFO, 1, [struct addrinfo (netdb.h)])
+ AC_DEFINE(HAVE_ADDRINFO, 1, [struct addrinfo])
fi
AC_MSG_CHECKING(for sockaddr_storage)
AC_CACHE_VAL(ac_cv_struct_sockaddr_storage,
AC_TRY_COMPILE([
-# include
-# include ],
+#ifdef HAVE_SYS_TYPES_H
+#include
+#endif
+#ifdef HAVE_SYS_SOCKET_H
+#include
+#endif
+#ifdef HAVE_WINSOCK2_H
+#include
+#endif],
[struct sockaddr_storage s],
ac_cv_struct_sockaddr_storage=yes,
ac_cv_struct_sockaddr_storage=no))
@@ -3019,6 +3216,10 @@
Darwin) ;;
*) LIBM=-lm
esac
+dnl new style to set libraries for host system
+case $host in
+ *-*-mingw*) LIBM=;;
+esac
AC_MSG_CHECKING(for --with-libm=STRING)
AC_ARG_WITH(libm,
AC_HELP_STRING(--with-libm=STRING, math library),
@@ -3075,6 +3276,12 @@
ac_cv_tanh_preserves_zero_sign=yes,
ac_cv_tanh_preserves_zero_sign=no,
ac_cv_tanh_preserves_zero_sign=no)])
+case $host in
+ *-*-mingw*)
+ # Some MSVC runtimes don't preserve zero sign.
+ # On mingw host we will use always replacemnt function.
+ ac_cv_tanh_preserves_zero_sign=no;;
+esac
AC_MSG_RESULT($ac_cv_tanh_preserves_zero_sign)
if test "$ac_cv_tanh_preserves_zero_sign" = yes
then
@@ -3129,7 +3336,10 @@
],
ac_cv_wchar_t_signed=yes,
ac_cv_wchar_t_signed=no,
- ac_cv_wchar_t_signed=yes)])
+ [case $host in
+ *-*-mingw*) ac_cv_wchar_t_signed=no;;
+ *) ac_cv_wchar_t_signed=yes;;
+ esac])])
AC_MSG_RESULT($ac_cv_wchar_t_signed)
fi
@@ -3628,8 +3838,39 @@
THREADHEADERS="$THREADHEADERS \$(srcdir)/$h"
done
+# FIXME: in cross-compilation env. (mingw on linux) how to select correct compiler ?
+# The current py-code will created modules with .so suffix and environment
+# variable setting SO=$(SO) don't help
+# see output of: python setup.py build --help-compiler
+AC_SUBST(PYMOD_BUILDOPT)
+case $host in
+ *-*-mingw*) PYMOD_BUILDOPT="--compiler mingw32";;
+esac
+
+dnl Objects for python and modules
+# Python interpreter main program for frozen scripts
+AC_SUBST(PYTHON_OBJS_FROZENMAIN)
+PYTHON_OBJS_FROZENMAIN="Python/frozenmain.o"
+# MODULE_GETPATH - default sys.path calculations
+AC_SUBST(MODULE_GETPATH)
+MODULE_GETPATH=Modules/getpath.o
+case $host in
+ *-*-mingw*)
+ dnl "PC" is project sub-directory and we has to prepend user defined flags
+ CPPFLAGS="-I\$(srcdir)/Python -I\$(srcdir)/PC $CPPFLAGS"
+
+ # FIXME: why windows builds don't use PC/frozen_dllmain.o ?
+ PYTHON_OBJS_FROZENMAIN=""
+ # default sys.path calculations for windows platforms
+ MODULE_GETPATH=PC/getpathp.o
+ ;;
+esac
+
AC_SUBST(SRCDIRS)
SRCDIRS="Parser Grammar Objects Python Modules Mac"
+case $host in
+ *-*-mingw*) SRCDIRS="$SRCDIRS PC";;
+esac
AC_MSG_CHECKING(for build directories)
for dir in $SRCDIRS; do
if test ! -d $dir; then
diff -Naur a/pyconfig.h.in b/pyconfig.h.in
--- a/pyconfig.h.in 2008-09-07 06:24:49.000000000 +0000
+++ b/pyconfig.h.in 2009-03-01 08:51:03.668976240 +0000
@@ -28,7 +28,7 @@
/* Define to 1 if you have the `acosh' function. */
#undef HAVE_ACOSH
-/* struct addrinfo (netdb.h) */
+/* struct addrinfo */
#undef HAVE_ADDRINFO
/* Define to 1 if you have the `alarm' function. */
@@ -58,6 +58,10 @@
/* Define to 1 if you have the header file. */
#undef HAVE_BLUETOOTH_H
+/* Define if mbstowcs(NULL, "text", 0) does not return the number of wide
+ chars that would be converted. */
+#undef HAVE_BROKEN_MBSTOWCS
+
/* Define if nice() returns success/failure instead of the new priority. */
#undef HAVE_BROKEN_NICE
@@ -122,8 +126,11 @@
/* Define if we have /dev/ptc. */
#undef HAVE_DEV_PTC
+/* disable openpty always */
+#if 0
/* Define if we have /dev/ptmx. */
#undef HAVE_DEV_PTMX
+#endif
/* Define to 1 if you have the header file. */
#undef HAVE_DIRECT_H
@@ -180,8 +187,11 @@
/* Define to 1 if you have the `fork' function. */
#undef HAVE_FORK
+/* disable forkpty always */
+#if 0
/* Define to 1 if you have the `forkpty' function. */
#undef HAVE_FORKPTY
+#endif
/* Define to 1 if you have the `fpathconf' function. */
#undef HAVE_FPATHCONF
@@ -357,7 +367,7 @@
/* Define to 1 if you have the header file. */
#undef HAVE_LIBINTL_H
-/* Define to 1 if you have the `readline' library (-lreadline). */
+/* Define if you have the readline library (-lreadline). */
#undef HAVE_LIBREADLINE
/* Define to 1 if you have the `resolv' library (-lresolv). */
@@ -420,8 +430,11 @@
/* Define to 1 if you have the `nice' function. */
#undef HAVE_NICE
+/* disable openpty always */
+#if 0
/* Define to 1 if you have the `openpty' function. */
#undef HAVE_OPENPTY
+#endif
/* Define if compiling using MacOS X 10.5 SDK or later. */
#undef HAVE_OSX105_SDK
@@ -447,6 +460,8 @@
/* Define if your compiler supports function prototype */
#undef HAVE_PROTOTYPES
+/* disable pthreads, pty always */
+#if 0
/* Define if you have GNU PTH threads. */
#undef HAVE_PTH
@@ -464,6 +479,7 @@
/* Define to 1 if you have the header file. */
#undef HAVE_PTY_H
+#endif /* force disable */
/* Define to 1 if you have the `putenv' function. */
#undef HAVE_PUTENV
@@ -800,9 +816,8 @@
/* Define to 1 if you have the `wcsxfrm' function. */
#undef HAVE_WCSXFRM
-/* Define if mbstowcs(NULL, "text", 0) does not return the number of
- wide chars that would be converted */
-#undef HAVE_BROKEN_MBSTOWCS
+/* Define to 1 if you have the header file. */
+#undef HAVE_WINSOCK2_H
/* Define if tzset() actually switches the local timezone in a meaningful way.
*/
@@ -811,8 +826,11 @@
/* Define if the zlib library has inflateCopy */
#undef HAVE_ZLIB_COPY
+/* disable getpty always */
+#if 0
/* Define to 1 if you have the `_getpty' function. */
#undef HAVE__GETPTY
+#endif
/* Define if you are using Mach cthreads directly under /include */
#undef HURD_C_THREADS
@@ -831,6 +849,9 @@
/* Define if mvwdelch in curses.h is an expression. */
#undef MVWDELCH_IS_EXPRESSION
+/* Define to 1 if you want to use native NT threads */
+#undef NT_THREADS
+
/* Define to the address where bug reports for this package should be sent. */
#undef PACKAGE_BUGREPORT
diff -Naur a/setup.py b/setup.py
--- a/setup.py 2009-02-10 16:25:06.000000000 +0000
+++ b/setup.py 2009-03-01 04:46:38.000000000 +0000
@@ -115,7 +115,7 @@
# with Modules/ and adding Python's include directory to the path.
(srcdir,) = sysconfig.get_config_vars('srcdir')
if not srcdir:
- # Maybe running on Windows but not using CYGWIN?
+ # Maybe running on Windows but not using posix build?
raise ValueError("No source directory; cannot proceed.")
# Figure out the location of the source code for extension modules
@@ -189,8 +189,38 @@
if compiler is not None:
(ccshared,cflags) = sysconfig.get_config_vars('CCSHARED','CFLAGS')
args['compiler_so'] = compiler + ' ' + ccshared + ' ' + cflags
+
+ # FIXME: Is next correct ?
+ # To link modules we need LDSHARED passed to setup.py otherwise
+ # distutils will use linker from build system if cross-compiling.
+ linker_so = os.environ.get('LDSHARED')
+ if linker_so is not None:
+ args['linker_so'] = linker_so
+
self.compiler.set_executables(**args)
+ if platform in ['mingw', 'win32']:
+ # FIXME: best way to pass just build python library to the modules
+ self.compiler.library_dirs.insert(0, '.')
+ data = open('pyconfig.h').read()
+ m = re.search(r"#s*define\s+Py_DEBUG\s+1\s*", data)
+ if m is not None:
+ self.compiler.libraries.append("python" + str(sysconfig.get_config_var('VERSION')) + "_d")
+ else:
+ self.compiler.libraries.append("python" + str(sysconfig.get_config_var('VERSION')))
+
+ if platform in ['mingw', 'win32']:
+ # NOTE: See comment for SHLIBS in configure.in .
+ # Although it look obsolete since setup.py add module
+ # required libraries we will pass list too.
+ # As example this will allow us to propage static
+ # libraries like mingwex to modules.
+ for lib in sysconfig.get_config_var('SHLIBS').split():
+ if lib.startswith('-l'):
+ self.compiler.libraries.append(lib[2:])
+ else:
+ self.compiler.libraries.append(lib)
+
build_ext.build_extensions(self)
longest = max([len(e.name) for e in self.extensions])
@@ -261,6 +291,10 @@
self.announce('WARNING: skipping import check for Cygwin-based "%s"'
% ext.name)
return
+ if os.environ.get('HOST_OS') is not None:
+ self.announce('WARNING: skipping import check for cross-compiled "%s"'
+ % ext.name)
+ return
ext_filename = os.path.join(
self.build_lib,
self.get_ext_filename(self.get_ext_fullname(ext.name)))
@@ -302,6 +336,19 @@
self.failed.append(ext.name)
def get_platform(self):
+ # Get value of host platform (set only if cross-compile)
+ host_os=os.environ.get('HOST_OS')
+ if host_os is not None:
+ # FIXME: extend for other host platforms.
+ # Until isn't confirmed that we can use 'win32' in all places
+ # where 'mingw' is use alone this method has to return 'mingw'
+ # otherwise uncomment next two lines:
+ #if host_os.startswith('mingw'):
+ # return 'win32'
+ for platform in ['mingw', 'cygwin', 'beos', 'darwin', 'atheos', 'osf1']:
+ if host_os.startswith(platform):
+ return platform
+ return host_os
# Get value of sys.platform
for platform in ['cygwin', 'darwin', 'atheos', 'osf1']:
if sys.platform.startswith(platform):
@@ -319,6 +366,9 @@
# directly since an inconsistently reproducible issue comes up where
# the environment variable is not set even though the value were passed
# into configure and stored in the Makefile (issue found on OS X 10.3).
+ # In cross-compilation environment python for build system
+ # is linked in top build directory under name syspython to get
+ # above to work (distutils hack).
for env_var, arg_name, dir_list in (
('LDFLAGS', '-R', self.compiler.runtime_library_dirs),
('LDFLAGS', '-L', self.compiler.library_dirs),
@@ -388,6 +438,7 @@
# NOTE: using shlex.split would technically be more correct, but
# also gives a bootstrap problem. Let's hope nobody uses directories
# with whitespace in the name to store libraries.
+ # FIXME: Why LDFLAGS again ?
cflags, ldflags = sysconfig.get_config_vars(
'CFLAGS', 'LDFLAGS')
for item in cflags.split():
@@ -400,7 +451,7 @@
# Check for MacOS X, which doesn't need libm.a at all
math_libs = ['m']
- if platform in ['darwin', 'mac']:
+ if platform in ['darwin', 'mac', 'mingw', 'win32']:
math_libs = []
# XXX Omitted modules: gl, pure, dl, SGI-specific modules
@@ -438,9 +489,11 @@
# heapq
exts.append( Extension("_heapq", ["_heapqmodule.c"]) )
# operator.add() and similar goodies
- exts.append( Extension('operator', ['operator.c']) )
+ if platform not in ['mingw', 'win32']:
+ exts.append( Extension('operator', ['operator.c']) )
# _functools
- exts.append( Extension("_functools", ["_functoolsmodule.c"]) )
+ if platform not in ['mingw', 'win32']:
+ exts.append( Extension("_functools", ["_functoolsmodule.c"]) )
# C-optimized pickle replacement
exts.append( Extension("_pickle", ["_pickle.c"]) )
# atexit
@@ -467,7 +520,10 @@
locale_extra_link_args = []
- exts.append( Extension('_locale', ['_localemodule.c'],
+ # On win32 host(mingw build in MSYS environment) show that site.py
+ # fail to load if some modules are not build-in:
+ if platform not in ['mingw', 'win32']:
+ exts.append( Extension('_locale', ['_localemodule.c'],
libraries=locale_libs,
extra_link_args=locale_extra_link_args) )
@@ -476,8 +532,11 @@
# supported...)
# fcntl(2) and ioctl(2)
- exts.append( Extension('fcntl', ['fcntlmodule.c']) )
- if platform not in ['mac']:
+ if platform not in ['mingw', 'win32']:
+ exts.append( Extension('fcntl', ['fcntlmodule.c']) )
+ else:
+ missing.append('fcntl')
+ if platform not in ['mac', 'mingw', 'win32']:
# pwd(3)
exts.append( Extension('pwd', ['pwdmodule.c']) )
# grp(3)
@@ -492,7 +551,12 @@
missing.extend(['pwd', 'grp', 'spwd'])
# select(2); not on ancient System V
- exts.append( Extension('select', ['selectmodule.c']) )
+ if platform in ['mingw', 'win32']:
+ select_libs = ['ws2_32']
+ else:
+ select_libs = []
+ exts.append( Extension('select', ['selectmodule.c'],
+ libraries=select_libs) )
# Fred Drake's interface to the Python parser
exts.append( Extension('parser', ['parsermodule.c']) )
@@ -504,7 +568,7 @@
missing.append('mmap')
# Lance Ellinghaus's syslog module
- if platform not in ['mac']:
+ if platform not in ['mac', 'mingw', 'win32']:
# syslog daemon interface
exts.append( Extension('syslog', ['syslogmodule.c']) )
else:
@@ -526,6 +590,11 @@
# readline
do_readline = self.compiler.find_library_file(lib_dirs, 'readline')
+ if platform in ['mingw', 'win32']:
+ # MSVC builds don't use readline.
+ # In cross-compilation environment readline check will
+ # find libraries on build system.
+ do_readline = False
if platform == 'darwin': # and os.uname()[2] = version_req:
if (self.compiler.find_library_file(lib_dirs, 'z')):
- if sys.platform == "darwin":
+ if platform == "darwin":
zlib_extra_link_args = ('-Wl,-search_paths_first',)
else:
zlib_extra_link_args = ()
@@ -938,7 +1044,7 @@
# Gustavo Niemeyer's bz2 module.
if (self.compiler.find_library_file(lib_dirs, 'bz2')):
- if sys.platform == "darwin":
+ if platform == "darwin":
bz2_extra_link_args = ('-Wl,-search_paths_first',)
else:
bz2_extra_link_args = ()
@@ -1000,7 +1106,7 @@
# _fileio -- supposedly cross platform
exts.append(Extension('_fileio', ['_fileio.c']))
# Richard Oudkerk's multiprocessing module
- if platform == 'win32': # Windows
+ if platform in ['mingw', 'win32']: # Windows
macros = dict()
libraries = ['ws2_32']
@@ -1048,7 +1154,7 @@
)
libraries = ['rt']
- if platform == 'win32':
+ if platform in ['mingw', 'win32']:
multiprocessing_srcs = [ '_multiprocessing/multiprocessing.c',
'_multiprocessing/semaphore.c',
'_multiprocessing/pipe_connection.c',
@@ -1192,7 +1298,7 @@
# Check for the include files on Debian and {Free,Open}BSD, where
# they're put in /usr/include/{tcl,tk}X.Y
dotversion = version
- if '.' not in dotversion and "bsd" in sys.platform.lower():
+ if '.' not in dotversion and "bsd" in platform.lower():
# OpenBSD and FreeBSD use Tcl/Tk library names like libtcl83.a,
# but the include subdirs are named like .../include/tcl8.3.
dotversion = dotversion[:-1] + '.' + dotversion[-1]
@@ -1221,6 +1327,9 @@
if platform == 'sunos5':
include_dirs.append('/usr/openwin/include')
added_lib_dirs.append('/usr/openwin/lib')
+ elif platform in ['mingw', 'win32']:
+ # mingw&win32 don't use X11 headers and libraries
+ pass
elif os.path.exists('/usr/X11R6/include'):
include_dirs.append('/usr/X11R6/include')
added_lib_dirs.append('/usr/X11R6/lib64')
@@ -1256,8 +1365,8 @@
if platform in ['aix3', 'aix4']:
libs.append('ld')
- # Finally, link with the X11 libraries (not appropriate on cygwin)
- if platform != "cygwin":
+ # Finally, link with the X11 libraries (not appropriate on cygwin, mingw)
+ if not platform in ['cygwin', 'mingw', 'win32']:
libs.append('X11')
ext = Extension('_tkinter', ['_tkinter.c', 'tkappinit.c'],
@@ -1308,8 +1417,32 @@
return True
def configure_ctypes(self, ext):
+ platform = self.get_platform()
+ if platform in ['mingw', 'win32']:
+ # win32 platform use own sources and includes
+ # from Modules/_ctypes/libffi_msvc/
+ srcdir = sysconfig.get_config_var('srcdir')
+ ffi_srcdir = os.path.abspath(os.path.join(srcdir, 'Modules',
+ '_ctypes', 'libffi_msvc'))
+ #FIXME: _ctypes/libffi_msvc/win64.asm ?
+ sources = [os.path.join(ffi_srcdir, p)
+ for p in ['ffi.c',
+ 'prep_cif.c',
+ 'win32.S',
+ ]]
+ # NOTE: issue2942 don't resolve problem with assembler code.
+ # It seems to me that python refuse to build an extension
+ # if exist a source with unknown suffix.
+ self.compiler.src_extensions.append('.S')
+ ext.include_dirs.append(ffi_srcdir)
+ ext.sources.extend(sources)
+ ext.libraries.extend(['ole32', 'oleaut32', 'uuid'])
+ #AdditionalOptions="/EXPORT:DllGetClassObject,PRIVATE /EXPORT:DllCanUnloadNow,PRIVATE"
+ ext.export_symbols.extend(['DllGetClassObject PRIVATE',
+ 'DllCanUnloadNow PRIVATE'])
+ return True
if not self.use_system_libffi:
- if sys.platform == 'darwin':
+ if platform == 'darwin':
return self.configure_ctypes_darwin(ext)
(srcdir,) = sysconfig.get_config_vars('srcdir')
@@ -1373,14 +1506,15 @@
'_ctypes/malloc_closure.c']
depends = ['_ctypes/ctypes.h']
- if sys.platform == 'darwin':
+ platform = self.get_platform()
+ if platform == 'darwin':
sources.append('_ctypes/darwin/dlfcn_simple.c')
extra_compile_args.append('-DMACOSX')
include_dirs.append('_ctypes/darwin')
# XXX Is this still needed?
## extra_link_args.extend(['-read_only_relocs', 'warning'])
- elif sys.platform == 'sunos5':
+ elif platform == 'sunos5':
# XXX This shouldn't be necessary; it appears that some
# of the assembler code is non-PIC (i.e. it has relocations
# when it shouldn't. The proper fix would be to rewrite
@@ -1391,7 +1525,7 @@
# finding some -z option for the Sun compiler.
extra_link_args.append('-mimpure-text')
- elif sys.platform.startswith('hp-ux'):
+ elif platform.startswith('hp-ux'):
extra_link_args.append('-fPIC')
ext = Extension('_ctypes',
@@ -1401,14 +1535,19 @@
libraries=[],
sources=sources,
depends=depends)
+ if platform in ['mingw', 'win32']:
+ ctypes_test_libs = ['oleaut32']
+ else:
+ ctypes_test_libs = []
ext_test = Extension('_ctypes_test',
+ libraries=ctypes_test_libs,
sources=['_ctypes/_ctypes_test.c'])
self.extensions.extend([ext, ext_test])
if not '--with-system-ffi' in sysconfig.get_config_var("CONFIG_ARGS"):
return
- if sys.platform == 'darwin':
+ if platform == 'darwin':
# OS X 10.5 comes with libffi.dylib; the include files are
# in /usr/include/ffi
inc_dirs.append('/usr/include/ffi')