Makefile 7.88 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

Nico Schottelius's avatar
Nico Schottelius committed
21
helper=./bin/build-helper
22

23
DOCS_SRC_DIR=docs/src
24 25 26
SPEECHDIR=docs/speeches
TYPEDIR=cdist/conf/type

27 28
WEBSRCDIR=docs/web

Nico Schottelius's avatar
Nico Schottelius committed
29
WEBDIR=$$HOME/vcs/www.nico.schottelius.org
Nico Schottelius's avatar
Nico Schottelius committed
30
WEBBLOG=$(WEBDIR)/blog
31
WEBBASE=$(WEBDIR)/software/cdist
Nico Schottelius's avatar
Nico Schottelius committed
32 33 34
WEBPAGE=$(WEBBASE).mdwn

CHANGELOG_VERSION=$(shell $(helper) changelog-version)
35 36
CHANGELOG_FILE=docs/changelog

37
PYTHON_VERSION=cdist/version.py
38

39 40
SPHINXM=make -C $(DOCS_SRC_DIR) man
SPHINXH=make -C $(DOCS_SRC_DIR) html
41
SPHINXC=make -C $(DOCS_SRC_DIR) clean
42 43

SHELLCHECKCMD=shellcheck -s sh -f gcc -x
44 45
# Skip SC2154 for variables starting with __ since such variables are cdist
# environment variables.
46
SHELLCHECK_SKIP=grep -v ': __.*is referenced but not assigned.*\[SC2154\]'
47
################################################################################
Nico Schottelius's avatar
Nico Schottelius committed
48
# Manpages
49
#
50 51
MAN1DSTDIR=$(DOCS_SRC_DIR)/man1
MAN7DSTDIR=$(DOCS_SRC_DIR)/man7
Nico Schottelius's avatar
Nico Schottelius committed
52 53

# Manpages #1: Types
Darko Poljak's avatar
Darko Poljak committed
54
# Use shell / ls to get complete list - $(TYPEDIR)/*/man.rst does not work
Darko Poljak's avatar
Darko Poljak committed
55 56
# 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
57
MANTYPEPREFIX=$(subst $(TYPEDIR)/,$(MAN7DSTDIR)/cdist-type,$(MANTYPESRC))
Darko Poljak's avatar
Darko Poljak committed
58
MANTYPES=$(subst /man.rst,.rst,$(MANTYPEPREFIX))
59

Darko Poljak's avatar
Darko Poljak committed
60 61
# Link manpage: do not create man.html but correct named file
$(MAN7DSTDIR)/cdist-type%.rst: $(TYPEDIR)/%/man.rst
62
	mkdir -p $(MAN7DSTDIR)
63 64
	ln -sf "../../../$^" $@

Nico Schottelius's avatar
Nico Schottelius committed
65
# Manpages #2: reference
66 67
DOCSREF=$(MAN7DSTDIR)/cdist-reference.rst
DOCSREFSH=$(DOCS_SRC_DIR)/cdist-reference.rst.sh
Nico Schottelius's avatar
Nico Schottelius committed
68

69 70
$(DOCSREF): $(DOCSREFSH)
	$(DOCSREFSH)
Nico Schottelius's avatar
Nico Schottelius committed
71

Darko Poljak's avatar
Darko Poljak committed
72
# Manpages #3: generic part
73
man: $(MANTYPES) $(DOCSREF) $(PYTHON_VERSION)
Darko Poljak's avatar
Darko Poljak committed
74
	$(SPHINXM)
Nico Schottelius's avatar
Nico Schottelius committed
75

76
html: $(MANTYPES) $(DOCSREF) $(PYTHON_VERSION)
Darko Poljak's avatar
Darko Poljak committed
77
	$(SPHINXH)
78

79
docs: man html
Nico Schottelius's avatar
Nico Schottelius committed
80

81 82 83
docs-clean:
	$(SPHINXC)

Nico Schottelius's avatar
Nico Schottelius committed
84 85
# Manpages #5: release part
MANWEBDIR=$(WEBBASE)/man/$(CHANGELOG_VERSION)
Darko Poljak's avatar
Darko Poljak committed
86
HTMLBUILDDIR=docs/dist/html
Nico Schottelius's avatar
Nico Schottelius committed
87

Darko Poljak's avatar
Darko Poljak committed
88
docs-dist: html
Nico Schottelius's avatar
Nico Schottelius committed
89
	rm -rf "${MANWEBDIR}"
Darko Poljak's avatar
Darko Poljak committed
90 91 92 93
	mkdir -p "${MANWEBDIR}"
	# mkdir -p "${MANWEBDIR}/man1" "${MANWEBDIR}/man7"
	# cp ${MAN1DSTDIR}/*.html ${MAN1DSTDIR}/*.css ${MANWEBDIR}/man1
	# cp ${MAN7DSTDIR}/*.html ${MAN7DSTDIR}/*.css ${MANWEBDIR}/man7
