# HG changeset patch # User Edouard Tisserant # Date 1513441799 -3600 # Node ID 0a8caba627ac75a613fe05c4170147abb56a61c1 # Parent 12390414aed0705d1ec03129d9f1442a5f197cd9 fixed M2Crypto build diff -r 12390414aed0 -r 0a8caba627ac M2Crypto-mingw-cross-compile-fix.patch --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/M2Crypto-mingw-cross-compile-fix.patch Sat Dec 16 17:29:59 2017 +0100 @@ -0,0 +1,94 @@ +diff -pruN M2Crypto-0.22.6rc2.orig/setup.py M2Crypto-0.22.6rc2/setup.py +--- M2Crypto-0.22.6rc2.orig/setup.py 2015-10-19 14:34:45.000000000 +0200 ++++ M2Crypto-0.22.6rc2/setup.py 2015-10-20 18:48:14.231865096 +0200 +@@ -28,6 +28,23 @@ except ImportError: + from distutils.core import Extension + from distutils.file_util import copy_file + ++# DISTUTILS HOT PATCH ++from distutils.cygwinccompiler import Mingw32CCompiler ++_old_mw32_init=Mingw32CCompiler.__init__ ++def Mingw32CCompInit(self, *args, **kwargs): ++ _old_mw32_init(self, *args, **kwargs) ++ for n in ["compiler", "compiler_so", "compiler_cxx", "linker_so"] : ++ l = getattr(self,n) ++ pfx = os.getenv("MINGCCPREFIX") ++ l[0] = pfx+l[0] ++ self.linker_so.insert(1, "-static-libgcc") ++Mingw32CCompiler.__init__ = Mingw32CCompInit ++ ++import distutils ++distutils.sysconfig.get_python_inc = lambda *x,**y : os.getenv("PYTHONINC") ++distutils.cygwinccompiler.get_msvcr = lambda *x,**y : [] ++distutils.util.get_platform = lambda *x,**y : "win32" ++distutils.sysconfig._init_nt() + + class _M2CryptoBuildExt(build_ext.build_ext): + '''Specialization of build_ext to enable swig_opts to inherit any +@@ -40,14 +57,9 @@ class _M2CryptoBuildExt(build_ext.build_ + + build_ext.build_ext.initialize_options(self) + +- # openssl is the attribute corresponding to openssl directory prefix +- # command line option +- if os.name == 'nt': +- self.libraries = ['ssleay32', 'libeay32'] +- self.openssl = 'c:\\pkg' +- else: +- self.libraries = ['ssl', 'crypto'] +- self.openssl = '/usr' ++ self.openssl = "mhooooo" ++ self.libraries = ['ssleay32', 'libeay32'] ++ self.libraries += ['ws2_32', 'crypt32', 'gdi32', "python27", "winstrm"] + + def finalize_options(self): + '''Overloaded build_ext implementation to append custom openssl +@@ -56,7 +68,8 @@ class _M2CryptoBuildExt(build_ext.build_ + build_ext.build_ext.finalize_options(self) + + openssl_include_dir = os.path.join(self.openssl, 'include') +- openssl_library_dir = os.path.join(self.openssl, 'lib') ++ #openssl_library_dir = os.path.join(self.openssl, 'lib') ++ openssl_library_dir = self.openssl + + self.swig_opts = ['-I%s' % i for i in self.include_dirs + + [openssl_include_dir]] +@@ -90,7 +103,7 @@ class _M2CryptoBuildExt(build_ext.build_ + # Someday distutils will be fixed and this won't be needed. + self.library_dirs += [os.path.join(self.openssl, 'bin')] + +- self.library_dirs += [os.path.join(self.openssl, openssl_library_dir)] ++ self.library_dirs += [os.getenv("PYTHONLIB"), os.path.join(self.openssl, openssl_library_dir)] + + def run(self): + '''Overloaded build_ext implementation to allow inplace=1 to work, +diff -pruN M2Crypto-0.22.6rc2.orig/SWIG/_ssl.i M2Crypto-0.22.6rc2/SWIG/_ssl.i +--- M2Crypto-0.22.6rc2.orig/SWIG/_ssl.i 2015-10-17 21:06:56.000000000 +0200 ++++ M2Crypto-0.22.6rc2/SWIG/_ssl.i 2015-10-20 18:48:24.835905739 +0200 +@@ -10,6 +10,9 @@ + /* $Id$ */ + + %{ ++#define _WIN32_WINNT 0x0600 ++#include ++#undef _WIN32_WINNT + #include + #include + #include +@@ -17,7 +19,6 @@ + #include + #include + #include +-#include + #include + %} + +@@ -514,7 +515,7 @@ static int ssl_sleep_with_timeout(SSL *s + return -1; + } + Py_BEGIN_ALLOW_THREADS +- tmp = poll(&fd, 1, ms); ++ tmp = WSAPoll(&fd, 1, ms); + Py_END_ALLOW_THREADS + switch (tmp) { + case 1: diff -r 12390414aed0 -r 0a8caba627ac Makefile --- a/Makefile Sat Dec 16 17:28:22 2017 +0100 +++ b/Makefile Sat Dec 16 17:29:59 2017 +0100 @@ -138,10 +138,6 @@ pydir = build/python pysite = $(pydir)/Lib/site-packages -OSSLVER=openssl-1.0.1p -M2CRVER=M2Crypto-0.22.6rc2 -MINGPFX=i686-w64-mingw32- - python: |build rm -rf $(pydir) mkdir -p $(pydir) @@ -295,15 +291,28 @@ unzip -d $(tmp) $$dld cp -R $(tmp)/lxml/* $(pysite) + touch $@ + + +OSSLVER=openssl-1.0.1p +MINGPFX=i686-w64-mingw32- + +openssl: # Build Openssl $(call get_src_http,https://openssl.org/source,$(OSSLVER).tar.gz)\ tar -C $(tmp) -xzf $$dld cd $(tmp)/$(OSSLVER); \ CC=$(MINGPFX)gcc ./Configure mingw && \ make all build-shared CROSS_COMPILE=$(MINGPFX) SHARED_LDFLAGS=-static-libgcc - + mv $(tmp)/$(OSSLVER) .; + + touch $@ + +M2CRVER=M2Crypto-0.22.5 + +m2crypto: openssl # Build M2crypto - $(call get_src_pypi,source/M/M2Crypto,$(M2CRVER).tar.gz)\ + $(call get_src_pypi,54/f5/6fa9bca4a18cc36c0c84c73d41d8e521c8cb70f077b11297efcd985242a6,M2Crypto-0.22.5.tar.gz)\ tar -C $(tmp) -xzf $$dld cd $(tmp)/$(M2CRVER); \ patch -p1 < $(src)/M2Crypto-mingw-cross-compile-fix.patch && \ @@ -311,10 +320,10 @@ PYTHONINC=$(abspath $(pydir))/include/ \ MINGCCPREFIX=$(MINGPFX) \ python setup.py build build_ext \ - --openssl=$(tmp)/$(OSSLVER) -cmingw32 + --openssl=$(CURDIR)/$(OSSLVER) -cmingw32 # Copy openssl dlls directly in M2Crypto package directory - cp -a $(tmp)/$(OSSLVER)/*.dll $(tmp)/$(M2CRVER)/build/lib.win32-2.7/M2Crypto + cp -a $(CURDIR)/$(OSSLVER)/*.dll $(tmp)/$(M2CRVER)/build/lib.win32-2.7/M2Crypto # Move result into python site packages mv $(tmp)/$(M2CRVER)/build/lib.win32-2.7/M2Crypto $(pysite) @@ -369,7 +378,7 @@ cd $(CFbuild); find . -name "*.o" -exec rm {} ';' #remove object files only touch $@ -targets=python mingw matiec beremiz +targets=python m2crypto mingw matiec beremiz Beremiz-$(version).exe: $(targets) $(src)/license.txt $(src)/install.nsi $(targets_ex) sed -e 's/\$$BVERSION/$(version)/g' $(src)/license.txt > build/license.txt sed -e 's/\$$BVERSION/$(version)/g' $(src)/install.nsi |\