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