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