blob: fd90308cded74dbc89a085dac29dd97d91fc91e9 [file] [log] [blame]
Joey Armstrong36592e32022-11-28 09:00:28 -05001# -*- makefile -*-
2# -----------------------------------------------------------------------
Eric Ball624906c2025-03-28 18:14:55 -07003# Copyright 2022-2025 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# -----------------------------------------------------------------------
Eric Ball624906c2025-03-28 18:14:55 -070017# SPDX-FileCopyrightText: 2022-2025 Open Networking Foundation Contributors
Joey Armstrong9f7c57c2024-05-03 18:29:30 -040018# 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 Armstrong36592e32022-11-28 09:00:28 -050028##--------------------##
29##---] INCLUDES [---##
30##--------------------##
Eric Ball69713112025-04-02 12:11:47 -070031include makefiles/include.mk
Zack Williams071eda22019-05-15 18:19:51 -070032
33# You can set these variables from the command line.
34SPHINXOPTS ?=
35SPHINXBUILD ?= sphinx-build
36SOURCEDIR ?= .
37BUILDDIR ?= _build
Eric Balla2761a72025-03-31 15:06:54 -070038
39# If running on Jenkins, we need to pick up the GERRIT_BRANCH env var.
40# Otherwise, we can simply use the current branch.
41ifdef GERRIT_BRANCH
42 BRANCH := $(GERRIT_BRANCH)
43else
44 BRANCH := $(shell git branch --show-current)
45endif
Zack Williams071eda22019-05-15 18:19:51 -070046
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 Ball69713112025-04-02 12:11:47 -070049OTHER_REPO_DOCS ?= bbsim ofagent-go openolt voltctl voltha-openolt-adapter voltha-openonu-adapter-go voltha-protos device-management-interface voltha-helm-charts voltha-system-tests cord-tester
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)
Eric Ball69713112025-04-02 12:11:47 -070058STATIC_DOCS := _static/voltha-system-tests _static/cord-tester
Zack Williams16042b62020-03-29 22:03:16 -070059
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## -----------------------------------------------------------------------
Eric Ballfc4ad7a2025-02-05 17:22:21 -080075reload: $(venv-activate-script)
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/
Eric Ballfc4ad7a2025-02-05 17:22:21 -080085lint : $(venv-activate-script)
86linkcheck : $(venv-activate-script)
Joey Armstrong50895b82023-09-14 16:44:28 -040087
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
Eric Ball69713112025-04-02 12:11:47 -0700159# 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
165# 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/* $@
Andy Bavier39d67b12020-02-27 16:08:52 -0700170
Joey Armstrong4de98b72023-02-09 14:51:38 -0500171## -----------------------------------------------------------------------
Eric Ball624906c2025-03-28 18:14:55 -0700172## Intent: Build docs for the current branch
173## -----------------------------------------------------------------------
174docs: $(venv-activate-script) Makefile | prep $(OTHER_REPO_DOCS)
175 $(activate) && sphinx-build "$(SOURCEDIR)" "$(BUILDDIR)/$(BRANCH)" $(SPHINXOPTS)
176ifeq ($(BRANCH),master)
177 cp "$(SOURCEDIR)/_templates/meta_refresh.html" "$(BUILDDIR)/index.html"
178endif
179
180## -----------------------------------------------------------------------
Joey Armstrong4de98b72023-02-09 14:51:38 -0500181## Intent: generate a list of git checksums suitable for updating git_refs
182## -----------------------------------------------------------------------
Zack Williams071eda22019-05-15 18:19:51 -0700183freeze: repos
184 @for repo in $(OTHER_REPO_DOCS) ; do \
185 GIT_SUBDIR=`grep "^$$repo " git_refs | awk '{print $$2}'` ;\
Zack Williams6c1703f2019-12-20 15:31:58 -0700186 cd "repos/$$repo" > /dev/null ;\
Zack Williams071eda22019-05-15 18:19:51 -0700187 HEAD_SHA=`git rev-parse HEAD` ;\
188 printf "%-24s %-8s %-40s\n" $$repo $$GIT_SUBDIR $$HEAD_SHA ;\
Zack Williams6c1703f2019-12-20 15:31:58 -0700189 cd ../.. ;\
Zack Williams071eda22019-05-15 18:19:51 -0700190 done
191
Joey Armstrong4de98b72023-02-09 14:51:38 -0500192## -----------------------------------------------------------------------
193## Intent: build multiple versions
194## -----------------------------------------------------------------------
Eric Ballfc4ad7a2025-02-05 17:22:21 -0800195multiversion: $(venv-activate-script) Makefile | prep $(OTHER_REPO_DOCS)
Joey Armstrong4de98b72023-02-09 14:51:38 -0500196 $(activate)\
197 && sphinx-multiversion "$(SOURCEDIR)" "$(BUILDDIR)/multiversion" $(SPHINXOPTS)
Zack Williams16042b62020-03-29 22:03:16 -0700198 cp "$(SOURCEDIR)/_templates/meta_refresh.html" "$(BUILDDIR)/multiversion/index.html"
Zack Williams88df4742019-12-20 08:24:47 -0700199
Joey Armstrong4de98b72023-02-09 14:51:38 -0500200## -----------------------------------------------------------------------
201## Intent: used in sphinx-multiversion to properly link
202## -----------------------------------------------------------------------
Zack Williams16042b62020-03-29 22:03:16 -0700203prep: | $(OTHER_REPO_DOCS) $(STATIC_DOCS)
Andy Bavier5dee6ae2020-01-29 16:03:40 -0700204
Joey Armstrong4de98b72023-02-09 14:51:38 -0500205## -----------------------------------------------------------------------
Joey Armstrong4de98b72023-02-09 14:51:38 -0500206## Intent: Display makefile target help
207## -----------------------------------------------------------------------
Eric Ballfc4ad7a2025-02-05 17:22:21 -0800208help-targets-sphinx : $(venv-activate-script)
Joey Armstrong4de98b72023-02-09 14:51:38 -0500209 @ echo
Joey Armstrong721519c2023-11-13 15:30:54 -0500210 @echo '[HELP: Sphinx]'
Joey Armstrong4de98b72023-02-09 14:51:38 -0500211 $(HIDE)$(activate) \
212 && $(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
213
214## -----------------------------------------------------------------------
Joey Armstrong924f3cb2023-06-05 15:21:51 -0400215## Intent: Display WARNINGS buried in sphinx output
216## -----------------------------------------------------------------------
217warnings-log := warnings.log
Joey Armstrong4f93b762023-06-06 08:36:02 -0400218warnings: sterile
Joey Armstrong924f3cb2023-06-05 15:21:51 -0400219 $(MAKE) html 2>&1 \
220 | sed -e 's@\([Ww][Aa][Rr][Nn][Ii][Nn][Gg]\)@\n\1@g' \
221 > "$(warnings-log)"
Joey Armstrong4f93b762023-06-06 08:36:02 -0400222 grep 'WARNING' $(warnings-log)
Joey Armstrong924f3cb2023-06-05 15:21:51 -0400223
Joey Armstrong4f93b762023-06-06 08:36:02 -0400224## -----------------------------------------------------------------------
225## Intent: Summarize linkcheck failures
226## -----------------------------------------------------------------------
227.PHONY: broken-log
228broken-log := broken.log
229broken-log : sterile
230 $(MAKE) linkcheck 2>&1 | tee "$(broken-log)"
231 ! grep broken "$(broken-log)"
232 grep -i error _build/linkcheck/output.txt
233
234## -----------------------------------------------------------------------
Joey Armstronge03bc602024-02-09 17:26:27 -0500235## Intent: Summarize linkcheck failures
236## -----------------------------------------------------------------------
237.PHONY: lint-doc8-debug
238lint-doc8-debug : sterile
239 $(HIDE) @echo "Searching for cryptic failures"
240 -grep -i 'X <' release_notes/voltha_2.12.rst | grep -v '`__'
241
242## -----------------------------------------------------------------------
Joey Armstrong4f93b762023-06-06 08:36:02 -0400243## Intent:
244## -----------------------------------------------------------------------
Joey Armstrong924f3cb2023-06-05 15:21:51 -0400245clean::
Joey Armstrong4f93b762023-06-06 08:36:02 -0400246 $(RM) $(broken-log)
Joey Armstrong924f3cb2023-06-05 15:21:51 -0400247 $(RM) $(warnings-log)
248
Joey Armstrong4f93b762023-06-06 08:36:02 -0400249## -----------------------------------------------------------------------
250## Intent:
251## -----------------------------------------------------------------------
Joey Armstrong721519c2023-11-13 15:30:54 -0500252help :: help-targets-main
253help-targets-main :
254
255 @echo
256 @echo '[HELP]'
257 @printf ' %-30.30s %s\n' 'help' \
258 'Summary makefile target help'
259 @printf ' %-30.30s %s\n' 'help-verbose' \
260 'Extended makefile target help'
261
262 @echo
Joey Armstrong9f7c57c2024-05-03 18:29:30 -0400263 @echo '[INIT]'
Joey Armstrong721519c2023-11-13 15:30:54 -0500264 @printf ' %-30.30s %s\n' 'init' \
265 'Alias for git-submodules'
266 @printf ' %-30.30s %s\n' 'git-submodules' \
267 'Checkout external dependent repositories'
268
269 @echo
270 @echo '[TEST: Failures]'
271 @printf ' %-30.30s %s\n' 'broken' \
272 'Display broken URLs detected in linkcheck output'
273 @printf ' %-30.30s %s\n' 'warnings' \
274 'Display WARNING strings buried in sphinx output'
275
276## -----------------------------------------------------------------------
Joey Armstrong9f7c57c2024-05-03 18:29:30 -0400277## Intent: Display make help footer
Joey Armstronga8bc8e12022-12-04 07:06:59 -0500278## -----------------------------------------------------------------------
Eric Ball69713112025-04-02 12:11:47 -0700279include makefiles-orig/help/trailer.mk
Joey Armstrong36592e32022-11-28 09:00:28 -0500280
281# [EOF]