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