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