Fixup python-sip and pyqt4 to use the internal host-python.
authorMichael Büsch <mb@bu3sch.de>
Wed, 27 Oct 2010 13:38:05 +0000 (13:38 +0000)
committerMichael Büsch <mb@bu3sch.de>
Wed, 27 Oct 2010 13:38:05 +0000 (13:38 +0000)
SVN-Revision: 23667

lang/pyqt4/Makefile
lang/pyqt4/patches/100-cross-compile.patch
lang/python-sip/Makefile
lang/python-sip/patches/100-cross-compile.patch

index d279b3d89911695f455c39fa138705601116c754..f05dc0f73fc048564c8a635fae4ee3abac675978 100644 (file)
@@ -31,7 +31,7 @@ define Package/pyqt4
   TITLE:=Python QT4
   MAINTAINER:=Michael Buesch <mb@bu3sch.de>
   URL:=http://www.riverbankcomputing.co.uk/software/pyqt/download
-  DEPENDS:=+qt4 +dbus-python +python-sip @FEATURE_drawing-backend_libX11
+  DEPENDS:=+qt4 +dbus-python +python +python-sip @FEATURE_drawing-backend_libX11
 endef
 
 define Package/pyqt4/Description
@@ -73,35 +73,35 @@ QT_EDITION:=./files/qt_versioning.sh edition "$(STAGING_DIR)/usr/include" "$(PKG
 # Welcome to cross compilation hell. Dinner is served!
 
 define Build/Configure
