Issue #15819: additional fixes for out-of-tree builds from read-only src.

Specifically, make sure the 'Object', 'Python' and 'Include' directories
in the build directory take precedence over the source directory if we're
an out-of-tree build.

Fix typeslots.inc so that it gets generated into the build directory.
diff --git a/configure b/configure
index f9a6261..8ba3dec 100755
--- a/configure
+++ b/configure
@@ -651,6 +651,8 @@
 HGBRANCH
 HGTAG
 HGVERSION
+BASECPPFLAGS
+BUILDDIR
 SVNVERSION
 ARFLAGS
 AR
@@ -5205,6 +5207,24 @@
 	SVNVERSION="echo Unversioned directory"
 fi
 
+BUILDDIR="`pwd`"
+
+
+if test "$srcdir" != "$BUILDDIR"; then
+    # If we're building out-of-tree, we need to make sure the following
+    # resources get picked up before their $srcdir counterparts.
+    #   Objects/ -> typeslots.inc
+    #   Include/ -> Python-ast.h, graminit.h
+    #   Python/  -> importlib.h
+    # (A side effect of this is that these resources will automatically be
+    #  regenerated when building out-of-tree, regardless of whether or not
+    #  the $srcdir counterpart is up-to-date.  This is an acceptable trade
+    #  off.)
+    BASECPPFLAGS="-IObjects -IInclude -IPython"
+else
+    BASECPPFLAGS=""
+fi
+