Merge branch 'stable-2.16' into stable-2.17
[ganeti-github.git] / 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 # For distcheck we need the haskell tests to be enabled. Note:
9 # The "correct" way would be to define AM_DISTCHECK_CONFIGURE_FLAGS.
10 # However, we still have to support older versions of autotools,
11 # so we cannot use that yet, hence we fall back to..
12 DISTCHECK_CONFIGURE_FLAGS = --enable-haskell-tests
13
14 # Automake doesn't export these variables before version 1.10.
15 abs_top_builddir = @abs_top_builddir@
16 abs_top_srcdir = @abs_top_srcdir@
17
18 # Helper values for calling builtin functions
19 empty :=
20 space := $(empty) $(empty)
21 comma := ,
22
23 # Helper function to strip src/ and test/hs/ from a list
24 strip_hsroot = $(patsubst src/%,%,$(patsubst test/hs/%,%,$(1)))
25
26 # Use bash in order to be able to use pipefail
27 SHELL=/bin/bash
28
29 EXTRA_DIST=
30
31 # Enable colors in shelltest
32 SHELLTESTARGS = "-c"
33
34 ACLOCAL_AMFLAGS = -I autotools
35 BUILD_BASH_COMPLETION = $(top_srcdir)/autotools/build-bash-completion
36 RUN_IN_TEMPDIR = $(top_srcdir)/autotools/run-in-tempdir
37 CHECK_PYTHON_CODE = $(top_srcdir)/autotools/check-python-code
38 CHECK_HEADER = $(top_srcdir)/autotools/check-header
39 CHECK_MAN_DASHES = $(top_srcdir)/autotools/check-man-dashes
40 CHECK_MAN_REFERENCES = $(top_srcdir)/autotools/check-man-references
41 CHECK_MAN_WARNINGS = $(top_srcdir)/autotools/check-man-warnings
42 CHECK_VERSION = $(top_srcdir)/autotools/check-version
43 CHECK_NEWS = $(top_srcdir)/autotools/check-news
44 CHECK_IMPORTS = $(top_srcdir)/autotools/check-imports
45 DOCPP = $(top_srcdir)/autotools/docpp
46 REPLACE_VARS_SED = autotools/replace_vars.sed
47 PRINT_PY_CONSTANTS = $(top_srcdir)/autotools/print-py-constants
48 BUILD_RPC = $(top_srcdir)/autotools/build-rpc
49 SHELL_ENV_INIT = autotools/shell-env-init
50
51 # starting as of Ganeti 2.10, all files are stored in two directories,
52 # with only symbolic links added at other places.
53 #
54 # $(versiondir) contains most of Ganeti and all architecture-dependent files
55 # $(versionedsharedir) contains only architecture-independent files; all python
56 # executables need to go directly to $(versionedsharedir), as all ganeti python
57 # mdules are installed outside the usual python path, i.e., as private modules.
58 #
59 # $(defaultversiondir) and $(defaultversionedsharedir) are the corresponding
60 # directories for "the currently running" version of Ganeti. We never install
61 # there, but all symbolic links go there, rather than directory to $(versiondir)
62 # or $(versionedsharedir). Note that all links to $(default*dir) need to be stable;
63 # so, if some currently architecture-independent executable is replaced by an
64 # architecture-dependent one (and hence has to go under $(versiondir)), add a link
65 # under $(versionedsharedir) but do not change the external links.
66 if USE_VERSION_FULL
67 DIRVERSION=$(VERSION_FULL)
68 else
69 DIRVERSION=$(VERSION_MAJOR).$(VERSION_MINOR)
70 endif
71 versiondir = $(libdir)/ganeti/$(DIRVERSION)
72 defaultversiondir = $(libdir)/ganeti/default
73 versionedsharedir = $(prefix)/share/ganeti/$(DIRVERSION)
74 defaultversionedsharedir = $(prefix)/share/ganeti/default
75
76 # Note: these are automake-specific variables, and must be named after
77 # the directory + 'dir' suffix
78 pkglibdir = $(versiondir)$(libdir)/ganeti
79 myexeclibdir = $(pkglibdir)
80 bindir = $(versiondir)/$(BINDIR)
81 sbindir = $(versiondir)$(SBINDIR)
82 mandir = $(versionedsharedir)/root$(MANDIR)
83 pkgpythondir = $(versionedsharedir)/ganeti
84 pkgpython_rpc_stubdir = $(versionedsharedir)/ganeti/rpc/stub
85 gntpythondir = $(versionedsharedir)
86 pkgpython_bindir = $(versionedsharedir)
87 gnt_python_sbindir = $(versionedsharedir)
88 tools_pythondir = $(versionedsharedir)
89
90 clientdir = $(pkgpythondir)/client
91 cmdlibdir = $(pkgpythondir)/cmdlib
92 cmdlib_clusterdir = $(pkgpythondir)/cmdlib/cluster
93 configdir = $(pkgpythondir)/config
94 hypervisordir = $(pkgpythondir)/hypervisor
95 hypervisor_hv_kvmdir = $(pkgpythondir)/hypervisor/hv_kvm
96 jqueuedir = $(pkgpythondir)/jqueue
97 storagedir = $(pkgpythondir)/storage
98 httpdir = $(pkgpythondir)/http
99 masterddir = $(pkgpythondir)/masterd
100 confddir = $(pkgpythondir)/confd
101 rapidir = $(pkgpythondir)/rapi
102 rpcdir = $(pkgpythondir)/rpc
103 rpc_stubdir = $(pkgpythondir)/rpc/stub
104 serverdir = $(pkgpythondir)/server
105 watcherdir = $(pkgpythondir)/watcher
106 impexpddir = $(pkgpythondir)/impexpd
107 utilsdir = $(pkgpythondir)/utils
108 toolsdir = $(pkglibdir)/tools
109 iallocatorsdir = $(pkglibdir)/iallocators
110 pytoolsdir = $(pkgpythondir)/tools
111 docdir = $(versiondir)$(datadir)/doc/$(PACKAGE)
112 ifupdir = $(sysconfdir)/ganeti
113
114 if USE_BACKUP_DIR
115 backup_dir = $(BACKUP_DIR)
116 else
117 backup_dir = $(localstatedir)/lib
118 endif
119
120 SYMLINK_TARGET_DIRS = \
121         $(sysconfdir)/ganeti \
122         $(libdir)/ganeti/iallocators \
123         $(libdir)/ganeti/tools \
124         $(prefix)/share/ganeti \
125         $(BINDIR) \
126         $(SBINDIR) \
127         $(MANDIR)/man1 \
128         $(MANDIR)/man7 \
129         $(MANDIR)/man8
130
131 # Delete output file if an error occurred while building it
132 .DELETE_ON_ERROR:
133
134 HS_DIRS = \
135         src \
136         src/Ganeti \
137         src/Ganeti/Confd \
138         src/Ganeti/Curl \
139         src/Ganeti/Cpu \
140         src/Ganeti/DataCollectors \
141         src/Ganeti/Daemon \
142         src/Ganeti/Hs2Py \
143         src/Ganeti/HTools \
144         src/Ganeti/HTools/Backend \
145         src/Ganeti/HTools/Cluster \
146         src/Ganeti/HTools/Program \
147         src/Ganeti/HTools/Tags \
148         src/Ganeti/Hypervisor \
149         src/Ganeti/Hypervisor/Xen \
150         src/Ganeti/JQScheduler \
151         src/Ganeti/JQueue \
152         src/Ganeti/Locking \
153         src/Ganeti/Logging \
154         src/Ganeti/MaintD \
155         src/Ganeti/Monitoring \
156         src/Ganeti/Metad \
157         src/Ganeti/Objects \
158         src/Ganeti/OpCodes \
159         src/Ganeti/Query \
160         src/Ganeti/Storage \
161         src/Ganeti/Storage/Diskstats \
162         src/Ganeti/Storage/Drbd \
163         src/Ganeti/Storage/Lvm \
164         src/Ganeti/THH \
165         src/Ganeti/Utils \
166         src/Ganeti/WConfd \
167         test/hs \
168         test/hs/Test \
169         test/hs/Test/Ganeti \
170         test/hs/Test/Ganeti/Storage \
171         test/hs/Test/Ganeti/Storage/Diskstats \
172         test/hs/Test/Ganeti/Storage/Drbd \
173         test/hs/Test/Ganeti/Storage/Lvm \
174         test/hs/Test/Ganeti/Confd \
175         test/hs/Test/Ganeti/HTools \
176         test/hs/Test/Ganeti/HTools/Backend \
177         test/hs/Test/Ganeti/Hypervisor \
178         test/hs/Test/Ganeti/Hypervisor/Xen \
179         test/hs/Test/Ganeti/JQueue \
180         test/hs/Test/Ganeti/Locking \
181         test/hs/Test/Ganeti/Objects \
182         test/hs/Test/Ganeti/Query \
183         test/hs/Test/Ganeti/THH \
184         test/hs/Test/Ganeti/Utils \
185         test/hs/Test/Ganeti/WConfd
186
187 # Haskell directories without the roots (src, test/hs)
188 HS_DIRS_NOROOT = $(filter-out src,$(filter-out test/hs,$(HS_DIRS)))
189
190 DIRS = \
191         $(HS_DIRS) \
192         autotools \
193         cabal \
194         daemons \
195         devel \
196         devel/data \
197         doc \
198         doc/css \
199         doc/examples \
200         doc/examples/gnt-debug \
201         doc/examples/hooks \
202         doc/examples/systemd \
203         doc/users \
204         test/data/htools \
205         test/data/htools/rapi \
206         test/hs/shelltests \
207         test/autotools \
208         lib \
209         lib/build \
210         lib/client \
211         lib/cmdlib \
212         lib/cmdlib/cluster \
213         lib/confd \
214         lib/config \
215         lib/jqueue \
216         lib/http \
217         lib/hypervisor \
218         lib/hypervisor/hv_kvm \
219         lib/impexpd \
220         lib/masterd \
221         lib/rapi \
222         lib/rpc \
223         lib/rpc/stub \
224         lib/server \
225         lib/storage \
226         lib/tools \
227         lib/utils \
228         lib/watcher \
229         man \
230         qa \
231         qa/patch \
232         test \
233         test/data \
234         test/data/bdev-rbd \
235         test/data/ovfdata \
236         test/data/ovfdata/other \
237         test/data/cgroup_root \
238         test/data/cgroup_root/memory \
239         test/data/cgroup_root/memory/lxc \
240         test/data/cgroup_root/memory/lxc/instance1 \
241         test/data/cgroup_root/cpuset \
242         test/data/cgroup_root/cpuset/some_group \
243         test/data/cgroup_root/cpuset/some_group/lxc \
244         test/data/cgroup_root/cpuset/some_group/lxc/instance1 \
245         test/data/cgroup_root/devices \
246         test/data/cgroup_root/devices/some_group \
247         test/data/cgroup_root/devices/some_group/lxc \
248         test/data/cgroup_root/devices/some_group/lxc/instance1 \
249         test/py \
250         test/py/testutils \
251         test/py/cmdlib \
252         test/py/cmdlib/testsupport \
253         tools
254
255 ALL_APIDOC_HS_DIRS = \
256         $(APIDOC_HS_DIR) \
257         $(patsubst %,$(APIDOC_HS_DIR)/%,$(call strip_hsroot,$(HS_DIRS_NOROOT)))
258
259 BUILDTIME_DIR_AUTOCREATE = \
260         scripts \
261         $(APIDOC_DIR) \
262         $(ALL_APIDOC_HS_DIRS) \
263         $(APIDOC_PY_DIR) \
264         $(COVERAGE_DIR) \
265         $(COVERAGE_HS_DIR) \
266         $(COVERAGE_PY_DIR) \
267         .hpc
268
269 BUILDTIME_DIRS = \
270         $(BUILDTIME_DIR_AUTOCREATE) \
271         apps \
272         dist \
273         doc/html \
274         doc/man-html
275
276 DIRCHECK_EXCLUDE = \
277         $(BUILDTIME_DIRS) \
278         ganeti-[0-9]*.[0-9]*.[0-9]* \
279         doc/html/_* \
280         doc/man-html/_* \
281         tools/shebang \
282         autom4te.cache
283
284 # some helper vars
285 COVERAGE_DIR = doc/coverage
286 COVERAGE_PY_DIR = $(COVERAGE_DIR)/py
287 COVERAGE_HS_DIR = $(COVERAGE_DIR)/hs
288 APIDOC_DIR = doc/api
289 APIDOC_PY_DIR = $(APIDOC_DIR)/py
290 APIDOC_HS_DIR = $(APIDOC_DIR)/hs
291
292 MAINTAINERCLEANFILES = \
293         $(maninput) \
294         doc/install-quick.rst \
295         doc/news.rst \
296         doc/upgrade.rst \
297         vcs-version
298
299 maintainer-clean-local:
300         rm -rf $(BUILDTIME_DIRS)
301
302 CLEANFILES = \
303         $(addsuffix /*.py[co],$(DIRS)) \
304         $(addsuffix /*.hi,$(HS_DIRS)) \
305         $(addsuffix /*.o,$(HS_DIRS)) \
306         $(addsuffix /*.dyn_hi,$(HS_DIRS)) \
307         $(addsuffix /*.dyn_o,$(HS_DIRS)) \
308         $(addsuffix /*.$(HTEST_SUFFIX)_hi,$(HS_DIRS)) \
309         $(addsuffix /*.$(HTEST_SUFFIX)_o,$(HS_DIRS)) \
310         $(HASKELL_PACKAGE_VERSIONS_FILE) \
311         $(CABAL_EXECUTABLES_APPS_STAMPS) \
312         empty-cabal-config \
313         ganeti.cabal \
314         $(HASKELL_PACKAGE_IDS_FILE) \
315         $(HASKELL_PACKAGE_VERSIONS_FILE) \
316         Makefile.ghc \
317         Makefile.ghc.bak \
318         $(PYTHON_BOOTSTRAP) \
319         $(gnt_python_sbin_SCRIPTS) \
320         epydoc.conf \
321         $(REPLACE_VARS_SED) \
322         $(SHELL_ENV_INIT) \
323         daemons/daemon-util \
324         daemons/ganeti-cleaner \
325         devel/squeeze-amd64.tar.gz \
326         devel/squeeze-amd64.conf \
327         $(mandocrst) \
328         doc/manpages-enabled.rst \
329         $(BUILT_EXAMPLES) \
330         doc/examples/bash_completion \
331         doc/examples/bash_completion-debug \
332         $(userspecs) \
333         lib/_generated_rpc.py \
334         $(man_MANS) \
335         $(manhtml) \
336         tools/kvm-ifup \
337         tools/kvm-ifup-os \
338         tools/xen-ifup-os \
339         tools/vif-ganeti \
340         tools/vif-ganeti-metad \
341         tools/net-common \
342         tools/users-setup \
343         tools/ssl-update \
344         tools/vcluster-setup \
345         tools/prepare-node-join \
346         tools/ssh-update \
347         $(python_scripts_shebang) \
348         stamp-directories \
349         stamp-srclinks \
350         $(nodist_pkgpython_PYTHON) \
351         $(nodist_pkgpython_rpc_stub_PYTHON) \
352         $(gnt_scripts) \
353         $(HS_ALL_PROGS) $(HS_BUILT_SRCS) \
354         $(HS_BUILT_TEST_HELPERS) \
355         src/ganeti-confd \
356         src/ganeti-wconfd \
357         src/ganeti-luxid \
358         src/ganeti-maintd \
359         src/ganeti-metad \
360         src/ganeti-mond \
361         .hpc/*.mix src/*.tix test/hs/*.tix *.tix \
362         doc/hs-lint.html
363
364 GENERATED_FILES = \
365         $(built_base_sources) \
366         $(built_python_sources) \
367         $(PYTHON_BOOTSTRAP) \
368         $(gnt_python_sbin_SCRIPTS)
369
370 clean-local:
371         rm -rf tools/shebang
372         rm -rf apps
373         rm -rf dist
374
375 HS_GENERATED_FILES = $(HS_PROGS) src/hluxid src/ganeti-luxid \
376         src/hconfd src/ganeti-confd
377 if ENABLE_MOND
378 HS_GENERATED_FILES += src/ganeti-mond src/ganeti-maintd
379 endif
380 if ENABLE_METADATA
381 HS_GENERATED_FILES += src/ganeti-metad
382 endif
383
384 built_base_sources = \
385         stamp-directories \
386         stamp-srclinks
387
388 built_python_base_sources = \
389         lib/_constants.py \
390         lib/_vcsversion.py \
391         lib/opcodes.py \
392         lib/rpc/stub/wconfd.py
393
394 if ENABLE_METADATA
395 built_python_base_sources += lib/rpc/stub/metad.py
396 endif
397
398 built_python_sources = \
399         $(nodist_pkgpython_PYTHON) \
400         $(nodist_pkgpython_rpc_stub_PYTHON)
401
402 # these are all built from the underlying %.in sources
403 BUILT_EXAMPLES = \
404         doc/examples/ganeti-kvm-poweroff.initd \
405         doc/examples/ganeti.cron \
406         doc/examples/ganeti.initd \
407         doc/examples/ganeti.logrotate \
408         doc/examples/ganeti-master-role.ocf \
409         doc/examples/ganeti-node-role.ocf \
410         doc/examples/gnt-config-backup \
411         doc/examples/hooks/ipsec \
412         doc/examples/systemd/ganeti-common.service \
413         doc/examples/systemd/ganeti-confd.service \
414         doc/examples/systemd/ganeti-kvmd.service \
415         doc/examples/systemd/ganeti-luxid.service \
416         doc/examples/systemd/ganeti-metad.service \
417         doc/examples/systemd/ganeti-maintd.service \
418         doc/examples/systemd/ganeti-mond.service \
419         doc/examples/systemd/ganeti-noded.service \
420         doc/examples/systemd/ganeti-rapi.service \
421         doc/examples/systemd/ganeti-wconfd.service
422
423 nodist_ifup_SCRIPTS = \
424         tools/kvm-ifup-os \
425         tools/xen-ifup-os
426
427 nodist_pkgpython_PYTHON = \
428         $(built_python_base_sources) \
429         lib/_generated_rpc.py
430
431 nodist_pkgpython_rpc_stub_PYTHON = \
432         lib/rpc/stub/wconfd.py
433
434 if ENABLE_METADATA
435 nodist_pkgpython_rpc_stub_PYTHON += lib/rpc/stub/metad.py
436 endif
437
438 nodist_pkgpython_bin_SCRIPTS = \
439         $(nodist_pkglib_python_scripts)
440
441 pkgpython_bin_SCRIPTS = \
442         $(pkglib_python_scripts)
443
444 noinst_PYTHON = \
445         lib/build/__init__.py \
446         lib/build/shell_example_lexer.py \
447         lib/build/sphinx_ext.py
448
449 pkgpython_PYTHON = \
450         lib/__init__.py \
451         lib/asyncnotifier.py \
452         lib/backend.py \
453         lib/bootstrap.py \
454         lib/cli.py \
455         lib/cli_opts.py \
456         lib/compat.py \
457         lib/constants.py \
458         lib/daemon.py \
459         lib/errors.py \
460         lib/hooksmaster.py \
461         lib/ht.py \
462         lib/jstore.py \
463         lib/locking.py \
464         lib/luxi.py \
465         lib/mcpu.py \
466         lib/metad.py \
467         lib/netutils.py \
468         lib/objects.py \
469         lib/opcodes_base.py \
470         lib/outils.py \
471         lib/ovf.py \
472         lib/pathutils.py \
473         lib/qlang.py \
474         lib/query.py \
475         lib/rpc_defs.py \
476         lib/runtime.py \
477         lib/serializer.py \
478         lib/ssconf.py \
479         lib/ssh.py \
480         lib/uidpool.py \
481         lib/vcluster.py \
482         lib/network.py \
483         lib/wconfd.py \
484         lib/workerpool.py
485
486 client_PYTHON = \
487         lib/client/__init__.py \
488         lib/client/base.py \
489         lib/client/gnt_backup.py \
490         lib/client/gnt_cluster.py \
491         lib/client/gnt_debug.py \
492         lib/client/gnt_group.py \
493         lib/client/gnt_instance.py \
494         lib/client/gnt_job.py \
495         lib/client/gnt_node.py \
496         lib/client/gnt_network.py \
497         lib/client/gnt_os.py \
498         lib/client/gnt_storage.py \
499         lib/client/gnt_filter.py
500
501 cmdlib_PYTHON = \
502         lib/cmdlib/__init__.py \
503         lib/cmdlib/backup.py \
504         lib/cmdlib/base.py \
505         lib/cmdlib/common.py \
506         lib/cmdlib/group.py \
507         lib/cmdlib/instance.py \
508         lib/cmdlib/instance_create.py \
509         lib/cmdlib/instance_helpervm.py \
510         lib/cmdlib/instance_migration.py \
511         lib/cmdlib/instance_operation.py \
512         lib/cmdlib/instance_query.py \
513         lib/cmdlib/instance_set_params.py \
514         lib/cmdlib/instance_storage.py \
515         lib/cmdlib/instance_utils.py \
516         lib/cmdlib/misc.py \
517         lib/cmdlib/network.py \
518         lib/cmdlib/node.py \
519         lib/cmdlib/operating_system.py \
520         lib/cmdlib/query.py \
521         lib/cmdlib/tags.py \
522         lib/cmdlib/test.py
523
524 cmdlib_cluster_PYTHON = \
525         lib/cmdlib/cluster/__init__.py \
526         lib/cmdlib/cluster/verify.py
527
528 config_PYTHON = \
529         lib/config/__init__.py \
530         lib/config/verify.py \
531         lib/config/temporary_reservations.py \
532         lib/config/utils.py
533
534 hypervisor_PYTHON = \
535         lib/hypervisor/__init__.py \
536         lib/hypervisor/hv_base.py \
537         lib/hypervisor/hv_chroot.py \
538         lib/hypervisor/hv_fake.py \
539         lib/hypervisor/hv_lxc.py \
540         lib/hypervisor/hv_xen.py
541
542 hypervisor_hv_kvm_PYTHON = \
543         lib/hypervisor/hv_kvm/__init__.py \
544         lib/hypervisor/hv_kvm/monitor.py \
545         lib/hypervisor/hv_kvm/netdev.py
546
547 jqueue_PYTHON = \
548         lib/jqueue/__init__.py \
549         lib/jqueue/exec.py
550
551 storage_PYTHON = \
552         lib/storage/__init__.py \
553         lib/storage/bdev.py \
554         lib/storage/base.py \
555         lib/storage/container.py \
556         lib/storage/drbd.py \
557         lib/storage/drbd_info.py \
558         lib/storage/drbd_cmdgen.py \
559         lib/storage/extstorage.py \
560         lib/storage/filestorage.py \
561         lib/storage/gluster.py
562
563 rapi_PYTHON = \
564         lib/rapi/__init__.py \
565         lib/rapi/baserlib.py \
566         lib/rapi/client.py \
567         lib/rapi/client_utils.py \
568         lib/rapi/connector.py \
569         lib/rapi/rlib2.py \
570         lib/rapi/testutils.py
571
572 http_PYTHON = \
573         lib/http/__init__.py \
574         lib/http/auth.py \
575         lib/http/client.py \
576         lib/http/server.py
577
578 confd_PYTHON = \
579         lib/confd/__init__.py \
580         lib/confd/client.py
581
582 masterd_PYTHON = \
583         lib/masterd/__init__.py \
584         lib/masterd/iallocator.py \
585         lib/masterd/instance.py
586
587 impexpd_PYTHON = \
588         lib/impexpd/__init__.py
589
590 watcher_PYTHON = \
591         lib/watcher/__init__.py \
592         lib/watcher/nodemaint.py \
593         lib/watcher/state.py
594
595 server_PYTHON = \
596         lib/server/__init__.py \
597         lib/server/masterd.py \
598         lib/server/noded.py \
599         lib/server/rapi.py
600
601 rpc_PYTHON = \
602         lib/rpc/__init__.py \
603         lib/rpc/client.py \
604         lib/rpc/errors.py \
605         lib/rpc/node.py \
606         lib/rpc/transport.py
607
608 rpc_stub_PYTHON = \
609         lib/rpc/stub/__init__.py
610
611 pytools_PYTHON = \
612         lib/tools/__init__.py \
613         lib/tools/burnin.py \
614         lib/tools/common.py \
615         lib/tools/ensure_dirs.py \
616         lib/tools/node_cleanup.py \
617         lib/tools/node_daemon_setup.py \
618         lib/tools/prepare_node_join.py \
619         lib/tools/ssh_update.py \
620         lib/tools/ssl_update.py \
621         lib/tools/cfgupgrade.py
622
623 utils_PYTHON = \
624         lib/utils/__init__.py \
625         lib/utils/algo.py \
626         lib/utils/filelock.py \
627         lib/utils/hash.py \
628         lib/utils/io.py \
629         lib/utils/livelock.py \
630         lib/utils/log.py \
631         lib/utils/lvm.py \
632         lib/utils/mlock.py \
633         lib/utils/nodesetup.py \
634         lib/utils/process.py \
635         lib/utils/retry.py \
636         lib/utils/security.py \
637         lib/utils/storage.py \
638         lib/utils/text.py \
639         lib/utils/tags.py \
640         lib/utils/version.py \
641         lib/utils/wrapper.py \
642         lib/utils/x509.py \
643         lib/utils/bitarrays.py
644
645 docinput = \
646         doc/admin.rst \
647         doc/cluster-keys-replacement.rst \
648         doc/cluster-merge.rst \
649         doc/conf.py \
650         doc/css/style.css \
651         doc/design-2.0.rst \
652         doc/design-2.1.rst \
653         doc/design-2.2.rst \
654         doc/design-2.3.rst \
655         doc/design-2.4.rst \
656         doc/design-2.5.rst \
657         doc/design-2.6.rst \
658         doc/design-2.7.rst \
659         doc/design-2.8.rst \
660         doc/design-2.9.rst \
661         doc/design-2.10.rst \
662         doc/design-2.11.rst \
663         doc/design-2.12.rst \
664         doc/design-2.13.rst \
665         doc/design-2.14.rst \
666         doc/design-2.15.rst \
667         doc/design-2.16.rst \
668         doc/design-2.17.rst \
669         doc/design-allocation-efficiency.rst \
670         doc/design-autorepair.rst \
671         doc/design-bulk-create.rst \
672         doc/design-ceph-ganeti-support.rst \
673         doc/design-configlock.rst \
674         doc/design-chained-jobs.rst \
675         doc/design-cmdlib-unittests.rst \
676         doc/design-cpu-pinning.rst \
677         doc/design-cpu-speed.rst \
678         doc/design-daemons.rst \
679         doc/design-dedicated-allocation.rst \
680         doc/design-device-uuid-name.rst \
681         doc/design-disk-conversion.rst \
682         doc/design-disks.rst \
683         doc/design-draft.rst \
684         doc/design-file-based-disks-ownership.rst \
685         doc/design-file-based-storage.rst \
686         doc/design-glusterfs-ganeti-support.rst \
687         doc/design-hotplug.rst \
688         doc/design-hroller.rst \
689         doc/design-hsqueeze.rst \
690         doc/design-htools-2.3.rst \
691         doc/design-http-server.rst \
692         doc/design-hugepages-support.rst \
693         doc/design-ifdown.rst \
694         doc/design-impexp2.rst \
695         doc/design-internal-shutdown.rst \
696         doc/design-kvmd.rst \
697         doc/design-location.rst \
698         doc/design-linuxha.rst \
699         doc/design-lu-generated-jobs.rst \
700         doc/design-macvtap.rst \
701         doc/design-memory-over-commitment.rst \
702         doc/design-migration-speed-hbal.rst \
703         doc/design-monitoring-agent.rst \
704         doc/design-move-instance-improvements.rst \
705         doc/design-multi-reloc.rst \
706         doc/design-multi-storage-htools.rst \
707         doc/design-multi-version-tests.rst \
708         doc/design-n-m-redundancy.rst \
709         doc/design-network.rst \
710         doc/design-network2.rst \
711         doc/design-node-add.rst \
712         doc/design-node-security.rst \
713         doc/design-oob.rst \
714         doc/design-openvswitch.rst \
715         doc/design-opportunistic-locking.rst \
716         doc/design-optables.rst \
717         doc/design-os.rst \
718         doc/design-ovf-support.rst \
719         doc/design-partitioned.rst \
720         doc/design-plain-redundancy.rst \
721         doc/design-performance-tests.rst \
722         doc/design-query-splitting.rst \
723         doc/design-query2.rst \
724         doc/design-query-splitting.rst \
725         doc/design-reason-trail.rst \
726         doc/design-repaird.rst \
727         doc/design-reservations.rst \
728         doc/design-resource-model.rst \
729         doc/design-restricted-commands.rst \
730         doc/design-scsi-kvm.rst \
731         doc/design-shared-storage.rst \
732         doc/design-shared-storage-redundancy.rst \
733         doc/design-ssh-ports.rst \
734         doc/design-storagetypes.rst \
735         doc/design-sync-rate-throttling.rst \
736         doc/design-systemd.rst \
737         doc/design-upgrade.rst \
738         doc/design-virtual-clusters.rst \
739         doc/design-x509-ca.rst \
740         doc/dev-codestyle.rst \
741         doc/devnotes.rst \
742         doc/glossary.rst \
743         doc/hooks.rst \
744         doc/iallocator.rst \
745         doc/index.rst \
746         doc/install-quick.rst \
747         doc/install.rst \
748         doc/locking.rst \
749         doc/manpages-disabled.rst \
750         doc/monitoring-query-format.rst \
751         doc/move-instance.rst \
752         doc/news.rst \
753         doc/ovfconverter.rst \
754         doc/rapi.rst \
755         doc/security.rst \
756         doc/upgrade.rst \
757         doc/virtual-cluster.rst \
758         doc/walkthrough.rst
759
760 # Generates file names such as "doc/man-gnt-instance.rst"
761 mandocrst = $(addprefix doc/man-,$(notdir $(manrst)))
762
763 # Haskell programs to be installed in $PREFIX/bin
764 HS_BIN_PROGS=src/htools
765
766 # Haskell programs to be installed in the MYEXECLIB dir
767 if ENABLE_MOND
768 HS_MYEXECLIB_PROGS=src/mon-collector
769 else
770 HS_MYEXECLIB_PROGS=
771 endif
772
773 # Haskell programs to be compiled by "make really-all"
774 HS_COMPILE_PROGS = \
775         src/ganeti-kvmd \
776         src/ganeti-wconfd \
777         src/hconfd \
778         src/hluxid \
779         src/hs2py \
780         src/rpc-test
781 if ENABLE_MOND
782 HS_COMPILE_PROGS += src/ganeti-mond src/ganeti-maintd
783 endif
784 if ENABLE_METADATA
785 HS_COMPILE_PROGS += src/ganeti-metad
786 endif
787
788 # All Haskell non-test programs to be compiled but not automatically installed
789 HS_PROGS = $(HS_BIN_PROGS) $(HS_MYEXECLIB_PROGS)
790
791 HS_BIN_ROLES = harep hbal hscan hspace hinfo hcheck hroller hsqueeze
792 HS_HTOOLS_PROGS = $(HS_BIN_ROLES) hail
793
794 # Haskell programs that cannot be disabled at configure (e.g., unlike
795 # 'mon-collector')
796 HS_DEFAULT_PROGS = \
797         $(HS_BIN_PROGS) \
798         test/hs/hpc-htools \
799         test/hs/hpc-mon-collector \
800         $(HS_COMPILE_PROGS)
801
802 if HTEST
803 HS_DEFAULT_PROGS += test/hs/htest
804 else
805 EXTRA_DIST += test/hs/htest.hs
806 endif
807
808 HS_ALL_PROGS = $(HS_DEFAULT_PROGS) $(HS_MYEXECLIB_PROGS)
809
810 HS_TEST_PROGS = $(filter test/%,$(HS_ALL_PROGS))
811 HS_SRC_PROGS = $(filter-out test/%,$(HS_ALL_PROGS))
812
813 HS_PROG_SRCS = $(patsubst %,%.hs,$(HS_DEFAULT_PROGS)) src/mon-collector.hs
814 HS_BUILT_TEST_HELPERS = $(HS_BIN_ROLES:%=test/hs/%) test/hs/hail
815
816 HFLAGS = \
817         -O -Wall -isrc \
818         -fwarn-monomorphism-restriction \
819         -fwarn-tabs \
820         -optP-include -optP$(HASKELL_PACKAGE_VERSIONS_FILE) \
821         -hide-all-packages \
822         `cat $(HASKELL_PACKAGE_IDS_FILE)` \
823         $(GHC_BYVERSION_FLAGS)
824 if DEVELOPER_MODE
825 HFLAGS += -Werror
826 endif
827
828 HTEST_SUFFIX = hpc
829 HPROF_SUFFIX = prof
830
831 DEP_SUFFIXES =
832 if GHC_LE_76
833 DEP_SUFFIXES += -dep-suffix $(HPROF_SUFFIX) -dep-suffix $(HTEST_SUFFIX)
834 else
835 # GHC >= 7.8 stopped putting underscores into -dep-suffix by itself
836 # (https://ghc.haskell.org/trac/ghc/ticket/9749) so we have to put them.
837 # It also needs -dep-suffix "" for the .o file.
838 DEP_SUFFIXES += -dep-suffix $(HPROF_SUFFIX)_ -dep-suffix $(HTEST_SUFFIX)_ \
839         -dep-suffix ""
840 endif
841
842 # GHC > 7.6 needs -dynamic-too when using Template Haskell since its
843 # ghci is switched to loading dynamic libraries by default.
844 # It must only be used in non-profiling GHC invocations.
845 # We also don't use it in compilations that use HTEST_SUFFIX (which are
846 # compiled with -fhpc) because HPC coverage doesn't interact well with
847 # GHCI shared lib loading (https://ghc.haskell.org/trac/ghc/ticket/9762).
848 HFLAGS_DYNAMIC =
849 if !GHC_LE_76
850 HFLAGS_DYNAMIC += -dynamic-too
851 endif
852
853 if HPROFILE
854 HPROFFLAGS = -prof -fprof-auto-top -osuf $(HPROF_SUFFIX)_o \
855         -hisuf $(HPROF_SUFFIX)_hi -rtsopts
856 endif
857 if HCOVERAGE
858 HFLAGS += -fhpc
859 endif
860 if HTEST
861 HFLAGS += -DTEST
862 endif
863
864 HTEST_FLAGS = $(HFLAGS) -fhpc -itest/hs \
865         -osuf $(HTEST_SUFFIX)_o \
866         -hisuf $(HTEST_SUFFIX)_hi
867
868 # extra flags that can be overriden on the command line (e.g. -Wwarn, etc.)
869 HEXTRA =
870 # combination of HEXTRA and HEXTRA_CONFIGURE
871 HEXTRA_COMBINED = $(HEXTRA) $(HEXTRA_CONFIGURE)
872
873 # extra flags used for test/hs/htest
874 # Only use the threaded runtime and run tests in parallel for GHC > 7.6. A bug
875 # in base that wasn't fixed until 4.7.0.0 in GHC 7.8 causes random file lock
876 # errors in the JQueue tests with the threaded runtime.
877 # See https://ghc.haskell.org/trac/ghc/ticket/7646
878 if GHC_LE_76
879 HEXTRA_TEST =
880 else
881 HEXTRA_TEST = -threaded -with-rtsopts=-N
882 endif
883
884 # exclude options for coverage reports
885 HPCEXCL = --exclude Main \
886         --exclude Ganeti.Constants \
887         --exclude Ganeti.HTools.QC \
888         --exclude Ganeti.THH \
889         --exclude Ganeti.Version \
890         --exclude Test.Ganeti.Attoparsec \
891         --exclude Test.Ganeti.TestCommon \
892         --exclude Test.Ganeti.TestHTools \
893         --exclude Test.Ganeti.TestHelper \
894         --exclude Test.Ganeti.TestImports \
895         $(patsubst src.%,--exclude Test.%,$(subst /,.,$(patsubst %.hs,%, $(HS_LIB_SRCS))))
896
897 HS_LIB_SRCS = \
898         src/Ganeti/Prelude.hs \
899         src/Ganeti/BasicTypes.hs \
900         src/Ganeti/Codec.hs \
901         src/Ganeti/Common.hs \
902         src/Ganeti/Compat.hs \
903         src/Ganeti/Confd/Client.hs \
904         src/Ganeti/Confd/ClientFunctions.hs \
905         src/Ganeti/Confd/Server.hs \
906         src/Ganeti/Confd/Types.hs \
907         src/Ganeti/Confd/Utils.hs \
908         src/Ganeti/Config.hs \
909         src/Ganeti/ConfigReader.hs \
910         src/Ganeti/Constants.hs \
911         src/Ganeti/ConstantUtils.hs \
912         src/Ganeti/Cpu/LoadParser.hs \
913         src/Ganeti/Cpu/Types.hs \
914         src/Ganeti/Curl/Multi.hs \
915         src/Ganeti/Daemon.hs \
916         src/Ganeti/Daemon/Utils.hs \
917         src/Ganeti/DataCollectors.hs \
918         src/Ganeti/DataCollectors/CLI.hs \
919         src/Ganeti/DataCollectors/CPUload.hs \
920         src/Ganeti/DataCollectors/Diagnose.hs \
921         src/Ganeti/DataCollectors/Diskstats.hs \
922         src/Ganeti/DataCollectors/Drbd.hs \
923         src/Ganeti/DataCollectors/InstStatus.hs \
924         src/Ganeti/DataCollectors/InstStatusTypes.hs \
925         src/Ganeti/DataCollectors/KvmRSS.hs \
926         src/Ganeti/DataCollectors/Lv.hs \
927         src/Ganeti/DataCollectors/Program.hs \
928         src/Ganeti/DataCollectors/Types.hs \
929         src/Ganeti/DataCollectors/XenCpuLoad.hs \
930         src/Ganeti/Errors.hs \
931         src/Ganeti/HTools/AlgorithmParams.hs \
932         src/Ganeti/HTools/Backend/IAlloc.hs \
933         src/Ganeti/HTools/Backend/Luxi.hs \
934         src/Ganeti/HTools/Backend/MonD.hs \
935         src/Ganeti/HTools/Backend/Rapi.hs \
936         src/Ganeti/HTools/Backend/Simu.hs \
937         src/Ganeti/HTools/Backend/Text.hs \
938         src/Ganeti/HTools/CLI.hs \
939         src/Ganeti/HTools/Cluster.hs \
940         src/Ganeti/HTools/Cluster/AllocatePrimitives.hs \
941         src/Ganeti/HTools/Cluster/AllocateSecondary.hs \
942         src/Ganeti/HTools/Cluster/AllocationSolution.hs \
943         src/Ganeti/HTools/Cluster/Evacuate.hs \
944         src/Ganeti/HTools/Cluster/Metrics.hs \
945         src/Ganeti/HTools/Cluster/MetricsComponents.hs \
946         src/Ganeti/HTools/Cluster/MetricsTH.hs \
947         src/Ganeti/HTools/Cluster/Moves.hs \
948         src/Ganeti/HTools/Cluster/Utils.hs \
949         src/Ganeti/HTools/Container.hs \
950         src/Ganeti/HTools/Dedicated.hs \
951         src/Ganeti/HTools/ExtLoader.hs \
952         src/Ganeti/HTools/GlobalN1.hs \
953         src/Ganeti/HTools/Graph.hs \
954         src/Ganeti/HTools/Group.hs \
955         src/Ganeti/HTools/Instance.hs \
956         src/Ganeti/HTools/Loader.hs \
957         src/Ganeti/HTools/Nic.hs \
958         src/Ganeti/HTools/Node.hs \
959         src/Ganeti/HTools/PeerMap.hs \
960         src/Ganeti/HTools/Program/Hail.hs \
961         src/Ganeti/HTools/Program/Harep.hs \
962         src/Ganeti/HTools/Program/Hbal.hs \
963         src/Ganeti/HTools/Program/Hcheck.hs \
964         src/Ganeti/HTools/Program/Hinfo.hs \
965         src/Ganeti/HTools/Program/Hscan.hs \
966         src/Ganeti/HTools/Program/Hspace.hs \
967         src/Ganeti/HTools/Program/Hsqueeze.hs \
968         src/Ganeti/HTools/Program/Hroller.hs \
969         src/Ganeti/HTools/Program/Main.hs \
970         src/Ganeti/HTools/RedundancyLevel.hs \
971         src/Ganeti/HTools/Repair.hs \
972         src/Ganeti/HTools/Tags.hs \
973         src/Ganeti/HTools/Tags/Constants.hs \
974         src/Ganeti/HTools/Types.hs \
975         src/Ganeti/Hypervisor/Xen.hs \
976         src/Ganeti/Hypervisor/Xen/XmParser.hs \
977         src/Ganeti/Hypervisor/Xen/Types.hs \
978         src/Ganeti/Hash.hs \
979         src/Ganeti/Hs2Py/GenConstants.hs \
980         src/Ganeti/Hs2Py/GenOpCodes.hs \
981         src/Ganeti/Hs2Py/OpDoc.hs \
982         src/Ganeti/JQScheduler.hs \
983         src/Ganeti/JQScheduler/Filtering.hs \
984         src/Ganeti/JQScheduler/ReasonRateLimiting.hs \
985         src/Ganeti/JQScheduler/Types.hs \
986         src/Ganeti/JQueue.hs \
987         src/Ganeti/JQueue/Lens.hs \
988         src/Ganeti/JQueue/Objects.hs \
989         src/Ganeti/JSON.hs \
990         src/Ganeti/Jobs.hs \
991         src/Ganeti/Kvmd.hs \
992         src/Ganeti/Lens.hs \
993         src/Ganeti/Locking/Allocation.hs \
994         src/Ganeti/Locking/Types.hs \
995         src/Ganeti/Locking/Locks.hs \
996         src/Ganeti/Locking/Waiting.hs \
997         src/Ganeti/Logging.hs \
998         src/Ganeti/Logging/Lifted.hs \
999         src/Ganeti/Logging/WriterLog.hs \
1000         src/Ganeti/Luxi.hs \
1001         src/Ganeti/MaintD/Autorepairs.hs \
1002         src/Ganeti/MaintD/Balance.hs \
1003         src/Ganeti/MaintD/CleanupIncidents.hs \
1004         src/Ganeti/MaintD/CollectIncidents.hs \
1005         src/Ganeti/MaintD/FailIncident.hs \
1006         src/Ganeti/MaintD/HandleIncidents.hs \
1007         src/Ganeti/MaintD/MemoryState.hs \
1008         src/Ganeti/MaintD/Server.hs \
1009         src/Ganeti/MaintD/Utils.hs \
1010         src/Ganeti/Network.hs \
1011         src/Ganeti/Objects.hs \
1012         src/Ganeti/Objects/BitArray.hs \
1013         src/Ganeti/Objects/Disk.hs \
1014         src/Ganeti/Objects/Instance.hs \
1015         src/Ganeti/Objects/HvState.hs \
1016         src/Ganeti/Objects/Lens.hs \
1017         src/Ganeti/Objects/Maintenance.hs \
1018         src/Ganeti/Objects/Nic.hs \
1019         src/Ganeti/OpCodes.hs \
1020         src/Ganeti/OpCodes/Lens.hs \
1021         src/Ganeti/OpParams.hs \
1022         src/Ganeti/Path.hs \
1023         src/Ganeti/Parsers.hs \
1024         src/Ganeti/PyValue.hs \
1025         src/Ganeti/Query/Cluster.hs \
1026         src/Ganeti/Query/Common.hs \
1027         src/Ganeti/Query/Exec.hs \
1028         src/Ganeti/Query/Export.hs \
1029         src/Ganeti/Query/Filter.hs \
1030         src/Ganeti/Query/FilterRules.hs \
1031         src/Ganeti/Query/Group.hs \
1032         src/Ganeti/Query/Instance.hs \
1033         src/Ganeti/Query/Job.hs \
1034         src/Ganeti/Query/Language.hs \
1035         src/Ganeti/Query/Locks.hs \
1036         src/Ganeti/Query/Network.hs \
1037         src/Ganeti/Query/Node.hs \
1038         src/Ganeti/Query/Query.hs \
1039         src/Ganeti/Query/Server.hs \
1040         src/Ganeti/Query/Types.hs \
1041         src/Ganeti/PartialParams.hs \
1042         src/Ganeti/Rpc.hs \
1043         src/Ganeti/Runtime.hs \
1044         src/Ganeti/SlotMap.hs \
1045         src/Ganeti/Ssconf.hs \
1046         src/Ganeti/Storage/Diskstats/Parser.hs \
1047         src/Ganeti/Storage/Diskstats/Types.hs \
1048         src/Ganeti/Storage/Drbd/Parser.hs \
1049         src/Ganeti/Storage/Drbd/Types.hs \
1050         src/Ganeti/Storage/Lvm/LVParser.hs \
1051         src/Ganeti/Storage/Lvm/Types.hs \
1052         src/Ganeti/Storage/Utils.hs \
1053         src/Ganeti/THH.hs \
1054         src/Ganeti/THH/Field.hs \
1055         src/Ganeti/THH/HsRPC.hs \
1056         src/Ganeti/THH/PyRPC.hs \
1057         src/Ganeti/THH/PyType.hs \
1058         src/Ganeti/THH/Types.hs \
1059         src/Ganeti/THH/RPC.hs \
1060         src/Ganeti/Types.hs \
1061         src/Ganeti/UDSServer.hs \
1062         src/Ganeti/Utils.hs \
1063         src/Ganeti/Utils/Atomic.hs \
1064         src/Ganeti/Utils/AsyncWorker.hs \
1065         src/Ganeti/Utils/Http.hs \
1066         src/Ganeti/Utils/IORef.hs \
1067         src/Ganeti/Utils/Livelock.hs \
1068         src/Ganeti/Utils/Monad.hs \
1069         src/Ganeti/Utils/MultiMap.hs \
1070         src/Ganeti/Utils/MVarLock.hs \
1071         src/Ganeti/Utils/Random.hs \
1072         src/Ganeti/Utils/Statistics.hs \
1073         src/Ganeti/Utils/UniStd.hs \
1074         src/Ganeti/Utils/Validate.hs \
1075         src/Ganeti/VCluster.hs \
1076         src/Ganeti/WConfd/ConfigState.hs \
1077         src/Ganeti/WConfd/ConfigModifications.hs \
1078         src/Ganeti/WConfd/ConfigVerify.hs \
1079         src/Ganeti/WConfd/ConfigWriter.hs \
1080         src/Ganeti/WConfd/Client.hs \
1081         src/Ganeti/WConfd/Core.hs \
1082         src/Ganeti/WConfd/DeathDetection.hs \
1083         src/Ganeti/WConfd/Language.hs \
1084         src/Ganeti/WConfd/Monad.hs \
1085         src/Ganeti/WConfd/Persistent.hs \
1086         src/Ganeti/WConfd/Server.hs \
1087         src/Ganeti/WConfd/Ssconf.hs \
1088         src/Ganeti/WConfd/TempRes.hs
1089
1090 if ENABLE_MOND
1091 HS_LIB_SRCS += src/Ganeti/Monitoring/Server.hs
1092 else
1093 EXTRA_DIST += src/Ganeti/Monitoring/Server.hs
1094 endif
1095
1096 if ENABLE_METADATA
1097 HS_LIB_SRCS += \
1098         src/Ganeti/Metad/Config.hs \
1099         src/Ganeti/Metad/ConfigCore.hs \
1100         src/Ganeti/Metad/ConfigServer.hs \
1101         src/Ganeti/Metad/Server.hs \
1102         src/Ganeti/Metad/Types.hs \
1103         src/Ganeti/Metad/WebServer.hs
1104 else
1105 EXTRA_DIST += \
1106         src/Ganeti/Metad/Config.hs \
1107         src/Ganeti/Metad/ConfigCore.hs \
1108         src/Ganeti/Metad/ConfigServer.hs \
1109         src/Ganeti/Metad/Server.hs \
1110         src/Ganeti/Metad/Types.hs \
1111         src/Ganeti/Metad/WebServer.hs
1112 endif
1113
1114 HS_TEST_SRCS = \
1115         test/hs/Test/AutoConf.hs \
1116         test/hs/Test/Ganeti/Attoparsec.hs \
1117         test/hs/Test/Ganeti/BasicTypes.hs \
1118         test/hs/Test/Ganeti/Common.hs \
1119         test/hs/Test/Ganeti/Confd/Types.hs \
1120         test/hs/Test/Ganeti/Confd/Utils.hs \
1121         test/hs/Test/Ganeti/Constants.hs \
1122         test/hs/Test/Ganeti/Daemon.hs \
1123         test/hs/Test/Ganeti/Errors.hs \
1124         test/hs/Test/Ganeti/HTools/Backend/MonD.hs \
1125         test/hs/Test/Ganeti/HTools/Backend/Simu.hs \
1126         test/hs/Test/Ganeti/HTools/Backend/Text.hs \
1127         test/hs/Test/Ganeti/HTools/CLI.hs \
1128         test/hs/Test/Ganeti/HTools/Cluster.hs \
1129         test/hs/Test/Ganeti/HTools/Container.hs \
1130         test/hs/Test/Ganeti/HTools/Graph.hs \
1131         test/hs/Test/Ganeti/HTools/Instance.hs \
1132         test/hs/Test/Ganeti/HTools/Loader.hs \
1133         test/hs/Test/Ganeti/HTools/Node.hs \
1134         test/hs/Test/Ganeti/HTools/PeerMap.hs \
1135         test/hs/Test/Ganeti/HTools/Types.hs \
1136         test/hs/Test/Ganeti/Hypervisor/Xen/XmParser.hs \
1137         test/hs/Test/Ganeti/JSON.hs \
1138         test/hs/Test/Ganeti/Jobs.hs \
1139         test/hs/Test/Ganeti/JQScheduler.hs \
1140         test/hs/Test/Ganeti/JQueue.hs \
1141         test/hs/Test/Ganeti/JQueue/Objects.hs \
1142         test/hs/Test/Ganeti/Kvmd.hs \
1143         test/hs/Test/Ganeti/Luxi.hs \
1144         test/hs/Test/Ganeti/Locking/Allocation.hs \
1145         test/hs/Test/Ganeti/Locking/Locks.hs \
1146         test/hs/Test/Ganeti/Locking/Waiting.hs \
1147         test/hs/Test/Ganeti/Network.hs \
1148         test/hs/Test/Ganeti/PartialParams.hs \
1149         test/hs/Test/Ganeti/Objects.hs \
1150         test/hs/Test/Ganeti/Objects/BitArray.hs \
1151         test/hs/Test/Ganeti/OpCodes.hs \
1152         test/hs/Test/Ganeti/Query/Aliases.hs \
1153         test/hs/Test/Ganeti/Query/Filter.hs \
1154         test/hs/Test/Ganeti/Query/Instance.hs \
1155         test/hs/Test/Ganeti/Query/Language.hs \
1156         test/hs/Test/Ganeti/Query/Network.hs \
1157         test/hs/Test/Ganeti/Query/Query.hs \
1158         test/hs/Test/Ganeti/Rpc.hs \
1159         test/hs/Test/Ganeti/Runtime.hs \
1160         test/hs/Test/Ganeti/SlotMap.hs \
1161         test/hs/Test/Ganeti/Ssconf.hs \
1162         test/hs/Test/Ganeti/Storage/Diskstats/Parser.hs \
1163         test/hs/Test/Ganeti/Storage/Drbd/Parser.hs \
1164         test/hs/Test/Ganeti/Storage/Drbd/Types.hs \
1165         test/hs/Test/Ganeti/Storage/Lvm/LVParser.hs \
1166         test/hs/Test/Ganeti/THH.hs \
1167         test/hs/Test/Ganeti/THH/Types.hs \
1168         test/hs/Test/Ganeti/TestCommon.hs \
1169         test/hs/Test/Ganeti/TestHTools.hs \
1170         test/hs/Test/Ganeti/TestHelper.hs \
1171         test/hs/Test/Ganeti/Types.hs \
1172         test/hs/Test/Ganeti/Utils.hs \
1173         test/hs/Test/Ganeti/Utils/MultiMap.hs \
1174         test/hs/Test/Ganeti/Utils/Statistics.hs \
1175         test/hs/Test/Ganeti/WConfd/Ssconf.hs \
1176         test/hs/Test/Ganeti/WConfd/TempRes.hs
1177
1178
1179 HS_LIBTEST_SRCS = $(HS_LIB_SRCS) $(HS_TEST_SRCS)
1180
1181 HS_BUILT_SRCS = \
1182         test/hs/Test/Ganeti/TestImports.hs \
1183         src/AutoConf.hs \
1184         src/Ganeti/Hs2Py/ListConstants.hs \
1185         src/Ganeti/Curl/Internal.hs \
1186         src/Ganeti/Version.hs
1187 HS_BUILT_SRCS_IN = \
1188         $(patsubst %,%.in,$(filter-out src/Ganeti/Curl/Internal.hs,$(HS_BUILT_SRCS))) \
1189         src/Ganeti/Curl/Internal.hsc \
1190         lib/_constants.py.in \
1191         lib/opcodes.py.in_after \
1192         lib/opcodes.py.in_before
1193
1194 HS_LIBTESTBUILT_SRCS = $(HS_LIBTEST_SRCS) $(HS_BUILT_SRCS)
1195
1196 $(RUN_IN_TEMPDIR): | stamp-directories
1197
1198 doc/html/index.html: ENABLE_MANPAGES =
1199 doc/man-html/index.html: ENABLE_MANPAGES = 1
1200 doc/man-html/index.html: doc/manpages-enabled.rst $(mandocrst)
1201
1202 if HAS_SPHINX_PRE13
1203         SPHINX_HTML_THEME=default
1204 else
1205         SPHINX_HTML_THEME=classic
1206 endif
1207 # Note: we use here an order-only prerequisite, as the contents of
1208 # _constants.py are not actually influencing the html build output: it
1209 # has to exist in order for the sphinx module to be loaded
1210 # successfully, but we certainly don't want the docs to be rebuilt if
1211 # it changes
1212 doc/html/index.html doc/man-html/index.html: $(docinput) doc/conf.py \
1213         configure.ac $(RUN_IN_TEMPDIR) lib/build/sphinx_ext.py \
1214         lib/build/shell_example_lexer.py lib/ht.py \
1215         doc/css/style.css lib/rapi/connector.py lib/rapi/rlib2.py \
1216         autotools/sphinx-wrapper | $(built_python_sources)
1217         @test -n "$(SPHINX)" || \
1218             { echo 'sphinx-build' not found during configure; exit 1; }
1219 if !MANPAGES_IN_DOC
1220         if test -n '$(ENABLE_MANPAGES)'; then \
1221           echo 'Man pages in documentation were disabled at configure time' >&2; \
1222           exit 1; \
1223         fi
1224 endif
1225 ## Sphinx provides little control over what content should be included. Some
1226 ## mechanisms exist, but they all have drawbacks or actual issues. Since we
1227 ## build two different versions of the documentation--once without man pages and
1228 ## once, if enabled, with them--some control is necessary. xmpp-wrapper provides
1229 ## us with this, but requires running in a temporary directory. It moves the
1230 ## correct files into place depending on environment variables.
1231         dir=$(dir $@) && \
1232         @mkdir_p@ $$dir && \
1233         PYTHONPATH=. ENABLE_MANPAGES=$(ENABLE_MANPAGES) COPY_DOC=1 \
1234         HTML_THEME=$(SPHINX_HTML_THEME) \
1235         $(RUN_IN_TEMPDIR) autotools/sphinx-wrapper $(SPHINX) -q -W -b html \
1236                 -d . \
1237                 -D version="$(VERSION_MAJOR).$(VERSION_MINOR)" \
1238                 -D release="$(PACKAGE_VERSION)" \
1239                 -D graphviz_dot="$(DOT)" \
1240         doc $(CURDIR)/$$dir && \
1241         rm -f $$dir/.buildinfo $$dir/objects.inv
1242         touch $@
1243
1244 doc/html: doc/html/index.html
1245
1246 doc/man-html: doc/man-html/index.html
1247
1248 doc/install-quick.rst: INSTALL
1249 doc/news.rst: NEWS
1250 doc/upgrade.rst: UPGRADE
1251
1252 doc/install-quick.rst doc/news.rst doc/upgrade.rst:
1253         set -e; \
1254         { echo '.. This file is automatically updated at build time from $<.'; \
1255           echo '.. Do not edit.'; \
1256           echo; \
1257           cat $<; \
1258         } > $@
1259
1260 doc/manpages-enabled.rst: Makefile | $(built_base_sources)
1261         { echo '.. This file is automatically generated, do not edit!'; \
1262           echo ''; \
1263           echo 'Man pages'; \
1264           echo '========='; \
1265           echo; \
1266           echo '.. toctree::'; \
1267           echo '   :maxdepth: 1'; \
1268           echo; \
1269           for i in $(notdir $(mandocrst)); do \
1270             echo "   $$i"; \
1271           done | LC_ALL=C sort; \
1272         } > $@
1273
1274 doc/man-%.rst: man/%.gen Makefile $(REPLACE_VARS_SED) | $(built_base_sources)
1275 if MANPAGES_IN_DOC
1276         { echo '.. This file is automatically updated at build time from $<.'; \
1277           echo '.. Do not edit.'; \
1278           echo; \
1279           echo "$*"; \
1280           echo '=========================================='; \
1281           tail -n +3 $< | sed -f $(REPLACE_VARS_SED); \
1282         } > $@
1283 else
1284         echo 'Man pages in documentation were disabled at configure time' >&2; \
1285         exit 1;
1286 endif
1287
1288 doc/users/%: doc/users/%.in Makefile $(REPLACE_VARS_SED)
1289         cat $< | sed -f $(REPLACE_VARS_SED) | LC_ALL=C sort | uniq | (grep -v '^root' || true) > $@
1290
1291 userspecs = \
1292         doc/users/users \
1293         doc/users/groups \
1294         doc/users/groupmemberships
1295
1296 # Things to build but not to install (add it to EXTRA_DIST if it should be
1297 # distributed)
1298 noinst_DATA = \
1299         $(BUILT_EXAMPLES) \
1300         doc/examples/bash_completion \
1301         doc/examples/bash_completion-debug \
1302         $(userspecs) \
1303         $(manhtml)
1304
1305 if HAS_SPHINX
1306 if MANPAGES_IN_DOC
1307 noinst_DATA += doc/man-html
1308 else
1309 noinst_DATA += doc/html
1310 endif
1311 endif
1312
1313 gnt_scripts = \
1314         scripts/gnt-backup \
1315         scripts/gnt-cluster \
1316         scripts/gnt-debug \
1317         scripts/gnt-group \
1318         scripts/gnt-instance \
1319         scripts/gnt-job \
1320         scripts/gnt-network \
1321         scripts/gnt-node \
1322         scripts/gnt-os \
1323         scripts/gnt-storage \
1324         scripts/gnt-filter
1325
1326 gnt_scripts_basenames = \
1327         $(patsubst scripts/%,%,$(patsubst daemons/%,%,$(gnt_scripts) $(gnt_python_sbin_SCRIPTS)))
1328
1329 gnt_python_sbin_SCRIPTS = \
1330         $(PYTHON_BOOTSTRAP_SBIN)
1331
1332 gntpython_SCRIPTS = $(gnt_scripts)
1333
1334 PYTHON_BOOTSTRAP_SBIN = \
1335         daemons/ganeti-noded \
1336         daemons/ganeti-rapi \
1337         daemons/ganeti-watcher
1338
1339 PYTHON_BOOTSTRAP = \
1340         tools/burnin \
1341         tools/ensure-dirs \
1342         tools/node-cleanup \
1343         tools/node-daemon-setup \
1344         tools/prepare-node-join \
1345         tools/ssh-update \
1346         tools/ssl-update
1347
1348 qa_scripts = \
1349         qa/__init__.py \
1350         qa/ganeti-qa.py \
1351         qa/qa_cluster.py \
1352         qa/qa_config.py \
1353         qa/qa_daemon.py \
1354         qa/qa_env.py \
1355         qa/qa_error.py \
1356         qa/qa_filters.py \
1357         qa/qa_group.py \
1358         qa/qa_instance.py \
1359         qa/qa_instance_utils.py \
1360         qa/qa_iptables.py \
1361         qa/qa_job.py \
1362         qa/qa_job_utils.py \
1363         qa/qa_logging.py \
1364         qa/qa_monitoring.py \
1365         qa/qa_network.py \
1366         qa/qa_node.py \
1367         qa/qa_os.py \
1368         qa/qa_performance.py \
1369         qa/qa_rapi.py \
1370         qa/qa_tags.py \
1371         qa/qa_utils.py
1372
1373 bin_SCRIPTS = $(HS_BIN_PROGS)
1374 install-exec-hook:
1375         @mkdir_p@ $(DESTDIR)$(iallocatorsdir)
1376 # FIXME: this is a hardcoded logic, instead of auto-resolving
1377         $(LN_S) -f ../../../bin/htools \
1378           $(DESTDIR)$(iallocatorsdir)/hail
1379         for role in $(HS_BIN_ROLES); do \
1380           $(LN_S) -f htools $(DESTDIR)$(bindir)/$$role ; \
1381         done
1382
1383 HS_SRCS = $(HS_LIBTESTBUILT_SRCS)
1384
1385 HS_MAKEFILE_GHC_SRCS = $(HS_SRC_PROGS:%=%.hs)
1386 if WANT_HSTESTS
1387 HS_MAKEFILE_GHC_SRCS += $(HS_TEST_PROGS:%=%.hs)
1388 endif
1389 Makefile.ghc: $(HS_MAKEFILE_GHC_SRCS) Makefile $(HASKELL_PACKAGE_VERSIONS_FILE) \
1390               | $(built_base_sources) $(HS_BUILT_SRCS)
1391         $(GHC) -M -dep-makefile $@ $(DEP_SUFFIXES) $(HFLAGS) $(HFLAGS_DYNAMIC) \
1392                 -itest/hs \
1393                 $(HEXTRA_COMBINED) $(HS_MAKEFILE_GHC_SRCS)
1394 # Since ghc -M does not generate dependency line for object files, dependencies
1395 # from a target executable seed object (e.g. src/hluxid.o) to objects which
1396 # finally will be linked to the target object (e.g. src/Ganeti/Daemon.o) are
1397 # missing in Makefile.ghc.
1398 # see: https://www.haskell.org/ghc/docs/7.6.2/html/users_guide/separate-compilation.html#makefile-dependencies
1399 # Following substitutions will add dependencies between object files which
1400 # corresponds to the interface file already there as a dependency for each
1401 # object listed in Makefile.ghc.
1402 # e.g. src/hluxid.o : src/Ganeti/Daemon.hi
1403 #        => src/hluxid.o : src/Ganeti/Daemon.hi src/Ganeti/Daemon.o
1404         sed -i -r -e 's/([^ ]+)\.hi$$/\1.hi \1.o/' -e 's/([^ ]+)_hi$$/\1_hi \1_o/' $@
1405
1406 @include_makefile_ghc@
1407
1408 # Contains the package-id flags for the current build: "-package-id" followed
1409 # by the name and hash of the package, one for each dependency.
1410 # Obtained from the setup-config using the Cabal API
1411 # (CabalDependenciesMacros.hs) after `cabal configure`.
1412 # This file is created along with HASKELL_PACKAGE_VERSIONS_FILE; if you want
1413 # to depend on it in a rule, depend on HASKELL_PACKAGE_VERSIONS_FILE instead.
1414 HASKELL_PACKAGE_IDS_FILE = ganeti.depsflags
1415
1416 # Defines the MIN_VERSION_* macros for all Haskell packages used in this
1417 # compilation.
1418 # The versions are determined using `cabal configure`, which takes them from
1419 # the ghc-pkg database.
1420 # At the moment, we don't support cabal sandboxes, so we use cabal configure
1421 # with the --user flag.
1422 # Note: `cabal configure` and CabalDependenciesMacros.hs perform no
1423 # downloading (only `cabal install` can do that).
1424 HASKELL_PACKAGE_VERSIONS_FILE = cabal_macros.h
1425
1426 $(HASKELL_PACKAGE_VERSIONS_FILE): Makefile ganeti.cabal \
1427                                   cabal/CabalDependenciesMacros.hs
1428         touch empty-cabal-config
1429         $(CABAL) --config-file=empty-cabal-config configure --user \
1430           -f`test $(HTEST) == yes && echo "htest" || echo "-htest"` \
1431           -f`test $(ENABLE_MOND) == True && echo "mond" || echo "-mond"` \
1432           -f`test $(ENABLE_METADATA) == True && echo "metad" || echo "-metad"`
1433         runhaskell $(abs_top_srcdir)/cabal/CabalDependenciesMacros.hs \
1434           ganeti.cabal \
1435           $(HASKELL_PACKAGE_IDS_FILE) \
1436           $(HASKELL_PACKAGE_VERSIONS_FILE)
1437
1438 # Like the %.o rule, but allows access to the test/hs directory.
1439 # This uses HFLAGS instead of HTEST_FLAGS because it's only for generating
1440 # object files (.o for GHC <= 7.6, .o/.so for newer GHCs) that are loaded
1441 # in GHCI when evaluating TH. The actual test-with-coverage .hpc_o files
1442 # are created in the `%.$(HTEST_SUFFIX)_o` rule.
1443 test/hs/%.o: $(HASKELL_PACKAGE_VERSIONS_FILE)
1444         @echo '[GHC|test]: $@ <- test/hs/$^'
1445         @set -o pipefail ; \
1446         $(GHC) -c $(HFLAGS) -itest/hs $(HFLAGS_DYNAMIC) \
1447                 $(HEXTRA_COMBINED) $(HEXTRA_TEST) $(@:%.o=%.hs) | \
1448                 sed '/^Loading package /d'
1449
1450 %.o: $(HASKELL_PACKAGE_VERSIONS_FILE)
1451         @echo '[GHC]: $@ <- $^'
1452         @set -o pipefail ; \
1453         $(GHC) -c $(HFLAGS) $(HFLAGS_DYNAMIC) \
1454                 $(HEXTRA_COMBINED) $(@:%.o=%.hs) | \
1455                 sed '/^Loading package /d'
1456
1457 # For TH+profiling we need to compile twice: Once without profiling,
1458 # and then once with profiling. See
1459 # http://www.haskell.org/ghc/docs/7.0.4/html/users_guide/template-haskell.html#id636646
1460 if HPROFILE
1461 %.$(HPROF_SUFFIX)_o: %.o
1462         @echo '[GHC|prof]: $@ <- $^'
1463         @set -o pipefail ; \
1464         $(GHC) -c $(HFLAGS) \
1465           $(HPROFFLAGS) \
1466                 $(HEXTRA_COMBINED) \
1467                 $(@:%.$(HPROF_SUFFIX)_o=%.hs) | \
1468                 sed '/^Loading package /d'
1469 endif
1470
1471 # We depend on the non-test .o file here because we need the corresponding .so
1472 # file for GHC > 7.6 ghci dynamic loading for TH, and creating the .o file
1473 # will create the .so file since we use -dynamic-too (using the `test/hs/%.o`
1474 # rule).
1475 %.$(HTEST_SUFFIX)_o: %.o
1476         @echo '[GHC|test]: $@ <- $^'
1477         @set -o pipefail ; \
1478         $(GHC) -c $(HTEST_FLAGS) \
1479                 $(HEXTRA_COMBINED) $(HEXTRA_TEST) $(@:%.$(HTEST_SUFFIX)_o=%.hs) | \
1480                 sed '/^Loading package /d'
1481
1482 %.hi: %.o ;
1483 %.$(HTEST_SUFFIX)_hi: %.$(HTEST_SUFFIX)_o ;
1484 %.$(HPROF_SUFFIX)_hi: %.$(HPROF_SUFFIX)_o ;
1485
1486 if HPROFILE
1487 $(HS_SRC_PROGS): %: %.$(HPROF_SUFFIX)_o | stamp-directories
1488         @echo '[GHC-link]: $@'
1489         $(GHC) $(HFLAGS) $(HPROFFLAGS) \
1490                 $(HEXTRA_COMBINED) --make $(@:%=%.hs)
1491 else
1492 $(HS_SRC_PROGS): %: %.o | stamp-directories
1493         @echo '[GHC-link]: $@'
1494         $(GHC) $(HFLAGS) $(HFLAGS_DYNAMIC) \
1495                 $(HEXTRA_COMBINED) --make $(@:%=%.hs)
1496 endif
1497         @rm -f $(notdir $@).tix
1498         @touch "$@"
1499
1500 $(HS_TEST_PROGS): %: %.$(HTEST_SUFFIX)_o \
1501                            | stamp-directories $(built_python_sources)
1502         @if [ "$(HS_NODEV)" ]; then \
1503           echo "Error: cannot run unittests without the development" \
1504                " libraries (see devnotes.rst)" 1>&2; \
1505           exit 1; \
1506         fi
1507         @echo '[GHC-link|test]: $@'
1508         $(GHC) $(HTEST_FLAGS) \
1509                 $(HEXTRA_COMBINED) $(HEXTRA_TEST) --make $(@:%=%.hs)
1510         @rm -f $(notdir $@).tix
1511         @touch "$@"
1512
1513 dist_sbin_SCRIPTS = \
1514         tools/ganeti-listrunner
1515
1516 nodist_sbin_SCRIPTS = \
1517         daemons/ganeti-cleaner \
1518         src/ganeti-kvmd \
1519         src/ganeti-luxid \
1520         src/ganeti-confd \
1521         src/ganeti-wconfd
1522
1523 src/ganeti-luxid: src/hluxid
1524         cp -f $< $@
1525
1526 # strip path prefixes off the sbin scripts
1527 all_sbin_scripts = \
1528         $(patsubst tools/%,%,$(patsubst daemons/%,%,$(patsubst scripts/%,%,\
1529         $(patsubst src/%,%,$(dist_sbin_SCRIPTS) $(nodist_sbin_SCRIPTS)))))
1530
1531 src/ganeti-confd: src/hconfd
1532         cp -f $< $@
1533
1534 if ENABLE_MOND
1535 nodist_sbin_SCRIPTS += src/ganeti-mond src/ganeti-maintd
1536 endif
1537
1538 if ENABLE_METADATA
1539 nodist_sbin_SCRIPTS += src/ganeti-metad
1540 endif
1541
1542 python_scripts = \
1543         tools/cfgshell \
1544         tools/cfgupgrade \
1545         tools/cfgupgrade12 \
1546         tools/cluster-merge \
1547         tools/confd-client \
1548         tools/fmtjson \
1549         tools/lvmstrap \
1550         tools/move-instance \
1551         tools/ovfconverter \
1552         tools/post-upgrade \
1553         tools/sanitize-config \
1554         tools/query-config
1555
1556 python_scripts_shebang = \
1557         $(patsubst tools/%,tools/shebang/%, $(python_scripts))
1558
1559 tools/shebang/%: tools/%
1560         mkdir -p tools/shebang
1561         head -1 $< | sed 's|#!/usr/bin/python|#!$(PYTHON)|' > $@
1562         echo '# Generated file; do not edit.' >> $@
1563         tail -n +2 $< >> $@
1564
1565 dist_tools_SCRIPTS = \
1566         tools/kvm-console-wrapper \
1567         tools/master-ip-setup \
1568         tools/xen-console-wrapper
1569
1570 dist_tools_python_SCRIPTS = \
1571         tools/burnin
1572
1573 nodist_tools_python_SCRIPTS = \
1574         tools/node-cleanup \
1575         $(python_scripts_shebang)
1576
1577 tools_python_basenames = \
1578         $(patsubst shebang/%,%,\
1579         $(patsubst tools/%,%,\
1580         $(dist_tools_python_SCRIPTS) $(nodist_tools_python_SCRIPTS)))
1581
1582 nodist_tools_SCRIPTS = \
1583         tools/users-setup \
1584         tools/vcluster-setup
1585
1586 tools_basenames = $(patsubst tools/%,%,$(nodist_tools_SCRIPTS) $(dist_tools_SCRIPTS))
1587
1588 pkglib_python_scripts = \
1589         daemons/import-export \
1590         tools/check-cert-expired
1591
1592 nodist_pkglib_python_scripts = \
1593         tools/ensure-dirs \
1594         tools/node-daemon-setup \
1595         tools/prepare-node-join \
1596         tools/ssh-update \
1597         tools/ssl-update
1598
1599 pkglib_python_basenames = \
1600         $(patsubst daemons/%,%,$(patsubst tools/%,%,\
1601         $(pkglib_python_scripts) $(nodist_pkglib_python_scripts)))
1602
1603 myexeclib_SCRIPTS = \
1604         daemons/daemon-util \
1605         tools/kvm-ifup \
1606         tools/kvm-ifup-os \
1607         tools/xen-ifup-os \
1608         tools/vif-ganeti \
1609         tools/vif-ganeti-metad \
1610         tools/net-common \
1611         $(HS_MYEXECLIB_PROGS)
1612
1613 # compute the basenames of the myexeclib_scripts
1614 myexeclib_scripts_basenames = \
1615         $(patsubst tools/%,%,$(patsubst daemons/%,%,$(patsubst src/%,%,$(myexeclib_SCRIPTS))))
1616
1617 EXTRA_DIST += \
1618         NEWS \
1619         UPGRADE \
1620         epydoc.conf.in \
1621         pylintrc \
1622         pylintrc-test \
1623         autotools/build-bash-completion \
1624         autotools/build-rpc \
1625         autotools/check-header \
1626         autotools/check-imports \
1627         autotools/check-man-dashes \
1628         autotools/check-man-references \
1629         autotools/check-man-warnings \
1630         autotools/check-news \
1631         autotools/check-python-code \
1632         autotools/check-tar \
1633         autotools/check-version \
1634         autotools/docpp \
1635         autotools/gen-py-coverage \
1636         autotools/print-py-constants \
1637         autotools/sphinx-wrapper \
1638         autotools/testrunner \
1639         autotools/wrong-hardcoded-paths \
1640         cabal/cabal-from-modules.py \
1641         $(RUN_IN_TEMPDIR) \
1642         daemons/daemon-util.in \
1643         daemons/ganeti-cleaner.in \
1644         $(pkglib_python_scripts) \
1645         devel/build_chroot \
1646         devel/cert_digest.py \
1647         devel/upload \
1648         devel/webserver \
1649         tools/kvm-ifup.in \
1650         tools/ifup-os.in \
1651         tools/vif-ganeti.in \
1652         tools/vif-ganeti-metad.in \
1653         tools/net-common.in \
1654         tools/vcluster-setup.in \
1655         $(python_scripts) \
1656         $(docinput) \
1657         doc/html \
1658         $(BUILT_EXAMPLES:%=%.in) \
1659         doc/examples/ganeti.default \
1660         doc/examples/ganeti.default-debug \
1661         doc/examples/hooks/ethers \
1662         doc/examples/gnt-debug/README \
1663         doc/examples/gnt-debug/delay0.json \
1664         doc/examples/gnt-debug/delay50.json \
1665         doc/examples/systemd/ganeti-master.target \
1666         doc/examples/systemd/ganeti-node.target \
1667         doc/examples/systemd/ganeti.service \
1668         doc/examples/systemd/ganeti.target \
1669         doc/users/groupmemberships.in \
1670         doc/users/groups.in \
1671         doc/users/users.in \
1672         ganeti.cabal \
1673         cabal/ganeti.template.cabal \
1674         cabal/CabalDependenciesMacros.hs \
1675         $(dist_TESTS) \
1676         $(TEST_FILES) \
1677         $(python_test_support) \
1678         $(python_test_utils) \
1679         man/footer.rst \
1680         $(manrst) \
1681         $(maninput) \
1682         qa/qa-sample.json \
1683         $(qa_scripts) \
1684         $(HS_LIBTEST_SRCS) $(HS_BUILT_SRCS_IN) \
1685         $(HS_PROG_SRCS) \
1686         src/lint-hints.hs \
1687         test/hs/cli-tests-defs.sh \
1688         test/hs/offline-test.sh \
1689         .ghci
1690
1691 man_MANS = \
1692         man/ganeti-cleaner.8 \
1693         man/ganeti-confd.8 \
1694         man/ganeti-luxid.8 \
1695         man/ganeti-listrunner.8 \
1696         man/ganeti-kvmd.8 \
1697         man/ganeti-mond.8 \
1698         man/ganeti-noded.8 \
1699         man/ganeti-os-interface.7 \
1700         man/ganeti-extstorage-interface.7 \
1701         man/ganeti-rapi.8 \
1702         man/ganeti-watcher.8 \
1703         man/ganeti-wconfd.8 \
1704         man/ganeti.7 \
1705         man/gnt-backup.8 \
1706         man/gnt-cluster.8 \
1707         man/gnt-debug.8 \
1708         man/gnt-group.8 \
1709         man/gnt-network.8 \
1710         man/gnt-instance.8 \
1711         man/gnt-job.8 \
1712         man/gnt-node.8 \
1713         man/gnt-os.8 \
1714         man/gnt-storage.8 \
1715         man/gnt-filter.8 \
1716         man/hail.1 \
1717         man/harep.1 \
1718         man/hbal.1 \
1719         man/hcheck.1 \
1720         man/hinfo.1 \
1721         man/hscan.1 \
1722         man/hspace.1 \
1723         man/hsqueeze.1 \
1724         man/hroller.1 \
1725         man/htools.1 \
1726         man/mon-collector.7
1727
1728 # Remove extensions from all filenames in man_MANS
1729 mannoext = $(patsubst %.1,%,$(patsubst %.7,%,$(patsubst %.8,%,$(man_MANS))))
1730
1731 manrst = $(patsubst %,%.rst,$(mannoext))
1732 manhtml = $(patsubst %.rst,%.html,$(manrst))
1733 mangen = $(patsubst %.rst,%.gen,$(manrst))
1734 maninput = \
1735         $(patsubst %.1,%.1.in,$(patsubst %.7,%.7.in,$(patsubst %.8,%.8.in,$(man_MANS)))) \
1736         $(patsubst %.html,%.html.in,$(manhtml)) \
1737         $(mangen)
1738
1739 manfullpath = $(patsubst man/%.1,man1/%.1,\
1740         $(patsubst man/%.7,man7/%.7,\
1741         $(patsubst man/%.8,man8/%.8,$(man_MANS))))
1742
1743 TEST_FILES = \
1744         test/autotools/autotools-check-news.test \
1745         test/data/htools/clean-nonzero-score.data \
1746         test/data/htools/common-suffix.data \
1747         test/data/htools/dyn1.json \
1748         test/data/htools/dyn2.json \
1749         test/data/htools/dyn3.json \
1750         test/data/htools/empty-cluster.data \
1751         test/data/htools/hail-alloc-dedicated-1.json \
1752         test/data/htools/hail-alloc-desired-location.json \
1753         test/data/htools/hail-alloc-drbd.json \
1754         test/data/htools/hail-alloc-drbd-restricted.json \
1755         test/data/htools/hail-alloc-ext.json \
1756         test/data/htools/hail-alloc-invalid-network.json \
1757         test/data/htools/hail-alloc-invalid-twodisks.json \
1758         test/data/htools/hail-alloc-restricted-network.json \
1759         test/data/htools/hail-alloc-nlocation.json \
1760         test/data/htools/hail-alloc-plain-tags.json \
1761         test/data/htools/hail-alloc-secondary.json \
1762         test/data/htools/hail-alloc-spindles.json \
1763         test/data/htools/hail-alloc-twodisks.json \
1764         test/data/htools/hail-alloc-memory-over-commitment.json \
1765         test/data/htools/hail-change-group.json \
1766         test/data/htools/hail-invalid-reloc.json \
1767         test/data/htools/hail-node-evac.json \
1768         test/data/htools/hail-reloc-drbd.json \
1769         test/data/htools/hail-reloc-drbd-crowded.json \
1770         test/data/htools/hbal-avoid-disk-moves.data \
1771         test/data/htools/hbal-cpu-speed.data \
1772         test/data/htools/hbal-desiredlocation-1.data \
1773         test/data/htools/hbal-desiredlocation-2.data \
1774         test/data/htools/hbal-desiredlocation-3.data \
1775         test/data/htools/hbal-desiredlocation-4.data \
1776         test/data/htools/hbal-dyn.data \
1777         test/data/htools/hbal-dyn2.data \
1778         test/data/htools/hbal-evac.data \
1779         test/data/htools/hbal-excl-tags.data \
1780         test/data/htools/hbal-forth.data \
1781         test/data/htools/hbal-location-1.data \
1782         test/data/htools/hbal-location-exclusion.data \
1783         test/data/htools/hbal-location-2.data \
1784         test/data/htools/hbal-memory-over-commitment.data \
1785         test/data/htools/hbal-memory-over-commitment-2.data \
1786         test/data/htools/hbal-migration-1.data \
1787         test/data/htools/hbal-migration-2.data \
1788         test/data/htools/hbal-migration-3.data \
1789         test/data/htools/hail-multialloc-dedicated.json \
1790         test/data/htools/hbal-soft-errors.data \
1791         test/data/htools/hbal-soft-errors2.data \
1792         test/data/htools/hbal-split-insts.data \
1793         test/data/htools/hspace-bad-group.data \
1794         test/data/htools/hspace-existing.data \
1795         test/data/htools/hspace-groups-one.data \
1796         test/data/htools/hspace-groups-two.data \
1797         test/data/htools/hspace-tiered-dualspec-exclusive.data \
1798         test/data/htools/hspace-tiered-dualspec.data \
1799         test/data/htools/hspace-tiered-exclusive.data \
1800         test/data/htools/hspace-tiered-ipolicy.data \
1801         test/data/htools/hspace-tiered-mixed.data \
1802         test/data/htools/hspace-tiered-resourcetypes.data \
1803         test/data/htools/hspace-tiered-vcpu.data \
1804         test/data/htools/hspace-tiered.data \
1805         test/data/htools/invalid-node.data \
1806         test/data/htools/missing-resources.data \
1807         test/data/htools/multiple-master.data \
1808         test/data/htools/multiple-tags.data \
1809         test/data/htools/n1-failure.data \
1810         test/data/htools/partly-used.data \
1811         test/data/htools/rapi/groups.json \
1812         test/data/htools/rapi/info.json \
1813         test/data/htools/rapi/instances.json \
1814         test/data/htools/rapi/nodes.json \
1815         test/data/htools/hroller-full.data \
1816         test/data/htools/hroller-nodegroups.data \
1817         test/data/htools/hroller-nonredundant.data \
1818         test/data/htools/hroller-online.data \
1819         test/data/htools/hsqueeze-mixed-instances.data \
1820         test/data/htools/hsqueeze-overutilized.data \
1821         test/data/htools/hsqueeze-underutilized.data \
1822         test/data/htools/plain-n1-restriction.data \
1823         test/data/htools/shared-n1-failure.data \
1824         test/data/htools/shared-n1-restriction.data \
1825         test/data/htools/unique-reboot-order.data \
1826         test/data/mond-data.txt \
1827         test/hs/shelltests/htools-balancing.test \
1828         test/hs/shelltests/htools-basic.test \
1829         test/hs/shelltests/htools-dynutil.test \
1830         test/hs/shelltests/htools-excl.test \
1831         test/hs/shelltests/htools-hail.test \
1832         test/hs/shelltests/htools-hbal-evac.test \
1833         test/hs/shelltests/htools-hbal.test \
1834         test/hs/shelltests/htools-hcheck.test \
1835         test/hs/shelltests/htools-hroller.test \
1836         test/hs/shelltests/htools-hspace.test \
1837         test/hs/shelltests/htools-hsqueeze.test \
1838         test/hs/shelltests/htools-invalid.test \
1839         test/hs/shelltests/htools-multi-group.test \
1840         test/hs/shelltests/htools-no-backend.test \
1841         test/hs/shelltests/htools-rapi.test \
1842         test/hs/shelltests/htools-single-group.test \
1843         test/hs/shelltests/htools-text-backend.test \
1844         test/hs/shelltests/htools-mon-collector.test \
1845         test/data/bdev-drbd-8.0.txt \
1846         test/data/bdev-drbd-8.3.txt \
1847         test/data/bdev-drbd-8.4.txt \
1848         test/data/bdev-drbd-8.4-no-disk-params.txt \
1849         test/data/bdev-drbd-disk.txt \
1850         test/data/bdev-drbd-net-ip4.txt \
1851         test/data/bdev-drbd-net-ip6.txt \
1852         test/data/bdev-rbd/json_output_empty.txt \
1853         test/data/bdev-rbd/json_output_extra_matches.txt \
1854         test/data/bdev-rbd/json_output_no_matches.txt \
1855         test/data/bdev-rbd/json_output_ok.txt \
1856         test/data/bdev-rbd/plain_output_new_extra_matches.txt \
1857         test/data/bdev-rbd/plain_output_new_no_matches.txt \
1858         test/data/bdev-rbd/plain_output_new_ok.txt \
1859         test/data/bdev-rbd/plain_output_old_empty.txt \
1860         test/data/bdev-rbd/plain_output_old_extra_matches.txt \
1861         test/data/bdev-rbd/plain_output_old_no_matches.txt \
1862         test/data/bdev-rbd/plain_output_old_ok.txt \
1863         test/data/bdev-rbd/output_invalid.txt \
1864         test/data/cert1.pem \
1865         test/data/cert2.pem \
1866         test/data/cgroup_root/memory/lxc/instance1/memory.limit_in_bytes \
1867         test/data/cgroup_root/cpuset/some_group/lxc/instance1/cpuset.cpus \
1868         test/data/cgroup_root/devices/some_group/lxc/instance1/devices.list \
1869         test/data/cluster_config_2.7.json \
1870         test/data/cluster_config_2.8.json \
1871         test/data/cluster_config_2.9.json \
1872         test/data/cluster_config_2.10.json \
1873         test/data/cluster_config_2.11.json \
1874         test/data/cluster_config_2.12.json \
1875         test/data/cluster_config_2.13.json \
1876         test/data/cluster_config_2.14.json \
1877         test/data/cluster_config_2.15.json \
1878         test/data/cluster_config_2.16.json \
1879         test/data/cluster_config_2.17.json \
1880         test/data/instance-minor-pairing.txt \
1881         test/data/instance-disks.txt \
1882         test/data/ip-addr-show-dummy0.txt \
1883         test/data/ip-addr-show-lo-ipv4.txt \
1884         test/data/ip-addr-show-lo-ipv6.txt \
1885         test/data/ip-addr-show-lo-oneline-ipv4.txt \
1886         test/data/ip-addr-show-lo-oneline-ipv6.txt \
1887         test/data/ip-addr-show-lo-oneline.txt \
1888         test/data/ip-addr-show-lo.txt \
1889         test/data/kvm_0.12.5_help.txt \
1890         test/data/kvm_0.15.90_help.txt \
1891         test/data/kvm_0.9.1_help.txt \
1892         test/data/kvm_0.9.1_help_boot_test.txt \
1893         test/data/kvm_1.0_help.txt \
1894         test/data/kvm_1.1.2_help.txt \
1895         test/data/kvm_runtime.json \
1896         test/data/lvs_lv.txt \
1897         test/data/NEWS_OK.txt \
1898         test/data/NEWS_previous_unreleased.txt \
1899         test/data/ovfdata/compr_disk.vmdk.gz \
1900         test/data/ovfdata/config.ini \
1901         test/data/ovfdata/corrupted_resources.ovf \
1902         test/data/ovfdata/empty.ini \
1903         test/data/ovfdata/empty.ovf \
1904         test/data/ovfdata/ganeti.mf \
1905         test/data/ovfdata/ganeti.ovf \
1906         test/data/ovfdata/gzip_disk.ovf \
1907         test/data/ovfdata/new_disk.vmdk \
1908         test/data/ovfdata/no_disk.ini \
1909         test/data/ovfdata/no_disk_in_ref.ovf \
1910         test/data/ovfdata/no_os.ini \
1911         test/data/ovfdata/no_ovf.ova \
1912         test/data/ovfdata/other/rawdisk.raw \
1913         test/data/ovfdata/ova.ova \
1914         test/data/ovfdata/rawdisk.raw \
1915         test/data/ovfdata/second_disk.vmdk \
1916         test/data/ovfdata/unsafe_path.ini \
1917         test/data/ovfdata/virtualbox.ovf \
1918         test/data/ovfdata/wrong_config.ini \
1919         test/data/ovfdata/wrong_extension.ovd \
1920         test/data/ovfdata/wrong_manifest.mf \
1921         test/data/ovfdata/wrong_manifest.ovf \
1922         test/data/ovfdata/wrong_ova.ova \
1923         test/data/ovfdata/wrong_xml.ovf \
1924         test/data/proc_cgroup.txt \
1925         test/data/proc_diskstats.txt \
1926         test/data/proc_drbd8.txt \
1927         test/data/proc_drbd80-emptyline.txt \
1928         test/data/proc_drbd80-emptyversion.txt \
1929         test/data/proc_drbd83.txt \
1930         test/data/proc_drbd83_sync.txt \
1931         test/data/proc_drbd83_sync_want.txt \
1932         test/data/proc_drbd83_sync_krnl2.6.39.txt \
1933         test/data/proc_drbd84.txt \
1934         test/data/proc_drbd84_emptyfirst.txt \
1935         test/data/proc_drbd84_sync.txt \
1936         test/data/proc_meminfo.txt \
1937         test/data/proc_cpuinfo.txt \
1938         test/data/qa-minimal-nodes-instances-only.json \
1939         test/data/sys_drbd_usermode_helper.txt \
1940         test/data/vgreduce-removemissing-2.02.02.txt \
1941         test/data/vgreduce-removemissing-2.02.66-fail.txt \
1942         test/data/vgreduce-removemissing-2.02.66-ok.txt \
1943         test/data/vgs-missing-pvs-2.02.02.txt \
1944         test/data/vgs-missing-pvs-2.02.66.txt \
1945         test/data/xen-xl-list-4.4-crashed-instances.txt \
1946         test/data/xen-xm-info-4.0.1.txt \
1947         test/data/xen-xm-list-4.0.1-dom0-only.txt \
1948         test/data/xen-xm-list-4.0.1-four-instances.txt \
1949         test/data/xen-xm-list-long-4.0.1.txt \
1950         test/data/xen-xm-uptime-4.0.1.txt \
1951         test/py/ganeti-cli.test \
1952         test/py/gnt-cli.test \
1953         test/py/import-export_unittest-helper
1954
1955
1956 python_tests = \
1957         doc/examples/rapi_testutils.py \
1958         test/py/cmdlib/backup_unittest.py \
1959         test/py/cmdlib/cluster_unittest.py \
1960         test/py/cmdlib/cmdlib_unittest.py \
1961         test/py/cmdlib/group_unittest.py \
1962         test/py/cmdlib/instance_unittest.py \
1963         test/py/cmdlib/instance_migration_unittest.py \
1964         test/py/cmdlib/instance_query_unittest.py \
1965         test/py/cmdlib/instance_storage_unittest.py \
1966         test/py/cmdlib/node_unittest.py \
1967         test/py/cmdlib/test_unittest.py \
1968         test/py/cfgupgrade_unittest.py \
1969         test/py/docs_unittest.py \
1970         test/py/ganeti.asyncnotifier_unittest.py \
1971         test/py/ganeti.backend_unittest-runasroot.py \
1972         test/py/ganeti.backend_unittest.py \
1973         test/py/ganeti.bootstrap_unittest.py \
1974         test/py/ganeti.cli_unittest.py \
1975         test/py/ganeti.cli_opts_unittest.py \
1976         test/py/ganeti.client.gnt_cluster_unittest.py \
1977         test/py/ganeti.client.gnt_instance_unittest.py \
1978         test/py/ganeti.client.gnt_job_unittest.py \
1979         test/py/ganeti.compat_unittest.py \
1980         test/py/ganeti.confd.client_unittest.py \
1981         test/py/ganeti.config_unittest.py \
1982         test/py/ganeti.constants_unittest.py \
1983         test/py/ganeti.daemon_unittest.py \
1984         test/py/ganeti.errors_unittest.py \
1985         test/py/ganeti.hooks_unittest.py \
1986         test/py/ganeti.ht_unittest.py \
1987         test/py/ganeti.http_unittest.py \
1988         test/py/ganeti.hypervisor.hv_chroot_unittest.py \
1989         test/py/ganeti.hypervisor.hv_fake_unittest.py \
1990         test/py/ganeti.hypervisor.hv_kvm_unittest.py \
1991         test/py/ganeti.hypervisor.hv_lxc_unittest.py \
1992         test/py/ganeti.hypervisor.hv_xen_unittest.py \
1993         test/py/ganeti.hypervisor_unittest.py \
1994         test/py/ganeti.impexpd_unittest.py \
1995         test/py/ganeti.jqueue_unittest.py \
1996         test/py/ganeti.jstore_unittest.py \
1997         test/py/ganeti.locking_unittest.py \
1998         test/py/ganeti.luxi_unittest.py \
1999         test/py/ganeti.masterd.iallocator_unittest.py \
2000         test/py/ganeti.masterd.instance_unittest.py \
2001         test/py/ganeti.mcpu_unittest.py \
2002         test/py/ganeti.netutils_unittest.py \
2003         test/py/ganeti.objects_unittest.py \
2004         test/py/ganeti.opcodes_unittest.py \
2005         test/py/ganeti.outils_unittest.py \
2006         test/py/ganeti.ovf_unittest.py \
2007         test/py/ganeti.qlang_unittest.py \
2008         test/py/ganeti.query_unittest.py \
2009         test/py/ganeti.rapi.baserlib_unittest.py \
2010         test/py/ganeti.rapi.client_unittest.py \
2011         test/py/ganeti.rapi.resources_unittest.py \
2012         test/py/ganeti.rapi.rlib2_unittest.py \
2013         test/py/ganeti.rapi.testutils_unittest.py \
2014         test/py/ganeti.rpc_unittest.py \
2015         test/py/ganeti.rpc.client_unittest.py \
2016         test/py/ganeti.runtime_unittest.py \
2017         test/py/ganeti.serializer_unittest.py \
2018         test/py/ganeti.server.rapi_unittest.py \
2019         test/py/ganeti.ssconf_unittest.py \
2020         test/py/ganeti.ssh_unittest.py \
2021         test/py/ganeti.storage.bdev_unittest.py \
2022         test/py/ganeti.storage.container_unittest.py \
2023         test/py/ganeti.storage.drbd_unittest.py \
2024         test/py/ganeti.storage.filestorage_unittest.py \
2025         test/py/ganeti.storage.gluster_unittest.py \
2026         test/py/ganeti.tools.burnin_unittest.py \
2027         test/py/ganeti.tools.ensure_dirs_unittest.py \
2028         test/py/ganeti.tools.node_daemon_setup_unittest.py \
2029         test/py/ganeti.tools.prepare_node_join_unittest.py \
2030         test/py/ganeti.uidpool_unittest.py \
2031         test/py/ganeti.utils.algo_unittest.py \
2032         test/py/ganeti.utils.filelock_unittest.py \
2033         test/py/ganeti.utils.hash_unittest.py \
2034         test/py/ganeti.utils.io_unittest-runasroot.py \
2035         test/py/ganeti.utils.io_unittest.py \
2036         test/py/ganeti.utils.log_unittest.py \
2037         test/py/ganeti.utils.lvm_unittest.py \
2038         test/py/ganeti.utils.mlock_unittest.py \
2039         test/py/ganeti.utils.nodesetup_unittest.py \
2040         test/py/ganeti.utils.process_unittest.py \
2041         test/py/ganeti.utils.retry_unittest.py \
2042         test/py/ganeti.utils.security_unittest.py \
2043         test/py/ganeti.utils.storage_unittest.py \
2044         test/py/ganeti.utils.text_unittest.py \
2045         test/py/ganeti.utils.version_unittest.py \
2046         test/py/ganeti.utils.wrapper_unittest.py \
2047         test/py/ganeti.utils.x509_unittest.py \
2048         test/py/ganeti.utils.bitarrays_unittest.py \
2049         test/py/ganeti.utils_unittest.py \
2050         test/py/ganeti.vcluster_unittest.py \
2051         test/py/ganeti.workerpool_unittest.py \
2052         test/py/pycurl_reset_unittest.py \
2053         test/py/qa.qa_config_unittest.py \
2054         test/py/tempfile_fork_unittest.py
2055
2056 python_test_support = \
2057         test/py/__init__.py \
2058         test/py/lockperf.py \
2059         test/py/testutils_ssh.py \
2060         test/py/mocks.py \
2061         test/py/testutils/__init__.py \
2062         test/py/testutils/config_mock.py \
2063         test/py/cmdlib/__init__.py \
2064         test/py/cmdlib/testsupport/__init__.py \
2065         test/py/cmdlib/testsupport/cmdlib_testcase.py \
2066         test/py/cmdlib/testsupport/iallocator_mock.py \
2067         test/py/cmdlib/testsupport/livelock_mock.py \
2068         test/py/cmdlib/testsupport/netutils_mock.py \
2069         test/py/cmdlib/testsupport/pathutils_mock.py \
2070         test/py/cmdlib/testsupport/processor_mock.py \
2071         test/py/cmdlib/testsupport/rpc_runner_mock.py \
2072         test/py/cmdlib/testsupport/ssh_mock.py \
2073         test/py/cmdlib/testsupport/utils_mock.py \
2074         test/py/cmdlib/testsupport/util.py \
2075         test/py/cmdlib/testsupport/wconfd_mock.py
2076
2077 haskell_tests = test/hs/htest
2078
2079 dist_TESTS = \
2080         test/py/check-cert-expired_unittest.bash \
2081         test/py/daemon-util_unittest.bash \
2082         test/py/systemd_unittest.bash \
2083         test/py/ganeti-cleaner_unittest.bash \
2084         test/py/import-export_unittest.bash \
2085         test/py/cli-test.bash \
2086         test/py/bash_completion.bash
2087
2088 if PY_UNIT
2089 dist_TESTS += $(python_tests)
2090 endif
2091
2092 nodist_TESTS =
2093 check_SCRIPTS =
2094
2095 if WANT_HSTESTS
2096 nodist_TESTS += $(haskell_tests)
2097 # test dependency
2098 test/hs/offline-test.sh: test/hs/hpc-htools test/hs/hpc-mon-collector
2099 dist_TESTS += test/hs/offline-test.sh
2100 check_SCRIPTS += \
2101         test/hs/hpc-htools \
2102         test/hs/hpc-mon-collector \
2103         $(HS_BUILT_TEST_HELPERS)
2104 endif
2105
2106 TESTS = $(dist_TESTS) $(nodist_TESTS)
2107
2108 # Environment for all tests
2109 PLAIN_TESTS_ENVIRONMENT = \
2110         PYTHONPATH=.:./test/py \
2111         TOP_SRCDIR=$(abs_top_srcdir) TOP_BUILDDIR=$(abs_top_builddir) \
2112         PYTHON=$(PYTHON) FAKEROOT=$(FAKEROOT_PATH) \
2113         $(RUN_IN_TEMPDIR)
2114
2115 # Environment for tests run by automake
2116 TESTS_ENVIRONMENT = \
2117         $(PLAIN_TESTS_ENVIRONMENT) $(abs_top_srcdir)/autotools/testrunner
2118
2119 all_python_code = \
2120         $(dist_sbin_SCRIPTS) \
2121         $(python_scripts) \
2122         $(pkglib_python_scripts) \
2123         $(nodist_pkglib_python_scripts) \
2124         $(nodist_tools_python_scripts) \
2125         $(pkgpython_PYTHON) \
2126         $(client_PYTHON) \
2127         $(cmdlib_PYTHON) \
2128         $(cmdlib_cluster_PYTHON) \
2129         $(config_PYTHON) \
2130         $(hypervisor_PYTHON) \
2131         $(hypervisor_hv_kvm_PYTHON) \
2132         $(jqueue_PYTHON) \
2133         $(storage_PYTHON) \
2134         $(rapi_PYTHON) \
2135         $(server_PYTHON) \
2136         $(rpc_PYTHON) \
2137         $(rpc_stub_PYTHON) \
2138         $(pytools_PYTHON) \
2139         $(http_PYTHON) \
2140         $(confd_PYTHON) \
2141         $(masterd_PYTHON) \
2142         $(impexpd_PYTHON) \
2143         $(utils_PYTHON) \
2144         $(watcher_PYTHON) \
2145         $(noinst_PYTHON) \
2146         $(qa_scripts)
2147
2148 if PY_UNIT
2149 all_python_code += $(python_tests)
2150 all_python_code += $(python_test_support)
2151 all_python_code += $(python_test_utils)
2152 endif
2153
2154 srclink_files = \
2155         man/footer.rst \
2156         test/py/check-cert-expired_unittest.bash \
2157         test/py/daemon-util_unittest.bash \
2158         test/py/systemd_unittest.bash \
2159         test/py/ganeti-cleaner_unittest.bash \
2160         test/py/import-export_unittest.bash \
2161         test/py/cli-test.bash \
2162         test/py/bash_completion.bash \
2163         test/hs/offline-test.sh \
2164         test/hs/cli-tests-defs.sh \
2165         $(all_python_code) \
2166         $(HS_LIBTEST_SRCS) $(HS_PROG_SRCS) \
2167         $(docinput)
2168
2169 check_python_code = \
2170         $(BUILD_BASH_COMPLETION) \
2171         $(CHECK_IMPORTS) \
2172         $(CHECK_HEADER) \
2173         $(DOCPP) \
2174         $(all_python_code)
2175
2176 lint_python_code = \
2177         ganeti \
2178         ganeti/http/server.py \
2179         $(dist_sbin_SCRIPTS) \
2180         $(python_scripts) \
2181         $(pkglib_python_scripts) \
2182         $(BUILD_BASH_COMPLETION) \
2183         $(CHECK_IMPORTS) \
2184         $(CHECK_HEADER) \
2185         $(DOCPP) \
2186         $(gnt_python_sbin_SCRIPTS) \
2187         $(PYTHON_BOOTSTRAP)
2188
2189 standalone_python_modules = \
2190         lib/rapi/client.py \
2191         tools/ganeti-listrunner
2192
2193 pep8_python_code = \
2194         ganeti \
2195         ganeti/http/server.py \
2196         $(dist_sbin_SCRIPTS) \
2197         $(python_scripts) \
2198         $(pkglib_python_scripts) \
2199         $(BUILD_BASH_COMPLETION) \
2200         $(CHECK_HEADER) \
2201         $(DOCPP) \
2202         $(PYTHON_BOOTSTRAP) \
2203         $(gnt_python_sbin_SCRIPTS) \
2204         qa \
2205         $(python_test_support)
2206         $(python_test_utils)
2207
2208 test/py/daemon-util_unittest.bash: daemons/daemon-util
2209
2210 test/py/systemd_unittest.bash: daemons/daemon-util $(BUILT_EXAMPLES)
2211
2212 test/py/ganeti-cleaner_unittest.bash: daemons/ganeti-cleaner
2213
2214 test/py/bash_completion.bash: doc/examples/bash_completion-debug
2215
2216 tools/kvm-ifup: tools/kvm-ifup.in $(REPLACE_VARS_SED)
2217         sed -f $(REPLACE_VARS_SED) < $< > $@
2218         chmod +x $@
2219
2220 tools/kvm-ifup-os: tools/ifup-os.in $(REPLACE_VARS_SED)
2221         sed -f $(REPLACE_VARS_SED) -e "s/ifup-os:/kvm-ifup-os:/" < $< > $@
2222         chmod +x $@
2223
2224 tools/xen-ifup-os: tools/ifup-os.in $(REPLACE_VARS_SED)
2225         sed -f $(REPLACE_VARS_SED) -e "s/ifup-os:/xen-ifup-os:/" < $< > $@
2226         chmod +x $@
2227
2228 tools/vif-ganeti: tools/vif-ganeti.in $(REPLACE_VARS_SED)
2229         sed -f $(REPLACE_VARS_SED) < $< > $@
2230         chmod +x $@
2231
2232 tools/vif-ganeti-metad: tools/vif-ganeti-metad.in $(REPLACE_VARS_SED)
2233         sed -f $(REPLACE_VARS_SED) < $< > $@
2234         chmod +x $@
2235
2236 tools/net-common: tools/net-common.in $(REPLACE_VARS_SED)
2237         sed -f $(REPLACE_VARS_SED) < $< > $@
2238         chmod +x $@
2239
2240 tools/users-setup: Makefile $(userspecs)
2241         set -e; \
2242         { echo '#!/bin/sh'; \
2243           echo 'if [ "x$$1" != "x--yes-do-it" ];'; \
2244           echo 'then echo "This will do the following changes"'; \
2245           $(AWK) -- '{print "echo + Will add group ",$$1; count++}\
2246                      END {if (count == 0) {print "echo + No groups to add"}}' doc/users/groups; \
2247           $(AWK) -- '{if (NF > 1) {print "echo + Will add user",$$1,"with primary group",$$2} \
2248                                   else {print "echo + Will add user",$$1}; count++}\
2249                      END {if (count == 0) {print "echo + No users to add"}}' doc/users/users; \
2250           $(AWK) -- '{print "echo + Will add user",$$1,"to group",$$2}' doc/users/groupmemberships; \
2251           echo 'echo'; \
2252           echo 'echo "OK? (y/n)"'; \
2253           echo 'read confirm'; \
2254           echo 'if [ "x$$confirm" != "xy" ]; then exit 0; fi'; \
2255           echo 'fi'; \
2256           $(AWK) -- '{print "groupadd --system",$$1}' doc/users/groups; \
2257           $(AWK) -- '{if (NF > 1) {print "useradd --system --gid",$$2,$$1} else {print "useradd --system",$$1}}' doc/users/users; \
2258           $(AWK) -- '{print "usermod --append --groups",$$2,$$1}' doc/users/groupmemberships; \
2259         } > $@
2260         chmod +x $@
2261
2262 tools/vcluster-setup: tools/vcluster-setup.in $(REPLACE_VARS_SED)
2263         sed -f $(REPLACE_VARS_SED) < $< > $@
2264         chmod +x $@
2265
2266 daemons/%:: daemons/%.in $(REPLACE_VARS_SED)
2267         sed -f $(REPLACE_VARS_SED) < $< > $@
2268         chmod +x $@
2269
2270 doc/examples/%:: doc/examples/%.in $(REPLACE_VARS_SED)
2271         sed -f $(REPLACE_VARS_SED) < $< > $@
2272
2273 doc/examples/bash_completion: BC_ARGS = --compact
2274 doc/examples/bash_completion-debug: BC_ARGS =
2275
2276 doc/examples/bash_completion doc/examples/bash_completion-debug: \
2277         $(BUILD_BASH_COMPLETION) $(RUN_IN_TEMPDIR) \
2278         lib/cli.py $(gnt_scripts) $(client_PYTHON) tools/burnin \
2279         daemons/ganeti-cleaner \
2280         $(GENERATED_FILES) $(HS_GENERATED_FILES)
2281         PYTHONPATH=. $(RUN_IN_TEMPDIR) \
2282           $(CURDIR)/$(BUILD_BASH_COMPLETION) $(BC_ARGS) > $@
2283
2284 man/%.gen: man/%.rst lib/query.py lib/build/sphinx_ext.py \
2285         lib/build/shell_example_lexer.py \
2286         | $(RUN_IN_TEMPDIR) $(built_python_sources)
2287         @echo "Checking $< for hardcoded paths..."
2288         @if grep -nEf autotools/wrong-hardcoded-paths $<; then \
2289           echo "Man page $< has hardcoded paths (see above)!" 1>&2 ; \
2290           exit 1; \
2291         fi
2292         set -e ; \
2293         trap 'echo auto-removing $@; rm $@' EXIT; \
2294         PYTHONPATH=. $(RUN_IN_TEMPDIR) $(CURDIR)/$(DOCPP) < $< > $@ ;\
2295         $(CHECK_MAN_REFERENCES) $@; \
2296         trap - EXIT
2297
2298 man/%.7.in man/%.8.in man/%.1.in: man/%.gen man/footer.rst
2299         @test -n "$(PANDOC)" || \
2300           { echo 'pandoc' not found during configure; exit 1; }
2301         set -o pipefail -e; \
2302         trap 'echo auto-removing $@; rm $@' EXIT; \
2303         $(PANDOC) -s -f rst -t man $< man/footer.rst | \
2304           sed -e 's/\\@/@/g' > $@; \
2305         if test -n "$(MAN_HAS_WARNINGS)"; then LC_ALL=en_US.UTF-8 $(CHECK_MAN_WARNINGS) $@; fi; \
2306         $(CHECK_MAN_DASHES) $@; \
2307         trap - EXIT
2308
2309 man/%.html.in: man/%.gen man/footer.rst
2310         @test -n "$(PANDOC)" || \
2311           { echo 'pandoc' not found during configure; exit 1; }
2312         set -o pipefail ; \
2313         $(PANDOC) --toc -s -f rst -t html $< man/footer.rst | \
2314           sed -e 's/\\@/@/g' > $@
2315
2316 man/%: man/%.in  $(REPLACE_VARS_SED)
2317         sed -f $(REPLACE_VARS_SED) < $< > $@
2318
2319 epydoc.conf: epydoc.conf.in $(REPLACE_VARS_SED)
2320         sed -f $(REPLACE_VARS_SED) < $< > $@
2321
2322 vcs-version:
2323         if test -d .git; then \
2324           git describe | tr '"' - > $@; \
2325         elif test ! -f $@ ; then \
2326           echo "Cannot auto-generate $@ file"; exit 1; \
2327         fi
2328
2329 .PHONY: clean-vcs-version
2330 clean-vcs-version:
2331         rm -f vcs-version
2332
2333 .PHONY: regen-vcs-version
2334 regen-vcs-version:
2335         @set -e; \
2336         cd $(srcdir); \
2337         if test -d .git; then \
2338           T=`mktemp` ; trap 'rm -f $$T' EXIT; \
2339           git describe > $$T; \
2340           if ! cmp --quiet $$T vcs-version; then \
2341             mv $$T vcs-version; \
2342           fi; \
2343         fi
2344
2345 src/Ganeti/Version.hs: src/Ganeti/Version.hs.in \
2346         vcs-version $(built_base_sources)
2347         set -e; \
2348         VCSVER=`cat $(abs_top_srcdir)/vcs-version`; \
2349         sed -e 's"%ver%"'"$$VCSVER"'"' < $< > $@
2350
2351 src/Ganeti/Hs2Py/ListConstants.hs: src/Ganeti/Hs2Py/ListConstants.hs.in \
2352                                    src/Ganeti/Constants.hs \
2353                                  | stamp-directories
2354         @echo Generating $@
2355         @set -e; \
2356 ## Extract constant names from 'Constants.hs' by extracting the left
2357 ## side of all lines containing an equal sign (i.e., '=') and
2358 ## prepending the apostrophe sign (i.e., "'").
2359 ##
2360 ## For example, the constant
2361 ##   adminstDown = ...
2362 ## becomes
2363 ##   'adminstDown
2364         NAMES=$$(sed -e "/^--/ d" $(abs_top_srcdir)/src/Ganeti/Constants.hs |\
2365                  sed -n -e "/=/ s/\(.*\) =.*/    '\1:/g p"); \
2366         m4 -DPY_CONSTANT_NAMES="$$NAMES" \
2367                 $(abs_top_srcdir)/src/Ganeti/Hs2Py/ListConstants.hs.in > $@
2368
2369 src/Ganeti/Curl/Internal.hs: src/Ganeti/Curl/Internal.hsc | stamp-directories
2370         hsc2hs -o $@ $<
2371
2372 test/hs/Test/Ganeti/TestImports.hs: test/hs/Test/Ganeti/TestImports.hs.in \
2373         $(built_base_sources)
2374         set -e; \
2375         { cat $< ; \
2376           echo ; \
2377           for name in $(filter-out Ganeti.THH,$(subst /,.,$(patsubst %.hs,%,$(patsubst src/%,%,$(HS_LIB_SRCS))))) ; do \
2378             echo "import $$name ()" ; \
2379           done ; \
2380         } > $@
2381
2382 lib/_constants.py: Makefile src/hs2py lib/_constants.py.in | stamp-directories
2383         cat $(abs_top_srcdir)/lib/_constants.py.in > $@
2384         src/hs2py --constants >> $@
2385
2386 lib/constants.py: lib/_constants.py
2387
2388 src/AutoConf.hs: Makefile src/AutoConf.hs.in $(PRINT_PY_CONSTANTS) \
2389                | $(built_base_sources)
2390         @echo "m4 ... >" $@
2391         @m4 -DPACKAGE_VERSION="$(PACKAGE_VERSION)" \
2392             -DVERSION_MAJOR="$(VERSION_MAJOR)" \
2393             -DVERSION_MINOR="$(VERSION_MINOR)" \
2394             -DVERSION_REVISION="$(VERSION_REVISION)" \
2395             -DVERSION_SUFFIX="$(VERSION_SUFFIX)" \
2396             -DVERSION_FULL="$(VERSION_FULL)" \
2397             -DDIRVERSION="$(DIRVERSION)" \
2398             -DLOCALSTATEDIR="$(localstatedir)" \
2399             -DSYSCONFDIR="$(sysconfdir)" \
2400             -DSSH_CONFIG_DIR="$(SSH_CONFIG_DIR)" \
2401             -DSSH_LOGIN_USER="$(SSH_LOGIN_USER)" \
2402             -DSSH_CONSOLE_USER="$(SSH_CONSOLE_USER)" \
2403             -DEXPORT_DIR="$(EXPORT_DIR)" \
2404             -DBACKUP_DIR="$(backup_dir)" \
2405             -DOS_SEARCH_PATH="\"$(OS_SEARCH_PATH)\"" \
2406             -DES_SEARCH_PATH="\"$(ES_SEARCH_PATH)\"" \
2407             -DXEN_BOOTLOADER="$(XEN_BOOTLOADER)" \
2408             -DXEN_CONFIG_DIR="$(XEN_CONFIG_DIR)" \
2409             -DXEN_KERNEL="$(XEN_KERNEL)" \
2410             -DXEN_INITRD="$(XEN_INITRD)" \
2411             -DKVM_KERNEL="$(KVM_KERNEL)" \
2412             -DSHARED_FILE_STORAGE_DIR="$(SHARED_FILE_STORAGE_DIR)" \
2413             -DIALLOCATOR_SEARCH_PATH="\"$(IALLOCATOR_SEARCH_PATH)\"" \
2414             -DDEFAULT_BRIDGE="$(DEFAULT_BRIDGE)" \
2415             -DDEFAULT_VG="$(DEFAULT_VG)" \
2416             -DKVM_PATH="$(KVM_PATH)" \
2417             -DIP_PATH="$(IP_PATH)" \
2418             -DSOCAT_PATH="$(SOCAT)" \
2419             -DPYTHON_PATH="$(PYTHON)" \
2420             -DSOCAT_USE_ESCAPE="$(SOCAT_USE_ESCAPE)" \
2421             -DSOCAT_USE_COMPRESS="$(SOCAT_USE_COMPRESS)" \
2422             -DLVM_STRIPECOUNT="$(LVM_STRIPECOUNT)" \
2423             -DTOOLSDIR="$(libdir)/ganeti/tools" \
2424             -DGNT_SCRIPTS="$(foreach i,$(notdir $(gnt_scripts)),\"$(i)\":)" \
2425             -DHS_HTOOLS_PROGS="$(foreach i,$(HS_HTOOLS_PROGS),\"$(i)\":)" \
2426             -DPKGLIBDIR="$(libdir)/ganeti" \
2427             -DSHAREDIR="$(prefix)/share/ganeti" \
2428             -DVERSIONEDSHAREDIR="$(versionedsharedir)" \
2429             -DDRBD_BARRIERS="$(DRBD_BARRIERS)" \
2430             -DDRBD_NO_META_FLUSH="$(DRBD_NO_META_FLUSH)" \
2431             -DSYSLOG_USAGE="$(SYSLOG_USAGE)" \
2432             -DDAEMONS_GROUP="$(DAEMONS_GROUP)" \
2433             -DADMIN_GROUP="$(ADMIN_GROUP)" \
2434             -DMASTERD_USER="$(MASTERD_USER)" \
2435             -DMASTERD_GROUP="$(MASTERD_GROUP)" \
2436             -DMETAD_USER="$(METAD_USER)" \
2437             -DMETAD_GROUP="$(METAD_GROUP)" \
2438             -DRAPI_USER="$(RAPI_USER)" \
2439             -DRAPI_GROUP="$(RAPI_GROUP)" \
2440             -DCONFD_USER="$(CONFD_USER)" \
2441             -DCONFD_GROUP="$(CONFD_GROUP)" \
2442             -DWCONFD_USER="$(WCONFD_USER)" \
2443             -DWCONFD_GROUP="$(WCONFD_GROUP)" \
2444             -DKVMD_USER="$(KVMD_USER)" \
2445             -DKVMD_GROUP="$(KVMD_GROUP)" \
2446             -DLUXID_USER="$(LUXID_USER)" \
2447             -DLUXID_GROUP="$(LUXID_GROUP)" \
2448             -DNODED_USER="$(NODED_USER)" \
2449             -DNODED_GROUP="$(NODED_GROUP)" \
2450             -DMOND_USER="$(MOND_USER)" \
2451             -DMOND_GROUP="$(MOND_GROUP)" \
2452             -DMETAD_USER="$(METAD_USER)" \
2453             -DMETAD_GROUP="$(METAD_GROUP)" \
2454             -DDISK_SEPARATOR="$(DISK_SEPARATOR)" \
2455             -DQEMUIMG_PATH="$(QEMUIMG_PATH)" \
2456             -DXEN_CMD="$(XEN_CMD)" \
2457             -DENABLE_RESTRICTED_COMMANDS="$(ENABLE_RESTRICTED_COMMANDS)" \
2458             -DENABLE_METADATA="$(ENABLE_METADATA)" \
2459             -DENABLE_MOND="$(ENABLE_MOND)" \
2460             -DHAS_GNU_LN="$(HAS_GNU_LN)" \
2461             -DMAN_PAGES="$$(for i in $(notdir $(man_MANS)); do \
2462                             echo -n "$$i" | sed -re 's/^(.*)\.([0-9]+)$$/("\1",\2):/g'; \
2463                             done)" \
2464             -DAF_INET4="$$(PYTHONPATH=. $(PYTHON) $(PRINT_PY_CONSTANTS) AF_INET4)" \
2465             -DAF_INET6="$$(PYTHONPATH=. $(PYTHON) $(PRINT_PY_CONSTANTS) AF_INET6)" \
2466         $(abs_top_srcdir)/src/AutoConf.hs.in > $@
2467
2468 lib/_vcsversion.py: Makefile vcs-version | stamp-directories
2469         set -e; \
2470         VCSVER=`cat $(abs_top_srcdir)/vcs-version`; \
2471         { echo '# This file is automatically generated, do not edit!'; \
2472           echo '#'; \
2473           echo ''; \
2474           echo '"""Build-time VCS version number for Ganeti.'; \
2475           echo '';\
2476           echo 'This file is autogenerated by the build process.'; \
2477           echo 'For any changes you need to re-run ./configure (and'; \
2478           echo 'not edit by hand).'; \
2479           echo ''; \
2480           echo '"""'; \
2481           echo ''; \
2482           echo '# pylint: disable=C0301,C0324'; \
2483           echo '# because this is autogenerated, we do not want'; \
2484           echo '# style warnings' ; \
2485           echo ''; \
2486           echo "VCS_VERSION = '$$VCSVER'"; \
2487         } > $@
2488
2489 lib/opcodes.py: Makefile src/hs2py lib/opcodes.py.in_before \
2490                 lib/opcodes.py.in_after | stamp-directories
2491         cat $(abs_top_srcdir)/lib/opcodes.py.in_before > $@
2492         src/hs2py --opcodes >> $@
2493         cat $(abs_top_srcdir)/lib/opcodes.py.in_after >> $@
2494
2495 # Generating the RPC wrappers depends on many things, so make sure
2496 # it's built at the end of the built sources
2497 lib/_generated_rpc.py: lib/rpc_defs.py $(BUILD_RPC) | $(built_base_sources) $(built_python_base_sources)
2498         PYTHONPATH=. $(RUN_IN_TEMPDIR) $(CURDIR)/$(BUILD_RPC) lib/rpc_defs.py > $@
2499
2500 if ENABLE_METADATA
2501 lib/rpc/stub/metad.py: Makefile src/hs2py | stamp-directories
2502         src/hs2py --metad-rpc > $@
2503 endif
2504
2505 lib/rpc/stub/wconfd.py: Makefile src/hs2py | stamp-directories
2506         src/hs2py --wconfd-rpc > $@
2507
2508 $(SHELL_ENV_INIT): Makefile stamp-directories
2509         set -e; \
2510         { echo '# Allow overriding for tests'; \
2511           echo 'readonly LOCALSTATEDIR=$${LOCALSTATEDIR:-$${GANETI_ROOTDIR:-}$(localstatedir)}'; \
2512           echo 'readonly SYSCONFDIR=$${SYSCONFDIR:-$${GANETI_ROOTDIR:-}$(sysconfdir)}'; \
2513           echo; \
2514           echo 'readonly PKGLIBDIR=$(libdir)/ganeti'; \
2515           echo 'readonly LOG_DIR="$$LOCALSTATEDIR/log/ganeti"'; \
2516           echo 'readonly RUN_DIR="$$LOCALSTATEDIR/run/ganeti"'; \
2517           echo 'readonly DATA_DIR="$$LOCALSTATEDIR/lib/ganeti"'; \
2518           echo 'readonly CONF_DIR="$$SYSCONFDIR/ganeti"'; \
2519         } > $@
2520
2521 ## Writes sed script to replace placeholders with build-time values. The
2522 ## additional quotes after the first @ sign are necessary to stop configure
2523 ## from replacing those values as well.
2524 $(REPLACE_VARS_SED): $(SHELL_ENV_INIT) Makefile stamp-directories
2525         set -e; \
2526         { echo 's#@''PREFIX@#$(prefix)#g'; \
2527           echo 's#@''SYSCONFDIR@#$(sysconfdir)#g'; \
2528           echo 's#@''LOCALSTATEDIR@#$(localstatedir)#g'; \
2529           echo 's#@''BINDIR@#$(BINDIR)#g'; \
2530           echo 's#@''SBINDIR@#$(SBINDIR)#g'; \
2531           echo 's#@''LIBDIR@#$(libdir)#g'; \
2532           echo 's#@''GANETI_VERSION@#$(PACKAGE_VERSION)#g'; \
2533           echo 's#@''CUSTOM_XEN_BOOTLOADER@#$(XEN_BOOTLOADER)#g'; \
2534           echo 's#@''CUSTOM_XEN_KERNEL@#$(XEN_KERNEL)#g'; \
2535           echo 's#@''CUSTOM_XEN_INITRD@#$(XEN_INITRD)#g'; \
2536           echo 's#@''CUSTOM_IALLOCATOR_SEARCH_PATH@#$(IALLOCATOR_SEARCH_PATH)#g'; \
2537           echo 's#@''CUSTOM_EXPORT_DIR@#$(EXPORT_DIR)#g'; \
2538           echo 's#@''RPL_SSH_INITD_SCRIPT@#$(SSH_INITD_SCRIPT)#g'; \
2539           echo 's#@''PKGLIBDIR@#$(libdir)/ganeti#g'; \
2540           echo 's#@''GNTMASTERUSER@#$(MASTERD_USER)#g'; \
2541           echo 's#@''GNTRAPIUSER@#$(RAPI_USER)#g'; \
2542           echo 's#@''GNTCONFDUSER@#$(CONFD_USER)#g'; \
2543           echo 's#@''GNTWCONFDUSER@#$(WCONFD_USER)#g'; \
2544           echo 's#@''GNTLUXIDUSER@#$(LUXID_USER)#g'; \
2545           echo 's#@''GNTNODEDUSER@#$(NODED_USER)#g'; \
2546           echo 's#@''GNTMONDUSER@#$(MOND_USER)#g'; \
2547           echo 's#@''GNTMETADUSER@#$(METAD_USER)#g'; \
2548           echo 's#@''GNTRAPIGROUP@#$(RAPI_GROUP)#g'; \
2549           echo 's#@''GNTADMINGROUP@#$(ADMIN_GROUP)#g'; \
2550           echo 's#@''GNTCONFDGROUP@#$(CONFD_GROUP)#g'; \
2551           echo 's#@''GNTNODEDGROUP@#$(NODED_GROUP)#g'; \
2552           echo 's#@''GNTWCONFDGROUP@#$(CONFD_GROUP)#g'; \
2553           echo 's#@''GNTLUXIDGROUP@#$(LUXID_GROUP)#g'; \
2554           echo 's#@''GNTMASTERDGROUP@#$(MASTERD_GROUP)#g'; \
2555           echo 's#@''GNTMONDGROUP@#$(MOND_GROUP)#g'; \
2556           echo 's#@''GNTMETADGROUP@#$(METAD_GROUP)#g'; \
2557           echo 's#@''GNTDAEMONSGROUP@#$(DAEMONS_GROUP)#g'; \
2558           echo 's#@''CUSTOM_ENABLE_MOND@#$(ENABLE_MOND)#g'; \
2559           echo 's#@''MODULES@#$(strip $(lint_python_code))#g'; \
2560           echo 's#@''XEN_CONFIG_DIR@#$(XEN_CONFIG_DIR)#g'; \
2561           echo; \
2562           echo '/^@SHELL_ENV_INIT@$$/ {'; \
2563           echo '  r $(SHELL_ENV_INIT)'; \
2564           echo '  d'; \
2565           echo '}'; \
2566         } > $@
2567
2568 # Using deferred evaluation
2569 daemons/ganeti-%: MODULE = ganeti.server.$(patsubst ganeti-%,%,$(notdir $@))
2570 daemons/ganeti-watcher: MODULE = ganeti.watcher
2571 scripts/%: MODULE = ganeti.client.$(subst -,_,$(notdir $@))
2572 tools/burnin: MODULE = ganeti.tools.burnin
2573 tools/ensure-dirs: MODULE = ganeti.tools.ensure_dirs
2574 tools/node-daemon-setup: MODULE = ganeti.tools.node_daemon_setup
2575 tools/prepare-node-join: MODULE = ganeti.tools.prepare_node_join
2576 tools/ssh-update: MODULE = ganeti.tools.ssh_update
2577 tools/node-cleanup: MODULE = ganeti.tools.node_cleanup
2578 tools/ssl-update: MODULE = ganeti.tools.ssl_update
2579 $(HS_BUILT_TEST_HELPERS): TESTROLE = $(patsubst test/hs/%,%,$@)
2580
2581 $(PYTHON_BOOTSTRAP) $(gnt_scripts) $(gnt_python_sbin_SCRIPTS): Makefile | stamp-directories
2582         test -n "$(MODULE)" || { echo Missing module; exit 1; }
2583         set -e; \
2584         { echo '#!${PYTHON}'; \
2585           echo '# This file is automatically generated, do not edit!'; \
2586           echo "# Edit $(MODULE) instead."; \
2587           echo; \
2588           echo '"""Bootstrap script for L{$(MODULE)}"""'; \
2589           echo; \
2590           echo '# pylint: disable=C0103'; \
2591           echo '# C0103: Invalid name'; \
2592           echo; \
2593           echo 'import sys'; \
2594           echo 'import $(MODULE) as main'; \
2595           echo; \
2596           echo '# Temporarily alias commands until bash completion'; \
2597           echo '# generator is changed'; \
2598           echo 'if hasattr(main, "commands"):'; \
2599           echo '  commands = main.commands # pylint: disable=E1101'; \
2600           echo 'if hasattr(main, "aliases"):'; \
2601           echo '  aliases = main.aliases # pylint: disable=E1101'; \
2602           echo; \
2603           echo 'if __name__ == "__main__":'; \
2604           echo '  sys.exit(main.Main())'; \
2605         } > $@
2606         chmod u+x $@
2607
2608 $(HS_BUILT_TEST_HELPERS): Makefile
2609         @test -n "$(TESTROLE)" || { echo Missing TESTROLE; exit 1; }
2610         set -e; \
2611         { echo '#!/bin/sh'; \
2612           echo '# This file is automatically generated, do not edit!'; \
2613           echo "# Edit Makefile.am instead."; \
2614           echo; \
2615           echo "HTOOLS=$(TESTROLE) exec ./test/hs/hpc-htools \"\$$@\""; \
2616         } > $@
2617         chmod u+x $@
2618
2619 stamp-directories: Makefile
2620         $(MAKE) $(AM_MAKEFLAGS) ganeti
2621         @mkdir_p@ $(DIRS) $(BUILDTIME_DIR_AUTOCREATE)
2622         touch $@
2623
2624 # We need to create symlinks because "make distcheck" will not install Python
2625 # files when building.
2626 stamp-srclinks: Makefile | stamp-directories
2627         set -e; \
2628         for i in $(srclink_files); do \
2629           if test ! -f $$i -a -f $(abs_top_srcdir)/$$i; then \
2630             $(LN_S) $(abs_top_srcdir)/$$i $$i; \
2631           fi; \
2632         done
2633         touch $@
2634
2635 .PHONY: ganeti
2636 ganeti:
2637         cd $(top_builddir) && test -h "$@" || { rm -f $@ && $(LN_S) lib $@; }
2638
2639 .PHONY: check-dirs
2640 check-dirs: $(GENERATED_FILES)
2641         @set -e; \
2642         find . -type d \( -name . -o -name .git -prune -o -print \) | { \
2643           error=; \
2644           while read dir; do \
2645             case "$$dir" in \
2646               $(strip $(patsubst %,(./%) ;;,$(DIRCHECK_EXCLUDE) $(DIRS))) \
2647               *) error=1; echo "Directory $$dir not listed in Makefile" >&2 ;; \
2648             esac; \
2649           done; \
2650           for dir in $(DIRS); do \
2651             if ! test -d "$$dir"; then \
2652               echo "Directory $$dir listed in DIRS does not exist" >&2; \
2653               error=1; \
2654             fi \
2655           done; \
2656           test -z "$$error"; \
2657         }
2658
2659 .PHONY: check-news
2660 check-news:
2661         RELEASE=$(PACKAGE_VERSION) $(CHECK_NEWS) < $(top_srcdir)/NEWS
2662
2663 .PHONY: check-local
2664 check-local: check-dirs check-news $(GENERATED_FILES)
2665         $(CHECK_PYTHON_CODE) $(check_python_code)
2666         PYTHONPATH=. $(CHECK_HEADER) \
2667             $(filter-out $(GENERATED_FILES),$(check_python_code))
2668         $(CHECK_VERSION) $(VERSION) $(top_srcdir)/NEWS
2669         PYTHONPATH=. $(RUN_IN_TEMPDIR) $(CURDIR)/$(CHECK_IMPORTS) . $(standalone_python_modules)
2670         error= ; \
2671         if [ "x`echo $(VERSION_SUFFIX)|grep 'alpha'`" == "x" ]; then \
2672           expver=$(VERSION_MAJOR).$(VERSION_MINOR); \
2673           if test "`head -n 1 $(top_srcdir)/README`" != "Ganeti $$expver"; then \
2674             echo "Incorrect version in README, expected $$expver" >&2; \
2675             error=1; \
2676           fi; \
2677           for file in doc/iallocator.rst doc/hooks.rst doc/virtual-cluster.rst \
2678               doc/security.rst; do \
2679             if test "`sed -ne '4 p' $(top_srcdir)/$$file`" != \
2680               "Documents Ganeti version $$expver"; then \
2681               echo "Incorrect version in $$file, expected $$expver" >&2; \
2682               error=1; \
2683             fi; \
2684           done; \
2685           if ! test -f $(top_srcdir)/doc/design-$$expver.rst; then \
2686             echo "File $(top_srcdir)/doc/design-$$expver.rst not found" >&2; \
2687             error=1; \
2688           fi; \
2689           if test "`sed -ne '5 p' $(top_srcdir)/doc/design-draft.rst`" != \
2690             ".. Last updated for Ganeti $$expver"; then \
2691             echo "doc/design-draft.rst was not updated for version $$expver" >&2; \
2692             error=1; \
2693           fi; \
2694         fi; \
2695         for file in configure.ac $(HS_LIBTEST_SRCS) $(HS_PROG_SRCS); do \
2696           if test $$(wc --max-line-length < $(top_srcdir)/$$file) -gt 80; then \
2697             echo "Longest line in $$file is longer than 80 characters" >&2; \
2698             error=1; \
2699           fi; \
2700         done; \
2701         test -z "$$error"
2702
2703 .PHONY: hs-test-%
2704 hs-test-%: test/hs/htest
2705         @rm -f htest.tix
2706         test/hs/htest -t $*
2707
2708 .PHONY: hs-tests
2709 hs-tests: test/hs/htest
2710         @rm -f htest.tix
2711         ./test/hs/htest
2712
2713 .PHONY: py-tests
2714 py-tests: $(python_tests) ganeti $(built_python_sources)
2715         error=; \
2716         for file in $(python_tests); \
2717           do if ! $(TESTS_ENVIRONMENT) $$file; then error=1; fi; \
2718         done; \
2719         test -z "$$error"
2720
2721 .PHONY: hs-shell-%
2722 hs-shell-%: test/hs/hpc-htools test/hs/hpc-mon-collector \
2723             $(HS_BUILT_TEST_HELPERS)
2724         @rm -f hpc-htools.tix hpc-mon-collector.tix
2725         HBINARY="./test/hs/hpc-htools" \
2726         SHELLTESTARGS=$(SHELLTESTARGS) \
2727         ./test/hs/offline-test.sh $*
2728
2729 .PHONY: hs-shell
2730 hs-shell: test/hs/hpc-htools test/hs/hpc-mon-collector $(HS_BUILT_TEST_HELPERS)
2731         @rm -f hpc-htools.tix hpc-mon-collector.tix
2732         HBINARY="./test/hs/hpc-htools" \
2733         SHELLTESTARGS=$(SHELLTESTARGS) \
2734         ./test/hs/offline-test.sh
2735
2736 .PHONY: hs-check
2737 hs-check: hs-tests hs-shell
2738
2739 # E111: indentation is not a multiple of four
2740 # E121: continuation line indentation is not a multiple of four
2741 #       (since our indent level is not 4)
2742 # E125: continuation line does not distinguish itself from next logical line
2743 #       (since our indent level is not 4)
2744 # E123: closing bracket does not match indentation of opening bracket's line
2745 # E127: continuation line over-indented for visual indent
2746 #       (since our indent level is not 4)
2747 # note: do NOT add E128 here; it's a valid style error in most cases!
2748 # I've seen real errors, but also some cases were we indent wrongly
2749 # due to line length; try to rework the cases where it is triggered,
2750 # instead of silencing it
2751 # E261: at least two spaces before inline comment
2752 # E501: line too long (80 characters)
2753 PEP8_IGNORE = E111,E121,E123,E125,E127,E261,E501
2754
2755 # For excluding pep8 expects filenames only, not whole paths
2756 PEP8_EXCLUDE = $(subst $(space),$(comma),$(strip $(notdir $(built_python_sources))))
2757
2758 # A space-separated list of pylint warnings to completely ignore:
2759 # I0013 = disable warnings for ignoring whole files
2760 # R0912 = disable too many branches warning. It's useful, but ganeti requires
2761 #         a lot of refactoring to fix this.
2762 # R0204 = disable redefined-variable-type warning. There are a large number of
2763 #         cases where Ganeti assigns multiple types (eg set/list, float/int) to
2764 #         the same variable, and these are benign.
2765 # C0325 = disable superfluous-parens. There are a lot of cases where this is
2766 #         overzealous, eg where we use parens to make it clear that we're
2767 #         deliberately doing a comparison that should yield bool, or are using
2768 #         parens clarify precedence or to allow multi-line expressions.
2769 # C0330 = disable wrong indentation warnings. pylint is much more strict than
2770 #         pep8, and it would be too invasive to fix all these.
2771 LINT_DISABLE = I0013 R0912 R0204 C0325 C0330
2772 # Additional pylint options
2773 LINT_OPTS =
2774 # The combined set of pylint options
2775 LINT_OPTS_ALL = $(LINT_OPTS) \
2776   $(addprefix --disable=,$(LINT_DISABLE))
2777
2778 # Whitelist loading pycurl C extension for attribute checking
2779 LINT_OPTS_ALL += --extension-pkg-whitelist=pycurl
2780
2781 LINT_TARGETS = pylint pylint-qa pylint-test
2782 if HAS_PEP8
2783 LINT_TARGETS += pep8
2784 endif
2785 if HAS_HLINT
2786 LINT_TARGETS += hlint
2787 endif
2788
2789 .PHONY: lint
2790 lint: $(LINT_TARGETS)
2791
2792 .PHONY: pylint
2793 pylint: $(GENERATED_FILES)
2794         @test -n "$(PYLINT)" || { echo 'pylint' not found during configure; exit 1; }
2795         $(PYLINT) $(LINT_OPTS_ALL) $(lint_python_code)
2796
2797 .PHONY: pylint-qa
2798 pylint-qa: $(GENERATED_FILES)
2799         @test -n "$(PYLINT)" || { echo 'pylint' not found during configure; exit 1; }
2800         cd $(top_srcdir)/qa && \
2801           PYTHONPATH=$(abs_top_srcdir) $(PYLINT) $(LINT_OPTS_ALL) \
2802                 --rcfile  ../pylintrc $(patsubst qa/%.py,%,$(qa_scripts))
2803 # FIXME: lint all test code, not just the newly added test support
2804 pylint-test: $(GENERATED_FILES)
2805         @test -n "$(PYLINT)" || { echo 'pylint' not found during configure; exit 1; }
2806         cd $(top_srcdir) && \
2807                 PYTHONPATH=.:./test/py $(PYLINT) $(LINT_OPTS_ALL) \
2808                 --rcfile=pylintrc-test  $(python_test_support) $(python_test_utils)
2809
2810 .PHONY: pep8
2811 pep8: $(GENERATED_FILES)
2812         @test -n "$(PEP8)" || { echo 'pep8' not found during configure; exit 1; }
2813         $(PEP8) --ignore='$(PEP8_IGNORE)' --exclude='$(PEP8_EXCLUDE)' \
2814           --repeat $(pep8_python_code)
2815
2816 HLINT_EXCLUDES = src/Ganeti/THH.hs test/hs/hpc-htools.hs
2817 .PHONY: hlint
2818 hlint: $(HS_BUILT_SRCS) src/lint-hints.hs
2819         @test -n "$(HLINT)" || { echo 'hlint' not found during configure; exit 1; }
2820         @rm -f doc/hs-lint.html
2821         if tty -s; then C="-c"; else C=""; fi; \
2822         $(HLINT) --utf8 --report=doc/hs-lint.html --cross $$C \
2823           --hint src/lint-hints \
2824           --cpp-file=$(HASKELL_PACKAGE_VERSIONS_FILE) \
2825           $(filter-out $(HLINT_EXCLUDES),$(HS_LIBTEST_SRCS) $(HS_PROG_SRCS))
2826         @if [ ! -f doc/hs-lint.html ]; then \
2827           echo "All good" > doc/hs-lint.html; \
2828         fi
2829
2830 # a dist hook rule for updating the vcs-version file; this is
2831 # hardcoded due to where it needs to build the file...
2832 dist-hook:
2833         $(MAKE) $(AM_MAKEFLAGS) regen-vcs-version
2834         rm -f $(top_distdir)/vcs-version
2835         cp -p $(srcdir)/vcs-version $(top_distdir)
2836
2837 # a distcheck hook rule for catching revision control directories
2838 distcheck-hook:
2839         if find $(top_distdir) -name .svn -or -name .git | grep .; then \
2840           echo "Found revision control files in final archive." 1>&2; \
2841           exit 1; \
2842         fi
2843         if find $(top_distdir) -name '*.py[co]' | grep .; then \
2844           echo "Found Python byte code in final archive." 1>&2; \
2845           exit 1; \
2846         fi
2847         if find $(top_distdir) -name '*~' | grep .; then \
2848           echo "Found backup files in final archive." 1>&2; \
2849           exit 1; \
2850         fi
2851 # Empty files or directories should not be distributed. They can cause
2852 # unnecessary warnings for packagers. Directories used by automake during
2853 # distcheck must be excluded.
2854         if find $(top_distdir) -empty -and -not \( \
2855             -path $(top_distdir)/_build -or \
2856             -path $(top_distdir)/_inst \) | grep .; then \
2857           echo "Found empty files or directories in final archive." 1>&2; \
2858           exit 1; \
2859         fi
2860         if test -e $(top_distdir)/doc/man-html; then \
2861           echo "Found documentation including man pages in final archive" >&2; \
2862           exit 1; \
2863         fi
2864
2865 # Backwards compatible distcheck-release target
2866 distcheck-release: distcheck
2867
2868 distrebuildcheck: dist
2869         set -e; \
2870         builddir=$$(mktemp -d $(abs_srcdir)/distrebuildcheck.XXXXXXX); \
2871         trap "echo Removing $$builddir; cd $(abs_srcdir); rm -rf $$builddir" EXIT; \
2872         cd $$builddir; \
2873         tar xzf $(abs_srcdir)/$(distdir).tar.gz; \
2874         cd $(distdir); \
2875         ./configure; \
2876         $(MAKE) maintainer-clean; \
2877         cp $(abs_srcdir)/vcs-version .; \
2878         ./configure; \
2879         $(MAKE) $(AM_MAKEFLAGS)
2880
2881 dist-release: dist
2882         set -e; \
2883         for i in $(DIST_ARCHIVES); do \
2884           echo -n "Checking $$i ... "; \
2885           autotools/check-tar < $$i; \
2886           echo OK; \
2887         done
2888
2889 install-exec-local:
2890         @mkdir_p@ "$(DESTDIR)${localstatedir}/lib/ganeti" \
2891           "$(DESTDIR)${localstatedir}/log/ganeti" \
2892           "$(DESTDIR)${localstatedir}/run/ganeti"
2893         for dir in $(SYMLINK_TARGET_DIRS); do \
2894           @mkdir_p@  $(DESTDIR)$$dir; \
2895         done
2896         $(LN_S) -f $(sysconfdir)/ganeti/lib $(DESTDIR)$(defaultversiondir)
2897         $(LN_S) -f $(sysconfdir)/ganeti/share $(DESTDIR)$(defaultversionedsharedir)
2898         for prog in $(HS_BIN_ROLES); do \
2899           $(LN_S) -f $(defaultversiondir)$(BINDIR)/$$prog $(DESTDIR)$(BINDIR)/$$prog; \
2900         done
2901         $(LN_S) -f $(defaultversiondir)$(libdir)/ganeti/iallocators/hail $(DESTDIR)$(libdir)/ganeti/iallocators/hail
2902         for prog in $(all_sbin_scripts); do \
2903           $(LN_S) -f $(defaultversiondir)$(SBINDIR)/$$prog $(DESTDIR)$(SBINDIR)/$$prog; \
2904         done
2905         for prog in $(gnt_scripts_basenames); do \
2906           $(LN_S) -f $(defaultversionedsharedir)/$$prog $(DESTDIR)$(SBINDIR)/$$prog; \
2907         done
2908         for prog in $(pkglib_python_basenames); do \
2909           $(LN_S) -f $(defaultversionedsharedir)/$$prog $(DESTDIR)$(libdir)/ganeti/$$prog; \
2910         done
2911         for prog in $(tools_python_basenames); do \
2912           $(LN_S) -f $(defaultversionedsharedir)/$$prog $(DESTDIR)$(libdir)/ganeti/tools/$$prog; \
2913         done
2914         for prog in $(tools_basenames); do \
2915           $(LN_S) -f $(defaultversiondir)/$(libdir)/ganeti/tools/$$prog $(DESTDIR)$(libdir)/ganeti/tools/$$prog; \
2916         done
2917         if ! test -n '$(ENABLE_MANPAGES)'; then \
2918           for man in $(manfullpath); do \
2919             $(LN_S) -f $(defaultversionedsharedir)/root$(MANDIR)/$$man $(DESTDIR)$(MANDIR)/$$man; \
2920           done; \
2921         fi
2922         for prog in $(myexeclib_scripts_basenames); do \
2923           $(LN_S) -f $(defaultversiondir)$(libdir)/ganeti/$$prog $(DESTDIR)$(libdir)/ganeti/$$prog; \
2924         done
2925 if INSTALL_SYMLINKS
2926         $(LN_S) -f $(versionedsharedir) $(DESTDIR)$(sysconfdir)/ganeti/share
2927         $(LN_S) -f $(versiondir) $(DESTDIR)$(sysconfdir)/ganeti/lib
2928 endif
2929
2930 .PHONY: apidoc
2931 if WANT_HSAPIDOC
2932 apidoc: py-apidoc hs-apidoc
2933 else
2934 apidoc: py-apidoc
2935 endif
2936
2937 .PHONY: py-apidoc
2938 py-apidoc: epydoc.conf $(RUN_IN_TEMPDIR) $(GENERATED_FILES)
2939         env - PATH="$$PATH" PYTHONPATH="$$PYTHONPATH" \
2940         $(RUN_IN_TEMPDIR) epydoc -v \
2941           --conf $(CURDIR)/epydoc.conf \
2942           --output $(CURDIR)/$(APIDOC_PY_DIR)
2943
2944 .PHONY: hs-apidoc
2945 hs-apidoc: $(APIDOC_HS_DIR)/index.html
2946
2947 $(APIDOC_HS_DIR)/index.html: $(HS_LIBTESTBUILT_SRCS) Makefile
2948         @test -n "$(HSCOLOUR)" || \
2949             { echo 'HsColour' not found during configure; exit 1; }
2950         @test -n "$(HADDOCK)" || \
2951             { echo 'haddock' not found during configure; exit 1; }
2952         rm -rf $(APIDOC_HS_DIR)/*
2953         for i in $(ALL_APIDOC_HS_DIRS); do \
2954           @mkdir_p@ $$i; \
2955           $(HSCOLOUR) -print-css > $$i/hscolour.css; \
2956         done
2957         set -e ; \
2958         export LC_ALL=en_US.UTF-8; \
2959         OPTGHC="--optghc=-isrc --optghc=-itest/hs"; \
2960         OPTGHC="$$OPTGHC --optghc=-optP-include --optghc=-optP$(HASKELL_PACKAGE_VERSIONS_FILE)"; \
2961         for file in $(HS_LIBTESTBUILT_SRCS); do \
2962           f_nosrc=$${file##src/}; \
2963           f_notst=$${f_nosrc##test/hs/}; \
2964           f_html=$${f_notst%%.hs}.html; \
2965           $(HSCOLOUR) -css -anchor $$file > $(APIDOC_HS_DIR)/$$f_html ; \
2966         done ; \
2967         $(HADDOCK) --odir $(APIDOC_HS_DIR) --html --hoogle --ignore-all-exports -w \
2968           -t ganeti -p src/haddock-prologue \
2969           --source-module="%{MODULE/.//}.html" \
2970           --source-entity="%{MODULE/.//}.html#%{NAME}" \
2971           $$OPTGHC \
2972           $(HS_LIBTESTBUILT_SRCS)
2973
2974 .PHONY: TAGS
2975 TAGS: $(GENERATED_FILES)
2976         rm -f TAGS
2977         $(GHC) -e ":etags TAGS_hs" -v0 \
2978           $(filter-out -O -Werror,$(HFLAGS)) \
2979                 -osuf tags.o \
2980                 -hisuf tags.hi \
2981         -lcurl \
2982           $(HS_LIBTEST_SRCS)
2983         find . -path './lib/*.py' -o -path './scripts/gnt-*' -o \
2984           -path './daemons/ganeti-*' -o -path './tools/*' -o \
2985           -path './qa/*.py' | \
2986           etags --etags-include=TAGS_hs -L -
2987
2988 .PHONY: coverage
2989
2990 COVERAGE_TESTS=
2991 if HS_UNIT
2992 COVERAGE_TESTS += hs-coverage
2993 endif
2994 if PY_UNIT
2995 COVERAGE_TESTS += py-coverage
2996 endif
2997
2998 coverage: $(COVERAGE_TESTS)
2999
3000 test/py/docs_unittest.py: $(gnt_scripts)
3001
3002 .PHONY: py-coverage
3003 py-coverage: $(GENERATED_FILES) $(python_tests)
3004         @test -n "$(PYCOVERAGE)" || \
3005             { echo 'python-coverage' not found during configure; exit 1; }
3006         set -e; \
3007         COVERAGE=$(PYCOVERAGE) \
3008         COVERAGE_FILE=$(CURDIR)/$(COVERAGE_PY_DIR)/data \
3009         TEXT_COVERAGE=$(CURDIR)/$(COVERAGE_PY_DIR)/report.txt \
3010         HTML_COVERAGE=$(CURDIR)/$(COVERAGE_PY_DIR) \
3011         $(PLAIN_TESTS_ENVIRONMENT) \
3012         $(abs_top_srcdir)/autotools/gen-py-coverage \
3013         $(python_tests)
3014
3015 .PHONY: hs-coverage
3016 hs-coverage: $(haskell_tests) test/hs/hpc-htools test/hs/hpc-mon-collector
3017         rm -f *.tix
3018         $(MAKE) $(AM_MAKEFLAGS) hs-check
3019         @mkdir_p@ $(COVERAGE_HS_DIR)
3020         hpc sum --union $(HPCEXCL) \
3021           htest.tix hpc-htools.tix hpc-mon-collector.tix > coverage-hs.tix
3022         hpc markup --destdir=$(COVERAGE_HS_DIR) coverage-hs.tix
3023         hpc report coverage-hs.tix | tee $(COVERAGE_HS_DIR)/report.txt
3024         $(LN_S) -f hpc_index.html $(COVERAGE_HS_DIR)/index.html
3025
3026 # Special "kind-of-QA" target for htools, needs special setup (all
3027 # tools compiled with -fhpc)
3028 .PHONY: live-test
3029 live-test: all
3030         set -e ; \
3031         cd src; \
3032         rm -f .hpc; $(LN_S) ../.hpc .hpc; \
3033         rm -f *.tix *.mix; \
3034         ./live-test.sh; \
3035         hpc sum --union $(HPCEXCL) $(addsuffix .tix,$(HS_PROGS:src/%=%)) \
3036           --output=live-test.tix ; \
3037         @mkdir_p@ ../$(COVERAGE_HS_DIR) ; \
3038         hpc markup --destdir=../$(COVERAGE_HS_DIR) live-test \
3039           --srcdir=.. $(HPCEXCL) ; \
3040         hpc report --srcdir=.. live-test $(HPCEXCL)
3041
3042 commit-check: autotools-check distcheck lint apidoc
3043
3044 autotools-check:
3045         TESTDATA_DIR=./test/data shelltest $(SHELLTESTARGS) \
3046   $(abs_top_srcdir)/test/autotools/*-*.test \
3047   -- --hide-successes
3048
3049 .PHONY: gitignore-check
3050 gitignore-check:
3051         @if [ -n "`git status --short`" ]; then \
3052           echo "Git status is not clean!" 1>&2 ; \
3053           git status --short; \
3054           exit 1; \
3055         fi
3056
3057 # target to rebuild all man pages (both groff and html output)
3058 .PHONY: man
3059 man: $(man_MANS) $(manhtml)
3060
3061 CABAL_EXECUTABLES = $(HS_DEFAULT_PROGS)
3062 CABAL_EXECUTABLES_HS = $(patsubst %,%.hs,$(CABAL_EXECUTABLES))
3063 CABAL_EXECUTABLES_APPS_STAMPS = $(patsubst src/%,apps/%.hs.stamp,$(patsubst test/hs/%,apps/%.hs.stamp,$(CABAL_EXECUTABLES)))
3064
3065 # Executable symlinks
3066 apps/%.hs.stamp: Makefile
3067         mkdir -p apps
3068         rm -f $(basename $@)
3069         ln -s ../$(filter %/$(basename $(notdir $@)),$(CABAL_EXECUTABLES_HS)) $(basename $@)
3070         touch $@
3071
3072 # Builds the cabal file
3073 ganeti.cabal: cabal/ganeti.template.cabal Makefile cabal/cabal-from-modules.py $(CABAL_EXECUTABLES_APPS_STAMPS)
3074         @echo $(subst /,.,$(patsubst %.hs,%,$(patsubst test/hs/%,%,$(patsubst src/%,%,$(HS_SRCS))))) \
3075           | python $(abs_top_srcdir)/cabal/cabal-from-modules.py $(abs_top_srcdir)/cabal/ganeti.template.cabal > $@
3076
3077         for p in $(CABAL_EXECUTABLES); do \
3078           echo                                   >> $@; \
3079           echo "executable `basename $$p`"       >> $@; \
3080           echo "  hs-source-dirs: apps"          >> $@; \
3081           echo "  main-is: `basename $$p`.hs"    >> $@; \
3082           echo "  default-language: Haskell2010" >> $@; \
3083           echo "  build-depends:"                >> $@; \
3084           echo "      base"                      >> $@; \
3085           echo "    , ganeti"                    >> $@; \
3086           if [ $$p == test/hs/htest ]; then \
3087             echo "    , hslogger"                  >> $@; \
3088             echo "    , test-framework"            >> $@; \
3089           elif [ $$p == src/rpc-test ]; then \
3090             echo "    , json"                      >> $@; \
3091           fi \
3092         done
3093
3094 # Target that builds all binaries (including those that are not
3095 # rebuilt except when running the tests)
3096 .PHONY: really-all
3097 really-all: all $(check_SCRIPTS) $(haskell_tests) $(HS_ALL_PROGS)
3098
3099 # we don't need the ancient implicit rules:
3100 %: %,v
3101 %: RCS/%,v
3102 %: RCS/%
3103 %: s.%
3104 %: SCCS/s.%
3105
3106 -include ./Makefile.local
3107
3108 # support inspecting the value of a make variable
3109
3110 print-%:
3111         @echo $($*)
3112
3113 # vim: set noet :