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