| 
									
										
										
										
											2019-12-03 18:54:04 +01:00
										 |  |  | # -*- coding: utf-8; mode: makefile-gmake -*- | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-03-15 17:01:36 +01:00
										 |  |  | export DOCS_FOLDER DOCS_BUILD DOCS_DIST BOOKS_FOLDER BOOKS_DIST | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-12-03 18:54:04 +01:00
										 |  |  | # You can set these variables from the command line. | 
					
						
							|  |  |  | SPHINXOPTS  ?= | 
					
						
							|  |  |  | SPHINXBUILD ?= $(PY_ENV_BIN)/sphinx-build | 
					
						
							|  |  |  | SPHINX_CONF ?= conf.py | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-06-18 18:44:22 +02:00
										 |  |  | DOCS_FOLDER = ./docs | 
					
						
							| 
									
										
										
										
											2020-03-23 18:05:46 +01:00
										 |  |  | DOCS_BUILD  = ./$(LXC_ENV_FOLDER)build/docs | 
					
						
							|  |  |  | DOCS_DIST   = ./$(LXC_ENV_FOLDER)dist/docs | 
					
						
							| 
									
										
										
										
											2019-12-03 18:54:04 +01:00
										 |  |  | GH_PAGES    ?= gh-pages | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-06-18 18:44:22 +02:00
										 |  |  | BOOKS_FOLDER = ./docs | 
					
						
							| 
									
										
										
										
											2020-03-23 18:05:46 +01:00
										 |  |  | BOOKS_DIST   = ./$(LXC_ENV_FOLDER)dist/books | 
					
						
							| 
									
										
										
										
											2019-12-03 18:54:04 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | ifeq ($(KBUILD_VERBOSE),1) | 
					
						
							|  |  |  |   SPHINX_VERBOSE = "-v" | 
					
						
							|  |  |  | else | 
					
						
							|  |  |  |   SPHINX_VERBOSE = | 
					
						
							|  |  |  | endif | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | ## SPHINXVERS variable | 
					
						
							|  |  |  | ## =================== | 
					
						
							|  |  |  | ## | 
					
						
							|  |  |  | ## .. _requirement-specifiers: https://pip.pypa.io/en/stable/reference/pip_install/#requirement-specifiers | 
					
						
							|  |  |  | ## | 
					
						
							|  |  |  | ## Sphinx version to use, when building documentation.  Set this when calling | 
					
						
							|  |  |  | ## build target.  The default value is empty (install latest), to select a | 
					
						
							|  |  |  | ## specific version use a requirement-specifiers_.  E.g. to build your target | 
					
						
							|  |  |  | ## 'doc' with a select sphinx-doc_ version 1.7.9:: | 
					
						
							|  |  |  | ## | 
					
						
							|  |  |  | ##     make SPHINXVERS='==1.7.9' docs | 
					
						
							|  |  |  | ## | 
					
						
							|  |  |  | ## To build with latest 1.7:: | 
					
						
							|  |  |  | ## | 
					
						
							|  |  |  | ##     make SPHINXVERS='>=1.7,<1.8' docs | 
					
						
							|  |  |  | ## | 
					
						
							|  |  |  | SPHINXVERS  ?= | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | docs-help: | 
					
						
							|  |  |  | 	@echo  'makefile.sphinx:' | 
					
						
							|  |  |  | 	@echo  '  docs-clean	- clean intermediate doc objects' | 
					
						
							|  |  |  | 	@echo  '  $(GH_PAGES)	- create & upload github pages' | 
					
						
							|  |  |  | 	@echo  '  sphinx-pdf    - run sphinx latex & pdf targets' | 
					
						
							|  |  |  | 	echo   '' | 
					
						
							|  |  |  | 	@echo  '  books/{name}.html : build only the HTML of document {name}' | 
					
						
							|  |  |  | 	@echo  '  valid values for books/{name}.html are:' | 
					
						
							|  |  |  | 	@echo  '    $(BOOKS_HTML)' | $(FMT) | 
					
						
							|  |  |  | 	@echo  '  books/{name}.pdf : build only the PDF of document {name}' | 
					
						
							|  |  |  | 	@echo  '  valid values for books/{name}.pdf are:' | 
					
						
							|  |  |  | 	@echo  '    $(BOOKS_PDF) ' | $(FMT) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | # ------------------------------------------------------------------------------ | 
					
						
							|  |  |  | # requirements | 
					
						
							|  |  |  | # ------------------------------------------------------------------------------ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-06-18 18:44:22 +02:00
										 |  |  | sphinx-doc-prebuilds:: $(PY_ENV) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | sphinx-doc: sphinx-doc-prebuilds | 
					
						
							| 
									
										
										
										
											2019-12-03 18:54:04 +01:00
										 |  |  | 	@echo "PYENV     installing Sphinx$(SPHINXVERS)" | 
					
						
							|  |  |  | 	$(Q)$(PY_ENV_BIN)/pip install $(PIP_VERBOSE) 'Sphinx$(SPHINXVERS)' | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-06-18 18:44:22 +02:00
										 |  |  | sphinx-live: sphinx-doc-prebuilds | 
					
						
							| 
									
										
										
										
											2019-12-03 18:54:04 +01:00
										 |  |  | 	@echo "PYENV     installing Sphinx$(SPHINXVERS)" | 
					
						
							|  |  |  | 	$(Q)$(PY_ENV_BIN)/pip install $(PIP_VERBOSE) 'Sphinx$(SPHINXVERS)' sphinx-autobuild | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | PHONY += msg-texlive texlive | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | ifeq ($(shell which xelatex >/dev/null 2>&1; echo $$?), 1) | 
					
						
							|  |  |  | texlive: msg-TeXLive | 
					
						
							|  |  |  | 	$(error The 'xelatex' command was not found) | 
					
						
							|  |  |  | else | 
					
						
							|  |  |  | texlive: | 
					
						
							|  |  |  | 	@: | 
					
						
							|  |  |  | endif | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | msg-texlive: | 
					
						
							|  |  |  | 	$(Q)echo "\n\ | 
					
						
							|  |  |  | The TeX/PDF output and the *math* extension require TexLive and latexmk:\n\n\ | 
					
						
							|  |  |  |   Make sure you have a updated TeXLive with XeTeX engine installed, grab it\n\ | 
					
						
							|  |  |  |   it from https://www.tug.org/texlive or install it from your package manager.\n\n\ | 
					
						
							|  |  |  |   Install latexmk from your package manager or visit https://ctan.org/pkg/latexmk\n\n\ | 
					
						
							|  |  |  |   Sphinx-doc produce (Xe)LaTeX files which might use additional TeX-packages\n\ | 
					
						
							|  |  |  |   and fonts. To process these LaTeX files, a TexLive installation with the\n\ | 
					
						
							|  |  |  |   additional packages is required. On debian based OS these requirements\n\ | 
					
						
							|  |  |  |   are installed by::\n\n\ | 
					
						
							|  |  |  |     sudo -H apt-get install\n\ | 
					
						
							|  |  |  |          latexmk\n\ | 
					
						
							|  |  |  |          texlive-base texlive-xetex texlive-latex-recommended\n\ | 
					
						
							|  |  |  |          texlive-extra-utils dvipng ttf-dejavu\n" | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | # ------------------------------------------------------------------------------ | 
					
						
							|  |  |  | # commands | 
					
						
							|  |  |  | # ------------------------------------------------------------------------------ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | # $2 sphinx builder e.g. "html" | 
					
						
							|  |  |  | # $3 path where configuration file (conf.py) is located | 
					
						
							|  |  |  | # $4 sourcedir | 
					
						
							|  |  |  | # $5 dest subfolder e.g. "man" for man pages at $(DOCS_DIST)/man | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | quiet_cmd_sphinx = SPHINX    $@ --> file://$(abspath $(DOCS_DIST)/$5) | 
					
						
							|  |  |  |       cmd_sphinx = SPHINX_CONF=$(abspath $4/$(SPHINX_CONF))\ | 
					
						
							|  |  |  | 	$(SPHINXBUILD) $(SPHINX_VERBOSE) $(SPHINXOPTS)\ | 
					
						
							|  |  |  | 	-b $2 -c $3 -d $(DOCS_BUILD)/.doctrees $4 $(DOCS_DIST)/$5 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | quiet_cmd_sphinx_autobuild = SPHINX    $@ --> file://$(abspath $(DOCS_DIST)/$5) | 
					
						
							|  |  |  |       cmd_sphinx_autobuild = PATH="$(PY_ENV_BIN):$(PATH)" $(PY_ENV_BIN)/sphinx-autobuild  $(SPHINX_VERBOSE) --poll -B --host 0.0.0.0 --port 8080 $(SPHINXOPTS)\ | 
					
						
							|  |  |  | 	-b $2 -c $3 -d $(DOCS_BUILD)/.doctrees $4 $(DOCS_DIST)/$5 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | quiet_cmd_sphinx_clean = CLEAN     $@ | 
					
						
							|  |  |  |       cmd_sphinx_clean = rm -rf $(DOCS_BUILD) $(DOCS_DIST) $(GH_PAGES)/* $(GH_PAGES)/.buildinfo | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | # ------------------------------------------------------------------------------ | 
					
						
							|  |  |  | # targets | 
					
						
							|  |  |  | # ------------------------------------------------------------------------------ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-06-18 18:44:22 +02:00
										 |  |  | # build PDF of whole documentation in: $(DOCS_DIST)/pdf | 
					
						
							| 
									
										
										
										
											2019-12-03 18:54:04 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | PHONY += sphinx-pdf | 
					
						
							|  |  |  | sphinx-pdf: sphinx-latex | 
					
						
							|  |  |  | 	$(Q)cd $(DOCS_BUILD)/latex/; make all-pdf | 
					
						
							|  |  |  | 	$(Q)mkdir -p $(DOCS_DIST)/pdf | 
					
						
							|  |  |  | 	$(Q)cp $(DOCS_BUILD)/latex/*.pdf $(DOCS_DIST)/pdf | 
					
						
							|  |  |  | 	@echo "SPHINX    *.pdf --> file://$(abspath $(DOCS_DIST)/pdf)" | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | PHONY += sphinx-latex | 
					
						
							|  |  |  | sphinx-latex: texlive sphinx-doc | 
					
						
							|  |  |  | 	$(SPHINXBUILD) $(SPHINX_VERBOSE) $(SPHINXOPTS)\ | 
					
						
							|  |  |  | 	  -b latex \ | 
					
						
							|  |  |  | 	  -c $(DOCS_FOLDER) \ | 
					
						
							|  |  |  | 	  -d $(DOCS_BUILD)/.doctrees \ | 
					
						
							|  |  |  | 	  $(DOCS_FOLDER) \ | 
					
						
							|  |  |  | 	  $(DOCS_BUILD)/latex | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | # Sphinx projects, we call them *books* (what is more common).  Books are | 
					
						
							|  |  |  | # folders under $(BOOKS_FOLDER) containing a conf.py file. The HTML output goes | 
					
						
							|  |  |  | # to folder $(BOOKS_DIST)/<name> while PDF is placed (BOOKS_DIST)/<name>/pdf | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | BOOKS=$(patsubst $(BOOKS_FOLDER)/%/conf.py,books/%,$(wildcard $(BOOKS_FOLDER)/*/conf.py)) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | # fine grained targets | 
					
						
							|  |  |  | BOOKS_HTML  = $(patsubst %,%.html,$(BOOKS)) | 
					
						
							|  |  |  | BOOKS_CLEAN = $(patsubst %,%.clean,$(BOOKS)) | 
					
						
							|  |  |  | BOOKS_LATEX = $(patsubst %,%.latex,$(BOOKS)) | 
					
						
							|  |  |  | BOOKS_PDF   = $(patsubst %,%.pdf,$(BOOKS)) | 
					
						
							|  |  |  | BOOKS_LIVE  = $(patsubst %,%.live,$(BOOKS)) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | $(BOOKS_DIST): | 
					
						
							|  |  |  | 	mkdir -p $(BOOKS_DIST) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | PHONY += $(BOOKS_HTML) | 
					
						
							|  |  |  | $(BOOKS_HTML): sphinx-doc | $(BOOKS_DIST) | 
					
						
							|  |  |  | 	SPHINX_CONF=$(patsubst books/%.html,%,$@)/conf.py \ | 
					
						
							|  |  |  | 	$(SPHINXBUILD) $(SPHINX_VERBOSE) $(SPHINXOPTS)\ | 
					
						
							|  |  |  | 	  -b html \ | 
					
						
							|  |  |  | 	  -c $(DOCS_FOLDER) \ | 
					
						
							|  |  |  | 	  -d $(DOCS_BUILD)/books/$(patsubst books/%.html,%,$@)/.doctrees \ | 
					
						
							| 
									
										
										
										
											2020-03-21 18:45:38 +01:00
										 |  |  | 	  $(BOOKS_FOLDER)/$(patsubst books/%.html,%,$@) \ | 
					
						
							| 
									
										
										
										
											2019-12-03 18:54:04 +01:00
										 |  |  | 	  $(BOOKS_DIST)/$(patsubst books/%.html,%,$@) | 
					
						
							|  |  |  | 	@echo "SPHINX    $@ --> file://$(abspath $(BOOKS_DIST)/$(patsubst books/%.html,%,$@))" | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | PHONY += $(BOOKS_HTML) | 
					
						
							|  |  |  | $(BOOKS_LIVE): sphinx-live | $(BOOKS_DIST) | 
					
						
							|  |  |  | 	PATH="$(PY_ENV_BIN):$(PATH)" \ | 
					
						
							|  |  |  | 	SPHINX_CONF=$(patsubst books/%.live,%,$@)/conf.py \ | 
					
						
							|  |  |  | 	$(PY_ENV_BIN)/sphinx-autobuild --poll -B --host 0.0.0.0 --port 8080 $(SPHINX_VERBOSE) $(SPHINXOPTS)\ | 
					
						
							|  |  |  | 	  -b html \ | 
					
						
							|  |  |  | 	  -c $(DOCS_FOLDER) \ | 
					
						
							|  |  |  | 	  -d $(DOCS_BUILD)/books/$(patsubst books/%.live,%,$@)/.doctrees \ | 
					
						
							| 
									
										
										
										
											2020-03-21 18:45:38 +01:00
										 |  |  | 	  $(BOOKS_FOLDER)/$(patsubst books/%.live,%,$@) \ | 
					
						
							| 
									
										
										
										
											2019-12-03 18:54:04 +01:00
										 |  |  | 	  $(BOOKS_DIST)/$(patsubst books/%.live,%,$@) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | $(BOOKS_PDF): %.pdf : %.latex | 
					
						
							|  |  |  | 	$(Q)cd $(DOCS_BUILD)/latex/$(patsubst books/%.pdf,%,$@); make all-pdf | 
					
						
							|  |  |  | 	$(Q)mkdir -p $(BOOKS_DIST)/$(patsubst books/%.pdf,%,$@)/pdf | 
					
						
							|  |  |  | 	$(Q)cp -v $(DOCS_BUILD)/latex/$(patsubst books/%.pdf,%,$@)/*.pdf $(BOOKS_DIST)/$(patsubst books/%.pdf,%,$@)/pdf | 
					
						
							|  |  |  | 	@echo "SPHINX    $@ --> file://$(abspath $(BOOKS_DIST)/$(patsubst books/%.pdf,%,$@))/pdf" | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | PHONY += $(BOOKS_LATEX) | 
					
						
							|  |  |  | $(BOOKS_LATEX): sphinx-doc | $(BOOKS_DIST) | 
					
						
							|  |  |  | 	SPHINX_CONF=$(patsubst books/%.latex,%,$@)/conf.py \ | 
					
						
							|  |  |  | 	$(SPHINXBUILD) $(SPHINX_VERBOSE) $(SPHINXOPTS)\ | 
					
						
							|  |  |  | 	  -b latex \ | 
					
						
							|  |  |  | 	  -c $(DOCS_FOLDER) \ | 
					
						
							|  |  |  | 	  -d $(DOCS_BUILD)/books/$(patsubst books/%.latex,%,$@)/.doctrees \ | 
					
						
							| 
									
										
										
										
											2020-03-21 18:45:38 +01:00
										 |  |  | 	  $(BOOKS_FOLDER)/$(patsubst books/%.latex,%,$@) \ | 
					
						
							| 
									
										
										
										
											2019-12-03 18:54:04 +01:00
										 |  |  | 	  $(DOCS_BUILD)/latex/$(patsubst books/%.latex,%,$@) | 
					
						
							|  |  |  | 	@echo "SPHINX    $@ --> file://$(abspath $(DOCS_BUILD)/latex/$(patsubst books/%.latex,%,$@))" | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | $(BOOKS_CLEAN): | 
					
						
							|  |  |  | 	$(Q)rm -rf $(BOOKS_DIST)/$(patsubst books/%.clean,%,$@) \ | 
					
						
							|  |  |  | 	       $(DOCS_BUILD)/books/$(patsubst books/%.clean,%,$@) \ | 
					
						
							|  |  |  | 	       $(DOCS_BUILD)/latex/$(patsubst books/%.clean,%,$@) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | # github pages | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | PHONY += $(GH_PAGES) | 
					
						
							| 
									
										
										
										
											2019-12-13 12:58:46 +01:00
										 |  |  | $(GH_PAGES):: | 
					
						
							| 
									
										
										
										
											2019-12-03 18:54:04 +01:00
										 |  |  | 	$(MAKE) docs | 
					
						
							|  |  |  | 	[ -d "gh-pages/.git" ] || git clone $(GIT_URL) gh-pages | 
					
						
							| 
									
										
										
										
											2019-12-13 12:58:46 +01:00
										 |  |  | 	-cd $(GH_PAGES); git checkout gh-pages >/dev/null | 
					
						
							| 
									
										
										
										
											2019-12-22 23:28:07 +01:00
										 |  |  | 	-cd $(GH_PAGES); git pull | 
					
						
							| 
									
										
										
										
											2019-12-13 12:58:46 +01:00
										 |  |  | 	-cd $(GH_PAGES); ls -A | grep -v '.git$$' | xargs rm -rf | 
					
						
							| 
									
										
										
										
											2019-12-03 18:54:04 +01:00
										 |  |  | 	cp -r $(DOCS_DIST)/* $(GH_PAGES)/ | 
					
						
							| 
									
										
										
										
											2019-12-13 12:58:46 +01:00
										 |  |  | 	touch $(GH_PAGES)/.nojekyll | 
					
						
							| 
									
										
										
										
											2019-12-03 18:54:04 +01:00
										 |  |  | 	echo "<html><head><META http-equiv='refresh' content='0;URL=index.html'></head></html>" > $(GH_PAGES)/404.html | 
					
						
							|  |  |  | 	cd $(GH_PAGES);\ | 
					
						
							|  |  |  | 		git add --all . ;\ | 
					
						
							|  |  |  | 		git commit -m "gh-pages: updated" ;\ | 
					
						
							|  |  |  | 		git push origin gh-pages | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-12-13 12:58:46 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-12-03 18:54:04 +01:00
										 |  |  | PHONY += docs-clean | 
					
						
							|  |  |  | docs-clean: $(BOOKS_CLEAN) | 
					
						
							|  |  |  | 	$(call cmd,sphinx_clean) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | .PHONY: $(PHONY) |