blob: 079d82eb51411170382838d6a8d4acb3a3b6c32b [file] [log] [blame]
Joey Armstrong36592e32022-11-28 09:00:28 -05001# -*- makefile -*-
2# -----------------------------------------------------------------------
Joey Armstrong9f7c57c2024-05-03 18:29:30 -04003# Copyright 2022-2024 Open Networking Foundation Contributors
Joey Armstrong36592e32022-11-28 09:00:28 -05004#
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# -----------------------------------------------------------------------
Joey Armstrong9f7c57c2024-05-03 18:29:30 -040017# SPDX-FileCopyrightText: 2022-2024 Open Networking Foundation Contributors
18# SPDX-License-Identifier: Apache-2.0
19# -----------------------------------------------------------------------
20# Intent: Makefile for Sphinx documentation
21# -----------------------------------------------------------------------
Zack Williams071eda22019-05-15 18:19:51 -070022
Joey Armstrong9f7c57c2024-05-03 18:29:30 -040023ifndef .DEFAULT_GOAL
Joey Armstronge16037a2024-06-28 15:36:09 -040024 export .DEFAULT_GOAL := help # no->(?=), help target evaluated late
Joey Armstrong9f7c57c2024-05-03 18:29:30 -040025endif
26MAKECMDGOALS ?= help
Joey Armstrong36592e32022-11-28 09:00:28 -050027
Joey Armstrong9f7c57c2024-05-03 18:29:30 -040028$(if $(findstring disabled-joey,$(USER)),\
29 $(eval USE_LF_MK := 1)) # special snowflake
Joey Armstrong36592e32022-11-28 09:00:28 -050030
31##--------------------##
32##---] INCLUDES [---##
33##--------------------##
Joey Armstrong9f7c57c2024-05-03 18:29:30 -040034ifdef USE_LF_MK
35 include lf/include.mk
36else
Joey Armstronge16037a2024-06-28 15:36:09 -040037 venv-name ?= .venv
Joey Armstrong9f7c57c2024-05-03 18:29:30 -040038 include lf/transition.mk
39endif # ifdef USE_LF_MK
Zack Williams071eda22019-05-15 18:19:51 -070040
41# You can set these variables from the command line.
42SPHINXOPTS ?=
43SPHINXBUILD ?= sphinx-build
44SOURCEDIR ?= .
45BUILDDIR ?= _build
46
Zack Williams88df4742019-12-20 08:24:47 -070047# Other repos with documentation to include.
48# edit the `git_refs` file with the commit/tag/branch that you want to use
Andrea Campanellac18d1182021-09-10 12:01:38 +020049OTHER_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 Williams88df4742019-12-20 08:24:47 -070050
Joey Armstrong36592e32022-11-28 09:00:28 -050051ifdef NO_OTHER_REPO_DOCS
52 # Inhibit pulling in external repos.
53 # python 3.10+ patching not supported by all repos yet.
54 OTHER_REPO_DOCS := $(null)
55endif
56
Zack Williams16042b62020-03-29 22:03:16 -070057# Static docs, built by other means (usually robot framework)
58STATIC_DOCS := _static/voltha-system-tests _static/cord-tester
59
Joey Armstrong4de98b72023-02-09 14:51:38 -050060# Why is existing source Makefile PHONY (?)
Zack Williams88df4742019-12-20 08:24:47 -070061.PHONY: help test lint reload Makefile prep
Zack Williams071eda22019-05-15 18:19:51 -070062
Joey Armstrong4de98b72023-02-09 14:51:38 -050063## -----------------------------------------------------------------------
Joey Armstrong721519c2023-11-13 15:30:54 -050064## Intent: Display makefile target help
65## -----------------------------------------------------------------------
66help :: help-targets-main
67help-verbose :: help-targets-sphinx
68
69## -----------------------------------------------------------------------
Joey Armstrong4de98b72023-02-09 14:51:38 -050070## Intent: Real time viewing, dynamically generate and reload document
71## changes for web browser viewing.
72## Usage:
73## make reload
74## -----------------------------------------------------------------------
Joey Armstrong449ce7a2023-07-18 18:32:24 -040075reload: $(venv-activate-patched)
Joey Armstrong4de98b72023-02-09 14:51:38 -050076 $(activate) && sphinx-reload $(SOURCEDIR)
Zack Williams071eda22019-05-15 18:19:51 -070077
Joey Armstrong8d62cd92022-12-22 13:53:48 -050078## -----------------------------------------------------------------------
79## Intent: lint and link verification. linkcheck is part of sphinx
Joey Armstrong64b82492023-06-01 17:34:39 -040080## See Also: make test-errors
Joey Armstrong8d62cd92022-12-22 13:53:48 -050081## -----------------------------------------------------------------------
Zack Williams071eda22019-05-15 18:19:51 -070082test: lint linkcheck
Joey Armstronga8bc8e12022-12-04 07:06:59 -050083
Joey Armstrong50895b82023-09-14 16:44:28 -040084# [TODO] relocate into repo:onf-make/
85lint : $(venv-activate-patched)
86linkcheck : $(venv-activate-patched)
87
Joey Armstrong8d62cd92022-12-22 13:53:48 -050088## -----------------------------------------------------------------------
89## Intent: Exercise all generation targets
Joey Armstrong4de98b72023-02-09 14:51:38 -050090## Bridge: library workaround to support legacy targets
Joey Armstrong8d62cd92022-12-22 13:53:48 -050091## -----------------------------------------------------------------------
92test-all-targets += html
93test-all-targets += coverage
94# test-all-targets += changes
95# test-all-targets += info
96test-all-targets += man
97test-all-targe4ts += text
98# test-all-targets += latex
99
Joey Armstrong8d62cd92022-12-22 13:53:48 -0500100test-all : test
101 $(MAKE) $(test-all-targets)
102
Joey Armstrong36592e32022-11-28 09:00:28 -0500103# doctest
104# coverage
105# linkcheck
Zack Williams071eda22019-05-15 18:19:51 -0700106
Joey Armstrong0cbee512023-10-18 15:39:24 -0400107# -----------------------------------------------------------------------
Zack Williams071eda22019-05-15 18:19:51 -0700108# currently not enabled, should be added to lint target
Joey Armstrong0cbee512023-10-18 15:39:24 -0400109# [TODO] Create repo:onf-make/makefiles/lint/mdl
110# -----------------------------------------------------------------------
Zack Williams071eda22019-05-15 18:19:51 -0700111LINT_STYLE ?= mdl_strict.rb
112md-lint: | $(OTHER_REPO_DOCS)
113 @echo "markdownlint(mdl) version: `mdl --version`"
114 @echo "style config:"
115 @echo "---"
116 @cat $(LINT_STYLE)
117 @echo "---"
Joey Armstrong4de98b72023-02-09 14:51:38 -0500118 mdl -s $(LINT_STYLE) `find -L $(SOURCEDIR) ! -path "./_$(venv-activate-script)/*" ! -path "./_build/*" ! -path "./repos/*" ! -path "*vendor*" -name "*.md"`
Zack Williams071eda22019-05-15 18:19:51 -0700119
120# clean up
Joey Armstrong64b82492023-06-01 17:34:39 -0400121clean ::
Joey Armstrong36592e32022-11-28 09:00:28 -0500122 $(RM) -r $(BUILDDIR) $(OTHER_REPO_DOCS) $(STATIC_DOCS)
Zack Williams071eda22019-05-15 18:19:51 -0700123
Joey Armstrong4de98b72023-02-09 14:51:38 -0500124clean-all sterile :: clean
125 $(RM) -r $(venv-activate-script) repos
Zack Williams071eda22019-05-15 18:19:51 -0700126
Zack Williams071eda22019-05-15 18:19:51 -0700127# checkout the repos inside repos/ dir
128repos:
129 mkdir repos
130
131# build directory paths in repos/* to perform 'git clone <repo>' into
132CHECKOUT_REPOS = $(foreach repo,$(OTHER_REPO_DOCS),repos/$(repo))
133
134# Host holding the git server
135REPO_HOST ?= https://gerrit.opencord.org
136
137# For QA patchset validation - set SKIP_CHECKOUT to the repo name and
138# pre-populate it under repos/ with the specific commit to being validated
139SKIP_CHECKOUT ?=
140
Zack Williams88df4742019-12-20 08:24:47 -0700141# clone (only if doesn't exist)
Zack Williams071eda22019-05-15 18:19:51 -0700142$(CHECKOUT_REPOS): | repos
Zack Williams071eda22019-05-15 18:19:51 -0700143 if [ ! -d '$@' ] ;\
144 then git clone $(REPO_HOST)/$(@F) $@ ;\
Zack Williams071eda22019-05-15 18:19:51 -0700145 fi
146
Joey Armstrong4de98b72023-02-09 14:51:38 -0500147## -----------------------------------------------------------------------
148## Intent: checkout correct ref if not under test, then copy
149## subdirectories into main docs dir
150## -----------------------------------------------------------------------
Zack Williams071eda22019-05-15 18:19:51 -0700151$(OTHER_REPO_DOCS): | $(CHECKOUT_REPOS)
Zack Williams88df4742019-12-20 08:24:47 -0700152 if [ "$(SKIP_CHECKOUT)" != "$@" ] ;\
153 then GIT_REF=`grep '^$@ ' git_refs | awk '{print $$3}'` ;\
Zack Williams6c1703f2019-12-20 15:31:58 -0700154 cd "repos/$@" && git checkout $$GIT_REF ;\
Zack Williams88df4742019-12-20 08:24:47 -0700155 fi
Zack Williams17e34022019-12-20 13:51:54 -0700156 GIT_SUBDIR=`grep '^$@ ' git_refs | awk '{print $$2}'` ;\
Zack Williams33085522020-02-28 11:41:01 -0700157 cp -r repos/$(@)$$GIT_SUBDIR $@ ;\
Zack Williams071eda22019-05-15 18:19:51 -0700158
Andrea Campanella92bd59b2020-01-30 17:26:32 +0100159# Build Robot documentation in voltha-system-tests and copy it into _static.
160_static/voltha-system-tests: | $(OTHER_REPO_DOCS)
161 make -C voltha-system-tests gendocs
162 mkdir -p $@
163 cp -r voltha-system-tests/gendocs/* $@
164
Andy Bavier39d67b12020-02-27 16:08:52 -0700165# Build Robot documentation in cord-tester and copy it into _static.
166_static/cord-tester: | $(OTHER_REPO_DOCS)
167 make -C cord-tester gendocs
168 mkdir -p $@
169 cp -r cord-tester/gendocs/* $@
170
Joey Armstrong4de98b72023-02-09 14:51:38 -0500171## -----------------------------------------------------------------------
172## Intent: generate a list of git checksums suitable for updating git_refs
173## -----------------------------------------------------------------------
Zack Williams071eda22019-05-15 18:19:51 -0700174freeze: repos
175 @for repo in $(OTHER_REPO_DOCS) ; do \
176 GIT_SUBDIR=`grep "^$$repo " git_refs | awk '{print $$2}'` ;\
Zack Williams6c1703f2019-12-20 15:31:58 -0700177 cd "repos/$$repo" > /dev/null ;\
Zack Williams071eda22019-05-15 18:19:51 -0700178 HEAD_SHA=`git rev-parse HEAD` ;\
179 printf "%-24s %-8s %-40s\n" $$repo $$GIT_SUBDIR $$HEAD_SHA ;\
Zack Williams6c1703f2019-12-20 15:31:58 -0700180 cd ../.. ;\
Zack Williams071eda22019-05-15 18:19:51 -0700181 done
182
Joey Armstrong4de98b72023-02-09 14:51:38 -0500183## -----------------------------------------------------------------------
184## Intent: build multiple versions
185## -----------------------------------------------------------------------
Joey Armstrong7be65812023-09-29 18:35:31 -0400186multiversion: $(venv-activate-patched) Makefile | prep $(OTHER_REPO_DOCS)
Joey Armstrong4de98b72023-02-09 14:51:38 -0500187 $(activate)\
188 && sphinx-multiversion "$(SOURCEDIR)" "$(BUILDDIR)/multiversion" $(SPHINXOPTS)
Zack Williams16042b62020-03-29 22:03:16 -0700189 cp "$(SOURCEDIR)/_templates/meta_refresh.html" "$(BUILDDIR)/multiversion/index.html"
Zack Williams88df4742019-12-20 08:24:47 -0700190
Joey Armstrong4de98b72023-02-09 14:51:38 -0500191## -----------------------------------------------------------------------
192## Intent: used in sphinx-multiversion to properly link
193## -----------------------------------------------------------------------
Zack Williams16042b62020-03-29 22:03:16 -0700194prep: | $(OTHER_REPO_DOCS) $(STATIC_DOCS)
Andy Bavier5dee6ae2020-01-29 16:03:40 -0700195
Joey Armstrong4de98b72023-02-09 14:51:38 -0500196## -----------------------------------------------------------------------
197## Intent: Forward sphinx supported targets to sphinxbuild.
198## Bridge: legacy makefile wildcard rule forwarded unknown targets to sphinx.
199## library makefiles do more so transfer control only when needed.
200## -----------------------------------------------------------------------
Joey Armstrong449ce7a2023-07-18 18:32:24 -0400201include $(ONF_MAKEDIR)/voltha/docs-catchall-targets.mk
Joey Armstrong7be65812023-09-29 18:35:31 -0400202voltha-docs-catchall : $(voltha-docs-catchall)
203$(voltha-docs-catchall): $(venv-activate-patched) Makefile | $(OTHER_REPO_DOCS) $(STATIC_DOCS)
Joey Armstrong36592e32022-11-28 09:00:28 -0500204 @echo " ** CATCHALL: $@"
Joey Armstrong4de98b72023-02-09 14:51:38 -0500205 $(activate)\
206 && $(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
Joey Armstrong36592e32022-11-28 09:00:28 -0500207
Joey Armstronga8bc8e12022-12-04 07:06:59 -0500208## -----------------------------------------------------------------------
Joey Armstrong4de98b72023-02-09 14:51:38 -0500209## Intent: Display makefile target help
210## -----------------------------------------------------------------------
Joey Armstrong721519c2023-11-13 15:30:54 -0500211help-targets-sphinx : $(venv-activate-patched)
Joey Armstrong4de98b72023-02-09 14:51:38 -0500212 @ echo
Joey Armstrong721519c2023-11-13 15:30:54 -0500213 @echo '[HELP: Sphinx]'
Joey Armstrong4de98b72023-02-09 14:51:38 -0500214 $(HIDE)$(activate) \
215 && $(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
216
217## -----------------------------------------------------------------------
Joey Armstrong924f3cb2023-06-05 15:21:51 -0400218## Intent: Display WARNINGS buried in sphinx output
219## -----------------------------------------------------------------------
220warnings-log := warnings.log
Joey Armstrong4f93b762023-06-06 08:36:02 -0400221warnings: sterile
Joey Armstrong924f3cb2023-06-05 15:21:51 -0400222 $(MAKE) html 2>&1 \
223 | sed -e 's@\([Ww][Aa][Rr][Nn][Ii][Nn][Gg]\)@\n\1@g' \
224 > "$(warnings-log)"
Joey Armstrong4f93b762023-06-06 08:36:02 -0400225 grep 'WARNING' $(warnings-log)
Joey Armstrong924f3cb2023-06-05 15:21:51 -0400226
Joey Armstrong4f93b762023-06-06 08:36:02 -0400227## -----------------------------------------------------------------------
228## Intent: Summarize linkcheck failures
229## -----------------------------------------------------------------------
230.PHONY: broken-log
231broken-log := broken.log
232broken-log : sterile
233 $(MAKE) linkcheck 2>&1 | tee "$(broken-log)"
234 ! grep broken "$(broken-log)"
235 grep -i error _build/linkcheck/output.txt
236
237## -----------------------------------------------------------------------
Joey Armstronge03bc602024-02-09 17:26:27 -0500238## Intent: Summarize linkcheck failures
239## -----------------------------------------------------------------------
240.PHONY: lint-doc8-debug
241lint-doc8-debug : sterile
242 $(HIDE) @echo "Searching for cryptic failures"
243 -grep -i 'X <' release_notes/voltha_2.12.rst | grep -v '`__'
244
245## -----------------------------------------------------------------------
Joey Armstrong4f93b762023-06-06 08:36:02 -0400246## Intent:
247## -----------------------------------------------------------------------
Joey Armstrong924f3cb2023-06-05 15:21:51 -0400248clean::
Joey Armstrong4f93b762023-06-06 08:36:02 -0400249 $(RM) $(broken-log)
Joey Armstrong924f3cb2023-06-05 15:21:51 -0400250 $(RM) $(warnings-log)
251
Joey Armstrong4f93b762023-06-06 08:36:02 -0400252## -----------------------------------------------------------------------
253## Intent:
254## -----------------------------------------------------------------------
Joey Armstrong721519c2023-11-13 15:30:54 -0500255help :: help-targets-main
256help-targets-main :
257
258 @echo
259 @echo '[HELP]'
260 @printf ' %-30.30s %s\n' 'help' \
261 'Summary makefile target help'
262 @printf ' %-30.30s %s\n' 'help-verbose' \
263 'Extended makefile target help'
264
265 @echo
Joey Armstrong9f7c57c2024-05-03 18:29:30 -0400266 @echo '[INIT]'
Joey Armstrong721519c2023-11-13 15:30:54 -0500267 @printf ' %-30.30s %s\n' 'init' \
268 'Alias for git-submodules'
269 @printf ' %-30.30s %s\n' 'git-submodules' \
270 'Checkout external dependent repositories'
271
272 @echo
273 @echo '[TEST: Failures]'
274 @printf ' %-30.30s %s\n' 'broken' \
275 'Display broken URLs detected in linkcheck output'
276 @printf ' %-30.30s %s\n' 'warnings' \
277 'Display WARNING strings buried in sphinx output'
278
279## -----------------------------------------------------------------------
280## Intent: Checkout external repository dependencies
281## -----------------------------------------------------------------------
282init :: git-submodules
283
284git-submodules:
285 git submodule update --init --recursive
Joey Armstrong924f3cb2023-06-05 15:21:51 -0400286
287## -----------------------------------------------------------------------
Joey Armstrong9f7c57c2024-05-03 18:29:30 -0400288## Intent: Display make help footer
Joey Armstronga8bc8e12022-12-04 07:06:59 -0500289## -----------------------------------------------------------------------
Joey Armstrong449ce7a2023-07-18 18:32:24 -0400290include $(ONF_MAKEDIR)/help/trailer.mk
Joey Armstrong36592e32022-11-28 09:00:28 -0500291
292# [EOF]