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