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