Add a CROSS_COMPILING=yes variable in order to tell setup.py that we are
cross compiling.

Signed-off-by: Robert Schwebel <r.schwe...@pengutronix.de>

---
 setup.py |   46 ++++++++++++++++++++++++++++++++++++----------
 1 file changed, 36 insertions(+), 10 deletions(-)

Index: Python-3.0/setup.py
===================================================================
--- Python-3.0.orig/setup.py
+++ Python-3.0/setup.py
@@ -18,6 +18,15 @@ from distutils.command.install_lib impor
 # This global variable is used to hold the list of modules to be disabled.
 disabled_module_list = []
 
+import os
+
+if os.environ.get('CROSS_COMPILING') == 'yes':
+    sysconfig.get_config_vars()
+    sysconfig._config_vars.update (os.environ)
+else:
+    sysconfig.get_config_vars()
+    sysconfig._config_vars['srcdir'] = os.environ['srcdir']
+
 def add_dir_to_list(dirlist, dir):
     """Add the directory 'dir' to the list 'dirlist' (at the front) if
     1) 'dir' is not already in 'dirlist'
@@ -260,6 +269,10 @@ class PyBuildExt(build_ext):
             self.announce('WARNING: skipping import check for Cygwin-based 
"%s"'
                 % ext.name)
             return
+        if os.environ.get('CROSS_COMPILING') == 'yes':
+            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)))
@@ -301,16 +314,20 @@ class PyBuildExt(build_ext):
             self.failed.append(ext.name)
 
     def get_platform(self):
-        # Get value of sys.platform
+        # Get value of target's sys.platform
+        p = sys.platform
+        if os.environ.get('CROSS_COMPILING') == 'yes':
+            p = os.environ.get('CROSS_TARGET')
         for platform in ['cygwin', 'darwin', 'atheos', 'osf1']:
-            if sys.platform.startswith(platform):
+            if p.startswith(platform):
                 return platform
-        return sys.platform
+        return p
 
     def detect_modules(self):
         # Ensure that /usr/local is always used
-        add_dir_to_list(self.compiler.library_dirs, '/usr/local/lib')
-        add_dir_to_list(self.compiler.include_dirs, '/usr/local/include')
+        if os.environ.get('CROSS_COMPILING') != 'yes':
+            add_dir_to_list(self.compiler.library_dirs, '/usr/local/lib')
+            add_dir_to_list(self.compiler.include_dirs, '/usr/local/include')
 
         # Add paths specified in the environment variables LDFLAGS and
         # CPPFLAGS for header and library files.
@@ -355,11 +372,14 @@ class PyBuildExt(build_ext):
         # lib_dirs and inc_dirs are used to search for files;
         # if a file is found in one of those directories, it can
         # be assumed that no additional -I,-L directives are needed.
-        lib_dirs = self.compiler.library_dirs + [
-            '/lib64', '/usr/lib64',
-            '/lib', '/usr/lib',
-            ]
-        inc_dirs = self.compiler.include_dirs + ['/usr/include']
+        lib_dirs = []
+        inc_dirs = []
+        if os.environ.get('CROSS_COMPILING') != 'yes':
+            lib_dirs = self.compiler.library_dirs + [
+                '/lib64', '/usr/lib64',
+                '/lib', '/usr/lib',
+                ]
+            inc_dirs = self.compiler.include_dirs + ['/usr/include']
         exts = []
         missing = []
 
@@ -675,6 +695,9 @@ class PyBuildExt(build_ext):
             '/sw/include/db3',
         ]
 
+        if os.environ.get('CROSS_COMPILING') == 'yes':
+            db_inc_paths = []
+
         db_incs = None
 
         # The sqlite interface
@@ -694,6 +717,9 @@ class PyBuildExt(build_ext):
         MIN_SQLITE_VERSION = ".".join([str(x)
                                     for x in MIN_SQLITE_VERSION_NUMBER])
 
+        if os.environ.get('CROSS_COMPILING') == 'yes':
+            sqlite_inc_paths = []
+
         # Scan the default include directories before the SQLite specific
         # ones. This allows one to override the copy of sqlite on OSX,
         # where /usr/include contains an old version of sqlite.

-- 
Pengutronix e.K.                           | Dipl.-Ing. Robert Schwebel  |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |
_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to