| # Minimal makefile for Sphinx documentation |
| # |
| |
| # You can set these variables from the command line. |
| SPHINXOPTS = |
| SPHINXBUILD = sphinx-build |
| SPHINXPROJ = KUnit |
| SOURCEDIR = . |
| BUILDDIR = _build |
| |
| # Put it first so that "make" without argument is like "make all". |
| all: html |
| |
| # param 1: The url of the git repo. |
| # param 2: The branch to clone. |
| # param 3: The directory to clone into. |
| define git_clone_raw |
| git clone --depth 1 --single-branch $(1) --branch $(2) $(3) |
| endef |
| |
| # param 1: The url of the git repo. |
| # param 2: The branch to clone. |
| # param 3: The directory to clone into. |
| define git_clone |
| if [ ! -d "$(3)" ]; then $(call git_clone_raw,$(1),$(2),$(3)); fi |
| endef |
| |
| define mkdir |
| if [ ! -d "$(1)" ]; then mkdir $(1); fi |
| endef |
| |
| # param 1: The url of the git repo. |
| # param 2: The branch to clone. |
| # param 3: The directory to clone into. |
| # param 4: The name of the directory under third_party to copy the docs. |
| # param 5: The directory under Documentation/ that contains the docs to copy. |
| define fetch_kernel_docs |
| $(call git_clone,$(1),$(2),$(3)) |
| make -C $(3) htmldocs SPHINXDIRS=$(5) |
| mkdir -p $(BUILDDIR)/html/third_party/$(4) |
| $(call mkdir,$(BUILDDIR)/html/third_party/$(4)/LICENSES/) |
| cp -r $(3)/LICENSES/* $(BUILDDIR)/html/third_party/$(4)/LICENSES/ |
| $(call mkdir,$(BUILDDIR)/html/third_party/$(4)/docs/) |
| cp -r $(3)/Documentation/output/$(5)/* $(BUILDDIR)/html/third_party/$(4)/docs/ |
| endef |
| |
| fetch_stable_docs: |
| $(call fetch_kernel_docs,https://kunit.googlesource.com/linux,kunit/alpha/master,$(BUILDDIR)/stable_kunit,stable_kernel,test) |
| |
| fetch_upstream_docs: |
| $(call fetch_kernel_docs,https://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest.git,test,$(BUILDDIR)/upstream_kunit,kernel,dev-tools/kunit) |
| |
| download_deps: fetch_stable_docs fetch_upstream_docs |
| |
| copy_statics: |
| cp LICENSE $(BUILDDIR)/html/ |
| cp CONTRIBUTING.md $(BUILDDIR)/html/ |
| cp statics/CNAME $(BUILDDIR)/html/ |
| cp statics/.nojekyll $(BUILDDIR)/html/ |
| cp statics/README.md $(BUILDDIR)/html/ |
| |
| clean: |
| rm -rf $(BUILDDIR) |
| |
| .PHONY: all fetch_stable_docs fetch_upstream_docs download_deps clean html copy_statics |
| |
| html: Makefile download_deps copy_statics |
| @$(SPHINXBUILD) -M html "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) |