Skip to content

Commit fbdd3ee

Browse files
authored
[2.7] bpo-31934: Abort when building out of a not clean source tree (GH-4255). (#4342)
(cherry picked from commit 0de9285)
1 parent 8494829 commit fbdd3ee

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

Makefile.pre.in

+12-3
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,16 @@ LIBRARY_OBJS= \
401401

402402
# Default target
403403
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 $(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.
407416
profile-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:
14721481
Python/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
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Abort the build when building out of a not clean source tree.

0 commit comments

Comments
 (0)