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