[Python-checkins] [2.7] bpo-31934: Abort when building out of a not clean source tree (GH-4255). (#4342)

xdegaye webhook-mailer at python.org
Wed Nov 8 11:10:20 EST 2017


https://github.com/python/cpython/commit/fbdd3eeba3e526e162f2eb54d224cf36ed8cfea1
commit: fbdd3eeba3e526e162f2eb54d224cf36ed8cfea1
branch: 2.7
author: xdegaye <xdegaye at gmail.com>
committer: GitHub <noreply at github.com>
date: 2017-11-08T17:10:16+01:00
summary:

[2.7] bpo-31934: Abort when building out of a not clean source tree (GH-4255). (#4342)

(cherry picked from commit 0de92859caf25e65fc968d4bb68626e9ba21b851)

files:
A Misc/NEWS.d/next/Build/2017-11-03-15-17-50.bpo-31934.8bUlpv.rst
M Makefile.pre.in

diff --git a/Makefile.pre.in b/Makefile.pre.in
index 16afd9cebe4..19e8f55b2ab 100644
--- a/Makefile.pre.in
+++ b/Makefile.pre.in
@@ -401,7 +401,16 @@ LIBRARY_OBJS=	\
 
 # Default target
 all:		@DEF_MAKE_ALL_RULE@
-build_all:	$(BUILDPYTHON) oldsharedmods sharedmods gdbhooks
+build_all:	check-clean-src $(BUILDPYTHON) oldsharedmods sharedmods gdbhooks
+
+# Check that the source is clean when building out of source.
+check-clean-src:
+	@if test -n "$(VPATH)" -a -f "$(srcdir)/Modules/python.o"; then \
+		echo "Error: The source directory ($(srcdir)) is not clean" ; \
+		echo "Building Python out of the source tree (in $(abs_builddir)) requires a clean source tree ($(abs_srcdir))" ; \
+		echo "Try to run: make -C \"$(srcdir)\" clean" ; \
+		exit 1; \
+	fi
 
 # Compile a binary with profile guided optimization.
 profile-opt:
@@ -928,7 +937,7 @@ altinstall:	commoninstall
 			$$ensurepip --root=$(DESTDIR)/ ; \
 	fi
 
-commoninstall:	@FRAMEWORKALTINSTALLFIRST@ \
+commoninstall:	check-clean-src @FRAMEWORKALTINSTALLFIRST@ \
 		altbininstall libinstall inclinstall libainstall \
 		sharedinstall oldsharedinstall altmaninstall \
 		@FRAMEWORKALTINSTALLLAST@
@@ -1472,7 +1481,7 @@ patchcheck:
 Python/thread.o: @THREADHEADERS@
 
 # Declare targets that aren't real files
-.PHONY: all build_all sharedmods oldsharedmods test quicktest memtest
+.PHONY: all build_all sharedmods check-clean-src oldsharedmods test quicktest memtest
 .PHONY: install altinstall oldsharedinstall bininstall altbininstall
 .PHONY: maninstall libinstall inclinstall libainstall sharedinstall
 .PHONY: frameworkinstall frameworkinstallframework frameworkinstallstructure
diff --git a/Misc/NEWS.d/next/Build/2017-11-03-15-17-50.bpo-31934.8bUlpv.rst b/Misc/NEWS.d/next/Build/2017-11-03-15-17-50.bpo-31934.8bUlpv.rst
new file mode 100644
index 00000000000..deaa74046e9
--- /dev/null
+++ b/Misc/NEWS.d/next/Build/2017-11-03-15-17-50.bpo-31934.8bUlpv.rst
@@ -0,0 +1 @@
+Abort the build when building out of a not clean source tree.



More information about the Python-checkins mailing list