Darko Poljak's avatar
Darko Poljak committed
94
	cp -R ${HTMLBUILDDIR}/* ${MANWEBDIR}
95
	cd ${MANWEBDIR} && git add . && git commit -m "cdist manpages update: $(CHANGELOG_VERSION)" || true
96

97
man-latest-link: web-pub
98
	# Fix ikiwiki, which does not like symlinks for pseudo security
99 100
	ssh staticweb.ungleich.ch \
		"cd /home/services/www/nico/nico.schottelius.org/www/software/cdist/man/ && rm -f latest && ln -sf "$(CHANGELOG_VERSION)" latest"
101

102 103 104 105
# Manpages: .cdist Types
DOT_CDIST_PATH=${HOME}/.cdist
DOTMAN7DSTDIR=$(MAN7DSTDIR)
DOTTYPEDIR=$(DOT_CDIST_PATH)/type
Darko Poljak's avatar
Darko Poljak committed
106
DOTMANTYPESRC=$(wildcard $(DOTTYPEDIR)/*/man.rst)
107 108 109 110 111 112 113 114
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 "$^" $@

# Manpages #3: generic part
115
dotman: $(DOTMANTYPES)
116 117
	$(SPHINXM)

118 119 120 121 122
################################################################################
# Speeches
#
SPEECHESOURCES=$(SPEECHDIR)/*.tex
SPEECHES=$(SPEECHESOURCES:.tex=.pdf)
Nico Schottelius's avatar
Nico Schottelius committed
123
SPEECHESWEBDIR=$(WEBBASE)/speeches
124 125 126 127 128 129 130 131 132

# 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)

133
speeches-dist: speeches
Nico Schottelius's avatar
Nico Schottelius committed
134 135 136
	rm -rf "${SPEECHESWEBDIR}"
	mkdir -p "${SPEECHESWEBDIR}"
	cp ${SPEECHES} "${SPEECHESWEBDIR}"
137
	cd ${SPEECHESWEBDIR} && git add . && git commit -m "cdist speeches updated" || true
Nico Schottelius's avatar
Nico Schottelius committed
138

139
################################################################################
140 141 142 143 144 145 146 147 148 149 150 151 152 153 154
# Website
#

BLOGFILE=$(WEBBLOG)/cdist-$(CHANGELOG_VERSION)-released.mdwn

$(BLOGFILE): $(CHANGELOG_FILE)
	$(helper) blog $(CHANGELOG_VERSION) $(BLOGFILE)

web-blog: $(BLOGFILE)

web-doc:
	# Go to top level, because of cdist.mdwn
	rsync -av "$(WEBSRCDIR)/" "${WEBBASE}/.."
	cd "${WEBBASE}/.." && git add cdist* && git commit -m "cdist doc update" cdist* || true

155
web-dist: web-blog web-doc
156

157
web-pub: web-dist docs-dist speeches-dist
158 159
	cd "${WEBDIR}" && make pub

160 161
web-release-all: man-latest-link
web-release-all-no-latest: web-pub
Nico Schottelius's avatar
Nico Schottelius committed
162

163
################################################################################
164
# Release: Mailinglist
165
#
166
ML_FILE=.lock-ml
Nico Schottelius's avatar
Nico Schottelius committed
167

168
# Only send mail once - lock until new changelog things happened
169
$(ML_FILE): $(CHANGELOG_FILE)
170 171
	$(helper) ml-release $(CHANGELOG_VERSION)
	touch $@
Nico Schottelius's avatar
Nico Schottelius committed
172

173
ml-release: $(ML_FILE)
Nico Schottelius's avatar
Nico Schottelius committed
174 175 176


################################################################################
177
# pypi
Nico Schottelius's avatar
Nico Schottelius committed
178
#
179 180
PYPI_FILE=.pypi-release
$(PYPI_FILE): man $(PYTHON_VERSION)
Nico Schottelius's avatar
Nico Schottelius committed
181
	python3 setup.py sdist upload
Nico Schottelius's avatar
Nico Schottelius committed
182
	touch $@
Nico Schottelius's avatar
Nico Schottelius committed
183

184
pypi-release: $(PYPI_FILE)
185 186 187
################################################################################
# archlinux
#
188
ARCHLINUX_FILE=.lock-archlinux
189
ARCHLINUXTAR=cdist-$(CHANGELOG_VERSION)-1.src.tar.gz
190

Nico Schottelius's avatar
Nico Schottelius committed
191
$(ARCHLINUXTAR): PKGBUILD
192
	umask 022; mkaurball
Nico Schottelius's avatar
Nico Schottelius committed
193

194
PKGBUILD: PKGBUILD.in $(PYTHON_VERSION)
195
	./PKGBUILD.in $(CHANGELOG_VERSION)
196

197
$(ARCHLINUX_FILE): $(ARCHLINUXTAR) $(PYTHON_VERSION)
198 199 200 201
	burp -c system $(ARCHLINUXTAR)
	touch $@

archlinux-release: $(ARCHLINUX_FILE)
202

Nico Schottelius's avatar
Nico Schottelius committed
203
################################################################################
204
# Release
Nico Schottelius's avatar
Nico Schottelius committed
205
#
Nico Schottelius's avatar
Nico Schottelius committed
206

207
$(PYTHON_VERSION) version: .git/refs/heads/master
208 209
	$(helper) version

210
# Code that is better handled in a shell script
211 212 213 214
check-%:
	$(helper) $@

release:
215
	$(helper) $@
Nico Schottelius's avatar
Nico Schottelius committed
216

217 218
################################################################################
# Cleanup
219
#
220 221

clean:
222
	rm -f $(DOCS_SRC_DIR)/cdist-reference.rst
223

224
	find "$(DOCS_SRC_DIR)" -mindepth 2 -type l \
225 226
	| xargs rm -f

227
	make -C $(DOCS_SRC_DIR) clean
Darko Poljak's avatar
Darko Poljak committed
228

Nico Schottelius's avatar
Nico Schottelius committed
229
	find * -name __pycache__  | xargs rm -rf
230 231 232 233

	# Archlinux
	rm -f cdist-*.pkg.tar.xz cdist-*.tar.gz
	rm -rf pkg/ src/
Nico Schottelius's avatar
Nico Schottelius committed
234

Nico Schottelius's avatar
Nico Schottelius committed
235 236 237
	rm -f MANIFEST PKGBUILD
	rm -rf dist/

238 239 240 241
	# Signed release
	rm -f cdist-*.tar.gz
	rm -f cdist-*.tar.gz.asc

Nico Schottelius's avatar
Nico Schottelius committed
242 243 244
distclean: clean
	rm -f cdist/version.py

Nico Schottelius's avatar
Nico Schottelius committed
245 246 247 248 249 250
################################################################################
# Misc
#

# The pub is Nico's "push to all git remotes" way ("make pub")
pub:
251
	git push --mirror
Nico Schottelius's avatar
Nico Schottelius committed
252 253 254

test:
	$(helper) $@
Darko Poljak's avatar
Darko Poljak committed
255

256 257 258
test-remote:
	$(helper) $@

259
pycodestyle pep8:
Darko Poljak's avatar
Darko Poljak committed
260
	$(helper) $@
261 262

shellcheck-global-explorers:
263 264
	@find cdist/conf/explorer -type f -exec $(SHELLCHECKCMD) {} + | $(SHELLCHECK_SKIP) || exit 0

265 266 267
shellcheck-type-explorers:
	@find cdist/conf/type -type f -path "*/explorer/*" -exec $(SHELLCHECKCMD) {} + | $(SHELLCHECK_SKIP) || exit 0

268
shellcheck-manifests:
269
	@find cdist/conf/type -type f -name manifest -exec $(SHELLCHECKCMD) {} + | $(SHELLCHECK_SKIP) || exit 0
270 271

shellcheck-local-gencodes:
272
	@find cdist/conf/type -type f -name gencode-local -exec $(SHELLCHECKCMD) {} + | $(SHELLCHECK_SKIP) || exit 0
273 274

shellcheck-remote-gencodes:
275
	@find cdist/conf/type -type f -name gencode-remote -exec $(SHELLCHECKCMD) {} + | $(SHELLCHECK_SKIP) || exit 0
276

Darko Poljak's avatar
Darko Poljak committed
277
shellcheck-scripts:
278
	@$(SHELLCHECKCMD) scripts/cdist-dump || exit 0
Darko Poljak's avatar
Darko Poljak committed
279

280 281
shellcheck-gencodes: shellcheck-local-gencodes shellcheck-remote-gencodes

282
shellcheck-types: shellcheck-type-explorers shellcheck-manifests shellcheck-gencodes
283

Darko Poljak's avatar
Darko Poljak committed
284
shellcheck: shellcheck-global-explorers shellcheck-types shellcheck-scripts
285 286 287 288 289

shellcheck-type-files:
	@find cdist/conf/type -type f -path "*/files/*" -exec $(SHELLCHECKCMD) {} + | $(SHELLCHECK_SKIP) || exit 0

shellcheck-with-files: shellcheck shellcheck-type-files