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