summaryrefslogtreecommitdiff
path: root/Makefile.pre.in
diff options
context:
space:
mode:
authorxdegaye <xdegaye@gmail.com>2017-11-08 16:03:58 +0100
committerGitHub <noreply@github.com>2017-11-08 16:03:58 +0100
commit0de92859caf25e65fc968d4bb68626e9ba21b851 (patch)
treed5b6be518d974ebeb3bf9746272e0cd9abc4969d /Makefile.pre.in
parentb5d9e0811463f3b28ba355a9e0bee7f1682854e3 (diff)
downloadcpython-git-0de92859caf25e65fc968d4bb68626e9ba21b851.tar.gz
bpo-31934: Abort when building out of a not clean source tree (GH-4255)
Diffstat (limited to 'Makefile.pre.in')
-rw-r--r--Makefile.pre.in18
1 files changed, 14 insertions, 4 deletions
diff --git a/Makefile.pre.in b/Makefile.pre.in
index 4bd3c07860..566afba253 100644
--- a/Makefile.pre.in
+++ b/Makefile.pre.in
@@ -440,7 +440,17 @@ DTRACE_DEPS = \
# Default target
all: @DEF_MAKE_ALL_RULE@
-build_all: $(BUILDPYTHON) oldsharedmods sharedmods gdbhooks Programs/_testembed python-config
+build_all: check-clean-src $(BUILDPYTHON) oldsharedmods sharedmods gdbhooks \
+ Programs/_testembed python-config
+
+# Check that the source is clean when building out of source.
+check-clean-src:
+ @if test -n "$(VPATH)" -a -f "$(srcdir)/Programs/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
# Profile generation build must start from a clean tree.
profile-clean-stamp:
@@ -542,7 +552,7 @@ coverage-report: regen-grammar regen-importlib
# Run "Argument Clinic" over all source files
# (depends on python having already been built)
.PHONY=clinic
-clinic: $(BUILDPYTHON) $(srcdir)/Modules/_blake2/blake2s_impl.c
+clinic: check-clean-src $(BUILDPYTHON) $(srcdir)/Modules/_blake2/blake2s_impl.c
$(RUNSHARED) $(PYTHON_FOR_BUILD) $(srcdir)/Tools/clinic/clinic.py --make --srcdir $(srcdir)
# Build the interpreter
@@ -1100,7 +1110,7 @@ altinstall: commoninstall
$$ensurepip --root=$(DESTDIR)/ ; \
fi
-commoninstall: @FRAMEWORKALTINSTALLFIRST@ \
+commoninstall: check-clean-src @FRAMEWORKALTINSTALLFIRST@ \
altbininstall libinstall inclinstall libainstall \
sharedinstall oldsharedinstall altmaninstall \
@FRAMEWORKALTINSTALLLAST@
@@ -1722,7 +1732,7 @@ patchcheck: @DEF_MAKE_RULE@
Python/thread.o: @THREADHEADERS@
# Declare targets that aren't real files
-.PHONY: all build_all sharedmods oldsharedmods test quicktest
+.PHONY: all build_all sharedmods check-clean-src oldsharedmods test quicktest
.PHONY: install altinstall oldsharedinstall bininstall altbininstall
.PHONY: maninstall libinstall inclinstall libainstall sharedinstall
.PHONY: frameworkinstall frameworkinstallframework frameworkinstallstructure