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