Add RAPI shell-level unittest
[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 # Use bash in order to be able to use pipefail
18 SHELL=/bin/bash
19
20 ACLOCAL_AMFLAGS = -I autotools
21 BUILD_BASH_COMPLETION = $(top_srcdir)/autotools/build-bash-completion
22 RUN_IN_TEMPDIR = $(top_srcdir)/autotools/run-in-tempdir
23 CHECK_PYTHON_CODE = $(top_srcdir)/autotools/check-python-code
24 CHECK_HEADER = $(top_srcdir)/autotools/check-header
25 CHECK_MAN_DASHES = $(top_srcdir)/autotools/check-man-dashes
26 CHECK_MAN_WARNINGS = $(top_srcdir)/autotools/check-man-warnings
27 CHECK_VERSION = $(top_srcdir)/autotools/check-version
28 CHECK_NEWS = $(top_srcdir)/autotools/check-news
29 CHECK_IMPORTS = $(top_srcdir)/autotools/check-imports
30 DOCPP = $(top_srcdir)/autotools/docpp
31 REPLACE_VARS_SED = autotools/replace_vars.sed
32 CONVERT_CONSTANTS = $(top_srcdir)/autotools/convert-constants
33 BUILD_RPC = $(top_srcdir)/autotools/build-rpc
34
35 # Note: these are automake-specific variables, and must be named after
36 # the directory + 'dir' suffix
37 clientdir = $(pkgpythondir)/client
38 hypervisordir = $(pkgpythondir)/hypervisor
39 httpdir = $(pkgpythondir)/http
40 masterddir = $(pkgpythondir)/masterd
41 confddir = $(pkgpythondir)/confd
42 rapidir = $(pkgpythondir)/rapi
43 serverdir = $(pkgpythondir)/server
44 watcherdir = $(pkgpythondir)/watcher
45 impexpddir = $(pkgpythondir)/impexpd
46 utilsdir = $(pkgpythondir)/utils
47 toolsdir = $(pkglibdir)/tools
48 iallocatorsdir = $(pkglibdir)/iallocators
49 pytoolsdir = $(pkgpythondir)/tools
50 docdir = $(datadir)/doc/$(PACKAGE)
51 myexeclibdir = $(pkglibdir)
52
53 # Delete output file if an error occurred while building it
54 .DELETE_ON_ERROR:
55
56 HTOOLS_DIRS = \
57         htools \
58         htools/Ganeti \
59         htools/Ganeti/Confd \
60         htools/Ganeti/HTools \
61         htools/Ganeti/HTools/Program
62
63 DIRS = \
64         autotools \
65         daemons \
66         devel \
67         doc \
68         doc/examples \
69         doc/examples/hooks \
70         doc/examples/gnt-debug \
71         $(HTOOLS_DIRS) \
72         lib \
73         lib/client \
74         lib/build \
75         lib/confd \
76         lib/http \
77         lib/hypervisor \
78         lib/impexpd \
79         lib/masterd \
80         lib/rapi \
81         lib/server \
82         lib/tools \
83         lib/utils \
84         lib/watcher \
85         man \
86         qa \
87         test \
88         test/data \
89         test/data/htools \
90         test/data/ovfdata \
91         test/data/ovfdata/other \
92         tools
93
94 BUILDTIME_DIR_AUTOCREATE = \
95         scripts \
96         $(APIDOC_DIR) \
97         $(APIDOC_PY_DIR) \
98         $(APIDOC_HS_DIR) \
99         $(APIDOC_HS_DIR)/Ganeti \
100         $(APIDOC_HS_DIR)/Ganeti/Confd \
101         $(APIDOC_HS_DIR)/Ganeti/HTools \
102         $(APIDOC_HS_DIR)/Ganeti/HTools/Program \
103         $(COVERAGE_DIR) \
104         $(COVERAGE_PY_DIR) \
105         $(COVERAGE_HS_DIR) \
106         .hpc
107
108 BUILDTIME_DIRS = \
109         $(BUILDTIME_DIR_AUTOCREATE) \
110         doc/html
111
112 DIRCHECK_EXCLUDE = \
113         $(BUILDTIME_DIRS) \
114         ganeti-[0-9]*.[0-9]*.[0-9]* \
115         doc/html/_*
116
117 all_dirfiles = $(addsuffix /.dir,$(DIRS) $(BUILDTIME_DIR_AUTOCREATE))
118
119 # some helper vars
120 COVERAGE_DIR = doc/coverage
121 COVERAGE_PY_DIR = $(COVERAGE_DIR)/py
122 COVERAGE_HS_DIR = $(COVERAGE_DIR)/hs
123 APIDOC_DIR = doc/api
124 APIDOC_PY_DIR = $(APIDOC_DIR)/py
125 APIDOC_HS_DIR = $(APIDOC_DIR)/hs
126
127 MAINTAINERCLEANFILES = \
128         $(docpng) \
129         $(maninput) \
130         doc/install-quick.rst \
131         doc/news.rst \
132         doc/upgrade.rst \
133         vcs-version
134
135 maintainer-clean-local:
136         rm -rf $(BUILDTIME_DIRS)
137
138 CLEANFILES = \
139         $(addsuffix /*.py[co],$(DIRS)) \
140         $(addsuffix /*.hi,$(HTOOLS_DIRS)) \
141         $(addsuffix /*.o,$(HTOOLS_DIRS)) \
142         $(all_dirfiles) \
143         $(PYTHON_BOOTSTRAP) \
144         epydoc.conf \
145         autotools/replace_vars.sed \
146         daemons/daemon-util \
147         daemons/ganeti-cleaner \
148         devel/upload \
149         $(BUILT_EXAMPLES) \
150         doc/examples/bash_completion \
151         lib/_generated_rpc.py \
152         $(man_MANS) \
153         $(manhtml) \
154         tools/kvm-ifup \
155         stamp-srclinks \
156         $(nodist_pkgpython_PYTHON) \
157         $(HS_ALL_PROGS) $(HS_BUILT_SRCS) \
158         .hpc/*.mix htools/*.tix \
159         doc/hs-lint.html
160
161 # BUILT_SOURCES should only be used as a dependency on phony targets. Otherwise
162 # it'll cause the target to rebuild every time.
163 BUILT_SOURCES = \
164   $(built_base_sources) \
165         $(BUILT_PYTHON_SOURCES) \
166         $(PYTHON_BOOTSTRAP)
167
168 built_base_sources = \
169         ganeti \
170         stamp-srclinks \
171         $(all_dirfiles)
172
173 built_python_base_sources = \
174         lib/_autoconf.py \
175         lib/_vcsversion.py
176
177 BUILT_PYTHON_SOURCES = \
178         $(built_python_base_sources) \
179         lib/_generated_rpc.py
180
181 # Generating the RPC wrappers depends on many things, so make sure it's built at
182 # the end of the built sources
183 lib/_generated_rpc.py: | $(built_base_sources) $(built_python_base_sources)
184
185 # these are all built from the underlying %.in sources
186 BUILT_EXAMPLES = \
187         doc/examples/ganeti-kvm-poweroff.initd \
188         doc/examples/ganeti.cron \
189         doc/examples/ganeti.initd \
190         doc/examples/gnt-config-backup \
191         doc/examples/hooks/ipsec
192
193 nodist_pkgpython_PYTHON = \
194         $(BUILT_PYTHON_SOURCES)
195
196 noinst_PYTHON = \
197         lib/build/__init__.py \
198         lib/build/sphinx_ext.py
199
200 pkgpython_PYTHON = \
201         lib/__init__.py \
202         lib/asyncnotifier.py \
203         lib/backend.py \
204         lib/bdev.py \
205         lib/bootstrap.py \
206         lib/cli.py \
207         lib/cmdlib.py \
208         lib/compat.py \
209         lib/config.py \
210         lib/constants.py \
211         lib/daemon.py \
212         lib/errors.py \
213         lib/ht.py \
214         lib/jqueue.py \
215         lib/jstore.py \
216         lib/locking.py \
217         lib/luxi.py \
218         lib/mcpu.py \
219         lib/netutils.py \
220         lib/objects.py \
221         lib/opcodes.py \
222         lib/ovf.py \
223         lib/qlang.py \
224         lib/query.py \
225         lib/rpc.py \
226         lib/rpc_defs.py \
227         lib/runtime.py \
228         lib/serializer.py \
229         lib/ssconf.py \
230         lib/ssh.py \
231         lib/storage.py \
232         lib/uidpool.py \
233         lib/workerpool.py
234
235 client_PYTHON = \
236         lib/client/__init__.py \
237         lib/client/gnt_backup.py \
238         lib/client/gnt_cluster.py \
239         lib/client/gnt_debug.py \
240         lib/client/gnt_group.py \
241         lib/client/gnt_instance.py \
242         lib/client/gnt_job.py \
243         lib/client/gnt_node.py \
244         lib/client/gnt_os.py
245
246 hypervisor_PYTHON = \
247         lib/hypervisor/__init__.py \
248         lib/hypervisor/hv_base.py \
249         lib/hypervisor/hv_chroot.py \
250         lib/hypervisor/hv_fake.py \
251         lib/hypervisor/hv_kvm.py \
252         lib/hypervisor/hv_lxc.py \
253         lib/hypervisor/hv_xen.py
254
255 rapi_PYTHON = \
256         lib/rapi/__init__.py \
257         lib/rapi/baserlib.py \
258         lib/rapi/client.py \
259         lib/rapi/client_utils.py \
260         lib/rapi/connector.py \
261         lib/rapi/rlib2.py \
262         lib/rapi/testutils.py
263
264 http_PYTHON = \
265         lib/http/__init__.py \
266         lib/http/auth.py \
267         lib/http/client.py \
268         lib/http/server.py
269
270 confd_PYTHON = \
271         lib/confd/__init__.py \
272         lib/confd/client.py \
273         lib/confd/querylib.py \
274         lib/confd/server.py
275
276 masterd_PYTHON = \
277         lib/masterd/__init__.py \
278         lib/masterd/instance.py
279
280 impexpd_PYTHON = \
281         lib/impexpd/__init__.py
282
283 watcher_PYTHON = \
284         lib/watcher/__init__.py \
285         lib/watcher/nodemaint.py \
286         lib/watcher/state.py
287
288 server_PYTHON = \
289         lib/server/__init__.py \
290         lib/server/confd.py \
291         lib/server/masterd.py \
292         lib/server/noded.py \
293         lib/server/rapi.py
294
295 pytools_PYTHON = \
296         lib/tools/__init__.py \
297         lib/tools/ensure_dirs.py
298
299 utils_PYTHON = \
300         lib/utils/__init__.py \
301         lib/utils/algo.py \
302         lib/utils/filelock.py \
303         lib/utils/hash.py \
304         lib/utils/io.py \
305         lib/utils/log.py \
306         lib/utils/mlock.py \
307         lib/utils/nodesetup.py \
308         lib/utils/process.py \
309         lib/utils/retry.py \
310         lib/utils/text.py \
311         lib/utils/wrapper.py \
312         lib/utils/x509.py
313
314 docrst = \
315         doc/admin.rst \
316         doc/design-2.0.rst \
317         doc/design-2.1.rst \
318         doc/design-2.2.rst \
319         doc/design-2.3.rst \
320         doc/design-htools-2.3.rst \
321         doc/design-2.4.rst \
322         doc/design-2.5.rst \
323         doc/design-draft.rst \
324         doc/design-oob.rst \
325         doc/design-cpu-pinning.rst \
326         doc/design-query2.rst \
327         doc/design-x509-ca.rst \
328         doc/design-http-server.rst \
329         doc/design-impexp2.rst \
330         doc/design-lu-generated-jobs.rst \
331         doc/design-multi-reloc.rst \
332         doc/design-network.rst \
333         doc/design-chained-jobs.rst \
334         doc/design-ovf-support.rst \
335         doc/design-resource-model.rst \
336         doc/cluster-merge.rst \
337         doc/design-shared-storage.rst \
338         doc/design-node-state-cache.rst \
339         doc/design-virtual-clusters.rst \
340         doc/devnotes.rst \
341         doc/glossary.rst \
342         doc/hooks.rst \
343         doc/iallocator.rst \
344         doc/index.rst \
345         doc/install-quick.rst \
346         doc/install.rst \
347         doc/locking.rst \
348         doc/move-instance.rst \
349         doc/news.rst \
350         doc/rapi.rst \
351         doc/security.rst \
352         doc/upgrade.rst \
353         doc/walkthrough.rst
354
355 HS_PROGS = htools/htools htools/hconfd
356 HS_BIN_ROLES = hbal hscan hspace hinfo
357
358 HS_ALL_PROGS = $(HS_PROGS) htools/test htools/htools-hpc
359 HS_PROG_SRCS = $(patsubst %,%.hs,$(HS_ALL_PROGS))
360 # we don't add -Werror by default
361 HFLAGS = -O -Wall -fwarn-monomorphism-restriction -fwarn-tabs -ihtools
362 # extra flags that can be overriden on the command line
363 HEXTRA =
364 # internal extra flags (used for htools/test mainly)
365 HEXTRA_INT =
366 # exclude options for coverage reports
367 HPCEXCL = --exclude Main \
368         --exclude Ganeti.Constants \
369         --exclude Ganeti.THH \
370         --exclude Ganeti.HTools.QC \
371         --exclude Ganeti.HTools.QCHelper \
372         --exclude Ganeti.HTools.Version
373
374 HS_LIB_SRCS = \
375         htools/Ganeti/HTools/CLI.hs \
376         htools/Ganeti/HTools/Cluster.hs \
377         htools/Ganeti/HTools/Compat.hs \
378         htools/Ganeti/HTools/Container.hs \
379         htools/Ganeti/HTools/ExtLoader.hs \
380         htools/Ganeti/HTools/Group.hs \
381         htools/Ganeti/HTools/IAlloc.hs \
382         htools/Ganeti/HTools/Instance.hs \
383         htools/Ganeti/HTools/JSON.hs \
384         htools/Ganeti/HTools/Loader.hs \
385         htools/Ganeti/HTools/Luxi.hs \
386         htools/Ganeti/HTools/Node.hs \
387         htools/Ganeti/HTools/PeerMap.hs \
388         htools/Ganeti/HTools/QC.hs \
389         htools/Ganeti/HTools/QCHelper.hs \
390         htools/Ganeti/HTools/Rapi.hs \
391         htools/Ganeti/HTools/Simu.hs \
392         htools/Ganeti/HTools/Text.hs \
393         htools/Ganeti/HTools/Types.hs \
394         htools/Ganeti/HTools/Utils.hs \
395         htools/Ganeti/HTools/Program.hs \
396         htools/Ganeti/HTools/Program/Hail.hs \
397         htools/Ganeti/HTools/Program/Hbal.hs \
398         htools/Ganeti/HTools/Program/Hinfo.hs \
399         htools/Ganeti/HTools/Program/Hscan.hs \
400         htools/Ganeti/HTools/Program/Hspace.hs \
401         htools/Ganeti/BasicTypes.hs \
402         htools/Ganeti/Confd.hs \
403         htools/Ganeti/Confd/Server.hs \
404         htools/Ganeti/Config.hs \
405         htools/Ganeti/Daemon.hs \
406         htools/Ganeti/Hash.hs \
407         htools/Ganeti/Jobs.hs \
408         htools/Ganeti/Logging.hs \
409         htools/Ganeti/Luxi.hs \
410         htools/Ganeti/Objects.hs \
411         htools/Ganeti/OpCodes.hs \
412         htools/Ganeti/Runtime.hs \
413         htools/Ganeti/THH.hs
414
415 HS_BUILT_SRCS = htools/Ganeti/HTools/Version.hs htools/Ganeti/Constants.hs
416 HS_BUILT_SRCS_IN = $(patsubst %,%.in,$(HS_BUILT_SRCS))
417
418 $(RUN_IN_TEMPDIR): | $(all_dirfiles)
419
420 # Note: we use here an order-only prerequisite, as the contents of
421 # _autoconf.py are not actually influencing the html build output: it
422 # has to exist in order for the sphinx module to be loaded
423 # successfully, but we certainly don't want the docs to be rebuilt if
424 # it changes
425 doc/html/index.html: $(docrst) $(docpng) doc/conf.py configure.ac \
426         $(RUN_IN_TEMPDIR) lib/build/sphinx_ext.py lib/opcodes.py lib/ht.py \
427         | $(BUILT_PYTHON_SOURCES)
428         @test -n "$(SPHINX)" || \
429             { echo 'sphinx-build' not found during configure; exit 1; }
430         @mkdir_p@ $(dir $@)
431         PYTHONPATH=. $(RUN_IN_TEMPDIR) $(SPHINX) -q -W -b html \
432             -d . \
433             -D version="$(VERSION_MAJOR).$(VERSION_MINOR)" \
434             -D release="$(PACKAGE_VERSION)" \
435             $(abs_top_srcdir)/doc $(CURDIR)/doc/html
436         rm -f doc/html/.buildinfo doc/html/objects.inv
437         touch $@
438
439 doc/html: doc/html/index.html
440
441 doc/install-quick.rst: INSTALL
442 doc/news.rst: NEWS
443 doc/upgrade.rst: UPGRADE
444
445 doc/install-quick.rst doc/news.rst doc/upgrade.rst:
446         set -e; \
447         { echo '.. This file is automatically updated at build time from $<.'; \
448           echo '.. Do not edit.'; \
449           echo; \
450           cat $<; \
451         } > $@
452
453 docdot = \
454         doc/arch-2.0.dot \
455         doc/design-2.1-lock-acquire.dot \
456         doc/design-2.1-lock-release.dot
457
458 docpng = $(patsubst %.dot,%.png,$(docdot))
459
460 # Things to build but not to install (add it to EXTRA_DIST if it should be
461 # distributed)
462 noinst_DATA = \
463         devel/upload \
464         doc/html \
465         $(BUILT_EXAMPLES) \
466         doc/examples/bash_completion \
467         $(manhtml)
468
469 gnt_scripts = \
470         scripts/gnt-backup \
471         scripts/gnt-cluster \
472         scripts/gnt-debug \
473         scripts/gnt-group \
474         scripts/gnt-instance \
475         scripts/gnt-job \
476         scripts/gnt-node \
477         scripts/gnt-os
478
479 PYTHON_BOOTSTRAP_SBIN = \
480         daemons/ganeti-confd \
481         daemons/ganeti-masterd \
482         daemons/ganeti-noded \
483         daemons/ganeti-watcher \
484         daemons/ganeti-rapi \
485         $(gnt_scripts)
486
487 PYTHON_BOOTSTRAP = \
488         $(PYTHON_BOOTSTRAP_SBIN) \
489         tools/ensure-dirs
490
491 qa_scripts = \
492         qa/ganeti-qa.py \
493         qa/qa_cluster.py \
494         qa/qa_config.py \
495         qa/qa_daemon.py \
496         qa/qa_env.py \
497         qa/qa_error.py \
498         qa/qa_group.py \
499         qa/qa_instance.py \
500         qa/qa_node.py \
501         qa/qa_os.py \
502         qa/qa_rapi.py \
503         qa/qa_tags.py \
504         qa/qa_utils.py
505
506 bin_SCRIPTS =
507 if WANT_HTOOLS
508 bin_SCRIPTS += $(filter-out htools/hail,$(HS_PROGS))
509 install-exec-hook:
510         @mkdir_p@ $(DESTDIR)$(iallocatorsdir)
511 # FIXME: this is a hardcoded logic, instead of auto-resolving
512         $(LN_S) -f ../../../bin/htools \
513                    $(DESTDIR)$(iallocatorsdir)/hail
514         for role in $(HS_BIN_ROLES); do \
515                 $(LN_S) -f htools \
516                            $(DESTDIR)$(bindir)/$$role ; \
517         done
518 endif
519
520 $(HS_ALL_PROGS): %: %.hs $(HS_LIB_SRCS) $(HS_BUILT_SRCS) Makefile
521         @if [ -z "$(HTOOLS)" ]; then \
522           echo "Error: htools compilation disabled at configure time" 1>&2 ;\
523           exit 1; \
524         fi
525         @BINARY=$(@:htools/%=%); \
526         if [ "$BINARY" = "test" ] && [ -z "$(GHC_PKG_QUICKCHECK)" ]; then \
527           echo "Error: cannot run unittests without the QuickCheck library (see devnotes.rst)" 1>&2; \
528           exit 1; \
529         fi
530         rm -f $(@:htools/%=%).tix
531         BINARY=$(@:htools/%=%); $(GHC) --make \
532           $(HFLAGS) \
533           $(HTOOLS_NOCURL) $(HTOOLS_PARALLEL3) \
534           -osuf $$BINARY.o -hisuf $$BINARY.hi \
535           $(HEXTRA) $(HEXTRA_INT) $@
536
537 # for the htools/test binary, we need to enable profiling/coverage
538 htools/test: HEXTRA_INT=-fhpc -Wwarn -fno-warn-missing-signatures \
539         -fno-warn-monomorphism-restriction -fno-warn-orphans \
540         -fno-warn-missing-methods -fno-warn-unused-imports
541
542 # we compile the htools-hpc binary with the program coverage
543 htools/htools-hpc: HEXTRA_INT=-fhpc
544
545 # test dependency
546 htools/offline-tests.sh: htools/htools-hpc
547
548 # rules for building profiling-enabled versions of the haskell
549 # programs: hs-prof does the full two-step build, whereas
550 # hs-prof-quick does only the final rebuild (hs-prof must have been
551 # run before)
552 .PHONY: hs-prof hs-prof-quick
553 hs-prof:
554         $(MAKE) clean
555         $(MAKE) $(HS_ALL_PROGS) HEXTRA="-osuf .o"
556         rm -f $(HS_ALL_PROGS)
557         $(MAKE) hs-prof-quick
558
559 hs-prof-quick:
560         $(MAKE) $(HS_ALL_PROGS) HEXTRA="-osuf .prof_o -prof -auto-all"
561
562 dist_sbin_SCRIPTS = \
563         tools/ganeti-listrunner
564
565 nodist_sbin_SCRIPTS = \
566         $(PYTHON_BOOTSTRAP_SBIN) \
567         daemons/ganeti-cleaner
568
569 python_scripts = \
570         tools/burnin \
571         tools/cfgshell \
572         tools/cfgupgrade \
573         tools/cfgupgrade12 \
574         tools/cluster-merge \
575         tools/confd-client \
576         tools/fmtjson \
577         tools/lvmstrap \
578         tools/move-instance \
579         tools/ovfconverter \
580         tools/setup-ssh \
581         tools/sanitize-config
582
583 dist_tools_SCRIPTS = \
584         $(python_scripts) \
585         tools/kvm-console-wrapper \
586         tools/xm-console-wrapper \
587         tools/master-ip-setup
588
589 pkglib_python_scripts = \
590         daemons/import-export \
591         tools/check-cert-expired
592
593 nodist_pkglib_python_scripts = \
594         tools/ensure-dirs
595
596 myexeclib_SCRIPTS = \
597         daemons/daemon-util \
598         tools/kvm-ifup \
599         $(pkglib_python_scripts)
600
601 nodist_myexeclib_SCRIPTS = \
602         $(nodist_pkglib_python_scripts)
603
604 EXTRA_DIST = \
605         NEWS \
606         UPGRADE \
607         epydoc.conf.in \
608         pylintrc \
609         autotools/build-bash-completion \
610         autotools/build-rpc \
611         autotools/check-header \
612         autotools/check-python-code \
613         autotools/check-imports \
614         autotools/check-man-dashes \
615         autotools/check-man-warnings \
616         autotools/check-news \
617         autotools/check-tar \
618         autotools/check-version \
619         autotools/convert-constants \
620         autotools/docpp \
621         autotools/gen-coverage \
622         autotools/testrunner \
623         $(RUN_IN_TEMPDIR) \
624         daemons/daemon-util.in \
625         daemons/ganeti-cleaner.in \
626         $(pkglib_python_scripts) \
627         devel/upload.in \
628         tools/kvm-ifup.in \
629         $(docdot) \
630         $(docpng) \
631         $(docrst) \
632         doc/conf.py \
633         doc/html \
634         $(BUILT_EXAMPLES:%=%.in) \
635         doc/examples/ganeti.default \
636         doc/examples/ganeti.default-debug \
637         doc/examples/hooks/ethers \
638         doc/examples/gnt-debug/README \
639         doc/examples/gnt-debug/delay0.json \
640         doc/examples/gnt-debug/delay50.json \
641         test/lockperf.py \
642         test/testutils.py \
643         test/mocks.py \
644         $(dist_TESTS) \
645         $(TEST_FILES) \
646         man/footer.rst \
647         $(manrst) \
648         $(maninput) \
649         qa/qa-sample.json \
650         $(qa_scripts) \
651         $(HS_LIB_SRCS) $(HS_BUILT_SRCS_IN) \
652         $(HS_PROG_SRCS) \
653         htools/lint-hints.hs \
654         htools/cli-tests-defs.sh \
655         htools/offline-test.sh
656
657 man_MANS = \
658         man/ganeti.7 \
659         man/ganeti-cleaner.8 \
660         man/ganeti-confd.8 \
661         man/ganeti-listrunner.8 \
662         man/ganeti-masterd.8 \
663         man/ganeti-noded.8 \
664         man/ganeti-os-interface.7 \
665         man/ganeti-rapi.8 \
666         man/ganeti-watcher.8 \
667         man/gnt-backup.8 \
668         man/gnt-cluster.8 \
669         man/gnt-debug.8 \
670         man/gnt-group.8 \
671         man/gnt-instance.8 \
672         man/gnt-job.8 \
673         man/gnt-node.8 \
674         man/gnt-os.8 \
675         man/hail.1 \
676         man/hbal.1 \
677         man/hinfo.1 \
678         man/hscan.1 \
679         man/hspace.1 \
680         man/htools.1
681
682 manrst = $(patsubst %.1,%.rst,$(patsubst %.7,%.rst,$(patsubst %.8,%.rst,$(man_MANS))))
683 manhtml = $(patsubst %.rst,%.html,$(manrst))
684 mangen = $(patsubst %.rst,%.gen,$(manrst))
685 maninput = \
686         $(patsubst %.1,%.1.in,$(patsubst %.7,%.7.in,$(patsubst %.8,%.8.in,$(man_MANS)))) \
687         $(patsubst %.html,%.html.in,$(manhtml)) \
688         man/footer.man man/footer.html $(mangen)
689
690 TEST_FILES = \
691         test/data/bdev-drbd-8.0.txt \
692         test/data/bdev-drbd-8.3.txt \
693         test/data/bdev-drbd-disk.txt \
694         test/data/bdev-drbd-net-ip4.txt \
695         test/data/bdev-drbd-net-ip6.txt \
696         test/data/cert1.pem \
697         test/data/ip-addr-show-dummy0.txt \
698         test/data/ip-addr-show-lo-ipv4.txt \
699         test/data/ip-addr-show-lo-ipv6.txt \
700         test/data/ip-addr-show-lo-oneline-ipv4.txt \
701         test/data/ip-addr-show-lo-oneline-ipv6.txt \
702         test/data/ip-addr-show-lo-oneline.txt \
703         test/data/ip-addr-show-lo.txt \
704         test/data/proc_drbd8.txt \
705         test/data/proc_drbd80-emptyline.txt \
706         test/data/proc_drbd83.txt \
707         test/data/proc_drbd83_sync.txt \
708         test/data/proc_drbd83_sync_krnl2.6.39.txt \
709         test/data/kvm_1.0_help.txt \
710         test/data/kvm_0.15.90_help.txt \
711         test/data/kvm_0.12.5_help.txt \
712         test/data/kvm_0.9.1_help.txt \
713         test/data/sys_drbd_usermode_helper.txt \
714         test/data/htools/hail-alloc-drbd.json \
715         test/data/htools/hail-change-group.json \
716         test/data/htools/hail-node-evac.json \
717         test/data/htools/hail-reloc-drbd.json \
718         test/data/htools/rapi/groups.json \
719         test/data/htools/rapi/info.json \
720         test/data/htools/rapi/instances.json \
721         test/data/htools/rapi/nodes.json \
722         test/data/ovfdata/compr_disk.vmdk.gz \
723         test/data/ovfdata/config.ini \
724         test/data/ovfdata/corrupted_resources.ovf \
725         test/data/ovfdata/empty.ini \
726         test/data/ovfdata/empty.ovf \
727         test/data/ovfdata/ganeti.mf \
728         test/data/ovfdata/ganeti.ovf \
729         test/data/ovfdata/gzip_disk.ovf \
730         test/data/ovfdata/new_disk.vmdk \
731         test/data/ovfdata/no_disk.ini \
732         test/data/ovfdata/no_disk_in_ref.ovf \
733         test/data/ovfdata/no_os.ini \
734         test/data/ovfdata/no_ovf.ova \
735         test/data/ovfdata/ova.ova \
736         test/data/ovfdata/second_disk.vmdk \
737         test/data/ovfdata/rawdisk.raw \
738         test/data/ovfdata/unsafe_path.ini \
739         test/data/ovfdata/virtualbox.ovf \
740         test/data/ovfdata/wrong_extension.ovd \
741         test/data/ovfdata/wrong_config.ini \
742         test/data/ovfdata/wrong_manifest.mf \
743         test/data/ovfdata/wrong_manifest.ovf \
744         test/data/ovfdata/wrong_ova.ova \
745         test/data/ovfdata/wrong_xml.ovf \
746         test/data/ovfdata/other/rawdisk.raw \
747         test/data/vgreduce-removemissing-2.02.02.txt \
748         test/data/vgreduce-removemissing-2.02.66-fail.txt \
749         test/data/vgreduce-removemissing-2.02.66-ok.txt \
750         test/data/vgs-missing-pvs-2.02.02.txt \
751         test/data/vgs-missing-pvs-2.02.66.txt \
752         test/import-export_unittest-helper
753
754 python_tests = \
755         test/ganeti.asyncnotifier_unittest.py \
756         test/ganeti.backend_unittest.py \
757         test/ganeti.bdev_unittest.py \
758         test/ganeti.cli_unittest.py \
759         test/ganeti.client.gnt_cluster_unittest.py \
760         test/ganeti.client.gnt_instance_unittest.py \
761         test/ganeti.daemon_unittest.py \
762         test/ganeti.cmdlib_unittest.py \
763         test/ganeti.compat_unittest.py \
764         test/ganeti.confd.client_unittest.py \
765         test/ganeti.config_unittest.py \
766         test/ganeti.constants_unittest.py \
767         test/ganeti.errors_unittest.py \
768         test/ganeti.hooks_unittest.py \
769         test/ganeti.ht_unittest.py \
770         test/ganeti.http_unittest.py \
771         test/ganeti.hypervisor_unittest.py \
772         test/ganeti.hypervisor.hv_chroot_unittest.py \
773         test/ganeti.hypervisor.hv_fake_unittest.py \
774         test/ganeti.hypervisor.hv_kvm_unittest.py \
775         test/ganeti.hypervisor.hv_lxc_unittest.py \
776         test/ganeti.hypervisor.hv_xen_unittest.py \
777         test/ganeti.impexpd_unittest.py \
778         test/ganeti.jqueue_unittest.py \
779         test/ganeti.locking_unittest.py \
780         test/ganeti.luxi_unittest.py \
781         test/ganeti.masterd.instance_unittest.py \
782         test/ganeti.mcpu_unittest.py \
783         test/ganeti.netutils_unittest.py \
784         test/ganeti.objects_unittest.py \
785         test/ganeti.opcodes_unittest.py \
786         test/ganeti.ovf_unittest.py \
787         test/ganeti.qlang_unittest.py \
788         test/ganeti.query_unittest.py \
789         test/ganeti.rapi.baserlib_unittest.py \
790         test/ganeti.rapi.client_unittest.py \
791         test/ganeti.rapi.resources_unittest.py \
792         test/ganeti.rapi.rlib2_unittest.py \
793         test/ganeti.rapi.testutils_unittest.py \
794         test/ganeti.rpc_unittest.py \
795         test/ganeti.runtime_unittest.py \
796         test/ganeti.serializer_unittest.py \
797         test/ganeti.ssh_unittest.py \
798         test/ganeti.storage_unittest.py \
799         test/ganeti.tools.ensure_dirs_unittest.py \
800         test/ganeti.uidpool_unittest.py \
801         test/ganeti.utils.algo_unittest.py \
802         test/ganeti.utils.filelock_unittest.py \
803         test/ganeti.utils.hash_unittest.py \
804         test/ganeti.utils.io_unittest.py \
805         test/ganeti.utils.log_unittest.py \
806         test/ganeti.utils.mlock_unittest.py \
807         test/ganeti.utils.nodesetup_unittest.py \
808         test/ganeti.utils.process_unittest.py \
809         test/ganeti.utils.retry_unittest.py \
810         test/ganeti.utils.text_unittest.py \
811         test/ganeti.utils.wrapper_unittest.py \
812         test/ganeti.utils.x509_unittest.py \
813         test/ganeti.utils_unittest.py \
814         test/ganeti.workerpool_unittest.py \
815         test/cfgupgrade_unittest.py \
816         test/docs_unittest.py \
817         test/pycurl_reset_unittest.py \
818         test/tempfile_fork_unittest.py
819 if HAS_FAKEROOT
820 python_tests += test/ganeti.utils.io_unittest-runasroot.py
821 endif
822
823 haskell_tests = htools/test
824
825 dist_TESTS = \
826         test/check-cert-expired_unittest.bash \
827         test/daemon-util_unittest.bash \
828         test/ganeti-cleaner_unittest.bash \
829         test/import-export_unittest.bash \
830         $(python_tests)
831
832 nodist_TESTS =
833 check_SCRIPTS =
834
835 if WANT_HTOOLSTESTS
836 nodist_TESTS += $(haskell_tests)
837 dist_TESTS += htools/offline-test.sh
838 check_SCRIPTS += htools/htools-hpc
839 endif
840
841 TESTS = $(dist_TESTS) $(nodist_TESTS)
842
843 # Environment for all tests
844 PLAIN_TESTS_ENVIRONMENT = \
845         PYTHONPATH=. TOP_SRCDIR=$(abs_top_srcdir) PYTHON=$(PYTHON) \
846         FAKEROOT=$(FAKEROOT_PATH) $(RUN_IN_TEMPDIR)
847
848 # Environment for tests run by automake
849 TESTS_ENVIRONMENT = \
850         $(PLAIN_TESTS_ENVIRONMENT) $(abs_top_srcdir)/autotools/testrunner
851
852 all_python_code = \
853         $(dist_sbin_SCRIPTS) \
854         $(python_scripts) \
855         $(pkglib_python_scripts) \
856         $(nodist_pkglib_python_scripts) \
857         $(python_tests) \
858         $(pkgpython_PYTHON) \
859         $(client_PYTHON) \
860         $(hypervisor_PYTHON) \
861         $(rapi_PYTHON) \
862         $(server_PYTHON) \
863         $(pytools_PYTHON) \
864         $(http_PYTHON) \
865         $(confd_PYTHON) \
866         $(masterd_PYTHON) \
867         $(impexpd_PYTHON) \
868         $(utils_PYTHON) \
869         $(watcher_PYTHON) \
870         $(noinst_PYTHON) \
871         $(qa_scripts)
872
873 srclink_files = \
874         man/footer.rst \
875         test/check-cert-expired_unittest.bash \
876         test/daemon-util_unittest.bash \
877         test/ganeti-cleaner_unittest.bash \
878         test/import-export_unittest.bash \
879         htools/offline-test.sh \
880         htools/cli-tests-defs.sh \
881         $(all_python_code) \
882         $(HS_LIB_SRCS) $(HS_PROG_SRCS)
883
884 check_python_code = \
885         $(BUILD_BASH_COMPLETION) \
886         $(CHECK_IMPORTS) \
887         $(CHECK_HEADER) \
888         $(DOCPP) \
889         $(all_python_code)
890
891 lint_python_code = \
892         ganeti \
893         ganeti/http/server.py \
894         $(dist_sbin_SCRIPTS) \
895         $(python_scripts) \
896         $(pkglib_python_scripts) \
897         $(BUILD_BASH_COMPLETION) \
898         $(CHECK_IMPORTS) \
899         $(CHECK_HEADER) \
900         $(DOCPP) \
901         $(PYTHON_BOOTSTRAP)
902
903 standalone_python_modules = \
904         lib/rapi/client.py \
905         tools/ganeti-listrunner
906
907 pep8_python_code = \
908         ganeti \
909         ganeti/http/server.py \
910         $(dist_sbin_SCRIPTS) \
911         $(python_scripts) \
912         $(pkglib_python_scripts) \
913         $(BUILD_BASH_COMPLETION) \
914         $(CHECK_HEADER) \
915         $(DOCPP) \
916         $(PYTHON_BOOTSTRAP) \
917         qa
918
919 test/daemon-util_unittest.bash: daemons/daemon-util
920
921 test/ganeti-cleaner_unittest.bash: daemons/ganeti-cleaner
922
923 tools/kvm-ifup: tools/kvm-ifup.in $(REPLACE_VARS_SED)
924         sed -f $(REPLACE_VARS_SED) < $< > $@
925         chmod +x $@
926
927 devel/upload: devel/upload.in $(REPLACE_VARS_SED)
928         sed -f $(REPLACE_VARS_SED) < $< > $@
929         chmod u+x $@
930
931 daemons/%: daemons/%.in $(REPLACE_VARS_SED)
932         sed -f $(REPLACE_VARS_SED) < $< > $@
933         chmod +x $@
934
935 doc/examples/%: doc/examples/%.in $(REPLACE_VARS_SED)
936         sed -f $(REPLACE_VARS_SED) < $< > $@
937
938 doc/examples/hooks/%: doc/examples/hooks/%.in $(REPLACE_VARS_SED)
939         sed -f $(REPLACE_VARS_SED) < $< > $@
940
941 doc/examples/bash_completion: $(BUILD_BASH_COMPLETION) $(RUN_IN_TEMPDIR) \
942         lib/cli.py $(gnt_scripts) $(client_PYTHON) tools/burnin
943         PYTHONPATH=. $(RUN_IN_TEMPDIR) $(CURDIR)/$(BUILD_BASH_COMPLETION) > $@
944
945 doc/%.png: doc/%.dot
946         @test -n "$(DOT)" || { echo 'dot' not found during configure; exit 1; }
947         $(DOT) -Tpng -o $@ $<
948
949 man/footer.man: man/footer.rst
950         @test -n "$(PANDOC)" || \
951           { echo 'pandoc' not found during configure; exit 1; }
952         $(PANDOC) -f rst -t man -o $@ $<
953
954 man/footer.html: man/footer.rst
955         @test -n "$(PANDOC)" || \
956           { echo 'pandoc' not found during configure; exit 1; }
957         $(PANDOC) -f rst -t html -o $@ $<
958
959 man/%.gen: man/%.rst lib/query.py lib/build/sphinx_ext.py
960         PYTHONPATH=. $(RUN_IN_TEMPDIR) $(CURDIR)/$(DOCPP) < $< > $@
961
962 man/%.7.in man/%.8.in man/%.1.in: man/%.gen man/footer.man
963         @test -n "$(PANDOC)" || \
964           { echo 'pandoc' not found during configure; exit 1; }
965         set -o pipefail ; \
966         trap 'echo auto-removing $@; rm $@' EXIT; \
967         $(PANDOC) -s -f rst -t man -A man/footer.man $< | \
968           sed -e 's/\\@/@/g' > $@; \
969         if test -n "$(MAN_HAS_WARNINGS)"; then $(CHECK_MAN_WARNINGS) $@; fi; \
970         $(CHECK_MAN_DASHES) $@; \
971         trap - EXIT
972
973
974 man/%.html.in: man/%.gen man/footer.html
975         @test -n "$(PANDOC)" || \
976           { echo 'pandoc' not found during configure; exit 1; }
977         set -o pipefail ; \
978         $(PANDOC) -s -f rst -t html -A man/footer.html $< | \
979           sed -e 's/\\@/@/g' > $@
980
981 man/%.1: man/%.1.in $(REPLACE_VARS_SED)
982         sed -f $(REPLACE_VARS_SED) < $< > $@
983
984 man/%.7: man/%.7.in $(REPLACE_VARS_SED)
985         sed -f $(REPLACE_VARS_SED) < $< > $@
986
987 man/%.8: man/%.8.in $(REPLACE_VARS_SED)
988         sed -f $(REPLACE_VARS_SED) < $< > $@
989
990 man/%.html: man/%.html.in $(REPLACE_VARS_SED)
991         sed -f $(REPLACE_VARS_SED) < $< > $@
992
993 epydoc.conf: epydoc.conf.in Makefile
994         sed -e 's#@MODULES@#$(strip $(lint_python_code))#g' < $< > $@
995
996 vcs-version:
997         if test -d .git; then \
998           git describe > $@; \
999         elif test ! -f $@ ; then \
1000           echo "Cannot auto-generate $@ file"; exit 1; \
1001         fi
1002
1003 .PHONY: regen-vcs-version
1004 regen-vcs-version:
1005         set -e; \
1006         cd $(srcdir); \
1007         if test -d .git; then \
1008           rm -f vcs-version; \
1009           $(MAKE) vcs-version; \
1010         fi
1011
1012 htools/Ganeti/HTools/Version.hs: htools/Ganeti/HTools/Version.hs.in vcs-version
1013         set -e; \
1014         VCSVER=`cat $(abs_top_srcdir)/vcs-version`; \
1015         sed -e "s/%ver%/$$VCSVER/" < $< > $@
1016
1017 htools/Ganeti/Constants.hs: htools/Ganeti/Constants.hs.in \
1018         lib/constants.py lib/_autoconf.py $(CONVERT_CONSTANTS) \
1019         | lib/_vcsversion.py
1020         set -e; \
1021         { cat $< ; PYTHONPATH=. $(CONVERT_CONSTANTS); } > $@
1022
1023 lib/_autoconf.py: Makefile | lib/.dir
1024         set -e; \
1025         { echo '# This file is automatically generated, do not edit!'; \
1026           echo '#'; \
1027           echo ''; \
1028           echo '"""Build-time configuration for Ganeti.'; \
1029           echo '';\
1030           echo 'This file is autogenerated by the build process.'; \
1031           echo 'For any changes you need to re-run ./configure (and'; \
1032           echo 'not edit by hand).'; \
1033           echo ''; \
1034           echo '"""'; \
1035           echo ''; \
1036           echo '# pylint: disable=C0301,C0324'; \
1037           echo '# because this is autogenerated, we do not want'; \
1038           echo '# style warnings' ; \
1039           echo ''; \
1040           echo "PACKAGE_VERSION = '$(PACKAGE_VERSION)'"; \
1041           echo "VERSION_MAJOR = '$(VERSION_MAJOR)'"; \
1042           echo "VERSION_MINOR = '$(VERSION_MINOR)'"; \
1043           echo "VERSION_REVISION = '$(VERSION_REVISION)'"; \
1044           echo "VERSION_SUFFIX = '$(VERSION_SUFFIX)'"; \
1045           echo "VERSION_FULL = '$(VERSION_FULL)'"; \
1046           echo "LOCALSTATEDIR = '$(localstatedir)'"; \
1047           echo "SYSCONFDIR = '$(sysconfdir)'"; \
1048           echo "SSH_CONFIG_DIR = '$(SSH_CONFIG_DIR)'"; \
1049           echo "EXPORT_DIR = '$(EXPORT_DIR)'"; \
1050           echo "OS_SEARCH_PATH = [$(OS_SEARCH_PATH)]"; \
1051           echo "XEN_BOOTLOADER = '$(XEN_BOOTLOADER)'"; \
1052           echo "XEN_KERNEL = '$(XEN_KERNEL)'"; \
1053           echo "XEN_INITRD = '$(XEN_INITRD)'"; \
1054           echo "FILE_STORAGE_DIR = '$(FILE_STORAGE_DIR)'"; \
1055           echo "ENABLE_FILE_STORAGE = $(ENABLE_FILE_STORAGE)"; \
1056           echo "SHARED_FILE_STORAGE_DIR = '$(SHARED_FILE_STORAGE_DIR)'"; \
1057           echo "ENABLE_SHARED_FILE_STORAGE = $(ENABLE_SHARED_FILE_STORAGE)"; \
1058           echo "IALLOCATOR_SEARCH_PATH = [$(IALLOCATOR_SEARCH_PATH)]"; \
1059           echo "KVM_PATH = '$(KVM_PATH)'"; \
1060           echo "IP_PATH = '$(IP_PATH)'"; \
1061           echo "SOCAT_PATH = '$(SOCAT)'"; \
1062           echo "SOCAT_USE_ESCAPE = $(SOCAT_USE_ESCAPE)"; \
1063           echo "SOCAT_USE_COMPRESS = $(SOCAT_USE_COMPRESS)"; \
1064           echo "LVM_STRIPECOUNT = $(LVM_STRIPECOUNT)"; \
1065           echo "TOOLSDIR = '$(toolsdir)'"; \
1066           echo "GNT_SCRIPTS = [$(foreach i,$(notdir $(gnt_scripts)),'$(i)',)]"; \
1067           echo "PKGLIBDIR = '$(pkglibdir)'"; \
1068           echo "DRBD_BARRIERS = '$(DRBD_BARRIERS)'"; \
1069           echo "DRBD_NO_META_FLUSH = $(DRBD_NO_META_FLUSH)"; \
1070           echo "SYSLOG_USAGE = '$(SYSLOG_USAGE)'"; \
1071           echo "DAEMONS_GROUP = '$(DAEMONS_GROUP)'"; \
1072           echo "ADMIN_GROUP = '$(ADMIN_GROUP)'"; \
1073           echo "MASTERD_USER = '$(MASTERD_USER)'"; \
1074           echo "MASTERD_GROUP = '$(MASTERD_GROUP)'"; \
1075           echo "RAPI_USER = '$(RAPI_USER)'"; \
1076           echo "RAPI_GROUP = '$(RAPI_GROUP)'"; \
1077           echo "CONFD_USER = '$(CONFD_USER)'"; \
1078           echo "CONFD_GROUP = '$(CONFD_GROUP)'"; \
1079           echo "NODED_USER = '$(NODED_USER)'"; \
1080           echo "NODED_GROUP = '$(NODED_GROUP)'"; \
1081           echo "DISK_SEPARATOR = '$(DISK_SEPARATOR)'"; \
1082           echo "QEMUIMG_PATH = '$(QEMUIMG_PATH)'"; \
1083           if [ "$(HTOOLS)" ]; then \
1084             echo "HTOOLS = True"; \
1085           else \
1086             echo "HTOOLS = False"; \
1087           fi; \
1088           echo "ENABLE_CONFD = $(ENABLE_CONFD)"; \
1089         } > $@
1090
1091 lib/_vcsversion.py: Makefile vcs-version | lib/.dir
1092         set -e; \
1093         VCSVER=`cat $(abs_top_srcdir)/vcs-version`; \
1094         { echo '# This file is automatically generated, do not edit!'; \
1095           echo '#'; \
1096           echo ''; \
1097           echo '"""Build-time VCS version number for Ganeti.'; \
1098           echo '';\
1099           echo 'This file is autogenerated by the build process.'; \
1100           echo 'For any changes you need to re-run ./configure (and'; \
1101           echo 'not edit by hand).'; \
1102           echo ''; \
1103           echo '"""'; \
1104           echo ''; \
1105           echo '# pylint: disable=C0301,C0324'; \
1106           echo '# because this is autogenerated, we do not want'; \
1107           echo '# style warnings' ; \
1108           echo ''; \
1109           echo "VCS_VERSION = '$$VCSVER'"; \
1110         } > $@
1111
1112 lib/_generated_rpc.py: lib/rpc_defs.py $(BUILD_RPC)
1113         PYTHONPATH=. $(RUN_IN_TEMPDIR) $(CURDIR)/$(BUILD_RPC) lib/rpc_defs.py > $@
1114
1115 $(REPLACE_VARS_SED): Makefile
1116         set -e; \
1117         { echo 's#@PREFIX@#$(prefix)#g'; \
1118           echo 's#@SYSCONFDIR@#$(sysconfdir)#g'; \
1119           echo 's#@LOCALSTATEDIR@#$(localstatedir)#g'; \
1120           echo 's#@BINDIR@#$(bindir)#g'; \
1121           echo 's#@SBINDIR@#$(sbindir)#g'; \
1122           echo 's#@GANETI_VERSION@#$(PACKAGE_VERSION)#g'; \
1123           echo 's#@CUSTOM_XEN_BOOTLOADER@#$(XEN_BOOTLOADER)#g'; \
1124           echo 's#@CUSTOM_XEN_KERNEL@#$(XEN_KERNEL)#g'; \
1125           echo 's#@CUSTOM_XEN_INITRD@#$(XEN_INITRD)#g'; \
1126           echo 's#@CUSTOM_IALLOCATOR_SEARCH_PATH@#$(IALLOCATOR_SEARCH_PATH)#g'; \
1127           echo 's#@CUSTOM_EXPORT_DIR@#$(EXPORT_DIR)#g'; \
1128           echo 's#@RPL_FILE_STORAGE_DIR@#$(FILE_STORAGE_DIR)#g'; \
1129           echo 's#@RPL_SSH_INITD_SCRIPT@#$(SSH_INITD_SCRIPT)#g'; \
1130           echo 's#@PKGLIBDIR@#$(pkglibdir)#g'; \
1131           echo 's#@GNTMASTERUSER@#$(MASTERD_USER)#g'; \
1132           echo 's#@GNTRAPIUSER@#$(RAPI_USER)#g'; \
1133           echo 's#@GNTCONFDUSER@#$(CONFD_USER)#g'; \
1134           echo 's#@GNTNODEDUSER@#$(NODED_USER)#g'; \
1135           echo 's#@GNTRAPIGROUP@#$(RAPI_GROUP)#g'; \
1136           echo 's#@GNTADMINGROUP@#$(ADMIN_GROUP)#g'; \
1137           echo 's#@GNTCONFDGROUP@#$(CONFD_GROUP)#g'; \
1138           echo 's#@GNTMASTERDGROUP@#$(MASTERD_GROUP)#g'; \
1139           echo 's#@GNTDAEMONSGROUP@#$(DAEMONS_GROUP)#g'; \
1140           echo 's#@CUSTOM_ENABLE_CONFD@#$(ENABLE_CONFD)#g'; \
1141         } > $@
1142
1143 # Using deferred evaluation
1144 daemons/ganeti-%: MODULE = ganeti.server.$(patsubst ganeti-%,%,$(notdir $@))
1145 daemons/ganeti-watcher: MODULE = ganeti.watcher
1146 scripts/%: MODULE = ganeti.client.$(subst -,_,$(notdir $@))
1147 tools/ensure-dirs: MODULE = ganeti.tools.ensure_dirs
1148
1149 $(PYTHON_BOOTSTRAP): Makefile | $(all_dirfiles)
1150         test -n "$(MODULE)" || { echo Missing module; exit 1; }
1151         set -e; \
1152         { echo '#!/usr/bin/python'; \
1153           echo '# This file is automatically generated, do not edit!'; \
1154           echo "# Edit $(MODULE) instead."; \
1155           echo; \
1156           echo '"""Bootstrap script for L{$(MODULE)}"""'; \
1157           echo; \
1158           echo '# pylint: disable=C0103'; \
1159           echo '# C0103: Invalid name'; \
1160           echo; \
1161           echo 'import sys'; \
1162           echo 'import $(MODULE) as main'; \
1163           echo; \
1164           echo '# Temporarily alias commands until bash completion'; \
1165           echo '# generator is changed'; \
1166           echo 'if hasattr(main, "commands"):'; \
1167           echo '  commands = main.commands # pylint: disable=E1101'; \
1168           echo 'if hasattr(main, "aliases"):'; \
1169           echo '  aliases = main.aliases # pylint: disable=E1101'; \
1170           echo; \
1171           echo 'if __name__ == "__main__":'; \
1172           echo '  sys.exit(main.Main())'; \
1173         } > $@
1174         chmod u+x $@
1175
1176 # We need to create symlinks because "make distcheck" will not install Python
1177 # files when building.
1178 stamp-srclinks: Makefile | $(all_dirfiles)
1179         set -e; \
1180         for i in $(srclink_files); do \
1181                 if test ! -f $$i -a -f $(abs_top_srcdir)/$$i; then \
1182                         $(LN_S) $(abs_top_srcdir)/$$i $$i; \
1183                 fi; \
1184         done
1185         touch $@
1186
1187 .PHONY: ganeti
1188 ganeti:
1189         cd $(top_builddir) && test -h "$@" || { rm -f $@ && $(LN_S) lib $@; }
1190
1191 .PHONY: check-dirs
1192 check-dirs: $(BUILT_SOURCES)
1193         @set -e; \
1194         find . -type d \( \( -name . \) -o \( \
1195                 -name .git -o \
1196                 -name autom4te.cache \
1197                 \) -prune -o -print \) | { \
1198                 error=; \
1199                 while read dir; do \
1200                         case "$$dir" in \
1201                                 $(strip $(patsubst %,(./%) ;;,$(DIRCHECK_EXCLUDE) $(DIRS))) \
1202                                 *) error=1; echo "Directory $$dir not listed in Makefile" >&2 ;; \
1203                         esac; \
1204                 done; \
1205                 for dir in $(DIRS); do \
1206                         if ! test -d "$$dir"; then \
1207                                 echo "Directory $$dir listed in DIRS does not exist" >&2; \
1208                                 error=1; \
1209                         fi \
1210                 done; \
1211                 if test -n "$$error"; then exit 1; else exit 0; fi; \
1212         }
1213
1214 .PHONY: check-local
1215 check-local: check-dirs $(BUILT_SOURCES)
1216         $(CHECK_PYTHON_CODE) $(check_python_code)
1217         PYTHONPATH=. $(CHECK_HEADER) $(check_python_code)
1218         $(CHECK_VERSION) $(VERSION) $(top_srcdir)/NEWS
1219         $(CHECK_NEWS) < $(top_srcdir)/NEWS
1220         PYTHONPATH=. $(RUN_IN_TEMPDIR) $(CURDIR)/$(CHECK_IMPORTS) . $(standalone_python_modules)
1221         expver=$(VERSION_MAJOR).$(VERSION_MINOR); \
1222         if test "`head -n 1 $(top_srcdir)/README`" != "Ganeti $$expver"; then \
1223                 echo "Incorrect version in README, expected $$expver"; \
1224                 exit 1; \
1225         fi; \
1226         for file in doc/iallocator.rst doc/hooks.rst; do \
1227                 if test "`sed -ne '4 p' $(top_srcdir)/$$file`" != \
1228                         "Documents Ganeti version $$expver"; then \
1229                         echo "Incorrect version in $$file, expected $$expver"; \
1230                         exit 1; \
1231                 fi; \
1232         done
1233
1234 .PHONY: hs-check
1235 hs-check: htools/test htools/htools-hpc
1236         @rm -f test.tix
1237         ./htools/test
1238         HBINARY="./htools/htools-hpc" ./htools/offline-test.sh
1239
1240 # E111: indentation is not a multiple of four
1241 # E261: at least two spaces before inline comment
1242 # E501: line too long (80 characters)
1243 PEP8_IGNORE = E111,E261,E501
1244
1245 # For excluding pep8 expects filenames only, not whole paths
1246 PEP8_EXCLUDE = $(subst $(space),$(comma),$(strip $(notdir $(BUILT_PYTHON_SOURCES))))
1247
1248 .PHONY: lint
1249 lint: $(BUILT_SOURCES)
1250         @test -n "$(PYLINT)" || { echo 'pylint' not found during configure; exit 1; }
1251         if test -z "$(PEP8)"; then \
1252                 echo '"pep8" not found during configure' >&2; \
1253         else \
1254                 $(PEP8) --repeat --ignore='$(PEP8_IGNORE)' --exclude='$(PEP8_EXCLUDE)' \
1255                         $(pep8_python_code); \
1256         fi
1257         $(PYLINT) $(LINT_OPTS) $(lint_python_code)
1258         cd $(top_srcdir)/qa && \
1259           PYTHONPATH=$(abs_top_srcdir) $(PYLINT) $(LINT_OPTS) \
1260           --rcfile  ../pylintrc $(patsubst qa/%.py,%,$(qa_scripts))
1261
1262 .PHONY: hlint
1263 hlint: $(HS_BUILT_SRCS) htools/lint-hints.hs
1264         if tty -s; then C="-c"; else C=""; fi; \
1265         hlint --report=doc/hs-lint.html --cross $$C \
1266           --ignore "Use first" \
1267           --ignore "Use comparing" \
1268           --ignore "Use on" \
1269           --ignore "Use Control.Exception.catch" \
1270           --ignore "Reduce duplication" \
1271           --hint htools/lint-hints \
1272           $(filter-out htools/Ganeti/THH.hs,$(HS_LIB_SRCS))
1273
1274 # a dist hook rule for updating the vcs-version file; this is
1275 # hardcoded due to where it needs to build the file...
1276 dist-hook:
1277         $(MAKE) regen-vcs-version && \
1278         rm -f $(top_distdir)/vcs-version && \
1279         cp -p $(srcdir)/vcs-version $(top_distdir)
1280
1281 # a distcheck hook rule for catching revision control directories
1282 distcheck-hook:
1283         if find $(top_distdir) -name .svn -or -name .git | grep .; then \
1284                 echo "Found revision control files in final archive." 1>&2; \
1285                 exit 1; \
1286         fi
1287         if find $(top_distdir) -name '*.py[co]' | grep .; then \
1288                 echo "Found Python byte code in final archive." 1>&2; \
1289                 exit 1; \
1290         fi
1291         if find $(top_distdir) -name '*~' | grep .; then \
1292                 echo "Found backup files in final archive." 1>&2; \
1293                 exit 1; \
1294         fi
1295 # Empty files or directories should not be distributed. They can cause
1296 # unnecessary warnings for packagers. Directories used by automake during
1297 # distcheck must be excluded.
1298         if find $(top_distdir) -empty -and -not \( \
1299                         -path $(top_distdir)/_build -or \
1300                         -path $(top_distdir)/_inst \) | grep .; then \
1301                 echo "Found empty files or directories in final archive." 1>&2; \
1302                 exit 1; \
1303         fi
1304         if test -n "$(BUILD_RELEASE)" && \
1305            grep -n -H -E '^\*.*unreleased' $(top_distdir)/NEWS; then \
1306                 echo "Found unreleased version in NEWS." >&2; \
1307                 exit 1; \
1308         fi
1309
1310 # When building a release, stricter checks should be used
1311 distcheck-release dist-release: export BUILD_RELEASE = 1
1312 distcheck-release: distcheck
1313
1314 dist-release: dist
1315         set -e; \
1316         for i in $(DIST_ARCHIVES); do \
1317                 echo -n "Checking $$i ... "; \
1318                 autotools/check-tar < $$i; \
1319                 echo OK; \
1320         done
1321
1322 install-exec-local:
1323         @mkdir_p@ "$(DESTDIR)${localstatedir}/lib/ganeti" \
1324           "$(DESTDIR)${localstatedir}/log/ganeti" \
1325           "$(DESTDIR)${localstatedir}/run/ganeti"
1326
1327 # To avoid conflicts between directory names and other targets, a file inside
1328 # the directory is used to ensure its existence.
1329 %.dir:
1330         @mkdir_p@ $* && touch $@
1331
1332 .PHONY: apidoc
1333 if WANT_HTOOLSAPIDOC
1334 apidoc: py-apidoc hs-apidoc
1335 else
1336 apidoc: py-apidoc
1337 endif
1338
1339 .PHONY: py-apidoc
1340 py-apidoc: epydoc.conf $(RUN_IN_TEMPDIR) $(BUILT_SOURCES)
1341         $(RUN_IN_TEMPDIR) epydoc -v \
1342                 --conf $(CURDIR)/epydoc.conf \
1343                 --output $(CURDIR)/$(APIDOC_PY_DIR)
1344
1345 .PHONY: hs-apidoc
1346 hs-apidoc: $(HS_BUILT_SRCS)
1347         @test -n "$(HSCOLOUR)" || \
1348             { echo 'HsColour' not found during configure; exit 1; }
1349         @test -n "$(HADDOCK)" || \
1350             { echo 'haddock' not found during configure; exit 1; }
1351         rm -rf $(APIDOC_HS_DIR)/*
1352         @mkdir_p@ $(APIDOC_HS_DIR)/Ganeti/HTools/Program
1353         @mkdir_p@ $(APIDOC_HS_DIR)/Ganeti/Confd
1354         $(HSCOLOUR) -print-css > $(APIDOC_HS_DIR)/Ganeti/hscolour.css
1355         $(LN_S) ../hscolour.css $(APIDOC_HS_DIR)/Ganeti/HTools/hscolour.css
1356         $(LN_S) ../hscolour.css $(APIDOC_HS_DIR)/Ganeti/Confd/hscolour.css
1357         set -e ; \
1358         cd htools; \
1359         if [ "$(HTOOLS_NOCURL)" ]; \
1360         then OPTGHC="--optghc=$(HTOOLS_NOCURL)"; \
1361         else OPTGHC=""; \
1362         fi; \
1363         if [ "$(HTOOLS_PARALLEL3)" ]; \
1364         then OPTGHC="$$OPTGHC --optghc=$(HTOOLS_PARALLEL3)"; \
1365         fi; \
1366         RELSRCS="$(HS_LIB_SRCS:htools/%=%)  $(HS_BUILT_SRCS:htools/%=%)"; \
1367         for file in $$RELSRCS; do \
1368                 hfile=`echo $$file|sed 's/\\.hs$$//'`.html; \
1369                 $(HSCOLOUR) -css -anchor $$file > ../$(APIDOC_HS_DIR)/$$hfile ; \
1370         done ; \
1371         $(HADDOCK) --odir ../$(APIDOC_HS_DIR) --html --ignore-all-exports -w \
1372                 -t ganeti-htools -p haddock-prologue \
1373                 --source-module="%{MODULE/.//}.html" \
1374                 --source-entity="%{MODULE/.//}.html#%{NAME}" \
1375                 $$OPTGHC \
1376                 $(filter-out Ganeti/HTools/ExtLoader.hs,$(HS_LIB_SRCS:htools/%=%))
1377
1378 .PHONY: TAGS
1379 TAGS: $(BUILT_SOURCES)
1380         rm -f TAGS
1381         find . -path './lib/*.py' -o -path './scripts/gnt-*' -o \
1382           -path './daemons/ganeti-*' -o -path './tools/*' -o \
1383           -path './qa/*.py' | \
1384           etags -l python -
1385
1386 .PHONY: coverage
1387 if WANT_HTOOLS
1388 coverage: py-coverage hs-coverage
1389 else
1390 coverage: py-coverage
1391 endif
1392
1393 .PHONY: py-coverage
1394 py-coverage: $(BUILT_SOURCES) $(python_tests)
1395         set -e; \
1396         COVERAGE_FILE=$(CURDIR)/$(COVERAGE_PY_DIR)/data \
1397         TEXT_COVERAGE=$(CURDIR)/$(COVERAGE_PY_DIR)/report.txt \
1398         HTML_COVERAGE=$(CURDIR)/$(COVERAGE_PY_DIR) \
1399         $(PLAIN_TESTS_ENVIRONMENT) $(abs_top_srcdir)/autotools/gen-coverage \
1400         $(python_tests)
1401
1402 .PHONY: hs-coverage
1403 hs-coverage: $(haskell_tests) htools/htools-hpc
1404         rm -f *.tix && $(MAKE) hs-check
1405         @mkdir_p@ $(COVERAGE_HS_DIR)
1406         hpc combine $(HPCEXCL) test.tix htools-hpc.tix > htools-coverage.tix
1407         hpc markup --destdir=$(COVERAGE_HS_DIR) htools-coverage.tix
1408         hpc report htools-coverage.tix
1409         $(LN_S) -f hpc_index.html $(COVERAGE_HS_DIR)/index.html
1410
1411 # Special "kind-of-QA" target for htools, needs special setup (all
1412 # tools compiled with -fhpc)
1413 .PHONY: live-test
1414 live-test: all
1415         set -e ; \
1416         cd htools; \
1417         rm -f .hpc; $(LN_S) ../.hpc .hpc; \
1418         rm -f *.tix *.mix; \
1419         ./live-test.sh; \
1420         hpc sum --union $(HPCEXCL) $(addsuffix .tix,$(HS_PROGS:htools/%=%)) \
1421           --output=live-test.tix ; \
1422         @mkdir_p@ ../$(COVERAGE_HS_DIR) ; \
1423         hpc markup --destdir=../$(COVERAGE_HS_DIR) live-test \
1424                 --srcdir=.. $(HPCEXCL) ; \
1425         hpc report --srcdir=.. live-test $(HPCEXCL)
1426
1427 commit-check: distcheck lint apidoc
1428
1429 -include ./Makefile.local
1430
1431 # vim: set noet :