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