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