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