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