1
by Ricardo Javier Cardenes Medina
Import upstream version 4.1.1 |
1 |
# This script handles the SIP configuration and generates the Makefiles.
|
2 |
#
|
|
1.2.1
by Torsten Marek
Import upstream version 4.10 |
3 |
# Copyright (c) 2010 Riverbank Computing Limited <info@riverbankcomputing.com>
|
1.2.2
by Torsten Marek
Import upstream version 4.10.1 |
4 |
#
|
1
by Ricardo Javier Cardenes Medina
Import upstream version 4.1.1 |
5 |
# This file is part of SIP.
|
1.2.2
by Torsten Marek
Import upstream version 4.10.1 |
6 |
#
|
1
by Ricardo Javier Cardenes Medina
Import upstream version 4.1.1 |
7 |
# This copy of SIP is licensed for use under the terms of the SIP License
|
8 |
# Agreement. See the file LICENSE for more details.
|
|
1.2.2
by Torsten Marek
Import upstream version 4.10.1 |
9 |
#
|
1.1.16
by Michael Casadevall
Import upstream version 4.9 |
10 |
# This copy of SIP may also used under the terms of the GNU General Public
|
11 |
# License v2 or v3 as published by the Free Software Foundation which can be
|
|
1.2.2
by Torsten Marek
Import upstream version 4.10.1 |
12 |
# found in the files LICENSE-GPL2 and LICENSE-GPL3 included in this package.
|
13 |
#
|
|
1
by Ricardo Javier Cardenes Medina
Import upstream version 4.1.1 |
14 |
# SIP is supplied WITHOUT ANY WARRANTY; without even the implied warranty of
|
15 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
16 |
||
17 |
||
18 |
import sys |
|
19 |
import os |
|
20 |
import glob |
|
1.1.13
by Jonathan Riddell
Import upstream version 4.8 |
21 |
import optparse |
1.1.9
by Michael Vogt
Import upstream version 4.7.4 |
22 |
from distutils import sysconfig |
1
by Ricardo Javier Cardenes Medina
Import upstream version 4.1.1 |
23 |
|
24 |
import siputils |
|
25 |
||
26 |
||
27 |
# Initialise the globals.
|
|
1.2.3
by Torsten Marek
Import upstream version 4.10.2 |
28 |
sip_version = 0x040a02 |
29 |
sip_version_str = "4.10.2" |
|
1
by Ricardo Javier Cardenes Medina
Import upstream version 4.1.1 |
30 |
py_version = sys.hexversion >> 8 |
31 |
plat_py_site_dir = None |
|
32 |
plat_py_inc_dir = None |
|
1.1.3
by Torsten Marek
Import upstream version 4.4.5 |
33 |
plat_py_conf_inc_dir = None |
1
by Ricardo Javier Cardenes Medina
Import upstream version 4.1.1 |
34 |
plat_py_lib_dir = None |
35 |
plat_sip_dir = None |
|
36 |
plat_bin_dir = None |
|
37 |
platform_specs = [] |
|
1.2.1
by Torsten Marek
Import upstream version 4.10 |
38 |
src_dir = os.path.dirname(os.path.abspath(__file__)) |
1
by Ricardo Javier Cardenes Medina
Import upstream version 4.1.1 |
39 |
|
1.1.10
by Jonathan Riddell
Import upstream version 4.7.6 |
40 |
# Constants.
|
1.1.16
by Michael Casadevall
Import upstream version 4.9 |
41 |
DEFAULT_MACOSX_ARCH = 'i386 ppc' |
42 |
MACOSX_SDK_DIR = '/Developer/SDKs' |
|
1.1.10
by Jonathan Riddell
Import upstream version 4.7.6 |
43 |
|
1
by Ricardo Javier Cardenes Medina
Import upstream version 4.1.1 |
44 |
# Command line options.
|
1.1.13
by Jonathan Riddell
Import upstream version 4.8 |
45 |
default_platform = None |
46 |
default_sipbindir = None |
|
47 |
default_sipmoddir = None |
|
48 |
default_sipincdir = None |
|
49 |
default_sipsipdir = None |
|
1
by Ricardo Javier Cardenes Medina
Import upstream version 4.1.1 |
50 |
|
51 |
# The names of build macros extracted from the platform specific configuration
|
|
52 |
# files.
|
|
1.1.3
by Torsten Marek
Import upstream version 4.4.5 |
53 |
build_macro_names = [ |
1.1.4
by Matthias Klose
Import upstream version 4.5 |
54 |
"DEFINES", "CONFIG", |
1
by Ricardo Javier Cardenes Medina
Import upstream version 4.1.1 |
55 |
"CC", |
56 |
"CFLAGS", |
|
57 |
"CFLAGS_RELEASE", "CFLAGS_DEBUG", |
|
58 |
"CFLAGS_CONSOLE", "CFLAGS_SHLIB", "CFLAGS_THREAD", |
|
59 |
"CFLAGS_MT", "CFLAGS_MT_DBG", "CFLAGS_MT_DLL", "CFLAGS_MT_DLLDBG", |
|
60 |
"CFLAGS_EXCEPTIONS_ON", "CFLAGS_EXCEPTIONS_OFF", |
|
61 |
"CFLAGS_RTTI_ON", "CFLAGS_RTTI_OFF", |
|
62 |
"CFLAGS_STL_ON", "CFLAGS_STL_OFF", |
|
63 |
"CFLAGS_WARN_ON", "CFLAGS_WARN_OFF", |
|
64 |
"CHK_DIR_EXISTS", "COPY", |
|
65 |
"CXX", |
|
66 |
"CXXFLAGS", |
|
67 |
"CXXFLAGS_RELEASE", "CXXFLAGS_DEBUG", |
|
68 |
"CXXFLAGS_CONSOLE", "CXXFLAGS_SHLIB", "CXXFLAGS_THREAD", |
|
69 |
"CXXFLAGS_MT", "CXXFLAGS_MT_DBG", "CXXFLAGS_MT_DLL", "CXXFLAGS_MT_DLLDBG", |
|
70 |
"CXXFLAGS_EXCEPTIONS_ON", "CXXFLAGS_EXCEPTIONS_OFF", |
|
71 |
"CXXFLAGS_RTTI_ON", "CXXFLAGS_RTTI_OFF", |
|
72 |
"CXXFLAGS_STL_ON", "CXXFLAGS_STL_OFF", |
|
73 |
"CXXFLAGS_WARN_ON", "CXXFLAGS_WARN_OFF", |
|
74 |
"DEL_FILE", |
|
1.1.1
by Hervé Cauwelier
Import upstream version 4.2.1 |
75 |
"EXTENSION_SHLIB", "EXTENSION_PLUGIN", |
1.1.3
by Torsten Marek
Import upstream version 4.4.5 |
76 |
"INCDIR", "INCDIR_X11", "INCDIR_OPENGL", |
77 |
"LIBS_CORE", "LIBS_GUI", "LIBS_NETWORK", "LIBS_OPENGL", |
|
1
by Ricardo Javier Cardenes Medina
Import upstream version 4.1.1 |
78 |
"LINK", "LINK_SHLIB", "AIX_SHLIB", "LINK_SHLIB_CMD", |
79 |
"LFLAGS", "LFLAGS_CONSOLE", "LFLAGS_CONSOLE_DLL", "LFLAGS_DEBUG", |
|
1.1.3
by Torsten Marek
Import upstream version 4.4.5 |
80 |
"LFLAGS_DLL", |
1
by Ricardo Javier Cardenes Medina
Import upstream version 4.1.1 |
81 |
"LFLAGS_PLUGIN", "LFLAGS_RELEASE", "LFLAGS_SHLIB", "LFLAGS_SONAME", |
82 |
"LFLAGS_THREAD", "LFLAGS_WINDOWS", "LFLAGS_WINDOWS_DLL", "LFLAGS_OPENGL", |
|
1.1.3
by Torsten Marek
Import upstream version 4.4.5 |
83 |
"LIBDIR", "LIBDIR_X11", "LIBDIR_OPENGL", |
1
by Ricardo Javier Cardenes Medina
Import upstream version 4.1.1 |
84 |
"LIBS", "LIBS_CONSOLE", "LIBS_OPENGL", "LIBS_OPENGL", "LIBS_RT", |
85 |
"LIBS_RTMT", "LIBS_THREAD", "LIBS_WINDOWS", "LIBS_X11", |
|
86 |
"MAKEFILE_GENERATOR", |
|
1.1.3
by Torsten Marek
Import upstream version 4.4.5 |
87 |
"MKDIR", |
1
by Ricardo Javier Cardenes Medina
Import upstream version 4.1.1 |
88 |
"RPATH", |
1.1.1
by Hervé Cauwelier
Import upstream version 4.2.1 |
89 |
"AR", "RANLIB", "LIB", "STRIP" |
1
by Ricardo Javier Cardenes Medina
Import upstream version 4.1.1 |
90 |
]
|
91 |
||
92 |
||
1.1.13
by Jonathan Riddell
Import upstream version 4.8 |
93 |
def show_platforms(): |
94 |
"""Display the different platform/compilers.
|
|
1
by Ricardo Javier Cardenes Medina
Import upstream version 4.1.1 |
95 |
"""
|
1.1.13
by Jonathan Riddell
Import upstream version 4.8 |
96 |
sys.stdout.write(""" |
97 |
The following platform/compiler configurations are supported:
|
|
1
by Ricardo Javier Cardenes Medina
Import upstream version 4.1.1 |
98 |
|
1.1.13
by Jonathan Riddell
Import upstream version 4.8 |
99 |
""") |
1
by Ricardo Javier Cardenes Medina
Import upstream version 4.1.1 |
100 |
|
101 |
platform_specs.sort() |
|
1.1.13
by Jonathan Riddell
Import upstream version 4.8 |
102 |
sys.stdout.write(siputils.format(", ".join(platform_specs), leftmargin=2)) |
103 |
sys.stdout.write("\n\n") |
|
104 |
||
105 |
||
106 |
def show_macros(): |
|
107 |
"""Display the different build macros.
|
|
108 |
"""
|
|
109 |
sys.stdout.write(""" |
|
110 |
The following options may be used to adjust the compiler configuration:
|
|
111 |
||
112 |
""") |
|
1
by Ricardo Javier Cardenes Medina
Import upstream version 4.1.1 |
113 |
|
1.1.3
by Torsten Marek
Import upstream version 4.4.5 |
114 |
build_macro_names.sort() |
1.1.13
by Jonathan Riddell
Import upstream version 4.8 |
115 |
sys.stdout.write(siputils.format(", ".join(build_macro_names), leftmargin=2)) |
116 |
sys.stdout.write("\n\n") |
|
1
by Ricardo Javier Cardenes Medina
Import upstream version 4.1.1 |
117 |
|
118 |
||
119 |
def set_defaults(): |
|
120 |
"""Set up the defaults for values that can be set on the command line.
|
|
121 |
"""
|
|
1.1.13
by Jonathan Riddell
Import upstream version 4.8 |
122 |
global default_platform, default_sipbindir, default_sipmoddir |
123 |
global default_sipincdir, default_sipsipdir |
|
1
by Ricardo Javier Cardenes Medina
Import upstream version 4.1.1 |
124 |
|
125 |
# Set the platform specific default specification.
|
|
126 |
platdefaults = { |
|
127 |
"aix": "aix-xlc", |
|
128 |
"bsd": "bsdi-g++", |
|
129 |
"cygwin": "cygwin-g++", |
|
130 |
"darwin": "macx-g++", |
|
131 |
"dgux": "dgux-g++", |
|
132 |
"freebsd": "freebsd-g++", |
|
133 |
"gnu": "hurd-g++", |
|
134 |
"hp-ux": "hpux-acc", |
|
135 |
"irix": "irix-cc", |
|
136 |
"linux": "linux-g++", |
|
137 |
"lynxos": "lynxos-g++", |
|
138 |
"netbsd": "netbsd-g++", |
|
139 |
"openbsd": "openbsd-g++", |
|
140 |
"openunix": "unixware-cc", |
|
141 |
"osf1": "tru64-cxx", |
|
142 |
"qnx": "qnx-g++", |
|
143 |
"reliantunix": "reliant-cds", |
|
144 |
"sco_sv": "sco-cc", |
|
145 |
"sinix": "reliant-cds", |
|
146 |
"sunos5": "solaris-cc", |
|
147 |
"ultrix": "ultrix-g++", |
|
148 |
"unix_sv": "unixware-g++", |
|
1.1.3
by Torsten Marek
Import upstream version 4.4.5 |
149 |
"unixware": "unixware-cc" |
1
by Ricardo Javier Cardenes Medina
Import upstream version 4.1.1 |
150 |
}
|
151 |
||
152 |
default_platform = "none" |
|
153 |
||
1.1.3
by Torsten Marek
Import upstream version 4.4.5 |
154 |
if sys.platform == "win32": |
1.1.10
by Jonathan Riddell
Import upstream version 4.7.6 |
155 |
if py_version >= 0x020600: |
156 |
default_platform = "win32-msvc2008" |
|
157 |
elif py_version >= 0x020400: |
|
1.1.3
by Torsten Marek
Import upstream version 4.4.5 |
158 |
default_platform = "win32-msvc.net" |
159 |
else: |
|
160 |
default_platform = "win32-msvc" |
|
161 |
else: |
|
1.1.13
by Jonathan Riddell
Import upstream version 4.8 |
162 |
for pd in list(platdefaults.keys()): |
1.1.3
by Torsten Marek
Import upstream version 4.4.5 |
163 |
if sys.platform[:len(pd)] == pd: |
164 |
default_platform = platdefaults[pd] |
|
165 |
break
|
|
1
by Ricardo Javier Cardenes Medina
Import upstream version 4.1.1 |
166 |
|
1.1.13
by Jonathan Riddell
Import upstream version 4.8 |
167 |
default_sipbindir = plat_bin_dir |
168 |
default_sipmoddir = plat_py_site_dir |
|
169 |
default_sipincdir = plat_py_inc_dir |
|
170 |
default_sipsipdir = plat_sip_dir |
|
1
by Ricardo Javier Cardenes Medina
Import upstream version 4.1.1 |
171 |
|
172 |
||
173 |
def inform_user(): |
|
174 |
"""Tell the user the option values that are going to be used.
|
|
175 |
"""
|
|
1.1.13
by Jonathan Riddell
Import upstream version 4.8 |
176 |
siputils.inform("The SIP code generator will be installed in %s." % opts.sipbindir) |
177 |
siputils.inform("The SIP module will be installed in %s." % opts.sipmoddir) |
|
178 |
siputils.inform("The SIP header file will be installed in %s." % opts.sipincdir) |
|
179 |
siputils.inform("The default directory to install .sip files in is %s." % opts.sipsipdir) |
|
180 |
siputils.inform("The platform/compiler configuration is %s." % opts.platform) |
|
1
by Ricardo Javier Cardenes Medina
Import upstream version 4.1.1 |
181 |
|
1.1.16
by Michael Casadevall
Import upstream version 4.9 |
182 |
if opts.arch: |
183 |
siputils.inform("MacOS/X binaries will be created for %s." % (", ".join(opts.arch.split()))) |
|
184 |
||
1.1.13
by Jonathan Riddell
Import upstream version 4.8 |
185 |
if opts.universal: |
186 |
siputils.inform("MacOS/X universal binaries will be created using %s." % opts.universal) |
|
1.1.5
by Steve Kowalik
Import upstream version 4.6 |
187 |
|
1
by Ricardo Javier Cardenes Medina
Import upstream version 4.1.1 |
188 |
|
189 |
def set_platform_directories(): |
|
190 |
"""Initialise the global variables relating to platform specific
|
|
191 |
directories.
|
|
192 |
"""
|
|
1.1.3
by Torsten Marek
Import upstream version 4.4.5 |
193 |
global plat_py_site_dir, plat_py_inc_dir, plat_py_conf_inc_dir |
194 |
global plat_bin_dir, plat_py_lib_dir, plat_sip_dir |
|
1
by Ricardo Javier Cardenes Medina
Import upstream version 4.1.1 |
195 |
|
1.1.9
by Michael Vogt
Import upstream version 4.7.4 |
196 |
# We trust distutils for some stuff.
|
1.1.10
by Jonathan Riddell
Import upstream version 4.7.6 |
197 |
plat_py_site_dir = sysconfig.get_python_lib(plat_specific=1) |
1.1.9
by Michael Vogt
Import upstream version 4.7.4 |
198 |
plat_py_inc_dir = sysconfig.get_python_inc() |
199 |
plat_py_conf_inc_dir = os.path.dirname(sysconfig.get_config_h_filename()) |
|
200 |
||
1
by Ricardo Javier Cardenes Medina
Import upstream version 4.1.1 |
201 |
if sys.platform == "win32": |
202 |
plat_py_lib_dir = sys.prefix + "\\libs" |
|
203 |
plat_bin_dir = sys.exec_prefix |
|
204 |
plat_sip_dir = sys.prefix + "\\sip" |
|
205 |
else: |
|
1.1.10
by Jonathan Riddell
Import upstream version 4.7.6 |
206 |
lib_dir = sysconfig.get_python_lib(plat_specific=1, standard_lib=1) |
1.1.4
by Matthias Klose
Import upstream version 4.5 |
207 |
|
208 |
plat_py_lib_dir = lib_dir + "/config" |
|
1
by Ricardo Javier Cardenes Medina
Import upstream version 4.1.1 |
209 |
plat_bin_dir = sys.exec_prefix + "/bin" |
210 |
plat_sip_dir = sys.prefix + "/share/sip" |
|
211 |
||
212 |
||
213 |
def create_config(module, template, macros): |
|
214 |
"""Create the SIP configuration module so that it can be imported by build
|
|
215 |
scripts.
|
|
216 |
||
217 |
module is the module file name.
|
|
218 |
template is the template file name.
|
|
219 |
macros is the dictionary of build macros.
|
|
220 |
"""
|
|
221 |
siputils.inform("Creating %s..." % module) |
|
222 |
||
223 |
content = { |
|
1.1.4
by Matthias Klose
Import upstream version 4.5 |
224 |
"sip_config_args": sys.argv[1:], |
1
by Ricardo Javier Cardenes Medina
Import upstream version 4.1.1 |
225 |
"sip_version": sip_version, |
226 |
"sip_version_str": sip_version_str, |
|
1.1.13
by Jonathan Riddell
Import upstream version 4.8 |
227 |
"platform": opts.platform, |
228 |
"sip_bin": os.path.join(opts.sipbindir, "sip"), |
|
229 |
"sip_inc_dir": opts.sipincdir, |
|
230 |
"sip_mod_dir": opts.sipmoddir, |
|
1
by Ricardo Javier Cardenes Medina
Import upstream version 4.1.1 |
231 |
"default_bin_dir": plat_bin_dir, |
232 |
"default_mod_dir": plat_py_site_dir, |
|
1.1.13
by Jonathan Riddell
Import upstream version 4.8 |
233 |
"default_sip_dir": opts.sipsipdir, |
1
by Ricardo Javier Cardenes Medina
Import upstream version 4.1.1 |
234 |
"py_version": py_version, |
235 |
"py_inc_dir": plat_py_inc_dir, |
|
1.1.3
by Torsten Marek
Import upstream version 4.4.5 |
236 |
"py_conf_inc_dir": plat_py_conf_inc_dir, |
1.1.5
by Steve Kowalik
Import upstream version 4.6 |
237 |
"py_lib_dir": plat_py_lib_dir, |
1.1.16
by Michael Casadevall
Import upstream version 4.9 |
238 |
"universal": opts.universal, |
239 |
"arch": opts.arch |
|
1.1.3
by Torsten Marek
Import upstream version 4.4.5 |
240 |
}
|
241 |
||
242 |
siputils.create_config_module(module, template, content, macros) |
|
243 |
||
244 |
||
245 |
def create_makefiles(macros): |
|
1
by Ricardo Javier Cardenes Medina
Import upstream version 4.1.1 |
246 |
"""Create the Makefiles.
|
1.1.3
by Torsten Marek
Import upstream version 4.4.5 |
247 |
|
248 |
macros is the dictionary of platform specific build macros.
|
|
1
by Ricardo Javier Cardenes Medina
Import upstream version 4.1.1 |
249 |
"""
|
1.2.1
by Torsten Marek
Import upstream version 4.10 |
250 |
# Bootstrap. Make sure we get the right one.
|
251 |
sys.path.insert(0, os.path.curdir) |
|
1
by Ricardo Javier Cardenes Medina
Import upstream version 4.1.1 |
252 |
import sipconfig |
3
by Torsten Marek
* The "backport-shmackport" release |
253 |
|
1
by Ricardo Javier Cardenes Medina
Import upstream version 4.1.1 |
254 |
cfg = sipconfig.Configuration() |
255 |
||
1.1.3
by Torsten Marek
Import upstream version 4.4.5 |
256 |
cfg.set_build_macros(macros) |
257 |
||
1
by Ricardo Javier Cardenes Medina
Import upstream version 4.1.1 |
258 |
sipconfig.inform("Creating top level Makefile...") |
259 |
||
260 |
sipconfig.ParentMakefile( |
|
261 |
configuration=cfg, |
|
262 |
subdirs=["sipgen", "siplib"], |
|
1.2.1
by Torsten Marek
Import upstream version 4.10 |
263 |
installs=(["sipconfig.py", os.path.join(src_dir, "sipdistutils.py")], |
264 |
cfg.sip_mod_dir) |
|
1
by Ricardo Javier Cardenes Medina
Import upstream version 4.1.1 |
265 |
).generate() |
266 |
||
267 |
sipconfig.inform("Creating sip code generator Makefile...") |
|
268 |
||
269 |
sipconfig.ProgramMakefile( |
|
270 |
configuration=cfg, |
|
1.2.1
by Torsten Marek
Import upstream version 4.10 |
271 |
build_file=os.path.join(src_dir, "sipgen", "sipgen.sbf"), |
1
by Ricardo Javier Cardenes Medina
Import upstream version 4.1.1 |
272 |
dir="sipgen", |
273 |
install_dir=os.path.dirname(cfg.sip_bin), |
|
274 |
console=1, |
|
1.1.5
by Steve Kowalik
Import upstream version 4.6 |
275 |
warnings=0, |
1.1.16
by Michael Casadevall
Import upstream version 4.9 |
276 |
universal=opts.universal, |
277 |
arch=opts.arch |
|
1
by Ricardo Javier Cardenes Medina
Import upstream version 4.1.1 |
278 |
).generate() |
279 |
||
280 |
sipconfig.inform("Creating sip module Makefile...") |
|
281 |
||
282 |
makefile = sipconfig.ModuleMakefile( |
|
283 |
configuration=cfg, |
|
1.2.1
by Torsten Marek
Import upstream version 4.10 |
284 |
build_file=os.path.join(src_dir, "siplib", "siplib.sbf"), |
1
by Ricardo Javier Cardenes Medina
Import upstream version 4.1.1 |
285 |
dir="siplib", |
286 |
install_dir=cfg.sip_mod_dir, |
|
1.2.1
by Torsten Marek
Import upstream version 4.10 |
287 |
installs=([os.path.join(src_dir, "siplib", "sip.h")], cfg.sip_inc_dir), |
1.1.3
by Torsten Marek
Import upstream version 4.4.5 |
288 |
console=1, |
1
by Ricardo Javier Cardenes Medina
Import upstream version 4.1.1 |
289 |
warnings=0, |
1.1.13
by Jonathan Riddell
Import upstream version 4.8 |
290 |
static=opts.static, |
291 |
debug=opts.debug, |
|
1.1.16
by Michael Casadevall
Import upstream version 4.9 |
292 |
universal=opts.universal, |
293 |
arch=opts.arch |
|
1
by Ricardo Javier Cardenes Medina
Import upstream version 4.1.1 |
294 |
)
|
295 |
||
296 |
makefile.generate() |
|
297 |
||
298 |
||
1.1.13
by Jonathan Riddell
Import upstream version 4.8 |
299 |
def create_optparser(): |
300 |
"""Create the parser for the command line.
|
|
301 |
"""
|
|
302 |
def store_abspath(option, opt_str, value, parser): |
|
303 |
setattr(parser.values, option.dest, os.path.abspath(value)) |
|
304 |
||
305 |
p = optparse.OptionParser(usage="python %prog [opts] [macro=value] " |
|
306 |
"[macro+=value]", version=sip_version_str) |
|
307 |
||
308 |
# Note: we don't use %default to be compatible with Python 2.3.
|
|
309 |
p.add_option("-k", "--static", action="store_true", default=False, |
|
310 |
dest="static", help="build the SIP module as a static library") |
|
311 |
p.add_option("-p", "--platform", action="store", |
|
312 |
default=default_platform, type="string", metavar="PLATFORM", |
|
313 |
dest="platform", help="the platform/compiler configuration " |
|
314 |
"[default: %s]" % default_platform) |
|
315 |
p.add_option("-u", "--debug", action="store_true", default=False, |
|
316 |
help="build with debugging symbols") |
|
317 |
||
1.1.16
by Michael Casadevall
Import upstream version 4.9 |
318 |
if sys.platform == 'darwin': |
319 |
# Get the latest SDK to use as the default.
|
|
320 |
sdks = glob.glob(MACOSX_SDK_DIR + '/MacOSX*.sdk') |
|
321 |
if len(sdks) > 0: |
|
322 |
sdks.sort() |
|
323 |
_, default_sdk = os.path.split(sdks[-1]) |
|
324 |
else: |
|
325 |
default_sdk = 'MacOSX10.4u.sdk' |
|
326 |
||
327 |
g = optparse.OptionGroup(p, title="MacOS X Configuration") |
|
328 |
g.add_option("--arch", action="append", default=[], dest="arch", |
|
329 |
choices=["i386", "x86_64", "ppc"], |
|
330 |
help="build for architecture ARCH") |
|
331 |
g.add_option("-n", "--universal", action="store_true", default=False, |
|
332 |
dest="universal", |
|
333 |
help="build the SIP code generator and module as universal " |
|
334 |
"binaries") |
|
335 |
g.add_option("-s", "--sdk", action="store", default=default_sdk, |
|
336 |
type="string", metavar="SDK", dest="sdk", |
|
337 |
help="the name of the SDK used when building universal " |
|
338 |
"binaries [default: %s]" % default_sdk) |
|
339 |
p.add_option_group(g) |
|
340 |
||
1.1.13
by Jonathan Riddell
Import upstream version 4.8 |
341 |
# Querying.
|
342 |
g = optparse.OptionGroup(p, title="Query") |
|
343 |
g.add_option("--show-platforms", action="store_true", default=False, |
|
344 |
dest="show_platforms", help="show the list of supported " |
|
345 |
"platform/compiler configurations") |
|
346 |
g.add_option("--show-build-macros", action="store_true", default=False, |
|
347 |
dest="show_build_macros", help="show the list of supported build " |
|
348 |
"macros") |
|
349 |
p.add_option_group(g) |
|
350 |
||
351 |
# Installation.
|
|
352 |
g = optparse.OptionGroup(p, title="Installation") |
|
353 |
g.add_option("-b", "--bindir", action="callback", |
|
354 |
default=default_sipbindir, type="string", metavar="DIR", |
|
355 |
dest="sipbindir", callback=store_abspath, help="where the SIP " |
|
356 |
"code generator will be installed [default: %s]" % |
|
357 |
default_sipbindir) |
|
358 |
g.add_option("-d", "--destdir", action="callback", |
|
359 |
default=default_sipmoddir, type="string", metavar="DIR", |
|
360 |
dest="sipmoddir", callback=store_abspath, help="where the SIP " |
|
361 |
"module will be installed [default: %s]" % default_sipmoddir) |
|
362 |
g.add_option("-e", "--incdir", action="callback", |
|
363 |
default=default_sipincdir, type="string", metavar="DIR", |
|
364 |
dest="sipincdir", callback=store_abspath, help="where the SIP " |
|
365 |
"header file will be installed [default: %s]" % default_sipincdir) |
|
366 |
g.add_option("-v", "--sipdir", action="callback", |
|
367 |
default=default_sipsipdir, type="string", metavar="DIR", |
|
368 |
dest="sipsipdir", callback=store_abspath, help="where .sip files " |
|
369 |
"are normally installed [default: %s]" % default_sipsipdir) |
|
370 |
p.add_option_group(g) |
|
371 |
||
372 |
return p |
|
373 |
||
374 |
||
1
by Ricardo Javier Cardenes Medina
Import upstream version 4.1.1 |
375 |
def main(argv): |
376 |
"""Create the configuration module module.
|
|
377 |
||
378 |
argv is the list of command line arguments.
|
|
379 |
"""
|
|
1.1.13
by Jonathan Riddell
Import upstream version 4.8 |
380 |
siputils.inform("This is SIP %s for Python %s on %s." % (sip_version_str, sys.version.split()[0], sys.platform)) |
1.1.3
by Torsten Marek
Import upstream version 4.4.5 |
381 |
|
382 |
if py_version < 0x020300: |
|
383 |
siputils.error("This version of SIP requires Python v2.3 or later.") |
|
384 |
||
1
by Ricardo Javier Cardenes Medina
Import upstream version 4.1.1 |
385 |
# Basic initialisation.
|
386 |
set_platform_directories() |
|
387 |
||
388 |
# Build up the list of valid specs.
|
|
1.2.1
by Torsten Marek
Import upstream version 4.10 |
389 |
for s in os.listdir(os.path.join(src_dir, "specs")): |
1
by Ricardo Javier Cardenes Medina
Import upstream version 4.1.1 |
390 |
platform_specs.append(s) |
391 |
||
1.1.13
by Jonathan Riddell
Import upstream version 4.8 |
392 |
# Parse the command line.
|
393 |
global opts |
|
394 |
||
1
by Ricardo Javier Cardenes Medina
Import upstream version 4.1.1 |
395 |
set_defaults() |
1.1.13
by Jonathan Riddell
Import upstream version 4.8 |
396 |
p = create_optparser() |
397 |
opts, args = p.parse_args() |
|
398 |
||
1.1.16
by Michael Casadevall
Import upstream version 4.9 |
399 |
# Make sure MacOS specific options get initialised.
|
400 |
if sys.platform != 'darwin': |
|
401 |
opts.universal = '' |
|
402 |
opts.arch = [] |
|
403 |
opts.sdk = '' |
|
404 |
||
1.1.13
by Jonathan Riddell
Import upstream version 4.8 |
405 |
# Handle the query options.
|
406 |
if opts.show_platforms or opts.show_build_macros: |
|
407 |
if opts.show_platforms: |
|
408 |
show_platforms() |
|
409 |
||
410 |
if opts.show_build_macros: |
|
411 |
show_macros() |
|
412 |
||
413 |
sys.exit() |
|
414 |
||
1.1.16
by Michael Casadevall
Import upstream version 4.9 |
415 |
# Convert the list 'arch' option to a string. Multiple architectures
|
416 |
# imply a universal binary.
|
|
417 |
if len(opts.arch) > 1: |
|
418 |
opts.universal = True |
|
419 |
||
420 |
opts.arch = ' '.join(opts.arch) |
|
421 |
||
1.1.13
by Jonathan Riddell
Import upstream version 4.8 |
422 |
# Convert the boolean 'universal' option to a string.
|
423 |
if opts.universal: |
|
424 |
if '/' in opts.sdk: |
|
425 |
opts.universal = os.path.abspath(opts.sdk) |
|
1.1.10
by Jonathan Riddell
Import upstream version 4.7.6 |
426 |
else: |
1.1.16
by Michael Casadevall
Import upstream version 4.9 |
427 |
opts.universal = MACOSX_SDK_DIR + '/' + opts.sdk |
1.1.10
by Jonathan Riddell
Import upstream version 4.7.6 |
428 |
|
1.1.13
by Jonathan Riddell
Import upstream version 4.8 |
429 |
if not os.path.isdir(opts.universal): |
1.1.16
by Michael Casadevall
Import upstream version 4.9 |
430 |
siputils.error("Unable to find the SDK directory %s. Use the --sdk flag to specify the name of the SDK or its full path." % opts.universal) |
431 |
||
432 |
if opts.arch == '': |
|
433 |
opts.arch = DEFAULT_MACOSX_ARCH |
|
1.1.13
by Jonathan Riddell
Import upstream version 4.8 |
434 |
else: |
435 |
opts.universal = '' |
|
1.1.10
by Jonathan Riddell
Import upstream version 4.7.6 |
436 |
|
1
by Ricardo Javier Cardenes Medina
Import upstream version 4.1.1 |
437 |
# Get the platform specific macros for building.
|
1.2.1
by Torsten Marek
Import upstream version 4.10 |
438 |
macros = siputils.parse_build_macros( |
439 |
os.path.join(src_dir, "specs", opts.platform), build_macro_names, |
|
440 |
args) |
|
1.1.3
by Torsten Marek
Import upstream version 4.4.5 |
441 |
|
442 |
if macros is None: |
|
1.1.13
by Jonathan Riddell
Import upstream version 4.8 |
443 |
p.print_help() |
444 |
sys.exit(2) |
|
1
by Ricardo Javier Cardenes Medina
Import upstream version 4.1.1 |
445 |
|
446 |
# Tell the user what's been found.
|
|
447 |
inform_user() |
|
448 |
||
449 |
# Install the configuration module.
|
|
1.2.1
by Torsten Marek
Import upstream version 4.10 |
450 |
create_config("sipconfig.py", os.path.join(src_dir, "siputils.py"), |
451 |
macros) |
|
1
by Ricardo Javier Cardenes Medina
Import upstream version 4.1.1 |
452 |
|
453 |
# Create the Makefiles.
|
|
1.1.3
by Torsten Marek
Import upstream version 4.4.5 |
454 |
create_makefiles(macros) |
1
by Ricardo Javier Cardenes Medina
Import upstream version 4.1.1 |
455 |
|
456 |
||
457 |
###############################################################################
|
|
458 |
# The script starts here.
|
|
459 |
###############################################################################
|
|
460 |
||
461 |
if __name__ == "__main__": |
|
462 |
try: |
|
463 |
main(sys.argv) |
|
464 |
except SystemExit: |
|
465 |
raise
|
|
466 |
except: |
|
1.1.13
by Jonathan Riddell
Import upstream version 4.8 |
467 |
sys.stderr.write( |
1
by Ricardo Javier Cardenes Medina
Import upstream version 4.1.1 |
468 |
"""An internal error occured. Please report all the output from the program,
|
1.1.10
by Jonathan Riddell
Import upstream version 4.7.6 |
469 |
including the following traceback, to support@riverbankcomputing.com.
|
1.1.13
by Jonathan Riddell
Import upstream version 4.8 |
470 |
""") |
1
by Ricardo Javier Cardenes Medina
Import upstream version 4.1.1 |
471 |
raise
|