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