Introduce utils.IsValidIP{4,6}()
[ganeti-local] / Makefile.am
1 # Ganeti makefile
2 # - Indent with tabs only.
3 # - Keep files sorted; one line per file.
4 # - Directories in lib/ must have their own *dir variable (see hypervisor).
5 # - All directories must be listed DIRS.
6 # - Use autogen.sh to generate Makefile.in and configure script.
7
8 # Automake doesn't export these variables before version 1.10.
9 abs_top_builddir = @abs_top_builddir@
10 abs_top_srcdir = @abs_top_srcdir@
11
12 ACLOCAL_AMFLAGS = -I autotools
13 DOCBOOK_WRAPPER = $(top_srcdir)/autotools/docbook-wrapper
14 BUILD_BASH_COMPLETION = $(top_srcdir)/autotools/build-bash-completion
15 RUN_IN_TEMPDIR = $(top_srcdir)/autotools/run-in-tempdir
16 CHECK_PYTHON_CODE = $(top_srcdir)/autotools/check-python-code
17 CHECK_MAN = $(top_srcdir)/autotools/check-man
18 REPLACE_VARS_SED = autotools/replace_vars.sed
19
20 hypervisordir = $(pkgpythondir)/hypervisor
21 httpdir = $(pkgpythondir)/http
22 masterddir = $(pkgpythondir)/masterd
23 confddir = $(pkgpythondir)/confd
24 rapidir = $(pkgpythondir)/rapi
25 impexpddir = $(pkgpythondir)/impexpd
26 toolsdir = $(pkglibdir)/tools
27 docdir = $(datadir)/doc/$(PACKAGE)
28
29 # Delete output file if an error occurred while building it
30 .DELETE_ON_ERROR:
31
32 DIRS = \
33         autotools \
34         daemons \
35         devel \
36         doc \
37         doc/examples \
38         doc/examples/hooks \
39         doc/examples/gnt-debug \
40         lib \
41         lib/build \
42         lib/confd \
43         lib/http \
44         lib/hypervisor \
45         lib/impexpd \
46         lib/masterd \
47         lib/rapi \
48         man \
49         qa \
50         scripts \
51         test \
52         test/data \
53         tools
54
55 BUILDTIME_DIRS = \
56         doc/api \
57         doc/coverage \
58         doc/html
59
60 DIRCHECK_EXCLUDE = \
61         $(BUILDTIME_DIRS) \
62         ganeti-[0-9]*.[0-9]*.[0-9]* \
63         doc/html/_*
64
65 MAINTAINERCLEANFILES = \
66         $(docpng) \
67         $(maninput) \
68         doc/install-quick.rst \
69         doc/news.rst
70
71 maintainer-clean-local:
72         rm -rf $(BUILDTIME_DIRS)
73
74 CLEANFILES = \
75         $(addsuffix /*.py[co],$(DIRS)) \
76         autotools/replace_vars.sed \
77         daemons/daemon-util \
78         daemons/ensure-dirs \
79         daemons/ganeti-cleaner \
80         devel/upload \
81         doc/examples/bash_completion \
82         doc/examples/ganeti.initd \
83         doc/examples/ganeti.cron \
84         doc/examples/gnt-config-backup \
85         doc/examples/hooks/ipsec \
86         $(man_MANS) \
87         $(manhtml) \
88         stamp-directories \
89         stamp-srclinks \
90         $(nodist_pkgpython_PYTHON)
91
92 BUILT_SOURCES = \
93         ganeti \
94         stamp-srclinks \
95         stamp-directories \
96         lib/_autoconf.py
97
98 nodist_pkgpython_PYTHON = \
99         lib/_autoconf.py
100
101 noinst_PYTHON = \
102         lib/build/__init__.py
103
104 pkgpython_PYTHON = \
105         lib/__init__.py \
106         lib/asyncnotifier.py \
107         lib/backend.py \
108         lib/bdev.py \
109         lib/bootstrap.py \
110         lib/cli.py \
111         lib/cmdlib.py \
112         lib/compat.py \
113         lib/config.py \
114         lib/constants.py \
115         lib/daemon.py \
116         lib/errors.py \
117         lib/jqueue.py \
118         lib/jstore.py \
119         lib/locking.py \
120         lib/luxi.py \
121         lib/mcpu.py \
122         lib/objects.py \
123         lib/opcodes.py \
124         lib/rpc.py \
125         lib/serializer.py \
126         lib/ssconf.py \
127         lib/ssh.py \
128         lib/storage.py \
129         lib/utils.py \
130         lib/uidpool.py \
131         lib/workerpool.py
132
133 hypervisor_PYTHON = \
134         lib/hypervisor/__init__.py \
135         lib/hypervisor/hv_base.py \
136         lib/hypervisor/hv_chroot.py \
137         lib/hypervisor/hv_fake.py \
138         lib/hypervisor/hv_kvm.py \
139         lib/hypervisor/hv_xen.py
140
141 rapi_PYTHON = \
142         lib/rapi/__init__.py \
143         lib/rapi/baserlib.py \
144         lib/rapi/client.py \
145         lib/rapi/client_utils.py \
146         lib/rapi/connector.py \
147         lib/rapi/rlib2.py
148
149 http_PYTHON = \
150         lib/http/__init__.py \
151         lib/http/auth.py \
152         lib/http/client.py \
153         lib/http/server.py
154
155 confd_PYTHON = \
156         lib/confd/__init__.py \
157         lib/confd/client.py \
158         lib/confd/querylib.py \
159         lib/confd/server.py
160
161 masterd_PYTHON = \
162         lib/masterd/__init__.py \
163         lib/masterd/instance.py
164
165 impexpd_PYTHON = \
166         lib/impexpd/__init__.py
167
168 docrst = \
169         doc/admin.rst \
170         doc/design-2.0.rst \
171         doc/design-2.1.rst \
172         doc/design-2.2.rst \
173         doc/design-cluster-merger.rst \
174         doc/devnotes.rst \
175         doc/glossary.rst \
176         doc/hooks.rst \
177         doc/iallocator.rst \
178         doc/index.rst \
179         doc/install-quick.rst \
180         doc/install.rst \
181         doc/locking.rst \
182         doc/move-instance.rst \
183         doc/news.rst \
184         doc/rapi.rst \
185         doc/security.rst \
186         doc/walkthrough.rst
187
188 doc/html/.stamp: $(docrst) $(docpng) doc/conf.py configure.ac
189         @test -n "$(SPHINX)" || \
190             { echo 'sphinx-build' not found during configure; exit 1; }
191         PYTHONPATH=. $(RUN_IN_TEMPDIR) $(SPHINX) -q -W -b html \
192             -d . \
193             -D version="$(VERSION_MAJOR).$(VERSION_MINOR)" \
194             -D release="$(PACKAGE_VERSION)" \
195             $(abs_top_srcdir)/doc $(CURDIR)/doc/html
196         rm -f doc/html/.buildinfo doc/html/objects.inv
197         touch $@
198
199 doc/html: doc/html/.stamp
200
201 doc/news.rst: NEWS
202         set -e; \
203         { echo '.. This file is automatically updated at build time from $<.'; \
204           echo '.. Do not edit.'; \
205           echo; \
206           cat $<; \
207         } > $@
208
209 doc/install-quick.rst: INSTALL
210         set -e; \
211         { echo '.. This file is automatically updated at build time from $<.'; \
212           echo '.. Do not edit.'; \
213           echo; \
214           cat $<; \
215         } > $@
216
217 docdot = \
218         doc/arch-2.0.dot \
219         doc/design-2.1-lock-acquire.dot \
220         doc/design-2.1-lock-release.dot
221
222 docpng = $(patsubst %.dot,%.png,$(docdot))
223
224 # Things to build but not to install (add it to EXTRA_DIST if it should be
225 # distributed)
226 noinst_DATA = \
227         devel/upload \
228         doc/html \
229         doc/examples/bash_completion \
230         doc/examples/ganeti.cron \
231         doc/examples/ganeti.initd \
232         doc/examples/gnt-config-backup \
233         doc/examples/hooks/ipsec \
234         $(manhtml)
235
236 gnt_scripts = \
237         scripts/gnt-backup \
238         scripts/gnt-cluster \
239         scripts/gnt-debug \
240         scripts/gnt-instance \
241         scripts/gnt-job \
242         scripts/gnt-node \
243         scripts/gnt-os
244
245 dist_sbin_SCRIPTS = \
246         daemons/ganeti-noded \
247         daemons/ganeti-watcher \
248         daemons/ganeti-masterd \
249         daemons/ganeti-confd \
250         daemons/ganeti-rapi \
251         $(gnt_scripts)
252
253 nodist_sbin_SCRIPTS = \
254         daemons/ganeti-cleaner
255
256 dist_tools_SCRIPTS = \
257         tools/burnin \
258         tools/cfgshell \
259         tools/cfgupgrade \
260         tools/cfgupgrade12 \
261         tools/cluster-merge \
262         tools/lvmstrap \
263         tools/move-instance \
264         tools/sanitize-config
265
266 pkglib_python_scripts = \
267         daemons/import-export \
268         tools/check-cert-expired
269
270 pkglib_SCRIPTS = \
271         daemons/daemon-util \
272         daemons/ensure-dirs \
273         $(pkglib_python_scripts)
274
275 EXTRA_DIST = \
276         NEWS \
277         pylintrc \
278         autotools/build-bash-completion \
279         autotools/check-python-code \
280         autotools/check-man \
281         autotools/docbook-wrapper \
282         autotools/gen-coverage \
283         autotools/testrunner \
284         $(RUN_IN_TEMPDIR) \
285         daemons/daemon-util.in \
286         daemons/ensure-dirs.in \
287         daemons/ganeti-cleaner.in \
288         $(pkglib_python_scripts) \
289         devel/upload.in \
290         $(docdot) \
291         $(docpng) \
292         $(docrst) \
293         doc/conf.py \
294         doc/html \
295         doc/examples/ganeti.initd.in \
296         doc/examples/ganeti.cron.in \
297         doc/examples/gnt-config-backup.in \
298         doc/examples/dumb-allocator \
299         doc/examples/ganeti.default \
300         doc/examples/ganeti.default-debug \
301         doc/examples/hooks/ethers \
302         doc/examples/hooks/ipsec.in \
303         doc/examples/gnt-debug/README \
304         doc/examples/gnt-debug/delay0.json \
305         doc/examples/gnt-debug/delay50.json \
306         test/testutils.py \
307         test/mocks.py \
308         $(dist_TESTS) \
309         $(TEST_FILES) \
310         man/footer.sgml \
311         $(mansgml) \
312         $(maninput) \
313         qa/ganeti-qa.py \
314         qa/qa-sample.json \
315         qa/qa_cluster.py \
316         qa/qa_config.py \
317         qa/qa_daemon.py \
318         qa/qa_env.py \
319         qa/qa_error.py \
320         qa/qa_instance.py \
321         qa/qa_node.py \
322         qa/qa_os.py \
323         qa/qa_rapi.py \
324         qa/qa_tags.py \
325         qa/qa_utils.py
326
327 man_MANS = \
328         man/ganeti.7 \
329         man/ganeti-cleaner.8 \
330         man/ganeti-confd.8 \
331         man/ganeti-masterd.8 \
332         man/ganeti-noded.8 \
333         man/ganeti-os-interface.7 \
334         man/ganeti-rapi.8 \
335         man/ganeti-watcher.8 \
336         man/gnt-backup.8 \
337         man/gnt-cluster.8 \
338         man/gnt-debug.8 \
339         man/gnt-instance.8 \
340         man/gnt-job.8 \
341         man/gnt-node.8 \
342         man/gnt-os.8
343
344 mansgml = $(patsubst %.7,%.sgml,$(patsubst %.8,%.sgml,$(man_MANS)))
345 manhtml = $(patsubst %.sgml,%.html,$(mansgml))
346 maninput = \
347         $(patsubst %.7,%.7.in,$(patsubst %.8,%.8.in,$(man_MANS))) \
348         $(patsubst %.html,%.html.in,$(manhtml))
349
350 TEST_FILES = \
351         test/data/bdev-both.txt \
352         test/data/bdev-8.3-both.txt \
353         test/data/bdev-disk.txt \
354         test/data/bdev-net.txt \
355         test/data/cert1.pem \
356         test/data/proc_drbd8.txt \
357         test/data/proc_drbd80-emptyline.txt \
358         test/data/proc_drbd83.txt \
359         test/import-export_unittest-helper
360
361 python_tests = \
362         test/ganeti.asyncnotifier_unittest.py \
363         test/ganeti.backend_unittest.py \
364         test/ganeti.bdev_unittest.py \
365         test/ganeti.cli_unittest.py \
366         test/ganeti.daemon_unittest.py \
367         test/ganeti.cmdlib_unittest.py \
368         test/ganeti.compat_unittest.py \
369         test/ganeti.confd.client_unittest.py \
370         test/ganeti.config_unittest.py \
371         test/ganeti.constants_unittest.py \
372         test/ganeti.errors_unittest.py \
373         test/ganeti.hooks_unittest.py \
374         test/ganeti.http_unittest.py \
375         test/ganeti.impexpd_unittest.py \
376         test/ganeti.locking_unittest.py \
377         test/ganeti.luxi_unittest.py \
378         test/ganeti.masterd.instance_unittest.py \
379         test/ganeti.mcpu_unittest.py \
380         test/ganeti.objects_unittest.py \
381         test/ganeti.opcodes_unittest.py \
382         test/ganeti.rapi.client_unittest.py \
383         test/ganeti.rapi.resources_unittest.py \
384         test/ganeti.rapi.rlib2_unittest.py \
385         test/ganeti.serializer_unittest.py \
386         test/ganeti.ssh_unittest.py \
387         test/ganeti.uidpool_unittest.py \
388         test/ganeti.utils_unittest.py \
389         test/ganeti.utils_mlockall_unittest.py \
390         test/ganeti.workerpool_unittest.py \
391         test/cfgupgrade_unittest.py \
392         test/docs_unittest.py \
393         test/tempfile_fork_unittest.py
394
395 dist_TESTS = \
396         test/check-cert-expired_unittest.bash \
397         test/daemon-util_unittest.bash \
398         test/ganeti-cleaner_unittest.bash \
399         test/import-export_unittest.bash \
400         $(python_tests)
401
402 nodist_TESTS =
403
404 TESTS = $(dist_TESTS) $(nodist_TESTS)
405
406 # Environment for all tests
407 PLAIN_TESTS_ENVIRONMENT = \
408         PYTHONPATH=. TOP_SRCDIR=$(abs_top_srcdir) PYTHON=$(PYTHON) $(RUN_IN_TEMPDIR)
409
410 # Environment for tests run by automake
411 TESTS_ENVIRONMENT = \
412         $(PLAIN_TESTS_ENVIRONMENT) $(abs_top_srcdir)/autotools/testrunner
413
414 all_python_code = \
415         $(dist_sbin_SCRIPTS) \
416         $(dist_tools_SCRIPTS) \
417         $(pkglib_python_scripts) \
418         $(python_tests) \
419         $(pkgpython_PYTHON) \
420         $(hypervisor_PYTHON) \
421         $(rapi_PYTHON) \
422         $(http_PYTHON) \
423         $(confd_PYTHON) \
424         $(masterd_PYTHON) \
425         $(impexpd_PYTHON) \
426         $(noinst_PYTHON)
427
428 srclink_files = \
429         man/footer.sgml \
430         test/check-cert-expired_unittest.bash \
431         test/daemon-util_unittest.bash \
432         test/ganeti-cleaner_unittest.bash \
433         test/import-export_unittest.bash \
434         $(all_python_code)
435
436 check_python_code = \
437         $(BUILD_BASH_COMPLETION) \
438         $(all_python_code)
439
440 lint_python_code = \
441         ganeti \
442         $(dist_sbin_SCRIPTS) \
443         $(dist_tools_SCRIPTS) \
444         $(pkglib_python_scripts) \
445         $(BUILD_BASH_COMPLETION)
446
447 test/daemon-util_unittest.bash: daemons/daemon-util
448
449 test/ganeti-cleaner_unittest.bash: daemons/ganeti-cleaner
450
451 devel/upload: devel/upload.in $(REPLACE_VARS_SED)
452         sed -f $(REPLACE_VARS_SED) < $< > $@
453         chmod u+x $@
454
455 daemons/%: daemons/%.in \
456                 $(REPLACE_VARS_SED)
457         sed -f $(REPLACE_VARS_SED) < $< > $@
458         chmod +x $@
459
460 doc/examples/%: doc/examples/%.in \
461                 $(REPLACE_VARS_SED)
462         sed -f $(REPLACE_VARS_SED) < $< > $@
463
464 doc/examples/hooks/%: doc/examples/hooks/%.in \
465                 $(REPLACE_VARS_SED)
466         sed -f $(REPLACE_VARS_SED) < $< > $@
467
468 doc/examples/bash_completion: $(BUILD_BASH_COMPLETION) $(RUN_IN_TEMPDIR) \
469         lib/cli.py $(gnt_scripts) tools/burnin
470         PYTHONPATH=. $(RUN_IN_TEMPDIR) $(CURDIR)/$(BUILD_BASH_COMPLETION) > $@
471
472 doc/%.png: doc/%.dot
473         @test -n "$(DOT)" || { echo 'dot' not found during configure; exit 1; }
474         $(DOT) -Tpng -o $@ $<
475
476 man/%.7.in man/%.8.in: man/%.sgml man/footer.sgml $(DOCBOOK_WRAPPER)
477         @test -n "$(DOCBOOK2MAN)" || \
478           { echo 'docbook2man' not found during configure; exit 1; }
479         $(DOCBOOK_WRAPPER) "$(DOCBOOK2MAN)" $< $(notdir $(@:.in=)) $@
480         $(CHECK_MAN) $@
481
482 man/%.html.in: man/%.sgml man/footer.sgml $(DOCBOOK_WRAPPER)
483         @test -n "$(DOCBOOK2HTML)" || \
484           { echo 'docbook2html' not found during configure; exit 1; }
485         $(DOCBOOK_WRAPPER) "$(DOCBOOK2HTML) --nochunks" $< $(notdir $(@:.in=)) $@
486
487 man/%.7: man/%.7.in $(REPLACE_VARS_SED)
488         sed -f $(REPLACE_VARS_SED) < $< > $@
489
490 man/%.8: man/%.8.in $(REPLACE_VARS_SED)
491         sed -f $(REPLACE_VARS_SED) < $< > $@
492
493 man/%.html: man/%.html.in $(REPLACE_VARS_SED)
494         sed -f $(REPLACE_VARS_SED) < $< > $@
495
496 lib/_autoconf.py: Makefile stamp-directories
497         set -e; \
498         { echo '# This file is automatically generated, do not edit!'; \
499           echo '#'; \
500           echo ''; \
501           echo '"""Build-time configuration for Ganeti.'; \
502           echo '';\
503           echo 'This file is autogenerated by the build process.'; \
504           echo 'For any changes you need to re-run ./configure (and'; \
505           echo 'not edit by hand).'; \
506           echo ''; \
507           echo '"""'; \
508           echo ''; \
509           echo '# pylint: disable-msg=C0301,C0324'; \
510           echo '# because this is autogenerated, we do not want'; \
511           echo '# style warnings' ; \
512           echo ''; \
513           echo "PACKAGE_VERSION = '$(PACKAGE_VERSION)'"; \
514           echo "VERSION_MAJOR = '$(VERSION_MAJOR)'"; \
515           echo "VERSION_MINOR = '$(VERSION_MINOR)'"; \
516           echo "VERSION_REVISION = '$(VERSION_REVISION)'"; \
517           echo "VERSION_SUFFIX = '$(VERSION_SUFFIX)'"; \
518           echo "VERSION_FULL = '$(VERSION_FULL)'"; \
519           echo "LOCALSTATEDIR = '$(localstatedir)'"; \
520           echo "SYSCONFDIR = '$(sysconfdir)'"; \
521           echo "SSH_CONFIG_DIR = '$(SSH_CONFIG_DIR)'"; \
522           echo "EXPORT_DIR = '$(EXPORT_DIR)'"; \
523           echo "OS_SEARCH_PATH = [$(OS_SEARCH_PATH)]"; \
524           echo "XEN_BOOTLOADER = '$(XEN_BOOTLOADER)'"; \
525           echo "XEN_KERNEL = '$(XEN_KERNEL)'"; \
526           echo "XEN_INITRD = '$(XEN_INITRD)'"; \
527           echo "FILE_STORAGE_DIR = '$(FILE_STORAGE_DIR)'"; \
528           echo "ENABLE_FILE_STORAGE = $(ENABLE_FILE_STORAGE)"; \
529           echo "IALLOCATOR_SEARCH_PATH = [$(IALLOCATOR_SEARCH_PATH)]"; \
530           echo "KVM_PATH = '$(KVM_PATH)'"; \
531           echo "SOCAT_PATH = '$(SOCAT)'"; \
532           echo "SOCAT_USE_ESCAPE = $(SOCAT_USE_ESCAPE)"; \
533           echo "LVM_STRIPECOUNT = $(LVM_STRIPECOUNT)"; \
534           echo "TOOLSDIR = '$(toolsdir)'"; \
535           echo "GNT_SCRIPTS = [$(foreach i,$(notdir $(gnt_scripts)),'$(i)',)]"; \
536           echo "PKGLIBDIR = '$(pkglibdir)'"; \
537           echo "DRBD_BARRIERS = $(DRBD_BARRIERS)"; \
538           echo "SYSLOG_USAGE = '$(SYSLOG_USAGE)'"; \
539           echo "DAEMONS_GROUP = '$(DAEMONS_GROUP)'"; \
540           echo "MASTERD_USER = '$(MASTERD_USER)'"; \
541           echo "RAPI_USER = '$(RAPI_USER)'"; \
542         } > $@
543
544 $(REPLACE_VARS_SED): Makefile
545         set -e; \
546         { echo 's#@PREFIX@#$(prefix)#g'; \
547           echo 's#@SYSCONFDIR@#$(sysconfdir)#g'; \
548           echo 's#@LOCALSTATEDIR@#$(localstatedir)#g'; \
549           echo 's#@BINDIR@#$(bindir)#g'; \
550           echo 's#@SBINDIR@#$(sbindir)#g'; \
551           echo 's#@GANETI_VERSION@#$(PACKAGE_VERSION)#g'; \
552           echo 's#@CUSTOM_XEN_BOOTLOADER@#$(XEN_BOOTLOADER)#g'; \
553           echo 's#@CUSTOM_XEN_KERNEL@#$(XEN_KERNEL)#g'; \
554           echo 's#@CUSTOM_XEN_INITRD@#$(XEN_INITRD)#g'; \
555           echo 's#@RPL_FILE_STORAGE_DIR@#$(FILE_STORAGE_DIR)#g'; \
556           echo 's#@RPL_SSH_INITD_SCRIPT@#$(SSH_INITD_SCRIPT)#g'; \
557           echo 's#@PKGLIBDIR@#$(pkglibdir)#g'; \
558           echo 's#@GNTMASTERUSER@#$(MASTERD_USER)#g'; \
559           echo 's#@GNTRAPIUSER@#$(RAPI_USER)#g'; \
560           echo 's#@GNTCONFDUSER@#$(CONFD_USER)#g'; \
561           echo 's#@GNTNODEDUSER@#$(NODED_USER)#g'; \
562           echo 's#@GNTRAPIGROUP@#$(RAPI_GROUP)#g'; \
563           echo 's#@GNTADMINGROUP@#$(ADMIN_GROUP)#g'; \
564           echo 's#@GNTCONFDGROUP@#$(CONFD_GROUP)#g'; \
565           echo 's#@GNTMASTERDGROUP@#$(MASTERD_GROUP)#g'; \
566           echo 's#@GNTDAEMONSGROUP@#$(DAEMONS_GROUP)#g'; \
567         } > $@
568
569 # We need to create symlinks because "make distcheck" will not install Python
570 # files when building.
571 stamp-srclinks: Makefile stamp-directories
572         set -e; \
573         for i in $(srclink_files); do \
574                 if test ! -f $$i -a -f $(abs_top_srcdir)/$$i; then \
575                         $(LN_S) $(abs_top_srcdir)/$$i $$i; \
576                 fi; \
577         done
578         touch $@
579
580 .PHONY: ganeti
581 ganeti:
582         cd $(top_builddir) && test -h "$@" || { rm -f $@ && $(LN_S) lib $@; }
583
584 .PHONY: check-dirs
585 check-dirs: $(BUILT_SOURCES)
586         set -e; \
587         find . -type d \( \( -name . \) -o \( \
588                 -name .git -o \
589                 -name autom4te.cache \
590                 \) -prune -o -print \) | { \
591                 error=; \
592                 while read dir; do \
593                         case "$$dir" in \
594                                 $(strip $(patsubst %,(./%) ;;,$(DIRCHECK_EXCLUDE) $(DIRS))) \
595                                 *) error=1; echo "Directory $$dir not listed in Makefile" >&2 ;; \
596                         esac; \
597                 done; \
598                 for dir in $(DIRS); do \
599                         if ! test -d "$$dir"; then \
600                                 echo "Directory $$dir listed in DIRS does not exist" >&2; \
601                                 error=1; \
602                         fi \
603                 done; \
604                 if test -n "$$error"; then exit 1; else exit 0; fi; \
605         }
606
607 check-local: check-dirs
608         $(CHECK_PYTHON_CODE) $(check_python_code)
609
610 .PHONY: lint
611 lint: ganeti $(BUILT_SOURCES)
612         @test -n "$(PYLINT)" || { echo 'pylint' not found during configure; exit 1; }
613         $(PYLINT) $(LINT_OPTS) $(lint_python_code)
614
615 # a dist hook rule for catching revision control directories
616 distcheck-hook:
617         if find $(top_distdir) -name .svn -or -name .git | grep .; then \
618                 echo "Found revision control files in final archive." 1>&2; \
619                 exit 1; \
620         fi
621         if find $(top_distdir) -name '*.py[co]' | grep .; then \
622                 echo "Found Python byte code in final archive." 1>&2; \
623                 exit 1; \
624         fi
625         if find $(top_distdir) -name '*~' | grep .; then \
626                 echo "Found backup files in final archive." 1>&2; \
627                 exit 1; \
628         fi
629
630 install-exec-local:
631         @mkdir_p@ "$(DESTDIR)${localstatedir}/lib/ganeti" \
632           "$(DESTDIR)${localstatedir}/log/ganeti" \
633           "$(DESTDIR)${localstatedir}/run/ganeti"
634
635 stamp-directories: Makefile
636         @mkdir_p@ $(DIRS)
637         touch $@
638
639 .PHONY: apidoc
640 apidoc: epydoc.conf $(RUN_IN_TEMPDIR) $(BUILT_SOURCES)
641         test -e doc/api || mkdir doc/api
642         $(RUN_IN_TEMPDIR) epydoc -v \
643                 --conf $(CURDIR)/epydoc.conf \
644                 --output $(CURDIR)/doc/api
645
646 .PHONY: TAGS
647 TAGS: $(BUILT_SOURCES)
648         rm -f TAGS
649         find . -path './lib/*.py' -o -path 'scripts/gnt-*' -o \
650           -path 'daemons/ganeti-*' -o -path 'tools/*' | \
651           etags -
652
653 .PHONY: coverage
654 coverage: $(BUILT_SOURCES) $(python_tests)
655         set -e; \
656         mkdir -p doc/coverage; \
657         COVERAGE_FILE=$(CURDIR)/doc/coverage/data \
658         TEXT_COVERAGE=$(CURDIR)/doc/coverage/report.txt \
659         HTML_COVERAGE=$(CURDIR)/doc/coverage \
660         $(PLAIN_TESTS_ENVIRONMENT) $(abs_top_srcdir)/autotools/gen-coverage \
661         $(python_tests)
662
663 commit-check: distcheck lint apidoc
664
665 -include ./Makefile.local
666
667 # vim: set noet :