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