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