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