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