--- ./PC/_winreg.c.MINGW 2008-08-06 23:36:36.000000000 +0300
+++ ./PC/_winreg.c 2008-09-27 01:00:04.000000000 +0300
@@ -17,6 +17,18 @@
#include "malloc.h" /* for alloca */
#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);
--- ./PC/msvcrtmodule.c.MINGW 2008-11-30 23:07:47.000000000 +0200
+++ ./PC/msvcrtmodule.c 2008-12-07 20:36:39.000000000 +0200
@@ -22,6 +22,31 @@
#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 native 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
@@ -258,6 +283,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);
--- ./Lib/distutils/command/build_ext.py.MINGW 2008-08-18 22:39:22.000000000 +0300
+++ ./Lib/distutils/command/build_ext.py 2008-09-28 19:14:21.000000000 +0300
@@ -19,7 +19,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:
from distutils.msvccompiler import get_build_version
MSVC_VERSION = int(get_build_version())
@@ -181,7 +182,8 @@
# for extensions under windows use different directories
# for Release and Debug builds.
# also Python's library directory must be appended to library_dirs
- 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:
# the 'libs' directory is for binary installs - we assume that
# must be the *native* platform. But we don't really support
# cross-compiling via a binary install anyway, so we let it go.
@@ -223,7 +225,7 @@
# for extensions under Cygwin and AtheOS Python's library directory must be
# appended to library_dirs
- if sys.platform[:6] == 'cygwin' or sys.platform[:6] == 'atheos':
+ if sys.platform[:6] == 'cygwin' or sys.platform[:6] == 'atheos' or 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",
--- ./Lib/distutils/command/build_scripts.py.MINGW 2008-08-06 23:37:01.000000000 +0300
+++ ./Lib/distutils/command/build_scripts.py 2008-10-05 16:25:37.000000000 +0300
@@ -104,7 +104,9 @@
outf.write("#!%s%s\n" %
(os.path.join(
sysconfig.get_config_var("BINDIR"),
- "python" + sysconfig.get_config_var("VERSION")
+ # GCC(mingw) define VERSION without dot as MSVC build,
+ # so we has to cast number to string
+ "python" + str(sysconfig.get_config_var("VERSION"))
+ sysconfig.get_config_var("EXE")),
post_interp))
outf.writelines(f.readlines())
--- ./Lib/distutils/tests/test_build_ext.py.MINGW 2008-09-28 01:43:35.000000000 +0300
+++ ./Lib/distutils/tests/test_build_ext.py 2008-09-29 00:33:52.000000000 +0300
@@ -19,7 +19,8 @@
self.sys_path = sys.path[:]
sys.path.append(self.tmp_dir)
- 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:
srcdir = sysconfig.get_config_var('srcdir')
else:
srcdir = sysconfig.project_base
--- ./Lib/distutils/cygwinccompiler.py.MINGW 2008-08-18 22:39:22.000000000 +0300
+++ ./Lib/distutils/cygwinccompiler.py 2008-11-29 22:36:29.000000000 +0200
@@ -60,6 +60,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]
@@ -77,6 +89,8 @@
return ['msvcr90']
else:
raise ValueError("Unknown MS Compiler version %i " % msc_Ver)
+ else:
+ return []
class CygwinCCompiler (UnixCCompiler):
@@ -85,6 +99,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"
@@ -103,6 +120,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" %
@@ -127,6 +148,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',
@@ -271,8 +295,14 @@
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')" % \
--- ./Lib/distutils/sysconfig.py.MINGW 2008-09-29 00:47:45.000000000 +0300
+++ ./Lib/distutils/sysconfig.py 2008-09-29 00:47:54.000000000 +0300
@@ -73,7 +73,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:
if plat_specific:
inc_dir = project_base
@@ -200,7 +201,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:
inc_dir = os.path.join(project_base, "PC")
else:
inc_dir = project_base
@@ -436,6 +438,11 @@
def _init_nt():
"""Initialize the module as appropriate for NT"""
+ if 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)
--- ./Lib/distutils/ccompiler.py.MINGW 2008-08-06 23:37:01.000000000 +0300
+++ ./Lib/distutils/ccompiler.py 2008-09-28 19:14:10.000000000 +0300
@@ -1083,6 +1083,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:
--- ./Lib/ctypes/test/test_functions.py.MINGW 2008-08-06 23:37:08.000000000 +0300
+++ ./Lib/ctypes/test/test_functions.py 2008-12-07 03:28:44.000000000 +0200
@@ -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),
--- ./Lib/ctypes/test/test_as_parameter.py.MINGW 2008-08-06 23:37:08.000000000 +0300
+++ ./Lib/ctypes/test/test_as_parameter.py 2008-12-07 03:28:41.000000000 +0200
@@ -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),
--- ./Lib/ctypes/util.py.MINGW 2008-08-06 23:37:08.000000000 +0300
+++ ./Lib/ctypes/util.py 2008-11-23 22:45:00.000000000 +0200
@@ -7,6 +7,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
@@ -30,6 +35,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:
--- ./Python/dynload_win.c.MINGW 2008-08-06 23:36:03.000000000 +0300
+++ ./Python/dynload_win.c 2008-10-03 21:21:18.000000000 +0300
@@ -21,6 +21,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 */
--- ./Python/fileblocks.c.MINGW 2008-09-01 21:37:41.000000000 +0300
+++ ./Python/fileblocks.c 2008-09-01 21:45:09.000000000 +0300
@@ -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
--- ./Include/pymath.h.MINGW 2008-08-24 20:46:42.000000000 +0300
+++ ./Include/pymath.h 2008-09-14 21:09:44.000000000 +0300
@@ -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
--- ./Include/pyport.h.MINGW 2008-08-06 23:36:05.000000000 +0300
+++ ./Include/pyport.h 2008-09-25 00:19:41.000000000 +0300
@@ -502,6 +502,126 @@
#endif /* 0 */
+#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 ".\\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_ISINF
+ here for Py_IS_INFINITY we define same as for native build.
+ This makes HAVE_ISINF 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 native 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
@@ -546,17 +666,17 @@
*/
/*
- All windows ports, except cygwin, are handled in PC/pyconfig.h.
+ All windows ports, except cygwin and mingw32, are handled in PC/pyconfig.h.
- BeOS and cygwin are the only other autoconf platform requiring special
+ BeOS, mingw32 and cygwin are the only other autoconf platform requiring special
linkage handling and both of these use __declspec().
*/
-#if defined(__CYGWIN__) || defined(__BEOS__)
+#if defined(__CYGWIN__) || defined(__MINGW32__) || defined(__BEOS__)
# define HAVE_DECLSPEC_DLL
#endif
-/* only get special linkage if built as shared or platform is Cygwin */
-#if defined(Py_ENABLE_SHARED) || defined(__CYGWIN__)
+/* only get special linkage if built as shared or platform is Cygwin, Mingw32 */
+#if defined(Py_ENABLE_SHARED) || defined(__CYGWIN__) || defined(__MINGW32__)
# if defined(HAVE_DECLSPEC_DLL)
# ifdef Py_BUILD_CORE
# define PyAPI_FUNC(RTYPE) __declspec(dllexport) RTYPE
@@ -569,13 +689,22 @@
# define PyMODINIT_FUNC void
# 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)
--- ./Makefile.pre.in.MINGW 2008-10-21 23:50:44.000000000 +0300
+++ ./Makefile.pre.in 2008-10-21 23:50:37.000000000 +0300
@@ -180,6 +180,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 ===
@@ -187,7 +191,7 @@
# Modules
MODULE_OBJS= \
Modules/config.o \
- Modules/getpath.o \
+ @MODULE_GETPATH@ \
Modules/main.o \
Modules/gcmodule.o
@@ -259,7 +263,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 \
@@ -387,15 +391,21 @@
Modules/python.o \
$(BLDLIBRARY) $(LIBS) $(MODLIBS) $(SYSLIBS) $(LDLAST)
+# FIXME: next produce incorrect result if cross-compiling
platform: $(BUILDPYTHON)
- $(RUNSHARED) ./$(BUILDPYTHON) -E -c 'import sys ; from distutils.util import get_platform ; print get_platform()+"-"+sys.version[0:3]' >platform
+ $(RUNPYTHON) -E -c 'import sys ; from distutils.util import get_platform ; print get_platform()+"-"+sys.version[0:3]' >platform
# Build the shared modules
+# FIXME: in cross-compilation env. (mingw on linux) how to select correct
+# compiler/linker ?
+# The current py-code will created modules with .so suffix and environment
+# variable setting SO=$(SO) don't help.
+# Also it link modules with gcc instead mingw...
sharedmods: $(BUILDPYTHON)
@case $$MAKEFLAGS in \
- *s*) $(RUNSHARED) CC='$(CC)' LDSHARED='$(BLDSHARED)' OPT='$(OPT)' ./$(BUILDPYTHON) -E $(srcdir)/setup.py -q build;; \
- *) $(RUNSHARED) CC='$(CC)' LDSHARED='$(BLDSHARED)' OPT='$(OPT)' ./$(BUILDPYTHON) -E $(srcdir)/setup.py build;; \
+ *s*) CC='$(CC)' LDSHARED='$(BLDSHARED)' OPT='$(OPT)' $(RUNPYTHON) -E $(srcdir)/setup.py -q build @PYMOD_BUILDOPT@;; \
+ *) CC='$(CC)' LDSHARED='$(BLDSHARED)' OPT='$(OPT)' $(RUNPYTHON) -E $(srcdir)/setup.py build @PYMOD_BUILDOPT@;; \
esac
# Build static library
@@ -494,6 +504,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)"' \
@@ -502,10 +513,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)
@@ -663,6 +679,7 @@
TESTOPTS= -l $(EXTRATESTOPTS)
TESTPROG= $(srcdir)/Lib/test/regrtest.py
+# FIXME: next test may fail in cross-compilation environment
TESTPYTHON= $(RUNSHARED) ./$(BUILDPYTHON) -E -tt
test: all platform
-find $(srcdir)/Lib -name '*.py[co]' -print | xargs rm -f
@@ -873,24 +890,24 @@
done; \
done
$(INSTALL_DATA) $(srcdir)/LICENSE $(DESTDIR)$(LIBDEST)/LICENSE.txt
- PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \
- ./$(BUILDPYTHON) -Wi -tt $(DESTDIR)$(LIBDEST)/compileall.py \
+ PYTHONPATH=$(DESTDIR)$(LIBDEST) \
+ $(RUNPYTHON) -Wi -tt $(DESTDIR)$(LIBDEST)/compileall.py \
-d $(LIBDEST) -f \
-x 'bad_coding|badsyntax|site-packages' $(DESTDIR)$(LIBDEST)
- PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \
- ./$(BUILDPYTHON) -Wi -tt -O $(DESTDIR)$(LIBDEST)/compileall.py \
+ PYTHONPATH=$(DESTDIR)$(LIBDEST) \
+ $(RUNPYTHON) -Wi -tt -O $(DESTDIR)$(LIBDEST)/compileall.py \
-d $(LIBDEST) -f \
-x 'bad_coding|badsyntax|site-packages' $(DESTDIR)$(LIBDEST)
- -PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \
- ./$(BUILDPYTHON) -Wi -t $(DESTDIR)$(LIBDEST)/compileall.py \
+ -PYTHONPATH=$(DESTDIR)$(LIBDEST) \
+ $(RUNPYTHON) -Wi -t $(DESTDIR)$(LIBDEST)/compileall.py \
-d $(LIBDEST)/site-packages -f \
-x badsyntax $(DESTDIR)$(LIBDEST)/site-packages
- -PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \
- ./$(BUILDPYTHON) -Wi -t -O $(DESTDIR)$(LIBDEST)/compileall.py \
+ -PYTHONPATH=$(DESTDIR)$(LIBDEST) \
+ $(RUNPYTHON) -Wi -t -O $(DESTDIR)$(LIBDEST)/compileall.py \
-d $(LIBDEST)/site-packages -f \
-x badsyntax $(DESTDIR)$(LIBDEST)/site-packages
- -PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \
- ./$(BUILDPYTHON) -Wi -t -c "import lib2to3.pygram, lib2to3.patcomp;lib2to3.patcomp.PatternCompiler()"
+ -PYTHONPATH=$(DESTDIR)$(LIBDEST) \
+ $(RUNPYTHON) -Wi -t -c "import lib2to3.pygram, lib2to3.patcomp;lib2to3.patcomp.PatternCompiler()"
# Create the PLATDIR source directory, if one wasn't distributed..
$(srcdir)/Lib/$(PLATDIR):
@@ -988,7 +1005,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) \
@@ -1026,7 +1043,7 @@
fi; \
done
$(LN) -fsn include/python$(VERSION) $(DESTDIR)$(prefix)/Headers
- sed 's/%VERSION%/'"`$(RUNSHARED) ./$(BUILDPYTHON) -c 'import platform; print platform.python_version()'`"'/g' < $(RESSRCDIR)/Info.plist > $(DESTDIR)$(prefix)/Resources/Info.plist
+ sed 's/%VERSION%/'"`$(RUNPYTHON) -c 'import platform; print platform.python_version()'`"'/g' < $(RESSRCDIR)/Info.plist > $(DESTDIR)$(prefix)/Resources/Info.plist
$(LN) -fsn $(VERSION) $(DESTDIR)$(PYTHONFRAMEWORKINSTALLDIR)/Versions/Current
$(LN) -fsn Versions/Current/$(PYTHONFRAMEWORK) $(DESTDIR)$(PYTHONFRAMEWORKINSTALLDIR)/$(PYTHONFRAMEWORK)
$(LN) -fsn Versions/Current/Headers $(DESTDIR)$(PYTHONFRAMEWORKINSTALLDIR)/Headers
@@ -1067,8 +1084,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)
@@ -1186,7 +1203,7 @@
# Perform some verification checks on any modified files.
patchcheck:
- $(RUNSHARED) ./$(BUILDPYTHON) $(srcdir)/Tools/scripts/patchcheck.py
+ $(RUNPYTHON) $(srcdir)/Tools/scripts/patchcheck.py
# Dependencies
--- ./setup.py.MINGW 2008-12-07 20:29:40.000000000 +0200
+++ ./setup.py 2008-12-07 23:19:32.000000000 +0200
@@ -196,8 +196,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])
@@ -267,6 +297,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', 'beos', '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),
@@ -393,6 +443,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():
@@ -405,7 +456,7 @@
# Check for MacOS X, which doesn't need libm.a at all
math_libs = ['m']
- if platform in ['darwin', 'beos', 'mac']:
+ if platform in ['darwin', 'beos', 'mac', 'mingw', 'win32']:
math_libs = []
# XXX Omitted modules: gl, pure, dl, SGI-specific modules
@@ -448,13 +499,19 @@
# heapq
exts.append( Extension("_heapq", ["_heapqmodule.c"]) )
# operator.add() and similar goodies
- exts.append( Extension('operator', ['operator.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('operator', ['operator.c']) )
# Python 3.0 _fileio module
exts.append( Extension("_fileio", ["_fileio.c"]) )
# Python 3.0 _bytesio module
exts.append( Extension("_bytesio", ["_bytesio.c"]) )
# _functools
- exts.append( Extension("_functools", ["_functoolsmodule.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("_functools", ["_functoolsmodule.c"]) )
# _json speedups
exts.append( Extension("_json", ["_json.c"]) )
# Python C API test module
@@ -480,7 +537,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) )
@@ -489,8 +549,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)
@@ -505,7 +568,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']) )
@@ -521,7 +589,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:
@@ -555,6 +623,11 @@
# readline
do_readline = self.compiler.find_library_file(lib_dirs, 'readline')
+ if platform in ['mingw', 'win32']:
+ # Windows native 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] < '9.':
# MacOSX 10.4 has a broken readline. Don't try to build
# the readline module unless the user has installed a fixed
@@ -564,7 +637,7 @@
if find_file('readline/rlconf.h', inc_dirs, []) is None:
do_readline = False
if do_readline:
- if sys.platform == 'darwin':
+ if platform == 'darwin':
# In every directory on the search path search for a dynamic
# library and then a static library, instead of first looking
# for dynamic libraries on the entiry path.
@@ -594,7 +667,7 @@
else:
missing.append('readline')
- if platform not in ['mac']:
+ if platform not in ['mac', 'mingw', 'win32']:
# crypt module.
if self.compiler.find_library_file(lib_dirs, 'crypt'):
@@ -609,7 +682,12 @@
exts.append( Extension('_csv', ['_csv.c']) )
# socket(2)
+ if platform in ['mingw', 'win32']:
+ socket_libs = ['ws2_32']
+ else:
+ socket_libs = []
exts.append( Extension('_socket', ['socketmodule.c'],
+ libraries=socket_libs,
depends = ['socketmodule.h']) )
# Detect SSL support for the socket module (via _ssl)
search_for_ssl_incs_in = [
@@ -631,10 +709,13 @@
if (ssl_incs is not None and
ssl_libs is not None):
+ ssl_libs = ['ssl', 'crypto']
+ if platform in ['mingw', 'win32']:
+ ssl_libs.append('ws2_32')
exts.append( Extension('_ssl', ['_ssl.c'],
include_dirs = ssl_incs,
library_dirs = ssl_libs,
- libraries = ['ssl', 'crypto'],
+ libraries = ssl_libs,
depends = ['socketmodule.h']), )
else:
missing.append('_ssl')
@@ -708,6 +789,29 @@
min_db_ver = (3, 3)
db_setup_debug = False # verbose debug prints from this script?
+ # Modules with some Windows dependencies:
+ if platform in ['mingw', 'win32']:
+ (srcdir,) = sysconfig.get_config_vars('srcdir')
+ pc_srcdir = os.path.abspath(os.path.join(srcdir, 'PC'))
+
+ exts.append( Extension('msvcrt', [os.path.join(pc_srcdir, p)
+ for p in ['msvcrtmodule.c']]) )
+
+ exts.append( Extension('_msi', [os.path.join(pc_srcdir, p)
+ for p in ['_msi.c']]) )
+
+ exts.append( Extension('_subprocess', [os.path.join(pc_srcdir, p)
+ for p in ['_subprocess.c']]) )
+
+ # On win32 host(mingw build in MSYS environment) show that site.py
+ # fail to load if some modules are not build-in:
+ #exts.append( Extension('_winreg', [os.path.join(pc_srcdir, p)
+ # for p in ['_winreg.c']]) )
+
+ exts.append( Extension('winsound', [os.path.join(pc_srcdir, p)
+ for p in ['winsound.c']],
+ libraries=['winmm']) )
+
def allow_db_ver(db_ver):
"""Returns a boolean if the given BerkeleyDB version is acceptable.
@@ -950,13 +1054,13 @@
'_sqlite/util.c', ]
sqlite_defines = []
- if sys.platform != "win32":
+ if platform != "win32":
sqlite_defines.append(('MODULE_NAME', '"sqlite3"'))
else:
sqlite_defines.append(('MODULE_NAME', '\\"sqlite3\\"'))
- if sys.platform == 'darwin':
+ if platform == 'darwin':
# In every directory on the search path search for a dynamic
# library and then a static library, instead of first looking
# for dynamic libraries on the entiry path.
@@ -1033,6 +1137,14 @@
'dbm', ['dbmmodule.c'],
define_macros=[('HAVE_GDBM_DASH_NDBM_H',None)],
libraries = gdbm_libs ) )
+ elif db_incs is not None:
+ exts.append( Extension('dbm', ['dbmmodule.c'],
+ library_dirs=dblib_dir,
+ runtime_library_dirs=dblib_dir,
+ include_dirs=db_incs,
+ define_macros=[('HAVE_BERKDB_H',None),
+ ('DB_DBM_HSEARCH',None)],
+ libraries=dblibs))
else:
missing.append('dbm')
elif db_incs is not None:
@@ -1047,14 +1159,15 @@
missing.append('dbm')
# Anthony Baxter's gdbm module. GNU dbm(3) will require -lgdbm:
- if (self.compiler.find_library_file(lib_dirs, 'gdbm')):
+ if (platform not in ['mingw', 'win32'] and
+ self.compiler.find_library_file(lib_dirs, 'gdbm')):
exts.append( Extension('gdbm', ['gdbmmodule.c'],
libraries = ['gdbm'] ) )
else:
missing.append('gdbm')
# Unix-only modules
- if platform not in ['mac', 'win32']:
+ if platform not in ['mac', 'mingw', 'win32']:
# Steen Lumholt's termios module
exts.append( Extension('termios', ['termios.c']) )
# Jeremy Hylton's rlimit interface
@@ -1079,7 +1192,12 @@
# Curses support, requiring the System V version of curses, often
# provided by the ncurses library.
panel_library = 'panel'
- if (self.compiler.find_library_file(lib_dirs, 'ncursesw')):
+ if platform in ['mingw', 'win32']:
+ # Native build is without _curses module.
+ # Also in cross-compilation environment the code below
+ # find libraries from build system, so ignore it.
+ pass
+ elif (self.compiler.find_library_file(lib_dirs, 'ncursesw')):
curses_libs = ['ncursesw']
# Bug 1464056: If _curses.so links with ncursesw,
# _curses_panel.so must link with panelw.
@@ -1142,7 +1260,7 @@
break
if version >= 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 = ()
@@ -1174,7 +1292,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 = ()
@@ -1239,7 +1357,7 @@
if sys.maxint == 0x7fffffff:
# This requires sizeof(int) == sizeof(long) == sizeof(char*)
dl_inc = find_file('dlfcn.h', [], inc_dirs)
- if (dl_inc is not None) and (platform not in ['atheos']):
+ if (dl_inc is not None) and (platform not in ['atheos', 'mingw', 'win32']):
exts.append( Extension('dl', ['dlmodule.c']) )
else:
missing.append('dl')
@@ -1250,7 +1368,7 @@
self.detect_ctypes(inc_dirs, lib_dirs)
# Richard Oudkerk's multiprocessing module
- if platform == 'win32': # Windows
+ if platform in ['mingw', 'win32']: # Windows
macros = dict()
libraries = ['ws2_32']
@@ -1298,7 +1416,7 @@
)
libraries = ['rt']
- if platform == 'win32':
+ if platform in ['mingw', 'win32']:
multiprocessing_srcs = [ '_multiprocessing/multiprocessing.c',
'_multiprocessing/semaphore.c',
'_multiprocessing/pipe_connection.c',
@@ -1314,7 +1432,9 @@
if macros.get('HAVE_SEM_OPEN', False):
multiprocessing_srcs.append('_multiprocessing/semaphore.c')
+ #FIXME: why above set libraries aren't used ?
exts.append ( Extension('_multiprocessing', multiprocessing_srcs,
+ libraries=libraries,
define_macros=macros.items(),
include_dirs=["Modules/_multiprocessing"]))
# End multiprocessing
@@ -1342,6 +1462,7 @@
if platform == 'darwin' and ("--disable-toolbox-glue" not in
sysconfig.get_config_var("CONFIG_ARGS")):
+ #FIXME: next fail in cross-compilation environment
if os.uname()[2] > '8.':
# We're on Mac OS X 10.4 or later, the compiler should
# support '-Wno-deprecated-declarations'. This will
@@ -1544,7 +1665,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]
@@ -1573,6 +1694,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')
@@ -1609,7 +1733,7 @@
libs.append('ld')
# Finally, link with the X11 libraries (not appropriate on cygwin, mingw)
- if not platform in ["cygwin", "mingw"]:
+ if not platform in ['cygwin', 'mingw', 'win32']:
libs.append('X11')
ext = Extension('_tkinter', ['_tkinter.c', 'tkappinit.c'],
@@ -1660,8 +1784,29 @@
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_vars('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',
+ ]]
+ 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')
@@ -1720,14 +1865,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
@@ -1738,7 +1884,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',
@@ -1748,14 +1894,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')
--- ./configure.in.MINGW 2008-12-07 02:26:35.000000000 +0200
+++ ./configure.in 2008-12-07 02:29:04.000000000 +0200
@@ -45,6 +45,7 @@
AC_SUBST(CROSS_ON)
AC_SUBST(CROSS_OFF)
+AC_PROG_LN_S
if test "x$cross_compiling" = xyes; then
AC_MSG_WARN([cross-compilation is incomplete])
@@ -56,10 +57,33 @@
if test "x$PYTHON" = xnone; then
AC_MSG_ERROR([python program is required in cross-compilation environment])
fi
+ SYSPYOSNAME=`${SYSPYTHON} -c "import os; print os.name"`
+ case $SYSPYOSNAME in
+ posix)
+ dnl On posix distutils read variables from installed makefile.
+ dnl We will do some hacks based on distutils internals to overcome
+ dnl this limitation:
+ dnl - we link system python in build directory so that it will
+ dnl read generated file.
+ dnl As result from sysconfig.get_config_vars we will get our
+ dnl setting (for the host system) like SO, CFLAGS, CPPFLAGS,
+ dnl LDFLAGS instead those for the build system.
+ rm -f syspython
+ ${LN_S} ${SYSPYTHON} syspython
+ SYSPYTHON=./syspython
+ esac
fi
AC_SUBST(VERSION)
+case $host in
+ *-*-mingw*)
+ dnl To be compatible with native build.
+VERSION=`echo PYTHON_VERSION | sed -e 's|\.||g'`
+ ;;
+ *)
VERSION=PYTHON_VERSION
+ ;;
+esac
AC_SUBST(SOVERSION)
SOVERSION=1.0
@@ -271,6 +295,22 @@
dnl point of view but same for python.
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
@@ -421,6 +461,16 @@
fi
AC_MSG_RESULT($MACHDEP)
+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])
+
# And add extra plat-mac for darwin
AC_SUBST(EXTRAPLATDIR)
AC_SUBST(EXTRAMACHDEPPATH)
@@ -711,6 +761,10 @@
*)
enable_shared="no";;
esac
+ case $host in
+ *-*-mingw*)
+ enable_shared="yes";;
+ esac
fi
AC_MSG_RESULT($enable_shared)
@@ -802,6 +856,14 @@
RUNSHARED=DLL_PATH=`pwd`:${DLL_PATH:-/atheos/sys/libs:/atheos/autolnk/lib}
;;
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*)
@@ -809,6 +871,10 @@
LDLIBRARY='libpython$(VERSION).dll.a'
;;
esac
+ case $host in
+ *-*-mingw*)
+ LDLIBRARY='libpython$(VERSION).dll.a';;
+ esac
fi
AC_MSG_RESULT($LDLIBRARY)
@@ -846,6 +912,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,
@@ -860,6 +928,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 native windows 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 $enable_shared = "yes"; 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?
@@ -876,6 +967,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
@@ -955,6 +1048,10 @@
alpha*)
BASECFLAGS="$BASECFLAGS -mieee"
;;
+ *-*-mingw*)
+ #MSVC compatable storage layout for bitfields in structures
+ BASECFLAGS="$BASECFLAGS -mms-bitfields"
+ ;;
esac
case $ac_sys_system in
@@ -1037,8 +1134,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
@@ -1231,6 +1335,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
@@ -1251,6 +1369,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
@@ -1292,7 +1413,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
@@ -1644,6 +1765,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
@@ -1767,6 +1898,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}
@@ -1864,6 +2000,12 @@
# when running test_compile.py.
LINKFORSHARED='-Wl,-E -N 2048K';;
esac
+ case $host in
+ *-*-mingw*)
+ if test $enable_shared = "no"; then
+ LINKFORSHARED='-Wl,--out-implib=$(LDLIBRARY)'
+ fi;;
+ esac
fi
AC_MSG_RESULT($LINKFORSHARED)
@@ -1880,6 +2022,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)
@@ -2063,6 +2211,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"
@@ -2226,6 +2381,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])
@@ -2493,6 +2660,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"
@@ -2505,6 +2680,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
@@ -2531,6 +2711,17 @@
sysconf tcgetpgrp tcsetpgrp tempnam timegm times tmpfile tmpnam tmpnam_r \
truncate uname unsetenv utimes waitpid wait3 wait4 wcscoll _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)
@@ -2925,8 +3116,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
@@ -2978,20 +3179,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))
@@ -3181,11 +3393,16 @@
# check for --with-libm=...
AC_SUBST(LIBM)
+dnl obsolete style to set libraries for a system
case $ac_sys_system in
Darwin) ;;
BeOS) ;;
*) 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),
@@ -3242,6 +3459,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
@@ -3251,6 +3474,12 @@
AC_REPLACE_FUNCS(hypot)
+dnl FIXME: For mingw "isinf" is a macro defined in and can't be
+dnl detected as function. Also PC/pyconfig.h define HAVE_ISINF but it is
+dnl useless since header define Py_IS_INFINITY as (!_finite(X) && !_isnan(X))
+dnl Also in pymath.h is commented too how PC/pyconfig.h define _isinf.
+dnl NOTE: For mingw to keep compatibility with native build we define
+dnl Py_IS_INFINITY in pyport.h.
AC_CHECK_FUNCS(acosh asinh atanh copysign expm1 finite isinf isnan log1p)
LIBS=$LIBS_SAVE
@@ -3298,7 +3527,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
@@ -3792,9 +4024,12 @@
AC_DEFINE(PY_FORMAT_SIZE_T, "z", [Define to printf format modifier for Py_ssize_t])],
AC_MSG_RESULT(no),
[case $host in
+ *-*-mingw*) AC_MSG_RESULT(no);;
*) AC_MSG_RESULT(cross-compiling, unknown);;
esac])
+dnl NOTE: check is incorrect for win host systems, i.e. mingw and etc.,
+dnl but on those systems socklen_t is defined in ws2tcpip.h as int ;)
AC_CHECK_TYPE(socklen_t,,
AC_DEFINE(socklen_t,int,
Define to `int' if does not define.),[
@@ -3813,8 +4048,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
--- ./pyconfig.h.in.MINGW 2008-09-09 01:22:20.000000000 +0300
+++ ./pyconfig.h.in 2008-09-09 02:18:59.000000000 +0300
@@ -37,7 +37,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. */
@@ -803,6 +803,9 @@
/* Define to 1 if you have the `wcscoll' function. */
#undef HAVE_WCSCOLL
+/* 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.
*/
#undef HAVE_WORKING_TZSET
@@ -830,6 +833,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
--- ./Modules/getnameinfo.c.MINGW 2008-08-06 23:38:06.000000000 +0300
+++ ./Modules/getnameinfo.c 2008-09-05 03:34:59.000000000 +0300
@@ -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
--- ./Modules/Setup.config.in.MINGW 2008-08-06 23:38:07.000000000 +0300
+++ ./Modules/Setup.config.in 2008-11-23 22:09:42.000000000 +0200
@@ -3,11 +3,22 @@
# The purpose of this file is to conditionally enable certain modules
# based on configure-time options.
+# init system calls(posix/nt/...) for INITFUNC (used by makesetup)
+@INITSYS@ posixmodule.c
+
# Threading
@USE_THREAD_MODULE@thread threadmodule.c
# The signal module
@USE_SIGNAL_MODULE@signal signalmodule.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@operator operator.c # operator.add() and similar goodies
+@BUILDIN_WIN32_MODULE@_locale _localemodule.c # -lintl
+@BUILDIN_WIN32_MODULE@_winreg ../PC/_winreg.c
+
+
# The rest of the modules previously listed in this file are built
# by the setup.py script in Python 2.1 and later.
--- ./Modules/Setup.dist.MINGW 2008-11-28 23:43:05.000000000 +0200
+++ ./Modules/Setup.dist 2008-11-28 23:38:58.000000000 +0200
@@ -112,9 +112,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: why do n't 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
@@ -473,8 +474,7 @@
#
# More information on Expat can be found at www.libexpat.org.
#
-#EXPAT_DIR=/usr/local/src/expat-1.95.2
-#pyexpat pyexpat.c -DHAVE_EXPAT_H -I$(EXPAT_DIR)/lib -L$(EXPAT_DIR) -lexpat
+#pyexpat expat/xmlparse.c expat/xmlrole.c expat/xmltok.c pyexpat.c -I$(srcdir)/Modules/expat -DHAVE_EXPAT_CONFIG_H -DUSE_PYEXPAT_CAPI
# Hye-Shik Chang's CJKCodecs
--- ./Modules/selectmodule.c.MINGW 2008-09-24 21:54:24.000000000 +0300
+++ ./Modules/selectmodule.c 2008-09-24 21:54:27.000000000 +0300
@@ -111,9 +111,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 < 0 || v >= FD_SETSIZE) {
PyErr_SetString(PyExc_ValueError,
"filedescriptor out of range in select()");
@@ -121,7 +122,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 */
@@ -164,7 +165,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()");
--- ./Modules/getaddrinfo.c.MINGW 2008-08-06 23:38:07.000000000 +0300
+++ ./Modules/getaddrinfo.c 2008-09-09 02:46:52.000000000 +0300
@@ -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)
--- ./Modules/_ctypes/_ctypes.c.MINGW 2008-08-24 20:46:47.000000000 +0300
+++ ./Modules/_ctypes/_ctypes.c 2008-09-30 20:50:51.000000000 +0300
@@ -3108,14 +3108,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 < 32; ++i) {
sprintf(mangled_name, "_%s@%d", name, i*4);
address = (PPROC)GetProcAddress(handle, mangled_name);
if (address)
return address;
+ sprintf(mangled_name, "%s@%d", name, i*4);
+ address = (PPROC)GetProcAddress(handle, mangled_name);
+ if (address)
+ return address;
}
return NULL;
#endif
--- ./Modules/posixmodule.c.MINGW 2008-11-08 23:17:37.000000000 +0200
+++ ./Modules/posixmodule.c 2008-11-08 23:17:50.000000000 +0200
@@ -130,6 +130,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 */
@@ -258,7 +268,7 @@
#endif
#endif
-#ifdef _MSC_VER
+#if defined(_MSC_VER) || defined(__MINGW32__)
#ifdef HAVE_DIRECT_H
#include
#endif
@@ -273,7 +283,7 @@
#include /* for ShellExecute() */
#define popen _popen
#define pclose _pclose
-#endif /* _MSC_VER */
+#endif /* _MSC_VER || __MINGW32__ */
#if defined(PYCC_VACPP) && defined(PYOS_OS2)
#include
@@ -350,7 +360,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 */
@@ -8200,6 +8210,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 native builds don't include it ?
+ */
+# include
+#endif
PyDoc_STRVAR(win32_urandom__doc__,
"urandom(n) -> str\n\n\
@@ -8906,7 +8923,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 initnt
#define MODNAME "nt"
--- ./Modules/cmathmodule.c.MINGW 2008-08-06 23:38:06.000000000 +0300
+++ ./Modules/cmathmodule.c 2008-12-07 02:33:33.000000000 +0200
@@ -55,6 +55,18 @@
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.
+ */
+static double fake_atan2 (double y, double x) { return atan2l (y, x); }
+#define atan2 fake_atan2
+#endif
+#endif
+
/* Code to deal with special values (infinities, NaNs, etc.). */
/* special_type takes a double and returns an integer code indicating
--- ./Modules/_fileio.c.MINGW 2008-11-22 04:30:51.000000000 +0200
+++ ./Modules/_fileio.c 2008-11-22 04:34:50.000000000 +0200
@@ -22,7 +22,9 @@
#ifdef MS_WINDOWS
/* can simulate truncate with Win32 API functions; see file_truncate */
+#ifndef HAVE_FTRUNCATE
#define HAVE_FTRUNCATE
+#endif
#define WIN32_LEAN_AND_MEAN
#include
#endif
--- ./Modules/mathmodule.c.MINGW 2008-08-06 23:38:06.000000000 +0300
+++ ./Modules/mathmodule.c 2008-12-07 02:32:56.000000000 +0200
@@ -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.
--- ./Modules/socketmodule.c.MINGW 2008-08-18 22:39:26.000000000 +0300
+++ ./Modules/socketmodule.c 2008-09-27 03:47:27.000000000 +0300
@@ -91,6 +91,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
@@ -312,6 +321,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)
+void WSAAPI freeaddrinfo (struct addrinfo*);
+int WSAAPI getaddrinfo (const char*,const char*,const struct addrinfo*,
+ struct addrinfo**);
+int WSAAPI getnameinfo(const struct sockaddr*,socklen_t,char*,DWORD,
+ char*,DWORD,int);
+# endif
+# define HAVE_GETADDRINFO
+# define HAVE_GETNAMEINFO
+#else
+# if (_WIN32_WINNT < 0x0501)
+ /* Internal implemetation that has to work on w2k and latest. */
+# define EAI_ADDRFAMILY
+# include "addrinfo.h"
+# else
+# define HAVE_GETADDRINFO
+# define HAVE_GETNAMEINFO
+# endif
+#endif
#else
# include "addrinfo.h"
#endif
@@ -349,6 +387,16 @@
#if !defined(HAVE_GETADDRINFO)
/* avoid clashes with the C library definition of the symbol. */
#define getaddrinfo fake_getaddrinfo
+#ifdef __MINGW32__
+#ifdef gai_strerror
+/* NOTE: Mingw w32api always define gai_strerror to gai_strerror{A|W}
+ but getaddrinfo is defined 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"
@@ -2827,7 +2875,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)
{
--- ./Modules/_localemodule.c.MINGW 2008-09-27 20:11:07.000000000 +0300
+++ ./Modules/_localemodule.c 2008-10-05 21:55:35.000000000 +0300
@@ -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 native build we has to undef some defines.
+ */
+#undef HAVE_LIBINTL_H
+#undef HAVE_BIND_TEXTDOMAIN_CODESET
+#endif
#include
#include
--- ./Objects/fileobject.c.MINGW 2008-09-30 21:12:44.000000000 +0300
+++ ./Objects/fileobject.c 2008-09-30 21:14:20.000000000 +0300
@@ -9,9 +9,17 @@
#endif /* HAVE_SYS_TYPES_H */
#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