diff --git a/Makefile.pre.in b/Makefile.pre.in
index bcd83bf..5e54a0d 100644
--- a/Makefile.pre.in
+++ b/Makefile.pre.in
@@ -461,6 +463,7 @@ sharedmods: $(BUILDPYTHON) pybuilddir.txt
 	esac; \
 	$(RUNSHARED) CC='$(CC)' LDSHARED='$(BLDSHARED)' OPT='$(OPT)' \
 		_TCLTK_INCLUDES='$(TCLTK_INCLUDES)' _TCLTK_LIBS='$(TCLTK_LIBS)' \
+		PYTHONXCPREFIX='$(DESTDIR)$(prefix)' \
 		$(PYTHON_FOR_BUILD) $(srcdir)/setup.py $$quiet build
 
 # Build static library
@@ -1142,7 +1145,9 @@ libainstall:	all python-config
 # Install the dynamically loadable modules
 # This goes into $(exec_prefix)
 sharedinstall: sharedmods
+	CC='$(CC)' LDSHARED='$(BLDSHARED)' OPT='$(OPT)' \
 	$(RUNSHARED) $(PYTHON_FOR_BUILD) $(srcdir)/setup.py install \
+		--skip-build \
 	   	--prefix=$(prefix) \
 		--install-scripts=$(BINDIR) \
 		--install-platlib=$(DESTSHARED) \
diff --git a/setup.py b/setup.py
index a46bf35..528e9df 100644
--- a/setup.py
+++ b/setup.py
@@ -17,7 +17,7 @@
 from distutils.command.install_lib import install_lib
 from distutils.spawn import find_executable

-cross_compiling = "_PYTHON_HOST_PLATFORM" in os.environ
+cross_compiling = ("_PYTHON_HOST_PLATFORM" in os.environ) or ('PYTHONXCPREFIX' in os.environ)

 def get_platform():
     # cross build
@@ -292,6 +292,14 @@ class PyBuildExt(build_ext):
                           (ext.name, sys.exc_info()[1]))
             self.failed.append(ext.name)
             return
+
+        # Inport check will not work when cross-compiling.
+        if os.environ.has_key('PYTHONXCPREFIX'):
+            self.announce(
+                'WARNING: skipping inport check for cross-compiled: "%s"' %
+                ext.name)
+            return
+
         # Workaround for Mac OS X: The Carbon-based modules cannot be
         # reliably imported into a command-line Python
         if 'Carbon' in ext.extra_link_args:
