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