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