ConfigWriter: add some helper functions
[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 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 REPLACE_VARS_SED = autotools/replace_vars.sed
19
20 clientdir = $(pkgpythondir)/client
21 hypervisordir = $(pkgpythondir)/hypervisor
22 httpdir = $(pkgpythondir)/http
23 masterddir = $(pkgpythondir)/masterd
24 confddir = $(pkgpythondir)/confd
25 rapidir = $(pkgpythondir)/rapi
26 impexpddir = $(pkgpythondir)/impexpd
27 toolsdir = $(pkglibdir)/tools
28 docdir = $(datadir)/doc/$(PACKAGE)
29
30 # Delete output file if an error occurred while building it
31 .DELETE_ON_ERROR:
32
33 DIRS = \
34         autotools \
35         daemons \
36         devel \
37         doc \
38         doc/examples \
39         doc/examples/hooks \
40         doc/examples/gnt-debug \
41         lib \
42         lib/client \
43         lib/build \
44         lib/confd \
45         lib/http \
46         lib/hypervisor \
47         lib/impexpd \
48         lib/masterd \
49         lib/rapi \
50         man \
51         qa \
52         scripts \
53         test \
54         test/data \
55         tools
56
57 BUILDTIME_DIRS = \
58         doc/api \
59         doc/coverage \
60         doc/html
61
62 DIRCHECK_EXCLUDE = \
63         $(BUILDTIME_DIRS) \
64         ganeti-[0-9]*.[0-9]*.[0-9]* \
65         doc/html/_*
66
67 MAINTAINERCLEANFILES = \
68         $(docpng) \
69         $(maninput) \
70         doc/install-quick.rst \
71         doc/news.rst \
72         vcs-version
73
74 maintainer-clean-local:
75         rm -rf $(BUILDTIME_DIRS)
76
77 CLEANFILES = \
78         $(addsuffix /*.py[co],$(DIRS)) \
79         $(PYTHON_BOOTSTRAP) \
80         autotools/replace_vars.sed \
81         daemons/daemon-util \
82         daemons/ensure-dirs \
83         daemons/ganeti-cleaner \
84         devel/upload \
85         doc/examples/bash_completion \
86         doc/examples/ganeti.initd \
87         doc/examples/ganeti.cron \
88         doc/examples/gnt-config-backup \
89         doc/examples/hooks/ipsec \
90         $(man_MANS) \
91         $(manhtml) \
92         stamp-directories \
93         stamp-srclinks \
94         $(nodist_pkgpython_PYTHON)
95
96 BUILT_SOURCES = \
97         ganeti \
98         stamp-srclinks \
99         stamp-directories \
100         lib/_autoconf.py \
101         $(PYTHON_BOOTSTRAP)
102
103 $(RUN_IN_TEMPDIR): $(BUILT_SOURCES)
104
105 nodist_pkgpython_PYTHON = \
106         lib/_autoconf.py
107
108 noinst_PYTHON = \
109         lib/build/__init__.py
110
111 pkgpython_PYTHON = \
112         lib/__init__.py \
113         lib/asyncnotifier.py \
114         lib/backend.py \
115         lib/bdev.py \
116         lib/bootstrap.py \
117         lib/cli.py \
118         lib/cmdlib.py \
119         lib/compat.py \
120         lib/config.py \
121         lib/constants.py \
122         lib/daemon.py \
123         lib/errors.py \
124         lib/ht.py \
125         lib/jqueue.py \
126         lib/jstore.py \
127         lib/locking.py \
128         lib/luxi.py \
129         lib/mcpu.py \
130         lib/netutils.py \
131         lib/objects.py \
132         lib/opcodes.py \
133         lib/rpc.py \
134         lib/runtime.py \
135         lib/serializer.py \
136         lib/ssconf.py \
137         lib/ssh.py \
138         lib/storage.py \
139         lib/utils.py \
140         lib/uidpool.py \
141         lib/workerpool.py
142
143 client_PYTHON = \
144         lib/client/__init__.py \
145         lib/client/gnt_backup.py \
146         lib/client/gnt_cluster.py \
147         lib/client/gnt_debug.py \
148         lib/client/gnt_instance.py \
149         lib/client/gnt_job.py \
150         lib/client/gnt_node.py \
151         lib/client/gnt_os.py
152
153 hypervisor_PYTHON = \
154         lib/hypervisor/__init__.py \
155         lib/hypervisor/hv_base.py \
156         lib/hypervisor/hv_chroot.py \
157         lib/hypervisor/hv_fake.py \
158         lib/hypervisor/hv_kvm.py \
159         lib/hypervisor/hv_lxc.py \
160         lib/hypervisor/hv_xen.py
161
162 rapi_PYTHON = \
163         lib/rapi/__init__.py \
164         lib/rapi/baserlib.py \
165         lib/rapi/client.py \
166         lib/rapi/client_utils.py \
167         lib/rapi/connector.py \
168         lib/rapi/rlib2.py
169
170 http_PYTHON = \
171         lib/http/__init__.py \
172         lib/http/auth.py \
173         lib/http/client.py \
174         lib/http/server.py
175
176 confd_PYTHON = \
177         lib/confd/__init__.py \
178         lib/confd/client.py \
179         lib/confd/querylib.py \
180         lib/confd/server.py
181
182 masterd_PYTHON = \
183         lib/masterd/__init__.py \
184         lib/masterd/instance.py
185
186 impexpd_PYTHON = \
187         lib/impexpd/__init__.py
188
189 docrst = \
190         doc/admin.rst \
191         doc/design-2.0.rst \
192         doc/design-2.1.rst \
193         doc/design-2.2.rst \
194         doc/design-2.3.rst \
195         doc/cluster-merge.rst \
196         doc/devnotes.rst \
197         doc/glossary.rst \
198         doc/hooks.rst \
199         doc/iallocator.rst \
200         doc/index.rst \
201         doc/install-quick.rst \
202         doc/install.rst \
203         doc/locking.rst \
204         doc/move-instance.rst \
205         doc/news.rst \
206         doc/rapi.rst \
207         doc/security.rst \
208         doc/walkthrough.rst
209
210 doc/html/.stamp: $(docrst) $(docpng) doc/conf.py configure.ac $(RUN_IN_TEMPDIR)
211         @test -n "$(SPHINX)" || \
212             { echo 'sphinx-build' not found during configure; exit 1; }
213         PYTHONPATH=. $(RUN_IN_TEMPDIR) $(SPHINX) -q -W -b html \
214             -d . \
215             -D version="$(VERSION_MAJOR).$(VERSION_MINOR)" \
216             -D release="$(PACKAGE_VERSION)" \
217             $(abs_top_srcdir)/doc $(CURDIR)/doc/html
218         rm -f doc/html/.buildinfo doc/html/objects.inv
219         touch $@
220
221 doc/html: doc/html/.stamp
222
223 doc/news.rst: NEWS
224         set -e; \
225         { echo '.. This file is automatically updated at build time from $<.'; \
226           echo '.. Do not edit.'; \
227           echo; \
228           cat $<; \
229         } > $@
230
231 doc/install-quick.rst: INSTALL
232         set -e; \
233         { echo '.. This file is automatically updated at build time from $<.'; \
234           echo '.. Do not edit.'; \
235           echo; \
236           cat $<; \
237         } > $@
238
239 docdot = \
240         doc/arch-2.0.dot \
241         doc/design-2.1-lock-acquire.dot \
242         doc/design-2.1-lock-release.dot
243
244 docpng = $(patsubst %.dot,%.png,$(docdot))
245
246 # Things to build but not to install (add it to EXTRA_DIST if it should be
247 # distributed)
248 noinst_DATA = \
249         devel/upload \
250         doc/html \
251         doc/examples/bash_completion \
252         doc/examples/ganeti.cron \
253         doc/examples/ganeti.initd \
254         doc/examples/gnt-config-backup \
255         doc/examples/hooks/ipsec \
256         $(manhtml)
257
258 gnt_scripts = \
259         scripts/gnt-backup \
260         scripts/gnt-cluster \
261         scripts/gnt-debug \
262         scripts/gnt-instance \
263         scripts/gnt-job \
264         scripts/gnt-node \
265         scripts/gnt-os
266
267 PYTHON_BOOTSTRAP = \
268         scripts/gnt-backup \
269         scripts/gnt-cluster \
270         scripts/gnt-debug \
271         scripts/gnt-instance \
272         scripts/gnt-job \
273         scripts/gnt-node \
274         scripts/gnt-os
275
276 dist_sbin_SCRIPTS = \
277         daemons/ganeti-noded \
278         daemons/ganeti-watcher \
279         daemons/ganeti-masterd \
280         daemons/ganeti-confd \
281         daemons/ganeti-rapi
282
283 nodist_sbin_SCRIPTS = \
284         $(PYTHON_BOOTSTRAP) \
285         daemons/ganeti-cleaner
286
287 dist_tools_SCRIPTS = \
288         tools/burnin \
289         tools/cfgshell \
290         tools/cfgupgrade \
291         tools/cfgupgrade12 \
292         tools/cluster-merge \
293         tools/lvmstrap \
294         tools/move-instance \
295         tools/setup-ssh \
296         tools/sanitize-config
297
298 pkglib_python_scripts = \
299         daemons/import-export \
300         tools/check-cert-expired
301
302 pkglib_SCRIPTS = \
303         daemons/daemon-util \
304         daemons/ensure-dirs \
305         $(pkglib_python_scripts)
306
307 EXTRA_DIST = \
308         NEWS \
309         pylintrc \
310         autotools/build-bash-completion \
311         autotools/check-python-code \
312         autotools/check-man \
313         autotools/docbook-wrapper \
314         autotools/gen-coverage \
315         autotools/testrunner \
316         $(RUN_IN_TEMPDIR) \
317         daemons/daemon-util.in \
318         daemons/ensure-dirs.in \
319         daemons/ganeti-cleaner.in \
320         $(pkglib_python_scripts) \
321         devel/upload.in \
322         $(docdot) \
323         $(docpng) \
324         $(docrst) \
325         doc/conf.py \
326         doc/html \
327         doc/examples/ganeti.initd.in \
328         doc/examples/ganeti.cron.in \
329         doc/examples/gnt-config-backup.in \
330         doc/examples/dumb-allocator \
331         doc/examples/ganeti.default \
332         doc/examples/ganeti.default-debug \
333         doc/examples/hooks/ethers \
334         doc/examples/hooks/ipsec.in \
335         doc/examples/gnt-debug/README \
336         doc/examples/gnt-debug/delay0.json \
337         doc/examples/gnt-debug/delay50.json \
338         test/testutils.py \
339         test/mocks.py \
340         $(dist_TESTS) \
341         $(TEST_FILES) \
342         man/footer.sgml \
343         $(mansgml) \
344         $(maninput) \
345         qa/ganeti-qa.py \
346         qa/qa-sample.json \
347         qa/qa_cluster.py \
348         qa/qa_config.py \
349         qa/qa_daemon.py \
350         qa/qa_env.py \
351         qa/qa_error.py \
352         qa/qa_instance.py \
353         qa/qa_node.py \
354         qa/qa_os.py \
355         qa/qa_rapi.py \
356         qa/qa_tags.py \
357         qa/qa_utils.py
358
359 man_MANS = \
360         man/ganeti.7 \
361         man/ganeti-cleaner.8 \
362         man/ganeti-confd.8 \
363         man/ganeti-masterd.8 \
364         man/ganeti-noded.8 \
365         man/ganeti-os-interface.7 \
366         man/ganeti-rapi.8 \
367         man/ganeti-watcher.8 \
368         man/gnt-backup.8 \
369         man/gnt-cluster.8 \
370         man/gnt-debug.8 \
371         man/gnt-instance.8 \
372         man/gnt-job.8 \
373         man/gnt-node.8 \
374         man/gnt-os.8
375
376 mansgml = $(patsubst %.7,%.sgml,$(patsubst %.8,%.sgml,$(man_MANS)))
377 manhtml = $(patsubst %.sgml,%.html,$(mansgml))
378 maninput = \
379         $(patsubst %.7,%.7.in,$(patsubst %.8,%.8.in,$(man_MANS))) \
380         $(patsubst %.html,%.html.in,$(manhtml))
381
382 TEST_FILES = \
383         test/data/bdev-drbd-8.0.txt \
384         test/data/bdev-drbd-8.3.txt \
385         test/data/bdev-drbd-disk.txt \
386         test/data/bdev-drbd-net-ip4.txt \
387         test/data/bdev-drbd-net-ip6.txt \
388         test/data/cert1.pem \
389         test/data/proc_drbd8.txt \
390         test/data/proc_drbd80-emptyline.txt \
391         test/data/proc_drbd83.txt \
392         test/data/sys_drbd_usermode_helper.txt \
393         test/import-export_unittest-helper
394
395 python_tests = \
396         test/ganeti.asyncnotifier_unittest.py \
397         test/ganeti.backend_unittest.py \
398         test/ganeti.bdev_unittest.py \
399         test/ganeti.cli_unittest.py \
400         test/ganeti.daemon_unittest.py \
401         test/ganeti.cmdlib_unittest.py \
402         test/ganeti.compat_unittest.py \
403         test/ganeti.confd.client_unittest.py \
404         test/ganeti.config_unittest.py \
405         test/ganeti.constants_unittest.py \
406         test/ganeti.errors_unittest.py \
407         test/ganeti.hooks_unittest.py \
408         test/ganeti.http_unittest.py \
409         test/ganeti.hypervisor.hv_kvm_unittest.py \
410         test/ganeti.impexpd_unittest.py \
411         test/ganeti.jqueue_unittest.py \
412         test/ganeti.locking_unittest.py \
413         test/ganeti.luxi_unittest.py \
414         test/ganeti.masterd.instance_unittest.py \
415         test/ganeti.mcpu_unittest.py \
416         test/ganeti.netutils_unittest.py \
417         test/ganeti.objects_unittest.py \
418         test/ganeti.opcodes_unittest.py \
419         test/ganeti.rapi.client_unittest.py \
420         test/ganeti.rapi.resources_unittest.py \
421         test/ganeti.rapi.rlib2_unittest.py \
422         test/ganeti.rpc_unittest.py \
423         test/ganeti.runtime_unittest.py \
424         test/ganeti.serializer_unittest.py \
425         test/ganeti.ssh_unittest.py \
426         test/ganeti.uidpool_unittest.py \
427         test/ganeti.utils_unittest.py \
428         test/ganeti.utils_mlockall_unittest.py \
429         test/ganeti.workerpool_unittest.py \
430         test/cfgupgrade_unittest.py \
431         test/docs_unittest.py \
432         test/tempfile_fork_unittest.py
433
434 dist_TESTS = \
435         test/check-cert-expired_unittest.bash \
436         test/daemon-util_unittest.bash \
437         test/ganeti-cleaner_unittest.bash \
438         test/import-export_unittest.bash \
439         $(python_tests)
440
441 nodist_TESTS =
442
443 TESTS = $(dist_TESTS) $(nodist_TESTS)
444
445 # Environment for all tests
446 PLAIN_TESTS_ENVIRONMENT = \
447         PYTHONPATH=. TOP_SRCDIR=$(abs_top_srcdir) PYTHON=$(PYTHON) $(RUN_IN_TEMPDIR)
448
449 # Environment for tests run by automake
450 TESTS_ENVIRONMENT = \
451         $(PLAIN_TESTS_ENVIRONMENT) $(abs_top_srcdir)/autotools/testrunner
452
453 all_python_code = \
454         $(dist_sbin_SCRIPTS) \
455         $(dist_tools_SCRIPTS) \
456         $(pkglib_python_scripts) \
457         $(python_tests) \
458         $(pkgpython_PYTHON) \
459         $(client_PYTHON) \
460         $(hypervisor_PYTHON) \
461         $(rapi_PYTHON) \
462         $(http_PYTHON) \
463         $(confd_PYTHON) \
464         $(masterd_PYTHON) \
465         $(impexpd_PYTHON) \
466         $(noinst_PYTHON)
467
468 srclink_files = \
469         man/footer.sgml \
470         test/check-cert-expired_unittest.bash \
471         test/daemon-util_unittest.bash \
472         test/ganeti-cleaner_unittest.bash \
473         test/import-export_unittest.bash \
474         $(all_python_code)
475
476 check_python_code = \
477         $(BUILD_BASH_COMPLETION) \
478         $(all_python_code)
479
480 lint_python_code = \
481         ganeti \
482         ganeti/http/server.py \
483         $(dist_sbin_SCRIPTS) \
484         $(dist_tools_SCRIPTS) \
485         $(pkglib_python_scripts) \
486         $(BUILD_BASH_COMPLETION)
487
488 test/daemon-util_unittest.bash: daemons/daemon-util
489
490 test/ganeti-cleaner_unittest.bash: daemons/ganeti-cleaner
491
492 devel/upload: devel/upload.in $(REPLACE_VARS_SED)
493         sed -f $(REPLACE_VARS_SED) < $< > $@
494         chmod u+x $@
495
496 daemons/%: daemons/%.in \
497                 $(REPLACE_VARS_SED)
498         sed -f $(REPLACE_VARS_SED) < $< > $@
499         chmod +x $@
500
501 doc/examples/%: doc/examples/%.in \
502                 $(REPLACE_VARS_SED)
503         sed -f $(REPLACE_VARS_SED) < $< > $@
504
505 doc/examples/hooks/%: doc/examples/hooks/%.in \
506                 $(REPLACE_VARS_SED)
507         sed -f $(REPLACE_VARS_SED) < $< > $@
508
509 doc/examples/bash_completion: $(BUILD_BASH_COMPLETION) $(RUN_IN_TEMPDIR) \
510         lib/cli.py $(gnt_scripts) $(client_PYTHON) tools/burnin
511         PYTHONPATH=. $(RUN_IN_TEMPDIR) $(CURDIR)/$(BUILD_BASH_COMPLETION) > $@
512
513 doc/%.png: doc/%.dot
514         @test -n "$(DOT)" || { echo 'dot' not found during configure; exit 1; }
515         $(DOT) -Tpng -o $@ $<
516
517 man/%.7.in man/%.8.in: man/%.sgml man/footer.sgml $(DOCBOOK_WRAPPER)
518         @test -n "$(DOCBOOK2MAN)" || \
519           { echo 'docbook2man' not found during configure; exit 1; }
520         $(DOCBOOK_WRAPPER) "$(DOCBOOK2MAN)" $< $(notdir $(@:.in=)) $@
521         if test -n "$(MAN_HAS_WARNINGS)"; then $(CHECK_MAN) $@; fi
522
523 man/%.html.in: man/%.sgml man/footer.sgml $(DOCBOOK_WRAPPER)
524         @test -n "$(DOCBOOK2HTML)" || \
525           { echo 'docbook2html' not found during configure; exit 1; }
526         $(DOCBOOK_WRAPPER) "$(DOCBOOK2HTML) --nochunks" $< $(notdir $(@:.in=)) $@
527
528 man/%.7: man/%.7.in $(REPLACE_VARS_SED)
529         sed -f $(REPLACE_VARS_SED) < $< > $@
530
531 man/%.8: man/%.8.in $(REPLACE_VARS_SED)
532         sed -f $(REPLACE_VARS_SED) < $< > $@
533
534 man/%.html: man/%.html.in $(REPLACE_VARS_SED)
535         sed -f $(REPLACE_VARS_SED) < $< > $@
536
537 vcs-version:
538         if test -d .git; then \
539           git describe > $@; \
540         elif test ! -f $@ ; then \
541           echo "Cannot auto-generate $@ file"; exit 1; \
542         fi
543
544 .PHONY: regen-vcs-version
545 regen-vcs-version:
546         set -e; \
547         cd $(srcdir); \
548         if test -d .git; then \
549           rm -f vcs-version; \
550           $(MAKE) vcs-version; \
551         fi
552
553 lib/_autoconf.py: Makefile stamp-directories vcs-version
554         set -e; \
555         VCSVER=`cat $(abs_top_srcdir)/vcs-version`; \
556         { echo '# This file is automatically generated, do not edit!'; \
557           echo '#'; \
558           echo ''; \
559           echo '"""Build-time configuration for Ganeti.'; \
560           echo '';\
561           echo 'This file is autogenerated by the build process.'; \
562           echo 'For any changes you need to re-run ./configure (and'; \
563           echo 'not edit by hand).'; \
564           echo ''; \
565           echo '"""'; \
566           echo ''; \
567           echo '# pylint: disable-msg=C0301,C0324'; \
568           echo '# because this is autogenerated, we do not want'; \
569           echo '# style warnings' ; \
570           echo ''; \
571           echo "PACKAGE_VERSION = '$(PACKAGE_VERSION)'"; \
572           echo "VERSION_MAJOR = '$(VERSION_MAJOR)'"; \
573           echo "VERSION_MINOR = '$(VERSION_MINOR)'"; \
574           echo "VERSION_REVISION = '$(VERSION_REVISION)'"; \
575           echo "VERSION_SUFFIX = '$(VERSION_SUFFIX)'"; \
576           echo "VERSION_FULL = '$(VERSION_FULL)'"; \
577           echo "LOCALSTATEDIR = '$(localstatedir)'"; \
578           echo "SYSCONFDIR = '$(sysconfdir)'"; \
579           echo "SSH_CONFIG_DIR = '$(SSH_CONFIG_DIR)'"; \
580           echo "EXPORT_DIR = '$(EXPORT_DIR)'"; \
581           echo "OS_SEARCH_PATH = [$(OS_SEARCH_PATH)]"; \
582           echo "XEN_BOOTLOADER = '$(XEN_BOOTLOADER)'"; \
583           echo "XEN_KERNEL = '$(XEN_KERNEL)'"; \
584           echo "XEN_INITRD = '$(XEN_INITRD)'"; \
585           echo "FILE_STORAGE_DIR = '$(FILE_STORAGE_DIR)'"; \
586           echo "ENABLE_FILE_STORAGE = $(ENABLE_FILE_STORAGE)"; \
587           echo "IALLOCATOR_SEARCH_PATH = [$(IALLOCATOR_SEARCH_PATH)]"; \
588           echo "KVM_PATH = '$(KVM_PATH)'"; \
589           echo "SOCAT_PATH = '$(SOCAT)'"; \
590           echo "SOCAT_USE_ESCAPE = $(SOCAT_USE_ESCAPE)"; \
591           echo "LVM_STRIPECOUNT = $(LVM_STRIPECOUNT)"; \
592           echo "TOOLSDIR = '$(toolsdir)'"; \
593           echo "GNT_SCRIPTS = [$(foreach i,$(notdir $(gnt_scripts)),'$(i)',)]"; \
594           echo "PKGLIBDIR = '$(pkglibdir)'"; \
595           echo "DRBD_BARRIERS = $(DRBD_BARRIERS)"; \
596           echo "SYSLOG_USAGE = '$(SYSLOG_USAGE)'"; \
597           echo "DAEMONS_GROUP = '$(DAEMONS_GROUP)'"; \
598           echo "ADMIN_GROUP = '$(ADMIN_GROUP)'"; \
599           echo "MASTERD_USER = '$(MASTERD_USER)'"; \
600           echo "MASTERD_GROUP = '$(MASTERD_GROUP)'"; \
601           echo "RAPI_USER = '$(RAPI_USER)'"; \
602           echo "RAPI_GROUP = '$(RAPI_GROUP)'"; \
603           echo "CONFD_USER = '$(CONFD_USER)'"; \
604           echo "CONFD_GROUP = '$(CONFD_GROUP)'"; \
605           echo "NODED_USER = '$(NODED_USER)'"; \
606           echo "VCS_VERSION = '$$VCSVER'"; \
607         } > $@
608
609 $(REPLACE_VARS_SED): Makefile
610         set -e; \
611         { echo 's#@PREFIX@#$(prefix)#g'; \
612           echo 's#@SYSCONFDIR@#$(sysconfdir)#g'; \
613           echo 's#@LOCALSTATEDIR@#$(localstatedir)#g'; \
614           echo 's#@BINDIR@#$(bindir)#g'; \
615           echo 's#@SBINDIR@#$(sbindir)#g'; \
616           echo 's#@GANETI_VERSION@#$(PACKAGE_VERSION)#g'; \
617           echo 's#@CUSTOM_XEN_BOOTLOADER@#$(XEN_BOOTLOADER)#g'; \
618           echo 's#@CUSTOM_XEN_KERNEL@#$(XEN_KERNEL)#g'; \
619           echo 's#@CUSTOM_XEN_INITRD@#$(XEN_INITRD)#g'; \
620           echo 's#@RPL_FILE_STORAGE_DIR@#$(FILE_STORAGE_DIR)#g'; \
621           echo 's#@RPL_SSH_INITD_SCRIPT@#$(SSH_INITD_SCRIPT)#g'; \
622           echo 's#@PKGLIBDIR@#$(pkglibdir)#g'; \
623           echo 's#@GNTMASTERUSER@#$(MASTERD_USER)#g'; \
624           echo 's#@GNTRAPIUSER@#$(RAPI_USER)#g'; \
625           echo 's#@GNTCONFDUSER@#$(CONFD_USER)#g'; \
626           echo 's#@GNTNODEDUSER@#$(NODED_USER)#g'; \
627           echo 's#@GNTRAPIGROUP@#$(RAPI_GROUP)#g'; \
628           echo 's#@GNTADMINGROUP@#$(ADMIN_GROUP)#g'; \
629           echo 's#@GNTCONFDGROUP@#$(CONFD_GROUP)#g'; \
630           echo 's#@GNTMASTERDGROUP@#$(MASTERD_GROUP)#g'; \
631           echo 's#@GNTDAEMONSGROUP@#$(DAEMONS_GROUP)#g'; \
632         } > $@
633
634 $(PYTHON_BOOTSTRAP): Makefile
635         set -e; \
636         test -e $(dir $@) || mkdir $(dir $@); \
637         module='$(subst -,_,$(notdir $@))'; \
638         { echo '#!/usr/bin/python'; \
639           echo '# This file is automatically generated, do not edit!'; \
640           echo "# Edit ganeti.client.$$module instead."; \
641           echo; \
642           echo '"""Bootstrap script for L{ganeti.client.'"$$module"'}"""'; \
643           echo; \
644           echo '# pylint: disable-msg=C0103'; \
645           echo '# C0103: Invalid name'; \
646           echo; \
647           echo 'import sys'; \
648           echo "from ganeti.client import $$module"; \
649           echo; \
650           echo '# Temporarily alias commands until bash completion'; \
651           echo '# generator is changed'; \
652           echo "if hasattr($$module, \"commands\"):"; \
653           echo "  commands = $$module.commands"; \
654           echo; \
655           echo 'if __name__ == "__main__":'; \
656           echo "  sys.exit($$module.Main())"; \
657         } > $@
658         chmod u+x $@
659
660 # We need to create symlinks because "make distcheck" will not install Python
661 # files when building.
662 stamp-srclinks: Makefile stamp-directories
663         set -e; \
664         for i in $(srclink_files); do \
665                 if test ! -f $$i -a -f $(abs_top_srcdir)/$$i; then \
666                         $(LN_S) $(abs_top_srcdir)/$$i $$i; \
667                 fi; \
668         done
669         touch $@
670
671 .PHONY: ganeti
672 ganeti:
673         cd $(top_builddir) && test -h "$@" || { rm -f $@ && $(LN_S) lib $@; }
674
675 .PHONY: check-dirs
676 check-dirs: $(BUILT_SOURCES)
677         @set -e; \
678         find . -type d \( \( -name . \) -o \( \
679                 -name .git -o \
680                 -name autom4te.cache \
681                 \) -prune -o -print \) | { \
682                 error=; \
683                 while read dir; do \
684                         case "$$dir" in \
685                                 $(strip $(patsubst %,(./%) ;;,$(DIRCHECK_EXCLUDE) $(DIRS))) \
686                                 *) error=1; echo "Directory $$dir not listed in Makefile" >&2 ;; \
687                         esac; \
688                 done; \
689                 for dir in $(DIRS); do \
690                         if ! test -d "$$dir"; then \
691                                 echo "Directory $$dir listed in DIRS does not exist" >&2; \
692                                 error=1; \
693                         fi \
694                 done; \
695                 if test -n "$$error"; then exit 1; else exit 0; fi; \
696         }
697
698 check-local: check-dirs
699         $(CHECK_PYTHON_CODE) $(check_python_code)
700
701 .PHONY: lint
702 lint: ganeti $(BUILT_SOURCES)
703         @test -n "$(PYLINT)" || { echo 'pylint' not found during configure; exit 1; }
704         $(PYLINT) $(LINT_OPTS) $(lint_python_code)
705
706 # a dist hook rule for updating the vcs-version file; this is
707 # hardcoded due to where it needs to build the file...
708 dist-hook:
709         $(MAKE) regen-vcs-version && \
710         rm -f $(top_distdir)/vcs-version && \
711         cp -p $(srcdir)/vcs-version $(top_distdir)
712
713 # a distcheck hook rule for catching revision control directories
714 distcheck-hook:
715         if find $(top_distdir) -name .svn -or -name .git | grep .; then \
716                 echo "Found revision control files in final archive." 1>&2; \
717                 exit 1; \
718         fi
719         if find $(top_distdir) -name '*.py[co]' | grep .; then \
720                 echo "Found Python byte code in final archive." 1>&2; \
721                 exit 1; \
722         fi
723         if find $(top_distdir) -name '*~' | grep .; then \
724                 echo "Found backup files in final archive." 1>&2; \
725                 exit 1; \
726         fi
727
728 install-exec-local:
729         @mkdir_p@ "$(DESTDIR)${localstatedir}/lib/ganeti" \
730           "$(DESTDIR)${localstatedir}/log/ganeti" \
731           "$(DESTDIR)${localstatedir}/run/ganeti"
732
733 stamp-directories: Makefile
734         @mkdir_p@ $(DIRS)
735         touch $@
736
737 .PHONY: apidoc
738 apidoc: epydoc.conf $(RUN_IN_TEMPDIR) $(BUILT_SOURCES)
739         test -e doc/api || mkdir doc/api
740         $(RUN_IN_TEMPDIR) epydoc -v \
741                 --conf $(CURDIR)/epydoc.conf \
742                 --output $(CURDIR)/doc/api
743
744 .PHONY: TAGS
745 TAGS: $(BUILT_SOURCES)
746         rm -f TAGS
747         find . -path './lib/*.py' -o -path './scripts/gnt-*' -o \
748           -path './daemons/ganeti-*' -o -path './tools/*' -o \
749           -path './qa/*.py' | \
750           etags -l python -
751
752 .PHONY: coverage
753 coverage: $(BUILT_SOURCES) $(python_tests)
754         set -e; \
755         @mkdir_p@ doc/coverage; \
756         COVERAGE_FILE=$(CURDIR)/doc/coverage/data \
757         TEXT_COVERAGE=$(CURDIR)/doc/coverage/report.txt \
758         HTML_COVERAGE=$(CURDIR)/doc/coverage \
759         $(PLAIN_TESTS_ENVIRONMENT) $(abs_top_srcdir)/autotools/gen-coverage \
760         $(python_tests)
761
762 commit-check: distcheck lint apidoc
763
764 -include ./Makefile.local
765
766 # vim: set noet :