1 # Copyright (c) 2021 Cisco and/or its affiliates.
2 # Licensed under the Apache License, Version 2.0 (the "License");
3 # you may not use this file except in compliance with the License.
4 # You may obtain a copy of the License at:
6 # http://www.apache.org/licenses/LICENSE-2.0
8 # Unless required by applicable law or agreed to in writing, software
9 # distributed under the License is distributed on an "AS IS" BASIS,
10 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 # See the License for the specific language governing permissions and
12 # limitations under the License.
14 # We support MacOS for docs generation
15 ifeq ($(shell uname),Darwin)
19 # These should be passed in by the root Makefile
20 WS_ROOT ?= $(CURDIR)/..
21 BR ?= $(WS_ROOT)/build-root
22 DOCS_DIR ?= $(WS_ROOT)/docs
24 SPHINX_SCRIPTS_DIR ?= $(WS_ROOT)/docs/scripts
26 # Work out the OS if we haven't already
27 OS_ID ?= $(shell grep '^ID=' /etc/os-release | cut -f2- -d= | sed -e 's/\"//g')
28 OS_VERSION ?= $(shell grep '^VERSION_ID=' /etc/os-release | cut -f2- -d= | sed -e 's/\"//g')
29 PIP_VERSION ?= $(shell grep 'PIP_VERSION=' ${WS_ROOT}/test/Makefile | cut -d'=' -f2)
30 PIP_TOOLS_VERSION ?= $(shell grep 'PIP_TOOLS_VERSION=' ${WS_ROOT}/test/Makefile | cut -d'=' -f2)
33 PYTHON_VERSION_OK := $(shell $(PYTHON) -c "exec('import sys\nif sys.hexversion >= 0x03070000: print(\"true\")\nelse: print(\"false\")')")
34 ifneq ($(PYTHON_VERSION_OK),true)
35 $(error "ERROR: docs build requires python version >= to 3.7")
38 # You can set these variables from the command line.
39 SPHINXOPTS = --keep-going -n -W
40 SPHINXBUILD = sphinx-build
43 BUILDDIR_SRC = ${BUILDDIR}/src
44 BUILDDIR_OUT = ${BUILDDIR}/html
45 SCRIPTS_DIR = _scripts
46 VENV_DIR ?= $(BUILDDIR)/venv
49 # Put it first so that "make" without argument is like "make help".
53 . ${VENV_DIR}/bin/activate; \
54 $(SPHINXBUILD) --help ;\
60 if [ ! -d ${VENV_DIR} ]; then \
61 ${PYTHON} -m venv ${VENV_DIR}; \
62 . ${VENV_DIR}/bin/activate; \
63 ${PYTHON} -m pip install pip==${PIP_VERSION}; \
64 ${PYTHON} -m pip install pip-tools==${PIP_TOOLS_VERSION}; \
65 ${PYTHON} -m pip install -r ${WS_ROOT}/test/requirements-3.txt; \
72 . ${VENV_DIR}/bin/activate; \
73 make -C ${SCRIPTS_DIR} generate && \
74 $(SPHINXBUILD) -b spelling $(SPHINXOPTS) $(BUILDDIR_SRC) $(BUILDDIR_OUT); \
78 rebuild-spell: clean spell
83 . ${VENV_DIR}/bin/activate; \
84 make -C ${SCRIPTS_DIR} generate && \
85 $(SPHINXBUILD) $(SPHINXOPTS) -b html $(BUILDDIR_SRC) $(BUILDDIR_OUT); \
93 @make -C ${SCRIPTS_DIR} clean