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