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