blob: db06a050fd71ee2007d04226a4dc5f6ac363c0d8 [file] [log] [blame]
Tim 'mithro' Ansell8b323f82020-05-14 13:18:07 -07001# Minimal makefile for Sphinx documentation
2
3DOCSDIR := $(dir $(lastword $(MAKEFILE_LIST)))
4TOPDIR := $(realpath $(DOCSDIR)/..)
5
6include $(TOPDIR)/scripts/make/conda.mk
7
8SHELL = /bin/bash
9
10EXP_OPEN := $$((
11EXP_CLOSE := ))
12CPU_CORES := $(shell nproc)
13CPU_CORES_2 := $(shell echo $(EXP_OPEN) $(CPU_CORES) * 2 $(EXP_CLOSE))
14
15SPHINXOPTS = -j $(CPU_CORES_2)
16SPHINXBUILD = $(IN_CONDA_ENV) sphinx-build
17SPHINXAUTOBUILD = $(IN_CONDA_ENV) sphinx-autobuild
18SPHINXPROJ = SkyWaterPDK
19SOURCEDIR = $(DOCSDIR)
20BUILDDIR = $(DOCSDIR)/_build
21
22# Put it first so that "make" without argument is like "make help".
23help: | $(CONDA_ENV_PYTHON)
24 @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
25
26# Vim makes a '4913' file for file system checking. Seriously.
27livehtml: | $(CONDA_ENV_PYTHON)
28 @$(SPHINXAUTOBUILD) \
29 -b html \
30 --delay 5 \
31 \
32 --ignore \*.swp \
33 --ignore \*~ \
34 --ignore env \
35 --ignore _build \
36 --ignore .git \
37 --ignore */4913 \
38 \
39 $(SPHINXOPTS) \
40 "$(SOURCEDIR)" \
41 "$(BUILDDIR)/html"
42
43.PHONY: help livehtml Makefile
44
Tim 'mithro' Ansell7303dab2020-06-21 18:05:40 -070045# Generate the rules/periphery-rules.rst from CSV files in rules/periphery/
46$(wildcard rules/periphery/*): | $(CONDA_ENV_PYTHON)
47 true
48
49rules/periphery-rules.rst: $(wildcard rules/periphery/*) | $(CONDA_ENV_PYTHON)
50 $(IN_CONDA_ENV) cd rules/periphery; ./periphery-split-csv.py > /dev/null
51
Tim 'mithro' Ansell8b323f82020-05-14 13:18:07 -070052# Various automated fixups that can be run
53fixup:
54 # Make sure it is SkyWater
55 find ../ -type f -name \*.rst -exec sed -i 's/Skywater/SkyWater/gi' \{\} \+
56 # Strip trailing space
57 find ../ -type f -name \*.rst -exec sed -i 's/ \+$$//' \{\} \+
58 # Make sure all library names have the :lib: role.
59 find ../ -type f -name \*.rst -exec sed -i -e'/:name:.*/!s/\(:lib:\)\?`\?\(sky130_[a-z0-9]\+_[a-z0-9]\+\(_[a-z0-9]\+\)\?\)`\?\(\s\|$$\)/:lib:`\2`\4/g' \{\} \+
60
61.PHONY: fixup
62
63echo: | $(CONDA_ENV_PYTHON)
64 @echo '$(SPHINXBUILD) -M XXXX "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)'
65
66# Catch-all target: route all unknown targets to Sphinx using the new
67# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
68.DEFAULT: | $(CONDA_ENV_PYTHON)
69 @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
Tim 'mithro' Ansell24e43102020-05-14 17:12:43 -070070
71
72clean: clean-docs
73
74
75clean-docs:
76 rm -rf _build