1 # Minimal makefile for Sphinx documentation
3 # We support MacOS for docs generation
4 ifeq ($(shell uname),Darwin)
8 # These should be passed in by the root Makefile
9 WS_ROOT ?= $(CURDIR)/..
10 BR ?= $(WS_ROOT)/build-root
11 DOCS_DIR ?= $(WS_ROOT)/docs
13 VENV_DIR ?= $(DOCS_DIR)/venv
14 SPHINX_SCRIPTS_DIR ?= $(WS_ROOT)/docs/scripts
16 # Work out the OS if we haven't already
17 OS_ID ?= $(shell grep '^ID=' /etc/os-release | cut -f2- -d= | sed -e 's/\"//g')
18 OS_VERSION ?= $(shell grep '^VERSION_ID=' /etc/os-release | cut -f2- -d= | sed -e 's/\"//g')
19 PIP_VERSION ?= $(shell grep 'PIP_VERSION=' ${WS_ROOT}/test/Makefile | cut -d'=' -f2)
20 PIP_TOOLS_VERSION ?= $(shell grep 'PIP_TOOLS_VERSION=' ${WS_ROOT}/test/Makefile | cut -d'=' -f2)
24 DOC_DEB_DEPENDS = enchant
25 DOC_RPM_DEPENDS = enchant
27 # You can set these variables from the command line.
28 SPHINXOPTS = --keep-going -n -W
29 SPHINXBUILD = sphinx-build
33 BUILDDIR_SRC = ${BUILDDIR}/src
34 BUILDDIR_OUT = ${BUILDDIR}/html
35 SCRIPTS_DIR = _scripts
38 # Put it first so that "make" without argument is like "make help".
42 . ${VENV_DIR}/bin/activate; \
43 $(SPHINXBUILD) --help ;\
48 @echo "Checking whether dependencies for Docs are installed..."
49 ifeq ($(OS_ID),ubuntu)
51 for i in $(DOC_DEB_DEPENDS); do \
52 dpkg-query --show $$i >/dev/null 2>&1 || inst="$$inst $$i"; \
54 if [ "$$inst" ]; then \
55 sudo apt-get update; \
56 sudo apt-get $(CONFIRM) $(FORCE) install $$inst; \
58 else ifneq ("$(wildcard /etc/redhat-release)","")
59 @sudo yum install $(CONFIRM) $(DOC_RPM_DEPENDS)
63 spell: clean checkdeps venv ${BUILDDIR_SRC}
65 . ${VENV_DIR}/bin/activate; \
66 make -C ${SCRIPTS_DIR} generate && \
67 $(SPHINXBUILD) -b spelling $(SPHINXOPTS) $(BUILDDIR_SRC) $(BUILDDIR_OUT); \
73 if [ ! -d ${VENV_DIR} ]; then \
74 ${PYTHON} -m venv ${VENV_DIR}; \
75 . ${VENV_DIR}/bin/activate; \
76 ${PYTHON} -m pip install pip==${PIP_VERSION}; \
77 ${PYTHON} -m pip install pip-tools==${PIP_TOOLS_VERSION}; \
78 ${PYTHON} -m pip install -r ${WS_ROOT}/test/requirements-3.txt; \
83 @mkdir -p ${BUILDDIR_SRC}
84 @cp -r $(SOURCEDIR) ${BUILDDIR_SRC}
85 @cd ${BUILDDIR_SRC} && find . -type l -exec cp --remove-destination -L ${DOCS_DIR}/{} {} \;
88 docs: clean venv ${BUILDDIR_SRC}
90 . ${VENV_DIR}/bin/activate; \
91 make -C ${SCRIPTS_DIR} generate && \
92 $(SPHINXBUILD) $(SPHINXOPTS) -b html $(BUILDDIR_SRC) $(BUILDDIR_OUT); \
98 @make -C ${SCRIPTS_DIR} clean