Fix gnt-instance reinstall
[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 REPLACE_VARS_SED = autotools/replace_vars.sed
15
16 hypervisordir = $(pkgpythondir)/hypervisor
17 httpdir = $(pkgpythondir)/http
18 rapidir = $(pkgpythondir)/rapi
19 toolsdir = $(pkglibdir)/tools
20 docdir = $(datadir)/doc/$(PACKAGE)
21
22 DIRS = \
23         autotools \
24         daemons \
25         devel \
26         doc \
27         doc/examples \
28         lib \
29         lib/http \
30         lib/hypervisor \
31         lib/rapi \
32         man \
33         qa \
34         scripts \
35         test \
36         test/data \
37         tools
38
39 MAINTAINERCLEANFILES = \
40         $(docpng) \
41         $(maninput)
42
43 maintainer-clean-local:
44         -rm -rf doc/api doc/build doc/html
45
46 CLEANFILES = \
47         autotools/replace_vars.sed \
48         devel/upload \
49         doc/examples/bash_completion \
50         doc/examples/ganeti.initd \
51         doc/examples/ganeti.cron \
52         lib/*.py[co] \
53         lib/http/*.py[co] \
54         lib/hypervisor/*.py[co] \
55         lib/rapi/*.py[co] \
56         $(man_MANS) \
57         $(manhtml) \
58         qa/*.py[co] \
59         test/*.py[co] \
60         stamp-directories \
61         $(nodist_pkgpython_PYTHON)
62
63 nodist_pkgpython_PYTHON = \
64         lib/_autoconf.py
65
66 pkgpython_PYTHON = \
67         lib/__init__.py \
68         lib/backend.py \
69         lib/bdev.py \
70         lib/bootstrap.py \
71         lib/cli.py \
72         lib/cmdlib.py \
73         lib/config.py \
74         lib/constants.py \
75         lib/daemon.py \
76         lib/errors.py \
77         lib/jqueue.py \
78         lib/jstore.py \
79         lib/locking.py \
80         lib/luxi.py \
81         lib/mcpu.py \
82         lib/objects.py \
83         lib/opcodes.py \
84         lib/rpc.py \
85         lib/serializer.py \
86         lib/ssconf.py \
87         lib/ssh.py \
88         lib/utils.py \
89         lib/workerpool.py
90
91 hypervisor_PYTHON = \
92         lib/hypervisor/__init__.py \
93         lib/hypervisor/hv_base.py \
94         lib/hypervisor/hv_fake.py \
95         lib/hypervisor/hv_kvm.py \
96         lib/hypervisor/hv_xen.py
97
98 rapi_PYTHON = \
99         lib/rapi/__init__.py \
100         lib/rapi/baserlib.py \
101         lib/rapi/connector.py \
102         lib/rapi/rlib2.py
103
104 http_PYTHON = \
105         lib/http/__init__.py \
106         lib/http/auth.py \
107         lib/http/client.py \
108         lib/http/server.py
109
110
111 docrst = \
112         doc/admin.rst \
113         doc/design-2.0.rst \
114         doc/glossary.rst \
115         doc/hooks.rst \
116         doc/iallocator.rst \
117         doc/index.rst \
118         doc/install.rst \
119         doc/rapi.rst \
120         doc/security.rst
121
122 doc/html: $(docrst) $(docpng) doc/conf.py configure.ac
123         @test -n "$(SPHINX)" || \
124             { echo 'sphinx-build' not found during configure; exit 1; }
125         mkdir -p doc/build/doctrees
126         PYTHONPATH=.:$(top_builddir) sphinx-build -q -b html \
127             -d doc/build/doctrees \
128             -D version="$(VERSION_MAJOR).$(VERSION_MINOR)" \
129             -D release="$(PACKAGE_VERSION)" \
130             $(top_srcdir)/doc doc/html
131         touch "$@"
132
133 docdot = \
134         doc/arch-2.0.dot
135
136 docpng = $(patsubst %.dot,%.png,$(docdot))
137
138 noinst_DATA = $(manhtml) doc/html
139
140 dist_sbin_SCRIPTS = \
141         daemons/ganeti-noded \
142         daemons/ganeti-watcher \
143         daemons/ganeti-masterd \
144         daemons/ganeti-rapi \
145         scripts/gnt-backup \
146         scripts/gnt-cluster \
147         scripts/gnt-debug \
148         scripts/gnt-instance \
149         scripts/gnt-job \
150         scripts/gnt-node \
151         scripts/gnt-os
152
153 dist_tools_SCRIPTS = \
154         tools/burnin \
155         tools/cfgshell \
156         tools/cfgupgrade \
157         tools/lvmstrap
158
159 EXTRA_DIST = \
160         $(MAINTAINERCLEANFILES) \
161         NEWS \
162         DEVNOTES \
163         autotools/docbook-wrapper \
164         devel/upload.in \
165         $(docdot) \
166         $(docrst) \
167         doc/conf.py \
168         doc/html \
169         doc/examples/bash_completion.in \
170         doc/examples/ganeti.initd.in \
171         doc/examples/ganeti.cron.in \
172         doc/examples/dumb-allocator \
173         doc/locking.txt \
174         test/testutils.py \
175         test/mocks.py \
176         $(dist_TESTS) \
177         $(TEST_FILES) \
178         man/footer.sgml \
179         $(mansgml) $(maninput) \
180         qa/ganeti-qa.py \
181         qa/qa-sample.json \
182         qa/qa_cluster.py \
183         qa/qa_config.py \
184         qa/qa_daemon.py \
185         qa/qa_env.py \
186         qa/qa_error.py \
187         qa/qa_instance.py \
188         qa/qa_node.py \
189         qa/qa_os.py \
190         qa/qa_rapi.py \
191         qa/qa_tags.py \
192         qa/qa_utils.py
193
194 man_MANS = \
195         man/ganeti.7 \
196         man/ganeti-masterd.8 \
197         man/ganeti-noded.8 \
198         man/ganeti-os-interface.7 \
199         man/ganeti-rapi.8 \
200         man/ganeti-watcher.8 \
201         man/gnt-backup.8 \
202         man/gnt-cluster.8 \
203         man/gnt-debug.8 \
204         man/gnt-instance.8 \
205         man/gnt-job.8 \
206         man/gnt-node.8 \
207         man/gnt-os.8
208
209 mansgml = $(patsubst %.7,%.sgml,$(patsubst %.8,%.sgml,$(man_MANS)))
210 manhtml = $(patsubst %.sgml,%.html,$(mansgml))
211 maninput = $(patsubst %.7,%.7.in,$(patsubst %.8,%.8.in,$(man_MANS))) $(patsubst %.html,%.html.in,$(manhtml))
212
213 TEST_FILES = \
214         test/data/bdev-both.txt \
215         test/data/bdev-8.3-both.txt \
216         test/data/bdev-disk.txt \
217         test/data/bdev-net.txt \
218         test/data/proc_drbd8.txt \
219         test/data/proc_drbd83.txt
220
221 dist_TESTS = \
222         test/ganeti.bdev_unittest.py \
223         test/ganeti.cli_unittest.py \
224         test/ganeti.cmdlib_unittest.py \
225         test/ganeti.config_unittest.py \
226         test/ganeti.constants_unittest.py \
227         test/ganeti.hooks_unittest.py \
228         test/ganeti.http_unittest.py \
229         test/ganeti.locking_unittest.py \
230         test/ganeti.rapi.resources_unittest.py \
231         test/ganeti.serializer_unittest.py \
232         test/ganeti.ssh_unittest.py \
233         test/ganeti.utils_unittest.py \
234         test/ganeti.workerpool_unittest.py
235
236 nodist_TESTS =
237
238 TESTS = $(dist_TESTS) $(nodist_TESTS)
239
240 TESTS_ENVIRONMENT = PYTHONPATH=.:$(top_builddir) $(PYTHON)
241
242 all-local: stamp-directories lib/_autoconf.py devel/upload \
243         doc/examples/bash_completion \
244         doc/examples/ganeti.initd doc/examples/ganeti.cron
245
246 devel/upload: devel/upload.in stamp-directories $(REPLACE_VARS_SED)
247         sed -f $(REPLACE_VARS_SED) < $< > $@
248         chmod u+x $@
249
250 doc/examples/%: doc/examples/%.in stamp-directories \
251                 $(REPLACE_VARS_SED)
252         sed -f $(REPLACE_VARS_SED) < $< > $@
253
254 doc/%.png: doc/%.dot
255         @test -n "$(DOT)" || { echo 'dot' not found during configure; exit 1; }
256         $(DOT) -Tpng -o $@ $<
257
258 man/%.7.in man/%.8.in: man/%.sgml man/footer.sgml $(DOCBOOK_WRAPPER)
259         @test -n "$(DOCBOOK2MAN)" || { echo 'docbook2html' not found during configure; exit 1; }
260         TMPDIR=`mktemp -d` && { \
261         $(DOCBOOK_WRAPPER) "$(DOCBOOK2MAN)" $< $$TMPDIR/$(patsubst man/%.in,%,$@) ; \
262         mv $$TMPDIR/$(patsubst man/%.in,%,$@) $@ ; \
263         rm -rf "$$TMPDIR" ; \
264         }
265
266 man/%.html.in: man/%.sgml man/footer.sgml $(DOCBOOK_WRAPPER)
267         @test -n "$(DOCBOOK2HTML)" || { echo 'docbook2html' not found during configure; exit 1; }
268         TMPDIR=`mktemp -d` && { \
269         $(DOCBOOK_WRAPPER) "$(DOCBOOK2HTML) --nochunks" $< $$TMPDIR/$(patsubst man/%.in,%,$@) ; \
270         mv $$TMPDIR/$(patsubst man/%.in,%,$@) $@ ; \
271         rm -rf "$$TMPDIR" ; \
272         }
273
274 man/%.7: man/%.7.in stamp-directories $(REPLACE_VARS_SED)
275         sed -f $(REPLACE_VARS_SED) < $< > $@
276
277 man/%.8: man/%.8.in stamp-directories $(REPLACE_VARS_SED)
278         sed -f $(REPLACE_VARS_SED) < $< > $@
279
280 man/%.html: man/%.html.in stamp-directories $(REPLACE_VARS_SED)
281         sed -f $(REPLACE_VARS_SED) < $< > $@
282
283 man/footer.sgml $(TESTS): srclinks
284
285 $(TESTS): ganeti lib/_autoconf.py
286
287 lib/_autoconf.py: Makefile stamp-directories
288         set -e; \
289         { echo '# This file is automatically generated, do not edit!'; \
290           echo '#'; \
291           echo ''; \
292           echo '"""Build-time configuration for Ganeti.'; \
293           echo '';\
294           echo 'This file is autogenerated by the build process.'; \
295           echo 'For any changes you need to re-run ./configure (and'; \
296           echo 'not edit by hand).'; \
297           echo ''; \
298           echo '"""'; \
299           echo ''; \
300           echo "PACKAGE_VERSION = '$(PACKAGE_VERSION)'"; \
301           echo "VERSION_MAJOR = '$(VERSION_MAJOR)'"; \
302           echo "VERSION_MINOR = '$(VERSION_MINOR)'"; \
303           echo "VERSION_REVISION = '$(VERSION_REVISION)'"; \
304           echo "VERSION_SUFFIX = '$(VERSION_SUFFIX)'"; \
305           echo "VERSION_FULL = '$(VERSION_FULL)'"; \
306           echo "LOCALSTATEDIR = '$(localstatedir)'"; \
307           echo "SYSCONFDIR = '$(sysconfdir)'"; \
308           echo "SSH_INITD_SCRIPT = '$(SSH_INITD_SCRIPT)'"; \
309           echo "EXPORT_DIR = '$(EXPORT_DIR)'"; \
310           echo "OS_SEARCH_PATH = [$(OS_SEARCH_PATH)]"; \
311           echo "XEN_KERNEL = '$(XEN_KERNEL)'"; \
312           echo "XEN_INITRD = '$(XEN_INITRD)'"; \
313           echo "FILE_STORAGE_DIR = '$(FILE_STORAGE_DIR)'"; \
314           echo "IALLOCATOR_SEARCH_PATH = [$(IALLOCATOR_SEARCH_PATH)]"; \
315           echo "KVM_PATH = '$(KVM_PATH)'"; \
316           echo "KVM_MIGRATION_PORT = '$(KVM_MIGRATION_PORT)'"; \
317           echo "SOCAT_PATH = '$(SOCAT_PATH)'"; \
318         } > $@
319
320 $(REPLACE_VARS_SED): Makefile stamp-directories
321         set -e; \
322         { echo 's#@PREFIX@#$(prefix)#g'; \
323           echo 's#@SYSCONFDIR@#$(sysconfdir)#g'; \
324           echo 's#@LOCALSTATEDIR@#$(localstatedir)#g'; \
325           echo 's#@SBINDIR@#$(sbindir)#g'; \
326           echo 's#@GANETI_VERSION@#$(PACKAGE_VERSION)#g'; \
327           echo 's#@CUSTOM_XEN_KERNEL@#$(XEN_KERNEL)#g'; \
328           echo 's#@CUSTOM_XEN_INITRD@#$(XEN_INITRD)#g'; \
329           echo 's#@RPL_FILE_STORAGE_DIR@#$(FILE_STORAGE_DIR)#g'; \
330         } > $@
331
332 # We need to create symlinks because "make distcheck" will not install Python
333 # files when building.
334 #.PHONY: srclinks
335 srclinks: stamp-directories
336         set -e; \
337         for i in man/footer.sgml $(pkgpython_PYTHON) $(hypervisor_PYTHON) \
338                         $(rapi_PYTHON) $(http_PYTHON); do \
339                 if test ! -f $$i -a -f $(abs_top_srcdir)/$$i; then \
340                         $(LN_S) $(abs_top_srcdir)/$$i $$i; \
341                 fi; \
342         done
343
344 .PHONY: ganeti
345 ganeti:
346         cd $(top_builddir) && test -h "$@" || { rm -f $@ && $(LN_S) lib $@; }
347
348 # a dist hook rule for catching revision control directories
349 distcheck-hook:
350         if find $(top_distdir) | grep -F -e '.svn' -e '.git'; then \
351                 echo "Found revision control files in final archive" 1>&2 ; \
352                 exit 1; \
353         fi
354
355 install-exec-local:
356         @mkdir_p@ "$(DESTDIR)${localstatedir}/lib/ganeti" \
357           "$(DESTDIR)${localstatedir}/log/ganeti" \
358           "$(DESTDIR)${localstatedir}/run/ganeti"
359
360 stamp-directories: Makefile
361         @mkdir_p@ $(DIRS)
362         touch $@
363
364 .PHONY: apidoc
365 apidoc:
366         test -e doc/api || mkdir doc/api
367         TMPDIR=`mktemp -d ` && { \
368                 cp -r scripts daemons lib $$TMPDIR && \
369                 ( \
370                         CDIR=`pwd` && \
371                         cd $$TMPDIR && \
372                         mv lib ganeti && \
373                         epydoc -v --conf $$CDIR/epydoc.conf -o $$CDIR/doc/api \
374                 ) ; \
375                 rm -rf $$TMPDIR ; \
376         }
377
378 .PHONY: TAGS
379 TAGS:
380         rm -f TAGS
381         find . -path './lib/*.py' -o -path 'scripts/gnt-*' -o \
382           -path 'daemons/ganeti-*' -o -path 'tools/*' | \
383           etags -
384
385 # vim: set noet :