-       echo "$(STAGING_DIR)/usr" > $(QTDIRSFILE); \
-       echo "$(STAGING_DIR)/usr/include" >> $(QTDIRSFILE); \
-       echo "$(STAGING_DIR)/usr/lib" >> $(QTDIRSFILE); \
-       echo "$(STAGING_DIR)/usr/bin" >> $(QTDIRSFILE); \
-       echo "$(STAGING_DIR)/usr/share" >> $(QTDIRSFILE); \
-       echo "$(STAGING_DIR)/usr/lib/Qt/plugins" >> $(QTDIRSFILE); \
-       $(QT_VERSION) >> $(QTDIRSFILE); \
-       $(QT_EDITION) >> $(QTDIRSFILE); \
-       echo "Open Source" >> $(QTDIRSFILE); \
-       echo "shared" >> $(QTDIRSFILE); \
-       \
-       $(CP) "$(PYTHON_SIP_CONFIG_TEMPLATE)" "$(SIPCFGFILE)"; \
-       echo "INCDIR_QT                 $(STAGING_DIR)/usr/include" >> $(SIPCFGFILE); \
-       echo "LIBDIR_QT                 $(STAGING_DIR)/usr/lib" >> $(SIPCFGFILE); \
-       echo "MOC                       $(STAGING_DIR_HOST)/bin/moc" >> $(SIPCFGFILE); \
-       echo "QT_INSTALL_BINS           $(STAGING_DIR)/usr/bin" >> $(SIPCFGFILE); \
-       echo "QT_INSTALL_HEADERS        $(STAGING_DIR)/usr/include" >> $(SIPCFGFILE); \
-       echo "QT_INSTALL_LIBS           $(STAGING_DIR)/usr/lib" >> $(SIPCFGFILE); \
-       echo "INCDIR                    $(TARGET_INCDIRS)" >> $(SIPCFGFILE); \
-       echo "INCDIR_OPENGL             $(TARGET_INCDIRS)" >> $(SIPCFGFILE); \
-       echo "INCDIR_X11                $(TARGET_INCDIRS)" >> $(SIPCFGFILE); \
-       echo "LIBDIR                    $(TARGET_LIBDIRS)" >> $(SIPCFGFILE); \
-       echo "LIBDIR_OPENGL             $(TARGET_LIBDIRS)" >> $(SIPCFGFILE); \
-       echo "LIBDIR_X11                $(TARGET_LIBDIRS)" >> $(SIPCFGFILE); \
-       ( \
+       echo "$(STAGING_DIR)/usr" > $(QTDIRSFILE)
+       echo "$(STAGING_DIR)/usr/include" >> $(QTDIRSFILE)
+       echo "$(STAGING_DIR)/usr/lib" >> $(QTDIRSFILE)
+       echo "$(STAGING_DIR)/usr/bin" >> $(QTDIRSFILE)
+       echo "$(STAGING_DIR)/usr/share" >> $(QTDIRSFILE)
+       echo "$(STAGING_DIR)/usr/lib/Qt/plugins" >> $(QTDIRSFILE)
+       $(QT_VERSION) >> $(QTDIRSFILE)
+       $(QT_EDITION) >> $(QTDIRSFILE)
+       echo "Open Source" >> $(QTDIRSFILE)
+       echo "shared" >> $(QTDIRSFILE)
+
+       $(CP) "$(PYTHON_SIP_CONFIG_TEMPLATE)" "$(SIPCFGFILE)"
+       echo "INCDIR_QT                 $(STAGING_DIR)/usr/include" >> $(SIPCFGFILE)
+       echo "LIBDIR_QT                 $(STAGING_DIR)/usr/lib" >> $(SIPCFGFILE)
+       echo "MOC                       $(STAGING_DIR_HOST)/bin/moc" >> $(SIPCFGFILE)
+       echo "QT_INSTALL_BINS           $(STAGING_DIR)/usr/bin" >> $(SIPCFGFILE)
+       echo "QT_INSTALL_HEADERS        $(STAGING_DIR)/usr/include" >> $(SIPCFGFILE)
+       echo "QT_INSTALL_LIBS           $(STAGING_DIR)/usr/lib" >> $(SIPCFGFILE)
+       echo "INCDIR                    $(TARGET_INCDIRS)" >> $(SIPCFGFILE)
+       echo "INCDIR_OPENGL             $(TARGET_INCDIRS)" >> $(SIPCFGFILE)
+       echo "INCDIR_X11                $(TARGET_INCDIRS)" >> $(SIPCFGFILE)
+       echo "LIBDIR                    $(TARGET_LIBDIRS)" >> $(SIPCFGFILE)
+       echo "LIBDIR_OPENGL             $(TARGET_LIBDIRS)" >> $(SIPCFGFILE)
+       echo "LIBDIR_X11                $(TARGET_LIBDIRS)" >> $(SIPCFGFILE)
+
+       $(call HostPython, \
                cd "$(PKG_BUILD_DIR)"; \
-               export PYTHONPATH="$(STAGING_DIR_HOST)/$(PYTHON_PKG_DIR)"; \
-               export PYTHONDONTWRITEBYTECODE=1; \
-               python ./configure.py \
+               , \
+               ./configure.py \
                        --use-arch="$(ARCH)" \
                        --qmake="$(STAGING_DIR_HOST)/bin/qmake" \
                        --qmake-spec="$(STAGING_DIR)/usr/share/mkspecs/linux-openwrt-g++" \
@@ -117,6 +117,7 @@ define Build/Configure
                        --qmake-prefix='TARGET_LIBDIRS="$(TARGET_LIBDIRS)"' \
                        --qmake-prefix='STAGING_DIR_HOST="$(STAGING_DIR)/../host"' \
                        --qtdirs-file="$(QTDIRSFILE)" \
+                       --host-sip-bin="$(STAGING_DIR_HOST)/usr/bin/sip" \
                        --sipconfig-macros="$(SIPCFGFILE)" \
                        --dbus="$(STAGING_DIR)/usr/include/dbus-1.0" \
                        --bindir="$(PKG_INSTALL_DIR)/usr/bin" \
@@ -130,13 +131,10 @@ define Build/Configure
                        --no-qsci-api \
                        --confirm-license \
                        --verbose \
-       ); \
+       )
        ./files/fixup.sh "$(PKG_BUILD_DIR)"
 endef
 
-#FIXME: Something still puts the host Python include path into the CFLAGS.
-#       I'm currently unsure who does this. Most likely SIP. arghh..
-
 define Build/Compile
        $(MAKE_VARS) $(MAKE) $(PKG_JOBS) -C $(PKG_BUILD_DIR)
 endef
@@ -153,8 +151,4 @@ define Package/pyqt4/install
        $(CP) $(PKG_INSTALL_DIR)/$(PYTHON_PKG_DIR)/PyQt4 $(1)/$(PYTHON_PKG_DIR)
 endef
 
