-
Notifications
You must be signed in to change notification settings - Fork 8
/
Makefile
74 lines (57 loc) · 1.68 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
GNUMAKEFLAGS := --no-builtins --no-builtin-variables
.SUFFIXES:
ifeq ($(OS),Windows_NT)
--which := where
--null := nul
RM := rmdir /s /q
else
--which := which
--null ?= /dev/null
RM := rm -rf
endif
POETRY ?= $(shell $(--which) poetry 2> $(--null))
ifeq ($(POETRY),)
$(error Could not find the `poetry` command. \
Please make sure you have installed poetry, \
and that it is on your system's PATH environment variable. \
If you don't have poetry installed, \
please visit https://python-poetry.org \
for instructions on its installation)
endif
SRCDIR ?= $(dir $(realpath $(firstword $(MAKEFILE_LIST))))
OUTDIR ?= $(join $(SRCDIR),_site)
ARCHIVE ?= cps-docs.tar
SPHINXOPTS ?=
venv := $(notdir $(realpath $(shell $(POETRY) env info --path 2> $(--null))))
archive.flags += --create --verbose
archive.flags += --exclude=.[^/]*
archive.flags += --file=$(ARCHIVE)
archive.flags += --directory=$(OUTDIR)
ifneq ($(OS),Windows_NT)
archive.flags += --mode=a+rw
endif
setup.flags += --with=docs
build.flags += $(if $(BUILDER),-b $(BUILDER),-b html)
build.flags += $(if $(LOGFILE),-w "$(LOGFILE)")
build.flags += $(if $(NOCOLOR),,--color)
build.flags += $(SPHINXOPTS)
.PHONY: all setup html clean.venv clean.cache clean purge archive
.PHONY: setup/fast html/fast archive/fast
all: html
setup: setup/fast
setup/fast:
$(POETRY) check
$(POETRY) install $(setup.flags)
html: setup html/fast
html/fast:
$(POETRY) run sphinx-build $(build.flags) "$(SRCDIR)" "$(OUTDIR)"
clean.venv:
$(if $(venv),$(POETRY) env remove "$(venv)",@echo "Nothing to do")
clean.cache:
$(RM) "$(join $(OUTDIR),.doctrees)"
clean:
$(RM) "$(OUTDIR)"
purge: clean.venv clean
archive: html archive/fast
archive/fast:
tar $(archive.flags) .