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