Design doc for partitioned Ganeti
[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 # Use bash in order to be able to use pipefail
18 SHELL=/bin/bash
19
20 ACLOCAL_AMFLAGS = -I autotools
21 BUILD_BASH_COMPLETION = $(top_srcdir)/autotools/build-bash-completion
22 RUN_IN_TEMPDIR = $(top_srcdir)/autotools/run-in-tempdir
23 CHECK_PYTHON_CODE = $(top_srcdir)/autotools/check-python-code
24 CHECK_HEADER = $(top_srcdir)/autotools/check-header
25 CHECK_MAN_DASHES = $(top_srcdir)/autotools/check-man-dashes
26 CHECK_MAN_WARNINGS = $(top_srcdir)/autotools/check-man-warnings
27 CHECK_VERSION = $(top_srcdir)/autotools/check-version
28 CHECK_NEWS = $(top_srcdir)/autotools/check-news
29 CHECK_IMPORTS = $(top_srcdir)/autotools/check-imports
30 DOCPP = $(top_srcdir)/autotools/docpp
31 REPLACE_VARS_SED = autotools/replace_vars.sed
32 CONVERT_CONSTANTS = $(top_srcdir)/autotools/convert-constants
33 BUILD_RPC = $(top_srcdir)/autotools/build-rpc
34 SHELL_ENV_INIT = autotools/shell-env-init
35
36 # Note: these are automake-specific variables, and must be named after
37 # the directory + 'dir' suffix
38 clientdir = $(pkgpythondir)/client
39 hypervisordir = $(pkgpythondir)/hypervisor
40 httpdir = $(pkgpythondir)/http
41 masterddir = $(pkgpythondir)/masterd
42 confddir = $(pkgpythondir)/confd
43 rapidir = $(pkgpythondir)/rapi
44 serverdir = $(pkgpythondir)/server
45 watcherdir = $(pkgpythondir)/watcher
46 impexpddir = $(pkgpythondir)/impexpd
47 utilsdir = $(pkgpythondir)/utils
48 toolsdir = $(pkglibdir)/tools
49 iallocatorsdir = $(pkglibdir)/iallocators
50 pytoolsdir = $(pkgpythondir)/tools
51 docdir = $(datadir)/doc/$(PACKAGE)
52 myexeclibdir = $(pkglibdir)
53
54 # Delete output file if an error occurred while building it
55 .DELETE_ON_ERROR:
56
57 HTOOLS_DIRS = \
58         htools \
59         htools/Ganeti \
60         htools/Ganeti/Confd \
61         htools/Ganeti/HTools \
62         htools/Ganeti/HTools/Program \
63         htools/Ganeti/Query \
64         htest \
65         htest/Test \
66         htest/Test/Ganeti \
67         htest/Test/Ganeti/Confd \
68         htest/Test/Ganeti/HTools \
69         htest/Test/Ganeti/Query
70
71 DIRS = \
72         autotools \
73         daemons \
74         devel \
75         doc \
76         doc/examples \
77         doc/examples/hooks \
78         doc/examples/gnt-debug \
79         $(HTOOLS_DIRS) \
80         lib \
81         lib/client \
82         lib/build \
83         lib/confd \
84         lib/http \
85         lib/hypervisor \
86         lib/impexpd \
87         lib/masterd \
88         lib/rapi \
89         lib/server \
90         lib/tools \
91         lib/utils \
92         lib/watcher \
93         man \
94         qa \
95         test \
96         test/data \
97         test/data/ovfdata \
98         test/data/ovfdata/other \
99         htest/data \
100         htest/data/rapi \
101         htest/shelltests \
102         tools
103
104 BUILDTIME_DIR_AUTOCREATE = \
105         scripts \
106         $(APIDOC_DIR) \
107         $(APIDOC_PY_DIR) \
108         $(APIDOC_HS_DIR) \
109         $(APIDOC_HS_DIR)/Ganeti \
110         $(APIDOC_HS_DIR)/Ganeti/Confd \
111         $(APIDOC_HS_DIR)/Ganeti/HTools \
112         $(APIDOC_HS_DIR)/Ganeti/HTools/Program \
113         $(APIDOC_HS_DIR)/Ganeti/Query \
114         $(COVERAGE_DIR) \
115         $(COVERAGE_PY_DIR) \
116         $(COVERAGE_HS_DIR) \
117         .hpc
118
119 BUILDTIME_DIRS = \
120         $(BUILDTIME_DIR_AUTOCREATE) \
121         doc/html
122
123 DIRCHECK_EXCLUDE = \
124         $(BUILDTIME_DIRS) \
125         ganeti-[0-9]*.[0-9]*.[0-9]* \
126         doc/html/_*
127
128 # some helper vars
129 COVERAGE_DIR = doc/coverage
130 COVERAGE_PY_DIR = $(COVERAGE_DIR)/py
131 COVERAGE_HS_DIR = $(COVERAGE_DIR)/hs
132 APIDOC_DIR = doc/api
133 APIDOC_PY_DIR = $(APIDOC_DIR)/py
134 APIDOC_HS_DIR = $(APIDOC_DIR)/hs
135
136 MAINTAINERCLEANFILES = \
137         $(docpng) \
138         $(maninput) \
139         doc/install-quick.rst \
140         doc/news.rst \
141         doc/upgrade.rst \
142         vcs-version
143
144 maintainer-clean-local:
145         rm -rf $(BUILDTIME_DIRS)
146
147 CLEANFILES = \
148         $(addsuffix /*.py[co],$(DIRS)) \
149         $(addsuffix /*.hi,$(HTOOLS_DIRS)) \
150         $(addsuffix /*.o,$(HTOOLS_DIRS)) \
151         $(PYTHON_BOOTSTRAP) \
152         epydoc.conf \
153         $(REPLACE_VARS_SED) \
154         $(SHELL_ENV_INIT) \
155         daemons/daemon-util \
156         daemons/ganeti-cleaner \
157         daemons/ganeti-master-cleaner \
158         devel/upload \
159         $(BUILT_EXAMPLES) \
160         doc/examples/bash_completion \
161         doc/examples/bash_completion-debug \
162         lib/_generated_rpc.py \
163         $(man_MANS) \
164         $(manhtml) \
165         tools/kvm-ifup \
166         tools/vcluster-setup \
167         stamp-directories \
168         stamp-srclinks \
169         $(nodist_pkgpython_PYTHON) \
170         $(HS_ALL_PROGS) $(HS_BUILT_SRCS) \
171         $(HS_BUILT_TEST_HELPERS) \
172         htools/ganeti-confd \
173         .hpc/*.mix htools/*.tix htest/*.tix \
174         doc/hs-lint.html
175
176 GENERATED_FILES = \
177         $(built_base_sources) \
178         $(BUILT_PYTHON_SOURCES) \
179         $(PYTHON_BOOTSTRAP)
180
181 HTOOLS_GENERATED_FILES =
182 if WANT_HTOOLS
183 HTOOLS_GENERATED_FILES += $(HS_PROGS)
184 if ENABLE_CONFD
185 HTOOLS_GENERATED_FILES += htools/hconfd
186 endif
187 endif
188
189 built_base_sources = \
190         stamp-directories \
191         stamp-srclinks
192
193 built_python_base_sources = \
194         lib/_autoconf.py \
195         lib/_vcsversion.py
196
197 BUILT_PYTHON_SOURCES = \
198         $(built_python_base_sources) \
199         lib/_generated_rpc.py
200
201 # Generating the RPC wrappers depends on many things, so make sure
202 # it's built at the end of the built sources
203 lib/_generated_rpc.py: | $(built_base_sources) $(built_python_base_sources)
204
205 # these are all built from the underlying %.in sources
206 BUILT_EXAMPLES = \
207         doc/examples/ganeti-kvm-poweroff.initd \
208         doc/examples/ganeti.cron \
209         doc/examples/ganeti.initd \
210         doc/examples/gnt-config-backup \
211         doc/examples/hooks/ipsec
212
213 nodist_pkgpython_PYTHON = \
214         $(BUILT_PYTHON_SOURCES)
215
216 noinst_PYTHON = \
217         lib/build/__init__.py \
218         lib/build/sphinx_ext.py \
219         lib/build/shell_example_lexer.py
220
221 pkgpython_PYTHON = \
222         lib/__init__.py \
223         lib/asyncnotifier.py \
224         lib/backend.py \
225         lib/bdev.py \
226         lib/bootstrap.py \
227         lib/cli.py \
228         lib/cmdlib.py \
229         lib/compat.py \
230         lib/config.py \
231         lib/constants.py \
232         lib/daemon.py \
233         lib/errors.py \
234         lib/ht.py \
235         lib/jqueue.py \
236         lib/jstore.py \
237         lib/locking.py \
238         lib/luxi.py \
239         lib/mcpu.py \
240         lib/netutils.py \
241         lib/objects.py \
242         lib/objectutils.py \
243         lib/opcodes.py \
244         lib/ovf.py \
245         lib/pathutils.py \
246         lib/qlang.py \
247         lib/query.py \
248         lib/rpc.py \
249         lib/rpc_defs.py \
250         lib/runtime.py \
251         lib/serializer.py \
252         lib/ssconf.py \
253         lib/ssh.py \
254         lib/storage.py \
255         lib/uidpool.py \
256         lib/vcluster.py \
257         lib/workerpool.py
258
259 client_PYTHON = \
260         lib/client/__init__.py \
261         lib/client/gnt_backup.py \
262         lib/client/gnt_cluster.py \
263         lib/client/gnt_debug.py \
264         lib/client/gnt_group.py \
265         lib/client/gnt_instance.py \
266         lib/client/gnt_job.py \
267         lib/client/gnt_node.py \
268         lib/client/gnt_os.py
269
270 hypervisor_PYTHON = \
271         lib/hypervisor/__init__.py \
272         lib/hypervisor/hv_base.py \
273         lib/hypervisor/hv_chroot.py \
274         lib/hypervisor/hv_fake.py \
275         lib/hypervisor/hv_kvm.py \
276         lib/hypervisor/hv_lxc.py \
277         lib/hypervisor/hv_xen.py
278
279 rapi_PYTHON = \
280         lib/rapi/__init__.py \
281         lib/rapi/baserlib.py \
282         lib/rapi/client.py \
283         lib/rapi/client_utils.py \
284         lib/rapi/connector.py \
285         lib/rapi/rlib2.py \
286         lib/rapi/testutils.py
287
288 http_PYTHON = \
289         lib/http/__init__.py \
290         lib/http/auth.py \
291         lib/http/client.py \
292         lib/http/server.py
293
294 confd_PYTHON = \
295         lib/confd/__init__.py \
296         lib/confd/client.py
297
298 masterd_PYTHON = \
299         lib/masterd/__init__.py \
300         lib/masterd/iallocator.py \
301         lib/masterd/instance.py
302
303 impexpd_PYTHON = \
304         lib/impexpd/__init__.py
305
306 watcher_PYTHON = \
307         lib/watcher/__init__.py \
308         lib/watcher/nodemaint.py \
309         lib/watcher/state.py
310
311 server_PYTHON = \
312         lib/server/__init__.py \
313         lib/server/masterd.py \
314         lib/server/noded.py \
315         lib/server/rapi.py
316
317 pytools_PYTHON = \
318         lib/tools/__init__.py \
319         lib/tools/ensure_dirs.py
320
321 utils_PYTHON = \
322         lib/utils/__init__.py \
323         lib/utils/algo.py \
324         lib/utils/filelock.py \
325         lib/utils/hash.py \
326         lib/utils/io.py \
327         lib/utils/log.py \
328         lib/utils/mlock.py \
329         lib/utils/nodesetup.py \
330         lib/utils/process.py \
331         lib/utils/retry.py \
332         lib/utils/text.py \
333         lib/utils/wrapper.py \
334         lib/utils/x509.py
335
336 docrst = \
337         doc/admin.rst \
338         doc/design-2.0.rst \
339         doc/design-2.1.rst \
340         doc/design-2.2.rst \
341         doc/design-2.3.rst \
342         doc/design-htools-2.3.rst \
343         doc/design-2.4.rst \
344         doc/design-2.5.rst \
345         doc/design-draft.rst \
346         doc/design-oob.rst \
347         doc/design-cpu-pinning.rst \
348         doc/design-query2.rst \
349         doc/design-x509-ca.rst \
350         doc/design-http-server.rst \
351         doc/design-impexp2.rst \
352         doc/design-lu-generated-jobs.rst \
353         doc/design-multi-reloc.rst \
354         doc/design-network.rst \
355         doc/design-chained-jobs.rst \
356         doc/design-ovf-support.rst \
357         doc/design-autorepair.rst \
358         doc/design-resource-model.rst \
359         doc/cluster-merge.rst \
360         doc/design-shared-storage.rst \
361         doc/design-node-state-cache.rst \
362         doc/design-virtual-clusters.rst \
363         doc/design-bulk-create.rst \
364         doc/design-query-splitting.rst \
365         doc/design-partitioned.rst \
366         doc/devnotes.rst \
367         doc/glossary.rst \
368         doc/hooks.rst \
369         doc/iallocator.rst \
370         doc/index.rst \
371         doc/install-quick.rst \
372         doc/install.rst \
373         doc/locking.rst \
374         doc/move-instance.rst \
375         doc/news.rst \
376         doc/ovfconverter.rst \
377         doc/rapi.rst \
378         doc/security.rst \
379         doc/upgrade.rst \
380         doc/virtual-cluster.rst \
381         doc/walkthrough.rst
382
383 HS_PROGS = htools/htools
384 HS_BIN_ROLES = hbal hscan hspace hinfo hcheck
385 HS_HTOOLS_PROGS = $(HS_BIN_ROLES) hail
386
387 HS_ALL_PROGS = $(HS_PROGS) htest/test htest/hpc-htools htools/hconfd
388 HS_PROG_SRCS = $(patsubst %,%.hs,$(HS_ALL_PROGS))
389 HS_BUILT_TEST_HELPERS = $(HS_BIN_ROLES:%=htest/%) htest/hail
390
391 HFLAGS = -O -Wall -Werror -fwarn-monomorphism-restriction -fwarn-tabs -ihtools
392 # extra flags that can be overriden on the command line (e.g. -Wwarn, etc.)
393 HEXTRA =
394 # internal extra flags (used for htest/test mainly)
395 HEXTRA_INT =
396 # exclude options for coverage reports
397 HPCEXCL = --exclude Main \
398         --exclude Ganeti.Constants \
399         --exclude Ganeti.THH \
400         --exclude Ganeti.HTools.QC \
401         --exclude Ganeti.Version \
402         --exclude Test.Ganeti.TestCommon \
403         --exclude Test.Ganeti.TestHTools \
404         --exclude Test.Ganeti.TestHelper \
405         --exclude Test.Ganeti.TestImports \
406         $(patsubst htools.%,--exclude Test.%,$(subst /,.,$(patsubst %.hs,%, $(HS_LIB_SRCS))))
407
408 HS_LIB_SRCS = \
409         htools/Ganeti/HTools/CLI.hs \
410         htools/Ganeti/HTools/Cluster.hs \
411         htools/Ganeti/HTools/Container.hs \
412         htools/Ganeti/HTools/ExtLoader.hs \
413         htools/Ganeti/HTools/Group.hs \
414         htools/Ganeti/HTools/IAlloc.hs \
415         htools/Ganeti/HTools/Instance.hs \
416         htools/Ganeti/HTools/Loader.hs \
417         htools/Ganeti/HTools/Luxi.hs \
418         htools/Ganeti/HTools/Node.hs \
419         htools/Ganeti/HTools/PeerMap.hs \
420         htools/Ganeti/HTools/Rapi.hs \
421         htools/Ganeti/HTools/Simu.hs \
422         htools/Ganeti/HTools/Text.hs \
423         htools/Ganeti/HTools/Types.hs \
424         htools/Ganeti/HTools/Utils.hs \
425         htools/Ganeti/HTools/Program.hs \
426         htools/Ganeti/HTools/Program/Hail.hs \
427         htools/Ganeti/HTools/Program/Hbal.hs \
428         htools/Ganeti/HTools/Program/Hcheck.hs \
429         htools/Ganeti/HTools/Program/Hinfo.hs \
430         htools/Ganeti/HTools/Program/Hscan.hs \
431         htools/Ganeti/HTools/Program/Hspace.hs \
432         htools/Ganeti/BasicTypes.hs \
433         htools/Ganeti/Common.hs \
434         htools/Ganeti/Compat.hs \
435         htools/Ganeti/Confd.hs \
436         htools/Ganeti/Confd/Server.hs \
437         htools/Ganeti/Confd/Utils.hs \
438         htools/Ganeti/Config.hs \
439         htools/Ganeti/Daemon.hs \
440         htools/Ganeti/Hash.hs \
441         htools/Ganeti/Jobs.hs \
442         htools/Ganeti/JSON.hs \
443         htools/Ganeti/Logging.hs \
444         htools/Ganeti/Luxi.hs \
445         htools/Ganeti/Objects.hs \
446         htools/Ganeti/OpCodes.hs \
447         htools/Ganeti/Path.hs \
448         htools/Ganeti/Query/Common.hs \
449         htools/Ganeti/Query/Filter.hs \
450         htools/Ganeti/Query/Group.hs \
451         htools/Ganeti/Query/Language.hs \
452         htools/Ganeti/Query/Node.hs \
453         htools/Ganeti/Query/Query.hs \
454         htools/Ganeti/Query/Server.hs \
455         htools/Ganeti/Query/Types.hs \
456         htools/Ganeti/Rpc.hs \
457         htools/Ganeti/Runtime.hs \
458         htools/Ganeti/Ssconf.hs \
459         htools/Ganeti/THH.hs
460
461 HS_TEST_SRCS = \
462         htest/Test/Ganeti/BasicTypes.hs \
463         htest/Test/Ganeti/Common.hs \
464         htest/Test/Ganeti/Daemon.hs \
465         htest/Test/Ganeti/Confd/Utils.hs \
466         htest/Test/Ganeti/HTools/CLI.hs \
467         htest/Test/Ganeti/HTools/Cluster.hs \
468         htest/Test/Ganeti/HTools/Container.hs \
469         htest/Test/Ganeti/HTools/Instance.hs \
470         htest/Test/Ganeti/HTools/Loader.hs \
471         htest/Test/Ganeti/HTools/Node.hs \
472         htest/Test/Ganeti/HTools/PeerMap.hs \
473         htest/Test/Ganeti/HTools/Simu.hs \
474         htest/Test/Ganeti/HTools/Text.hs \
475         htest/Test/Ganeti/HTools/Types.hs \
476         htest/Test/Ganeti/HTools/Utils.hs \
477         htest/Test/Ganeti/JSON.hs \
478         htest/Test/Ganeti/Jobs.hs \
479         htest/Test/Ganeti/Luxi.hs \
480         htest/Test/Ganeti/Objects.hs \
481         htest/Test/Ganeti/OpCodes.hs \
482         htest/Test/Ganeti/Query/Filter.hs \
483         htest/Test/Ganeti/Query/Language.hs \
484         htest/Test/Ganeti/Query/Query.hs \
485         htest/Test/Ganeti/Rpc.hs \
486         htest/Test/Ganeti/Ssconf.hs \
487         htest/Test/Ganeti/TestCommon.hs \
488         htest/Test/Ganeti/TestHTools.hs \
489         htest/Test/Ganeti/TestHelper.hs
490
491 HS_LIBTEST_SRCS = $(HS_LIB_SRCS) $(HS_TEST_SRCS)
492
493 HS_BUILT_SRCS = \
494         htest/Test/Ganeti/TestImports.hs \
495         htools/Ganeti/Constants.hs \
496         htools/Ganeti/Version.hs
497 HS_BUILT_SRCS_IN = $(patsubst %,%.in,$(HS_BUILT_SRCS))
498
499 $(RUN_IN_TEMPDIR): | stamp-directories
500
501 # Note: we use here an order-only prerequisite, as the contents of
502 # _autoconf.py are not actually influencing the html build output: it
503 # has to exist in order for the sphinx module to be loaded
504 # successfully, but we certainly don't want the docs to be rebuilt if
505 # it changes
506 doc/html/index.html: $(docrst) $(docpng) doc/conf.py configure.ac \
507         $(RUN_IN_TEMPDIR) lib/build/sphinx_ext.py \
508         lib/build/shell_example_lexer.py lib/opcodes.py lib/ht.py \
509         | $(BUILT_PYTHON_SOURCES)
510         @test -n "$(SPHINX)" || \
511             { echo 'sphinx-build' not found during configure; exit 1; }
512         @mkdir_p@ $(dir $@)
513         PYTHONPATH=. $(RUN_IN_TEMPDIR) $(SPHINX) -q -W -b html \
514             -d . \
515             -D version="$(VERSION_MAJOR).$(VERSION_MINOR)" \
516             -D release="$(PACKAGE_VERSION)" \
517             $(abs_top_srcdir)/doc $(CURDIR)/doc/html
518         rm -f doc/html/.buildinfo doc/html/objects.inv
519         touch $@
520
521 doc/html: doc/html/index.html
522
523 doc/install-quick.rst: INSTALL
524 doc/news.rst: NEWS
525 doc/upgrade.rst: UPGRADE
526
527 doc/install-quick.rst doc/news.rst doc/upgrade.rst:
528         set -e; \
529         { echo '.. This file is automatically updated at build time from $<.'; \
530           echo '.. Do not edit.'; \
531           echo; \
532           cat $<; \
533         } > $@
534
535 docdot = \
536         doc/arch-2.0.dot \
537         doc/design-2.1-lock-acquire.dot \
538         doc/design-2.1-lock-release.dot
539
540 docpng = $(patsubst %.dot,%.png,$(docdot))
541
542 # Things to build but not to install (add it to EXTRA_DIST if it should be
543 # distributed)
544 noinst_DATA = \
545         devel/upload \
546         doc/html \
547         $(BUILT_EXAMPLES) \
548         doc/examples/bash_completion \
549         doc/examples/bash_completion-debug \
550         $(manhtml)
551
552 gnt_scripts = \
553         scripts/gnt-backup \
554         scripts/gnt-cluster \
555         scripts/gnt-debug \
556         scripts/gnt-group \
557         scripts/gnt-instance \
558         scripts/gnt-job \
559         scripts/gnt-node \
560         scripts/gnt-os
561
562 PYTHON_BOOTSTRAP_SBIN = \
563         daemons/ganeti-masterd \
564         daemons/ganeti-noded \
565         daemons/ganeti-watcher \
566         daemons/ganeti-rapi \
567         $(gnt_scripts)
568
569 PYTHON_BOOTSTRAP = \
570         $(PYTHON_BOOTSTRAP_SBIN) \
571         tools/ensure-dirs
572
573 qa_scripts = \
574         qa/__init__.py \
575         qa/ganeti-qa.py \
576         qa/qa_cluster.py \
577         qa/qa_config.py \
578         qa/qa_daemon.py \
579         qa/qa_env.py \
580         qa/qa_error.py \
581         qa/qa_group.py \
582         qa/qa_instance.py \
583         qa/qa_job.py \
584         qa/qa_node.py \
585         qa/qa_os.py \
586         qa/qa_rapi.py \
587         qa/qa_tags.py \
588         qa/qa_utils.py
589
590 bin_SCRIPTS =
591 if WANT_HTOOLS
592 bin_SCRIPTS += $(filter-out htools/hail,$(HS_PROGS))
593 install-exec-hook:
594         @mkdir_p@ $(DESTDIR)$(iallocatorsdir)
595 # FIXME: this is a hardcoded logic, instead of auto-resolving
596         $(LN_S) -f ../../../bin/htools \
597                    $(DESTDIR)$(iallocatorsdir)/hail
598         for role in $(HS_BIN_ROLES); do \
599                 $(LN_S) -f htools \
600                            $(DESTDIR)$(bindir)/$$role ; \
601         done
602 endif
603
604 $(HS_ALL_PROGS): %: %.hs $(HS_LIBTEST_SRCS) $(HS_BUILT_SRCS) Makefile
605         @if [ -z "$(HTOOLS)" ]; then \
606           echo "Error: htools compilation disabled at configure time" 1>&2 ;\
607           exit 1; \
608         fi
609         @if [ "$(notdir $@)" = "test" ] && [ -z "$(GHC_PKG_QUICKCHECK)" ]; then \
610           echo "Error: cannot run unittests without the QuickCheck library (see devnotes.rst)" 1>&2; \
611           exit 1; \
612         fi
613         @rm -f $(notdir $@).tix
614         $(GHC) --make \
615           $(HFLAGS) \
616           $(HTOOLS_NOCURL) $(HTOOLS_PARALLEL3) \
617           -osuf $(notdir $@).o -hisuf $(notdir $@).hi \
618           $(HEXTRA) $(HEXTRA_INT) $@
619         @touch "$@"
620
621 # for the htest/test binary, we need to enable profiling/coverage
622 htest/test: HEXTRA_INT=-fhpc -ihtest
623
624 # we compile the hpc-htools binary with the program coverage
625 htest/hpc-htools: HEXTRA_INT=-fhpc
626
627 # test dependency
628 htest/offline-tests.sh: htest/hpc-htools
629
630 # rules for building profiling-enabled versions of the haskell
631 # programs: hs-prof does the full two-step build, whereas
632 # hs-prof-quick does only the final rebuild (hs-prof must have been
633 # run before)
634 .PHONY: hs-prof hs-prof-quick
635 hs-prof:
636         $(MAKE) $(AM_MAKEFLAGS) clean
637         $(MAKE) $(AM_MAKEFLAGS) $(HS_ALL_PROGS) HEXTRA="-osuf .o"
638         rm -f $(HS_ALL_PROGS)
639         $(MAKE) $(AM_MAKEFLAGS) hs-prof-quick
640
641 hs-prof-quick:
642         $(MAKE) $(AM_MAKEFLAGS) $(HS_ALL_PROGS) HEXTRA="-osuf .prof_o -prof -auto-all"
643
644 dist_sbin_SCRIPTS = \
645         tools/ganeti-listrunner
646
647 nodist_sbin_SCRIPTS = \
648         $(PYTHON_BOOTSTRAP_SBIN) \
649         daemons/ganeti-cleaner \
650         daemons/ganeti-master-cleaner
651
652 if ENABLE_CONFD
653 htools/ganeti-confd: htools/hconfd
654         cp -f $< $@
655
656 nodist_sbin_SCRIPTS += htools/ganeti-confd
657 endif
658
659 python_scripts = \
660         tools/burnin \
661         tools/cfgshell \
662         tools/cfgupgrade \
663         tools/cfgupgrade12 \
664         tools/cluster-merge \
665         tools/confd-client \
666         tools/fmtjson \
667         tools/lvmstrap \
668         tools/move-instance \
669         tools/ovfconverter \
670         tools/setup-ssh \
671         tools/sanitize-config
672
673 dist_tools_SCRIPTS = \
674         $(python_scripts) \
675         tools/kvm-console-wrapper \
676         tools/xm-console-wrapper \
677         tools/master-ip-setup
678
679 nodist_tools_SCRIPTS = \
680         tools/vcluster-setup
681
682 pkglib_python_scripts = \
683         daemons/import-export \
684         tools/check-cert-expired
685
686 nodist_pkglib_python_scripts = \
687         tools/ensure-dirs
688
689 myexeclib_SCRIPTS = \
690         daemons/daemon-util \
691         tools/kvm-ifup \
692         $(pkglib_python_scripts)
693
694 nodist_myexeclib_SCRIPTS = \
695         $(nodist_pkglib_python_scripts)
696
697 EXTRA_DIST = \
698         NEWS \
699         UPGRADE \
700         epydoc.conf.in \
701         pylintrc \
702         autotools/build-bash-completion \
703         autotools/build-rpc \
704         autotools/check-header \
705         autotools/check-python-code \
706         autotools/check-imports \
707         autotools/check-man-dashes \
708         autotools/check-man-warnings \
709         autotools/check-news \
710         autotools/check-tar \
711         autotools/check-version \
712         autotools/convert-constants \
713         autotools/docpp \
714         autotools/gen-coverage \
715         autotools/testrunner \
716         autotools/wrong-hardcoded-paths \
717         $(RUN_IN_TEMPDIR) \
718         daemons/daemon-util.in \
719         daemons/ganeti-cleaner.in \
720         daemons/ganeti-master-cleaner.in \
721         $(pkglib_python_scripts) \
722         devel/upload.in \
723         tools/kvm-ifup.in \
724         tools/vcluster-setup.in \
725         $(docdot) \
726         $(docpng) \
727         $(docrst) \
728         doc/conf.py \
729         doc/html \
730         $(BUILT_EXAMPLES:%=%.in) \
731         doc/examples/ganeti.default \
732         doc/examples/ganeti.default-debug \
733         doc/examples/hooks/ethers \
734         doc/examples/gnt-debug/README \
735         doc/examples/gnt-debug/delay0.json \
736         doc/examples/gnt-debug/delay50.json \
737         test/lockperf.py \
738         test/testutils.py \
739         test/mocks.py \
740         $(dist_TESTS) \
741         $(TEST_FILES) \
742         man/footer.rst \
743         $(manrst) \
744         $(maninput) \
745         qa/qa-sample.json \
746         $(qa_scripts) \
747         $(HS_LIBTEST_SRCS) $(HS_BUILT_SRCS_IN) \
748         $(HS_PROG_SRCS) \
749         htools/lint-hints.hs \
750         htest/cli-tests-defs.sh \
751         htest/offline-test.sh
752
753 man_MANS = \
754         man/ganeti.7 \
755         man/ganeti-cleaner.8 \
756         man/ganeti-master-cleaner.8 \
757         man/ganeti-confd.8 \
758         man/ganeti-listrunner.8 \
759         man/ganeti-masterd.8 \
760         man/ganeti-noded.8 \
761         man/ganeti-os-interface.7 \
762         man/ganeti-rapi.8 \
763         man/ganeti-watcher.8 \
764         man/gnt-backup.8 \
765         man/gnt-cluster.8 \
766         man/gnt-debug.8 \
767         man/gnt-group.8 \
768         man/gnt-instance.8 \
769         man/gnt-job.8 \
770         man/gnt-node.8 \
771         man/gnt-os.8 \
772         man/hail.1 \
773         man/hbal.1 \
774         man/hcheck.1 \
775         man/hinfo.1 \
776         man/hscan.1 \
777         man/hspace.1 \
778         man/htools.1
779
780 manrst = $(patsubst %.1,%.rst,$(patsubst %.7,%.rst,$(patsubst %.8,%.rst,$(man_MANS))))
781 manhtml = $(patsubst %.rst,%.html,$(manrst))
782 mangen = $(patsubst %.rst,%.gen,$(manrst))
783 maninput = \
784         $(patsubst %.1,%.1.in,$(patsubst %.7,%.7.in,$(patsubst %.8,%.8.in,$(man_MANS)))) \
785         $(patsubst %.html,%.html.in,$(manhtml)) \
786         man/footer.man man/footer.html $(mangen)
787
788 TEST_FILES = \
789         test/data/bdev-drbd-8.0.txt \
790         test/data/bdev-drbd-8.3.txt \
791         test/data/bdev-drbd-disk.txt \
792         test/data/bdev-drbd-net-ip4.txt \
793         test/data/bdev-drbd-net-ip6.txt \
794         test/data/cert1.pem \
795         test/data/ip-addr-show-dummy0.txt \
796         test/data/ip-addr-show-lo-ipv4.txt \
797         test/data/ip-addr-show-lo-ipv6.txt \
798         test/data/ip-addr-show-lo-oneline-ipv4.txt \
799         test/data/ip-addr-show-lo-oneline-ipv6.txt \
800         test/data/ip-addr-show-lo-oneline.txt \
801         test/data/ip-addr-show-lo.txt \
802         test/data/proc_drbd8.txt \
803         test/data/proc_drbd80-emptyline.txt \
804         test/data/proc_drbd83.txt \
805         test/data/proc_drbd83_sync.txt \
806         test/data/proc_drbd83_sync_krnl2.6.39.txt \
807         test/data/kvm_1.0_help.txt \
808         test/data/kvm_0.15.90_help.txt \
809         test/data/kvm_0.12.5_help.txt \
810         test/data/kvm_0.9.1_help.txt \
811         test/data/sys_drbd_usermode_helper.txt \
812         test/data/ovfdata/compr_disk.vmdk.gz \
813         test/data/ovfdata/config.ini \
814         test/data/ovfdata/corrupted_resources.ovf \
815         test/data/ovfdata/empty.ini \
816         test/data/ovfdata/empty.ovf \
817         test/data/ovfdata/ganeti.mf \
818         test/data/ovfdata/ganeti.ovf \
819         test/data/ovfdata/gzip_disk.ovf \
820         test/data/ovfdata/new_disk.vmdk \
821         test/data/ovfdata/no_disk.ini \
822         test/data/ovfdata/no_disk_in_ref.ovf \
823         test/data/ovfdata/no_os.ini \
824         test/data/ovfdata/no_ovf.ova \
825         test/data/ovfdata/ova.ova \
826         test/data/ovfdata/second_disk.vmdk \
827         test/data/ovfdata/rawdisk.raw \
828         test/data/ovfdata/unsafe_path.ini \
829         test/data/ovfdata/virtualbox.ovf \
830         test/data/ovfdata/wrong_extension.ovd \
831         test/data/ovfdata/wrong_config.ini \
832         test/data/ovfdata/wrong_manifest.mf \
833         test/data/ovfdata/wrong_manifest.ovf \
834         test/data/ovfdata/wrong_ova.ova \
835         test/data/ovfdata/wrong_xml.ovf \
836         test/data/ovfdata/other/rawdisk.raw \
837         test/data/vgreduce-removemissing-2.02.02.txt \
838         test/data/vgreduce-removemissing-2.02.66-fail.txt \
839         test/data/vgreduce-removemissing-2.02.66-ok.txt \
840         test/data/vgs-missing-pvs-2.02.02.txt \
841         test/data/vgs-missing-pvs-2.02.66.txt \
842         test/import-export_unittest-helper \
843         test/gnt-cli.test \
844         test/ganeti-cli.test \
845         htest/shelltests/htools-balancing.test \
846         htest/shelltests/htools-basic.test \
847         htest/shelltests/htools-dynutil.test \
848         htest/shelltests/htools-excl.test \
849         htest/shelltests/htools-hail.test \
850         htest/shelltests/htools-hspace.test \
851         htest/shelltests/htools-invalid.test \
852         htest/shelltests/htools-multi-group.test \
853         htest/shelltests/htools-no-backend.test \
854         htest/shelltests/htools-rapi.test \
855         htest/shelltests/htools-single-group.test \
856         htest/shelltests/htools-text-backend.test \
857         htest/data/hail-alloc-drbd.json \
858         htest/data/hail-change-group.json \
859         htest/data/hail-invalid-reloc.json \
860         htest/data/hail-node-evac.json \
861         htest/data/hail-reloc-drbd.json \
862         htest/data/hbal-split-insts.data \
863         htest/data/common-suffix.data \
864         htest/data/invalid-node.data \
865         htest/data/missing-resources.data \
866         htest/data/rapi/groups.json \
867         htest/data/rapi/info.json \
868         htest/data/rapi/instances.json \
869         htest/data/rapi/nodes.json
870
871 python_tests = \
872         doc/examples/rapi_testutils.py \
873         test/ganeti.asyncnotifier_unittest.py \
874         test/ganeti.backend_unittest.py \
875         test/ganeti.bdev_unittest.py \
876         test/ganeti.cli_unittest.py \
877         test/ganeti.client.gnt_cluster_unittest.py \
878         test/ganeti.client.gnt_instance_unittest.py \
879         test/ganeti.daemon_unittest.py \
880         test/ganeti.cmdlib_unittest.py \
881         test/ganeti.compat_unittest.py \
882         test/ganeti.confd.client_unittest.py \
883         test/ganeti.config_unittest.py \
884         test/ganeti.constants_unittest.py \
885         test/ganeti.errors_unittest.py \
886         test/ganeti.hooks_unittest.py \
887         test/ganeti.ht_unittest.py \
888         test/ganeti.http_unittest.py \
889         test/ganeti.hypervisor_unittest.py \
890         test/ganeti.hypervisor.hv_chroot_unittest.py \
891         test/ganeti.hypervisor.hv_fake_unittest.py \
892         test/ganeti.hypervisor.hv_kvm_unittest.py \
893         test/ganeti.hypervisor.hv_lxc_unittest.py \
894         test/ganeti.hypervisor.hv_xen_unittest.py \
895         test/ganeti.impexpd_unittest.py \
896         test/ganeti.jqueue_unittest.py \
897         test/ganeti.jstore_unittest.py \
898         test/ganeti.locking_unittest.py \
899         test/ganeti.luxi_unittest.py \
900         test/ganeti.masterd.iallocator_unittest.py \
901         test/ganeti.masterd.instance_unittest.py \
902         test/ganeti.mcpu_unittest.py \
903         test/ganeti.netutils_unittest.py \
904         test/ganeti.objects_unittest.py \
905         test/ganeti.objectutils_unittest.py \
906         test/ganeti.opcodes_unittest.py \
907         test/ganeti.ovf_unittest.py \
908         test/ganeti.qlang_unittest.py \
909         test/ganeti.query_unittest.py \
910         test/ganeti.rapi.baserlib_unittest.py \
911         test/ganeti.rapi.client_unittest.py \
912         test/ganeti.rapi.resources_unittest.py \
913         test/ganeti.rapi.rlib2_unittest.py \
914         test/ganeti.rapi.testutils_unittest.py \
915         test/ganeti.rpc_unittest.py \
916         test/ganeti.runtime_unittest.py \
917         test/ganeti.serializer_unittest.py \
918         test/ganeti.ssh_unittest.py \
919         test/ganeti.storage_unittest.py \
920         test/ganeti.tools.ensure_dirs_unittest.py \
921         test/ganeti.uidpool_unittest.py \
922         test/ganeti.utils.algo_unittest.py \
923         test/ganeti.utils.filelock_unittest.py \
924         test/ganeti.utils.hash_unittest.py \
925         test/ganeti.utils.io_unittest.py \
926         test/ganeti.utils.io_unittest-runasroot.py \
927         test/ganeti.utils.log_unittest.py \
928         test/ganeti.utils.mlock_unittest.py \
929         test/ganeti.utils.nodesetup_unittest.py \
930         test/ganeti.utils.process_unittest.py \
931         test/ganeti.utils.retry_unittest.py \
932         test/ganeti.utils.text_unittest.py \
933         test/ganeti.utils.wrapper_unittest.py \
934         test/ganeti.utils.x509_unittest.py \
935         test/ganeti.utils_unittest.py \
936         test/ganeti.vcluster_unittest.py \
937         test/ganeti.workerpool_unittest.py \
938         test/qa.qa_config_unittest.py \
939         test/cfgupgrade_unittest.py \
940         test/docs_unittest.py \
941         test/pycurl_reset_unittest.py \
942         test/tempfile_fork_unittest.py
943
944 haskell_tests = htest/test
945
946 dist_TESTS = \
947         test/check-cert-expired_unittest.bash \
948         test/daemon-util_unittest.bash \
949         test/ganeti-cleaner_unittest.bash \
950         test/import-export_unittest.bash \
951         test/cli-test.bash \
952         test/bash_completion.bash \
953         $(python_tests)
954
955 nodist_TESTS =
956 check_SCRIPTS =
957
958 if WANT_HTOOLSTESTS
959 nodist_TESTS += $(haskell_tests)
960 dist_TESTS += htest/offline-test.sh
961 check_SCRIPTS += htest/hpc-htools $(HS_BUILT_TEST_HELPERS)
962 endif
963
964 TESTS = $(dist_TESTS) $(nodist_TESTS)
965
966 # Environment for all tests
967 PLAIN_TESTS_ENVIRONMENT = \
968         PYTHONPATH=. \
969         TOP_SRCDIR=$(abs_top_srcdir) TOP_BUILDDIR=$(abs_top_builddir) \
970         PYTHON=$(PYTHON) FAKEROOT=$(FAKEROOT_PATH) \
971         $(RUN_IN_TEMPDIR)
972
973 # Environment for tests run by automake
974 TESTS_ENVIRONMENT = \
975         $(PLAIN_TESTS_ENVIRONMENT) $(abs_top_srcdir)/autotools/testrunner
976
977 all_python_code = \
978         $(dist_sbin_SCRIPTS) \
979         $(python_scripts) \
980         $(pkglib_python_scripts) \
981         $(nodist_pkglib_python_scripts) \
982         $(python_tests) \
983         $(pkgpython_PYTHON) \
984         $(client_PYTHON) \
985         $(hypervisor_PYTHON) \
986         $(rapi_PYTHON) \
987         $(server_PYTHON) \
988         $(pytools_PYTHON) \
989         $(http_PYTHON) \
990         $(confd_PYTHON) \
991         $(masterd_PYTHON) \
992         $(impexpd_PYTHON) \
993         $(utils_PYTHON) \
994         $(watcher_PYTHON) \
995         $(noinst_PYTHON) \
996         $(qa_scripts)
997
998 srclink_files = \
999         man/footer.rst \
1000         test/check-cert-expired_unittest.bash \
1001         test/daemon-util_unittest.bash \
1002         test/ganeti-cleaner_unittest.bash \
1003         test/import-export_unittest.bash \
1004         test/cli-test.bash \
1005         test/bash_completion.bash \
1006         htest/offline-test.sh \
1007         htest/cli-tests-defs.sh \
1008         $(all_python_code) \
1009         $(HS_LIBTEST_SRCS) $(HS_PROG_SRCS)
1010
1011 check_python_code = \
1012         $(BUILD_BASH_COMPLETION) \
1013         $(CHECK_IMPORTS) \
1014         $(CHECK_HEADER) \
1015         $(DOCPP) \
1016         $(all_python_code)
1017
1018 lint_python_code = \
1019         ganeti \
1020         ganeti/http/server.py \
1021         $(dist_sbin_SCRIPTS) \
1022         $(python_scripts) \
1023         $(pkglib_python_scripts) \
1024         $(BUILD_BASH_COMPLETION) \
1025         $(CHECK_IMPORTS) \
1026         $(CHECK_HEADER) \
1027         $(DOCPP) \
1028         $(PYTHON_BOOTSTRAP)
1029
1030 standalone_python_modules = \
1031         lib/rapi/client.py \
1032         tools/ganeti-listrunner
1033
1034 pep8_python_code = \
1035         ganeti \
1036         ganeti/http/server.py \
1037         $(dist_sbin_SCRIPTS) \
1038         $(python_scripts) \
1039         $(pkglib_python_scripts) \
1040         $(BUILD_BASH_COMPLETION) \
1041         $(CHECK_HEADER) \
1042         $(DOCPP) \
1043         $(PYTHON_BOOTSTRAP) \
1044         qa
1045
1046 test/daemon-util_unittest.bash: daemons/daemon-util
1047
1048 test/ganeti-cleaner_unittest.bash: daemons/ganeti-cleaner \
1049   daemons/ganeti-master-cleaner
1050
1051 test/bash_completion.bash: doc/examples/bash_completion-debug
1052
1053 tools/kvm-ifup: tools/kvm-ifup.in $(REPLACE_VARS_SED)
1054         sed -f $(REPLACE_VARS_SED) < $< > $@
1055         chmod +x $@
1056
1057 devel/upload: devel/upload.in $(REPLACE_VARS_SED)
1058         sed -f $(REPLACE_VARS_SED) < $< > $@
1059         chmod u+x $@
1060
1061 tools/vcluster-setup: tools/vcluster-setup.in $(REPLACE_VARS_SED)
1062         sed -f $(REPLACE_VARS_SED) < $< > $@
1063         chmod +x $@
1064
1065 daemons/%:: daemons/%.in $(REPLACE_VARS_SED)
1066         sed -f $(REPLACE_VARS_SED) < $< > $@
1067         chmod +x $@
1068
1069 doc/examples/%:: doc/examples/%.in $(REPLACE_VARS_SED)
1070         sed -f $(REPLACE_VARS_SED) < $< > $@
1071
1072 doc/examples/bash_completion: BC_ARGS = --compact
1073 doc/examples/bash_completion-debug: BC_ARGS =
1074
1075 doc/examples/bash_completion doc/examples/bash_completion-debug: \
1076         $(BUILD_BASH_COMPLETION) $(RUN_IN_TEMPDIR) \
1077         lib/cli.py $(gnt_scripts) $(client_PYTHON) tools/burnin \
1078         $(GENERATED_FILES) $(HTOOLS_GENERATED_FILES)
1079         PYTHONPATH=. $(RUN_IN_TEMPDIR) \
1080           $(CURDIR)/$(BUILD_BASH_COMPLETION) $(BC_ARGS) > $@
1081
1082 doc/%.png: doc/%.dot
1083         @test -n "$(DOT)" || { echo 'dot' not found during configure; exit 1; }
1084         $(DOT) -Tpng -o $@ $<
1085
1086 man/footer.man: man/footer.rst
1087         @test -n "$(PANDOC)" || \
1088           { echo 'pandoc' not found during configure; exit 1; }
1089         $(PANDOC) -f rst -t man -o $@ $<
1090
1091 man/footer.html: man/footer.rst
1092         @test -n "$(PANDOC)" || \
1093           { echo 'pandoc' not found during configure; exit 1; }
1094         $(PANDOC) -f rst -t html -o $@ $<
1095
1096 man/%.gen: man/%.rst lib/query.py lib/build/sphinx_ext.py \
1097         lib/build/shell_example_lexer.py \
1098         | $(RUN_IN_TEMPDIR) $(BUILT_PYTHON_SOURCES)
1099         @echo "Checking $< for hardcoded paths..."
1100         @if grep -nEf autotools/wrong-hardcoded-paths $<; then \
1101           echo "Man page $< has harcoded paths (see above)!" 1>&2 ; \
1102           exit 1; \
1103         fi
1104         set -e ; \
1105         trap 'echo auto-removing $@; rm $@' EXIT; \
1106         PYTHONPATH=. $(RUN_IN_TEMPDIR) $(CURDIR)/$(DOCPP) < $< > $@ ;\
1107         trap - EXIT
1108
1109 man/%.7.in man/%.8.in man/%.1.in: man/%.gen man/footer.man
1110         @test -n "$(PANDOC)" || \
1111           { echo 'pandoc' not found during configure; exit 1; }
1112         set -o pipefail ; \
1113         trap 'echo auto-removing $@; rm $@' EXIT; \
1114         $(PANDOC) -s -f rst -t man -A man/footer.man $< | \
1115           sed -e 's/\\@/@/g' > $@; \
1116         if test -n "$(MAN_HAS_WARNINGS)"; then $(CHECK_MAN_WARNINGS) $@; fi; \
1117         $(CHECK_MAN_DASHES) $@; \
1118         trap - EXIT
1119
1120
1121 man/%.html.in: man/%.gen man/footer.html
1122         @test -n "$(PANDOC)" || \
1123           { echo 'pandoc' not found during configure; exit 1; }
1124         set -o pipefail ; \
1125         $(PANDOC) -s -f rst -t html -A man/footer.html $< | \
1126           sed -e 's/\\@/@/g' > $@
1127
1128 man/%: man/%.in  $(REPLACE_VARS_SED)
1129         sed -f $(REPLACE_VARS_SED) < $< > $@
1130
1131 epydoc.conf: epydoc.conf.in $(REPLACE_VARS_SED)
1132         sed -f $(REPLACE_VARS_SED) < $< > $@
1133
1134 vcs-version:
1135         if test -d .git; then \
1136           git describe > $@; \
1137         elif test ! -f $@ ; then \
1138           echo "Cannot auto-generate $@ file"; exit 1; \
1139         fi
1140
1141 .PHONY: clean-vcs-version
1142 clean-vcs-version:
1143         rm -f vcs-version
1144
1145 .PHONY: regen-vcs-version
1146 regen-vcs-version:
1147         set -e; \
1148         cd $(srcdir); \
1149         if test -d .git; then \
1150           $(MAKE) $(AM_MAKEFLAGS) clean-vcs-version; \
1151           $(MAKE) $(AM_MAKEFLAGS) vcs-version; \
1152         fi
1153
1154 htools/Ganeti/Version.hs: htools/Ganeti/Version.hs.in \
1155         vcs-version $(built_base_sources)
1156         set -e; \
1157         VCSVER=`cat $(abs_top_srcdir)/vcs-version`; \
1158         sed -e "s/%ver%/$$VCSVER/" < $< > $@
1159
1160 htools/Ganeti/Constants.hs: htools/Ganeti/Constants.hs.in \
1161         lib/constants.py lib/_autoconf.py lib/luxi.py \
1162         $(CONVERT_CONSTANTS) $(built_base_sources) \
1163         | lib/_vcsversion.py
1164         set -e; \
1165         { cat $< ; PYTHONPATH=. $(CONVERT_CONSTANTS); } > $@
1166
1167 htest/Test/Ganeti/TestImports.hs: htest/Test/Ganeti/TestImports.hs.in \
1168         $(built_base_sources)
1169         set -e; \
1170         { cat $< ; \
1171           echo ; \
1172           for name in $(filter-out Ganeti.THH,$(subst /,.,$(patsubst %.hs,%,$(patsubst htools/%,%,$(HS_LIB_SRCS))))) ; do \
1173             echo "import $$name ()" ; \
1174           done ; \
1175         } > $@
1176
1177 lib/_autoconf.py: Makefile | stamp-directories
1178         set -e; \
1179         { echo '# This file is automatically generated, do not edit!'; \
1180           echo '#'; \
1181           echo ''; \
1182           echo '"""Build-time configuration for Ganeti.'; \
1183           echo '';\
1184           echo 'This file is autogenerated by the build process.'; \
1185           echo 'For any changes you need to re-run ./configure (and'; \
1186           echo 'not edit by hand).'; \
1187           echo ''; \
1188           echo '"""'; \
1189           echo ''; \
1190           echo '# pylint: disable=C0301,C0324'; \
1191           echo '# because this is autogenerated, we do not want'; \
1192           echo '# style warnings' ; \
1193           echo ''; \
1194           echo "PACKAGE_VERSION = '$(PACKAGE_VERSION)'"; \
1195           echo "VERSION_MAJOR = '$(VERSION_MAJOR)'"; \
1196           echo "VERSION_MINOR = '$(VERSION_MINOR)'"; \
1197           echo "VERSION_REVISION = '$(VERSION_REVISION)'"; \
1198           echo "VERSION_SUFFIX = '$(VERSION_SUFFIX)'"; \
1199           echo "VERSION_FULL = '$(VERSION_FULL)'"; \
1200           echo "LOCALSTATEDIR = '$(localstatedir)'"; \
1201           echo "SYSCONFDIR = '$(sysconfdir)'"; \
1202           echo "SSH_CONFIG_DIR = '$(SSH_CONFIG_DIR)'"; \
1203           echo "SSH_LOGIN_USER = '$(SSH_LOGIN_USER)'"; \
1204           echo "SSH_CONSOLE_USER = '$(SSH_CONSOLE_USER)'"; \
1205           echo "EXPORT_DIR = '$(EXPORT_DIR)'"; \
1206           echo "OS_SEARCH_PATH = [$(OS_SEARCH_PATH)]"; \
1207           echo "XEN_BOOTLOADER = '$(XEN_BOOTLOADER)'"; \
1208           echo "XEN_KERNEL = '$(XEN_KERNEL)'"; \
1209           echo "XEN_INITRD = '$(XEN_INITRD)'"; \
1210           echo "KVM_KERNEL = '$(KVM_KERNEL)'"; \
1211           echo "FILE_STORAGE_DIR = '$(FILE_STORAGE_DIR)'"; \
1212           echo "ENABLE_FILE_STORAGE = $(ENABLE_FILE_STORAGE)"; \
1213           echo "SHARED_FILE_STORAGE_DIR = '$(SHARED_FILE_STORAGE_DIR)'"; \
1214           echo "ENABLE_SHARED_FILE_STORAGE = $(ENABLE_SHARED_FILE_STORAGE)"; \
1215           echo "IALLOCATOR_SEARCH_PATH = [$(IALLOCATOR_SEARCH_PATH)]"; \
1216           echo "KVM_PATH = '$(KVM_PATH)'"; \
1217           echo "IP_PATH = '$(IP_PATH)'"; \
1218           echo "SOCAT_PATH = '$(SOCAT)'"; \
1219           echo "SOCAT_USE_ESCAPE = $(SOCAT_USE_ESCAPE)"; \
1220           echo "SOCAT_USE_COMPRESS = $(SOCAT_USE_COMPRESS)"; \
1221           echo "LVM_STRIPECOUNT = $(LVM_STRIPECOUNT)"; \
1222           echo "TOOLSDIR = '$(toolsdir)'"; \
1223           echo "GNT_SCRIPTS = [$(foreach i,$(notdir $(gnt_scripts)),'$(i)',)]"; \
1224           echo "HTOOLS_PROGS = [$(foreach i,$(HS_HTOOLS_PROGS),'$(i)',)]"; \
1225           echo "PKGLIBDIR = '$(pkglibdir)'"; \
1226           echo "DRBD_BARRIERS = '$(DRBD_BARRIERS)'"; \
1227           echo "DRBD_NO_META_FLUSH = $(DRBD_NO_META_FLUSH)"; \
1228           echo "SYSLOG_USAGE = '$(SYSLOG_USAGE)'"; \
1229           echo "DAEMONS_GROUP = '$(DAEMONS_GROUP)'"; \
1230           echo "ADMIN_GROUP = '$(ADMIN_GROUP)'"; \
1231           echo "MASTERD_USER = '$(MASTERD_USER)'"; \
1232           echo "MASTERD_GROUP = '$(MASTERD_GROUP)'"; \
1233           echo "RAPI_USER = '$(RAPI_USER)'"; \
1234           echo "RAPI_GROUP = '$(RAPI_GROUP)'"; \
1235           echo "CONFD_USER = '$(CONFD_USER)'"; \
1236           echo "CONFD_GROUP = '$(CONFD_GROUP)'"; \
1237           echo "NODED_USER = '$(NODED_USER)'"; \
1238           echo "NODED_GROUP = '$(NODED_GROUP)'"; \
1239           echo "DISK_SEPARATOR = '$(DISK_SEPARATOR)'"; \
1240           echo "QEMUIMG_PATH = '$(QEMUIMG_PATH)'"; \
1241           if [ "$(HTOOLS)" ]; then \
1242             echo "HTOOLS = True"; \
1243           else \
1244             echo "HTOOLS = False"; \
1245           fi; \
1246           echo "ENABLE_CONFD = $(ENABLE_CONFD)"; \
1247           echo "XEN_CMD = '$(XEN_CMD)'"; \
1248           echo "ENABLE_SPLIT_QUERY = $(ENABLE_SPLIT_QUERY)"; \
1249         } > $@
1250
1251 lib/_vcsversion.py: Makefile vcs-version | stamp-directories
1252         set -e; \
1253         VCSVER=`cat $(abs_top_srcdir)/vcs-version`; \
1254         { echo '# This file is automatically generated, do not edit!'; \
1255           echo '#'; \
1256           echo ''; \
1257           echo '"""Build-time VCS version number for Ganeti.'; \
1258           echo '';\
1259           echo 'This file is autogenerated by the build process.'; \
1260           echo 'For any changes you need to re-run ./configure (and'; \
1261           echo 'not edit by hand).'; \
1262           echo ''; \
1263           echo '"""'; \
1264           echo ''; \
1265           echo '# pylint: disable=C0301,C0324'; \
1266           echo '# because this is autogenerated, we do not want'; \
1267           echo '# style warnings' ; \
1268           echo ''; \
1269           echo "VCS_VERSION = '$$VCSVER'"; \
1270         } > $@
1271
1272 lib/_generated_rpc.py: lib/rpc_defs.py $(BUILD_RPC)
1273         PYTHONPATH=. $(RUN_IN_TEMPDIR) $(CURDIR)/$(BUILD_RPC) lib/rpc_defs.py > $@
1274
1275 $(SHELL_ENV_INIT): Makefile stamp-directories
1276         set -e; \
1277         { echo '# Allow overriding for tests'; \
1278           echo 'readonly LOCALSTATEDIR=$${LOCALSTATEDIR:-$${GANETI_ROOTDIR:-}$(localstatedir)}'; \
1279           echo 'readonly SYSCONFDIR=$${SYSCONFDIR:-$${GANETI_ROOTDIR:-}$(sysconfdir)}'; \
1280           echo; \
1281           echo 'readonly PKGLIBDIR=$(pkglibdir)'; \
1282           echo 'readonly LOG_DIR="$$LOCALSTATEDIR/log/ganeti"'; \
1283           echo 'readonly RUN_DIR="$$LOCALSTATEDIR/run/ganeti"'; \
1284           echo 'readonly DATA_DIR="$$LOCALSTATEDIR/lib/ganeti"'; \
1285           echo 'readonly CONF_DIR="$$SYSCONFDIR/ganeti"'; \
1286         } > $@
1287
1288 $(REPLACE_VARS_SED): $(SHELL_ENV_INIT) Makefile stamp-directories
1289         set -e; \
1290         { echo 's#@PREFIX@#$(prefix)#g'; \
1291           echo 's#@SYSCONFDIR@#$(sysconfdir)#g'; \
1292           echo 's#@LOCALSTATEDIR@#$(localstatedir)#g'; \
1293           echo 's#@BINDIR@#$(bindir)#g'; \
1294           echo 's#@SBINDIR@#$(sbindir)#g'; \
1295           echo 's#@GANETI_VERSION@#$(PACKAGE_VERSION)#g'; \
1296           echo 's#@CUSTOM_XEN_BOOTLOADER@#$(XEN_BOOTLOADER)#g'; \
1297           echo 's#@CUSTOM_XEN_KERNEL@#$(XEN_KERNEL)#g'; \
1298           echo 's#@CUSTOM_XEN_INITRD@#$(XEN_INITRD)#g'; \
1299           echo 's#@CUSTOM_IALLOCATOR_SEARCH_PATH@#$(IALLOCATOR_SEARCH_PATH)#g'; \
1300           echo 's#@CUSTOM_EXPORT_DIR@#$(EXPORT_DIR)#g'; \
1301           echo 's#@RPL_FILE_STORAGE_DIR@#$(FILE_STORAGE_DIR)#g'; \
1302           echo 's#@RPL_SSH_INITD_SCRIPT@#$(SSH_INITD_SCRIPT)#g'; \
1303           echo 's#@PKGLIBDIR@#$(pkglibdir)#g'; \
1304           echo 's#@GNTMASTERUSER@#$(MASTERD_USER)#g'; \
1305           echo 's#@GNTRAPIUSER@#$(RAPI_USER)#g'; \
1306           echo 's#@GNTCONFDUSER@#$(CONFD_USER)#g'; \
1307           echo 's#@GNTNODEDUSER@#$(NODED_USER)#g'; \
1308           echo 's#@GNTRAPIGROUP@#$(RAPI_GROUP)#g'; \
1309           echo 's#@GNTADMINGROUP@#$(ADMIN_GROUP)#g'; \
1310           echo 's#@GNTCONFDGROUP@#$(CONFD_GROUP)#g'; \
1311           echo 's#@GNTMASTERDGROUP@#$(MASTERD_GROUP)#g'; \
1312           echo 's#@GNTDAEMONSGROUP@#$(DAEMONS_GROUP)#g'; \
1313           echo 's#@CUSTOM_ENABLE_CONFD@#$(ENABLE_CONFD)#g'; \
1314           echo 's#@MODULES@#$(strip $(lint_python_code))#g'; \
1315           echo 's#@ENABLE_SPLIT_QUERY@#$(ENABLE_SPLIT_QUERY)#g'; \
1316           echo; \
1317           echo '/^@SHELL_ENV_INIT@$$/ {'; \
1318           echo '  r $(SHELL_ENV_INIT)'; \
1319           echo '  d'; \
1320           echo '}'; \
1321         } > $@
1322
1323 # Using deferred evaluation
1324 daemons/ganeti-%: MODULE = ganeti.server.$(patsubst ganeti-%,%,$(notdir $@))
1325 daemons/ganeti-watcher: MODULE = ganeti.watcher
1326 scripts/%: MODULE = ganeti.client.$(subst -,_,$(notdir $@))
1327 tools/ensure-dirs: MODULE = ganeti.tools.ensure_dirs
1328 $(HS_BUILT_TEST_HELPERS): TESTROLE = $(patsubst htest/%,%,$@)
1329
1330 $(PYTHON_BOOTSTRAP): Makefile | stamp-directories
1331         test -n "$(MODULE)" || { echo Missing module; exit 1; }
1332         set -e; \
1333         { echo '#!/usr/bin/python'; \
1334           echo '# This file is automatically generated, do not edit!'; \
1335           echo "# Edit $(MODULE) instead."; \
1336           echo; \
1337           echo '"""Bootstrap script for L{$(MODULE)}"""'; \
1338           echo; \
1339           echo '# pylint: disable=C0103'; \
1340           echo '# C0103: Invalid name'; \
1341           echo; \
1342           echo 'import sys'; \
1343           echo 'import $(MODULE) as main'; \
1344           echo; \
1345           echo '# Temporarily alias commands until bash completion'; \
1346           echo '# generator is changed'; \
1347           echo 'if hasattr(main, "commands"):'; \
1348           echo '  commands = main.commands # pylint: disable=E1101'; \
1349           echo 'if hasattr(main, "aliases"):'; \
1350           echo '  aliases = main.aliases # pylint: disable=E1101'; \
1351           echo; \
1352           echo 'if __name__ == "__main__":'; \
1353           echo '  sys.exit(main.Main())'; \
1354         } > $@
1355         chmod u+x $@
1356
1357 $(HS_BUILT_TEST_HELPERS): Makefile
1358         @test -n "$(TESTROLE)" || { echo Missing TESTROLE; exit 1; }
1359         set -e; \
1360         { echo '#!/bin/sh'; \
1361           echo '# This file is automatically generated, do not edit!'; \
1362           echo "# Edit Makefile.am instead."; \
1363           echo; \
1364           echo "HTOOLS=$(TESTROLE) exec ./htest/hpc-htools \"\$$@\""; \
1365         } > $@
1366         chmod u+x $@
1367
1368 stamp-directories: Makefile
1369         $(MAKE) $(AM_MAKEFLAGS) ganeti
1370         @mkdir_p@ $(DIRS) $(BUILDTIME_DIR_AUTOCREATE)
1371         touch $@
1372
1373 # We need to create symlinks because "make distcheck" will not install Python
1374 # files when building.
1375 stamp-srclinks: Makefile | stamp-directories
1376         set -e; \
1377         for i in $(srclink_files); do \
1378                 if test ! -f $$i -a -f $(abs_top_srcdir)/$$i; then \
1379                         $(LN_S) $(abs_top_srcdir)/$$i $$i; \
1380                 fi; \
1381         done
1382         touch $@
1383
1384 .PHONY: ganeti
1385 ganeti:
1386         cd $(top_builddir) && test -h "$@" || { rm -f $@ && $(LN_S) lib $@; }
1387
1388 .PHONY: check-dirs
1389 check-dirs: $(GENERATED_FILES)
1390         @set -e; \
1391         find . -type d \( \( -name . \) -o \( \
1392                 -name .git -o \
1393                 -name autom4te.cache \
1394                 \) -prune -o -print \) | { \
1395                 error=; \
1396                 while read dir; do \
1397                         case "$$dir" in \
1398                                 $(strip $(patsubst %,(./%) ;;,$(DIRCHECK_EXCLUDE) $(DIRS))) \
1399                                 *) error=1; echo "Directory $$dir not listed in Makefile" >&2 ;; \
1400                         esac; \
1401                 done; \
1402                 for dir in $(DIRS); do \
1403                         if ! test -d "$$dir"; then \
1404                                 echo "Directory $$dir listed in DIRS does not exist" >&2; \
1405                                 error=1; \
1406                         fi \
1407                 done; \
1408                 if test -n "$$error"; then exit 1; else exit 0; fi; \
1409         }
1410
1411 .PHONY: check-local
1412 check-local: check-dirs $(GENERATED_FILES)
1413         $(CHECK_PYTHON_CODE) $(check_python_code)
1414         PYTHONPATH=. $(CHECK_HEADER) $(check_python_code)
1415         $(CHECK_VERSION) $(VERSION) $(top_srcdir)/NEWS
1416         $(CHECK_NEWS) < $(top_srcdir)/NEWS
1417         PYTHONPATH=. $(RUN_IN_TEMPDIR) $(CURDIR)/$(CHECK_IMPORTS) . $(standalone_python_modules)
1418         expver=$(VERSION_MAJOR).$(VERSION_MINOR); \
1419         if test "`head -n 1 $(top_srcdir)/README`" != "Ganeti $$expver"; then \
1420                 echo "Incorrect version in README, expected $$expver"; \
1421                 exit 1; \
1422         fi; \
1423         for file in doc/iallocator.rst doc/hooks.rst doc/virtual-cluster.rst; do \
1424                 if test "`sed -ne '4 p' $(top_srcdir)/$$file`" != \
1425                         "Documents Ganeti version $$expver"; then \
1426                         echo "Incorrect version in $$file, expected $$expver"; \
1427                         exit 1; \
1428                 fi; \
1429         done
1430
1431 .PHONY: hs-check
1432 hs-check: htest/test htest/hpc-htools $(HS_BUILT_TEST_HELPERS)
1433         @rm -f test.tix
1434         ./htest/test
1435         HBINARY="./htest/hpc-htools" ./htest/offline-test.sh
1436
1437 # E111: indentation is not a multiple of four
1438 # E121: continuation line indentation is not a multiple of four
1439 #       (since our indent level is not 4)
1440 # E125: continuation line does not distinguish itself from next logical line
1441 #       (since our indent level is not 4)
1442 # E127: continuation line over-indented for visual indent
1443 #       (since our indent level is not 4)
1444 # note: do NOT add E128 here; it's a valid style error in most cases!
1445 # I've seen real errors, but also some cases were we indent wrongly
1446 # due to line length; try to rework the cases where it is triggered,
1447 # instead of silencing it
1448 # E261: at least two spaces before inline comment
1449 # E501: line too long (80 characters)
1450 PEP8_IGNORE = E111,E121,E125,E127,E261,E501
1451
1452 # For excluding pep8 expects filenames only, not whole paths
1453 PEP8_EXCLUDE = $(subst $(space),$(comma),$(strip $(notdir $(BUILT_PYTHON_SOURCES))))
1454
1455 LINT_TARGETS = pylint pylint-qa
1456 if HAS_PEP8
1457 LINT_TARGETS += pep8
1458 endif
1459 if HAS_HLINT
1460 LINT_TARGETS += hlint
1461 endif
1462
1463 .PHONY: lint
1464 lint: $(LINT_TARGETS)
1465
1466 .PHONY: pylint
1467 pylint: $(GENERATED_FILES)
1468         @test -n "$(PYLINT)" || { echo 'pylint' not found during configure; exit 1; }
1469         $(PYLINT) $(LINT_OPTS) $(lint_python_code)
1470
1471 .PHONY: pylint-qa
1472 pylint-qa: $(GENERATED_FILES)
1473         @test -n "$(PYLINT)" || { echo 'pylint' not found during configure; exit 1; }
1474         cd $(top_srcdir)/qa && \
1475           PYTHONPATH=$(abs_top_srcdir) $(PYLINT) $(LINT_OPTS) \
1476           --rcfile  ../pylintrc $(patsubst qa/%.py,%,$(qa_scripts))
1477
1478 .PHONY: pep8
1479 pep8: $(GENERATED_FILES)
1480         @test -n "$(PEP8)" || { echo 'pep8' not found during configure; exit 1; }
1481         $(PEP8) --ignore='$(PEP8_IGNORE)' --exclude='$(PEP8_EXCLUDE)' \
1482                 --repeat $(pep8_python_code)
1483
1484 # FIXME: remove ignore "Use void" when GHC 6.x is deprecated
1485 .PHONY: hlint
1486 hlint: $(HS_BUILT_SRCS) htools/lint-hints.hs
1487         @test -n "$(HLINT)" || { echo 'hlint' not found during configure; exit 1; }
1488         if tty -s; then C="-c"; else C=""; fi; \
1489         $(HLINT) --report=doc/hs-lint.html --cross $$C \
1490           --ignore "Use first" \
1491           --ignore "Use comparing" \
1492           --ignore "Use on" \
1493           --ignore "Reduce duplication" \
1494           --ignore "Use &&&" \
1495           --ignore "Use void" \
1496           --hint htools/lint-hints \
1497           $(filter-out htools/Ganeti/THH.hs,$(HS_LIBTEST_SRCS))
1498
1499 # a dist hook rule for updating the vcs-version file; this is
1500 # hardcoded due to where it needs to build the file...
1501 dist-hook:
1502         $(MAKE) $(AM_MAKEFLAGS) regen-vcs-version
1503         rm -f $(top_distdir)/vcs-version
1504         cp -p $(srcdir)/vcs-version $(top_distdir)
1505
1506 # a distcheck hook rule for catching revision control directories
1507 distcheck-hook:
1508         if find $(top_distdir) -name .svn -or -name .git | grep .; then \
1509                 echo "Found revision control files in final archive." 1>&2; \
1510                 exit 1; \
1511         fi
1512         if find $(top_distdir) -name '*.py[co]' | grep .; then \
1513                 echo "Found Python byte code in final archive." 1>&2; \
1514                 exit 1; \
1515         fi
1516         if find $(top_distdir) -name '*~' | grep .; then \
1517                 echo "Found backup files in final archive." 1>&2; \
1518                 exit 1; \
1519         fi
1520 # Empty files or directories should not be distributed. They can cause
1521 # unnecessary warnings for packagers. Directories used by automake during
1522 # distcheck must be excluded.
1523         if find $(top_distdir) -empty -and -not \( \
1524                         -path $(top_distdir)/_build -or \
1525                         -path $(top_distdir)/_inst \) | grep .; then \
1526                 echo "Found empty files or directories in final archive." 1>&2; \
1527                 exit 1; \
1528         fi
1529         if test -n "$(BUILD_RELEASE)" && \
1530            grep -n -H -E '^\*.*unreleased' $(top_distdir)/NEWS; then \
1531                 echo "Found unreleased version in NEWS." >&2; \
1532                 exit 1; \
1533         fi
1534
1535 # When building a release, stricter checks should be used
1536 distcheck-release dist-release: export BUILD_RELEASE = 1
1537 distcheck-release: distcheck
1538
1539 distrebuildcheck: dist
1540         set -e; \
1541         builddir=$$(mktemp -d $(abs_srcdir)/distrebuildcheck.XXXXXXX); \
1542         trap "echo Removing $$builddir; cd $(abs_srcdir); rm -rf $$builddir" EXIT; \
1543         cd $$builddir; \
1544         tar xzf $(abs_srcdir)/$(distdir).tar.gz; \
1545         cd $(distdir); \
1546         ./configure; \
1547         $(MAKE) maintainer-clean; \
1548         cp $(abs_srcdir)/vcs-version .; \
1549         ./configure; \
1550         $(MAKE) $(AM_MAKEFLAGS)
1551
1552 dist-release: dist
1553         set -e; \
1554         for i in $(DIST_ARCHIVES); do \
1555                 echo -n "Checking $$i ... "; \
1556                 autotools/check-tar < $$i; \
1557                 echo OK; \
1558         done
1559
1560 install-exec-local:
1561         @mkdir_p@ "$(DESTDIR)${localstatedir}/lib/ganeti" \
1562           "$(DESTDIR)${localstatedir}/log/ganeti" \
1563           "$(DESTDIR)${localstatedir}/run/ganeti"
1564
1565 .PHONY: apidoc
1566 if WANT_HTOOLSAPIDOC
1567 apidoc: py-apidoc hs-apidoc
1568 else
1569 apidoc: py-apidoc
1570 endif
1571
1572 .PHONY: py-apidoc
1573 py-apidoc: epydoc.conf $(RUN_IN_TEMPDIR) $(GENERATED_FILES)
1574         $(RUN_IN_TEMPDIR) epydoc -v \
1575                 --conf $(CURDIR)/epydoc.conf \
1576                 --output $(CURDIR)/$(APIDOC_PY_DIR)
1577
1578 .PHONY: hs-apidoc
1579 hs-apidoc: $(HS_BUILT_SRCS)
1580         @test -n "$(HSCOLOUR)" || \
1581             { echo 'HsColour' not found during configure; exit 1; }
1582         @test -n "$(HADDOCK)" || \
1583             { echo 'haddock' not found during configure; exit 1; }
1584         rm -rf $(APIDOC_HS_DIR)/*
1585         @mkdir_p@ $(APIDOC_HS_DIR)/Ganeti/HTools/Program
1586         @mkdir_p@ $(APIDOC_HS_DIR)/Ganeti/Confd
1587         @mkdir_p@ $(APIDOC_HS_DIR)/Ganeti/Query
1588         $(HSCOLOUR) -print-css > $(APIDOC_HS_DIR)/Ganeti/hscolour.css
1589         $(LN_S) ../hscolour.css $(APIDOC_HS_DIR)/Ganeti/HTools/hscolour.css
1590         $(LN_S) ../hscolour.css $(APIDOC_HS_DIR)/Ganeti/Confd/hscolour.css
1591         set -e ; \
1592         cd htools; \
1593         if [ "$(HTOOLS_NOCURL)" ]; \
1594         then OPTGHC="--optghc=$(HTOOLS_NOCURL)"; \
1595         else OPTGHC=""; \
1596         fi; \
1597         if [ "$(HTOOLS_PARALLEL3)" ]; \
1598         then OPTGHC="$$OPTGHC --optghc=$(HTOOLS_PARALLEL3)"; \
1599         fi; \
1600         RELSRCS="$(HS_LIB_SRCS:htools/%=%) $(patsubst htools/%,%,$(filter htools/%,$(HS_BUILT_SRCS)))"; \
1601         for file in $$RELSRCS; do \
1602                 hfile=`echo $$file|sed 's/\\.hs$$//'`.html; \
1603                 $(HSCOLOUR) -css -anchor $$file > ../$(APIDOC_HS_DIR)/$$hfile ; \
1604         done ; \
1605         $(HADDOCK) --odir ../$(APIDOC_HS_DIR) --html --ignore-all-exports -w \
1606                 -t ganeti-htools -p haddock-prologue \
1607                 --source-module="%{MODULE/.//}.html" \
1608                 --source-entity="%{MODULE/.//}.html#%{NAME}" \
1609                 $$OPTGHC \
1610                 $(filter-out Ganeti/HTools/ExtLoader.hs,$(HS_LIB_SRCS:htools/%=%))
1611
1612 .PHONY: TAGS
1613 TAGS: $(GENERATED_FILES)
1614         rm -f TAGS
1615         $(GHC) -e ":etags" -v0 $(HFLAGS) $(HS_LIBTEST_SRCS)
1616         find . -path './lib/*.py' -o -path './scripts/gnt-*' -o \
1617           -path './daemons/ganeti-*' -o -path './tools/*' -o \
1618           -path './qa/*.py' | \
1619           etags -l python -a -
1620
1621 .PHONY: coverage
1622 if WANT_HTOOLS
1623 coverage: py-coverage hs-coverage
1624 else
1625 coverage: py-coverage
1626 endif
1627
1628 .PHONY: py-coverage
1629 py-coverage: $(GENERATED_FILES) $(python_tests)
1630         set -e; \
1631         COVERAGE_FILE=$(CURDIR)/$(COVERAGE_PY_DIR)/data \
1632         TEXT_COVERAGE=$(CURDIR)/$(COVERAGE_PY_DIR)/report.txt \
1633         HTML_COVERAGE=$(CURDIR)/$(COVERAGE_PY_DIR) \
1634         $(PLAIN_TESTS_ENVIRONMENT) $(abs_top_srcdir)/autotools/gen-coverage \
1635         $(python_tests)
1636
1637 .PHONY: hs-coverage
1638 hs-coverage: $(haskell_tests) htest/hpc-htools
1639         rm -f *.tix
1640         $(MAKE) $(AM_MAKEFLAGS) hs-check
1641         @mkdir_p@ $(COVERAGE_HS_DIR)
1642         hpc combine --union $(HPCEXCL) \
1643           test.tix hpc-htools.tix > coverage-htools.tix
1644         hpc markup --destdir=$(COVERAGE_HS_DIR) coverage-htools.tix
1645         hpc report coverage-htools.tix
1646         $(LN_S) -f hpc_index.html $(COVERAGE_HS_DIR)/index.html
1647
1648 # Special "kind-of-QA" target for htools, needs special setup (all
1649 # tools compiled with -fhpc)
1650 .PHONY: live-test
1651 live-test: all
1652         set -e ; \
1653         cd htools; \
1654         rm -f .hpc; $(LN_S) ../.hpc .hpc; \
1655         rm -f *.tix *.mix; \
1656         ./live-test.sh; \
1657         hpc sum --union $(HPCEXCL) $(addsuffix .tix,$(HS_PROGS:htools/%=%)) \
1658           --output=live-test.tix ; \
1659         @mkdir_p@ ../$(COVERAGE_HS_DIR) ; \
1660         hpc markup --destdir=../$(COVERAGE_HS_DIR) live-test \
1661                 --srcdir=.. $(HPCEXCL) ; \
1662         hpc report --srcdir=.. live-test $(HPCEXCL)
1663
1664 commit-check: distcheck lint apidoc
1665
1666 .PHONY: gitignore-check
1667 gitignore-check:
1668         @if [ -n "`git status --short`" ]; then \
1669           echo "Git status is not clean!" 1>&2 ; \
1670           git status --short; \
1671           exit 1; \
1672         fi
1673
1674 # we don't need the ancient implicit rules:
1675 %: %,v
1676 %: RCS/%,v
1677 %: RCS/%
1678 %: s.%
1679 %: SCCS/s.%
1680
1681 -include ./Makefile.local
1682
1683 # vim: set noet :