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