Commits

Trent Nelson committed 617591e

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.

Comments (0)

Files changed (3)

 VERSION=	@VERSION@
 srcdir=		@srcdir@
 VPATH=		@srcdir@
+BUILDDIR=	@BUILDDIR@
+
 
 CC=		@CC@
 CXX=		@CXX@
 # Compiler options
 OPT=		@OPT@
 BASECFLAGS=	@BASECFLAGS@
+BASECPPFLAGS=	@BASECPPFLAGS@
 CONFIGURE_CFLAGS=	@CFLAGS@
 CONFIGURE_CPPFLAGS=	@CPPFLAGS@
 CONFIGURE_LDFLAGS=	@LDFLAGS@
 # Both CPPFLAGS and LDFLAGS need to contain the shell's value for setup.py to
 # be able to build extension modules using the directories specified in the
 # environment variables
-PY_CPPFLAGS=	-I. -IInclude -I$(srcdir)/Include $(CONFIGURE_CPPFLAGS) $(CPPFLAGS)
+PY_CPPFLAGS=	$(BASECPPFLAGS) -I. -IInclude -I$(srcdir)/Include $(CONFIGURE_CPPFLAGS) $(CPPFLAGS)
 PY_LDFLAGS=	$(CONFIGURE_LDFLAGS) $(LDFLAGS)
 NO_AS_NEEDED=	@NO_AS_NEEDED@
 LDLAST=		@LDLAST@
 # Python
 
 OPCODETARGETS_H= \
-		$(srcdir)/Python/opcode_targets.h
+		Python/opcode_targets.h
 
 OPCODETARGETGEN= \
 		$(srcdir)/Python/makeopcodetargets.py
 				$(BYTESTR_DEPS) \
 				$(srcdir)/Objects/stringlib/formatter.h
 
-Objects/typeobject.o: $(srcdir)/Objects/typeslots.inc
-$(srcdir)/Objects/typeslots.inc: $(srcdir)/Include/typeslots.h $(srcdir)/Objects/typeslots.py
-	$(PYTHON) $(srcdir)/Objects/typeslots.py < $(srcdir)/Include/typeslots.h > $(srcdir)/Objects/typeslots.inc
+Objects/typeobject.o: Objects/typeslots.inc
+Objects/typeslots.inc: $(srcdir)/Include/typeslots.h $(srcdir)/Objects/typeslots.py
+	$(PYTHON) $(srcdir)/Objects/typeslots.py < $(srcdir)/Include/typeslots.h > Objects/typeslots.inc
 
 ############################################################################
 # Header files
 HGBRANCH
 HGTAG
 HGVERSION
+BASECPPFLAGS
+BUILDDIR
 SVNVERSION
 ARFLAGS
 AR
 	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
+
 
 
 
 	SVNVERSION="echo Unversioned directory"
 fi
 
+BUILDDIR="`pwd`"
+AC_SUBST(BUILDDIR)
+AC_SUBST(BASECPPFLAGS)
+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
+
 AC_SUBST(HGVERSION)
 AC_SUBST(HGTAG)
 AC_SUBST(HGBRANCH)