@@ -401,7 +401,16 @@ LIBRARY_OBJS= \
401401
402402# Default target
403403all: @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 $(abs_builddir)) requires a clean source tree ($(abs_srcdir))" ; \
411+ echo "Try to run: make -C \"$(srcdir)\" clean" ; \
412+ exit 1; \
413+ fi
405414
406415# Compile a binary with profile guided optimization.
407416profile-opt:
@@ -928,7 +937,7 @@ altinstall: commoninstall
928937 $$ensurepip --root=$(DESTDIR)/ ; \
929938 fi
930939
931- commoninstall: @FRAMEWORKALTINSTALLFIRST@ \
940+ commoninstall: check-clean-src @FRAMEWORKALTINSTALLFIRST@ \
932941 altbininstall libinstall inclinstall libainstall \
933942 sharedinstall oldsharedinstall altmaninstall \
934943 @FRAMEWORKALTINSTALLLAST@
@@ -1472,7 +1481,7 @@ patchcheck:
14721481Python/thread.o: @THREADHEADERS@
14731482
14741483# 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
14761485.PHONY: install altinstall oldsharedinstall bininstall altbininstall
14771486.PHONY: maninstall libinstall inclinstall libainstall sharedinstall
14781487.PHONY: frameworkinstall frameworkinstallframework frameworkinstallstructure
0 commit comments