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