-$(eval $(call RequireCommand,python, \
-       Please install Python 2.x \
-))
-
 $(eval $(call BuildPackage,pyqt4))
index 2eb458034ba2a628d18f2f7c79111730d977d5e8..afe018a4278bf96154919b26d8c2d39fff822fcb 100644 (file)
@@ -2,9 +2,11 @@
  configure.py |  218 ++++++++++++++++++++++++++++++++++++++++-------------------
  1 file changed, 149 insertions(+), 69 deletions(-)
 
---- PyQt-x11-gpl-4.7.4.orig/configure.py
-+++ PyQt-x11-gpl-4.7.4/configure.py
-@@ -33,6 +33,7 @@ import os
+Index: PyQt-x11-gpl-4.7.4/configure.py
+===================================================================
+--- PyQt-x11-gpl-4.7.4.orig/configure.py       2010-07-12 12:41:15.000000000 +0200
++++ PyQt-x11-gpl-4.7.4/configure.py    2010-10-27 12:30:01.000000000 +0200
+@@ -33,6 +33,7 @@
  import glob
  import optparse
  import shutil
@@ -12,7 +14,7 @@
  
  import sipconfig
  
-@@ -173,25 +174,17 @@ def create_optparser():
+@@ -173,25 +174,17 @@
              metavar="PLUGIN", dest="staticplugins", help="add PLUGIN to the "
              "list be linked (if Qt is built as static libraries)")
  
@@ -49,7 +51,7 @@
  
      g.add_option("-s", "--dbus", action="callback", metavar="DIR",
              dest="pydbusincdir", callback=store_abspath_dir, type="string",
-@@ -199,13 +192,13 @@ def create_optparser():
+@@ -199,13 +192,13 @@
              "[default: supplied by pkg-config]")
      p.add_option_group(g)
  
@@ -70,7 +72,7 @@
  
      # Installation.
      g = optparse.OptionGroup(p, title="Installation")
-@@ -264,12 +257,38 @@ def create_optparser():
+@@ -264,12 +257,42 @@
              "QTDIR/qsci]")
      p.add_option_group(g)
  
 +    g.add_option("--crosscompile", action="store_true",
 +                 default=False, dest="crosscompile",
 +                 help="Set, if cross-compiling")
