Makefile.am 20.8 KB
Newer Older
1 2 3 4 5
# Ganeti makefile
# - Indent with tabs only.
# - Keep files sorted; one line per file.
# - Directories in lib/ must have their own *dir variable (see hypervisor).
# - All directories must be listed DIRS.
Michael Hanselmann's avatar
Michael Hanselmann committed
6
# - Use autogen.sh to generate Makefile.in and configure script.
7 8 9 10 11

# Automake doesn't export these variables before version 1.10.
abs_top_builddir = @abs_top_builddir@
abs_top_srcdir = @abs_top_srcdir@

12
ACLOCAL_AMFLAGS = -I autotools
13
DOCBOOK_WRAPPER = $(top_srcdir)/autotools/docbook-wrapper
14
BUILD_BASH_COMPLETION = $(top_srcdir)/autotools/build-bash-completion
15
RUN_IN_TEMPDIR = $(top_srcdir)/autotools/run-in-tempdir
16
CHECK_PYTHON_CODE = $(top_srcdir)/autotools/check-python-code
17
CHECK_MAN = $(top_srcdir)/autotools/check-man
18 19
REPLACE_VARS_SED = autotools/replace_vars.sed

20
clientdir = $(pkgpythondir)/client
21
hypervisordir = $(pkgpythondir)/hypervisor
22
httpdir = $(pkgpythondir)/http
Michael Hanselmann's avatar
Michael Hanselmann committed
23
masterddir = $(pkgpythondir)/masterd
Guido Trotter's avatar
Guido Trotter committed
24
confddir = $(pkgpythondir)/confd
25
rapidir = $(pkgpythondir)/rapi
26
serverdir = $(pkgpythondir)/server
27
watcherdir = $(pkgpythondir)/watcher
28
impexpddir = $(pkgpythondir)/impexpd
29 30 31
toolsdir = $(pkglibdir)/tools
docdir = $(datadir)/doc/$(PACKAGE)

32 33 34
# Delete output file if an error occurred while building it
.DELETE_ON_ERROR:

35 36 37 38 39 40
DIRS = \
	autotools \
	daemons \
	devel \
	doc \
	doc/examples \
Guido Trotter's avatar
Guido Trotter committed
41
	doc/examples/hooks \
42
	doc/examples/gnt-debug \
43
	lib \
44
	lib/client \
45
	lib/build \
46
	lib/confd \
47
	lib/http \
48
	lib/hypervisor \
49
	lib/impexpd \
Michael Hanselmann's avatar
Michael Hanselmann committed
50
	lib/masterd \
51
	lib/rapi \
52
	lib/server \
53
	lib/watcher \
54 55 56 57 58 59
	man \
	qa \
	test \
	test/data \
	tools

60
BUILDTIME_DIRS = \
61
	scripts \
62 63 64 65 66 67 68 69 70
	doc/api \
	doc/coverage \
	doc/html

DIRCHECK_EXCLUDE = \
	$(BUILDTIME_DIRS) \
	ganeti-[0-9]*.[0-9]*.[0-9]* \
	doc/html/_*

71 72
all_dirfiles = $(addsuffix /.dir,$(DIRS) $(BUILDTIME_DIRS))

Iustin Pop's avatar
Iustin Pop committed
73
MAINTAINERCLEANFILES = \
74
	$(docpng) \
75
	$(maninput) \
76
	doc/install-quick.rst \
77 78
	doc/news.rst \
	vcs-version
Iustin Pop's avatar
Iustin Pop committed
79

80
maintainer-clean-local:
81
	rm -rf $(BUILDTIME_DIRS)
82

