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