sphinx
sphinx copied to clipboard
[Quickstart] Allow calling the Makefile using `make -f path/to/Makefile <target>`
Subject: Allow calling the quickstart Makefile with make -f
Feature or Bugfix
- Bugfix
Purpose
- This PR modifies the default Makefile so that it can be called using
make -f. Otherwise it would call it with a target that is the path to the Makefile itself, this would result in a weird "path/to/Makefile is not a directory" error. - This PR does impacts people using the quickstart setup. It relies on the shell having the
pwdcommand.
Relates
- https://github.com/sphinx-doc/sphinx/issues/10706
I do not understand:
- when moving to source (where
conf.pyandMakefileare),make -f Makefile htmlworks for me with current Makefile, already - if I rename Makefile to something else and try to use (in same directory) this new name via
make -fthen it does not work indeed, but this applies both to current Sphinx and to your branch, with sphinx-build complaining about not knowing the builder, as you mention, - if I issue
make -ffrom parent directory (cf your #10706) I get the expected error about this directory not containing aconf.py. And this applies whether or not using your branch. This seems to be what you report at #10706 but my understanding of https://www.gnu.org/software/make/manual/make.html#Makefile-Names is that this is to be expected.
Besides as you already mention in #10706, using make -C does work fine, from an arbitrary location, if argument of -C is the relative or absolute path to source directory.
My make is GNU Make 4.2.1
Hmm it seems this may solve it:
diff --git a/sphinx/templates/quickstart/Makefile.new_t b/sphinx/templates/quickstart/Makefile.new_t
index 1a527578b..5d5985d3b 100644
--- a/sphinx/templates/quickstart/Makefile.new_t
+++ b/sphinx/templates/quickstart/Makefile.new_t
@@ -12,10 +12,10 @@ BUILDDIR = {{ rbuilddir }}
help:
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
-.PHONY: help Makefile
+.PHONY: help
# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
-%: Makefile
+.DEFAULT:
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
For example renaming this to MyMakefile then make -f MyMakefile html pseudoxml latexpdf works fine at my locale.
I got the hint from this stackoverflow answer but some advice would be needed to make sure we do not break things.
cf https://www.gnu.org/software/make/manual/make.html#Last-Resort
I guess this change will cause trouble for Windows users. So it's better not to use pwd command as possible. Could you check the advice from jfbu, please?
We want to move away from Makefile long-term, so I'm closing this. Thank you for your time, though.
A