blob: 237c457326c8ba372a7d3076d1013424c00554f9 [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 Ball36c9b5b2025-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 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## -----------------------------------------------------------------------
Eric Ball624906c2025-03-28 18:14:55 -0700173## Intent: Build docs for the current branch
174## -----------------------------------------------------------------------
175docs: $(venv-activate-script) Makefile | prep $(OTHER_REPO_DOCS)
176 $(activate) && sphinx-build "$(SOURCEDIR)" "$(BUILDDIR)/$(BRANCH)" $(SPHINXOPTS)
177ifeq ($(BRANCH),master)
178 cp "$(SOURCEDIR)/_templates/meta_refresh.html" "$(BUILDDIR)/index.html"
179endif
180
181## -----------------------------------------------------------------------
Joey Armstrong4de98b72023-02-09 14:51:38 -0500182## Intent: generate a list of git checksums suitable for updating git_refs
183## -----------------------------------------------------------------------
Zack Williams071eda22019-05-15 18:19:51 -0700184freeze: repos
185 @for repo in $(OTHER_REPO_DOCS) ; do \
186 GIT_SUBDIR=`grep "^$$repo " git_refs | awk '{print $$2}'` ;\
Zack Williams6c1703f2019-12-20 15:31:58 -0700187 cd "repos/$$repo" > /dev/null ;\
Zack Williams071eda22019-05-15 18:19:51 -0700188 HEAD_SHA=`git rev-parse HEAD` ;\
189 printf "%-24s %-8s %-40s\n" $$repo $$GIT_SUBDIR $$HEAD_SHA ;\
Zack Williams6c1703f2019-12-20 15:31:58 -0700190 cd ../.. ;\
Zack Williams071eda22019-05-15 18:19:51 -0700191 done
192
Joey Armstrong4de98b72023-02-09 14:51:38 -0500193## -----------------------------------------------------------------------
194## Intent: build multiple versions
195## -----------------------------------------------------------------------
Eric Ballfc4ad7a2025-02-05 17:22:21 -0800196multiversion: $(venv-activate-script) Makefile | prep $(OTHER_REPO_DOCS)
Joey Armstrong4de98b72023-02-09 14:51:38 -0500197 $(activate)\
198 && sphinx-multiversion "$(SOURCEDIR)" "$(BUILDDIR)/multiversion" $(SPHINXOPTS)
Zack Williams16042b62020-03-29 22:03:16 -0700199 cp "$(SOURCEDIR)/_templates/meta_refresh.html" "$(BUILDDIR)/multiversion/index.html"
Zack Williams88df4742019-12-20 08:24:47 -0700200
Joey Armstrong4de98b72023-02-09 14:51:38 -0500201## -----------------------------------------------------------------------
202## Intent: used in sphinx-multiversion to properly link
203## -----------------------------------------------------------------------
Zack Williams16042b62020-03-29 22:03:16 -0700204prep: | $(OTHER_REPO_DOCS) $(STATIC_DOCS)
Andy Bavier5dee6ae2020-01-29 16:03:40 -0700205
Joey Armstrong4de98b72023-02-09 14:51:38 -0500206## -----------------------------------------------------------------------
Joey Armstrong4de98b72023-02-09 14:51:38 -0500207## Intent: Display makefile target help
208## -----------------------------------------------------------------------
Eric Ballfc4ad7a2025-02-05 17:22:21 -0800209help-targets-sphinx : $(venv-activate-script)
Joey Armstrong4de98b72023-02-09 14:51:38 -0500210 @ echo
Joey Armstrong721519c2023-11-13 15:30:54 -0500211 @echo '[HELP: Sphinx]'
Joey Armstrong4de98b72023-02-09 14:51:38 -0500212 $(HIDE)$(activate) \
213 && $(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
214
215## -----------------------------------------------------------------------
Joey Armstrong924f3cb2023-06-05 15:21:51 -0400216## Intent: Display WARNINGS buried in sphinx output
217## -----------------------------------------------------------------------
218warnings-log := warnings.log
Joey Armstrong4f93b762023-06-06 08:36:02 -0400219warnings: sterile
Joey Armstrong924f3cb2023-06-05 15:21:51 -0400220 $(MAKE) html 2>&1 \
221 | sed -e 's@\([Ww][Aa][Rr][Nn][Ii][Nn][Gg]\)@\n\1@g' \
222 > "$(warnings-log)"
Joey Armstrong4f93b762023-06-06 08:36:02 -0400223 grep 'WARNING' $(warnings-log)
Joey Armstrong924f3cb2023-06-05 15:21:51 -0400224
Joey Armstrong4f93b762023-06-06 08:36:02 -0400225## -----------------------------------------------------------------------
226## Intent: Summarize linkcheck failures
227## -----------------------------------------------------------------------
228.PHONY: broken-log
229broken-log := broken.log
230broken-log : sterile
231 $(MAKE) linkcheck 2>&1 | tee "$(broken-log)"
232 ! grep broken "$(broken-log)"
233 grep -i error _build/linkcheck/output.txt
234
235## -----------------------------------------------------------------------
Joey Armstronge03bc602024-02-09 17:26:27 -0500236## Intent: Summarize linkcheck failures
237## -----------------------------------------------------------------------
238.PHONY: lint-doc8-debug
239lint-doc8-debug : sterile
240 $(HIDE) @echo "Searching for cryptic failures"
241 -grep -i 'X <' release_notes/voltha_2.12.rst | grep -v '`__'
242
243## -----------------------------------------------------------------------
Joey Armstrong4f93b762023-06-06 08:36:02 -0400244## Intent:
245## -----------------------------------------------------------------------
Joey Armstrong924f3cb2023-06-05 15:21:51 -0400246clean::
Joey Armstrong4f93b762023-06-06 08:36:02 -0400247 $(RM) $(broken-log)
Joey Armstrong924f3cb2023-06-05 15:21:51 -0400248 $(RM) $(warnings-log)
249
Joey Armstrong4f93b762023-06-06 08:36:02 -0400250## -----------------------------------------------------------------------
251## Intent:
252## -----------------------------------------------------------------------
Joey Armstrong721519c2023-11-13 15:30:54 -0500253help :: help-targets-main
254help-targets-main :
255
256 @echo
257 @echo '[HELP]'
258 @printf ' %-30.30s %s\n' 'help' \
259 'Summary makefile target help'
260 @printf ' %-30.30s %s\n' 'help-verbose' \
261 'Extended makefile target help'
262
263 @echo
Joey Armstrong9f7c57c2024-05-03 18:29:30 -0400264 @echo '[INIT]'
Joey Armstrong721519c2023-11-13 15:30:54 -0500265 @printf ' %-30.30s %s\n' 'init' \
266 'Alias for git-submodules'
267 @printf ' %-30.30s %s\n' 'git-submodules' \
268 'Checkout external dependent repositories'
269
270 @echo
271 @echo '[TEST: Failures]'
272 @printf ' %-30.30s %s\n' 'broken' \
273 'Display broken URLs detected in linkcheck output'
274 @printf ' %-30.30s %s\n' 'warnings' \
275 'Display WARNING strings buried in sphinx output'
276
277## -----------------------------------------------------------------------
Joey Armstrong9f7c57c2024-05-03 18:29:30 -0400278## Intent: Display make help footer
Joey Armstronga8bc8e12022-12-04 07:06:59 -0500279## -----------------------------------------------------------------------
Eric Ball36c9b5b2025-04-02 12:11:47 -0700280include makefiles-orig/help/trailer.mk
Joey Armstrong36592e32022-11-28 09:00:28 -0500281
282# [EOF]