Makefile 4.27 KB
Newer Older
Nico Schottelius's avatar
Nico Schottelius committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
#
# 2013 Nico Schottelius (nico-cdist at schottelius.org)
#
# This file is part of cdist.
#
# cdist is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# cdist is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with cdist. If not, see <http://www.gnu.org/licenses/>.
#
#
20

21 22 23 24 25 26 27 28 29 30 31 32
.PHONY: help
help:
	@echo "Please use \`make <target>' where <target> is one of"
	@echo "man             build only man user documentation"
	@echo "html            build only html user documentation"
	@echo "docs            build both man and html user documentation"
	@echo "dotman          build man pages for types in your ~/.cdist directory"
	@echo "speeches        build speeches pdf files"
	@echo "install         install in the system site-packages directory"
	@echo "install-user    install in the user site-packages directory"
	@echo "docs-clean      clean documentation"
	@echo "clean           clean"
33

Darko Poljak's avatar
Darko Poljak committed
34 35 36
DOCS_SRC_DIR=./docs/src
SPEECHDIR=./docs/speeches
TYPEDIR=./cdist/conf/type
37

38 39
SPHINXM=make -C $(DOCS_SRC_DIR) man
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
Darko Poljak's avatar
Darko Poljak committed
48
# Use shell / ls to get complete list - $(TYPEDIR)/*/man.rst does not work
49 50
# Using ls does not work if no file with given pattern exist, so use wildcard
MANTYPESRC=$(wildcard $(TYPEDIR)/*/man.rst)
Nico Schottelius's avatar
Nico Schottelius committed
51
MANTYPEPREFIX=$(subst $(TYPEDIR)/,$(MAN7DSTDIR)/cdist-type,$(MANTYPESRC))
Darko Poljak's avatar
Darko Poljak committed
52
MANTYPES=$(subst /man.rst,.rst,$(MANTYPEPREFIX))
53

Darko Poljak's avatar
Darko Poljak committed
54 55
# Link manpage: do not create man.html but correct named file
$(MAN7DSTDIR)/cdist-type%.rst: $(TYPEDIR)/%/man.rst
56
	mkdir -p $(MAN7DSTDIR)
57 58
	ln -sf "../../../$^" $@

59
# Manpages #2: reference
60 61
DOCSREF=$(MAN7DSTDIR)/cdist-reference.rst
DOCSREFSH=$(DOCS_SRC_DIR)/cdist-reference.rst.sh
62

63 64
$(DOCSREF): $(DOCSREFSH)
	$(DOCSREFSH)
65

66 67 68 69 70 71 72
# Html types list with references
DOCSTYPESREF=$(MAN7DSTDIR)/cdist-types.rst
DOCSTYPESREFSH=$(DOCS_SRC_DIR)/cdist-types.rst.sh

$(DOCSTYPESREF): $(DOCSTYPESREFSH)
	$(DOCSTYPESREFSH)

73 74 75 76 77
DOCSCFGSKEL=./configuration/cdist.cfg.skeleton

configskel: $(DOCSCFGSKEL)
	cp -f "$(DOCSCFGSKEL)" "$(DOCS_SRC_DIR)/"

78 79 80 81 82
version:
	@[ -f "cdist/version.py" ] || { \
		printf "Missing 'cdist/version.py', please generate it first.\n" && exit 1; \
	}

Darko Poljak's avatar
Darko Poljak committed
83
# Manpages #3: generic part
84
man: version $(MANTYPES) $(DOCSREF)
Darko Poljak's avatar
Darko Poljak committed
85
	$(SPHINXM)
86

87
html: version configskel $(MANTYPES) $(DOCSREF) $(DOCSTYPESREF)
Darko Poljak's avatar
Darko Poljak committed
88
	$(SPHINXH)
89

90
docs: man html
91

92 93 94
docs-clean:
	$(SPHINXC)

95 96 97 98
# Manpages: .cdist Types
DOT_CDIST_PATH=${HOME}/.cdist
DOTMAN7DSTDIR=$(MAN7DSTDIR)
DOTTYPEDIR=$(DOT_CDIST_PATH)/type
99
DOTMANTYPESRC=$(wildcard $(DOTTYPEDIR)/*/man.rst)
100 101 102 103 104 105 106
DOTMANTYPEPREFIX=$(subst $(DOTTYPEDIR)/,$(DOTMAN7DSTDIR)/cdist-type,$(DOTMANTYPESRC))
DOTMANTYPES=$(subst /man.rst,.rst,$(DOTMANTYPEPREFIX))

# Link manpage: do not create man.html but correct named file
$(DOTMAN7DSTDIR)/cdist-type%.rst: $(DOTTYPEDIR)/%/man.rst
	ln -sf "$^" $@

107
dotman: version $(DOTMANTYPES)
108 109
	$(SPHINXM)

110 111 112 113 114 115 116 117 118 119 120 121 122 123
################################################################################
# Speeches
#
SPEECHESOURCES=$(SPEECHDIR)/*.tex
SPEECHES=$(SPEECHESOURCES:.tex=.pdf)

# Create speeches and ensure Toc is up-to-date
$(SPEECHDIR)/%.pdf: $(SPEECHDIR)/%.tex
	pdflatex -output-directory $(SPEECHDIR) $^
	pdflatex -output-directory $(SPEECHDIR) $^
	pdflatex -output-directory $(SPEECHDIR) $^

speeches: $(SPEECHES)

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 134
	| xargs rm -f

Nico Schottelius's avatar
Nico Schottelius committed
135
	find * -name __pycache__  | xargs rm -rf
136

137 138
	# distutils
	rm -rf ./build
Nico Schottelius's avatar
Nico Schottelius committed
139

Nico Schottelius's avatar
Nico Schottelius committed
140
################################################################################
141
# install
Nico Schottelius's avatar
Nico Schottelius committed
142 143
#

144 145
install:
	python3 setup.py install
146

147 148
install-user:
	python3 setup.py install --user