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