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