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