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