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