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