packages/lang/python-sip/patches/100-cross-compile.patch
mb 59cb70ac2c Fixup python-sip and pyqt4 to use the internal host-python.
git-svn-id: svn://svn.openwrt.org/openwrt/packages@23667 3c298f89-4303-0410-b956-a3cf2f4a3e73
2010-10-27 13:38:05 +00:00

213 lines
7.4 KiB
Diff

---
configure.py | 52 ++++++++++++++++++++++++++++++++++++++++++++--------
1 file changed, 44 insertions(+), 8 deletions(-)
Index: sip-4.10.5/configure.py
===================================================================
--- sip-4.10.5.orig/configure.py 2010-07-16 16:15:08.000000000 +0200
+++ sip-4.10.5/configure.py 2010-10-26 16:07:37.000000000 +0200
@@ -19,7 +19,6 @@
import os
import glob
import optparse
-from distutils import sysconfig
import siputils
@@ -193,21 +192,45 @@
global plat_py_site_dir, plat_py_inc_dir, plat_py_conf_inc_dir
global plat_bin_dir, plat_py_lib_dir, plat_sip_dir
- # We trust distutils for some stuff.
- plat_py_site_dir = sysconfig.get_python_lib(plat_specific=1)
- plat_py_inc_dir = sysconfig.get_python_inc()
- plat_py_conf_inc_dir = os.path.dirname(sysconfig.get_config_h_filename())
-
- if sys.platform == "win32":
- plat_py_lib_dir = sys.prefix + "\\libs"
- plat_bin_dir = sys.exec_prefix
- plat_sip_dir = sys.prefix + "\\sip"
- else:
- lib_dir = sysconfig.get_python_lib(plat_specific=1, standard_lib=1)
+ if not opts.crosscompile:
+ # We trust distutils for some stuff.
+ from distutils import sysconfig
+ plat_py_site_dir = sysconfig.get_python_lib(plat_specific=1)
+ plat_py_inc_dir = sysconfig.get_python_inc()
+ plat_py_conf_inc_dir = os.path.dirname(sysconfig.get_config_h_filename())
+
+ if sys.platform == "win32":
+ plat_py_lib_dir = sys.prefix + "\\libs"
+ plat_bin_dir = sys.exec_prefix
+ plat_sip_dir = sys.prefix + "\\sip"
+ else:
+ lib_dir = sysconfig.get_python_lib(plat_specific=1, standard_lib=1)
- plat_py_lib_dir = lib_dir + "/config"
- plat_bin_dir = sys.exec_prefix + "/bin"
- plat_sip_dir = sys.prefix + "/share/sip"
+ plat_py_lib_dir = lib_dir + "/config"
+ plat_bin_dir = sys.exec_prefix + "/bin"
+ plat_sip_dir = sys.prefix + "/share/sip"
+
+ count = 0
+ if opts.py_site_dir:
+ plat_py_site_dir = opts.py_site_dir
+ count += 1
+ if opts.py_inc_dir:
+ plat_py_inc_dir = opts.py_inc_dir
+ count += 1
+ if opts.py_conf_inc_dir:
+ plat_py_conf_inc_dir = opts.py_conf_inc_dir
+ count += 1
+ if opts.py_lib_dir:
+ plat_py_lib_dir = opts.py_lib_dir
+ count += 1
+ if opts.py_bin_dir:
+ plat_py_bin_dir = opts.py_bin_dir
+ count += 1
+ if opts.py_sip_dir:
+ plat_sip_dir = opts.py_sip_dir
+ count += 1
+ if count != 6 and opts.crosscompile:
+ siputils.error("Need to specify all --py-... options for crosscompile.")
def create_config(module, template, macros):
@@ -302,6 +325,11 @@
def store_abspath(option, opt_str, value, parser):
setattr(parser.values, option.dest, os.path.abspath(value))
+ def store_abspath_file(option, opt_str, value, parser):
+ if not os.path.isfile(value):
+ raise optparse.OptionValueError("'%s' is not a file" % value)
+ setattr(parser.values, option.dest, os.path.abspath(value))
+
p = optparse.OptionParser(usage="python %prog [opts] [macro=value] "
"[macro+=value]", version=sip_version_str)
@@ -369,9 +397,62 @@
"are normally installed [default: %s]" % default_sipsipdir)
p.add_option_group(g)
+ # Crosscompilation
+ g = optparse.OptionGroup(p, title="Crosscompilation")
+ g.add_option("--crosscompile", action="store_true",
+ default=False, dest="crosscompile",
+ help="Set, if cross-compiling")
+ g.add_option("--sipconfig-macros", action="callback", metavar="FILE",
+ default=None, dest="sipconfig_macros", type="string",
+ callback=store_abspath_file,
+ help="Path to a file containing sipconfig macros")
+ g.add_option("--py-site-dir", action="callback",
+ default=None, dest="py_site_dir", type="string",
+ callback=store_abspath,
+ help="Python site directory")
+ g.add_option("--py-inc-dir", action="callback",
+ default=None, dest="py_inc_dir", type="string",
+ callback=store_abspath,
+ help="Python include directory")
+ g.add_option("--py-conf-inc-dir", action="callback",
+ default=None, dest="py_conf_inc_dir", type="string",
+ callback=store_abspath,
+ help="Python config include directory")
+ g.add_option("--py-lib-dir", action="callback",
+ default=None, dest="py_lib_dir", type="string",
+ callback=store_abspath,
+ help="Python library directory")
+ g.add_option("--py-bin-dir", action="callback",
+ default=None, dest="py_bin_dir", type="string",
+ callback=store_abspath,
+ help="Python binary directory")
+ g.add_option("--py-sip-dir", action="callback",
+ default=None, dest="py_sip_dir", type="string",
+ callback=store_abspath,
+ help="Python SIP directory")
+ p.add_option_group(g)
+
return p
+def load_sipconfig_macros(filename):
+ macros = {}
+ fd = file(filename, "r")
+ for line in fd.readlines():
+ line = line.split()
+ try:
+ key = line[0]
+ except IndexError:
+ sipconfig.error("Invalid sipconfig macros file format")
+ value = ""
+ try:
+ value = " ".join(line[1:])
+ except IndexError:
+ pass
+ macros[key] = value
+ return macros
+
+
def main(argv):
"""Create the configuration module module.
@@ -382,9 +463,6 @@
if py_version < 0x020300:
siputils.error("This version of SIP requires Python v2.3 or later.")
- # Basic initialisation.
- set_platform_directories()
-
# Build up the list of valid specs.
for s in os.listdir(os.path.join(src_dir, "specs")):
platform_specs.append(s)
@@ -396,6 +474,9 @@
p = create_optparser()
opts, args = p.parse_args()
+ # Basic initialisation.
+ set_platform_directories()
+
# Make sure MacOS specific options get initialised.
if sys.platform != 'darwin':
opts.universal = ''
@@ -434,14 +515,16 @@
else:
opts.universal = ''
- # Get the platform specific macros for building.
- macros = siputils.parse_build_macros(
- os.path.join(src_dir, "specs", opts.platform), build_macro_names,
- args)
-
- if macros is None:
- p.print_help()
- sys.exit(2)
+ if opts.sipconfig_macros:
+ macros = load_sipconfig_macros(opts.sipconfig_macros)
+ else:
+ # Get the platform specific macros for building.
+ macros = siputils.parse_build_macros(
+ os.path.join(src_dir, "specs", opts.platform), build_macro_names,
+ args)
+ if macros is None:
+ p.print_help()
+ sys.exit(2)
# Tell the user what's been found.
inform_user()
Index: sip-4.10.5/siputils.py
===================================================================
--- sip-4.10.5.orig/siputils.py 2010-07-16 16:07:33.000000000 +0200
+++ sip-4.10.5/siputils.py 2010-10-26 16:02:14.000000000 +0200
@@ -1026,9 +1026,11 @@
for f in self.optional_list("DEFINES"):
cppflags.append("-D" + f)
+ print "CPPFLAGS: Adding -D", f
for f in self.optional_list("INCDIR"):
cppflags.append("-I" + _quote(f))
+ print "CPPFLAGS: Adding -I", _quote(f)
libs = []