blob: 033776d465f6b48981eac2ee223304416a54dfb3 [file] [log] [blame]
Do not look at host headers/libraries in cross-compile mode
When we are cross-compiling, setup.py should never look in /usr or
/usr/local to find headers or libraries. A later patch adds a
mechanism to tell setup.py to look in a specific directory for headers
and libraries.
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
---
setup.py | 39 +++++++++++++++++++++------------------
1 file changed, 21 insertions(+), 18 deletions(-)
Index: Python-2.7.1/setup.py
===================================================================
--- Python-2.7.1.orig/setup.py
+++ Python-2.7.1/setup.py
@@ -351,8 +351,9 @@
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.
@@ -388,17 +389,6 @@
for directory in reversed(options.dirs):
add_dir_to_list(dir_list, directory)
- if os.path.normpath(sys.prefix) != '/usr' \
- and not sysconfig.get_config_var('PYTHONFRAMEWORK'):
- # OSX note: Don't add LIBDIR and INCLUDEDIR to building a framework
- # (PYTHONFRAMEWORK is set) to avoid # linking problems when
- # building a framework with different architectures than
- # the one that is currently installed (issue #7473)
- add_dir_to_list(self.compiler.library_dirs,
- sysconfig.get_config_var("LIBDIR"))
- add_dir_to_list(self.compiler.include_dirs,
- sysconfig.get_config_var("INCLUDEDIR"))
-
try:
have_unicode = unicode
except NameError:
@@ -407,11 +397,16 @@
# 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 = self.compiler.library_dirs
+ inc_dirs = self.compiler.include_dirs
+
+ if os.environ.get('CROSS_COMPILING') != 'yes':
+ lib_dirs += [
+ '/lib64', '/usr/lib64',
+ '/lib', '/usr/lib',
+ ]
+ inc_dirs += ['/usr/include']
+
exts = []
missing = []
@@ -844,6 +839,9 @@
db_inc_paths.append('/pkg/db-3.%d/include' % x)
db_inc_paths.append('/opt/db-3.%d/include' % x)
+ if os.environ.get('CROSS_COMPILING') == 'yes':
+ db_inc_paths = []
+
# Add some common subdirectories for Sleepycat DB to the list,
# based on the standard include directories. This way DB3/4 gets
# picked up when it is installed in a non-standard prefix and
@@ -996,6 +994,9 @@
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.
@@ -1095,6 +1096,8 @@
# the more recent berkeleydb's db.h file first in the include path
# when attempting to compile and it will fail.
f = "/usr/include/db.h"
+ if os.environ.get('CROSS_COMPILING') == 'yes':
+ f = ''
if sys.platform == 'darwin':
if is_macosx_sdk_path(f):