Skip to content

Commit 0c4785b

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

File tree

2 files changed

+15
-4
lines changed

2 files changed

+15
-4
lines changed

Makefile.pre.in

+14-4
Original file line numberDiff line numberDiff line change
@@ -440,7 +440,17 @@ DTRACE_DEPS = \
440440

441441
# Default target
442442
all: @DEF_MAKE_ALL_RULE@
443-
build_all: $(BUILDPYTHON) oldsharedmods sharedmods gdbhooks Programs/_testembed python-config
443+
build_all: check-clean-src $(BUILDPYTHON) oldsharedmods sharedmods gdbhooks \
444+
Programs/_testembed python-config
445+
446+
# Check that the source is clean when building out of source.
447+
check-clean-src:
448+
@if test -n "$(VPATH)" -a -f "$(srcdir)/Programs/python.o"; then \
449+
echo "Error: The source directory ($(srcdir)) is not clean" ; \
450+
echo "Building Python out of the source tree (in $(abs_builddir)) requires a clean source tree ($(abs_srcdir))" ; \
451+
echo "Try to run: make -C \"$(srcdir)\" clean" ; \
452+
exit 1; \
453+
fi
444454

445455
# Compile a binary with profile guided optimization.
446456
profile-opt:
@@ -530,7 +540,7 @@ coverage-report: regen-grammar regen-importlib
530540
# Run "Argument Clinic" over all source files
531541
# (depends on python having already been built)
532542
.PHONY=clinic
533-
clinic: $(BUILDPYTHON) $(srcdir)/Modules/_blake2/blake2s_impl.c
543+
clinic: check-clean-src $(BUILDPYTHON) $(srcdir)/Modules/_blake2/blake2s_impl.c
534544
$(RUNSHARED) $(PYTHON_FOR_BUILD) ./Tools/clinic/clinic.py --make
535545

536546
# Build the interpreter
@@ -1091,7 +1101,7 @@ altinstall: commoninstall
10911101
$$ensurepip --root=$(DESTDIR)/ ; \
10921102
fi
10931103

1094-
commoninstall: @FRAMEWORKALTINSTALLFIRST@ \
1104+
commoninstall: check-clean-src @FRAMEWORKALTINSTALLFIRST@ \
10951105
altbininstall libinstall inclinstall libainstall \
10961106
sharedinstall oldsharedinstall altmaninstall \
10971107
@FRAMEWORKALTINSTALLLAST@
@@ -1714,7 +1724,7 @@ patchcheck: @DEF_MAKE_RULE@
17141724
Python/thread.o: @THREADHEADERS@
17151725

17161726
# Declare targets that aren't real files
1717-
.PHONY: all build_all sharedmods oldsharedmods test quicktest
1727+
.PHONY: all build_all sharedmods check-clean-src oldsharedmods test quicktest
17181728
.PHONY: install altinstall oldsharedinstall bininstall altbininstall
17191729
.PHONY: maninstall libinstall inclinstall libainstall sharedinstall
17201730
.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)