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