83
CLEANFILES = \
84
	$(addsuffix /*.py[co],$(DIRS)) \
85
	$(all_dirfiles) \
86
	$(PYTHON_BOOTSTRAP) \
87
	autotools/replace_vars.sed \
88
	daemons/daemon-util \
89
	daemons/ensure-dirs \
90
	daemons/ganeti-cleaner \
91
	devel/upload \
92
	doc/examples/bash_completion \
93 94
	doc/examples/ganeti.initd \
	doc/examples/ganeti.cron \
95
	doc/examples/gnt-config-backup \
Luca Bigliardi's avatar
Luca Bigliardi committed
96
	doc/examples/hooks/ipsec \
Iustin Pop's avatar
Iustin Pop committed
97 98
	$(man_MANS) \
	$(manhtml) \
99
	stamp-srclinks \
100 101
	$(nodist_pkgpython_PYTHON)

102 103
# BUILT_SOURCES should only be used as a dependency on phony targets. Otherwise
# it'll cause the target to rebuild every time.
104 105
BUILT_SOURCES = \
	ganeti \
106
	stamp-srclinks \
107
	lib/_autoconf.py \
108
	$(all_dirfiles) \
109 110
	$(PYTHON_BOOTSTRAP)

111 112 113
nodist_pkgpython_PYTHON = \
	lib/_autoconf.py

114 115 116
noinst_PYTHON = \
	lib/build/__init__.py

117 118
pkgpython_PYTHON = \
	lib/__init__.py \
Guido Trotter's avatar
Guido Trotter committed
119
	lib/asyncnotifier.py \
120 121 122 123 124
	lib/backend.py \
	lib/bdev.py \
	lib/bootstrap.py \
	lib/cli.py \
	lib/cmdlib.py \
125
	lib/compat.py \
126 127
	lib/config.py \
	lib/constants.py \
128
	lib/daemon.py \
129
	lib/errors.py \
130
	lib/ht.py \
131
	lib/jqueue.py \
132
	lib/jstore.py \
133 134 135
	lib/locking.py \
	lib/luxi.py \
	lib/mcpu.py \
136
	lib/netutils.py \
137 138 139
	lib/objects.py \
	lib/opcodes.py \
	lib/rpc.py \
140
	lib/runtime.py \
141 142 143
	lib/serializer.py \
	lib/ssconf.py \
	lib/ssh.py \
144
	lib/storage.py \
145
	lib/utils.py \
146
	lib/uidpool.py \
147
	lib/workerpool.py
148

149
client_PYTHON = \
150
	lib/client/__init__.py \
151
	lib/client/gnt_backup.py \
152
	lib/client/gnt_cluster.py \
153
	lib/client/gnt_debug.py \
154
	lib/client/gnt_instance.py \
155
	lib/client/gnt_job.py \
156
	lib/client/gnt_node.py \
157
	lib/client/gnt_os.py
158

159 160 161
hypervisor_PYTHON = \
	lib/hypervisor/__init__.py \
	lib/hypervisor/hv_base.py \
162
	lib/hypervisor/hv_chroot.py \
163
	lib/hypervisor/hv_fake.py \
Guido Trotter's avatar
Guido Trotter committed
164
	lib/hypervisor/hv_kvm.py \
Iustin Pop's avatar
Iustin Pop committed
165
	lib/hypervisor/hv_lxc.py \
166 167
	lib/hypervisor/hv_xen.py

168 169
rapi_PYTHON = \
	lib/rapi/__init__.py \
170
	lib/rapi/baserlib.py \
David Knowles's avatar
David Knowles committed
171
	lib/rapi/client.py \
172
	lib/rapi/client_utils.py \
173 174
	lib/rapi/connector.py \
	lib/rapi/rlib2.py
175

176
http_PYTHON = \
177
	lib/http/__init__.py \
178
	lib/http/auth.py \
179 180
	lib/http/client.py \
	lib/http/server.py
181

Guido Trotter's avatar
Guido Trotter committed
182
confd_PYTHON = \
Guido Trotter's avatar
Guido Trotter committed
183
	lib/confd/__init__.py \
Guido Trotter's avatar
Guido Trotter committed
184
	lib/confd/client.py \
185 186
	lib/confd/querylib.py \
	lib/confd/server.py
187

Michael Hanselmann's avatar
Michael Hanselmann committed
188
masterd_PYTHON = \
189 190
	lib/masterd/__init__.py \
	lib/masterd/instance.py
Michael Hanselmann's avatar
Michael Hanselmann committed
191

192 193 194
impexpd_PYTHON = \
	lib/impexpd/__init__.py

195 196 197
watcher_PYTHON = \
	lib/watcher/__init__.py

198
server_PYTHON = \
199
	lib/server/__init__.py \
200
	lib/server/confd.py \
201 202
	lib/server/masterd.py \
	lib/server/noded.py
203

Michael Hanselmann's avatar
Michael Hanselmann committed
204
docrst = \
205
	doc/admin.rst \
206
	doc/design-2.0.rst \
207
	doc/design-2.1.rst \
208
	doc/design-2.2.rst \
Guido Trotter's avatar
Guido Trotter committed
209
	doc/design-2.3.rst \
210
	doc/cluster-merge.rst \
211
	doc/devnotes.rst \
212
	doc/glossary.rst \
213
	doc/hooks.rst \
214
	doc/iallocator.rst \
215
	doc/index.rst \
216
	doc/install-quick.rst \
217
	doc/install.rst \
218
	doc/locking.rst \
219
	doc/move-instance.rst \
Iustin Pop's avatar
Iustin Pop committed
220
	doc/news.rst \
221
	doc/rapi.rst \
222
	doc/security.rst \
Iustin Pop's avatar
Iustin Pop committed
223
	doc/walkthrough.rst
Michael Hanselmann's avatar
Michael Hanselmann committed
224

225 226 227 228
$(RUN_IN_TEMPDIR): | $(all_dirfiles)

doc/html/index.html: $(docrst) $(docpng) doc/conf.py configure.ac \
	$(RUN_IN_TEMPDIR) | doc/html/.dir
229 230
	@test -n "$(SPHINX)" || \
	    { echo 'sphinx-build' not found during configure; exit 1; }
231
	PYTHONPATH=. $(RUN_IN_TEMPDIR) $(SPHINX) -q -W -b html \
232
	    -d . \
233 234
	    -D version="$(VERSION_MAJOR).$(VERSION_MINOR)" \
	    -D release="$(PACKAGE_VERSION)" \
235 236 237 238
	    $(abs_top_srcdir)/doc $(CURDIR)/doc/html
	rm -f doc/html/.buildinfo doc/html/objects.inv
	touch $@

239
doc/html: doc/html/index.html
Iustin Pop's avatar
Iustin Pop committed
240

241 242 243 244 245 246 247 248
doc/news.rst: NEWS
	set -e; \
	{ echo '.. This file is automatically updated at build time from $<.'; \
	  echo '.. Do not edit.'; \
	  echo; \
	  cat $<; \
	} > $@

249 250 251 252 253 254 255 256
doc/install-quick.rst: INSTALL
	set -e; \
	{ echo '.. This file is automatically updated at build time from $<.'; \
	  echo '.. Do not edit.'; \
	  echo; \
	  cat $<; \
	} > $@

257
docdot = \
258 259 260
	doc/arch-2.0.dot \
	doc/design-2.1-lock-acquire.dot \
	doc/design-2.1-lock-release.dot
261

262
docpng = $(patsubst %.dot,%.png,$(docdot))
263

264 265 266 267 268 269 270 271
# Things to build but not to install (add it to EXTRA_DIST if it should be
# distributed)
noinst_DATA = \
	devel/upload \
	doc/html \
	doc/examples/bash_completion \
	doc/examples/ganeti.cron \
	doc/examples/ganeti.initd \
272
	doc/examples/gnt-config-backup \
273 274
	doc/examples/hooks/ipsec \
	$(manhtml)
275

276
gnt_scripts = \
277 278 279 280 281 282 283 284
	scripts/gnt-backup \
	scripts/gnt-cluster \
	scripts/gnt-debug \
	scripts/gnt-instance \
	scripts/gnt-job \
	scripts/gnt-node \
	scripts/gnt-os

285
PYTHON_BOOTSTRAP = \
286
	daemons/ganeti-confd \
287
	daemons/ganeti-masterd \
288
	daemons/ganeti-noded \
289
	daemons/ganeti-watcher \
290
	scripts/gnt-backup \
291
	scripts/gnt-cluster \
292
	scripts/gnt-debug \
293
	scripts/gnt-instance \
294
	scripts/gnt-job \
295
	scripts/gnt-node \
296
	scripts/gnt-os
297

298
dist_sbin_SCRIPTS = \
299
	daemons/ganeti-rapi
300

301
nodist_sbin_SCRIPTS = \
302
	$(PYTHON_BOOTSTRAP) \
303 304
	daemons/ganeti-cleaner

305 306 307 308
dist_tools_SCRIPTS = \
	tools/burnin \
	tools/cfgshell \
	tools/cfgupgrade \
309
	tools/cfgupgrade12 \
310
	tools/cluster-merge \
Iustin Pop's avatar
Iustin Pop committed
311
	tools/lvmstrap \
312
	tools/move-instance \
313
	tools/setup-ssh \
Iustin Pop's avatar
Iustin Pop committed
314
	tools/sanitize-config
315

316
pkglib_python_scripts = \
317 318
	daemons/import-export \
	tools/check-cert-expired
319

320
pkglib_SCRIPTS = \
321
	daemons/daemon-util \
322
	daemons/ensure-dirs \
323
	$(pkglib_python_scripts)
324

325 326
EXTRA_DIST = \
	NEWS \
Michael Hanselmann's avatar
Michael Hanselmann committed
327
	pylintrc \
328
	autotools/build-bash-completion \
329
	autotools/check-python-code \
330
	autotools/check-man \
331
	autotools/docbook-wrapper \
332
	autotools/gen-coverage \
333
	autotools/testrunner \
334
	$(RUN_IN_TEMPDIR) \
335
	daemons/daemon-util.in \
336
	daemons/ensure-dirs.in \
337
	daemons/ganeti-cleaner.in \
338
	$(pkglib_python_scripts) \
339
	devel/upload.in \
340
	$(docdot) \
341
	$(docpng) \
342 343 344
	$(docrst) \
	doc/conf.py \
	doc/html \
345 346
	doc/examples/ganeti.initd.in \
	doc/examples/ganeti.cron.in \
347
	doc/examples/gnt-config-backup.in \
348
	doc/examples/dumb-allocator \
349 350
	doc/examples/ganeti.default \
	doc/examples/ganeti.default-debug \
Guido Trotter's avatar
Guido Trotter committed
351
	doc/examples/hooks/ethers \
Luca Bigliardi's avatar
Luca Bigliardi committed
352
	doc/examples/hooks/ipsec.in \
353 354 355
	doc/examples/gnt-debug/README \
	doc/examples/gnt-debug/delay0.json \
	doc/examples/gnt-debug/delay50.json \
356 357 358 359 360
	test/testutils.py \
	test/mocks.py \
	$(dist_TESTS) \
	$(TEST_FILES) \
	man/footer.sgml \
361 362
	$(mansgml) \
	$(maninput) \
363
	qa/ganeti-qa.py \
Michael Hanselmann's avatar
Michael Hanselmann committed
364
	qa/qa-sample.json \
365 366 367 368 369 370 371 372
	qa/qa_cluster.py \
	qa/qa_config.py \
	qa/qa_daemon.py \
	qa/qa_env.py \
	qa/qa_error.py \
	qa/qa_instance.py \
	qa/qa_node.py \
	qa/qa_os.py \
Oleksiy Mishchenko's avatar
Oleksiy Mishchenko committed
373
	qa/qa_rapi.py \
374 375 376 377 378
	qa/qa_tags.py \
	qa/qa_utils.py

man_MANS = \
	man/ganeti.7 \
379
	man/ganeti-cleaner.8 \
Guido Trotter's avatar
Guido Trotter committed
380
	man/ganeti-confd.8 \
381
	man/ganeti-masterd.8 \
382 383
	man/ganeti-noded.8 \
	man/ganeti-os-interface.7 \
384
	man/ganeti-rapi.8 \
385 386 387
	man/ganeti-watcher.8 \
	man/gnt-backup.8 \
	man/gnt-cluster.8 \
388
	man/gnt-debug.8 \
389
	man/gnt-instance.8 \
390
	man/gnt-job.8 \
391 392 393
	man/gnt-node.8 \
	man/gnt-os.8

Iustin Pop's avatar
Iustin Pop committed
394 395
mansgml = $(patsubst %.7,%.sgml,$(patsubst %.8,%.sgml,$(man_MANS)))
manhtml = $(patsubst %.sgml,%.html,$(mansgml))
396 397 398
maninput = \
	$(patsubst %.7,%.7.in,$(patsubst %.8,%.8.in,$(man_MANS))) \
	$(patsubst %.html,%.html.in,$(manhtml))
399 400

TEST_FILES = \
Manuel Franceschini's avatar
Manuel Franceschini committed
401 402 403 404 405
	test/data/bdev-drbd-8.0.txt \
	test/data/bdev-drbd-8.3.txt \
	test/data/bdev-drbd-disk.txt \
	test/data/bdev-drbd-net-ip4.txt \
	test/data/bdev-drbd-net-ip6.txt \
406
	test/data/cert1.pem \
407
	test/data/proc_drbd8.txt \
408
	test/data/proc_drbd80-emptyline.txt \
409
	test/data/proc_drbd83.txt \
410
	test/data/sys_drbd_usermode_helper.txt \
411
	test/import-export_unittest-helper
412

413
python_tests = \
Guido Trotter's avatar
Guido Trotter committed
414
	test/ganeti.asyncnotifier_unittest.py \
415
	test/ganeti.backend_unittest.py \
416 417
	test/ganeti.bdev_unittest.py \
	test/ganeti.cli_unittest.py \
Guido Trotter's avatar
Guido Trotter committed
418
	test/ganeti.daemon_unittest.py \
419
	test/ganeti.cmdlib_unittest.py \
420
	test/ganeti.compat_unittest.py \
421
	test/ganeti.confd.client_unittest.py \
422
	test/ganeti.config_unittest.py \
423
	test/ganeti.constants_unittest.py \
424
	test/ganeti.errors_unittest.py \
425
	test/ganeti.hooks_unittest.py \
426
	test/ganeti.http_unittest.py \
427
	test/ganeti.hypervisor.hv_kvm_unittest.py \
428
	test/ganeti.impexpd_unittest.py \
429
	test/ganeti.jqueue_unittest.py \
430
	test/ganeti.locking_unittest.py \
431
	test/ganeti.luxi_unittest.py \
432
	test/ganeti.masterd.instance_unittest.py \
433
	test/ganeti.mcpu_unittest.py \
434
	test/ganeti.netutils_unittest.py \
435
	test/ganeti.objects_unittest.py \
436
	test/ganeti.opcodes_unittest.py \
David Knowles's avatar
David Knowles committed
437
	test/ganeti.rapi.client_unittest.py \
438
	test/ganeti.rapi.resources_unittest.py \
439
	test/ganeti.rapi.rlib2_unittest.py \
440
	test/ganeti.rpc_unittest.py \
441
	test/ganeti.runtime_unittest.py \
442 443
	test/ganeti.serializer_unittest.py \
	test/ganeti.ssh_unittest.py \
Balazs Lecz's avatar
Balazs Lecz committed
444
	test/ganeti.uidpool_unittest.py \
445
	test/ganeti.utils_unittest.py \
Luca Bigliardi's avatar
Luca Bigliardi committed
446
	test/ganeti.utils_mlockall_unittest.py \
447
	test/ganeti.workerpool_unittest.py \
448
	test/cfgupgrade_unittest.py \
449 450
	test/docs_unittest.py \
	test/tempfile_fork_unittest.py
451

452
dist_TESTS = \
453
	test/check-cert-expired_unittest.bash \
454
	test/daemon-util_unittest.bash \
455
	test/ganeti-cleaner_unittest.bash \
456
	test/import-export_unittest.bash \
457 458
	$(python_tests)

459 460 461 462
nodist_TESTS =

TESTS = $(dist_TESTS) $(nodist_TESTS)

463 464 465 466 467
# Environment for all tests
PLAIN_TESTS_ENVIRONMENT = \
	PYTHONPATH=. TOP_SRCDIR=$(abs_top_srcdir) PYTHON=$(PYTHON) $(RUN_IN_TEMPDIR)

# Environment for tests run by automake
468
TESTS_ENVIRONMENT = \
469
	$(PLAIN_TESTS_ENVIRONMENT) $(abs_top_srcdir)/autotools/testrunner
470

471
all_python_code = \
472 473
	$(dist_sbin_SCRIPTS) \
	$(dist_tools_SCRIPTS) \
474
	$(pkglib_python_scripts) \
475
	$(python_tests) \
476
	$(pkgpython_PYTHON) \
477
	$(client_PYTHON) \
478 479
	$(hypervisor_PYTHON) \
	$(rapi_PYTHON) \
480
	$(server_PYTHON) \
481 482
	$(http_PYTHON) \
	$(confd_PYTHON) \
Michael Hanselmann's avatar
Michael Hanselmann committed
483
	$(masterd_PYTHON) \
484
	$(impexpd_PYTHON) \
485
	$(watcher_PYTHON) \
486 487
	$(noinst_PYTHON)

488 489
srclink_files = \
	man/footer.sgml \
490
	test/check-cert-expired_unittest.bash \
491
	test/daemon-util_unittest.bash \
492
	test/ganeti-cleaner_unittest.bash \
493
	test/import-export_unittest.bash \
494 495 496
	$(all_python_code)

check_python_code = \
497
	$(BUILD_BASH_COMPLETION) \
498 499
	$(all_python_code)

500
lint_python_code = \
501
	ganeti \
502
	ganeti/http/server.py \
503 504
	$(dist_sbin_SCRIPTS) \
	$(dist_tools_SCRIPTS) \
505
	$(pkglib_python_scripts) \
506
	$(BUILD_BASH_COMPLETION)
507

508 509
test/daemon-util_unittest.bash: daemons/daemon-util

510 511
test/ganeti-cleaner_unittest.bash: daemons/ganeti-cleaner

512
devel/upload: devel/upload.in $(REPLACE_VARS_SED)
513 514 515
	sed -f $(REPLACE_VARS_SED) < $< > $@
	chmod u+x $@

516
daemons/%: daemons/%.in $(REPLACE_VARS_SED)
517
	sed -f $(REPLACE_VARS_SED) < $< > $@
518
	chmod +x $@
519

520
doc/examples/%: doc/examples/%.in $(REPLACE_VARS_SED)
521 522
	sed -f $(REPLACE_VARS_SED) < $< > $@

523
doc/examples/hooks/%: doc/examples/hooks/%.in $(REPLACE_VARS_SED)
Luca Bigliardi's avatar
Luca Bigliardi committed
524 525
	sed -f $(REPLACE_VARS_SED) < $< > $@

526
doc/examples/bash_completion: $(BUILD_BASH_COMPLETION) $(RUN_IN_TEMPDIR) \
527
	lib/cli.py $(gnt_scripts) $(client_PYTHON) tools/burnin
528
	PYTHONPATH=. $(RUN_IN_TEMPDIR) $(CURDIR)/$(BUILD_BASH_COMPLETION) > $@
529

530
doc/%.png: doc/%.dot
Iustin Pop's avatar
Iustin Pop committed
531
	@test -n "$(DOT)" || { echo 'dot' not found during configure; exit 1; }
532 533
	$(DOT) -Tpng -o $@ $<

Iustin Pop's avatar
Iustin Pop committed
534
man/%.7.in man/%.8.in: man/%.sgml man/footer.sgml $(DOCBOOK_WRAPPER)
535 536
	@test -n "$(DOCBOOK2MAN)" || \
	  { echo 'docbook2man' not found during configure; exit 1; }
Michael Hanselmann's avatar
Michael Hanselmann committed
537
	$(DOCBOOK_WRAPPER) "$(DOCBOOK2MAN)" $< $(notdir $(@:.in=)) $@
538
	if test -n "$(MAN_HAS_WARNINGS)"; then $(CHECK_MAN) $@; fi
Iustin Pop's avatar
Iustin Pop committed
539 540

man/%.html.in: man/%.sgml man/footer.sgml $(DOCBOOK_WRAPPER)
541 542
	@test -n "$(DOCBOOK2HTML)" || \
	  { echo 'docbook2html' not found during configure; exit 1; }
Michael Hanselmann's avatar
Michael Hanselmann committed
543
	$(DOCBOOK_WRAPPER) "$(DOCBOOK2HTML) --nochunks" $< $(notdir $(@:.in=)) $@
Iustin Pop's avatar
Iustin Pop committed
544

545
man/%.7: man/%.7.in $(REPLACE_VARS_SED)
Iustin Pop's avatar
Iustin Pop committed
546
	sed -f $(REPLACE_VARS_SED) < $< > $@
547

548
man/%.8: man/%.8.in $(REPLACE_VARS_SED)
Iustin Pop's avatar
Iustin Pop committed
549
	sed -f $(REPLACE_VARS_SED) < $< > $@
550

551
man/%.html: man/%.html.in $(REPLACE_VARS_SED)
Iustin Pop's avatar
Iustin Pop committed
552
	sed -f $(REPLACE_VARS_SED) < $< > $@
553

554 555 556 557 558 559 560 561 562
vcs-version:
	if test -d .git; then \
	  git describe > $@; \
	elif test ! -f $@ ; then \
	  echo "Cannot auto-generate $@ file"; exit 1; \
	fi

.PHONY: regen-vcs-version
regen-vcs-version:
563
	set -e; \
564 565 566 567 568 569
	cd $(srcdir); \
	if test -d .git; then \
	  rm -f vcs-version; \
	  $(MAKE) vcs-version; \
	fi

570
lib/_autoconf.py: Makefile vcs-version | lib/.dir
571 572
	set -e; \
	VCSVER=`cat $(abs_top_srcdir)/vcs-version`; \
573 574
	{ echo '# This file is automatically generated, do not edit!'; \
	  echo '#'; \
Iustin Pop's avatar
Iustin Pop committed
575 576 577 578 579 580 581 582 583
	  echo ''; \
	  echo '"""Build-time configuration for Ganeti.'; \
	  echo '';\
	  echo 'This file is autogenerated by the build process.'; \
	  echo 'For any changes you need to re-run ./configure (and'; \
	  echo 'not edit by hand).'; \
	  echo ''; \
	  echo '"""'; \
	  echo ''; \
584 585 586 587
	  echo '# pylint: disable-msg=C0301,C0324'; \
	  echo '# because this is autogenerated, we do not want'; \
	  echo '# style warnings' ; \
	  echo ''; \
588 589 590 591 592 593 594 595
	  echo "PACKAGE_VERSION = '$(PACKAGE_VERSION)'"; \
	  echo "VERSION_MAJOR = '$(VERSION_MAJOR)'"; \
	  echo "VERSION_MINOR = '$(VERSION_MINOR)'"; \
	  echo "VERSION_REVISION = '$(VERSION_REVISION)'"; \
	  echo "VERSION_SUFFIX = '$(VERSION_SUFFIX)'"; \
	  echo "VERSION_FULL = '$(VERSION_FULL)'"; \
	  echo "LOCALSTATEDIR = '$(localstatedir)'"; \
	  echo "SYSCONFDIR = '$(sysconfdir)'"; \
596
	  echo "SSH_CONFIG_DIR = '$(SSH_CONFIG_DIR)'"; \
597 598
	  echo "EXPORT_DIR = '$(EXPORT_DIR)'"; \
	  echo "OS_SEARCH_PATH = [$(OS_SEARCH_PATH)]"; \
599
	  echo "XEN_BOOTLOADER = '$(XEN_BOOTLOADER)'"; \
600 601 602
	  echo "XEN_KERNEL = '$(XEN_KERNEL)'"; \
	  echo "XEN_INITRD = '$(XEN_INITRD)'"; \
	  echo "FILE_STORAGE_DIR = '$(FILE_STORAGE_DIR)'"; \
603
	  echo "ENABLE_FILE_STORAGE = $(ENABLE_FILE_STORAGE)"; \
604
	  echo "IALLOCATOR_SEARCH_PATH = [$(IALLOCATOR_SEARCH_PATH)]"; \
605
	  echo "KVM_PATH = '$(KVM_PATH)'"; \
606 607
	  echo "SOCAT_PATH = '$(SOCAT)'"; \
	  echo "SOCAT_USE_ESCAPE = $(SOCAT_USE_ESCAPE)"; \
608 609
	  echo "LVM_STRIPECOUNT = $(LVM_STRIPECOUNT)"; \
	  echo "TOOLSDIR = '$(toolsdir)'"; \
610
	  echo "GNT_SCRIPTS = [$(foreach i,$(notdir $(gnt_scripts)),'$(i)',)]"; \
611
	  echo "PKGLIBDIR = '$(pkglibdir)'"; \
612
	  echo "DRBD_BARRIERS = $(DRBD_BARRIERS)"; \
613
	  echo "SYSLOG_USAGE = '$(SYSLOG_USAGE)'"; \
614
	  echo "DAEMONS_GROUP = '$(DAEMONS_GROUP)'"; \
615
	  echo "ADMIN_GROUP = '$(ADMIN_GROUP)'"; \
616
	  echo "MASTERD_USER = '$(MASTERD_USER)'"; \
617
	  echo "MASTERD_GROUP = '$(MASTERD_GROUP)'"; \
618
	  echo "RAPI_USER = '$(RAPI_USER)'"; \
619 620 621 622
	  echo "RAPI_GROUP = '$(RAPI_GROUP)'"; \
	  echo "CONFD_USER = '$(CONFD_USER)'"; \
	  echo "CONFD_GROUP = '$(CONFD_GROUP)'"; \
	  echo "NODED_USER = '$(NODED_USER)'"; \
623
	  echo "VCS_VERSION = '$$VCSVER'"; \
624 625
	} > $@

626
$(REPLACE_VARS_SED): Makefile
627 628 629 630
	set -e; \
	{ echo 's#@PREFIX@#$(prefix)#g'; \
	  echo 's#@SYSCONFDIR@#$(sysconfdir)#g'; \
	  echo 's#@LOCALSTATEDIR@#$(localstatedir)#g'; \
631
	  echo 's#@BINDIR@#$(bindir)#g'; \
632 633
	  echo 's#@SBINDIR@#$(sbindir)#g'; \
	  echo 's#@GANETI_VERSION@#$(PACKAGE_VERSION)#g'; \
634
	  echo 's#@CUSTOM_XEN_BOOTLOADER@#$(XEN_BOOTLOADER)#g'; \
635 636
	  echo 's#@CUSTOM_XEN_KERNEL@#$(XEN_KERNEL)#g'; \
	  echo 's#@CUSTOM_XEN_INITRD@#$(XEN_INITRD)#g'; \
637
	  echo 's#@RPL_FILE_STORAGE_DIR@#$(FILE_STORAGE_DIR)#g'; \
638
	  echo 's#@RPL_SSH_INITD_SCRIPT@#$(SSH_INITD_SCRIPT)#g'; \
Iustin Pop's avatar
Iustin Pop committed
639
	  echo 's#@PKGLIBDIR@#$(pkglibdir)#g'; \
640 641 642 643 644 645 646 647
	  echo 's#@GNTMASTERUSER@#$(MASTERD_USER)#g'; \
	  echo 's#@GNTRAPIUSER@#$(RAPI_USER)#g'; \
	  echo 's#@GNTCONFDUSER@#$(CONFD_USER)#g'; \
	  echo 's#@GNTNODEDUSER@#$(NODED_USER)#g'; \
	  echo 's#@GNTRAPIGROUP@#$(RAPI_GROUP)#g'; \
	  echo 's#@GNTADMINGROUP@#$(ADMIN_GROUP)#g'; \
	  echo 's#@GNTCONFDGROUP@#$(CONFD_GROUP)#g'; \
	  echo 's#@GNTMASTERDGROUP@#$(MASTERD_GROUP)#g'; \
648
	  echo 's#@GNTDAEMONSGROUP@#$(DAEMONS_GROUP)#g'; \
649 650
	} > $@

651
# Using deferred evaluation
652
daemons/ganeti-%: MODULE = ganeti.server.$(patsubst ganeti-%,%,$(notdir $@))
653
daemons/ganeti-watcher: MODULE = ganeti.watcher
654 655
scripts/%: MODULE = ganeti.client.$(subst -,_,$(notdir $@))

656
$(PYTHON_BOOTSTRAP): Makefile | $(all_dirfiles)
657
	test -n "$(MODULE)" || { echo Missing module; exit 1; }
658
	set -e; \
659
	{ echo '#!/usr/bin/python'; \
660
	  echo '# This file is automatically generated, do not edit!'; \
661
	  echo "# Edit $(MODULE) instead."; \
662
	  echo; \
663
	  echo '"""Bootstrap script for L{$(MODULE)}"""'; \
664 665 666 667 668
	  echo; \
	  echo '# pylint: disable-msg=C0103'; \
	  echo '# C0103: Invalid name'; \
	  echo; \
	  echo 'import sys'; \
669
	  echo 'import $(MODULE) as main'; \
670 671 672
	  echo; \
	  echo '# Temporarily alias commands until bash completion'; \
	  echo '# generator is changed'; \
673 674
	  echo 'if hasattr(main, "commands"):'; \
	  echo '  commands = main.commands'; \
675 676
	  echo; \
	  echo 'if __name__ == "__main__":'; \
677
	  echo '  sys.exit(main.Main())'; \
678 679 680
	} > $@
	chmod u+x $@

681 682
# We need to create symlinks because "make distcheck" will not install Python
# files when building.
683
stamp-srclinks: Makefile | $(all_dirfiles)
684
	set -e; \
685
	for i in $(srclink_files); do \
686 687 688 689
		if test ! -f $$i -a -f $(abs_top_srcdir)/$$i; then \
			$(LN_S) $(abs_top_srcdir)/$$i $$i; \
		fi; \
	done
690
	touch $@
691

Michael Hanselmann's avatar
Michael Hanselmann committed
692 693
.PHONY: ganeti
ganeti:
694
	cd $(top_builddir) && test -h "$@" || { rm -f $@ && $(LN_S) lib $@; }
Michael Hanselmann's avatar
Michael Hanselmann committed
695

696 697
.PHONY: check-dirs
check-dirs: $(BUILT_SOURCES)
Iustin Pop's avatar
Iustin Pop committed
698
	@set -e; \
699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719
	find . -type d \( \( -name . \) -o \( \
		-name .git -o \
		-name autom4te.cache \
		\) -prune -o -print \) | { \
		error=; \
		while read dir; do \
			case "$$dir" in \
				$(strip $(patsubst %,(./%) ;;,$(DIRCHECK_EXCLUDE) $(DIRS))) \
				*) error=1; echo "Directory $$dir not listed in Makefile" >&2 ;; \
			esac; \
		done; \
		for dir in $(DIRS); do \
			if ! test -d "$$dir"; then \
				echo "Directory $$dir listed in DIRS does not exist" >&2; \
				error=1; \
			fi \
		done; \
		if test -n "$$error"; then exit 1; else exit 0; fi; \
	}

check-local: check-dirs
720 721
	$(CHECK_PYTHON_CODE) $(check_python_code)

Iustin Pop's avatar
Iustin Pop committed
722
.PHONY: lint
723
lint: $(BUILT_SOURCES)
724 725
	@test -n "$(PYLINT)" || { echo 'pylint' not found during configure; exit 1; }
	$(PYLINT) $(LINT_OPTS) $(lint_python_code)
Iustin Pop's avatar
Iustin Pop committed
726

727 728 729 730 731 732 733 734
# a dist hook rule for updating the vcs-version file; this is
# hardcoded due to where it needs to build the file...
dist-hook:
	$(MAKE) regen-vcs-version && \
	rm -f $(top_distdir)/vcs-version && \
	cp -p $(srcdir)/vcs-version $(top_distdir)

# a distcheck hook rule for catching revision control directories
Iustin Pop's avatar
Iustin Pop committed
735
distcheck-hook:
736 737 738 739 740 741 742 743 744 745
	if find $(top_distdir) -name .svn -or -name .git | grep .; then \
		echo "Found revision control files in final archive." 1>&2; \
		exit 1; \
	fi
	if find $(top_distdir) -name '*.py[co]' | grep .; then \
		echo "Found Python byte code in final archive." 1>&2; \
		exit 1; \
	fi
	if find $(top_distdir) -name '*~' | grep .; then \
		echo "Found backup files in final archive." 1>&2; \
Iustin Pop's avatar
Iustin Pop committed
746 747
		exit 1; \
	fi
748 749 750 751 752 753 754 755 756
	if test -n "$(BUILD_RELEASE)" && \
	   grep -n -H -E '^\*.*unreleased' $(top_distdir)/NEWS; then \
		echo "Found unreleased version in NEWS." >&2; \
		exit 1; \
	fi

# When building a release, stricter checks should be used
distcheck-release: export BUILD_RELEASE = 1
distcheck-release: distcheck
Iustin Pop's avatar
Iustin Pop committed
757

Iustin Pop's avatar
Iustin Pop committed
758
install-exec-local:
759
	@mkdir_p@ "$(DESTDIR)${localstatedir}/lib/ganeti" \
760 761
	  "$(DESTDIR)${localstatedir}/log/ganeti" \
	  "$(DESTDIR)${localstatedir}/run/ganeti"
762

763 764 765 766
# To avoid conflicts between directory names and other targets, a file inside
# the directory is used to ensure its existence.
%.dir:
	@mkdir_p@ $* && touch $@
767

Iustin Pop's avatar
Iustin Pop committed
768
.PHONY: apidoc
769
apidoc: epydoc.conf $(RUN_IN_TEMPDIR) $(BUILT_SOURCES)
770 771 772
	$(RUN_IN_TEMPDIR) epydoc -v \
		--conf $(CURDIR)/epydoc.conf \
		--output $(CURDIR)/doc/api
Iustin Pop's avatar
Iustin Pop committed
773

774
.PHONY: TAGS
775
TAGS: $(BUILT_SOURCES)
776
	rm -f TAGS
Iustin Pop's avatar
Iustin Pop committed
777 778 779
	find . -path './lib/*.py' -o -path './scripts/gnt-*' -o \
	  -path './daemons/ganeti-*' -o -path './tools/*' -o \
	  -path './qa/*.py' | \
Iustin Pop's avatar
Iustin Pop committed
780
	  etags -l python -
781

782
.PHONY: coverage
783
coverage: $(BUILT_SOURCES) $(python_tests)
784 785 786 787
	set -e; \
	COVERAGE_FILE=$(CURDIR)/doc/coverage/data \
	TEXT_COVERAGE=$(CURDIR)/doc/coverage/report.txt \
	HTML_COVERAGE=$(CURDIR)/doc/coverage \
788 789
	$(PLAIN_TESTS_ENVIRONMENT) $(abs_top_srcdir)/autotools/gen-coverage \
	$(python_tests)
790