wok rev 16307
ARM: now python seems to cross compile (if libpython.so ARM are installed in sysroot)
author | Christophe Lincoln <pankso@slitaz.org> |
---|---|
date | Tue Apr 08 00:37:42 2014 +0200 (2014-04-08) |
parents | 850328f07d42 |
children | c3460fec1e9b |
files | python-dev/receipt python/receipt python/stuff/python-2.7.3-xcompile.patch |
line diff
1.1 --- a/python-dev/receipt Mon Apr 07 09:49:54 2014 +0000 1.2 +++ b/python-dev/receipt Tue Apr 08 00:37:42 2014 +0200 1.3 @@ -9,6 +9,7 @@ 1.4 WANTED="python" 1.5 SOURCE="Python" 1.6 WEB_SITE="http://www.python.org/" 1.7 +HOST_ARCH="i486 arm" 1.8 1.9 DEPENDS="python" 1.10
2.1 --- a/python/receipt Mon Apr 07 09:49:54 2014 +0000 2.2 +++ b/python/receipt Tue Apr 08 00:37:42 2014 +0200 2.3 @@ -7,7 +7,7 @@ 2.4 MAINTAINER="pankso@slitaz.org" 2.5 LICENSE="PSL" 2.6 SOURCE="Python" 2.7 -TARBALL="$SOURCE-$VERSION.tar.xz" 2.8 +TARBALL="$SOURCE-$VERSION.tar.bz2" 2.9 WEB_SITE="http://www.python.org/" 2.10 WGET_URL="https://www.python.org/ftp/python/$VERSION/$TARBALL" 2.11 HOST_ARCH="i486 arm" 2.12 @@ -91,11 +91,6 @@ 2.13 mkdir -p $fs/usr/include/${PACKAGE}$python_version 2.14 cp -a $install/usr/bin $fs/usr 2.15 cp -a $install/usr/lib $fs/usr 2.16 - # Create /usr/bin/python for ARM 2.17 - if [ ! -f "$fs/usr/python" ]; then 2.18 - cd $fs/usr/bin && ln -s python2.7 python 2.19 - mkdir -p $fs/usr/lib/python2.7 2.20 - fi 2.21 # needed for mercurial to work now 2.22 cp -a $install/usr/include/${PACKAGE}$python_version/pyconfig.h \ 2.23 $fs/usr/include/${PACKAGE}$python_version
3.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 3.2 +++ b/python/stuff/python-2.7.3-xcompile.patch Tue Apr 08 00:37:42 2014 +0200 3.3 @@ -0,0 +1,264 @@ 3.4 +diff -ur Python-2.7.3.orig/configure Python-2.7.3-Source/configure 3.5 +--- Python-2.7.3.orig/configure 2012-04-09 19:07:36.000000000 -0400 3.6 ++++ Python-2.7.3-Source/configure 2012-10-23 14:10:45.305220393 -0400 3.7 +@@ -13697,7 +13697,7 @@ 3.8 + $as_echo_n "(cached) " >&6 3.9 + else 3.10 + if test "$cross_compiling" = yes; then : 3.11 +- ac_cv_have_long_long_format=no 3.12 ++ ac_cv_have_long_long_format="cross -- assuming yes" 3.13 + else 3.14 + cat confdefs.h - <<_ACEOF >conftest.$ac_ext 3.15 + /* end confdefs.h. */ 3.16 +@@ -13749,7 +13749,7 @@ 3.17 + $as_echo "$ac_cv_have_long_long_format" >&6; } 3.18 + fi 3.19 + 3.20 +-if test "$ac_cv_have_long_long_format" = yes 3.21 ++if test "$ac_cv_have_long_long_format" != no 3.22 + then 3.23 + 3.24 + $as_echo "#define PY_FORMAT_LONG_LONG \"ll\"" >>confdefs.h 3.25 +diff -ur Python-2.7.3.orig/Makefile.pre.in Python-2.7.3-Source/Makefile.pre.in 3.26 +--- Python-2.7.3.orig/Makefile.pre.in 2012-04-09 19:07:33.000000000 -0400 3.27 ++++ Python-2.7.3-Source/Makefile.pre.in 2012-10-23 14:10:45.305220393 -0400 3.28 +@@ -182,6 +182,7 @@ 3.29 + 3.30 + PYTHON= python$(EXE) 3.31 + BUILDPYTHON= python$(BUILDEXE) 3.32 ++HOSTPYTHON= ./$(BUILDPYTHON) 3.33 + 3.34 + # The task to run while instrument when building the profile-opt target 3.35 + PROFILE_TASK= $(srcdir)/Tools/pybench/pybench.py -n 2 --with-gc --with-syscheck 3.36 +@@ -215,6 +216,8 @@ 3.37 + # Parser 3.38 + PGEN= Parser/pgen$(EXE) 3.39 + 3.40 ++HOSTPGEN= $(PGEN) 3.41 ++ 3.42 + POBJS= \ 3.43 + Parser/acceler.o \ 3.44 + Parser/grammar1.o \ 3.45 +@@ -408,8 +411,8 @@ 3.46 + # Build the shared modules 3.47 + sharedmods: $(BUILDPYTHON) 3.48 + @case $$MAKEFLAGS in \ 3.49 +- *s*) $(RUNSHARED) CC='$(CC)' LDSHARED='$(BLDSHARED)' OPT='$(OPT)' ./$(BUILDPYTHON) -E $(srcdir)/setup.py -q build;; \ 3.50 +- *) $(RUNSHARED) CC='$(CC)' LDSHARED='$(BLDSHARED)' OPT='$(OPT)' ./$(BUILDPYTHON) -E $(srcdir)/setup.py build;; \ 3.51 ++ *s*) $(RUNSHARED) CC='$(CC)' LDSHARED='$(BLDSHARED)' OPT='$(OPT)' PYTHONXCPREFIX='$(DESTDIR)$(prefix)' $(HOSTPYTHON) -E $(srcdir)/setup.py -q build;; \ 3.52 ++ *) $(RUNSHARED) CC='$(CC)' LDSHARED='$(BLDSHARED)' OPT='$(OPT)' PYTHONXCPREFIX='$(DESTDIR)$(prefix)' $(HOSTPYTHON) -E $(srcdir)/setup.py build;; \ 3.53 + esac 3.54 + 3.55 + # Build static library 3.56 +@@ -543,7 +546,7 @@ 3.57 + $(GRAMMAR_H) $(GRAMMAR_C): Parser/pgen.stamp 3.58 + Parser/pgen.stamp: $(PGEN) $(GRAMMAR_INPUT) 3.59 + -@$(INSTALL) -d Include 3.60 +- $(PGEN) $(GRAMMAR_INPUT) $(GRAMMAR_H) $(GRAMMAR_C) 3.61 ++ -$(HOSTPGEN) $(GRAMMAR_INPUT) $(GRAMMAR_H) $(GRAMMAR_C) 3.62 + -touch Parser/pgen.stamp 3.63 + 3.64 + $(PGEN): $(PGENOBJS) 3.65 +@@ -938,26 +941,26 @@ 3.66 + $(INSTALL_DATA) $(srcdir)/Modules/xxmodule.c \ 3.67 + $(DESTDIR)$(LIBDEST)/distutils/tests ; \ 3.68 + fi 3.69 +- PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \ 3.70 +- ./$(BUILDPYTHON) -Wi -tt $(DESTDIR)$(LIBDEST)/compileall.py \ 3.71 ++ -PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \ 3.72 ++ ./$(HOSTPYTHON) -Wi -tt $(DESTDIR)$(LIBDEST)/compileall.py \ 3.73 + -d $(LIBDEST) -f \ 3.74 + -x 'bad_coding|badsyntax|site-packages|lib2to3/tests/data' \ 3.75 + $(DESTDIR)$(LIBDEST) 3.76 +- PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \ 3.77 +- ./$(BUILDPYTHON) -Wi -tt -O $(DESTDIR)$(LIBDEST)/compileall.py \ 3.78 ++ -PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \ 3.79 ++ ./$(HOSTPYTHON) -Wi -tt -O $(DESTDIR)$(LIBDEST)/compileall.py \ 3.80 + -d $(LIBDEST) -f \ 3.81 + -x 'bad_coding|badsyntax|site-packages|lib2to3/tests/data' \ 3.82 + $(DESTDIR)$(LIBDEST) 3.83 + -PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \ 3.84 +- ./$(BUILDPYTHON) -Wi -t $(DESTDIR)$(LIBDEST)/compileall.py \ 3.85 ++ ./$(HOSTPYTHON) -Wi -t $(DESTDIR)$(LIBDEST)/compileall.py \ 3.86 + -d $(LIBDEST)/site-packages -f \ 3.87 + -x badsyntax $(DESTDIR)$(LIBDEST)/site-packages 3.88 + -PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \ 3.89 +- ./$(BUILDPYTHON) -Wi -t -O $(DESTDIR)$(LIBDEST)/compileall.py \ 3.90 ++ ./$(HOSTPYTHON) -Wi -t -O $(DESTDIR)$(LIBDEST)/compileall.py \ 3.91 + -d $(LIBDEST)/site-packages -f \ 3.92 + -x badsyntax $(DESTDIR)$(LIBDEST)/site-packages 3.93 + -PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \ 3.94 +- ./$(BUILDPYTHON) -Wi -t -c "import lib2to3.pygram, lib2to3.patcomp;lib2to3.patcomp.PatternCompiler()" 3.95 ++ ./$(HOSTPYTHON) -Wi -t -c "import lib2to3.pygram, lib2to3.patcomp;lib2to3.patcomp.PatternCompiler()" 3.96 + 3.97 + # Create the PLATDIR source directory, if one wasn't distributed.. 3.98 + $(srcdir)/Lib/$(PLATDIR): 3.99 +@@ -1062,7 +1065,9 @@ 3.100 + # Install the dynamically loadable modules 3.101 + # This goes into $(exec_prefix) 3.102 + sharedinstall: sharedmods 3.103 +- $(RUNSHARED) ./$(BUILDPYTHON) -E $(srcdir)/setup.py install \ 3.104 ++ CC='$(CC)' LDSHARED='$(BLDSHARED)' OPT='$(OPT)' \ 3.105 ++ $(RUNSHARED) $(HOSTPYTHON) -E $(srcdir)/setup.py install \ 3.106 ++ --skip-build \ 3.107 + --prefix=$(prefix) \ 3.108 + --install-scripts=$(BINDIR) \ 3.109 + --install-platlib=$(DESTSHARED) \ 3.110 +diff -ur Python-2.7.3.orig/setup.py Python-2.7.3-Source/setup.py 3.111 +--- Python-2.7.3.orig/setup.py 2012-04-09 19:07:36.000000000 -0400 3.112 ++++ Python-2.7.3-Source/setup.py 2012-10-23 14:10:56.085220237 -0400 3.113 +@@ -145,6 +145,7 @@ 3.114 + def __init__(self, dist): 3.115 + build_ext.__init__(self, dist) 3.116 + self.failed = [] 3.117 ++ self.cross_compile = os.environ.get('CROSS_COMPILE_TARGET') == 'yes' 3.118 + 3.119 + def build_extensions(self): 3.120 + 3.121 +@@ -278,6 +279,14 @@ 3.122 + (ext.name, sys.exc_info()[1])) 3.123 + self.failed.append(ext.name) 3.124 + return 3.125 ++ 3.126 ++ # Import check will not work when cross-compiling. 3.127 ++ if os.environ.has_key('PYTHONXCPREFIX'): 3.128 ++ self.announce( 3.129 ++ 'WARNING: skipping import check for cross-compiled: "%s"' % 3.130 ++ ext.name) 3.131 ++ return 3.132 ++ 3.133 + # Workaround for Mac OS X: The Carbon-based modules cannot be 3.134 + # reliably imported into a command-line Python 3.135 + if 'Carbon' in ext.extra_link_args: 3.136 +@@ -369,9 +378,10 @@ 3.137 + 3.138 + def detect_modules(self): 3.139 + # Ensure that /usr/local is always used 3.140 +- add_dir_to_list(self.compiler.library_dirs, '/usr/local/lib') 3.141 +- add_dir_to_list(self.compiler.include_dirs, '/usr/local/include') 3.142 +- self.add_multiarch_paths() 3.143 ++ if not self.cross_compile: 3.144 ++ add_dir_to_list(self.compiler.library_dirs, '/usr/local/lib') 3.145 ++ add_dir_to_list(self.compiler.include_dirs, '/usr/local/include') 3.146 ++ self.add_multiarch_paths() 3.147 + 3.148 + # Add paths specified in the environment variables LDFLAGS and 3.149 + # CPPFLAGS for header and library files. 3.150 +@@ -408,7 +418,8 @@ 3.151 + add_dir_to_list(dir_list, directory) 3.152 + 3.153 + if os.path.normpath(sys.prefix) != '/usr' \ 3.154 +- and not sysconfig.get_config_var('PYTHONFRAMEWORK'): 3.155 ++ and not sysconfig.get_config_var('PYTHONFRAMEWORK') \ 3.156 ++ and not self.cross_compile: 3.157 + # OSX note: Don't add LIBDIR and INCLUDEDIR to building a framework 3.158 + # (PYTHONFRAMEWORK is set) to avoid # linking problems when 3.159 + # building a framework with different architectures than 3.160 +@@ -426,11 +437,23 @@ 3.161 + # lib_dirs and inc_dirs are used to search for files; 3.162 + # if a file is found in one of those directories, it can 3.163 + # be assumed that no additional -I,-L directives are needed. 3.164 +- lib_dirs = self.compiler.library_dirs + [ 3.165 +- '/lib64', '/usr/lib64', 3.166 +- '/lib', '/usr/lib', 3.167 +- ] 3.168 +- inc_dirs = self.compiler.include_dirs + ['/usr/include'] 3.169 ++ lib_dirs = self.compiler.library_dirs 3.170 ++ inc_dirs = self.compiler.include_dirs 3.171 ++ if not self.cross_compile: 3.172 ++ lib_dirs += [ 3.173 ++ '/lib64', '/usr/lib64', 3.174 ++ '/lib', '/usr/lib', 3.175 ++ ] 3.176 ++ inc_dirs += ['/usr/include'] 3.177 ++ else: 3.178 ++ # The common install prefix of 3rd party libraries used during 3.179 ++ # cross compilation 3.180 ++ mydir = os.environ.get('PYTHON_XCOMPILE_DEPENDENCIES_PREFIX') 3.181 ++ if mydir: 3.182 ++ inc_dirs += [mydir + '/include' ] 3.183 ++ inc_dirs += [mydir + '/lib/libffi-3.0.10/include'] 3.184 ++ lib_dirs += [mydir + '/lib' ] 3.185 ++ 3.186 + exts = [] 3.187 + missing = [] 3.188 + 3.189 +@@ -1004,13 +1027,24 @@ 3.190 + # We hunt for #define SQLITE_VERSION "n.n.n" 3.191 + # We need to find >= sqlite version 3.0.8 3.192 + sqlite_incdir = sqlite_libdir = None 3.193 +- sqlite_inc_paths = [ '/usr/include', 3.194 +- '/usr/include/sqlite', 3.195 +- '/usr/include/sqlite3', 3.196 +- '/usr/local/include', 3.197 +- '/usr/local/include/sqlite', 3.198 +- '/usr/local/include/sqlite3', 3.199 +- ] 3.200 ++ 3.201 ++ if not self.cross_compile: 3.202 ++ sqlite_inc_paths = [ '/usr/include', 3.203 ++ '/usr/include/sqlite', 3.204 ++ '/usr/include/sqlite3', 3.205 ++ '/usr/local/include', 3.206 ++ '/usr/local/include/sqlite', 3.207 ++ '/usr/local/include/sqlite3', 3.208 ++ ] 3.209 ++ else: 3.210 ++ # The common install prefix of 3rd party headers used during 3.211 ++ # cross compilation 3.212 ++ mydir = os.environ.get('PYTHON_XCOMPILE_DEPENDENCIES_PREFIX') 3.213 ++ if mydir: 3.214 ++ sqlite_inc_paths = [mydir + '/include' ] 3.215 ++ else: 3.216 ++ sqlite_inc_paths = [] 3.217 ++ 3.218 + MIN_SQLITE_VERSION_NUMBER = (3, 0, 8) 3.219 + MIN_SQLITE_VERSION = ".".join([str(x) 3.220 + for x in MIN_SQLITE_VERSION_NUMBER]) 3.221 +@@ -1050,12 +1084,22 @@ 3.222 + print "sqlite: %s had no SQLITE_VERSION"%(f,) 3.223 + 3.224 + if sqlite_incdir: 3.225 +- sqlite_dirs_to_check = [ 3.226 +- os.path.join(sqlite_incdir, '..', 'lib64'), 3.227 +- os.path.join(sqlite_incdir, '..', 'lib'), 3.228 +- os.path.join(sqlite_incdir, '..', '..', 'lib64'), 3.229 +- os.path.join(sqlite_incdir, '..', '..', 'lib'), 3.230 +- ] 3.231 ++ if not self.cross_compile: 3.232 ++ sqlite_dirs_to_check = [ 3.233 ++ os.path.join(sqlite_incdir, '..', 'lib64'), 3.234 ++ os.path.join(sqlite_incdir, '..', 'lib'), 3.235 ++ os.path.join(sqlite_incdir, '..', '..', 'lib64'), 3.236 ++ os.path.join(sqlite_incdir, '..', '..', 'lib'), 3.237 ++ ] 3.238 ++ else: 3.239 ++ # The common install prefix of 3rd party headers used during 3.240 ++ # cross compilation 3.241 ++ mydir = os.environ.get('PYTHON_XCOMPILE_DEPENDENCIES_PREFIX') 3.242 ++ if mydir: 3.243 ++ sqlite_dirs_to_check = [mydir + '/lib' ] 3.244 ++ else: 3.245 ++ sqlite_dirs_to_check = [] 3.246 ++ 3.247 + sqlite_libfile = self.compiler.find_library_file( 3.248 + sqlite_dirs_to_check + lib_dirs, 'sqlite3') 3.249 + if sqlite_libfile: 3.250 +@@ -1864,8 +1908,15 @@ 3.251 + 3.252 + # Pass empty CFLAGS because we'll just append the resulting 3.253 + # CFLAGS to Python's; -g or -O2 is to be avoided. 3.254 +- cmd = "cd %s && env CFLAGS='' '%s/configure' %s" \ 3.255 +- % (ffi_builddir, ffi_srcdir, " ".join(config_args)) 3.256 ++ if self.cross_compile: 3.257 ++ cmd = "cd %s && env CFLAGS='' %s/configure --host=%s --build=%s %s" \ 3.258 ++ % (ffi_builddir, ffi_srcdir, 3.259 ++ os.environ.get('HOSTARCH'), 3.260 ++ os.environ.get('BUILDARCH'), 3.261 ++ " ".join(config_args)) 3.262 ++ else: 3.263 ++ cmd = "cd %s && env CFLAGS='' '%s/configure' %s" \ 3.264 ++ % (ffi_builddir, ffi_srcdir, " ".join(config_args)) 3.265 + 3.266 + res = os.system(cmd) 3.267 + if res or not os.path.exists(ffi_configfile):