Debian Codegraph @

Makefile

raw
1 #
2 # 2013 Nico Schottelius (nico-cdist at schottelius.org)
3 #
4 # This file is part of cdist.
5 #
6 # cdist is free software: you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation, either version 3 of the License, or
9 # (at your option) any later version.
10 #
11 # cdist is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
15 #
16 # You should have received a copy of the GNU General Public License
17 # along with cdist. If not, see <http://www.gnu.org/licenses/>.
18 #
19 #
20
21 .PHONY: help
22 help:
23 @echo "Please use \`make <target>' where <target> is one of"
24 @echo "man build only man user documentation"
25 @echo "html build only html user documentation"
26 @echo "docs build both man and html user documentation"
27 @echo "dotman build man pages for types in your ~/.cdist directory"
28 @echo "speeches build speeches pdf files"
29 @echo "install install in the system site-packages directory"
30 @echo "install-user install in the user site-packages directory"
31 @echo "docs-clean clean documentation"
32 @echo "clean clean"
33
34 DOCS_SRC_DIR=./docs/src
35 SPEECHDIR=./docs/speeches
36 TYPEDIR=./cdist/conf/type
37
38 SPHINXM=$(MAKE) -C $(DOCS_SRC_DIR) man
39 SPHINXH=$(MAKE) -C $(DOCS_SRC_DIR) html
40 SPHINXC=$(MAKE) -C $(DOCS_SRC_DIR) clean
41
42 ################################################################################
43 # Manpages
44 #
45 MAN7DSTDIR=$(DOCS_SRC_DIR)/man7
46
47 # Manpages #1: Types
48 # Use shell / ls to get complete list - $(TYPEDIR)/*/man.rst does not work
49 # Using ls does not work if no file with given pattern exist, so use wildcard
50 MANTYPESRC=$(wildcard $(TYPEDIR)/*/man.rst)
51 MANTYPEPREFIX=$(subst $(TYPEDIR)/,$(MAN7DSTDIR)/cdist-type,$(MANTYPESRC))
52 MANTYPES=$(subst /man.rst,.rst,$(MANTYPEPREFIX))
53
54 # Link manpage: do not create man.html but correct named file
55 $(MAN7DSTDIR)/cdist-type%.rst: $(TYPEDIR)/%/man.rst
56 mkdir -p $(MAN7DSTDIR)
57 ln -sf "../../../$^" $@
58
59 # Manpages #2: reference
60 DOCSREF=$(MAN7DSTDIR)/cdist-reference.rst
61 DOCSREFSH=$(DOCS_SRC_DIR)/cdist-reference.rst.sh
62
63 $(DOCSREF): $(DOCSREFSH)
64 $(DOCSREFSH)
65
66 # Html types list with references
67 DOCSTYPESREF=$(MAN7DSTDIR)/cdist-types.rst
68 DOCSTYPESREFSH=$(DOCS_SRC_DIR)/cdist-types.rst.sh
69
70 $(DOCSTYPESREF): $(DOCSTYPESREFSH)
71 $(DOCSTYPESREFSH)
72
73 DOCSCFGSKEL=./configuration/cdist.cfg.skeleton
74
75 configskel: $(DOCSCFGSKEL)
76 cp -f "$(DOCSCFGSKEL)" "$(DOCS_SRC_DIR)/"
77
78 version:
79 @[ -f "cdist/version.py" ] || { \
80 printf "Missing 'cdist/version.py', please generate it first.\n" && exit 1; \
81 }
82
83 # Manpages #3: generic part
84 man: version configskel $(MANTYPES) $(DOCSREF) $(DOCSTYPESREF)
85 $(SPHINXM)
86
87 html: version configskel $(MANTYPES) $(DOCSREF) $(DOCSTYPESREF)
88 $(SPHINXH)
89
90 docs: man html
91
92 docs-clean:
93 $(SPHINXC)
94
95 # Manpages: .cdist Types
96 DOT_CDIST_PATH=${HOME}/.cdist
97 DOTMAN7DSTDIR=$(MAN7DSTDIR)
98 DOTTYPEDIR=$(DOT_CDIST_PATH)/type
99 DOTMANTYPESRC=$(wildcard $(DOTTYPEDIR)/*/man.rst)
100 DOTMANTYPEPREFIX=$(subst $(DOTTYPEDIR)/,$(DOTMAN7DSTDIR)/cdist-type,$(DOTMANTYPESRC))
101 DOTMANTYPES=$(subst /man.rst,.rst,$(DOTMANTYPEPREFIX))
102
103 # Link manpage: do not create man.html but correct named file
104 $(DOTMAN7DSTDIR)/cdist-type%.rst: $(DOTTYPEDIR)/%/man.rst
105 ln -sf "$^" $@
106
107 dotman: version configskel $(DOTMANTYPES) $(DOCSREF) $(DOCSTYPESREF)
108 $(SPHINXM)
109
110 ################################################################################
111 # Speeches
112 #
113 SPEECHESOURCES=$(SPEECHDIR)/*.tex
114 SPEECHES=$(SPEECHESOURCES:.tex=.pdf)
115
116 # Create speeches and ensure Toc is up-to-date
117 $(SPEECHDIR)/%.pdf: $(SPEECHDIR)/%.tex
118 pdflatex -output-directory $(SPEECHDIR) $^
119 pdflatex -output-directory $(SPEECHDIR) $^
120 pdflatex -output-directory $(SPEECHDIR) $^
121
122 speeches: $(SPEECHES)
123
124 ################################################################################
125 # Misc
126 #
127 clean: docs-clean
128 rm -f $(DOCS_SRC_DIR)/cdist-reference.rst
129 rm -f $(DOCS_SRC_DIR)/cdist-types.rst
130 rm -f $(DOCS_SRC_DIR)/cdist.cfg.skeleton
131
132 find "$(DOCS_SRC_DIR)" -mindepth 2 -type l \
133 | xargs rm -f
134
135 find * -name __pycache__ | xargs rm -rf
136
137 # distutils
138 rm -rf ./build
139
140 ################################################################################
141 # install
142 #
143
144 install:
145 python3 setup.py install
146
147 install-user:
148 python3 setup.py install --user