view patches/python-2.4.5-setup-cross.patch @ 6211:37158d8bead6

python-2.4, python-2.6 tools and cross build fixes.
author Jan Nieuwenhuizen <janneke@gnu.org>
date Tue, 28 Aug 2012 19:01:24 +0200
parents a4dfe4e574ec
children
line wrap: on
line source

Teach the python module compiler setup.py about cross compilation.

--- python-2.4.5/setup.py~	2012-08-27 11:07:07.049617420 +0200
+++ python-2.4.5/setup.py	2012-08-27 11:46:45.350781819 +0200
@@ -5,6 +5,8 @@
 
 import sys, os, getopt, imp, re
 
+if os.environ.get ('system_root', ''):
+    sys.path.insert (0, os.environ.get ('srcdir', '') + '/Lib')
 from distutils import log
 from distutils import sysconfig
 from distutils import text_file
@@ -14,6 +14,16 @@
 from distutils.command.install import install
 from distutils.command.install_lib import install_lib
 
+def exists_in_sysroot (f):
+    if (f.startswith ('/')
+        and not f.startswith (os.environ.get ('alltargetdir', ''))):
+        f = os.environ.get ('system_root', '') + f
+    if os_path_exists (f):
+       return f
+    return False
+os_path_exists = os.path.exists
+os.path.exists = exists_in_sysroot
+
 # This global variable is used to hold the list of modules to be disabled.
 disabled_module_list = []
 
@@ -58,13 +58,14 @@ def find_file(filename, std_dirs, paths)
     # Check the standard locations
     for dir in std_dirs:
         f = os.path.join(dir, filename)
-        if os.path.exists(f): return []
+        if os.path.exists(f):
+            return [os.path.exists(dir)]
 
     # Check the additional directories
     for dir in paths:
         f = os.path.join(dir, filename)
         if os.path.exists(f):
-            return [dir]
+            return [os.path.exists (dir)]
 
     # Not found anywhere
     return None
@@ -174,6 +174,7 @@ class PyBuildExt(build_ext):
         headers = glob("Include/*.h") + ["pyconfig.h"]
 
         for ext in self.extensions[:]:
+            ext.libraries += (sysconfig.get_config_var ('EXT_LIBS') or '').replace ('-l', '').split ()
             ext.sources = [ find_module_file(filename, moddirlist)
                             for filename in ext.sources ]
             if ext.depends is not None:
@@ -590,7 +590,8 @@
             for d in inc_dirs + db_inc_paths:
                 f = os.path.join(d, "db.h")
                 if db_setup_debug: print "db: looking for db.h in", f
-                if os.path.exists(f):
+                f = os.path.exists(f)
+                if f:
                     f = open(f).read()
                     m = re.search(r"#define\WDB_VERSION_MAJOR\W(\d+)", f)
                     if m:
@@ -629,7 +632,7 @@ class PyBuildExt(build_ext):
                            (db_ver <= max_db_ver and db_ver >= min_db_ver) ):
                             # save the include directory with the db.h version
                             # (first occurrance only)
-                            db_ver_inc_map[db_ver] = d
+                            db_ver_inc_map[db_ver] = os.path.exists (d)
                             print "db.h: found", db_ver, "in", d
                         else:
                             # we already found a header for this library version
@@ -673,7 +674,8 @@
         # underlying db library.  May BSD-ish Unixes incorporate db 1.85
         # symbols into libc and place the include file in /usr/include.
         f = "/usr/include/db.h"
-        if os.path.exists(f):
+        f = os.path.exists(f)
+        if f:
             data = open(f).read()
             m = re.search(r"#s*define\s+HASHVERSION\s+2\s*", data)
             if m is not None:
--- python-2.4.5/Makefile.pre.in~	2012-08-27 18:01:49.608729518 +0200
+++ python-2.4.5/Makefile.pre.in	2012-08-27 18:06:05.118707910 +0200
@@ -895,7 +895,7 @@ sharedinstall:
 		--prefix=$(prefix) \
 		--install-scripts=$(BINDIR) \
 		--install-platlib=$(DESTSHARED) \
-		--root=/$(DESTDIR)
+		--root=$(DESTDIR)
 
 # Here are a couple of targets for MacOSX again, to install a full
 # framework-based Python. frameworkinstall installs everything, the
@@ -965,7 +965,7 @@ scriptsinstall:
 	./$(PYTHON_FOR_BUILD) $(srcdir)/Tools/scripts/setup.py install \
 	--prefix=$(prefix) \
 	--install-scripts=$(BINDIR) \
-	--root=/$(DESTDIR)
+	--root=$(DESTDIR)
 
 # Build the toplevel Makefile
 Makefile.pre: Makefile.pre.in config.status
--- python-2.4.5/Lib/distutils/unixccompiler.py~	2012-08-27 21:51:36.950636210 +0200
+++ python-2.4.5/Lib/distutils/unixccompiler.py	2012-08-27 21:50:00.732128349 +0200
@@ -249,7 +249,7 @@
         # this time, there's no way to determine this information from
         # the configuration data stored in the Python installation, so
         # we use this hack.
-        compiler = os.path.basename(sysconfig.get_config_var("CC"))
+        compiler = os.path.basename(sysconfig.get_config_var("CC").split ()[0])
         if sys.platform[:6] == "darwin":
             # MacOSX's linker doesn't understand the -R flag at all
             return "-L" + dir
--- python-2.4-2.4.5/Lib/distutils/sysconfig.py~	2009-09-22 21:31:34.000000000 +0200
+++ python-2.4-2.p.5/Lib/distutils/sysconfig.py	2012-08-28 17:08:01.256687224 +0200
@@ -217,6 +223,8 @@ def get_config_h_filename():
 
 def get_makefile_filename():
     """Return full pathname of installed Makefile from the Python build."""
+    if os.environ.get('system_root', ''):
+        return 'Makefile'
     if python_build:
         return os.path.join(os.path.dirname(sys.executable), "Makefile")
     lib_dir = get_python_lib(plat_specific=1, standard_lib=1)