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