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