++    g.add_option("--host-sip-bin", action="callback", metavar="FILE",
++                 default=None, dest="host_sip_bin", type="string",
++                 callback=store_abspath_file,
++                 help="Path to the host SIP binary")
 +    g.add_option("--sipconfig-macros", action="callback", metavar="FILE",
 +                 default=None, dest="sipconfig_macros", type="string",
 +                 callback=store_abspath_file,
      """
  
      def __init__(self):
-@@ -282,6 +301,8 @@ class pyrccMakefile(sipconfig.ProgramMak
+@@ -282,6 +305,8 @@
      def generate_target_default(self, mfile):
          """Generate the default target."""
          sipconfig.ProgramMakefile.generate_target_default(self, mfile)
  
          # The correct call to pyrcc depends on the Python version.
          if sys.hexversion >= 0x03000000:
-@@ -772,7 +793,7 @@ include(%s)
+@@ -772,7 +797,7 @@
  
              f.close()
  
              os.chdir(cwd)
  
          sipconfig.inform("Creating QPy support libraries Makefile...")
-@@ -825,12 +846,16 @@ include(%s)
+@@ -825,12 +850,16 @@
          # not on Windows (so that normal console use will work).
          sipconfig.inform("Creating pyuic4 wrapper...")
  
  
          uicdir=os.path.join(pyqt_modroot, "uic")
          wrapper = sipconfig.create_wrapper(os.path.join(uicdir, "pyuic.py"), os.path.join("pyuic", "pyuic4"), gui, use_arch)
-@@ -880,6 +905,7 @@ include(%s)
+@@ -880,6 +909,7 @@
              py_major = sipcfg.py_version >> 16
              py_minor = (sipcfg.py_version >> 8) & 0x0ff
  
              if sys.platform == 'win32':
                  lib_dir_flag = quote("-L%s" % sipcfg.py_lib_dir)
                  link = "%s -lpython%d%d" % (lib_dir_flag, py_major, py_minor)
-@@ -938,7 +964,7 @@ include(%s)
+@@ -938,7 +968,7 @@
                  fout.write(prj)
                  fout.close()
  
                  os.chdir(cwd)
  
                  tool.append("designer")
-@@ -1056,6 +1082,14 @@ def create_config(module, template, macr
+@@ -1056,6 +1086,14 @@
      sipconfig.create_config_module(module, template, content, macros)
  
  
  def run_command(cmd):
      """Run a command and display the output if verbose mode is enabled.
  
-@@ -1272,30 +1306,38 @@ def check_dbus():
+@@ -1272,30 +1310,38 @@
      """
      sipconfig.inform("Checking to see if the dbus support module should be built...")
  
  
      # Try and find dbus-python.h.  We don't use pkg-config because it is broken
      # for dbus-python (at least for versions up to and including v0.81.0).
-@@ -1381,6 +1423,7 @@ def set_sip_flags(pyqt):
+@@ -1381,6 +1427,7 @@
  
      pyqt is the configuration instance.
      """
      # If we don't check for signed interpreters, we exclude the 'VendorID'
      # feature
      if not opts.vendorcheck:
-@@ -1779,6 +1822,8 @@ def check_qt_installation(macros):
+@@ -1525,7 +1572,10 @@
+             needed_qt_libs(mname, qt_libs)
+     # Build the SIP command line.  Keyword argument support is enabled.
+-    argv = ['"' + sipcfg.sip_bin + '"', '-k']
++    sip_bin = sipcfg.sip_bin
++    if opts.host_sip_bin:
++        sip_bin = opts.host_sip_bin
++    argv = ['"' + sip_bin + '"', '-k']
+     if not opts.no_docstrings:
+         argv.append("-o");
+@@ -1779,6 +1829,8 @@
  def fix_qmake_args(args=""):
      """Make any platform specific adjustments to the arguments passed to qmake.
      """
      if sys.platform == "darwin":
          # The Qt binary installer has macx-xcode as the default.
          args = "-spec %s %s" % (sipcfg.platform, args)
-@@ -1930,7 +1975,7 @@ int main(int, char **)
+@@ -1930,7 +1982,7 @@
  
      # Create the makefile, first making sure it doesn't already exist.
      remove_file(make_file)
  
      if not os.access(make_file, os.F_OK):
          sipconfig.error("%s failed to create a makefile. %s" % (opts.qmake, MSG_CHECK_QMAKE))
-@@ -1952,15 +1997,30 @@ int main(int, char **)
+@@ -1952,15 +2004,30 @@
      if not os.access(exe_file, os.X_OK):
          sipconfig.error("Failed to determine the layout of your Qt installation. Try again using the --verbose flag to see more detail about the problem.")
  
      lines = f.read().strip().split("\n")
      f.close()
  
-@@ -2022,6 +2082,24 @@ int main(int, char **)
+@@ -2022,6 +2089,24 @@
              sipconfig.error("Qt has been built as static libraries so either the -g or -k argument should be used.")
  
  
  def main():
      """Create the configuration module module.
      """
-@@ -2036,7 +2114,7 @@ def main():
+@@ -2036,7 +2121,7 @@
      opts, args = p.parse_args()
  
      # Provide defaults for platform-specific options.
          opts.qmake = find_default_qmake()
          opts.prot_is_public = False
  
-@@ -2069,12 +2147,14 @@ def main():
+@@ -2069,12 +2154,14 @@
              # Install the API file if the default directory exists.
              opts.api = os.path.isdir(opts.qscidir)
  
index 1bc37d4b6c5faacb7e9bd9adc4bead46522ce14f..17b33c3889881440490ab58603d5b0080848fd2e 100644 (file)
@@ -20,6 +20,9 @@ HOST_BUILD_PARALLEL:=1
 HOST_BUILD_DIR:=$(BUILD_DIR_HOST)/sip-$(PKG_VERSION)
 PKG_BUILD_DIR:=$(BUILD_DIR)/sip-$(PKG_VERSION)
 
+PKG_BUILD_DEPENDS:=python
+HOST_BUILD_DEPENDS:=python
+
 include $(INCLUDE_DIR)/host-build.mk
 include $(INCLUDE_DIR)/package.mk
 $(call include_mk, python-package.mk)
@@ -41,25 +44,33 @@ EXTRA_CFLAGS:=\
        $(FPIC)
 
 define Build/Configure
-       $(INSTALL_DIR) "$(PYTHON_SIP_CONFIG_TEMPLATE_DIR)"; \
-       $(CP) ./files/sipconfig.macros.template "$(PYTHON_SIP_CONFIG_TEMPLATE)"; \
-       echo "CC                        $(TARGET_CROSS)gcc" >> $(PYTHON_SIP_CONFIG_TEMPLATE); \
-       echo "CFLAGS                    $(TARGET_CFLAGS) $(EXTRA_CFLAGS)" >> $(PYTHON_SIP_CONFIG_TEMPLATE); \
-       echo "CXX                       $(TARGET_CROSS)g++" >> $(PYTHON_SIP_CONFIG_TEMPLATE); \
-       echo "CXXFLAGS                  $(TARGET_CFLAGS) $(EXTRA_CFLAGS)" >> $(PYTHON_SIP_CONFIG_TEMPLATE); \
-       echo "LINK                      $(TARGET_CROSS)g++" >> $(PYTHON_SIP_CONFIG_TEMPLATE); \
-       echo "LINK_SHLIB                $(TARGET_CROSS)g++" >> $(PYTHON_SIP_CONFIG_TEMPLATE); \
-       echo "LFLAGS                    $(TARGET_LDFLAGS) $(EXTRA_LDFLAGS)" >> $(PYTHON_SIP_CONFIG_TEMPLATE); \
-       echo "AR                        $(TARGET_CROSS)ar cqs" >> $(PYTHON_SIP_CONFIG_TEMPLATE); \
-       echo "STRIP                     $(STRIP)" >> $(PYTHON_SIP_CONFIG_TEMPLATE); \
-       (       cd "$(PKG_BUILD_DIR)"; \
-               export PYTHONDONTWRITEBYTECODE=1; \
-               python -E ./configure.py \
+       $(INSTALL_DIR) "$(PYTHON_SIP_CONFIG_TEMPLATE_DIR)"
+       $(CP) ./files/sipconfig.macros.template "$(PYTHON_SIP_CONFIG_TEMPLATE)"
+       echo "CC                        $(TARGET_CROSS)gcc" >> $(PYTHON_SIP_CONFIG_TEMPLATE)
+       echo "CFLAGS                    $(TARGET_CFLAGS) $(EXTRA_CFLAGS)" >> $(PYTHON_SIP_CONFIG_TEMPLATE)
+       echo "CXX                       $(TARGET_CROSS)g++" >> $(PYTHON_SIP_CONFIG_TEMPLATE)
+       echo "CXXFLAGS                  $(TARGET_CFLAGS) $(EXTRA_CFLAGS)" >> $(PYTHON_SIP_CONFIG_TEMPLATE)
+       echo "LINK                      $(TARGET_CROSS)g++" >> $(PYTHON_SIP_CONFIG_TEMPLATE)
+       echo "LINK_SHLIB                $(TARGET_CROSS)g++" >> $(PYTHON_SIP_CONFIG_TEMPLATE)
+       echo "LFLAGS                    $(TARGET_LDFLAGS) $(EXTRA_LDFLAGS)" >> $(PYTHON_SIP_CONFIG_TEMPLATE)
+       echo "AR                        $(TARGET_CROSS)ar cqs" >> $(PYTHON_SIP_CONFIG_TEMPLATE)
+       echo "STRIP                     $(STRIP)" >> $(PYTHON_SIP_CONFIG_TEMPLATE)
+       $(call HostPython, \
+               cd "$(PKG_BUILD_DIR)"; \
+               , \
+               ./configure.py \
+                       --crosscompile \
                        --bindir=$(PKG_INSTALL_DIR)/usr/bin \
                        --destdir=$(PKG_INSTALL_DIR)/$(PYTHON_PKG_DIR) \
                        --incdir=$(PKG_INSTALL_DIR)/usr/include \
                        --sipdir=$(PKG_INSTALL_DIR)/usr/share/sip \
                        --sipconfig-macros="$(PYTHON_SIP_CONFIG_TEMPLATE)" \
+                       --py-site-dir=$(STAGING_DIR)/$(PYTHON_PKG_DIR) \
+                       --py-inc-dir=$(PYTHON_INC_DIR) \
+                       --py-conf-inc-dir=$(PKG_BUILD_DIR) \
+                       --py-lib-dir=$(PYTHON_LIB_DIR) \
+                       --py-bin-dir=$(PYTHON_BIN_DIR) \
+                       --py-sip-dir=$(STAGING_DIR)/usr/share/sip \
        )
 endef
 
@@ -73,8 +84,9 @@ define Build/Compile
 endef
 
 define Build/InstallDev
-       $(INSTALL_DIR) $(1)/mk
+       $(INSTALL_DIR) $(1)/mk $(1)/$(PYTHON_PKG_DIR)
        $(INSTALL_DATA) ./files/python-sip-package.mk $(1)/mk/
+       $(CP) $(PKG_INSTALL_DIR)/$(PYTHON_PKG_DIR)/* $(1)/$(PYTHON_PKG_DIR)
 endef
 
 define Build/Install
@@ -97,10 +109,15 @@ endef
 
 # ===> HOST <===
 
+HOST_CFLAGS+= \
+       $(HOST_FPIC) \
+       -I$(STAGING_DIR_HOST)/include/python$(PYTHON_VERSION)
+
 define Host/Configure
-       (       cd "$(HOST_BUILD_DIR)"; \
-               export PYTHONDONTWRITEBYTECODE=1; \
-               python -E ./configure.py \
+       $(call HostPython, \
+               cd "$(HOST_BUILD_DIR)"; \
+               , \
+               ./configure.py \
                        --bindir=$(STAGING_DIR_HOST)/usr/bin \
                        --destdir=$(STAGING_DIR_HOST)/$(PYTHON_PKG_DIR) \
                        --incdir=$(STAGING_DIR_HOST)/usr/include \
@@ -108,8 +125,6 @@ define Host/Configure
        )
 endef
 
-HOST_CFLAGS+=$(HOST_FPIC)
-
 define Host/Compile
        $(MAKE) $(HOST_JOBS) -C $(HOST_BUILD_DIR) \
                CC="$(HOSTCC)" \
@@ -129,20 +144,5 @@ define Host/Install
                install
 endef
 
-define Require/python2-dev
-  [ -e /usr/include/Python.h ] || \
-  [ -e /usr/include/python/Python.h ] || \
-  [ -e /usr/include/python2.5/Python.h ] || \
-  [ -e /usr/include/python2.6/Python.h ]
-endef
-
-#$(eval $(call Require,python2-dev, \
-#      Please install Python 2.x headers (python-dev) \
-#))
-
-$(eval $(call RequireCommand,python, \
-       Please install Python 2.x \
-))
-
 $(eval $(call HostBuild))
 $(eval $(call BuildPackage,python-sip))
index c09cadd032c809fd0266ef8359365d053b522a51..0380bd7f56be0a8cfe05199d871e33e3ac7b8877 100644 (file)
@@ -2,9 +2,79 @@
  configure.py |   52 ++++++++++++++++++++++++++++++++++++++++++++--------
  1 file changed, 44 insertions(+), 8 deletions(-)
 
---- sip-4.10.5.orig/configure.py
-+++ sip-4.10.5/configure.py
-@@ -302,6 +302,11 @@ def create_optparser():
+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))
  
@@ -16,7 +86,7 @@
      p = optparse.OptionParser(usage="python %prog [opts] [macro=value] "
              "[macro+=value]", version=sip_version_str)
  
-@@ -369,9 +374,38 @@ def create_optparser():
+@@ -369,9 +397,62 @@
              "are normally installed [default: %s]" % default_sipsipdir)
      p.add_option_group(g)
  
 +                 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 main(argv):
      """Create the configuration module module.
  
-@@ -434,14 +468,16 @@ def main(argv):
+@@ -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 = ''
  
  
      # 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 = []