@@ -440,7 +440,17 @@ DTRACE_DEPS = \
440
440
441
441
# Default target
442
442
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
444
454
445
455
# Compile a binary with profile guided optimization.
446
456
profile-opt:
@@ -530,7 +540,7 @@ coverage-report: regen-grammar regen-importlib
530
540
# Run "Argument Clinic" over all source files
531
541
# (depends on python having already been built)
532
542
.PHONY=clinic
533
- clinic: $(BUILDPYTHON) $(srcdir)/Modules/_blake2/blake2s_impl.c
543
+ clinic: check-clean-src $(BUILDPYTHON) $(srcdir)/Modules/_blake2/blake2s_impl.c
534
544
$(RUNSHARED) $(PYTHON_FOR_BUILD) ./Tools/clinic/clinic.py --make
535
545
536
546
# Build the interpreter
@@ -1091,7 +1101,7 @@ altinstall: commoninstall
1091
1101
$$ensurepip --root=$(DESTDIR)/ ; \
1092
1102
fi
1093
1103
1094
- commoninstall: @FRAMEWORKALTINSTALLFIRST@ \
1104
+ commoninstall: check-clean-src @FRAMEWORKALTINSTALLFIRST@ \
1095
1105
altbininstall libinstall inclinstall libainstall \
1096
1106
sharedinstall oldsharedinstall altmaninstall \
1097
1107
@FRAMEWORKALTINSTALLLAST@
@@ -1714,7 +1724,7 @@ patchcheck: @DEF_MAKE_RULE@
1714
1724
Python/thread.o: @THREADHEADERS@
1715
1725
1716
1726
# 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
1718
1728
.PHONY: install altinstall oldsharedinstall bininstall altbininstall
1719
1729
.PHONY: maninstall libinstall inclinstall libainstall sharedinstall
1720
1730
.PHONY: frameworkinstall frameworkinstallframework frameworkinstallstructure
0 commit comments