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