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