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