Joey Armstrong | 36592e3 | 2022-11-28 09:00:28 -0500 | [diff] [blame] | 1 | # -*- makefile -*- |
| 2 | # ----------------------------------------------------------------------- |
Joey Armstrong | 8d62cd9 | 2022-12-22 13:53:48 -0500 | [diff] [blame] | 3 | # Copyright 2022-2023 Open Networking Foundation (ONF) and the ONF Contributors |
Joey Armstrong | 36592e3 | 2022-11-28 09:00:28 -0500 | [diff] [blame] | 4 | # |
| 5 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | # you may not use this file except in compliance with the License. |
| 7 | # You may obtain a copy of the License at |
| 8 | # |
| 9 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | # |
| 11 | # Unless required by applicable law or agreed to in writing, software |
| 12 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | # See the License for the specific language governing permissions and |
| 15 | # limitations under the License. |
| 16 | # ----------------------------------------------------------------------- |
Zack Williams | 071eda2 | 2019-05-15 18:19:51 -0700 | [diff] [blame] | 17 | # Makefile for Sphinx documentation |
| 18 | |
Joey Armstrong | 36592e3 | 2022-11-28 09:00:28 -0500 | [diff] [blame] | 19 | .DEFAULT_GOAL := help |
| 20 | |
Joey Armstrong | 449ce7a | 2023-07-18 18:32:24 -0400 | [diff] [blame^] | 21 | ##-------------------## |
| 22 | ##---] GLOBALS [---## |
| 23 | ##-------------------## |
| 24 | TOP ?=$(strip \ |
| 25 | $(dir \ |
| 26 | $(abspath $(lastword $(MAKEFILE_LIST)))\ |
| 27 | )\ |
| 28 | ) |
Joey Armstrong | 36592e3 | 2022-11-28 09:00:28 -0500 | [diff] [blame] | 29 | |
| 30 | ##--------------------## |
| 31 | ##---] INCLUDES [---## |
| 32 | ##--------------------## |
Joey Armstrong | 449ce7a | 2023-07-18 18:32:24 -0400 | [diff] [blame^] | 33 | include $(TOP)/config.mk# # configure |
| 34 | include $(TOP)/makefiles/include.mk # top level include |
Zack Williams | 071eda2 | 2019-05-15 18:19:51 -0700 | [diff] [blame] | 35 | |
| 36 | # You can set these variables from the command line. |
| 37 | SPHINXOPTS ?= |
| 38 | SPHINXBUILD ?= sphinx-build |
| 39 | SOURCEDIR ?= . |
| 40 | BUILDDIR ?= _build |
| 41 | |
Zack Williams | 88df474 | 2019-12-20 08:24:47 -0700 | [diff] [blame] | 42 | # Other repos with documentation to include. |
| 43 | # edit the `git_refs` file with the commit/tag/branch that you want to use |
Andrea Campanella | c18d118 | 2021-09-10 12:01:38 +0200 | [diff] [blame] | 44 | OTHER_REPO_DOCS ?= bbsim cord-tester ofagent-go openolt voltctl voltha-openolt-adapter voltha-openonu-adapter-go voltha-protos voltha-system-tests device-management-interface voltha-helm-charts |
Zack Williams | 88df474 | 2019-12-20 08:24:47 -0700 | [diff] [blame] | 45 | |
Joey Armstrong | 36592e3 | 2022-11-28 09:00:28 -0500 | [diff] [blame] | 46 | ifdef NO_OTHER_REPO_DOCS |
| 47 | # Inhibit pulling in external repos. |
| 48 | # python 3.10+ patching not supported by all repos yet. |
| 49 | OTHER_REPO_DOCS := $(null) |
| 50 | endif |
| 51 | |
Zack Williams | 16042b6 | 2020-03-29 22:03:16 -0700 | [diff] [blame] | 52 | # Static docs, built by other means (usually robot framework) |
| 53 | STATIC_DOCS := _static/voltha-system-tests _static/cord-tester |
| 54 | |
Joey Armstrong | 4de98b7 | 2023-02-09 14:51:38 -0500 | [diff] [blame] | 55 | # Why is existing source Makefile PHONY (?) |
Zack Williams | 88df474 | 2019-12-20 08:24:47 -0700 | [diff] [blame] | 56 | .PHONY: help test lint reload Makefile prep |
Zack Williams | 071eda2 | 2019-05-15 18:19:51 -0700 | [diff] [blame] | 57 | |
Joey Armstrong | 4de98b7 | 2023-02-09 14:51:38 -0500 | [diff] [blame] | 58 | ## ----------------------------------------------------------------------- |
| 59 | ## Intent: Real time viewing, dynamically generate and reload document |
| 60 | ## changes for web browser viewing. |
| 61 | ## Usage: |
| 62 | ## make reload |
| 63 | ## ----------------------------------------------------------------------- |
Joey Armstrong | 449ce7a | 2023-07-18 18:32:24 -0400 | [diff] [blame^] | 64 | reload: $(venv-activate-patched) |
Joey Armstrong | 4de98b7 | 2023-02-09 14:51:38 -0500 | [diff] [blame] | 65 | $(activate) && sphinx-reload $(SOURCEDIR) |
Zack Williams | 071eda2 | 2019-05-15 18:19:51 -0700 | [diff] [blame] | 66 | |
Joey Armstrong | 8d62cd9 | 2022-12-22 13:53:48 -0500 | [diff] [blame] | 67 | ## ----------------------------------------------------------------------- |
| 68 | ## Intent: lint and link verification. linkcheck is part of sphinx |
Joey Armstrong | 64b8249 | 2023-06-01 17:34:39 -0400 | [diff] [blame] | 69 | ## See Also: make test-errors |
Joey Armstrong | 8d62cd9 | 2022-12-22 13:53:48 -0500 | [diff] [blame] | 70 | ## ----------------------------------------------------------------------- |
Zack Williams | 071eda2 | 2019-05-15 18:19:51 -0700 | [diff] [blame] | 71 | test: lint linkcheck |
Joey Armstrong | a8bc8e1 | 2022-12-04 07:06:59 -0500 | [diff] [blame] | 72 | |
Joey Armstrong | 8d62cd9 | 2022-12-22 13:53:48 -0500 | [diff] [blame] | 73 | ## ----------------------------------------------------------------------- |
| 74 | ## Intent: Exercise all generation targets |
Joey Armstrong | 4de98b7 | 2023-02-09 14:51:38 -0500 | [diff] [blame] | 75 | ## Bridge: library workaround to support legacy targets |
Joey Armstrong | 8d62cd9 | 2022-12-22 13:53:48 -0500 | [diff] [blame] | 76 | ## ----------------------------------------------------------------------- |
| 77 | test-all-targets += html |
| 78 | test-all-targets += coverage |
| 79 | # test-all-targets += changes |
| 80 | # test-all-targets += info |
| 81 | test-all-targets += man |
| 82 | test-all-targe4ts += text |
| 83 | # test-all-targets += latex |
| 84 | |
Joey Armstrong | 8d62cd9 | 2022-12-22 13:53:48 -0500 | [diff] [blame] | 85 | test-all : test |
| 86 | $(MAKE) $(test-all-targets) |
| 87 | |
Joey Armstrong | 36592e3 | 2022-11-28 09:00:28 -0500 | [diff] [blame] | 88 | # doctest |
| 89 | # coverage |
| 90 | # linkcheck |
Zack Williams | 071eda2 | 2019-05-15 18:19:51 -0700 | [diff] [blame] | 91 | |
Zack Williams | 071eda2 | 2019-05-15 18:19:51 -0700 | [diff] [blame] | 92 | # currently not enabled, should be added to lint target |
| 93 | LINT_STYLE ?= mdl_strict.rb |
| 94 | md-lint: | $(OTHER_REPO_DOCS) |
| 95 | @echo "markdownlint(mdl) version: `mdl --version`" |
| 96 | @echo "style config:" |
| 97 | @echo "---" |
| 98 | @cat $(LINT_STYLE) |
| 99 | @echo "---" |
Joey Armstrong | 4de98b7 | 2023-02-09 14:51:38 -0500 | [diff] [blame] | 100 | mdl -s $(LINT_STYLE) `find -L $(SOURCEDIR) ! -path "./_$(venv-activate-script)/*" ! -path "./_build/*" ! -path "./repos/*" ! -path "*vendor*" -name "*.md"` |
Zack Williams | 071eda2 | 2019-05-15 18:19:51 -0700 | [diff] [blame] | 101 | |
| 102 | # clean up |
Joey Armstrong | 64b8249 | 2023-06-01 17:34:39 -0400 | [diff] [blame] | 103 | clean :: |
Joey Armstrong | 36592e3 | 2022-11-28 09:00:28 -0500 | [diff] [blame] | 104 | $(RM) -r $(BUILDDIR) $(OTHER_REPO_DOCS) $(STATIC_DOCS) |
Zack Williams | 071eda2 | 2019-05-15 18:19:51 -0700 | [diff] [blame] | 105 | |
Joey Armstrong | 4de98b7 | 2023-02-09 14:51:38 -0500 | [diff] [blame] | 106 | clean-all sterile :: clean |
| 107 | $(RM) -r $(venv-activate-script) repos |
Zack Williams | 071eda2 | 2019-05-15 18:19:51 -0700 | [diff] [blame] | 108 | |
Zack Williams | 071eda2 | 2019-05-15 18:19:51 -0700 | [diff] [blame] | 109 | # checkout the repos inside repos/ dir |
| 110 | repos: |
| 111 | mkdir repos |
| 112 | |
| 113 | # build directory paths in repos/* to perform 'git clone <repo>' into |
| 114 | CHECKOUT_REPOS = $(foreach repo,$(OTHER_REPO_DOCS),repos/$(repo)) |
| 115 | |
| 116 | # Host holding the git server |
| 117 | REPO_HOST ?= https://gerrit.opencord.org |
| 118 | |
| 119 | # For QA patchset validation - set SKIP_CHECKOUT to the repo name and |
| 120 | # pre-populate it under repos/ with the specific commit to being validated |
| 121 | SKIP_CHECKOUT ?= |
| 122 | |
Zack Williams | 88df474 | 2019-12-20 08:24:47 -0700 | [diff] [blame] | 123 | # clone (only if doesn't exist) |
Zack Williams | 071eda2 | 2019-05-15 18:19:51 -0700 | [diff] [blame] | 124 | $(CHECKOUT_REPOS): | repos |
Zack Williams | 071eda2 | 2019-05-15 18:19:51 -0700 | [diff] [blame] | 125 | if [ ! -d '$@' ] ;\ |
| 126 | then git clone $(REPO_HOST)/$(@F) $@ ;\ |
Zack Williams | 071eda2 | 2019-05-15 18:19:51 -0700 | [diff] [blame] | 127 | fi |
| 128 | |
Joey Armstrong | 4de98b7 | 2023-02-09 14:51:38 -0500 | [diff] [blame] | 129 | ## ----------------------------------------------------------------------- |
| 130 | ## Intent: checkout correct ref if not under test, then copy |
| 131 | ## subdirectories into main docs dir |
| 132 | ## ----------------------------------------------------------------------- |
Zack Williams | 071eda2 | 2019-05-15 18:19:51 -0700 | [diff] [blame] | 133 | $(OTHER_REPO_DOCS): | $(CHECKOUT_REPOS) |
Zack Williams | 88df474 | 2019-12-20 08:24:47 -0700 | [diff] [blame] | 134 | if [ "$(SKIP_CHECKOUT)" != "$@" ] ;\ |
| 135 | then GIT_REF=`grep '^$@ ' git_refs | awk '{print $$3}'` ;\ |
Zack Williams | 6c1703f | 2019-12-20 15:31:58 -0700 | [diff] [blame] | 136 | cd "repos/$@" && git checkout $$GIT_REF ;\ |
Zack Williams | 88df474 | 2019-12-20 08:24:47 -0700 | [diff] [blame] | 137 | fi |
Zack Williams | 17e3402 | 2019-12-20 13:51:54 -0700 | [diff] [blame] | 138 | GIT_SUBDIR=`grep '^$@ ' git_refs | awk '{print $$2}'` ;\ |
Zack Williams | 3308552 | 2020-02-28 11:41:01 -0700 | [diff] [blame] | 139 | cp -r repos/$(@)$$GIT_SUBDIR $@ ;\ |
Zack Williams | 071eda2 | 2019-05-15 18:19:51 -0700 | [diff] [blame] | 140 | |
Andrea Campanella | 92bd59b | 2020-01-30 17:26:32 +0100 | [diff] [blame] | 141 | # Build Robot documentation in voltha-system-tests and copy it into _static. |
| 142 | _static/voltha-system-tests: | $(OTHER_REPO_DOCS) |
| 143 | make -C voltha-system-tests gendocs |
| 144 | mkdir -p $@ |
| 145 | cp -r voltha-system-tests/gendocs/* $@ |
| 146 | |
Andy Bavier | 39d67b1 | 2020-02-27 16:08:52 -0700 | [diff] [blame] | 147 | # Build Robot documentation in cord-tester and copy it into _static. |
| 148 | _static/cord-tester: | $(OTHER_REPO_DOCS) |
| 149 | make -C cord-tester gendocs |
| 150 | mkdir -p $@ |
| 151 | cp -r cord-tester/gendocs/* $@ |
| 152 | |
Joey Armstrong | 4de98b7 | 2023-02-09 14:51:38 -0500 | [diff] [blame] | 153 | ## ----------------------------------------------------------------------- |
| 154 | ## Intent: generate a list of git checksums suitable for updating git_refs |
| 155 | ## ----------------------------------------------------------------------- |
Zack Williams | 071eda2 | 2019-05-15 18:19:51 -0700 | [diff] [blame] | 156 | freeze: repos |
| 157 | @for repo in $(OTHER_REPO_DOCS) ; do \ |
| 158 | GIT_SUBDIR=`grep "^$$repo " git_refs | awk '{print $$2}'` ;\ |
Zack Williams | 6c1703f | 2019-12-20 15:31:58 -0700 | [diff] [blame] | 159 | cd "repos/$$repo" > /dev/null ;\ |
Zack Williams | 071eda2 | 2019-05-15 18:19:51 -0700 | [diff] [blame] | 160 | HEAD_SHA=`git rev-parse HEAD` ;\ |
| 161 | printf "%-24s %-8s %-40s\n" $$repo $$GIT_SUBDIR $$HEAD_SHA ;\ |
Zack Williams | 6c1703f | 2019-12-20 15:31:58 -0700 | [diff] [blame] | 162 | cd ../.. ;\ |
Zack Williams | 071eda2 | 2019-05-15 18:19:51 -0700 | [diff] [blame] | 163 | done |
| 164 | |
Joey Armstrong | 4de98b7 | 2023-02-09 14:51:38 -0500 | [diff] [blame] | 165 | ## ----------------------------------------------------------------------- |
| 166 | ## Intent: build multiple versions |
| 167 | ## ----------------------------------------------------------------------- |
| 168 | multiversion: $(venv-activate-script) Makefile | prep $(OTHER_REPO_DOCS) |
| 169 | $(activate)\ |
| 170 | && sphinx-multiversion "$(SOURCEDIR)" "$(BUILDDIR)/multiversion" $(SPHINXOPTS) |
Zack Williams | 16042b6 | 2020-03-29 22:03:16 -0700 | [diff] [blame] | 171 | cp "$(SOURCEDIR)/_templates/meta_refresh.html" "$(BUILDDIR)/multiversion/index.html" |
Zack Williams | 88df474 | 2019-12-20 08:24:47 -0700 | [diff] [blame] | 172 | |
Joey Armstrong | 4de98b7 | 2023-02-09 14:51:38 -0500 | [diff] [blame] | 173 | ## ----------------------------------------------------------------------- |
| 174 | ## Intent: used in sphinx-multiversion to properly link |
| 175 | ## ----------------------------------------------------------------------- |
Zack Williams | 16042b6 | 2020-03-29 22:03:16 -0700 | [diff] [blame] | 176 | prep: | $(OTHER_REPO_DOCS) $(STATIC_DOCS) |
Andy Bavier | 5dee6ae | 2020-01-29 16:03:40 -0700 | [diff] [blame] | 177 | |
Joey Armstrong | 4de98b7 | 2023-02-09 14:51:38 -0500 | [diff] [blame] | 178 | ## ----------------------------------------------------------------------- |
| 179 | ## Intent: Forward sphinx supported targets to sphinxbuild. |
| 180 | ## Bridge: legacy makefile wildcard rule forwarded unknown targets to sphinx. |
| 181 | ## library makefiles do more so transfer control only when needed. |
| 182 | ## ----------------------------------------------------------------------- |
Joey Armstrong | 449ce7a | 2023-07-18 18:32:24 -0400 | [diff] [blame^] | 183 | include $(ONF_MAKEDIR)/voltha/docs-catchall-targets.mk |
Joey Armstrong | 4de98b7 | 2023-02-09 14:51:38 -0500 | [diff] [blame] | 184 | $(voltha-docs-catchall): $(venv-activate-script) Makefile | $(OTHER_REPO_DOCS) $(STATIC_DOCS) |
Joey Armstrong | 36592e3 | 2022-11-28 09:00:28 -0500 | [diff] [blame] | 185 | @echo " ** CATCHALL: $@" |
Joey Armstrong | 4de98b7 | 2023-02-09 14:51:38 -0500 | [diff] [blame] | 186 | $(activate)\ |
| 187 | && $(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) |
Joey Armstrong | 36592e3 | 2022-11-28 09:00:28 -0500 | [diff] [blame] | 188 | |
Joey Armstrong | a8bc8e1 | 2022-12-04 07:06:59 -0500 | [diff] [blame] | 189 | ## ----------------------------------------------------------------------- |
Joey Armstrong | 4de98b7 | 2023-02-09 14:51:38 -0500 | [diff] [blame] | 190 | ## Intent: Display makefile target help |
| 191 | ## ----------------------------------------------------------------------- |
| 192 | help :: $(venv-activate-script) |
| 193 | @ echo |
| 194 | $(HIDE)$(activate) \ |
| 195 | && $(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) |
| 196 | |
| 197 | ## ----------------------------------------------------------------------- |
Joey Armstrong | 924f3cb | 2023-06-05 15:21:51 -0400 | [diff] [blame] | 198 | ## Intent: Display WARNINGS buried in sphinx output |
| 199 | ## ----------------------------------------------------------------------- |
| 200 | warnings-log := warnings.log |
Joey Armstrong | 4f93b76 | 2023-06-06 08:36:02 -0400 | [diff] [blame] | 201 | warnings: sterile |
Joey Armstrong | 924f3cb | 2023-06-05 15:21:51 -0400 | [diff] [blame] | 202 | $(MAKE) html 2>&1 \ |
| 203 | | sed -e 's@\([Ww][Aa][Rr][Nn][Ii][Nn][Gg]\)@\n\1@g' \ |
| 204 | > "$(warnings-log)" |
Joey Armstrong | 4f93b76 | 2023-06-06 08:36:02 -0400 | [diff] [blame] | 205 | grep 'WARNING' $(warnings-log) |
Joey Armstrong | 924f3cb | 2023-06-05 15:21:51 -0400 | [diff] [blame] | 206 | |
Joey Armstrong | 4f93b76 | 2023-06-06 08:36:02 -0400 | [diff] [blame] | 207 | ## ----------------------------------------------------------------------- |
| 208 | ## Intent: Summarize linkcheck failures |
| 209 | ## ----------------------------------------------------------------------- |
| 210 | .PHONY: broken-log |
| 211 | broken-log := broken.log |
| 212 | broken-log : sterile |
| 213 | $(MAKE) linkcheck 2>&1 | tee "$(broken-log)" |
| 214 | ! grep broken "$(broken-log)" |
| 215 | grep -i error _build/linkcheck/output.txt |
| 216 | |
| 217 | ## ----------------------------------------------------------------------- |
| 218 | ## Intent: |
| 219 | ## ----------------------------------------------------------------------- |
Joey Armstrong | 924f3cb | 2023-06-05 15:21:51 -0400 | [diff] [blame] | 220 | clean:: |
Joey Armstrong | 4f93b76 | 2023-06-06 08:36:02 -0400 | [diff] [blame] | 221 | $(RM) $(broken-log) |
Joey Armstrong | 924f3cb | 2023-06-05 15:21:51 -0400 | [diff] [blame] | 222 | $(RM) $(warnings-log) |
| 223 | |
Joey Armstrong | 4f93b76 | 2023-06-06 08:36:02 -0400 | [diff] [blame] | 224 | ## ----------------------------------------------------------------------- |
| 225 | ## Intent: |
| 226 | ## ----------------------------------------------------------------------- |
Joey Armstrong | 924f3cb | 2023-06-05 15:21:51 -0400 | [diff] [blame] | 227 | help :: |
| 228 | @echo " warnings Display WARNING strings buried in sphinx output" |
| 229 | |
| 230 | ## ----------------------------------------------------------------------- |
Joey Armstrong | 4de98b7 | 2023-02-09 14:51:38 -0500 | [diff] [blame] | 231 | ## Intent: Display make hel footer |
Joey Armstrong | a8bc8e1 | 2022-12-04 07:06:59 -0500 | [diff] [blame] | 232 | ## ----------------------------------------------------------------------- |
Joey Armstrong | 449ce7a | 2023-07-18 18:32:24 -0400 | [diff] [blame^] | 233 | include $(ONF_MAKEDIR)/help/trailer.mk |
Joey Armstrong | 36592e3 | 2022-11-28 09:00:28 -0500 | [diff] [blame] | 234 | |
| 235 | # [EOF] |