blob: 01ff99ab2f32bd44737103078aea91775ee24365 [file] [log] [blame]
Mike Frysingerce0b8c02019-07-11 00:40:18 -04001Change setup.py to respect the SYSROOT environment variable.
2This is needed to build the installed standard modules (e.g. readline & zlib).
3
4--- a/setup.py
5+++ b/setup.py
6@@ -455,12 +455,16 @@
7
8 def detect_modules(self):
9 global disable_ssl
10+
11+ # We must respect the user specified sysroot!
12+ sysroot = os.getenv('SYSROOT', '')
13+
14 # Ensure that /usr/local is always used, but the local build
15 # directories (i.e. '.' and 'Include') must be first. See issue
16 # 10520.
17 if not cross_compiling:
18- add_dir_to_list(self.compiler.library_dirs, '/usr/local/@@GENTOO_LIBDIR@@')
19- add_dir_to_list(self.compiler.include_dirs, '/usr/local/include')
20+ add_dir_to_list(self.compiler.library_dirs, sysroot + '/usr/local/@@GENTOO_LIBDIR@@')
21+ add_dir_to_list(self.compiler.include_dirs, sysroot + '/usr/local/include')
22 # only change this for cross builds for 3.3, issues on Mageia
23 if cross_compiling:
24 self.add_gcc_paths()
25@@ -504,9 +508,15 @@
26 # building a framework with different architectures than
27 # the one that is currently installed (issue #7473)
28 add_dir_to_list(self.compiler.library_dirs,
29- sysconfig.get_config_var("LIBDIR"))
30+ sysroot + sysconfig.get_config_var("LIBDIR"))
31 add_dir_to_list(self.compiler.include_dirs,
32- sysconfig.get_config_var("INCLUDEDIR"))
33+ sysroot + sysconfig.get_config_var("INCLUDEDIR"))
34+
35+ # We should always look into sysroot/usr/include and consider
36+ # also the lib dirs there for searching for files
37+ add_dir_to_list(self.compiler.include_dirs, sysroot + '/usr/include')
38+ add_dir_to_list(self.compiler.library_dirs, sysroot + '/@@GENTOO_LIBDIR@@')
39+ add_dir_to_list(self.compiler.library_dirs, sysroot + '/usr/@@GENTOO_LIBDIR@@')
40
41 try:
42 have_unicode = unicode
43@@ -527,6 +537,9 @@
44 inc_dirs = (self.compiler.include_dirs +
45 sysroot_paths(('CPPFLAGS', 'CFLAGS', 'CC'),
46 system_include_dirs))
47+ # Ignore previous settings.
48+ lib_dirs = self.compiler.library_dirs
49+ inc_dirs = self.compiler.include_dirs
50 exts = []
51 missing = []
52
53@@ -778,11 +791,11 @@
54 elif curses_library:
55 readline_libs.append(curses_library)
56 elif self.compiler.find_library_file(lib_dirs +
57- ['/usr/@@GENTOO_LIBDIR@@/termcap'],
58+ [sysroot + '/usr/@@GENTOO_LIBDIR@@/termcap'],
59 'termcap'):
60 readline_libs.append('termcap')
61 exts.append( Extension('readline', ['readline.c'],
62- library_dirs=['/usr/@@GENTOO_LIBDIR@@/termcap'],
63+ library_dirs=[sysroot + '/usr/@@GENTOO_LIBDIR@@/termcap'],
64 extra_link_args=readline_extra_link_args,
65 libraries=readline_libs) )
66 else:
67@@ -805,20 +818,20 @@
68 libraries=math_libs) )
69 # Detect SSL support for the socket module (via _ssl)
70 search_for_ssl_incs_in = [
71- '/usr/local/ssl/include',
72- '/usr/contrib/ssl/include/'
73+ sysroot + '/usr/local/ssl/include',
74+ sysroot + '/usr/contrib/ssl/include/'
75 ]
76 ssl_incs = find_file('openssl/ssl.h', inc_dirs,
77 search_for_ssl_incs_in
78 )
79 if ssl_incs is not None and not disable_ssl:
80 krb5_h = find_file('krb5.h', inc_dirs,
81- ['/usr/kerberos/include'])
82+ [sysroot + '/usr/kerberos/include'])
83 if krb5_h:
84 ssl_incs += krb5_h
85 ssl_libs = find_library_file(self.compiler, 'ssl',lib_dirs,
86- ['/usr/local/ssl/lib',
87- '/usr/contrib/ssl/lib/'
88+ [sysroot + '/usr/local/ssl/lib',
89+ sysroot + '/usr/contrib/ssl/lib/'
90 ] )
91
92 if (ssl_incs is not None and
93@@ -968,6 +981,7 @@
94 db_inc_paths.append('/usr/local/include/db3%d' % x)
95 db_inc_paths.append('/pkg/db-3.%d/include' % x)
96 db_inc_paths.append('/opt/db-3.%d/include' % x)
97+ db_inc_paths = [sysroot + x for x in db_inc_paths]
98
99 if cross_compiling:
100 db_inc_paths = []
101@@ -1121,6 +1135,7 @@
102 ]
103 if cross_compiling:
104 sqlite_inc_paths = []
105+ sqlite_inc_paths = [sysroot + x for x in sqlite_inc_paths]
106 MIN_SQLITE_VERSION_NUMBER = (3, 0, 8)
107 MIN_SQLITE_VERSION = ".".join([str(x)
108 for x in MIN_SQLITE_VERSION_NUMBER])
109@@ -1835,7 +1850,7 @@
110 # For 8.4a2, the X11 headers are not included. Rather than include a
111 # complicated search, this is a hard-coded path. It could bail out
112 # if X11 libs are not found...
113- include_dirs.append('/usr/X11R6/include')
114+ include_dirs.append(sysroot + '/usr/X11R6/include')
115 frameworks = ['-framework', 'Tcl', '-framework', 'Tk']
116
117 # All existing framework builds of Tcl/Tk don't support 64-bit
118@@ -1879,6 +1894,9 @@
119 if self.detect_tkinter_explicitly():
120 return
121
122+ # We must respect the user specified sysroot!
123+ sysroot = os.getenv('SYSROOT', '')
124+
125 # Rather than complicate the code below, detecting and building
126 # AquaTk is a separate method. Only one Tkinter will be built on
127 # Darwin - either AquaTk, if it is found, or X11 based Tk.
128@@ -1934,16 +1952,16 @@
129 if host_platform == 'sunos5':
130 include_dirs.append('/usr/openwin/include')
131 added_lib_dirs.append('/usr/openwin/lib')
132- elif os.path.exists('/usr/X11R6/include'):
133- include_dirs.append('/usr/X11R6/include')
134- added_lib_dirs.append('/usr/X11R6/@@GENTOO_LIBDIR@@')
135- elif os.path.exists('/usr/X11R5/include'):
136- include_dirs.append('/usr/X11R5/include')
137- added_lib_dirs.append('/usr/X11R5/@@GENTOO_LIBDIR@@')
138+ elif os.path.exists(sysroot + '/usr/X11R6/include'):
139+ include_dirs.append(sysroot + '/usr/X11R6/include')
140+ added_lib_dirs.append(sysroot + '/usr/X11R6/@@GENTOO_LIBDIR@@')
141+ elif os.path.exists(sysroot + '/usr/X11R5/include'):
142+ include_dirs.append(sysroot + '/usr/X11R5/include')
143+ added_lib_dirs.append(sysroot + '/usr/X11R5/@@GENTOO_LIBDIR@@')
144 else:
145 # Assume default location for X11
146- include_dirs.append('/usr/X11/include')
147- added_lib_dirs.append('/usr/X11/@@GENTOO_LIBDIR@@')
148+ include_dirs.append(sysroot + '/usr/X11/include')
149+ added_lib_dirs.append(sysroot + '/usr/X11/@@GENTOO_LIBDIR@@')
150
151 # If Cygwin, then verify that X is installed before proceeding
152 if host_platform == 'cygwin':