Answer the question
In order to leave comments, you need to log in
How to move a compiled pdf file from a directory with renaming (add a suffix) in Makefile?
Hello! I use Sphinx-doc to generate project documentation, for simplicity there is a basic Makefile that allows you to build html or pdf with a simple command `make html` or `make latexpdf`. Since the project documentation is written in English and Russian, I start the generation for the Russian language by adding an additional argument `LANG=ru` (en is generated by default). Depending on the language, the source corresponding to the language is picked up, the pdf file is generated with the same name for any language in the folder with latex files. It is necessary to move the assembled pdf file to another directory and add the _ru or _en suffix.
# Makefile for Sphinx documentation
#
# You can set these variables from the command line.
LANG = en
SPHINXOPTS = -c sphinx/source -a -D language=$(LANG)
SPHINXBUILD = sphinx-build
PAPER =
BUILDDIR = .
# Internal variables.
ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) source/$(LANG)
.PHONY: help
help:
@echo "Please use \`make <target>' where <target> is one of"
@echo " html to make standalone HTML files, you can set LANG=ru (en default)"
@echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter"
@echo " latexpdf to make LaTeX files and run them through pdflatex"
.PHONY: html
html:
$(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html/$(LANG)
@echo
@echo "Build finished. The HTML pages are in $(BUILDDIR)/html/$(LANG)."
.PHONY: latex
latex:
$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex/$(LANG)
@echo
@echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex/$(LANG)."
@echo "Run \`make' in that directory to run these through (pdf)latex" \
"(use \`make latexpdf' here to do that automatically)."
.PHONY: latexpdf
latexpdf:
rm -rf $(BUILDDIR)/latex/$(LANG)
$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex/$(LANG)
@echo "Running LaTeX files through pdflatex..."
$(MAKE) -C $(BUILDDIR)/latex/$(LANG) all-pdf
@echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex/$(LANG)."
mv -f $(BUILDDIR)/latex/$(LANG)/documentation.pdf $(BUILDDIR)/pdf/documentation_$(LANG).pdf
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question