blob: cb8ee1b9e10745115f0347aa703f01777e16a1ce [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
Eric Ballfc4ad7a2025-02-05 17:22:21 -080049OTHER_REPO_DOCS ?= bbsim ofagent-go openolt voltctl voltha-openolt-adapter voltha-openonu-adapter-go voltha-protos device-management-interface voltha-helm-charts
50# Temporarily disabled: cord-tester voltha-system-tests
Zack Williams88df4742019-12-20 08:24:47 -070051
Joey Armstrong36592e32022-11-28 09:00:28 -050052ifdef NO_OTHER_REPO_DOCS
53 # Inhibit pulling in external repos.
54 # python 3.10+ patching not supported by all repos yet.
55 OTHER_REPO_DOCS := $(null)
56endif
57
Zack Williams16042b62020-03-29 22:03:16 -070058# Static docs, built by other means (usually robot framework)
Eric Ballfc4ad7a2025-02-05 17:22:21 -080059# STATIC_DOCS := _static/voltha-system-tests _static/cord-tester
Zack Williams16042b62020-03-29 22:03:16 -070060
Joey Armstrong4de98b72023-02-09 14:51:38 -050061# Why is existing source Makefile PHONY (?)
Zack Williams88df4742019-12-20 08:24:47 -070062.PHONY: help test lint reload Makefile prep
Zack Williams071eda22019-05-15 18:19:51 -070063
Joey Armstrong4de98b72023-02-09 14:51:38 -050064## -----------------------------------------------------------------------
Joey Armstrong721519c2023-11-13 15:30:54 -050065## Intent: Display makefile target help
66## -----------------------------------------------------------------------
67help :: help-targets-main
68help-verbose :: help-targets-sphinx
69
70## -----------------------------------------------------------------------
Joey Armstrong4de98b72023-02-09 14:51:38 -050071## Intent: Real time viewing, dynamically generate and reload document
72## changes for web browser viewing.
73## Usage:
74## make reload
75## -----------------------------------------------------------------------
Eric Ballfc4ad7a2025-02-05 17:22:21 -080076reload: $(venv-activate-script)
Joey Armstrong4de98b72023-02-09 14:51:38 -050077 $(activate) && sphinx-reload $(SOURCEDIR)
Zack Williams071eda22019-05-15 18:19:51 -070078
Joey Armstrong8d62cd92022-12-22 13:53:48 -050079## -----------------------------------------------------------------------
80## Intent: lint and link verification. linkcheck is part of sphinx
Joey Armstrong64b82492023-06-01 17:34:39 -040081## See Also: make test-errors
Joey Armstrong8d62cd92022-12-22 13:53:48 -050082## -----------------------------------------------------------------------
Zack Williams071eda22019-05-15 18:19:51 -070083test: lint linkcheck
Joey Armstronga8bc8e12022-12-04 07:06:59 -050084
Joey Armstrong50895b82023-09-14 16:44:28 -040085# [TODO] relocate into repo:onf-make/
Eric Ballfc4ad7a2025-02-05 17:22:21 -080086lint : $(venv-activate-script)
87linkcheck : $(venv-activate-script)
Joey Armstrong50895b82023-09-14 16:44:28 -040088
Joey Armstrong8d62cd92022-12-22 13:53:48 -050089## -----------------------------------------------------------------------
90## Intent: Exercise all generation targets
Joey Armstrong4de98b72023-02-09 14:51:38 -050091## Bridge: library workaround to support legacy targets
Joey Armstrong8d62cd92022-12-22 13:53:48 -050092## -----------------------------------------------------------------------
93test-all-targets += html
94test-all-targets += coverage
95# test-all-targets += changes
96# test-all-targets += info
97test-all-targets += man
98test-all-targe4ts += text
99# test-all-targets += latex
100
Joey Armstrong8d62cd92022-12-22 13:53:48 -0500101test-all : test
102 $(MAKE) $(test-all-targets)
103
Joey Armstrong36592e32022-11-28 09:00:28 -0500104# doctest
105# coverage
106# linkcheck
Zack Williams071eda22019-05-15 18:19:51 -0700107
Joey Armstrong0cbee512023-10-18 15:39:24 -0400108# -----------------------------------------------------------------------
Zack Williams071eda22019-05-15 18:19:51 -0700109# currently not enabled, should be added to lint target
Joey Armstrong0cbee512023-10-18 15:39:24 -0400110# [TODO] Create repo:onf-make/makefiles/lint/mdl
111# -----------------------------------------------------------------------
Zack Williams071eda22019-05-15 18:19:51 -0700112LINT_STYLE ?= mdl_strict.rb
113md-lint: | $(OTHER_REPO_DOCS)
114 @echo "markdownlint(mdl) version: `mdl --version`"
115 @echo "style config:"
116 @echo "---"
117 @cat $(LINT_STYLE)
118 @echo "---"
Joey Armstrong4de98b72023-02-09 14:51:38 -0500119 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 -0700120
121# clean up
Joey Armstrong64b82492023-06-01 17:34:39 -0400122clean ::
Joey Armstrong36592e32022-11-28 09:00:28 -0500123 $(RM) -r $(BUILDDIR) $(OTHER_REPO_DOCS) $(STATIC_DOCS)
Zack Williams071eda22019-05-15 18:19:51 -0700124
Joey Armstrong4de98b72023-02-09 14:51:38 -0500125clean-all sterile :: clean
126 $(RM) -r $(venv-activate-script) repos
Zack Williams071eda22019-05-15 18:19:51 -0700127
Zack Williams071eda22019-05-15 18:19:51 -0700128# checkout the repos inside repos/ dir
129repos:
130 mkdir repos
131
132# build directory paths in repos/* to perform 'git clone <repo>' into
133CHECKOUT_REPOS = $(foreach repo,$(OTHER_REPO_DOCS),repos/$(repo))
134
135# Host holding the git server
136REPO_HOST ?= https://gerrit.opencord.org
137
138# For QA patchset validation - set SKIP_CHECKOUT to the repo name and
139# pre-populate it under repos/ with the specific commit to being validated
140SKIP_CHECKOUT ?=
141
Zack Williams88df4742019-12-20 08:24:47 -0700142# clone (only if doesn't exist)
Zack Williams071eda22019-05-15 18:19:51 -0700143$(CHECKOUT_REPOS): | repos
Zack Williams071eda22019-05-15 18:19:51 -0700144 if [ ! -d '$@' ] ;\
145 then git clone $(REPO_HOST)/$(@F) $@ ;\
Zack Williams071eda22019-05-15 18:19:51 -0700146 fi
147
Joey Armstrong4de98b72023-02-09 14:51:38 -0500148## -----------------------------------------------------------------------
149## Intent: checkout correct ref if not under test, then copy
150## subdirectories into main docs dir
151## -----------------------------------------------------------------------
Zack Williams071eda22019-05-15 18:19:51 -0700152$(OTHER_REPO_DOCS): | $(CHECKOUT_REPOS)
Zack Williams88df4742019-12-20 08:24:47 -0700153 if [ "$(SKIP_CHECKOUT)" != "$@" ] ;\
154 then GIT_REF=`grep '^$@ ' git_refs | awk '{print $$3}'` ;\
Zack Williams6c1703f2019-12-20 15:31:58 -0700155 cd "repos/$@" && git checkout $$GIT_REF ;\
Zack Williams88df4742019-12-20 08:24:47 -0700156 fi
Zack Williams17e34022019-12-20 13:51:54 -0700157 GIT_SUBDIR=`grep '^$@ ' git_refs | awk '{print $$2}'` ;\
Zack Williams33085522020-02-28 11:41:01 -0700158 cp -r repos/$(@)$$GIT_SUBDIR $@ ;\
Zack Williams071eda22019-05-15 18:19:51 -0700159
Eric Ballfc4ad7a2025-02-05 17:22:21 -0800160# # Build Robot documentation in voltha-system-tests and copy it into _static.
161# _static/voltha-system-tests: | $(OTHER_REPO_DOCS)
162# make -C voltha-system-tests gendocs
163# mkdir -p $@
164# cp -r voltha-system-tests/gendocs/* $@
165#
166# # Build Robot documentation in cord-tester and copy it into _static.
167# _static/cord-tester: | $(OTHER_REPO_DOCS)
168# make -C cord-tester gendocs
169# mkdir -p $@
170# cp -r cord-tester/gendocs/* $@
Andy Bavier39d67b12020-02-27 16:08:52 -0700171
Joey Armstrong4de98b72023-02-09 14:51:38 -0500172## -----------------------------------------------------------------------
173## Intent: generate a list of git checksums suitable for updating git_refs
174## -----------------------------------------------------------------------
Zack Williams071eda22019-05-15 18:19:51 -0700175freeze: repos
176 @for repo in $(OTHER_REPO_DOCS) ; do \
177 GIT_SUBDIR=`grep "^$$repo " git_refs | awk '{print $$2}'` ;\
Zack Williams6c1703f2019-12-20 15:31:58 -0700178 cd "repos/$$repo" > /dev/null ;\
Zack Williams071eda22019-05-15 18:19:51 -0700179 HEAD_SHA=`git rev-parse HEAD` ;\
180 printf "%-24s %-8s %-40s\n" $$repo $$GIT_SUBDIR $$HEAD_SHA ;\
Zack Williams6c1703f2019-12-20 15:31:58 -0700181 cd ../.. ;\
Zack Williams071eda22019-05-15 18:19:51 -0700182 done
183
Joey Armstrong4de98b72023-02-09 14:51:38 -0500184## -----------------------------------------------------------------------
185## Intent: build multiple versions
186## -----------------------------------------------------------------------
Eric Ballfc4ad7a2025-02-05 17:22:21 -0800187multiversion: $(venv-activate-script) Makefile | prep $(OTHER_REPO_DOCS)
Joey Armstrong4de98b72023-02-09 14:51:38 -0500188 $(activate)\
189 && sphinx-multiversion "$(SOURCEDIR)" "$(BUILDDIR)/multiversion" $(SPHINXOPTS)
Zack Williams16042b62020-03-29 22:03:16 -0700190 cp "$(SOURCEDIR)/_templates/meta_refresh.html" "$(BUILDDIR)/multiversion/index.html"
Zack Williams88df4742019-12-20 08:24:47 -0700191
Joey Armstrong4de98b72023-02-09 14:51:38 -0500192## -----------------------------------------------------------------------
193## Intent: used in sphinx-multiversion to properly link
194## -----------------------------------------------------------------------
Zack Williams16042b62020-03-29 22:03:16 -0700195prep: | $(OTHER_REPO_DOCS) $(STATIC_DOCS)
Andy Bavier5dee6ae2020-01-29 16:03:40 -0700196
Joey Armstrong4de98b72023-02-09 14:51:38 -0500197## -----------------------------------------------------------------------
198## Intent: Forward sphinx supported targets to sphinxbuild.
199## Bridge: legacy makefile wildcard rule forwarded unknown targets to sphinx.
200## library makefiles do more so transfer control only when needed.
201## -----------------------------------------------------------------------
Joey Armstrong449ce7a2023-07-18 18:32:24 -0400202include $(ONF_MAKEDIR)/voltha/docs-catchall-targets.mk
Joey Armstrong7be65812023-09-29 18:35:31 -0400203voltha-docs-catchall : $(voltha-docs-catchall)
Eric Ballfc4ad7a2025-02-05 17:22:21 -0800204$(voltha-docs-catchall): $(venv-activate-script) Makefile | $(OTHER_REPO_DOCS) $(STATIC_DOCS)
Joey Armstrong36592e32022-11-28 09:00:28 -0500205 @echo " ** CATCHALL: $@"
Joey Armstrong4de98b72023-02-09 14:51:38 -0500206 $(activate)\
207 && $(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
Joey Armstrong36592e32022-11-28 09:00:28 -0500208
Joey Armstronga8bc8e12022-12-04 07:06:59 -0500209## -----------------------------------------------------------------------
Joey Armstrong4de98b72023-02-09 14:51:38 -0500210## Intent: Display makefile target help
211## -----------------------------------------------------------------------
Eric Ballfc4ad7a2025-02-05 17:22:21 -0800212help-targets-sphinx : $(venv-activate-script)
Joey Armstrong4de98b72023-02-09 14:51:38 -0500213 @ echo
Joey Armstrong721519c2023-11-13 15:30:54 -0500214 @echo '[HELP: Sphinx]'
Joey Armstrong4de98b72023-02-09 14:51:38 -0500215 $(HIDE)$(activate) \
216 && $(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
217
218## -----------------------------------------------------------------------
Joey Armstrong924f3cb2023-06-05 15:21:51 -0400219## Intent: Display WARNINGS buried in sphinx output
220## -----------------------------------------------------------------------
221warnings-log := warnings.log
Joey Armstrong4f93b762023-06-06 08:36:02 -0400222warnings: sterile
Joey Armstrong924f3cb2023-06-05 15:21:51 -0400223 $(MAKE) html 2>&1 \
224 | sed -e 's@\([Ww][Aa][Rr][Nn][Ii][Nn][Gg]\)@\n\1@g' \
225 > "$(warnings-log)"
Joey Armstrong4f93b762023-06-06 08:36:02 -0400226 grep 'WARNING' $(warnings-log)
Joey Armstrong924f3cb2023-06-05 15:21:51 -0400227
Joey Armstrong4f93b762023-06-06 08:36:02 -0400228## -----------------------------------------------------------------------
229## Intent: Summarize linkcheck failures
230## -----------------------------------------------------------------------
231.PHONY: broken-log
232broken-log := broken.log
233broken-log : sterile
234 $(MAKE) linkcheck 2>&1 | tee "$(broken-log)"
235 ! grep broken "$(broken-log)"
236 grep -i error _build/linkcheck/output.txt
237
238## -----------------------------------------------------------------------
Joey Armstronge03bc602024-02-09 17:26:27 -0500239## Intent: Summarize linkcheck failures
240## -----------------------------------------------------------------------
241.PHONY: lint-doc8-debug
242lint-doc8-debug : sterile
243 $(HIDE) @echo "Searching for cryptic failures"
244 -grep -i 'X <' release_notes/voltha_2.12.rst | grep -v '`__'
245
246## -----------------------------------------------------------------------
Joey Armstrong4f93b762023-06-06 08:36:02 -0400247## Intent:
248## -----------------------------------------------------------------------
Joey Armstrong924f3cb2023-06-05 15:21:51 -0400249clean::
Joey Armstrong4f93b762023-06-06 08:36:02 -0400250 $(RM) $(broken-log)
Joey Armstrong924f3cb2023-06-05 15:21:51 -0400251 $(RM) $(warnings-log)
252
Joey Armstrong4f93b762023-06-06 08:36:02 -0400253## -----------------------------------------------------------------------
254## Intent:
255## -----------------------------------------------------------------------
Joey Armstrong721519c2023-11-13 15:30:54 -0500256help :: help-targets-main
257help-targets-main :
258
259 @echo
260 @echo '[HELP]'
261 @printf ' %-30.30s %s\n' 'help' \
262 'Summary makefile target help'
263 @printf ' %-30.30s %s\n' 'help-verbose' \
264 'Extended makefile target help'
265
266 @echo
Joey Armstrong9f7c57c2024-05-03 18:29:30 -0400267 @echo '[INIT]'
Joey Armstrong721519c2023-11-13 15:30:54 -0500268 @printf ' %-30.30s %s\n' 'init' \
269 'Alias for git-submodules'
270 @printf ' %-30.30s %s\n' 'git-submodules' \
271 'Checkout external dependent repositories'
272
273 @echo
274 @echo '[TEST: Failures]'
275 @printf ' %-30.30s %s\n' 'broken' \
276 'Display broken URLs detected in linkcheck output'
277 @printf ' %-30.30s %s\n' 'warnings' \
278 'Display WARNING strings buried in sphinx output'
279
280## -----------------------------------------------------------------------
281## Intent: Checkout external repository dependencies
282## -----------------------------------------------------------------------
283init :: git-submodules
284
285git-submodules:
286 git submodule update --init --recursive
Joey Armstrong924f3cb2023-06-05 15:21:51 -0400287
288## -----------------------------------------------------------------------
Joey Armstrong9f7c57c2024-05-03 18:29:30 -0400289## Intent: Display make help footer
Joey Armstronga8bc8e12022-12-04 07:06:59 -0500290## -----------------------------------------------------------------------
Joey Armstrong449ce7a2023-07-18 18:32:24 -0400291include $(ONF_MAKEDIR)/help/trailer.mk
Joey Armstrong36592e32022-11-28 09:00:28 -0500292
293# [EOF]