Debian Codegraph @

doc/sphinx/Makefile

raw
1 # Makefile for Sphinx documentation
2 #
3
4 # You can set these variables from the command line.
5 SPHINXOPTS =
6 SPHINXBUILD = python -msphinx
7 SPHINXPROJ = cclib
8 SOURCEDIR = .
9 BUILDDIR = _build
10
11 # Put it first so that "make" without argument is like "make help".
12 .PHONY: help Makefile
13 help:
14 @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) && exit 2
15
16 .PHONY: default
17 default: cclib update attributes coverage html
18
19 clean:
20 -rm -rf $(BUILDDIR)/*
21 -rm -rf cclib*
22 -rm -rf attributes*.rst
23 -rm -rf coverage*.rst
24
25 # When releasing a new version, this can't be updated until after the tag is pushed.
26 PRODUCTION_VERSION = v1.8
27 CCLIB_PROD = $(BUILDDIR)/cclib_prod
28 CCLIB_DEV = $(realpath $(SOURCEDIR)/../..)
29 SRC_PROD = $(CCLIB_PROD)/cclib
30 SRC_DEV = $(CCLIB_DEV)/cclib
31
32 # Have the production and master in two separate directories so that
33 # dependencies are triggered correctly. If we had one, it would not
34 # work correctly, since git updates timestamps on each checkout, which
35 # would trigger some targets unnecessarily.
36 .PHONY: cclib
37 cclib: $(CCLIB_PROD)
38 $(CCLIB_PROD):
39 @echo "Checking out prod..."
40 git clone https://github.com/cclib/cclib.git $@
41 cd $(CCLIB_PROD); git checkout $(PRODUCTION_VERSION)
42
43 .PHONY: update update_prod
44 update: update_prod
45 update_prod:
46 @echo "Updating prod..."
47 cd $(CCLIB_PROD); git checkout $(PRODUCTION_VERSION); git fetch --all --tags
48 cd $(CCLIB_PROD); find . -name "*.pyc" -delete
49
50 # Since we have two separate directories, 'checking out' a branch actually
51 # means making a symlink to the appropriate directory, because scripts should be
52 # impervious to this Makefile and will import from always the same name (cclib).
53 .PHONY: checkout_prod checkout_dev
54 checkout_prod:
55 ln -fs $(SRC_PROD) cclib
56 checkout_dev:
57 ln -fs $(SRC_DEV) cclib
58
59 # We need three layers of targets in order to always get the checkout
60 # to execute, but the actual file-generating target to run only if the
61 # appropriate files have been updated (resolved via the right symlink).
62 .PHONY: attributes
63 attributes: attributes.rst attributes_dev.rst
64 attributes.rst: attributes.py $(SRC_PROD)/parser/data.py
65 @echo "Generating prod attributes..."
66 @$(MAKE) --no-print-directory checkout_prod
67 python attributes.py > $@
68 -rm cclib
69 attributes_dev.rst: attributes.py $(SRC_DEV)/parser/data.py
70 @echo "Generating dev attributes..."
71 @$(MAKE) --no-print-directory checkout_dev
72 python attributes.py > $@
73 -rm cclib
74
75 # Same as above, we need three layers of targets, since this script
76 # especially takes some time as it performs all the tests.
77 .PHONY: coverage
78 coverage: coverage.rst coverage_dev.rst
79 coverage.rst: coverage.py $(wildcard $(SRC_PROD)/parser/*parser.py) $(wildcard $(CCLIB_PROD)/test/*.py)
80 @echo "Generating prod coverage..."
81 @$(MAKE) --no-print-directory checkout_prod
82 python coverage.py $(CCLIB_PROD) > $@
83 -rm cclib
84 coverage_dev.rst: coverage.py $(wildcard $(SRC_DEV)/parser/*parser.py) $(wildcard $(CCLIB_DEV)/test/*.py)
85 @echo "Generating dev coverage..."
86 @$(MAKE) --no-print-directory checkout_dev
87 python coverage.py $(CCLIB_DEV) > $@
88 -rm cclib
89
90 # Catch-all target: route all unknown targets to Sphinx using the new
91 # "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
92 # %: Makefile
93 # @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
94
95 # We can't use the default catch-all target, because it traps our
96 # custom targets that don't use Sphinx, like `attributes`, but it's
97 # still needed for our specific Sphinx build type.
98 .PHONY: html
99 html: Makefile
100 @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)