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