Add shortcut for network-related cluster params
[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 # Helper values for calling builtin functions
13 empty :=
14 space := $(empty) $(empty)
15 comma := ,
16
17 # Use bash in order to be able to use pipefail
18 SHELL=/bin/bash
19
20 ACLOCAL_AMFLAGS = -I autotools
21 BUILD_BASH_COMPLETION = $(top_srcdir)/autotools/build-bash-completion
22 RUN_IN_TEMPDIR = $(top_srcdir)/autotools/run-in-tempdir
23 CHECK_PYTHON_CODE = $(top_srcdir)/autotools/check-python-code
24 CHECK_MAN = $(top_srcdir)/autotools/check-man
25 CHECK_VERSION = $(top_srcdir)/autotools/check-version
26 CHECK_NEWS = $(top_srcdir)/autotools/check-news
27 CHECK_IMPORTS = $(top_srcdir)/autotools/check-imports
28 DOCPP = $(top_srcdir)/autotools/docpp
29 REPLACE_VARS_SED = autotools/replace_vars.sed
30 CONVERT_CONSTANTS = $(top_srcdir)/autotools/convert-constants
31 BUILD_RPC = $(top_srcdir)/autotools/build-rpc
32
33 # Note: these are automake-specific variables, and must be named after
34 # the directory + 'dir' suffix
35 clientdir = $(pkgpythondir)/client
36 hypervisordir = $(pkgpythondir)/hypervisor
37 httpdir = $(pkgpythondir)/http
38 masterddir = $(pkgpythondir)/masterd
39 confddir = $(pkgpythondir)/confd
40 rapidir = $(pkgpythondir)/rapi
41 serverdir = $(pkgpythondir)/server
42 watcherdir = $(pkgpythondir)/watcher
43 impexpddir = $(pkgpythondir)/impexpd
44 utilsdir = $(pkgpythondir)/utils
45 toolsdir = $(pkglibdir)/tools
46 iallocatorsdir = $(pkglibdir)/iallocators
47 pytoolsdir = $(pkgpythondir)/tools
48 docdir = $(datadir)/doc/$(PACKAGE)
49
50 # Delete output file if an error occurred while building it
51 .DELETE_ON_ERROR:
52
53 HTOOLS_DIRS = \
54         htools \
55         htools/Ganeti \
56         htools/Ganeti/HTools \
57         htools/Ganeti/HTools/Program
58
59 DIRS = \
60         autotools \
61         daemons \
62         devel \
63         doc \
64         doc/examples \
65         doc/examples/hooks \
66         doc/examples/gnt-debug \
67         $(HTOOLS_DIRS) \
68         lib \
69         lib/client \
70         lib/build \
71         lib/confd \
72         lib/http \
73         lib/hypervisor \
74         lib/impexpd \
75         lib/masterd \
76         lib/rapi \
77         lib/server \
78         lib/tools \
79         lib/utils \
80         lib/watcher \
81         man \
82         qa \
83         test \
84         test/data \
85         test/data/ovfdata \
86         test/data/ovfdata/other \
87         tools
88
89 BUILDTIME_DIR_AUTOCREATE = \
90         scripts \
91         $(APIDOC_DIR) \
92         $(APIDOC_PY_DIR) \
93         $(APIDOC_HS_DIR) \
94         $(APIDOC_HS_DIR)/Ganeti $(APIDOC_HS_DIR)/Ganeti/HTools \
95         $(APIDOC_HS_DIR)/Ganeti/HTools/Program \
96         $(COVERAGE_DIR) \
97         $(COVERAGE_PY_DIR) \
98         $(COVERAGE_HS_DIR) \
99         .hpc
100
101 BUILDTIME_DIRS = \
102         $(BUILDTIME_DIR_AUTOCREATE) \
103         doc/html
104
105 DIRCHECK_EXCLUDE = \
106         $(BUILDTIME_DIRS) \
107         ganeti-[0-9]*.[0-9]*.[0-9]* \
108         doc/html/_*
109
110 all_dirfiles = $(addsuffix /.dir,$(DIRS) $(BUILDTIME_DIR_AUTOCREATE))
111
112 # some helper vars
113 COVERAGE_DIR = doc/coverage
114 COVERAGE_PY_DIR = $(COVERAGE_DIR)/py
115 COVERAGE_HS_DIR = $(COVERAGE_DIR)/hs
116 APIDOC_DIR = doc/api
117 APIDOC_PY_DIR = $(APIDOC_DIR)/py
118 APIDOC_HS_DIR = $(APIDOC_DIR)/hs
119
120 MAINTAINERCLEANFILES = \
121         $(docpng) \
122         $(maninput) \
123         doc/install-quick.rst \
124         doc/news.rst \
125         doc/upgrade.rst \
126         vcs-version
127
128 maintainer-clean-local:
129         rm -rf $(BUILDTIME_DIRS)
130
131 CLEANFILES = \
132         $(addsuffix /*.py[co],$(DIRS)) \
133         $(addsuffix /*.hi,$(HTOOLS_DIRS)) \
134         $(addsuffix /*.o,$(HTOOLS_DIRS)) \
135         $(all_dirfiles) \
136         $(PYTHON_BOOTSTRAP) \
137         epydoc.conf \
138         autotools/replace_vars.sed \
139         daemons/daemon-util \
140         daemons/ganeti-cleaner \
141         devel/upload \
142         doc/examples/bash_completion \
143         doc/examples/ganeti.initd \
144         doc/examples/ganeti-kvm-poweroff.initd \
145         doc/examples/ganeti.cron \
146         doc/examples/gnt-config-backup \
147         doc/examples/hooks/ipsec \
148         lib/_generated_rpc.py \
149         $(man_MANS) \
150         $(manhtml) \
151         tools/kvm-ifup \
152         stamp-srclinks \
153         $(nodist_pkgpython_PYTHON) \
154         $(HS_ALL_PROGS) $(HS_BUILT_SRCS) \
155         .hpc/*.mix htools/*.tix \
156         doc/hs-lint.html
157
158 # BUILT_SOURCES should only be used as a dependency on phony targets. Otherwise
159 # it'll cause the target to rebuild every time.
160 BUILT_SOURCES = \
161         ganeti \
162         stamp-srclinks \
163         $(all_dirfiles) \
164         $(PYTHON_BOOTSTRAP) \
165         $(BUILT_PYTHON_SOURCES)
166
167 BUILT_PYTHON_SOURCES = \
168         lib/_autoconf.py \
169         lib/_vcsversion.py \
170         lib/_generated_rpc.py
171
172 nodist_pkgpython_PYTHON = \
173         $(BUILT_PYTHON_SOURCES)
174
175 noinst_PYTHON = \
176         lib/build/__init__.py \
177         lib/build/rpc_definitions.py \
178         lib/build/sphinx_ext.py
179
180 pkgpython_PYTHON = \
181         lib/__init__.py \
182         lib/asyncnotifier.py \
183         lib/backend.py \
184         lib/bdev.py \
185         lib/bootstrap.py \
186         lib/cli.py \
187         lib/cmdlib.py \
188         lib/compat.py \
189         lib/config.py \
190         lib/constants.py \
191         lib/daemon.py \
192         lib/errors.py \
193         lib/ht.py \
194         lib/jqueue.py \
195         lib/jstore.py \
196         lib/locking.py \
197         lib/luxi.py \
198         lib/mcpu.py \
199         lib/netutils.py \
200         lib/objects.py \
201         lib/opcodes.py \
202         lib/ovf.py \
203         lib/qlang.py \
204         lib/query.py \
205         lib/rpc.py \
206         lib/runtime.py \
207         lib/serializer.py \
208         lib/ssconf.py \
209         lib/ssh.py \
210         lib/storage.py \
211         lib/uidpool.py \
212         lib/workerpool.py
213
214 client_PYTHON = \
215         lib/client/__init__.py \
216         lib/client/gnt_backup.py \
217         lib/client/gnt_cluster.py \
218         lib/client/gnt_debug.py \
219         lib/client/gnt_group.py \
220         lib/client/gnt_instance.py \
221         lib/client/gnt_job.py \
222         lib/client/gnt_node.py \
223         lib/client/gnt_os.py
224
225 hypervisor_PYTHON = \
226         lib/hypervisor/__init__.py \
227         lib/hypervisor/hv_base.py \
228         lib/hypervisor/hv_chroot.py \
229         lib/hypervisor/hv_fake.py \
230         lib/hypervisor/hv_kvm.py \
231         lib/hypervisor/hv_lxc.py \
232         lib/hypervisor/hv_xen.py
233
234 rapi_PYTHON = \
235         lib/rapi/__init__.py \
236         lib/rapi/baserlib.py \
237         lib/rapi/client.py \
238         lib/rapi/client_utils.py \
239         lib/rapi/connector.py \
240         lib/rapi/rlib2.py
241
242 http_PYTHON = \
243         lib/http/__init__.py \
244         lib/http/auth.py \
245         lib/http/client.py \
246         lib/http/server.py
247
248 confd_PYTHON = \
249         lib/confd/__init__.py \
250         lib/confd/client.py \
251         lib/confd/querylib.py \
252         lib/confd/server.py
253
254 masterd_PYTHON = \
255         lib/masterd/__init__.py \
256         lib/masterd/instance.py
257
258 impexpd_PYTHON = \
259         lib/impexpd/__init__.py
260
261 watcher_PYTHON = \
262         lib/watcher/__init__.py \
263         lib/watcher/nodemaint.py \
264         lib/watcher/state.py
265
266 server_PYTHON = \
267         lib/server/__init__.py \
268         lib/server/confd.py \
269         lib/server/masterd.py \
270         lib/server/noded.py \
271         lib/server/rapi.py
272
273 pytools_PYTHON = \
274         lib/tools/__init__.py \
275         lib/tools/ensure_dirs.py
276
277 utils_PYTHON = \
278         lib/utils/__init__.py \
279         lib/utils/algo.py \
280         lib/utils/filelock.py \
281         lib/utils/hash.py \
282         lib/utils/io.py \
283         lib/utils/log.py \
284         lib/utils/mlock.py \
285         lib/utils/nodesetup.py \
286         lib/utils/process.py \
287         lib/utils/retry.py \
288         lib/utils/text.py \
289         lib/utils/wrapper.py \
290         lib/utils/x509.py
291
292 docrst = \
293         doc/admin.rst \
294         doc/design-2.0.rst \
295         doc/design-2.1.rst \
296         doc/design-2.2.rst \
297         doc/design-2.3.rst \
298         doc/design-htools-2.3.rst \
299         doc/design-2.4.rst \
300         doc/design-2.5.rst \
301         doc/design-draft.rst \
302         doc/design-oob.rst \
303         doc/design-cpu-pinning.rst \
304         doc/design-query2.rst \
305         doc/design-x509-ca.rst \
306         doc/design-http-server.rst \
307         doc/design-impexp2.rst \
308         doc/design-lu-generated-jobs.rst \
309         doc/design-multi-reloc.rst \
310         doc/design-network.rst \
311         doc/design-chained-jobs.rst \
312         doc/design-ovf-support.rst \
313         doc/design-resource-model.rst \
314         doc/cluster-merge.rst \
315         doc/design-shared-storage.rst \
316         doc/design-node-state-cache.rst \
317         doc/design-virtual-clusters.rst \
318         doc/devnotes.rst \
319         doc/glossary.rst \
320         doc/hooks.rst \
321         doc/iallocator.rst \
322         doc/index.rst \
323         doc/install-quick.rst \
324         doc/install.rst \
325         doc/locking.rst \
326         doc/move-instance.rst \
327         doc/news.rst \
328         doc/rapi.rst \
329         doc/security.rst \
330         doc/upgrade.rst \
331         doc/walkthrough.rst
332
333 HS_PROGS = htools/htools
334 HS_BIN_ROLES = hbal hscan hspace
335
336 HS_ALL_PROGS = $(HS_PROGS) htools/test
337 HS_PROG_SRCS = $(patsubst %,%.hs,$(HS_ALL_PROGS))
338 # we don't add -Werror by default
339 HFLAGS = -O -Wall -fwarn-monomorphism-restriction -fwarn-tabs -ihtools
340 # extra flags that can be overriden on the command line
341 HEXTRA =
342 # exclude options for coverage reports
343 HPCEXCL = --exclude Main \
344         --exclude Ganeti.Constants \
345         --exclude Ganeti.THH \
346         --exclude Ganeti.HTools.QC \
347         --exclude Ganeti.HTools.QCHelper \
348         --exclude Ganeti.HTools.Version
349
350 HS_LIB_SRCS = \
351         htools/Ganeti/HTools/CLI.hs \
352         htools/Ganeti/HTools/Cluster.hs \
353         htools/Ganeti/HTools/Compat.hs \
354         htools/Ganeti/HTools/Container.hs \
355         htools/Ganeti/HTools/ExtLoader.hs \
356         htools/Ganeti/HTools/Group.hs \
357         htools/Ganeti/HTools/IAlloc.hs \
358         htools/Ganeti/HTools/Instance.hs \
359         htools/Ganeti/HTools/JSON.hs \
360         htools/Ganeti/HTools/Loader.hs \
361         htools/Ganeti/HTools/Luxi.hs \
362         htools/Ganeti/HTools/Node.hs \
363         htools/Ganeti/HTools/PeerMap.hs \
364         htools/Ganeti/HTools/QC.hs \
365         htools/Ganeti/HTools/QCHelper.hs \
366         htools/Ganeti/HTools/Rapi.hs \
367         htools/Ganeti/HTools/Simu.hs \
368         htools/Ganeti/HTools/Text.hs \
369         htools/Ganeti/HTools/Types.hs \
370         htools/Ganeti/HTools/Utils.hs \
371         htools/Ganeti/HTools/Program/Hail.hs \
372         htools/Ganeti/HTools/Program/Hbal.hs \
373         htools/Ganeti/HTools/Program/Hscan.hs \
374         htools/Ganeti/HTools/Program/Hspace.hs \
375         htools/Ganeti/Jobs.hs \
376         htools/Ganeti/Luxi.hs \
377         htools/Ganeti/OpCodes.hs \
378         htools/Ganeti/THH.hs
379
380 HS_BUILT_SRCS = htools/Ganeti/HTools/Version.hs htools/Ganeti/Constants.hs
381 HS_BUILT_SRCS_IN = $(patsubst %,%.in,$(HS_BUILT_SRCS))
382
383 $(RUN_IN_TEMPDIR): | $(all_dirfiles)
384
385 # Note: we use here an order-only prerequisite, as the contents of
386 # _autoconf.py are not actually influencing the html build output: it
387 # has to exist in order for the sphinx module to be loaded
388 # successfully, but we certainly don't want the docs to be rebuilt if
389 # it changes
390 doc/html/index.html: $(docrst) $(docpng) doc/conf.py configure.ac \
391         $(RUN_IN_TEMPDIR) lib/build/sphinx_ext.py lib/opcodes.py lib/ht.py \
392         | $(BUILT_PYTHON_SOURCES)
393         @test -n "$(SPHINX)" || \
394             { echo 'sphinx-build' not found during configure; exit 1; }
395         @mkdir_p@ $(dir $@)
396         PYTHONPATH=. $(RUN_IN_TEMPDIR) $(SPHINX) -q -W -b html \
397             -d . \
398             -D version="$(VERSION_MAJOR).$(VERSION_MINOR)" \
399             -D release="$(PACKAGE_VERSION)" \
400             $(abs_top_srcdir)/doc $(CURDIR)/doc/html
401         rm -f doc/html/.buildinfo doc/html/objects.inv
402         touch $@
403
404 doc/html: doc/html/index.html
405
406 doc/install-quick.rst: INSTALL
407 doc/news.rst: NEWS
408 doc/upgrade.rst: UPGRADE
409
410 doc/install-quick.rst doc/news.rst doc/upgrade.rst:
411         set -e; \
412         { echo '.. This file is automatically updated at build time from $<.'; \
413           echo '.. Do not edit.'; \
414           echo; \
415           cat $<; \
416         } > $@
417
418 docdot = \
419         doc/arch-2.0.dot \
420         doc/design-2.1-lock-acquire.dot \
421         doc/design-2.1-lock-release.dot
422
423 docpng = $(patsubst %.dot,%.png,$(docdot))
424
425 # Things to build but not to install (add it to EXTRA_DIST if it should be
426 # distributed)
427 noinst_DATA = \
428         devel/upload \
429         doc/html \
430         doc/examples/bash_completion \
431         doc/examples/ganeti.cron \
432         doc/examples/ganeti.initd \
433         doc/examples/ganeti-kvm-poweroff.initd \
434         doc/examples/gnt-config-backup \
435         doc/examples/hooks/ipsec \
436         $(manhtml)
437
438 gnt_scripts = \
439         scripts/gnt-backup \
440         scripts/gnt-cluster \
441         scripts/gnt-debug \
442         scripts/gnt-group \
443         scripts/gnt-instance \
444         scripts/gnt-job \
445         scripts/gnt-node \
446         scripts/gnt-os
447
448 PYTHON_BOOTSTRAP_SBIN = \
449         daemons/ganeti-confd \
450         daemons/ganeti-masterd \
451         daemons/ganeti-noded \
452         daemons/ganeti-watcher \
453         daemons/ganeti-rapi \
454         scripts/gnt-backup \
455         scripts/gnt-cluster \
456         scripts/gnt-debug \
457         scripts/gnt-group \
458         scripts/gnt-instance \
459         scripts/gnt-job \
460         scripts/gnt-node \
461         scripts/gnt-os
462
463 PYTHON_BOOTSTRAP = \
464         $(PYTHON_BOOTSTRAP_SBIN) \
465         tools/ensure-dirs
466
467 qa_scripts = \
468         qa/ganeti-qa.py \
469         qa/qa_cluster.py \
470         qa/qa_config.py \
471         qa/qa_daemon.py \
472         qa/qa_env.py \
473         qa/qa_error.py \
474         qa/qa_group.py \
475         qa/qa_instance.py \
476         qa/qa_node.py \
477         qa/qa_os.py \
478         qa/qa_rapi.py \
479         qa/qa_tags.py \
480         qa/qa_utils.py
481
482 bin_SCRIPTS =
483 if WANT_HTOOLS
484 bin_SCRIPTS += $(filter-out htools/hail,$(HS_PROGS))
485 install-exec-hook:
486         @mkdir_p@ $(DESTDIR)$(iallocatorsdir)
487 # FIXME: this is a hardcoded logic, instead of auto-resolving
488         $(LN_S) -f ../../../bin/htools \
489                    $(DESTDIR)$(iallocatorsdir)/hail
490         for role in $(HS_BIN_ROLES); do \
491                 $(LN_S) -f htools \
492                            $(DESTDIR)$(bindir)/$$role ; \
493         done
494 endif
495
496 $(HS_ALL_PROGS): %: %.hs $(HS_LIB_SRCS) $(HS_BUILT_SRCS) Makefile
497         @if [ -z "$(HTOOLS)" ]; then \
498           echo "Error: htools compilation disabled at configure time" 1>&2 ;\
499           exit 1; \
500         fi
501         @BINARY=$(@:htools/%=%); \
502         if [ "$BINARY" = "test" ] && [ -z "$(GHC_PKG_QUICKCHECK)" ]; then \
503           echo "Error: cannot run unittests without the QuickCheck library (see devnotes.rst)" 1>&2; \
504           exit 1; \
505         fi
506         BINARY=$(@:htools/%=%); $(GHC) --make \
507           $(HFLAGS) \
508           $(HTOOLS_NOCURL) $(HTOOLS_PARALLEL3) \
509           -osuf $$BINARY.o -hisuf $$BINARY.hi \
510           $(HEXTRA) $@
511
512 # for the htools/test binary, we need to enable profiling/coverage
513 htools/test: HEXTRA=-fhpc -Wwarn -fno-warn-missing-signatures \
514         -fno-warn-monomorphism-restriction -fno-warn-orphans \
515         -fno-warn-missing-methods -fno-warn-unused-imports
516
517 dist_sbin_SCRIPTS = \
518         tools/ganeti-listrunner
519
520 nodist_sbin_SCRIPTS = \
521         $(PYTHON_BOOTSTRAP_SBIN) \
522         daemons/ganeti-cleaner
523
524 dist_tools_PYTHON = \
525         tools/burnin \
526         tools/cfgshell \
527         tools/cfgupgrade \
528         tools/cfgupgrade12 \
529         tools/cluster-merge \
530         tools/lvmstrap \
531         tools/move-instance \
532         tools/ovfconverter \
533         tools/setup-ssh \
534         tools/sanitize-config
535
536 dist_tools_SCRIPTS = \
537         $(dist_tools_PYTHON) \
538         tools/kvm-console-wrapper \
539         tools/xm-console-wrapper
540
541 pkglib_python_scripts = \
542         daemons/import-export \
543         tools/check-cert-expired
544
545 nodist_pkglib_python_scripts = \
546         tools/ensure-dirs
547
548 pkglib_SCRIPTS = \
549         daemons/daemon-util \
550         tools/kvm-ifup \
551         $(pkglib_python_scripts)
552
553 nodist_pkglib_SCRIPTS = \
554         $(nodist_pkglib_python_scripts)
555
556 EXTRA_DIST = \
557         NEWS \
558         UPGRADE \
559         epydoc.conf.in \
560         pylintrc \
561         autotools/build-bash-completion \
562         autotools/build-rpc \
563         autotools/check-python-code \
564         autotools/check-imports \
565         autotools/check-man \
566         autotools/check-news \
567         autotools/check-tar \
568         autotools/check-version \
569         autotools/convert-constants \
570         autotools/docpp \
571         autotools/gen-coverage \
572         autotools/testrunner \
573         $(RUN_IN_TEMPDIR) \
574         daemons/daemon-util.in \
575         daemons/ganeti-cleaner.in \
576         $(pkglib_python_scripts) \
577         devel/upload.in \
578         tools/kvm-ifup.in \
579         $(docdot) \
580         $(docpng) \
581         $(docrst) \
582         doc/conf.py \
583         doc/html \
584         doc/examples/ganeti.initd.in \
585         doc/examples/ganeti-kvm-poweroff.initd.in \
586         doc/examples/ganeti.cron.in \
587         doc/examples/gnt-config-backup.in \
588         doc/examples/ganeti.default \
589         doc/examples/ganeti.default-debug \
590         doc/examples/hooks/ethers \
591         doc/examples/hooks/ipsec.in \
592         doc/examples/gnt-debug/README \
593         doc/examples/gnt-debug/delay0.json \
594         doc/examples/gnt-debug/delay50.json \
595         test/testutils.py \
596         test/mocks.py \
597         $(dist_TESTS) \
598         $(TEST_FILES) \
599         man/footer.rst \
600         $(manrst) \
601         $(maninput) \
602         qa/qa-sample.json \
603         $(qa_scripts) \
604         $(HS_LIB_SRCS) $(HS_BUILT_SRCS_IN) \
605         $(HS_PROG_SRCS)
606
607 man_MANS = \
608         man/ganeti.7 \
609         man/ganeti-cleaner.8 \
610         man/ganeti-confd.8 \
611         man/ganeti-listrunner.8 \
612         man/ganeti-masterd.8 \
613         man/ganeti-noded.8 \
614         man/ganeti-os-interface.7 \
615         man/ganeti-rapi.8 \
616         man/ganeti-watcher.8 \
617         man/gnt-backup.8 \
618         man/gnt-cluster.8 \
619         man/gnt-debug.8 \
620         man/gnt-group.8 \
621         man/gnt-instance.8 \
622         man/gnt-job.8 \
623         man/gnt-node.8 \
624         man/gnt-os.8 \
625         man/hail.1 \
626         man/hbal.1 \
627         man/hscan.1 \
628         man/hspace.1 \
629         man/htools.1
630
631 manrst = $(patsubst %.1,%.rst,$(patsubst %.7,%.rst,$(patsubst %.8,%.rst,$(man_MANS))))
632 manhtml = $(patsubst %.rst,%.html,$(manrst))
633 mangen = $(patsubst %.rst,%.gen,$(manrst))
634 maninput = \
635         $(patsubst %.1,%.1.in,$(patsubst %.7,%.7.in,$(patsubst %.8,%.8.in,$(man_MANS)))) \
636         $(patsubst %.html,%.html.in,$(manhtml)) \
637         man/footer.man man/footer.html $(mangen)
638
639 TEST_FILES = \
640         test/data/bdev-drbd-8.0.txt \
641         test/data/bdev-drbd-8.3.txt \
642         test/data/bdev-drbd-disk.txt \
643         test/data/bdev-drbd-net-ip4.txt \
644         test/data/bdev-drbd-net-ip6.txt \
645         test/data/cert1.pem \
646         test/data/ip-addr-show-dummy0.txt \
647         test/data/ip-addr-show-lo-ipv4.txt \
648         test/data/ip-addr-show-lo-ipv6.txt \
649         test/data/ip-addr-show-lo-oneline-ipv4.txt \
650         test/data/ip-addr-show-lo-oneline-ipv6.txt \
651         test/data/ip-addr-show-lo-oneline.txt \
652         test/data/ip-addr-show-lo.txt \
653         test/data/proc_drbd8.txt \
654         test/data/proc_drbd80-emptyline.txt \
655         test/data/proc_drbd83.txt \
656         test/data/proc_drbd83_sync.txt \
657         test/data/proc_drbd83_sync_krnl2.6.39.txt \
658         test/data/sys_drbd_usermode_helper.txt \
659         test/data/ovfdata/compr_disk.vmdk.gz \
660         test/data/ovfdata/config.ini \
661         test/data/ovfdata/corrupted_resources.ovf \
662         test/data/ovfdata/empty.ini \
663         test/data/ovfdata/empty.ovf \
664         test/data/ovfdata/ganeti.mf \
665         test/data/ovfdata/ganeti.ovf \
666         test/data/ovfdata/gzip_disk.ovf \
667         test/data/ovfdata/new_disk.vmdk \
668         test/data/ovfdata/no_disk.ini \
669         test/data/ovfdata/no_disk_in_ref.ovf \
670         test/data/ovfdata/no_os.ini \
671         test/data/ovfdata/no_ovf.ova \
672         test/data/ovfdata/ova.ova \
673         test/data/ovfdata/second_disk.vmdk \
674         test/data/ovfdata/rawdisk.raw \
675         test/data/ovfdata/unsafe_path.ini \
676         test/data/ovfdata/virtualbox.ovf \
677         test/data/ovfdata/wrong_extension.ovd \
678         test/data/ovfdata/wrong_config.ini \
679         test/data/ovfdata/wrong_manifest.mf \
680         test/data/ovfdata/wrong_manifest.ovf \
681         test/data/ovfdata/wrong_ova.ova \
682         test/data/ovfdata/wrong_xml.ovf \
683         test/data/ovfdata/other/rawdisk.raw \
684         test/import-export_unittest-helper
685
686 python_tests = \
687         test/ganeti.asyncnotifier_unittest.py \
688         test/ganeti.backend_unittest.py \
689         test/ganeti.bdev_unittest.py \
690         test/ganeti.cli_unittest.py \
691         test/ganeti.client.gnt_cluster_unittest.py \
692         test/ganeti.client.gnt_instance_unittest.py \
693         test/ganeti.daemon_unittest.py \
694         test/ganeti.cmdlib_unittest.py \
695         test/ganeti.compat_unittest.py \
696         test/ganeti.confd.client_unittest.py \
697         test/ganeti.config_unittest.py \
698         test/ganeti.constants_unittest.py \
699         test/ganeti.errors_unittest.py \
700         test/ganeti.hooks_unittest.py \
701         test/ganeti.ht_unittest.py \
702         test/ganeti.http_unittest.py \
703         test/ganeti.hypervisor_unittest.py \
704         test/ganeti.hypervisor.hv_chroot_unittest.py \
705         test/ganeti.hypervisor.hv_fake_unittest.py \
706         test/ganeti.hypervisor.hv_kvm_unittest.py \
707         test/ganeti.hypervisor.hv_lxc_unittest.py \
708         test/ganeti.hypervisor.hv_xen_unittest.py \
709         test/ganeti.impexpd_unittest.py \
710         test/ganeti.jqueue_unittest.py \
711         test/ganeti.locking_unittest.py \
712         test/ganeti.luxi_unittest.py \
713         test/ganeti.masterd.instance_unittest.py \
714         test/ganeti.mcpu_unittest.py \
715         test/ganeti.netutils_unittest.py \
716         test/ganeti.objects_unittest.py \
717         test/ganeti.opcodes_unittest.py \
718         test/ganeti.ovf_unittest.py \
719         test/ganeti.qlang_unittest.py \
720         test/ganeti.query_unittest.py \
721         test/ganeti.rapi.baserlib_unittest.py \
722         test/ganeti.rapi.client_unittest.py \
723         test/ganeti.rapi.resources_unittest.py \
724         test/ganeti.rapi.rlib2_unittest.py \
725         test/ganeti.rpc_unittest.py \
726         test/ganeti.runtime_unittest.py \
727         test/ganeti.serializer_unittest.py \
728         test/ganeti.ssh_unittest.py \
729         test/ganeti.tools.ensure_dirs_unittest.py \
730         test/ganeti.uidpool_unittest.py \
731         test/ganeti.utils.algo_unittest.py \
732         test/ganeti.utils.filelock_unittest.py \
733         test/ganeti.utils.hash_unittest.py \
734         test/ganeti.utils.io_unittest.py \
735         test/ganeti.utils.log_unittest.py \
736         test/ganeti.utils.mlock_unittest.py \
737         test/ganeti.utils.nodesetup_unittest.py \
738         test/ganeti.utils.process_unittest.py \
739         test/ganeti.utils.retry_unittest.py \
740         test/ganeti.utils.text_unittest.py \
741         test/ganeti.utils.wrapper_unittest.py \
742         test/ganeti.utils.x509_unittest.py \
743         test/ganeti.utils_unittest.py \
744         test/ganeti.workerpool_unittest.py \
745         test/cfgupgrade_unittest.py \
746         test/docs_unittest.py \
747         test/pycurl_reset_unittest.py \
748         test/tempfile_fork_unittest.py
749
750 haskell_tests = htools/test
751
752 dist_TESTS = \
753         test/check-cert-expired_unittest.bash \
754         test/daemon-util_unittest.bash \
755         test/ganeti-cleaner_unittest.bash \
756         test/import-export_unittest.bash \
757         $(python_tests)
758
759 nodist_TESTS =
760 if WANT_HTOOLSTESTS
761 nodist_TESTS += $(haskell_tests)
762 endif
763
764 TESTS = $(dist_TESTS) $(nodist_TESTS)
765
766 # Environment for all tests
767 PLAIN_TESTS_ENVIRONMENT = \
768         PYTHONPATH=. TOP_SRCDIR=$(abs_top_srcdir) PYTHON=$(PYTHON) $(RUN_IN_TEMPDIR)
769
770 # Environment for tests run by automake
771 TESTS_ENVIRONMENT = \
772         $(PLAIN_TESTS_ENVIRONMENT) $(abs_top_srcdir)/autotools/testrunner
773
774 all_python_code = \
775         $(dist_sbin_SCRIPTS) \
776         $(dist_tools_PYTHON) \
777         $(pkglib_python_scripts) \
778         $(nodist_pkglib_python_scripts) \
779         $(python_tests) \
780         $(pkgpython_PYTHON) \
781         $(client_PYTHON) \
782         $(hypervisor_PYTHON) \
783         $(rapi_PYTHON) \
784         $(server_PYTHON) \
785         $(pytools_PYTHON) \
786         $(http_PYTHON) \
787         $(confd_PYTHON) \
788         $(masterd_PYTHON) \
789         $(impexpd_PYTHON) \
790         $(utils_PYTHON) \
791         $(watcher_PYTHON) \
792         $(noinst_PYTHON) \
793         $(qa_scripts)
794
795 srclink_files = \
796         man/footer.rst \
797         test/check-cert-expired_unittest.bash \
798         test/daemon-util_unittest.bash \
799         test/ganeti-cleaner_unittest.bash \
800         test/import-export_unittest.bash \
801         $(all_python_code) \
802         $(HS_LIB_SRCS) $(HS_PROG_SRCS)
803
804 check_python_code = \
805         $(BUILD_BASH_COMPLETION) \
806         $(CHECK_IMPORTS) \
807         $(DOCPP) \
808         $(all_python_code)
809
810 lint_python_code = \
811         ganeti \
812         ganeti/http/server.py \
813         $(dist_sbin_SCRIPTS) \
814         $(dist_tools_PYTHON) \
815         $(pkglib_python_scripts) \
816         $(BUILD_BASH_COMPLETION) \
817         $(CHECK_IMPORTS) \
818         $(DOCPP) \
819         $(PYTHON_BOOTSTRAP)
820
821 standalone_python_modules = \
822         lib/rapi/client.py \
823         tools/ganeti-listrunner
824
825 pep8_python_code = \
826         ganeti \
827         ganeti/http/server.py \
828         $(dist_sbin_SCRIPTS) \
829         $(dist_tools_PYTHON) \
830         $(pkglib_python_scripts) \
831         $(BUILD_BASH_COMPLETION) \
832         $(DOCPP) \
833         $(PYTHON_BOOTSTRAP) \
834         qa
835
836 test/daemon-util_unittest.bash: daemons/daemon-util
837
838 test/ganeti-cleaner_unittest.bash: daemons/ganeti-cleaner
839
840 tools/kvm-ifup: tools/kvm-ifup.in $(REPLACE_VARS_SED)
841         sed -f $(REPLACE_VARS_SED) < $< > $@
842         chmod +x $@
843
844 devel/upload: devel/upload.in $(REPLACE_VARS_SED)
845         sed -f $(REPLACE_VARS_SED) < $< > $@
846         chmod u+x $@
847
848 daemons/%: daemons/%.in $(REPLACE_VARS_SED)
849         sed -f $(REPLACE_VARS_SED) < $< > $@
850         chmod +x $@
851
852 doc/examples/%: doc/examples/%.in $(REPLACE_VARS_SED)
853         sed -f $(REPLACE_VARS_SED) < $< > $@
854
855 doc/examples/hooks/%: doc/examples/hooks/%.in $(REPLACE_VARS_SED)
856         sed -f $(REPLACE_VARS_SED) < $< > $@
857
858 doc/examples/bash_completion: $(BUILD_BASH_COMPLETION) $(RUN_IN_TEMPDIR) \
859         lib/cli.py $(gnt_scripts) $(client_PYTHON) tools/burnin
860         PYTHONPATH=. $(RUN_IN_TEMPDIR) $(CURDIR)/$(BUILD_BASH_COMPLETION) > $@
861
862 doc/%.png: doc/%.dot
863         @test -n "$(DOT)" || { echo 'dot' not found during configure; exit 1; }
864         $(DOT) -Tpng -o $@ $<
865
866 man/footer.man: man/footer.rst
867         @test -n "$(PANDOC)" || \
868           { echo 'pandoc' not found during configure; exit 1; }
869         $(PANDOC) -f rst -t man -o $@ $<
870
871 man/footer.html: man/footer.rst
872         @test -n "$(PANDOC)" || \
873           { echo 'pandoc' not found during configure; exit 1; }
874         $(PANDOC) -f rst -t html -o $@ $<
875
876 man/%.gen: man/%.rst lib/query.py lib/build/sphinx_ext.py
877         PYTHONPATH=. $(RUN_IN_TEMPDIR) $(CURDIR)/$(DOCPP) < $< > $@
878
879 man/%.7.in man/%.8.in man/%.1.in: man/%.gen man/footer.man
880         @test -n "$(PANDOC)" || \
881           { echo 'pandoc' not found during configure; exit 1; }
882         set -o pipefail ; \
883         $(PANDOC) -s -f rst -t man -A man/footer.man $< | \
884           sed -e 's/\\@/@/g' > $@
885         if test -n "$(MAN_HAS_WARNINGS)"; then $(CHECK_MAN) $@; fi
886
887 man/%.html.in: man/%.gen man/footer.html
888         @test -n "$(PANDOC)" || \
889           { echo 'pandoc' not found during configure; exit 1; }
890         set -o pipefail ; \
891         $(PANDOC) -s -f rst -t html -A man/footer.html $< | \
892           sed -e 's/\\@/@/g' > $@
893
894 man/%.1: man/%.1.in $(REPLACE_VARS_SED)
895         sed -f $(REPLACE_VARS_SED) < $< > $@
896
897 man/%.7: man/%.7.in $(REPLACE_VARS_SED)
898         sed -f $(REPLACE_VARS_SED) < $< > $@
899
900 man/%.8: man/%.8.in $(REPLACE_VARS_SED)
901         sed -f $(REPLACE_VARS_SED) < $< > $@
902
903 man/%.html: man/%.html.in $(REPLACE_VARS_SED)
904         sed -f $(REPLACE_VARS_SED) < $< > $@
905
906 epydoc.conf: epydoc.conf.in Makefile
907         sed -e 's#@MODULES@#$(strip $(lint_python_code))#g' < $< > $@
908
909 vcs-version:
910         if test -d .git; then \
911           git describe > $@; \
912         elif test ! -f $@ ; then \
913           echo "Cannot auto-generate $@ file"; exit 1; \
914         fi
915
916 .PHONY: regen-vcs-version
917 regen-vcs-version:
918         set -e; \
919         cd $(srcdir); \
920         if test -d .git; then \
921           rm -f vcs-version; \
922           $(MAKE) vcs-version; \
923         fi
924
925 htools/Ganeti/HTools/Version.hs: htools/Ganeti/HTools/Version.hs.in vcs-version
926         set -e; \
927         VCSVER=`cat $(abs_top_srcdir)/vcs-version`; \
928         sed -e "s/%ver%/$$VCSVER/" < $< > $@
929
930 htools/Ganeti/Constants.hs: htools/Ganeti/Constants.hs.in \
931         lib/constants.py lib/_autoconf.py $(CONVERT_CONSTANTS) \
932         | lib/_vcsversion.py
933         set -e; \
934         { cat $< ; PYTHONPATH=. $(CONVERT_CONSTANTS); } > $@
935
936 lib/_autoconf.py: Makefile | lib/.dir
937         set -e; \
938         { echo '# This file is automatically generated, do not edit!'; \
939           echo '#'; \
940           echo ''; \
941           echo '"""Build-time configuration for Ganeti.'; \
942           echo '';\
943           echo 'This file is autogenerated by the build process.'; \
944           echo 'For any changes you need to re-run ./configure (and'; \
945           echo 'not edit by hand).'; \
946           echo ''; \
947           echo '"""'; \
948           echo ''; \
949           echo '# pylint: disable=C0301,C0324'; \
950           echo '# because this is autogenerated, we do not want'; \
951           echo '# style warnings' ; \
952           echo ''; \
953           echo "PACKAGE_VERSION = '$(PACKAGE_VERSION)'"; \
954           echo "VERSION_MAJOR = '$(VERSION_MAJOR)'"; \
955           echo "VERSION_MINOR = '$(VERSION_MINOR)'"; \
956           echo "VERSION_REVISION = '$(VERSION_REVISION)'"; \
957           echo "VERSION_SUFFIX = '$(VERSION_SUFFIX)'"; \
958           echo "VERSION_FULL = '$(VERSION_FULL)'"; \
959           echo "LOCALSTATEDIR = '$(localstatedir)'"; \
960           echo "SYSCONFDIR = '$(sysconfdir)'"; \
961           echo "SSH_CONFIG_DIR = '$(SSH_CONFIG_DIR)'"; \
962           echo "EXPORT_DIR = '$(EXPORT_DIR)'"; \
963           echo "OS_SEARCH_PATH = [$(OS_SEARCH_PATH)]"; \
964           echo "XEN_BOOTLOADER = '$(XEN_BOOTLOADER)'"; \
965           echo "XEN_KERNEL = '$(XEN_KERNEL)'"; \
966           echo "XEN_INITRD = '$(XEN_INITRD)'"; \
967           echo "FILE_STORAGE_DIR = '$(FILE_STORAGE_DIR)'"; \
968           echo "ENABLE_FILE_STORAGE = $(ENABLE_FILE_STORAGE)"; \
969           echo "SHARED_FILE_STORAGE_DIR = '$(SHARED_FILE_STORAGE_DIR)'"; \
970           echo "ENABLE_SHARED_FILE_STORAGE = $(ENABLE_SHARED_FILE_STORAGE)"; \
971           echo "IALLOCATOR_SEARCH_PATH = [$(IALLOCATOR_SEARCH_PATH)]"; \
972           echo "KVM_PATH = '$(KVM_PATH)'"; \
973           echo "IP_PATH = '$(IP_PATH)'"; \
974           echo "SOCAT_PATH = '$(SOCAT)'"; \
975           echo "SOCAT_USE_ESCAPE = $(SOCAT_USE_ESCAPE)"; \
976           echo "SOCAT_USE_COMPRESS = $(SOCAT_USE_COMPRESS)"; \
977           echo "LVM_STRIPECOUNT = $(LVM_STRIPECOUNT)"; \
978           echo "TOOLSDIR = '$(toolsdir)'"; \
979           echo "GNT_SCRIPTS = [$(foreach i,$(notdir $(gnt_scripts)),'$(i)',)]"; \
980           echo "PKGLIBDIR = '$(pkglibdir)'"; \
981           echo "DRBD_BARRIERS = $(DRBD_BARRIERS)"; \
982           echo "SYSLOG_USAGE = '$(SYSLOG_USAGE)'"; \
983           echo "DAEMONS_GROUP = '$(DAEMONS_GROUP)'"; \
984           echo "ADMIN_GROUP = '$(ADMIN_GROUP)'"; \
985           echo "MASTERD_USER = '$(MASTERD_USER)'"; \
986           echo "MASTERD_GROUP = '$(MASTERD_GROUP)'"; \
987           echo "RAPI_USER = '$(RAPI_USER)'"; \
988           echo "RAPI_GROUP = '$(RAPI_GROUP)'"; \
989           echo "CONFD_USER = '$(CONFD_USER)'"; \
990           echo "CONFD_GROUP = '$(CONFD_GROUP)'"; \
991           echo "NODED_USER = '$(NODED_USER)'"; \
992           echo "NODED_GROUP = '$(NODED_GROUP)'"; \
993           echo "DISK_SEPARATOR = '$(DISK_SEPARATOR)'"; \
994           echo "QEMUIMG_PATH = '$(QEMUIMG_PATH)'"; \
995           if [ "$(HTOOLS)" ]; then \
996             echo "HTOOLS = True"; \
997           else \
998             echo "HTOOLS = False"; \
999           fi; \
1000         } > $@
1001
1002 lib/_vcsversion.py: Makefile vcs-version | lib/.dir
1003         set -e; \
1004         VCSVER=`cat $(abs_top_srcdir)/vcs-version`; \
1005         { echo '# This file is automatically generated, do not edit!'; \
1006           echo '#'; \
1007           echo ''; \
1008           echo '"""Build-time VCS version number for Ganeti.'; \
1009           echo '';\
1010           echo 'This file is autogenerated by the build process.'; \
1011           echo 'For any changes you need to re-run ./configure (and'; \
1012           echo 'not edit by hand).'; \
1013           echo ''; \
1014           echo '"""'; \
1015           echo ''; \
1016           echo '# pylint: disable=C0301,C0324'; \
1017           echo '# because this is autogenerated, we do not want'; \
1018           echo '# style warnings' ; \
1019           echo ''; \
1020           echo "VCS_VERSION = '$$VCSVER'"; \
1021         } > $@
1022
1023 lib/_generated_rpc.py: lib/build/rpc_definitions.py $(BUILD_RPC) | lib/.dir
1024         PYTHONPATH=. $(RUN_IN_TEMPDIR) $(CURDIR)/$(BUILD_RPC) $< > $@
1025
1026 $(REPLACE_VARS_SED): Makefile
1027         set -e; \
1028         { echo 's#@PREFIX@#$(prefix)#g'; \
1029           echo 's#@SYSCONFDIR@#$(sysconfdir)#g'; \
1030           echo 's#@LOCALSTATEDIR@#$(localstatedir)#g'; \
1031           echo 's#@BINDIR@#$(bindir)#g'; \
1032           echo 's#@SBINDIR@#$(sbindir)#g'; \
1033           echo 's#@GANETI_VERSION@#$(PACKAGE_VERSION)#g'; \
1034           echo 's#@CUSTOM_XEN_BOOTLOADER@#$(XEN_BOOTLOADER)#g'; \
1035           echo 's#@CUSTOM_XEN_KERNEL@#$(XEN_KERNEL)#g'; \
1036           echo 's#@CUSTOM_XEN_INITRD@#$(XEN_INITRD)#g'; \
1037           echo 's#@CUSTOM_IALLOCATOR_SEARCH_PATH@#$(IALLOCATOR_SEARCH_PATH)#g'; \
1038           echo 's#@CUSTOM_EXPORT_DIR@#$(EXPORT_DIR)#g'; \
1039           echo 's#@RPL_FILE_STORAGE_DIR@#$(FILE_STORAGE_DIR)#g'; \
1040           echo 's#@RPL_SSH_INITD_SCRIPT@#$(SSH_INITD_SCRIPT)#g'; \
1041           echo 's#@PKGLIBDIR@#$(pkglibdir)#g'; \
1042           echo 's#@GNTMASTERUSER@#$(MASTERD_USER)#g'; \
1043           echo 's#@GNTRAPIUSER@#$(RAPI_USER)#g'; \
1044           echo 's#@GNTCONFDUSER@#$(CONFD_USER)#g'; \
1045           echo 's#@GNTNODEDUSER@#$(NODED_USER)#g'; \
1046           echo 's#@GNTRAPIGROUP@#$(RAPI_GROUP)#g'; \
1047           echo 's#@GNTADMINGROUP@#$(ADMIN_GROUP)#g'; \
1048           echo 's#@GNTCONFDGROUP@#$(CONFD_GROUP)#g'; \
1049           echo 's#@GNTMASTERDGROUP@#$(MASTERD_GROUP)#g'; \
1050           echo 's#@GNTDAEMONSGROUP@#$(DAEMONS_GROUP)#g'; \
1051         } > $@
1052
1053 # Using deferred evaluation
1054 daemons/ganeti-%: MODULE = ganeti.server.$(patsubst ganeti-%,%,$(notdir $@))
1055 daemons/ganeti-watcher: MODULE = ganeti.watcher
1056 scripts/%: MODULE = ganeti.client.$(subst -,_,$(notdir $@))
1057 tools/ensure-dirs: MODULE = ganeti.tools.ensure_dirs
1058
1059 $(PYTHON_BOOTSTRAP): Makefile | $(all_dirfiles)
1060         test -n "$(MODULE)" || { echo Missing module; exit 1; }
1061         set -e; \
1062         { echo '#!/usr/bin/python'; \
1063           echo '# This file is automatically generated, do not edit!'; \
1064           echo "# Edit $(MODULE) instead."; \
1065           echo; \
1066           echo '"""Bootstrap script for L{$(MODULE)}"""'; \
1067           echo; \
1068           echo '# pylint: disable=C0103'; \
1069           echo '# C0103: Invalid name'; \
1070           echo; \
1071           echo 'import sys'; \
1072           echo 'import $(MODULE) as main'; \
1073           echo; \
1074           echo '# Temporarily alias commands until bash completion'; \
1075           echo '# generator is changed'; \
1076           echo 'if hasattr(main, "commands"):'; \
1077           echo '  commands = main.commands # pylint: disable=E1101'; \
1078           echo 'if hasattr(main, "aliases"):'; \
1079           echo '  aliases = main.aliases # pylint: disable=E1101'; \
1080           echo; \
1081           echo 'if __name__ == "__main__":'; \
1082           echo '  sys.exit(main.Main())'; \
1083         } > $@
1084         chmod u+x $@
1085
1086 # We need to create symlinks because "make distcheck" will not install Python
1087 # files when building.
1088 stamp-srclinks: Makefile | $(all_dirfiles)
1089         set -e; \
1090         for i in $(srclink_files); do \
1091                 if test ! -f $$i -a -f $(abs_top_srcdir)/$$i; then \
1092                         $(LN_S) $(abs_top_srcdir)/$$i $$i; \
1093                 fi; \
1094         done
1095         touch $@
1096
1097 .PHONY: ganeti
1098 ganeti:
1099         cd $(top_builddir) && test -h "$@" || { rm -f $@ && $(LN_S) lib $@; }
1100
1101 .PHONY: check-dirs
1102 check-dirs: $(BUILT_SOURCES)
1103         @set -e; \
1104         find . -type d \( \( -name . \) -o \( \
1105                 -name .git -o \
1106                 -name autom4te.cache \
1107                 \) -prune -o -print \) | { \
1108                 error=; \
1109                 while read dir; do \
1110                         case "$$dir" in \
1111                                 $(strip $(patsubst %,(./%) ;;,$(DIRCHECK_EXCLUDE) $(DIRS))) \
1112                                 *) error=1; echo "Directory $$dir not listed in Makefile" >&2 ;; \
1113                         esac; \
1114                 done; \
1115                 for dir in $(DIRS); do \
1116                         if ! test -d "$$dir"; then \
1117                                 echo "Directory $$dir listed in DIRS does not exist" >&2; \
1118                                 error=1; \
1119                         fi \
1120                 done; \
1121                 if test -n "$$error"; then exit 1; else exit 0; fi; \
1122         }
1123
1124 .PHONY: check-local
1125 check-local: check-dirs $(BUILT_SOURCES)
1126         $(CHECK_PYTHON_CODE) $(check_python_code)
1127         $(CHECK_VERSION) $(VERSION) $(top_srcdir)/NEWS
1128         $(CHECK_NEWS) < $(top_srcdir)/NEWS
1129         PYTHONPATH=. $(RUN_IN_TEMPDIR) $(CURDIR)/$(CHECK_IMPORTS) . $(standalone_python_modules)
1130         expver=$(VERSION_MAJOR).$(VERSION_MINOR); \
1131         if test "`head -n 1 $(top_srcdir)/README`" != "Ganeti $$expver"; then \
1132                 echo "Incorrect version in README, expected $$expver"; \
1133                 exit 1; \
1134         fi; \
1135         for file in doc/iallocator.rst doc/hooks.rst; do \
1136                 if test "`sed -ne '4 p' $(top_srcdir)/$$file`" != \
1137                         "Documents Ganeti version $$expver"; then \
1138                         echo "Incorrect version in $$file, expected $$expver"; \
1139                         exit 1; \
1140                 fi; \
1141         done
1142
1143 .PHONY: hs-check
1144 hs-check: htools/test
1145         @rm -f test.tix
1146         ./htools/test
1147
1148 # E111: indentation is not a multiple of four
1149 # E261: at least two spaces before inline comment
1150 # E501: line too long (80 characters)
1151 PEP8_IGNORE = E111,E261,E501
1152
1153 # For excluding pep8 expects filenames only, not whole paths
1154 PEP8_EXCLUDE = $(subst $(space),$(comma),$(strip $(notdir $(BUILT_PYTHON_SOURCES))))
1155
1156 .PHONY: lint
1157 lint: $(BUILT_SOURCES)
1158         @test -n "$(PYLINT)" || { echo 'pylint' not found during configure; exit 1; }
1159         if test -z "$(PEP8)"; then \
1160                 echo '"pep8" not found during configure' >&2; \
1161         else \
1162                 $(PEP8) --repeat --ignore='$(PEP8_IGNORE)' --exclude='$(PEP8_EXCLUDE)' \
1163                         $(pep8_python_code); \
1164         fi
1165         $(PYLINT) $(LINT_OPTS) $(lint_python_code)
1166         cd $(top_srcdir)/qa && \
1167           PYTHONPATH=$(abs_top_srcdir) $(PYLINT) $(LINT_OPTS) \
1168           --rcfile  ../pylintrc $(patsubst qa/%.py,%,$(qa_scripts))
1169
1170 .PHONY: hlint
1171 hlint: $(HS_BUILT_SRCS)
1172         if tty -s; then C="-c"; else C=""; fi; \
1173         hlint --report=doc/hs-lint.html $$C htools
1174
1175 # a dist hook rule for updating the vcs-version file; this is
1176 # hardcoded due to where it needs to build the file...
1177 dist-hook:
1178         $(MAKE) regen-vcs-version && \
1179         rm -f $(top_distdir)/vcs-version && \
1180         cp -p $(srcdir)/vcs-version $(top_distdir)
1181
1182 # a distcheck hook rule for catching revision control directories
1183 distcheck-hook:
1184         if find $(top_distdir) -name .svn -or -name .git | grep .; then \
1185                 echo "Found revision control files in final archive." 1>&2; \
1186                 exit 1; \
1187         fi
1188         if find $(top_distdir) -name '*.py[co]' | grep .; then \
1189                 echo "Found Python byte code in final archive." 1>&2; \
1190                 exit 1; \
1191         fi
1192         if find $(top_distdir) -name '*~' | grep .; then \
1193                 echo "Found backup files in final archive." 1>&2; \
1194                 exit 1; \
1195         fi
1196 # Empty files or directories should not be distributed. They can cause
1197 # unnecessary warnings for packagers. Directories used by automake during
1198 # distcheck must be excluded.
1199         if find $(top_distdir) -empty -and -not \( \
1200                         -path $(top_distdir)/_build -or \
1201                         -path $(top_distdir)/_inst \) | grep .; then \
1202                 echo "Found empty files or directories in final archive." 1>&2; \
1203                 exit 1; \
1204         fi
1205         if test -n "$(BUILD_RELEASE)" && \
1206            grep -n -H -E '^\*.*unreleased' $(top_distdir)/NEWS; then \
1207                 echo "Found unreleased version in NEWS." >&2; \
1208                 exit 1; \
1209         fi
1210
1211 # When building a release, stricter checks should be used
1212 distcheck-release dist-release: export BUILD_RELEASE = 1
1213 distcheck-release: distcheck
1214
1215 dist-release: dist
1216         set -e; \
1217         for i in $(DIST_ARCHIVES); do \
1218                 echo -n "Checking $$i ... "; \
1219                 autotools/check-tar < $$i; \
1220                 echo OK; \
1221         done
1222
1223 install-exec-local:
1224         @mkdir_p@ "$(DESTDIR)${localstatedir}/lib/ganeti" \
1225           "$(DESTDIR)${localstatedir}/log/ganeti" \
1226           "$(DESTDIR)${localstatedir}/run/ganeti"
1227
1228 # To avoid conflicts between directory names and other targets, a file inside
1229 # the directory is used to ensure its existence.
1230 %.dir:
1231         @mkdir_p@ $* && touch $@
1232
1233 .PHONY: apidoc
1234 if WANT_HTOOLSAPIDOC
1235 apidoc: py-apidoc hs-apidoc
1236 else
1237 apidoc: py-apidoc
1238 endif
1239
1240 .PHONY: py-apidoc
1241 py-apidoc: epydoc.conf $(RUN_IN_TEMPDIR) $(BUILT_SOURCES)
1242         $(RUN_IN_TEMPDIR) epydoc -v \
1243                 --conf $(CURDIR)/epydoc.conf \
1244                 --output $(CURDIR)/$(APIDOC_PY_DIR)
1245
1246 .PHONY: hs-apidoc
1247 hs-apidoc: $(HS_BUILT_SRCS)
1248         @test -n "$(HSCOLOUR)" || \
1249             { echo 'HsColour' not found during configure; exit 1; }
1250         @test -n "$(HADDOCK)" || \
1251             { echo 'haddock' not found during configure; exit 1; }
1252         rm -rf $(APIDOC_HS_DIR)/*
1253         @mkdir_p@ $(APIDOC_HS_DIR)/Ganeti/HTools/Program
1254         $(HSCOLOUR) -print-css > $(APIDOC_HS_DIR)/Ganeti/hscolour.css
1255         $(LN_S) ../hscolour.css $(APIDOC_HS_DIR)/Ganeti/HTools/hscolour.css
1256         set -e ; \
1257         cd htools; \
1258         if [ "$(HTOOLS_NOCURL)" ]; \
1259         then OPTGHC="--optghc=$(HTOOLS_NOCURL)"; \
1260         else OPTGHC=""; \
1261         fi; \
1262         if [ "$(HTOOLS_PARALLEL3)" ]; \
1263         then OPTGHC="$$OPTGHC --optghc=$(HTOOLS_PARALLEL3)"; \
1264         fi; \
1265         RELSRCS="$(HS_LIB_SRCS:htools/%=%)  $(HS_BUILT_SRCS:htools/%=%)"; \
1266         for file in $$RELSRCS; do \
1267                 hfile=`echo $$file|sed 's/\\.hs$$//'`.html; \
1268                 $(HSCOLOUR) -css -anchor $$file > ../$(APIDOC_HS_DIR)/$$hfile ; \
1269         done ; \
1270         $(HADDOCK) --odir ../$(APIDOC_HS_DIR) --html --ignore-all-exports -w \
1271                 -t ganeti-htools -p haddock-prologue \
1272                 --source-module="%{MODULE/.//}.html" \
1273                 --source-entity="%{MODULE/.//}.html#%{NAME}" \
1274                 $$OPTGHC \
1275                 $(filter-out Ganeti/HTools/ExtLoader.hs,$(HS_LIB_SRCS:htools/%=%))
1276
1277 .PHONY: TAGS
1278 TAGS: $(BUILT_SOURCES)
1279         rm -f TAGS
1280         find . -path './lib/*.py' -o -path './scripts/gnt-*' -o \
1281           -path './daemons/ganeti-*' -o -path './tools/*' -o \
1282           -path './qa/*.py' | \
1283           etags -l python -
1284
1285 .PHONY: coverage
1286 if WANT_HTOOLS
1287 coverage: py-coverage hs-coverage
1288 else
1289 coverage: py-coverage
1290 endif
1291
1292 .PHONY: py-coverage
1293 py-coverage: $(BUILT_SOURCES) $(python_tests)
1294         set -e; \
1295         COVERAGE_FILE=$(CURDIR)/$(COVERAGE_PY_DIR)/data \
1296         TEXT_COVERAGE=$(CURDIR)/$(COVERAGE_PY_DIR)/report.txt \
1297         HTML_COVERAGE=$(CURDIR)/$(COVERAGE_PY_DIR) \
1298         $(PLAIN_TESTS_ENVIRONMENT) $(abs_top_srcdir)/autotools/gen-coverage \
1299         $(python_tests)
1300
1301 .PHONY: hs-coverage
1302 hs-coverage: $(haskell_tests)
1303         cd htools && rm -f *.tix *.mix && ./test
1304         @mkdir_p@ $(COVERAGE_HS_DIR)
1305         hpc markup --destdir=$(COVERAGE_HS_DIR) htools/test $(HPCEXCL)
1306         hpc report htools/test $(HPCEXCL)
1307         $(LN_S) -f hpc_index.html $(COVERAGE_HS_DIR)/index.html
1308
1309 # Special "kind-of-QA" target for htools, needs special setup (all
1310 # tools compiled with -fhpc)
1311 .PHONY: live-test
1312 live-test: all
1313         set -e ; \
1314         cd htools; \
1315         rm -f .hpc; $(LN_S) ../.hpc .hpc; \
1316         rm -f *.tix *.mix; \
1317         ./live-test.sh; \
1318         hpc sum --union $(HPCEXCL) $(addsuffix .tix,$(HS_PROGS:htools/%=%)) \
1319           --output=live-test.tix ; \
1320         @mkdir_p@ ../$(COVERAGE_HS_DIR) ; \
1321         hpc markup --destdir=../$(COVERAGE_HS_DIR) live-test \
1322                 --srcdir=.. $(HPCEXCL) ; \
1323         hpc report --srcdir=.. live-test $(HPCEXCL)
1324
1325 commit-check: distcheck lint apidoc
1326
1327 -include ./Makefile.local
1328
1329 # vim: set noet :