diff --git a/Makefile.pre.in b/Makefile.pre.in index f1f5c8557e7ffc..a39c86b11c6505 100644 --- a/Makefile.pre.in +++ b/Makefile.pre.in @@ -783,7 +783,10 @@ clinic-tests: check-clean-src $(srcdir)/Lib/test/clinic.test.c # Build the interpreter $(BUILDPYTHON): Programs/python.o $(LINK_PYTHON_DEPS) - $(LINKCC) $(PY_CORE_LDFLAGS) $(LINKFORSHARED) -o $@ Programs/python.o $(LINK_PYTHON_OBJS) $(LIBS) $(MODLIBS) $(SYSLIBS) + @ # gh-103053: Use "-o $(BUILDPYTHON)" instead of "-o $@". + @ # On FreeBSD when Python is built out of tree, $@ contains the source + @ # directory, whereas the build directory is expected. + $(LINKCC) $(PY_CORE_LDFLAGS) $(LINKFORSHARED) -o $(BUILDPYTHON) Programs/python.o $(LINK_PYTHON_OBJS) $(LIBS) $(MODLIBS) $(SYSLIBS) platform: $(PYTHON_FOR_BUILD_DEPS) pybuilddir.txt $(RUNSHARED) $(PYTHON_FOR_BUILD) -c 'import sys ; from sysconfig import get_platform ; print("%s-%d.%d" % (get_platform(), *sys.version_info[:2]))' >platform diff --git a/Misc/NEWS.d/next/Build/2023-10-06-01-35-22.gh-issue-103053.qyJ0ru.rst b/Misc/NEWS.d/next/Build/2023-10-06-01-35-22.gh-issue-103053.qyJ0ru.rst new file mode 100644 index 00000000000000..a1fc76a5a88cd3 --- /dev/null +++ b/Misc/NEWS.d/next/Build/2023-10-06-01-35-22.gh-issue-103053.qyJ0ru.rst @@ -0,0 +1,4 @@ +On FreeBSD when Python is built out of tree, the "python" program was +created in the source directory instead of build directory. Fix the Makefile +to write the "python" program in the build directory. Patch by Victor +Stinner.