blob: eed77bce1aa8412121becc22b6863ac5e4393913 [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##--------------------##
Joey Armstrong9f7c57c2024-05-03 18:29:30 -040031ifdef USE_LF_MK
32 include lf/include.mk
33else
Joey Armstronge16037a2024-06-28 15:36:09 -040034 venv-name ?= .venv
Joey Armstrong9f7c57c2024-05-03 18:29:30 -040035 include lf/transition.mk
36endif # ifdef USE_LF_MK
Zack Williams071eda22019-05-15 18:19:51 -070037
38# You can set these variables from the command line.
39SPHINXOPTS ?=
40SPHINXBUILD ?= sphinx-build
41SOURCEDIR ?= .
42BUILDDIR ?= _build
Eric Ball624906c2025-03-28 18:14:55 -070043BRANCH ?= $(shell git branch --show-current)
Zack Williams071eda22019-05-15 18:19:51 -070044
Zack Williams88df4742019-12-20 08:24:47 -070045# Other repos with documentation to include.
46# edit the `git_refs` file with the commit/tag/branch that you want to use
Eric Ballfc4ad7a2025-02-05 17:22:21 -080047OTHER_REPO_DOCS ?= bbsim ofagent-go openolt voltctl voltha-openolt-adapter voltha-openonu-adapter-go voltha-protos device-management-interface voltha-helm-charts
48# Temporarily disabled: cord-tester voltha-system-tests
Zack Williams88df4742019-12-20 08:24:47 -070049
Joey Armstrong36592e32022-11-28 09:00:28 -050050ifdef NO_OTHER_REPO_DOCS
51 # Inhibit pulling in external repos.
52 # python 3.10+ patching not supported by all repos yet.
53 OTHER_REPO_DOCS := $(null)
54endif
55
Zack Williams16042b62020-03-29 22:03:16 -070056# Static docs, built by other means (usually robot framework)
Eric Ballfc4ad7a2025-02-05 17:22:21 -080057# STATIC_DOCS := _static/voltha-system-tests _static/cord-tester
Zack Williams16042b62020-03-29 22:03:16 -070058
Joey Armstrong4de98b72023-02-09 14:51:38 -050059# Why is existing source Makefile PHONY (?)
Zack Williams88df4742019-12-20 08:24:47 -070060.PHONY: help test lint reload Makefile prep
Zack Williams071eda22019-05-15 18:19:51 -070061
Joey Armstrong4de98b72023-02-09 14:51:38 -050062## -----------------------------------------------------------------------
Joey Armstrong721519c2023-11-13 15:30:54 -050063## Intent: Display makefile target help
64## -----------------------------------------------------------------------
65help :: help-targets-main
66help-verbose :: help-targets-sphinx
67
68## -----------------------------------------------------------------------
Joey Armstrong4de98b72023-02-09 14:51:38 -050069## Intent: Real time viewing, dynamically generate and reload document
70## changes for web browser viewing.
71## Usage:
72## make reload
73## -----------------------------------------------------------------------
Eric Ballfc4ad7a2025-02-05 17:22:21 -080074reload: $(venv-activate-script)
Joey Armstrong4de98b72023-02-09 14:51:38 -050075 $(activate) && sphinx-reload $(SOURCEDIR)
Zack Williams071eda22019-05-15 18:19:51 -070076
Joey Armstrong8d62cd92022-12-22 13:53:48 -050077## -----------------------------------------------------------------------
78## Intent: lint and link verification. linkcheck is part of sphinx
Joey Armstrong64b82492023-06-01 17:34:39 -040079## See Also: make test-errors
Joey Armstrong8d62cd92022-12-22 13:53:48 -050080## -----------------------------------------------------------------------
Zack Williams071eda22019-05-15 18:19:51 -070081test: lint linkcheck
Joey Armstronga8bc8e12022-12-04 07:06:59 -050082
Joey Armstrong50895b82023-09-14 16:44:28 -040083# [TODO] relocate into repo:onf-make/
Eric Ballfc4ad7a2025-02-05 17:22:21 -080084lint : $(venv-activate-script)
85linkcheck : $(venv-activate-script)
Joey Armstrong50895b82023-09-14 16:44:28 -040086
Joey Armstrong8d62cd92022-12-22 13:53:48 -050087## -----------------------------------------------------------------------
88## Intent: Exercise all generation targets
Joey Armstrong4de98b72023-02-09 14:51:38 -050089## Bridge: library workaround to support legacy targets
Joey Armstrong8d62cd92022-12-22 13:53:48 -050090## -----------------------------------------------------------------------
91test-all-targets += html
92test-all-targets += coverage
93# test-all-targets += changes
94# test-all-targets += info
95test-all-targets += man
96test-all-targe4ts += text
97# test-all-targets += latex
98
Joey Armstrong8d62cd92022-12-22 13:53:48 -050099test-all : test
100 $(MAKE) $(test-all-targets)
101
Joey Armstrong36592e32022-11-28 09:00:28 -0500102# doctest
103# coverage
104# linkcheck
Zack Williams071eda22019-05-15 18:19:51 -0700105
Joey Armstrong0cbee512023-10-18 15:39:24 -0400106# -----------------------------------------------------------------------
Zack Williams071eda22019-05-15 18:19:51 -0700107# currently not enabled, should be added to lint target
Joey Armstrong0cbee512023-10-18 15:39:24 -0400108# [TODO] Create repo:onf-make/makefiles/lint/mdl
109# -----------------------------------------------------------------------
Zack Williams071eda22019-05-15 18:19:51 -0700110LINT_STYLE ?= mdl_strict.rb
111md-lint: | $(OTHER_REPO_DOCS)
112 @echo "markdownlint(mdl) version: `mdl --version`"
113 @echo "style config:"
114 @echo "---"
115 @cat $(LINT_STYLE)
116 @echo "---"
Joey Armstrong4de98b72023-02-09 14:51:38 -0500117 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 -0700118
119# clean up
Joey Armstrong64b82492023-06-01 17:34:39 -0400120clean ::
Joey Armstrong36592e32022-11-28 09:00:28 -0500121 $(RM) -r $(BUILDDIR) $(OTHER_REPO_DOCS) $(STATIC_DOCS)
Zack Williams071eda22019-05-15 18:19:51 -0700122
Joey Armstrong4de98b72023-02-09 14:51:38 -0500123clean-all sterile :: clean
124 $(RM) -r $(venv-activate-script) repos
Zack Williams071eda22019-05-15 18:19:51 -0700125
Zack Williams071eda22019-05-15 18:19:51 -0700126# checkout the repos inside repos/ dir
127repos:
128 mkdir repos
129
130# build directory paths in repos/* to perform 'git clone <repo>' into
131CHECKOUT_REPOS = $(foreach repo,$(OTHER_REPO_DOCS),repos/$(repo))
132
133# Host holding the git server
134REPO_HOST ?= https://gerrit.opencord.org
135
136# For QA patchset validation - set SKIP_CHECKOUT to the repo name and
137# pre-populate it under repos/ with the specific commit to being validated
138SKIP_CHECKOUT ?=
139
Zack Williams88df4742019-12-20 08:24:47 -0700140# clone (only if doesn't exist)
Zack Williams071eda22019-05-15 18:19:51 -0700141$(CHECKOUT_REPOS): | repos
Zack Williams071eda22019-05-15 18:19:51 -0700142 if [ ! -d '$@' ] ;\
143 then git clone $(REPO_HOST)/$(@F) $@ ;\
Zack Williams071eda22019-05-15 18:19:51 -0700144 fi
145
Joey Armstrong4de98b72023-02-09 14:51:38 -0500146## -----------------------------------------------------------------------
147## Intent: checkout correct ref if not under test, then copy
148## subdirectories into main docs dir
149## -----------------------------------------------------------------------
Zack Williams071eda22019-05-15 18:19:51 -0700150$(OTHER_REPO_DOCS): | $(CHECKOUT_REPOS)
Zack Williams88df4742019-12-20 08:24:47 -0700151 if [ "$(SKIP_CHECKOUT)" != "$@" ] ;\
152 then GIT_REF=`grep '^$@ ' git_refs | awk '{print $$3}'` ;\
Zack Williams6c1703f2019-12-20 15:31:58 -0700153 cd "repos/$@" && git checkout $$GIT_REF ;\
Zack Williams88df4742019-12-20 08:24:47 -0700154 fi
Zack Williams17e34022019-12-20 13:51:54 -0700155 GIT_SUBDIR=`grep '^$@ ' git_refs | awk '{print $$2}'` ;\
Zack Williams33085522020-02-28 11:41:01 -0700156 cp -r repos/$(@)$$GIT_SUBDIR $@ ;\
Zack Williams071eda22019-05-15 18:19:51 -0700157
Eric Ballfc4ad7a2025-02-05 17:22:21 -0800158# # Build Robot documentation in voltha-system-tests and copy it into _static.
159# _static/voltha-system-tests: | $(OTHER_REPO_DOCS)
160# make -C voltha-system-tests gendocs
161# mkdir -p $@
162# cp -r voltha-system-tests/gendocs/* $@
163#
164# # Build Robot documentation in cord-tester and copy it into _static.
165# _static/cord-tester: | $(OTHER_REPO_DOCS)
166# make -C cord-tester gendocs
167# mkdir -p $@
168# cp -r cord-tester/gendocs/* $@
Andy Bavier39d67b12020-02-27 16:08:52 -0700169
Joey Armstrong4de98b72023-02-09 14:51:38 -0500170## -----------------------------------------------------------------------
Eric Ball624906c2025-03-28 18:14:55 -0700171## Intent: Build docs for the current branch
172## -----------------------------------------------------------------------
173docs: $(venv-activate-script) Makefile | prep $(OTHER_REPO_DOCS)
174 $(activate) && sphinx-build "$(SOURCEDIR)" "$(BUILDDIR)/$(BRANCH)" $(SPHINXOPTS)
175ifeq ($(BRANCH),master)
176 cp "$(SOURCEDIR)/_templates/meta_refresh.html" "$(BUILDDIR)/index.html"
177endif
178
179## -----------------------------------------------------------------------
Joey Armstrong4de98b72023-02-09 14:51:38 -0500180## Intent: generate a list of git checksums suitable for updating git_refs
181## -----------------------------------------------------------------------
Zack Williams071eda22019-05-15 18:19:51 -0700182freeze: repos
183 @for repo in $(OTHER_REPO_DOCS) ; do \
184 GIT_SUBDIR=`grep "^$$repo " git_refs | awk '{print $$2}'` ;\
Zack Williams6c1703f2019-12-20 15:31:58 -0700185 cd "repos/$$repo" > /dev/null ;\
Zack Williams071eda22019-05-15 18:19:51 -0700186 HEAD_SHA=`git rev-parse HEAD` ;\
187 printf "%-24s %-8s %-40s\n" $$repo $$GIT_SUBDIR $$HEAD_SHA ;\
Zack Williams6c1703f2019-12-20 15:31:58 -0700188 cd ../.. ;\
Zack Williams071eda22019-05-15 18:19:51 -0700189 done
190
Joey Armstrong4de98b72023-02-09 14:51:38 -0500191## -----------------------------------------------------------------------
192## Intent: build multiple versions
193## -----------------------------------------------------------------------
Eric Ballfc4ad7a2025-02-05 17:22:21 -0800194multiversion: $(venv-activate-script) Makefile | prep $(OTHER_REPO_DOCS)
Joey Armstrong4de98b72023-02-09 14:51:38 -0500195 $(activate)\
196 && sphinx-multiversion "$(SOURCEDIR)" "$(BUILDDIR)/multiversion" $(SPHINXOPTS)
Zack Williams16042b62020-03-29 22:03:16 -0700197 cp "$(SOURCEDIR)/_templates/meta_refresh.html" "$(BUILDDIR)/multiversion/index.html"
Zack Williams88df4742019-12-20 08:24:47 -0700198
Joey Armstrong4de98b72023-02-09 14:51:38 -0500199## -----------------------------------------------------------------------
200## Intent: used in sphinx-multiversion to properly link
201## -----------------------------------------------------------------------
Zack Williams16042b62020-03-29 22:03:16 -0700202prep: | $(OTHER_REPO_DOCS) $(STATIC_DOCS)
Andy Bavier5dee6ae2020-01-29 16:03:40 -0700203
Joey Armstrong4de98b72023-02-09 14:51:38 -0500204## -----------------------------------------------------------------------
Joey Armstrong4de98b72023-02-09 14:51:38 -0500205## Intent: Display makefile target help
206## -----------------------------------------------------------------------
Eric Ballfc4ad7a2025-02-05 17:22:21 -0800207help-targets-sphinx : $(venv-activate-script)
Joey Armstrong4de98b72023-02-09 14:51:38 -0500208 @ echo
Joey Armstrong721519c2023-11-13 15:30:54 -0500209 @echo '[HELP: Sphinx]'
Joey Armstrong4de98b72023-02-09 14:51:38 -0500210 $(HIDE)$(activate) \
211 && $(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
212
213## -----------------------------------------------------------------------
Joey Armstrong924f3cb2023-06-05 15:21:51 -0400214## Intent: Display WARNINGS buried in sphinx output
215## -----------------------------------------------------------------------
216warnings-log := warnings.log
Joey Armstrong4f93b762023-06-06 08:36:02 -0400217warnings: sterile
Joey Armstrong924f3cb2023-06-05 15:21:51 -0400218 $(MAKE) html 2>&1 \
219 | sed -e 's@\([Ww][Aa][Rr][Nn][Ii][Nn][Gg]\)@\n\1@g' \
220 > "$(warnings-log)"
Joey Armstrong4f93b762023-06-06 08:36:02 -0400221 grep 'WARNING' $(warnings-log)
Joey Armstrong924f3cb2023-06-05 15:21:51 -0400222
Joey Armstrong4f93b762023-06-06 08:36:02 -0400223## -----------------------------------------------------------------------
224## Intent: Summarize linkcheck failures
225## -----------------------------------------------------------------------
226.PHONY: broken-log
227broken-log := broken.log
228broken-log : sterile
229 $(MAKE) linkcheck 2>&1 | tee "$(broken-log)"
230 ! grep broken "$(broken-log)"
231 grep -i error _build/linkcheck/output.txt
232
233## -----------------------------------------------------------------------
Joey Armstronge03bc602024-02-09 17:26:27 -0500234## Intent: Summarize linkcheck failures
235## -----------------------------------------------------------------------
236.PHONY: lint-doc8-debug
237lint-doc8-debug : sterile
238 $(HIDE) @echo "Searching for cryptic failures"
239 -grep -i 'X <' release_notes/voltha_2.12.rst | grep -v '`__'
240
241## -----------------------------------------------------------------------
Joey Armstrong4f93b762023-06-06 08:36:02 -0400242## Intent:
243## -----------------------------------------------------------------------
Joey Armstrong924f3cb2023-06-05 15:21:51 -0400244clean::
Joey Armstrong4f93b762023-06-06 08:36:02 -0400245 $(RM) $(broken-log)
Joey Armstrong924f3cb2023-06-05 15:21:51 -0400246 $(RM) $(warnings-log)
247
Joey Armstrong4f93b762023-06-06 08:36:02 -0400248## -----------------------------------------------------------------------
249## Intent:
250## -----------------------------------------------------------------------
Joey Armstrong721519c2023-11-13 15:30:54 -0500251help :: help-targets-main
252help-targets-main :
253
254 @echo
255 @echo '[HELP]'
256 @printf ' %-30.30s %s\n' 'help' \
257 'Summary makefile target help'
258 @printf ' %-30.30s %s\n' 'help-verbose' \
259 'Extended makefile target help'
260
261 @echo
Joey Armstrong9f7c57c2024-05-03 18:29:30 -0400262 @echo '[INIT]'
Joey Armstrong721519c2023-11-13 15:30:54 -0500263 @printf ' %-30.30s %s\n' 'init' \
264 'Alias for git-submodules'
265 @printf ' %-30.30s %s\n' 'git-submodules' \
266 'Checkout external dependent repositories'
267
268 @echo
269 @echo '[TEST: Failures]'
270 @printf ' %-30.30s %s\n' 'broken' \
271 'Display broken URLs detected in linkcheck output'
272 @printf ' %-30.30s %s\n' 'warnings' \
273 'Display WARNING strings buried in sphinx output'
274
275## -----------------------------------------------------------------------
276## Intent: Checkout external repository dependencies
277## -----------------------------------------------------------------------
278init :: git-submodules
279
280git-submodules:
281 git submodule update --init --recursive
Joey Armstrong924f3cb2023-06-05 15:21:51 -0400282
283## -----------------------------------------------------------------------
Joey Armstrong9f7c57c2024-05-03 18:29:30 -0400284## Intent: Display make help footer
Joey Armstronga8bc8e12022-12-04 07:06:59 -0500285## -----------------------------------------------------------------------
Joey Armstrong449ce7a2023-07-18 18:32:24 -0400286include $(ONF_MAKEDIR)/help/trailer.mk
Joey Armstrong36592e32022-11-28 09:00:28 -0500287
288# [EOF]