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