blob: 447e858df7ed5ccf1b7bdc242b6a5dd00baf3c8f [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 Balla2761a72025-03-31 15:06:54 -070043
44# If running on Jenkins, we need to pick up the GERRIT_BRANCH env var.
45# Otherwise, we can simply use the current branch.
46ifdef GERRIT_BRANCH
47 BRANCH := $(GERRIT_BRANCH)
48else
49 BRANCH := $(shell git branch --show-current)
50endif
Zack Williams071eda22019-05-15 18:19:51 -070051
Zack Williams88df4742019-12-20 08:24:47 -070052# Other repos with documentation to include.
53# edit the `git_refs` file with the commit/tag/branch that you want to use
Eric Ballfc4ad7a2025-02-05 17:22:21 -080054OTHER_REPO_DOCS ?= bbsim ofagent-go openolt voltctl voltha-openolt-adapter voltha-openonu-adapter-go voltha-protos device-management-interface voltha-helm-charts
55# Temporarily disabled: cord-tester voltha-system-tests
Zack Williams88df4742019-12-20 08:24:47 -070056
Joey Armstrong36592e32022-11-28 09:00:28 -050057ifdef NO_OTHER_REPO_DOCS
58 # Inhibit pulling in external repos.
59 # python 3.10+ patching not supported by all repos yet.
60 OTHER_REPO_DOCS := $(null)
61endif
62
Zack Williams16042b62020-03-29 22:03:16 -070063# Static docs, built by other means (usually robot framework)
Eric Ballfc4ad7a2025-02-05 17:22:21 -080064# STATIC_DOCS := _static/voltha-system-tests _static/cord-tester
Zack Williams16042b62020-03-29 22:03:16 -070065
Joey Armstrong4de98b72023-02-09 14:51:38 -050066# Why is existing source Makefile PHONY (?)
Zack Williams88df4742019-12-20 08:24:47 -070067.PHONY: help test lint reload Makefile prep
Zack Williams071eda22019-05-15 18:19:51 -070068
Joey Armstrong4de98b72023-02-09 14:51:38 -050069## -----------------------------------------------------------------------
Joey Armstrong721519c2023-11-13 15:30:54 -050070## Intent: Display makefile target help
71## -----------------------------------------------------------------------
72help :: help-targets-main
73help-verbose :: help-targets-sphinx
74
75## -----------------------------------------------------------------------
Joey Armstrong4de98b72023-02-09 14:51:38 -050076## Intent: Real time viewing, dynamically generate and reload document
77## changes for web browser viewing.
78## Usage:
79## make reload
80## -----------------------------------------------------------------------
Eric Ballfc4ad7a2025-02-05 17:22:21 -080081reload: $(venv-activate-script)
Joey Armstrong4de98b72023-02-09 14:51:38 -050082 $(activate) && sphinx-reload $(SOURCEDIR)
Zack Williams071eda22019-05-15 18:19:51 -070083
Joey Armstrong8d62cd92022-12-22 13:53:48 -050084## -----------------------------------------------------------------------
85## Intent: lint and link verification. linkcheck is part of sphinx
Joey Armstrong64b82492023-06-01 17:34:39 -040086## See Also: make test-errors
Joey Armstrong8d62cd92022-12-22 13:53:48 -050087## -----------------------------------------------------------------------
Zack Williams071eda22019-05-15 18:19:51 -070088test: lint linkcheck
Joey Armstronga8bc8e12022-12-04 07:06:59 -050089
Joey Armstrong50895b82023-09-14 16:44:28 -040090# [TODO] relocate into repo:onf-make/
Eric Ballfc4ad7a2025-02-05 17:22:21 -080091lint : $(venv-activate-script)
92linkcheck : $(venv-activate-script)
Joey Armstrong50895b82023-09-14 16:44:28 -040093
Joey Armstrong8d62cd92022-12-22 13:53:48 -050094## -----------------------------------------------------------------------
95## Intent: Exercise all generation targets
Joey Armstrong4de98b72023-02-09 14:51:38 -050096## Bridge: library workaround to support legacy targets
Joey Armstrong8d62cd92022-12-22 13:53:48 -050097## -----------------------------------------------------------------------
98test-all-targets += html
99test-all-targets += coverage
100# test-all-targets += changes
101# test-all-targets += info
102test-all-targets += man
103test-all-targe4ts += text
104# test-all-targets += latex
105
Joey Armstrong8d62cd92022-12-22 13:53:48 -0500106test-all : test
107 $(MAKE) $(test-all-targets)
108
Joey Armstrong36592e32022-11-28 09:00:28 -0500109# doctest
110# coverage
111# linkcheck
Zack Williams071eda22019-05-15 18:19:51 -0700112
Joey Armstrong0cbee512023-10-18 15:39:24 -0400113# -----------------------------------------------------------------------
Zack Williams071eda22019-05-15 18:19:51 -0700114# currently not enabled, should be added to lint target
Joey Armstrong0cbee512023-10-18 15:39:24 -0400115# [TODO] Create repo:onf-make/makefiles/lint/mdl
116# -----------------------------------------------------------------------
Zack Williams071eda22019-05-15 18:19:51 -0700117LINT_STYLE ?= mdl_strict.rb
118md-lint: | $(OTHER_REPO_DOCS)
119 @echo "markdownlint(mdl) version: `mdl --version`"
120 @echo "style config:"
121 @echo "---"
122 @cat $(LINT_STYLE)
123 @echo "---"
Joey Armstrong4de98b72023-02-09 14:51:38 -0500124 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 -0700125
126# clean up
Joey Armstrong64b82492023-06-01 17:34:39 -0400127clean ::
Joey Armstrong36592e32022-11-28 09:00:28 -0500128 $(RM) -r $(BUILDDIR) $(OTHER_REPO_DOCS) $(STATIC_DOCS)
Zack Williams071eda22019-05-15 18:19:51 -0700129
Joey Armstrong4de98b72023-02-09 14:51:38 -0500130clean-all sterile :: clean
131 $(RM) -r $(venv-activate-script) repos
Zack Williams071eda22019-05-15 18:19:51 -0700132
Zack Williams071eda22019-05-15 18:19:51 -0700133# checkout the repos inside repos/ dir
134repos:
135 mkdir repos
136
137# build directory paths in repos/* to perform 'git clone <repo>' into
138CHECKOUT_REPOS = $(foreach repo,$(OTHER_REPO_DOCS),repos/$(repo))
139
140# Host holding the git server
141REPO_HOST ?= https://gerrit.opencord.org
142
143# For QA patchset validation - set SKIP_CHECKOUT to the repo name and
144# pre-populate it under repos/ with the specific commit to being validated
145SKIP_CHECKOUT ?=
146
Zack Williams88df4742019-12-20 08:24:47 -0700147# clone (only if doesn't exist)
Zack Williams071eda22019-05-15 18:19:51 -0700148$(CHECKOUT_REPOS): | repos
Zack Williams071eda22019-05-15 18:19:51 -0700149 if [ ! -d '$@' ] ;\
150 then git clone $(REPO_HOST)/$(@F) $@ ;\
Zack Williams071eda22019-05-15 18:19:51 -0700151 fi
152
Joey Armstrong4de98b72023-02-09 14:51:38 -0500153## -----------------------------------------------------------------------
154## Intent: checkout correct ref if not under test, then copy
155## subdirectories into main docs dir
156## -----------------------------------------------------------------------
Zack Williams071eda22019-05-15 18:19:51 -0700157$(OTHER_REPO_DOCS): | $(CHECKOUT_REPOS)
Zack Williams88df4742019-12-20 08:24:47 -0700158 if [ "$(SKIP_CHECKOUT)" != "$@" ] ;\
159 then GIT_REF=`grep '^$@ ' git_refs | awk '{print $$3}'` ;\
Zack Williams6c1703f2019-12-20 15:31:58 -0700160 cd "repos/$@" && git checkout $$GIT_REF ;\
Zack Williams88df4742019-12-20 08:24:47 -0700161 fi
Zack Williams17e34022019-12-20 13:51:54 -0700162 GIT_SUBDIR=`grep '^$@ ' git_refs | awk '{print $$2}'` ;\
Zack Williams33085522020-02-28 11:41:01 -0700163 cp -r repos/$(@)$$GIT_SUBDIR $@ ;\
Zack Williams071eda22019-05-15 18:19:51 -0700164
Eric Ballfc4ad7a2025-02-05 17:22:21 -0800165# # Build Robot documentation in voltha-system-tests and copy it into _static.
166# _static/voltha-system-tests: | $(OTHER_REPO_DOCS)
167# make -C voltha-system-tests gendocs
168# mkdir -p $@
169# cp -r voltha-system-tests/gendocs/* $@
170#
171# # Build Robot documentation in cord-tester and copy it into _static.
172# _static/cord-tester: | $(OTHER_REPO_DOCS)
173# make -C cord-tester gendocs
174# mkdir -p $@
175# cp -r cord-tester/gendocs/* $@
Andy Bavier39d67b12020-02-27 16:08:52 -0700176
Joey Armstrong4de98b72023-02-09 14:51:38 -0500177## -----------------------------------------------------------------------
Eric Ball624906c2025-03-28 18:14:55 -0700178## Intent: Build docs for the current branch
179## -----------------------------------------------------------------------
180docs: $(venv-activate-script) Makefile | prep $(OTHER_REPO_DOCS)
181 $(activate) && sphinx-build "$(SOURCEDIR)" "$(BUILDDIR)/$(BRANCH)" $(SPHINXOPTS)
182ifeq ($(BRANCH),master)
183 cp "$(SOURCEDIR)/_templates/meta_refresh.html" "$(BUILDDIR)/index.html"
184endif
185
186## -----------------------------------------------------------------------
Joey Armstrong4de98b72023-02-09 14:51:38 -0500187## Intent: generate a list of git checksums suitable for updating git_refs
188## -----------------------------------------------------------------------
Zack Williams071eda22019-05-15 18:19:51 -0700189freeze: repos
190 @for repo in $(OTHER_REPO_DOCS) ; do \
191 GIT_SUBDIR=`grep "^$$repo " git_refs | awk '{print $$2}'` ;\
Zack Williams6c1703f2019-12-20 15:31:58 -0700192 cd "repos/$$repo" > /dev/null ;\
Zack Williams071eda22019-05-15 18:19:51 -0700193 HEAD_SHA=`git rev-parse HEAD` ;\
194 printf "%-24s %-8s %-40s\n" $$repo $$GIT_SUBDIR $$HEAD_SHA ;\
Zack Williams6c1703f2019-12-20 15:31:58 -0700195 cd ../.. ;\
Zack Williams071eda22019-05-15 18:19:51 -0700196 done
197
Joey Armstrong4de98b72023-02-09 14:51:38 -0500198## -----------------------------------------------------------------------
199## Intent: build multiple versions
200## -----------------------------------------------------------------------
Eric Ballfc4ad7a2025-02-05 17:22:21 -0800201multiversion: $(venv-activate-script) Makefile | prep $(OTHER_REPO_DOCS)
Joey Armstrong4de98b72023-02-09 14:51:38 -0500202 $(activate)\
203 && sphinx-multiversion "$(SOURCEDIR)" "$(BUILDDIR)/multiversion" $(SPHINXOPTS)
Zack Williams16042b62020-03-29 22:03:16 -0700204 cp "$(SOURCEDIR)/_templates/meta_refresh.html" "$(BUILDDIR)/multiversion/index.html"
Zack Williams88df4742019-12-20 08:24:47 -0700205
Joey Armstrong4de98b72023-02-09 14:51:38 -0500206## -----------------------------------------------------------------------
207## Intent: used in sphinx-multiversion to properly link
208## -----------------------------------------------------------------------
Zack Williams16042b62020-03-29 22:03:16 -0700209prep: | $(OTHER_REPO_DOCS) $(STATIC_DOCS)
Andy Bavier5dee6ae2020-01-29 16:03:40 -0700210
Joey Armstrong4de98b72023-02-09 14:51:38 -0500211## -----------------------------------------------------------------------
Joey Armstrong4de98b72023-02-09 14:51:38 -0500212## Intent: Display makefile target help
213## -----------------------------------------------------------------------
Eric Ballfc4ad7a2025-02-05 17:22:21 -0800214help-targets-sphinx : $(venv-activate-script)
Joey Armstrong4de98b72023-02-09 14:51:38 -0500215 @ echo
Joey Armstrong721519c2023-11-13 15:30:54 -0500216 @echo '[HELP: Sphinx]'
Joey Armstrong4de98b72023-02-09 14:51:38 -0500217 $(HIDE)$(activate) \
218 && $(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
219
220## -----------------------------------------------------------------------
Joey Armstrong924f3cb2023-06-05 15:21:51 -0400221## Intent: Display WARNINGS buried in sphinx output
222## -----------------------------------------------------------------------
223warnings-log := warnings.log
Joey Armstrong4f93b762023-06-06 08:36:02 -0400224warnings: sterile
Joey Armstrong924f3cb2023-06-05 15:21:51 -0400225 $(MAKE) html 2>&1 \
226 | sed -e 's@\([Ww][Aa][Rr][Nn][Ii][Nn][Gg]\)@\n\1@g' \
227 > "$(warnings-log)"
Joey Armstrong4f93b762023-06-06 08:36:02 -0400228 grep 'WARNING' $(warnings-log)
Joey Armstrong924f3cb2023-06-05 15:21:51 -0400229
Joey Armstrong4f93b762023-06-06 08:36:02 -0400230## -----------------------------------------------------------------------
231## Intent: Summarize linkcheck failures
232## -----------------------------------------------------------------------
233.PHONY: broken-log
234broken-log := broken.log
235broken-log : sterile
236 $(MAKE) linkcheck 2>&1 | tee "$(broken-log)"
237 ! grep broken "$(broken-log)"
238 grep -i error _build/linkcheck/output.txt
239
240## -----------------------------------------------------------------------
Joey Armstronge03bc602024-02-09 17:26:27 -0500241## Intent: Summarize linkcheck failures
242## -----------------------------------------------------------------------
243.PHONY: lint-doc8-debug
244lint-doc8-debug : sterile
245 $(HIDE) @echo "Searching for cryptic failures"
246 -grep -i 'X <' release_notes/voltha_2.12.rst | grep -v '`__'
247
248## -----------------------------------------------------------------------
Joey Armstrong4f93b762023-06-06 08:36:02 -0400249## Intent:
250## -----------------------------------------------------------------------
Joey Armstrong924f3cb2023-06-05 15:21:51 -0400251clean::
Joey Armstrong4f93b762023-06-06 08:36:02 -0400252 $(RM) $(broken-log)
Joey Armstrong924f3cb2023-06-05 15:21:51 -0400253 $(RM) $(warnings-log)
254
Joey Armstrong4f93b762023-06-06 08:36:02 -0400255## -----------------------------------------------------------------------
256## Intent:
257## -----------------------------------------------------------------------
Joey Armstrong721519c2023-11-13 15:30:54 -0500258help :: help-targets-main
259help-targets-main :
260
261 @echo
262 @echo '[HELP]'
263 @printf ' %-30.30s %s\n' 'help' \
264 'Summary makefile target help'
265 @printf ' %-30.30s %s\n' 'help-verbose' \
266 'Extended makefile target help'
267
268 @echo
Joey Armstrong9f7c57c2024-05-03 18:29:30 -0400269 @echo '[INIT]'
Joey Armstrong721519c2023-11-13 15:30:54 -0500270 @printf ' %-30.30s %s\n' 'init' \
271 'Alias for git-submodules'
272 @printf ' %-30.30s %s\n' 'git-submodules' \
273 'Checkout external dependent repositories'
274
275 @echo
276 @echo '[TEST: Failures]'
277 @printf ' %-30.30s %s\n' 'broken' \
278 'Display broken URLs detected in linkcheck output'
279 @printf ' %-30.30s %s\n' 'warnings' \
280 'Display WARNING strings buried in sphinx output'
281
282## -----------------------------------------------------------------------
283## Intent: Checkout external repository dependencies
284## -----------------------------------------------------------------------
285init :: git-submodules
286
287git-submodules:
288 git submodule update --init --recursive
Joey Armstrong924f3cb2023-06-05 15:21:51 -0400289
290## -----------------------------------------------------------------------
Joey Armstrong9f7c57c2024-05-03 18:29:30 -0400291## Intent: Display make help footer
Joey Armstronga8bc8e12022-12-04 07:06:59 -0500292## -----------------------------------------------------------------------
Joey Armstrong449ce7a2023-07-18 18:32:24 -0400293include $(ONF_MAKEDIR)/help/trailer.mk
Joey Armstrong36592e32022-11-28 09:00:28 -0500294
295# [EOF]