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