Shared file storage initialization code
[ganeti-local] / Makefile.am
1 # Ganeti makefile
2 # - Indent with tabs only.
3 # - Keep files sorted; one line per file.
4 # - Directories in lib/ must have their own *dir variable (see hypervisor).
5 # - All directories must be listed DIRS.
6 # - Use autogen.sh to generate Makefile.in and configure script.
7
8 # Automake doesn't export these variables before version 1.10.
9 abs_top_builddir = @abs_top_builddir@
10 abs_top_srcdir = @abs_top_srcdir@
11
12 # Use bash in order to be able to use pipefail
13 SHELL=/bin/bash
14
15 ACLOCAL_AMFLAGS = -I autotools
16 BUILD_BASH_COMPLETION = $(top_srcdir)/autotools/build-bash-completion
17 RUN_IN_TEMPDIR = $(top_srcdir)/autotools/run-in-tempdir
18 CHECK_PYTHON_CODE = $(top_srcdir)/autotools/check-python-code
19 CHECK_MAN = $(top_srcdir)/autotools/check-man
20 CHECK_VERSION = $(top_srcdir)/autotools/check-version
21 CHECK_NEWS = $(top_srcdir)/autotools/check-news
22 DOCPP = $(top_srcdir)/autotools/docpp
23 REPLACE_VARS_SED = autotools/replace_vars.sed
24
25 clientdir = $(pkgpythondir)/client
26 hypervisordir = $(pkgpythondir)/hypervisor
27 httpdir = $(pkgpythondir)/http
28 masterddir = $(pkgpythondir)/masterd
29 confddir = $(pkgpythondir)/confd
30 rapidir = $(pkgpythondir)/rapi
31 serverdir = $(pkgpythondir)/server
32 watcherdir = $(pkgpythondir)/watcher
33 impexpddir = $(pkgpythondir)/impexpd
34 utilsdir = $(pkgpythondir)/utils
35 toolsdir = $(pkglibdir)/tools
36 docdir = $(datadir)/doc/$(PACKAGE)
37
38 # Delete output file if an error occurred while building it
39 .DELETE_ON_ERROR:
40
41 DIRS = \
42         autotools \
43         daemons \
44         devel \
45         doc \
46         doc/examples \
47         doc/examples/hooks \
48         doc/examples/gnt-debug \
49         lib \
50         lib/client \
51         lib/build \
52         lib/confd \
53         lib/http \
54         lib/hypervisor \
55         lib/impexpd \
56         lib/masterd \
57         lib/rapi \
58         lib/server \
59         lib/utils \
60         lib/watcher \
61         man \
62         qa \
63         test \
64         test/data \
65         tools
66
67 BUILDTIME_DIR_AUTOCREATE = \
68         scripts \
69         doc/api \
70         doc/coverage
71
72 BUILDTIME_DIRS = \
73         $(BUILDTIME_DIR_AUTOCREATE) \
74         doc/html
75
76 DIRCHECK_EXCLUDE = \
77         $(BUILDTIME_DIRS) \
78         ganeti-[0-9]*.[0-9]*.[0-9]* \
79         doc/html/_*
80
81 all_dirfiles = $(addsuffix /.dir,$(DIRS) $(BUILDTIME_DIR_AUTOCREATE))
82
83 MAINTAINERCLEANFILES = \
84         $(docpng) \
85         $(maninput) \
86         doc/install-quick.rst \
87         doc/news.rst \
88         doc/upgrade.rst \
89         vcs-version
90
91 maintainer-clean-local:
92         rm -rf $(BUILDTIME_DIRS)
93
94 CLEANFILES = \
95         $(addsuffix /*.py[co],$(DIRS)) \
96         $(all_dirfiles) \
97         $(PYTHON_BOOTSTRAP) \
98         epydoc.conf \
99         autotools/replace_vars.sed \
100         daemons/daemon-util \
101         daemons/ensure-dirs \
102         daemons/ganeti-cleaner \
103         devel/upload \
104         doc/examples/bash_completion \
105         doc/examples/ganeti.initd \
106         doc/examples/ganeti-kvm-poweroff.initd \
107         doc/examples/ganeti.cron \
108         doc/examples/gnt-config-backup \
109         doc/examples/hooks/ipsec \
110         $(man_MANS) \
111         $(manhtml) \
112         tools/kvm-ifup \
113         stamp-srclinks \
114         $(nodist_pkgpython_PYTHON)
115
116 # BUILT_SOURCES should only be used as a dependency on phony targets. Otherwise
117 # it'll cause the target to rebuild every time.
118 BUILT_SOURCES = \
119         ganeti \
120         stamp-srclinks \
121         lib/_autoconf.py \
122         $(all_dirfiles) \
123         $(PYTHON_BOOTSTRAP)
124
125 nodist_pkgpython_PYTHON = \
126         lib/_autoconf.py
127
128 noinst_PYTHON = \
129         lib/build/__init__.py \
130         lib/build/sphinx_ext.py
131
132 pkgpython_PYTHON = \
133         lib/__init__.py \
134         lib/asyncnotifier.py \
135         lib/backend.py \
136         lib/bdev.py \
137         lib/bootstrap.py \
138         lib/cli.py \
139         lib/cmdlib.py \
140         lib/compat.py \
141         lib/config.py \
142         lib/constants.py \
143         lib/daemon.py \
144         lib/errors.py \
145         lib/ht.py \
146         lib/jqueue.py \
147         lib/jstore.py \
148         lib/locking.py \
149         lib/luxi.py \
150         lib/mcpu.py \
151         lib/netutils.py \
152         lib/objects.py \
153         lib/opcodes.py \
154         lib/qlang.py \
155         lib/query.py \
156         lib/rpc.py \
157         lib/runtime.py \
158         lib/serializer.py \
159         lib/ssconf.py \
160         lib/ssh.py \
161         lib/storage.py \
162         lib/uidpool.py \
163         lib/workerpool.py
164
165 client_PYTHON = \
166         lib/client/__init__.py \
167         lib/client/gnt_backup.py \
168         lib/client/gnt_cluster.py \
169         lib/client/gnt_debug.py \
170         lib/client/gnt_group.py \
171         lib/client/gnt_instance.py \
172         lib/client/gnt_job.py \
173         lib/client/gnt_node.py \
174         lib/client/gnt_os.py
175
176 hypervisor_PYTHON = \
177         lib/hypervisor/__init__.py \
178         lib/hypervisor/hv_base.py \
179         lib/hypervisor/hv_chroot.py \
180         lib/hypervisor/hv_fake.py \
181         lib/hypervisor/hv_kvm.py \
182         lib/hypervisor/hv_lxc.py \
183         lib/hypervisor/hv_xen.py
184
185 rapi_PYTHON = \
186         lib/rapi/__init__.py \
187         lib/rapi/baserlib.py \
188         lib/rapi/client.py \
189         lib/rapi/client_utils.py \
190         lib/rapi/connector.py \
191         lib/rapi/rlib2.py
192
193 http_PYTHON = \
194         lib/http/__init__.py \
195         lib/http/auth.py \
196         lib/http/client.py \
197         lib/http/server.py
198
199 confd_PYTHON = \
200         lib/confd/__init__.py \
201         lib/confd/client.py \
202         lib/confd/querylib.py \
203         lib/confd/server.py
204
205 masterd_PYTHON = \
206         lib/masterd/__init__.py \
207         lib/masterd/instance.py
208
209 impexpd_PYTHON = \
210         lib/impexpd/__init__.py
211
212 watcher_PYTHON = \
213         lib/watcher/__init__.py
214
215 server_PYTHON = \
216         lib/server/__init__.py \
217         lib/server/confd.py \
218         lib/server/masterd.py \
219         lib/server/noded.py \
220         lib/server/rapi.py
221
222 utils_PYTHON = \
223         lib/utils/__init__.py \
224         lib/utils/algo.py \
225         lib/utils/filelock.py \
226         lib/utils/hash.py \
227         lib/utils/io.py \
228         lib/utils/log.py \
229         lib/utils/mlock.py \
230         lib/utils/nodesetup.py \
231         lib/utils/process.py \
232         lib/utils/retry.py \
233         lib/utils/text.py \
234         lib/utils/wrapper.py \
235         lib/utils/x509.py
236
237 docrst = \
238         doc/admin.rst \
239         doc/design-2.0.rst \
240         doc/design-2.1.rst \
241         doc/design-2.2.rst \
242         doc/design-2.3.rst \
243         doc/design-2.4.rst \
244         doc/design-draft.rst \
245         doc/design-oob.rst \
246         doc/design-query2.rst \
247         doc/cluster-merge.rst \
248         doc/design-shared-storage.rst \
249         doc/devnotes.rst \
250         doc/glossary.rst \
251         doc/hooks.rst \
252         doc/iallocator.rst \
253         doc/index.rst \
254         doc/install-quick.rst \
255         doc/install.rst \
256         doc/locking.rst \
257         doc/move-instance.rst \
258         doc/news.rst \
259         doc/rapi.rst \
260         doc/security.rst \
261         doc/upgrade.rst \
262         doc/walkthrough.rst
263
264 $(RUN_IN_TEMPDIR): | $(all_dirfiles)
265
266 # Note: we use here an order-only prerequisite, as the contents of
267 # _autoconf.py are not actually influencing the html build output: it
268 # has to exist in order for the sphinx module to be loaded
269 # successfully, but we certainly don't want the docs to be rebuilt if
270 # it changes
271 doc/html/index.html: $(docrst) $(docpng) doc/conf.py configure.ac \
272         $(RUN_IN_TEMPDIR) lib/build/sphinx_ext.py lib/opcodes.py lib/ht.py \
273         | lib/_autoconf.py
274         @test -n "$(SPHINX)" || \
275             { echo 'sphinx-build' not found during configure; exit 1; }
276         @mkdir_p@ $(dir $@)
277         PYTHONPATH=. $(RUN_IN_TEMPDIR) $(SPHINX) -q -W -b html \
278             -d . \
279             -D version="$(VERSION_MAJOR).$(VERSION_MINOR)" \
280             -D release="$(PACKAGE_VERSION)" \
281             $(abs_top_srcdir)/doc $(CURDIR)/doc/html
282         rm -f doc/html/.buildinfo doc/html/objects.inv
283         touch $@
284
285 doc/html: doc/html/index.html
286
287 doc/install-quick.rst: INSTALL
288 doc/news.rst: NEWS
289 doc/upgrade.rst: UPGRADE
290
291 doc/install-quick.rst doc/news.rst doc/upgrade.rst:
292         set -e; \
293         { echo '.. This file is automatically updated at build time from $<.'; \
294           echo '.. Do not edit.'; \
295           echo; \
296           cat $<; \
297         } > $@
298
299 docdot = \
300         doc/arch-2.0.dot \
301         doc/design-2.1-lock-acquire.dot \
302         doc/design-2.1-lock-release.dot
303
304 docpng = $(patsubst %.dot,%.png,$(docdot))
305
306 # Things to build but not to install (add it to EXTRA_DIST if it should be
307 # distributed)
308 noinst_DATA = \
309         devel/upload \
310         doc/html \
311         doc/examples/bash_completion \
312         doc/examples/ganeti.cron \
313         doc/examples/ganeti.initd \
314         doc/examples/ganeti-kvm-poweroff.initd \
315         doc/examples/gnt-config-backup \
316         doc/examples/hooks/ipsec \
317         $(manhtml)
318
319 gnt_scripts = \
320         scripts/gnt-backup \
321         scripts/gnt-cluster \
322         scripts/gnt-debug \
323         scripts/gnt-group \
324         scripts/gnt-instance \
325         scripts/gnt-job \
326         scripts/gnt-node \
327         scripts/gnt-os
328
329 PYTHON_BOOTSTRAP = \
330         daemons/ganeti-confd \
331         daemons/ganeti-masterd \
332         daemons/ganeti-noded \
333         daemons/ganeti-watcher \
334         daemons/ganeti-rapi \
335         scripts/gnt-backup \
336         scripts/gnt-cluster \
337         scripts/gnt-debug \
338         scripts/gnt-group \
339         scripts/gnt-instance \
340         scripts/gnt-job \
341         scripts/gnt-node \
342         scripts/gnt-os
343
344 qa_scripts = \
345         qa/ganeti-qa.py \
346         qa/qa_cluster.py \
347         qa/qa_config.py \
348         qa/qa_daemon.py \
349         qa/qa_env.py \
350         qa/qa_error.py \
351         qa/qa_instance.py \
352         qa/qa_node.py \
353         qa/qa_os.py \
354         qa/qa_rapi.py \
355         qa/qa_tags.py \
356         qa/qa_utils.py
357
358 dist_sbin_SCRIPTS = \
359         tools/ganeti-listrunner
360
361 nodist_sbin_SCRIPTS = \
362         $(PYTHON_BOOTSTRAP) \
363         daemons/ganeti-cleaner
364
365 dist_tools_SCRIPTS = \
366         tools/burnin \
367         tools/cfgshell \
368         tools/cfgupgrade \
369         tools/cfgupgrade12 \
370         tools/cluster-merge \
371         tools/lvmstrap \
372         tools/move-instance \
373         tools/setup-ssh \
374         tools/sanitize-config
375
376 pkglib_python_scripts = \
377         daemons/import-export \
378         tools/check-cert-expired
379
380 pkglib_SCRIPTS = \
381         daemons/daemon-util \
382         daemons/ensure-dirs \
383         tools/kvm-ifup \
384         $(pkglib_python_scripts)
385
386 EXTRA_DIST = \
387         NEWS \
388         UPGRADE \
389         epydoc.conf.in \
390         pylintrc \
391         autotools/build-bash-completion \
392         autotools/check-python-code \
393         autotools/check-man \
394         autotools/check-news \
395         autotools/check-tar \
396         autotools/check-version \
397         autotools/docpp \
398         autotools/gen-coverage \
399         autotools/testrunner \
400         $(RUN_IN_TEMPDIR) \
401         daemons/daemon-util.in \
402         daemons/ensure-dirs.in \
403         daemons/ganeti-cleaner.in \
404         $(pkglib_python_scripts) \
405         devel/upload.in \
406         tools/kvm-ifup.in \
407         $(docdot) \
408         $(docpng) \
409         $(docrst) \
410         doc/conf.py \
411         doc/html \
412         doc/examples/ganeti.initd.in \
413         doc/examples/ganeti-kvm-poweroff.initd.in \
414         doc/examples/ganeti.cron.in \
415         doc/examples/gnt-config-backup.in \
416         doc/examples/ganeti.default \
417         doc/examples/ganeti.default-debug \
418         doc/examples/hooks/ethers \
419         doc/examples/hooks/ipsec.in \
420         doc/examples/gnt-debug/README \
421         doc/examples/gnt-debug/delay0.json \
422         doc/examples/gnt-debug/delay50.json \
423         test/testutils.py \
424         test/mocks.py \
425         $(dist_TESTS) \
426         $(TEST_FILES) \
427         man/footer.rst \
428         $(manrst) \
429         $(maninput) \
430         qa/qa-sample.json \
431         $(qa_scripts)
432
433 man_MANS = \
434         man/ganeti.7 \
435         man/ganeti-cleaner.8 \
436         man/ganeti-confd.8 \
437         man/ganeti-listrunner.8 \
438         man/ganeti-masterd.8 \
439         man/ganeti-noded.8 \
440         man/ganeti-os-interface.7 \
441         man/ganeti-rapi.8 \
442         man/ganeti-watcher.8 \
443         man/gnt-backup.8 \
444         man/gnt-cluster.8 \
445         man/gnt-debug.8 \
446         man/gnt-group.8 \
447         man/gnt-instance.8 \
448         man/gnt-job.8 \
449         man/gnt-node.8 \
450         man/gnt-os.8
451
452 manrst = $(patsubst %.7,%.rst,$(patsubst %.8,%.rst,$(man_MANS)))
453 manhtml = $(patsubst %.rst,%.html,$(manrst))
454 mangen = $(patsubst %.rst,%.gen,$(manrst))
455 maninput = \
456         $(patsubst %.7,%.7.in,$(patsubst %.8,%.8.in,$(man_MANS))) \
457         $(patsubst %.html,%.html.in,$(manhtml)) \
458         man/footer.man man/footer.html $(mangen)
459
460 TEST_FILES = \
461         test/data/bdev-drbd-8.0.txt \
462         test/data/bdev-drbd-8.3.txt \
463         test/data/bdev-drbd-disk.txt \
464         test/data/bdev-drbd-net-ip4.txt \
465         test/data/bdev-drbd-net-ip6.txt \
466         test/data/cert1.pem \
467         test/data/proc_drbd8.txt \
468         test/data/proc_drbd80-emptyline.txt \
469         test/data/proc_drbd83.txt \
470         test/data/sys_drbd_usermode_helper.txt \
471         test/import-export_unittest-helper
472
473 python_tests = \
474         test/ganeti.asyncnotifier_unittest.py \
475         test/ganeti.backend_unittest.py \
476         test/ganeti.bdev_unittest.py \
477         test/ganeti.cli_unittest.py \
478         test/ganeti.client.gnt_cluster_unittest.py \
479         test/ganeti.client.gnt_instance_unittest.py \
480         test/ganeti.daemon_unittest.py \
481         test/ganeti.cmdlib_unittest.py \
482         test/ganeti.compat_unittest.py \
483         test/ganeti.confd.client_unittest.py \
484         test/ganeti.config_unittest.py \
485         test/ganeti.constants_unittest.py \
486         test/ganeti.errors_unittest.py \
487         test/ganeti.hooks_unittest.py \
488         test/ganeti.ht_unittest.py \
489         test/ganeti.http_unittest.py \
490         test/ganeti.hypervisor_unittest.py \
491         test/ganeti.hypervisor.hv_chroot_unittest.py \
492         test/ganeti.hypervisor.hv_fake_unittest.py \
493         test/ganeti.hypervisor.hv_kvm_unittest.py \
494         test/ganeti.hypervisor.hv_lxc_unittest.py \
495         test/ganeti.hypervisor.hv_xen_unittest.py \
496         test/ganeti.impexpd_unittest.py \
497         test/ganeti.jqueue_unittest.py \
498         test/ganeti.locking_unittest.py \
499         test/ganeti.luxi_unittest.py \
500         test/ganeti.masterd.instance_unittest.py \
501         test/ganeti.mcpu_unittest.py \
502         test/ganeti.netutils_unittest.py \
503         test/ganeti.objects_unittest.py \
504         test/ganeti.opcodes_unittest.py \
505         test/ganeti.qlang_unittest.py \
506         test/ganeti.query_unittest.py \
507         test/ganeti.rapi.baserlib_unittest.py \
508         test/ganeti.rapi.client_unittest.py \
509         test/ganeti.rapi.resources_unittest.py \
510         test/ganeti.rapi.rlib2_unittest.py \
511         test/ganeti.rpc_unittest.py \
512         test/ganeti.runtime_unittest.py \
513         test/ganeti.serializer_unittest.py \
514         test/ganeti.ssh_unittest.py \
515         test/ganeti.uidpool_unittest.py \
516         test/ganeti.utils.algo_unittest.py \
517         test/ganeti.utils.filelock_unittest.py \
518         test/ganeti.utils.hash_unittest.py \
519         test/ganeti.utils.io_unittest.py \
520         test/ganeti.utils.log_unittest.py \
521         test/ganeti.utils.mlock_unittest.py \
522         test/ganeti.utils.nodesetup_unittest.py \
523         test/ganeti.utils.process_unittest.py \
524         test/ganeti.utils.retry_unittest.py \
525         test/ganeti.utils.text_unittest.py \
526         test/ganeti.utils.wrapper_unittest.py \
527         test/ganeti.utils.x509_unittest.py \
528         test/ganeti.utils_unittest.py \
529         test/ganeti.workerpool_unittest.py \
530         test/cfgupgrade_unittest.py \
531         test/docs_unittest.py \
532         test/tempfile_fork_unittest.py
533
534 dist_TESTS = \
535         test/check-cert-expired_unittest.bash \
536         test/daemon-util_unittest.bash \
537         test/ganeti-cleaner_unittest.bash \
538         test/import-export_unittest.bash \
539         $(python_tests)
540
541 nodist_TESTS =
542
543 TESTS = $(dist_TESTS) $(nodist_TESTS)
544
545 # Environment for all tests
546 PLAIN_TESTS_ENVIRONMENT = \
547         PYTHONPATH=. TOP_SRCDIR=$(abs_top_srcdir) PYTHON=$(PYTHON) $(RUN_IN_TEMPDIR)
548
549 # Environment for tests run by automake
550 TESTS_ENVIRONMENT = \
551         $(PLAIN_TESTS_ENVIRONMENT) $(abs_top_srcdir)/autotools/testrunner
552
553 all_python_code = \
554         $(dist_sbin_SCRIPTS) \
555         $(dist_tools_SCRIPTS) \
556         $(pkglib_python_scripts) \
557         $(python_tests) \
558         $(pkgpython_PYTHON) \
559         $(client_PYTHON) \
560         $(hypervisor_PYTHON) \
561         $(rapi_PYTHON) \
562         $(server_PYTHON) \
563         $(http_PYTHON) \
564         $(confd_PYTHON) \
565         $(masterd_PYTHON) \
566         $(impexpd_PYTHON) \
567         $(utils_PYTHON) \
568         $(watcher_PYTHON) \
569         $(noinst_PYTHON) \
570         $(qa_scripts)
571
572 srclink_files = \
573         man/footer.rst \
574         test/check-cert-expired_unittest.bash \
575         test/daemon-util_unittest.bash \
576         test/ganeti-cleaner_unittest.bash \
577         test/import-export_unittest.bash \
578         $(all_python_code)
579
580 check_python_code = \
581         $(BUILD_BASH_COMPLETION) \
582         $(DOCPP) \
583         $(all_python_code)
584
585 lint_python_code = \
586         ganeti \
587         ganeti/http/server.py \
588         $(dist_sbin_SCRIPTS) \
589         $(dist_tools_SCRIPTS) \
590         $(pkglib_python_scripts) \
591         $(BUILD_BASH_COMPLETION) \
592         $(DOCPP) \
593         $(PYTHON_BOOTSTRAP)
594
595 test/daemon-util_unittest.bash: daemons/daemon-util
596
597 test/ganeti-cleaner_unittest.bash: daemons/ganeti-cleaner
598
599 tools/kvm-ifup: tools/kvm-ifup.in $(REPLACE_VARS_SED)
600         sed -f $(REPLACE_VARS_SED) < $< > $@
601         chmod +x $@
602
603 devel/upload: devel/upload.in $(REPLACE_VARS_SED)
604         sed -f $(REPLACE_VARS_SED) < $< > $@
605         chmod u+x $@
606
607 daemons/%: daemons/%.in $(REPLACE_VARS_SED)
608         sed -f $(REPLACE_VARS_SED) < $< > $@
609         chmod +x $@
610
611 doc/examples/%: doc/examples/%.in $(REPLACE_VARS_SED)
612         sed -f $(REPLACE_VARS_SED) < $< > $@
613
614 doc/examples/hooks/%: doc/examples/hooks/%.in $(REPLACE_VARS_SED)
615         sed -f $(REPLACE_VARS_SED) < $< > $@
616
617 doc/examples/bash_completion: $(BUILD_BASH_COMPLETION) $(RUN_IN_TEMPDIR) \
618         lib/cli.py $(gnt_scripts) $(client_PYTHON) tools/burnin
619         PYTHONPATH=. $(RUN_IN_TEMPDIR) $(CURDIR)/$(BUILD_BASH_COMPLETION) > $@
620
621 doc/%.png: doc/%.dot
622         @test -n "$(DOT)" || { echo 'dot' not found during configure; exit 1; }
623         $(DOT) -Tpng -o $@ $<
624
625 man/footer.man: man/footer.rst
626         @test -n "$(PANDOC)" || \
627           { echo 'pandoc' not found during configure; exit 1; }
628         $(PANDOC) -f rst -t man -o $@ $<
629
630 man/footer.html: man/footer.rst
631         @test -n "$(PANDOC)" || \
632           { echo 'pandoc' not found during configure; exit 1; }
633         $(PANDOC) -f rst -t html -o $@ $<
634
635 man/%.gen: man/%.rst lib/query.py lib/build/sphinx_ext.py
636         PYTHONPATH=. $(RUN_IN_TEMPDIR) $(CURDIR)/$(DOCPP) < $< > $@
637
638 man/%.7.in man/%.8.in: man/%.gen man/footer.man
639         @test -n "$(PANDOC)" || \
640           { echo 'pandoc' not found during configure; exit 1; }
641         set -o pipefail ; \
642         $(PANDOC) -s -f rst -t man -A man/footer.man $< | \
643           sed -e 's/\\@/@/g' > $@
644         if test -n "$(MAN_HAS_WARNINGS)"; then $(CHECK_MAN) $@; fi
645
646 man/%.html.in: man/%.gen man/footer.html
647         @test -n "$(PANDOC)" || \
648           { echo 'pandoc' not found during configure; exit 1; }
649         set -o pipefail ; \
650         $(PANDOC) -s -f rst -t html -A man/footer.html $< | \
651           sed -e 's/\\@/@/g' > $@
652
653 man/%.7: man/%.7.in $(REPLACE_VARS_SED)
654         sed -f $(REPLACE_VARS_SED) < $< > $@
655
656 man/%.8: man/%.8.in $(REPLACE_VARS_SED)
657         sed -f $(REPLACE_VARS_SED) < $< > $@
658
659 man/%.html: man/%.html.in $(REPLACE_VARS_SED)
660         sed -f $(REPLACE_VARS_SED) < $< > $@
661
662 epydoc.conf: epydoc.conf.in Makefile
663         sed -e 's#@MODULES@#$(strip $(lint_python_code))#g' < $< > $@
664
665 vcs-version:
666         if test -d .git; then \
667           git describe > $@; \
668         elif test ! -f $@ ; then \
669           echo "Cannot auto-generate $@ file"; exit 1; \
670         fi
671
672 .PHONY: regen-vcs-version
673 regen-vcs-version:
674         set -e; \
675         cd $(srcdir); \
676         if test -d .git; then \
677           rm -f vcs-version; \
678           $(MAKE) vcs-version; \
679         fi
680
681 lib/_autoconf.py: Makefile vcs-version | lib/.dir
682         set -e; \
683         VCSVER=`cat $(abs_top_srcdir)/vcs-version`; \
684         { echo '# This file is automatically generated, do not edit!'; \
685           echo '#'; \
686           echo ''; \
687           echo '"""Build-time configuration for Ganeti.'; \
688           echo '';\
689           echo 'This file is autogenerated by the build process.'; \
690           echo 'For any changes you need to re-run ./configure (and'; \
691           echo 'not edit by hand).'; \
692           echo ''; \
693           echo '"""'; \
694           echo ''; \
695           echo '# pylint: disable-msg=C0301,C0324'; \
696           echo '# because this is autogenerated, we do not want'; \
697           echo '# style warnings' ; \
698           echo ''; \
699           echo "PACKAGE_VERSION = '$(PACKAGE_VERSION)'"; \
700           echo "VERSION_MAJOR = '$(VERSION_MAJOR)'"; \
701           echo "VERSION_MINOR = '$(VERSION_MINOR)'"; \
702           echo "VERSION_REVISION = '$(VERSION_REVISION)'"; \
703           echo "VERSION_SUFFIX = '$(VERSION_SUFFIX)'"; \
704           echo "VERSION_FULL = '$(VERSION_FULL)'"; \
705           echo "LOCALSTATEDIR = '$(localstatedir)'"; \
706           echo "SYSCONFDIR = '$(sysconfdir)'"; \
707           echo "SSH_CONFIG_DIR = '$(SSH_CONFIG_DIR)'"; \
708           echo "EXPORT_DIR = '$(EXPORT_DIR)'"; \
709           echo "OS_SEARCH_PATH = [$(OS_SEARCH_PATH)]"; \
710           echo "XEN_BOOTLOADER = '$(XEN_BOOTLOADER)'"; \
711           echo "XEN_KERNEL = '$(XEN_KERNEL)'"; \
712           echo "XEN_INITRD = '$(XEN_INITRD)'"; \
713           echo "FILE_STORAGE_DIR = '$(FILE_STORAGE_DIR)'"; \
714           echo "ENABLE_FILE_STORAGE = $(ENABLE_FILE_STORAGE)"; \
715           echo "SHARED_FILE_STORAGE_DIR = '$(SHARED_FILE_STORAGE_DIR)'"; \
716           echo "ENABLE_SHARED_FILE_STORAGE = $(ENABLE_SHARED_FILE_STORAGE)"; \
717           echo "IALLOCATOR_SEARCH_PATH = [$(IALLOCATOR_SEARCH_PATH)]"; \
718           echo "KVM_PATH = '$(KVM_PATH)'"; \
719           echo "SOCAT_PATH = '$(SOCAT)'"; \
720           echo "SOCAT_USE_ESCAPE = $(SOCAT_USE_ESCAPE)"; \
721           echo "SOCAT_USE_COMPRESS = $(SOCAT_USE_COMPRESS)"; \
722           echo "LVM_STRIPECOUNT = $(LVM_STRIPECOUNT)"; \
723           echo "TOOLSDIR = '$(toolsdir)'"; \
724           echo "GNT_SCRIPTS = [$(foreach i,$(notdir $(gnt_scripts)),'$(i)',)]"; \
725           echo "PKGLIBDIR = '$(pkglibdir)'"; \
726           echo "DRBD_BARRIERS = $(DRBD_BARRIERS)"; \
727           echo "SYSLOG_USAGE = '$(SYSLOG_USAGE)'"; \
728           echo "DAEMONS_GROUP = '$(DAEMONS_GROUP)'"; \
729           echo "ADMIN_GROUP = '$(ADMIN_GROUP)'"; \
730           echo "MASTERD_USER = '$(MASTERD_USER)'"; \
731           echo "MASTERD_GROUP = '$(MASTERD_GROUP)'"; \
732           echo "RAPI_USER = '$(RAPI_USER)'"; \
733           echo "RAPI_GROUP = '$(RAPI_GROUP)'"; \
734           echo "CONFD_USER = '$(CONFD_USER)'"; \
735           echo "CONFD_GROUP = '$(CONFD_GROUP)'"; \
736           echo "NODED_USER = '$(NODED_USER)'"; \
737           echo "VCS_VERSION = '$$VCSVER'"; \
738           echo "DISK_SEPARATOR = '$(DISK_SEPARATOR)'"; \
739         } > $@
740
741 $(REPLACE_VARS_SED): Makefile
742         set -e; \
743         { echo 's#@PREFIX@#$(prefix)#g'; \
744           echo 's#@SYSCONFDIR@#$(sysconfdir)#g'; \
745           echo 's#@LOCALSTATEDIR@#$(localstatedir)#g'; \
746           echo 's#@BINDIR@#$(bindir)#g'; \
747           echo 's#@SBINDIR@#$(sbindir)#g'; \
748           echo 's#@GANETI_VERSION@#$(PACKAGE_VERSION)#g'; \
749           echo 's#@CUSTOM_XEN_BOOTLOADER@#$(XEN_BOOTLOADER)#g'; \
750           echo 's#@CUSTOM_XEN_KERNEL@#$(XEN_KERNEL)#g'; \
751           echo 's#@CUSTOM_XEN_INITRD@#$(XEN_INITRD)#g'; \
752           echo 's#@CUSTOM_IALLOCATOR_SEARCH_PATH@#$(IALLOCATOR_SEARCH_PATH)#g'; \
753           echo 's#@CUSTOM_EXPORT_DIR@#$(EXPORT_DIR)#g'; \
754           echo 's#@RPL_FILE_STORAGE_DIR@#$(FILE_STORAGE_DIR)#g'; \
755           echo 's#@RPL_SSH_INITD_SCRIPT@#$(SSH_INITD_SCRIPT)#g'; \
756           echo 's#@PKGLIBDIR@#$(pkglibdir)#g'; \
757           echo 's#@GNTMASTERUSER@#$(MASTERD_USER)#g'; \
758           echo 's#@GNTRAPIUSER@#$(RAPI_USER)#g'; \
759           echo 's#@GNTCONFDUSER@#$(CONFD_USER)#g'; \
760           echo 's#@GNTNODEDUSER@#$(NODED_USER)#g'; \
761           echo 's#@GNTRAPIGROUP@#$(RAPI_GROUP)#g'; \
762           echo 's#@GNTADMINGROUP@#$(ADMIN_GROUP)#g'; \
763           echo 's#@GNTCONFDGROUP@#$(CONFD_GROUP)#g'; \
764           echo 's#@GNTMASTERDGROUP@#$(MASTERD_GROUP)#g'; \
765           echo 's#@GNTDAEMONSGROUP@#$(DAEMONS_GROUP)#g'; \
766         } > $@
767
768 # Using deferred evaluation
769 daemons/ganeti-%: MODULE = ganeti.server.$(patsubst ganeti-%,%,$(notdir $@))
770 daemons/ganeti-watcher: MODULE = ganeti.watcher
771 scripts/%: MODULE = ganeti.client.$(subst -,_,$(notdir $@))
772
773 $(PYTHON_BOOTSTRAP): Makefile | $(all_dirfiles)
774         test -n "$(MODULE)" || { echo Missing module; exit 1; }
775         set -e; \
776         { echo '#!/usr/bin/python'; \
777           echo '# This file is automatically generated, do not edit!'; \
778           echo "# Edit $(MODULE) instead."; \
779           echo; \
780           echo '"""Bootstrap script for L{$(MODULE)}"""'; \
781           echo; \
782           echo '# pylint: disable-msg=C0103'; \
783           echo '# C0103: Invalid name'; \
784           echo; \
785           echo 'import sys'; \
786           echo 'import $(MODULE) as main'; \
787           echo; \
788           echo '# Temporarily alias commands until bash completion'; \
789           echo '# generator is changed'; \
790           echo 'if hasattr(main, "commands"):'; \
791                 echo '  commands = main.commands # pylint: disable-msg=E1101'; \
792           echo; \
793           echo 'if __name__ == "__main__":'; \
794           echo '  sys.exit(main.Main())'; \
795         } > $@
796         chmod u+x $@
797
798 # We need to create symlinks because "make distcheck" will not install Python
799 # files when building.
800 stamp-srclinks: Makefile | $(all_dirfiles)
801         set -e; \
802         for i in $(srclink_files); do \
803                 if test ! -f $$i -a -f $(abs_top_srcdir)/$$i; then \
804                         $(LN_S) $(abs_top_srcdir)/$$i $$i; \
805                 fi; \
806         done
807         touch $@
808
809 .PHONY: ganeti
810 ganeti:
811         cd $(top_builddir) && test -h "$@" || { rm -f $@ && $(LN_S) lib $@; }
812
813 .PHONY: check-dirs
814 check-dirs: $(BUILT_SOURCES)
815         @set -e; \
816         find . -type d \( \( -name . \) -o \( \
817                 -name .git -o \
818                 -name autom4te.cache \
819                 \) -prune -o -print \) | { \
820                 error=; \
821                 while read dir; do \
822                         case "$$dir" in \
823                                 $(strip $(patsubst %,(./%) ;;,$(DIRCHECK_EXCLUDE) $(DIRS))) \
824                                 *) error=1; echo "Directory $$dir not listed in Makefile" >&2 ;; \
825                         esac; \
826                 done; \
827                 for dir in $(DIRS); do \
828                         if ! test -d "$$dir"; then \
829                                 echo "Directory $$dir listed in DIRS does not exist" >&2; \
830                                 error=1; \
831                         fi \
832                 done; \
833                 if test -n "$$error"; then exit 1; else exit 0; fi; \
834         }
835
836 check-local: check-dirs
837         $(CHECK_PYTHON_CODE) $(check_python_code)
838         $(CHECK_VERSION) $(VERSION) $(top_srcdir)/NEWS
839         $(CHECK_NEWS) < $(top_srcdir)/NEWS
840
841 .PHONY: lint
842 lint: $(BUILT_SOURCES)
843         @test -n "$(PYLINT)" || { echo 'pylint' not found during configure; exit 1; }
844         $(PYLINT) $(LINT_OPTS) $(lint_python_code)
845         cd $(top_srcdir)/qa && \
846           PYTHONPATH=$(abs_top_srcdir) $(PYLINT) $(LINT_OPTS) \
847           --rcfile  ../pylintrc $(patsubst qa/%.py,%,$(qa_scripts))
848
849 # a dist hook rule for updating the vcs-version file; this is
850 # hardcoded due to where it needs to build the file...
851 dist-hook:
852         $(MAKE) regen-vcs-version && \
853         rm -f $(top_distdir)/vcs-version && \
854         cp -p $(srcdir)/vcs-version $(top_distdir)
855
856 # a distcheck hook rule for catching revision control directories
857 distcheck-hook:
858         if find $(top_distdir) -name .svn -or -name .git | grep .; then \
859                 echo "Found revision control files in final archive." 1>&2; \
860                 exit 1; \
861         fi
862         if find $(top_distdir) -name '*.py[co]' | grep .; then \
863                 echo "Found Python byte code in final archive." 1>&2; \
864                 exit 1; \
865         fi
866         if find $(top_distdir) -name '*~' | grep .; then \
867                 echo "Found backup files in final archive." 1>&2; \
868                 exit 1; \
869         fi
870 # Empty files or directories should not be distributed. They can cause
871 # unnecessary warnings for packagers. Directories used by automake during
872 # distcheck must be excluded.
873         if find $(top_distdir) -empty -and -not \( \
874                         -path $(top_distdir)/_build -or \
875                         -path $(top_distdir)/_inst \) | grep .; then \
876                 echo "Found empty files or directories in final archive." 1>&2; \
877                 exit 1; \
878         fi
879         if test -n "$(BUILD_RELEASE)" && \
880            grep -n -H -E '^\*.*unreleased' $(top_distdir)/NEWS; then \
881                 echo "Found unreleased version in NEWS." >&2; \
882                 exit 1; \
883         fi
884
885 # When building a release, stricter checks should be used
886 distcheck-release dist-release: export BUILD_RELEASE = 1
887 distcheck-release: distcheck
888
889 dist-release: dist
890         set -e; \
891         for i in $(DIST_ARCHIVES); do \
892                 echo -n "Checking $$i ... "; \
893                 autotools/check-tar < $$i; \
894                 echo OK; \
895         done
896
897 install-exec-local:
898         @mkdir_p@ "$(DESTDIR)${localstatedir}/lib/ganeti" \
899           "$(DESTDIR)${localstatedir}/log/ganeti" \
900           "$(DESTDIR)${localstatedir}/run/ganeti"
901
902 # To avoid conflicts between directory names and other targets, a file inside
903 # the directory is used to ensure its existence.
904 %.dir:
905         @mkdir_p@ $* && touch $@
906
907 .PHONY: apidoc
908 apidoc: epydoc.conf $(RUN_IN_TEMPDIR) $(BUILT_SOURCES)
909         $(RUN_IN_TEMPDIR) epydoc -v \
910                 --conf $(CURDIR)/epydoc.conf \
911                 --output $(CURDIR)/doc/api
912
913 .PHONY: TAGS
914 TAGS: $(BUILT_SOURCES)
915         rm -f TAGS
916         find . -path './lib/*.py' -o -path './scripts/gnt-*' -o \
917           -path './daemons/ganeti-*' -o -path './tools/*' -o \
918           -path './qa/*.py' | \
919           etags -l python -
920
921 .PHONY: coverage
922 coverage: $(BUILT_SOURCES) $(python_tests)
923         set -e; \
924         COVERAGE_FILE=$(CURDIR)/doc/coverage/data \
925         TEXT_COVERAGE=$(CURDIR)/doc/coverage/report.txt \
926         HTML_COVERAGE=$(CURDIR)/doc/coverage \
927         $(PLAIN_TESTS_ENVIRONMENT) $(abs_top_srcdir)/autotools/gen-coverage \
928         $(python_tests)
929
930 commit-check: distcheck lint apidoc
931
932 -include ./Makefile.local
933
934 # vim: set noet :