[2.7] bpo-31934: Abort when building out of a not clean source tree (… · python/cpython@fbdd3ee (original) (raw)

Original file line number Diff line number Diff line change
@@ -401,7 +401,16 @@ LIBRARY_OBJS= \
401 401
402 402 # Default target
403 403 all: @DEF_MAKE_ALL_RULE@
404 -build_all: $(BUILDPYTHON) oldsharedmods sharedmods gdbhooks
404 +build_all: check-clean-src $(BUILDPYTHON) oldsharedmods sharedmods gdbhooks
405 +
406 +# Check that the source is clean when building out of source.
407 +check-clean-src:
408 + @if test -n "$(VPATH)" -a -f "$(srcdir)/Modules/python.o"; then \
409 + echo "Error: The source directory ($(srcdir)) is not clean" ; \
410 + echo "Building Python out of the source tree (in (absbuilddir))requiresacleansourcetree((abs_builddir)) requires a clean source tree ((absbuilddir))requiresacleansourcetree((abs_srcdir))" ; \
411 + echo "Try to run: make -C \"$(srcdir)\" clean" ; \
412 + exit 1; \
413 + fi
405 414
406 415 # Compile a binary with profile guided optimization.
407 416 profile-opt:
@@ -928,7 +937,7 @@ altinstall: commoninstall
928 937 ensurepip --root=$(DESTDIR)/ ; \
929 938 fi
930 939
931 -commoninstall: @FRAMEWORKALTINSTALLFIRST@ \
940 +commoninstall: check-clean-src @FRAMEWORKALTINSTALLFIRST@ \
932 941 altbininstall libinstall inclinstall libainstall \
933 942 sharedinstall oldsharedinstall altmaninstall \
934 943 @FRAMEWORKALTINSTALLLAST@
@@ -1472,7 +1481,7 @@ patchcheck:
1472 1481 Python/thread.o: @THREADHEADERS@
1473 1482
1474 1483 # Declare targets that aren't real files
1475 -.PHONY: all build_all sharedmods oldsharedmods test quicktest memtest
1484 +.PHONY: all build_all sharedmods check-clean-src oldsharedmods test quicktest memtest
1476 1485 .PHONY: install altinstall oldsharedinstall bininstall altbininstall
1477 1486 .PHONY: maninstall libinstall inclinstall libainstall sharedinstall
1478 1487 .PHONY: frameworkinstall frameworkinstallframework frameworkinstallstructure