Statistics
| Branch: | Tag: | Revision:

root / Makefile.am @ 030a9cb8

History | View | Annotate | Download (32 kB)

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
# Use bash in order to be able to use pipefail
13
SHELL=/bin/bash
14

    
15
ACLOCAL_AMFLAGS = -I autotools
16
BUILD_BASH_COMPLETION = $(top_srcdir)/autotools/build-bash-completion
17
RUN_IN_TEMPDIR = $(top_srcdir)/autotools/run-in-tempdir
18
CHECK_PYTHON_CODE = $(top_srcdir)/autotools/check-python-code
19
CHECK_MAN = $(top_srcdir)/autotools/check-man
20
CHECK_VERSION = $(top_srcdir)/autotools/check-version
21
CHECK_NEWS = $(top_srcdir)/autotools/check-news
22
DOCPP = $(top_srcdir)/autotools/docpp
23
REPLACE_VARS_SED = autotools/replace_vars.sed
24
CONVERT_CONSTANTS = $(top_srcdir)/autotools/convert-constants
25

    
26
# Note: these are automake-specific variables, and must be named after
27
# the directory + 'dir' suffix
28
clientdir = $(pkgpythondir)/client
29
hypervisordir = $(pkgpythondir)/hypervisor
30
httpdir = $(pkgpythondir)/http
31
masterddir = $(pkgpythondir)/masterd
32
confddir = $(pkgpythondir)/confd
33
rapidir = $(pkgpythondir)/rapi
34
serverdir = $(pkgpythondir)/server
35
watcherdir = $(pkgpythondir)/watcher
36
impexpddir = $(pkgpythondir)/impexpd
37
utilsdir = $(pkgpythondir)/utils
38
toolsdir = $(pkglibdir)/tools
39
iallocatorsdir = $(pkglibdir)/iallocators
40
pytoolsdir = $(pkgpythondir)/tools
41
docdir = $(datadir)/doc/$(PACKAGE)
42

    
43
# Delete output file if an error occurred while building it
44
.DELETE_ON_ERROR:
45

    
46
HTOOLS_DIRS = \
47
	htools \
48
	htools/Ganeti \
49
	htools/Ganeti/HTools
50

    
51
DIRS = \
52
	autotools \
53
	daemons \
54
	devel \
55
	doc \
56
	doc/examples \
57
	doc/examples/hooks \
58
	doc/examples/gnt-debug \
59
	$(HTOOLS_DIRS) \
60
	lib \
61
	lib/client \
62
	lib/build \
63
	lib/confd \
64
	lib/http \
65
	lib/hypervisor \
66
	lib/impexpd \
67
	lib/masterd \
68
	lib/rapi \
69
	lib/server \
70
	lib/tools \
71
	lib/utils \
72
	lib/watcher \
73
	man \
74
	qa \
75
	test \
76
	test/data \
77
	tools
78

    
79
BUILDTIME_DIR_AUTOCREATE = \
80
	scripts \
81
	$(APIDOC_DIR) \
82
	$(APIDOC_PY_DIR) \
83
	$(APIDOC_HS_DIR) \
84
	$(APIDOC_HS_DIR)/Ganeti $(APIDOC_HS_DIR)/Ganeti/HTools \
85
	$(COVERAGE_DIR) \
86
	$(COVERAGE_PY_DIR) \
87
	$(COVERAGE_HS_DIR) \
88
	.hpc
89

    
90
BUILDTIME_DIRS = \
91
	$(BUILDTIME_DIR_AUTOCREATE) \
92
	doc/html
93

    
94
DIRCHECK_EXCLUDE = \
95
	$(BUILDTIME_DIRS) \
96
	ganeti-[0-9]*.[0-9]*.[0-9]* \
97
	doc/html/_*
98

    
99
all_dirfiles = $(addsuffix /.dir,$(DIRS) $(BUILDTIME_DIR_AUTOCREATE))
100

    
101
# some helper vars
102
COVERAGE_DIR = doc/coverage
103
COVERAGE_PY_DIR = $(COVERAGE_DIR)/py
104
COVERAGE_HS_DIR = $(COVERAGE_DIR)/hs
105
APIDOC_DIR = doc/api
106
APIDOC_PY_DIR = $(APIDOC_DIR)/py
107
APIDOC_HS_DIR = $(APIDOC_DIR)/hs
108

    
109
MAINTAINERCLEANFILES = \
110
	$(docpng) \
111
	$(maninput) \
112
	doc/install-quick.rst \
113
	doc/news.rst \
114
	doc/upgrade.rst \
115
	vcs-version
116

    
117
maintainer-clean-local:
118
	rm -rf $(BUILDTIME_DIRS)
119

    
120
CLEANFILES = \
121
	$(addsuffix /*.py[co],$(DIRS)) \
122
	$(addsuffix /*.hi,$(HTOOLS_DIRS)) \
123
	$(addsuffix /*.o,$(HTOOLS_DIRS)) \
124
	$(all_dirfiles) \
125
	$(PYTHON_BOOTSTRAP) \
126
	epydoc.conf \
127
	autotools/replace_vars.sed \
128
	daemons/daemon-util \
129
	daemons/ganeti-cleaner \
130
	devel/upload \
131
	doc/examples/bash_completion \
132
	doc/examples/ganeti.initd \
133
	doc/examples/ganeti-kvm-poweroff.initd \
134
	doc/examples/ganeti.cron \
135
	doc/examples/gnt-config-backup \
136
	doc/examples/hooks/ipsec \
137
	$(man_MANS) \
138
	$(manhtml) \
139
	tools/kvm-ifup \
140
	stamp-srclinks \
141
	$(nodist_pkgpython_PYTHON) \
142
	$(HS_ALL_PROGS) $(HS_BUILT_SRCS) \
143
	.hpc/*.mix htools/*.tix \
144
	doc/hs-lint.html
145

    
146
# BUILT_SOURCES should only be used as a dependency on phony targets. Otherwise
147
# it'll cause the target to rebuild every time.
148
BUILT_SOURCES = \
149
	ganeti \
150
	stamp-srclinks \
151
	lib/_autoconf.py \
152
	$(all_dirfiles) \
153
	$(PYTHON_BOOTSTRAP)
154

    
155
nodist_pkgpython_PYTHON = \
156
	lib/_autoconf.py
157

    
158
noinst_PYTHON = \
159
	lib/build/__init__.py \
160
	lib/build/sphinx_ext.py
161

    
162
pkgpython_PYTHON = \
163
	lib/__init__.py \
164
	lib/asyncnotifier.py \
165
	lib/backend.py \
166
	lib/bdev.py \
167
	lib/bootstrap.py \
168
	lib/cli.py \
169
	lib/cmdlib.py \
170
	lib/compat.py \
171
	lib/config.py \
172
	lib/constants.py \
173
	lib/daemon.py \
174
	lib/errors.py \
175
	lib/ht.py \
176
	lib/jqueue.py \
177
	lib/jstore.py \
178
	lib/locking.py \
179
	lib/luxi.py \
180
	lib/mcpu.py \
181
	lib/netutils.py \
182
	lib/objects.py \
183
	lib/opcodes.py \
184
	lib/qlang.py \
185
	lib/query.py \
186
	lib/rpc.py \
187
	lib/runtime.py \
188
	lib/serializer.py \
189
	lib/ssconf.py \
190
	lib/ssh.py \
191
	lib/storage.py \
192
	lib/uidpool.py \
193
	lib/workerpool.py
194

    
195
client_PYTHON = \
196
	lib/client/__init__.py \
197
	lib/client/gnt_backup.py \
198
	lib/client/gnt_cluster.py \
199
	lib/client/gnt_debug.py \
200
	lib/client/gnt_group.py \
201
	lib/client/gnt_instance.py \
202
	lib/client/gnt_job.py \
203
	lib/client/gnt_node.py \
204
	lib/client/gnt_os.py
205

    
206
hypervisor_PYTHON = \
207
	lib/hypervisor/__init__.py \
208
	lib/hypervisor/hv_base.py \
209
	lib/hypervisor/hv_chroot.py \
210
	lib/hypervisor/hv_fake.py \
211
	lib/hypervisor/hv_kvm.py \
212
	lib/hypervisor/hv_lxc.py \
213
	lib/hypervisor/hv_xen.py
214

    
215
rapi_PYTHON = \
216
	lib/rapi/__init__.py \
217
	lib/rapi/baserlib.py \
218
	lib/rapi/client.py \
219
	lib/rapi/client_utils.py \
220
	lib/rapi/connector.py \
221
	lib/rapi/rlib2.py
222

    
223
http_PYTHON = \
224
	lib/http/__init__.py \
225
	lib/http/auth.py \
226
	lib/http/client.py \
227
	lib/http/server.py
228

    
229
confd_PYTHON = \
230
	lib/confd/__init__.py \
231
	lib/confd/client.py \
232
	lib/confd/querylib.py \
233
	lib/confd/server.py
234

    
235
masterd_PYTHON = \
236
	lib/masterd/__init__.py \
237
	lib/masterd/instance.py
238

    
239
impexpd_PYTHON = \
240
	lib/impexpd/__init__.py
241

    
242
watcher_PYTHON = \
243
	lib/watcher/__init__.py
244

    
245
server_PYTHON = \
246
	lib/server/__init__.py \
247
	lib/server/confd.py \
248
	lib/server/masterd.py \
249
	lib/server/noded.py \
250
	lib/server/rapi.py
251

    
252
pytools_PYTHON = \
253
	lib/tools/__init__.py \
254
	lib/tools/ensure_dirs.py
255

    
256
utils_PYTHON = \
257
	lib/utils/__init__.py \
258
	lib/utils/algo.py \
259
	lib/utils/filelock.py \
260
	lib/utils/hash.py \
261
	lib/utils/io.py \
262
	lib/utils/log.py \
263
	lib/utils/mlock.py \
264
	lib/utils/nodesetup.py \
265
	lib/utils/process.py \
266
	lib/utils/retry.py \
267
	lib/utils/text.py \
268
	lib/utils/wrapper.py \
269
	lib/utils/x509.py
270

    
271
docrst = \
272
	doc/admin.rst \
273
	doc/design-2.0.rst \
274
	doc/design-2.1.rst \
275
	doc/design-2.2.rst \
276
	doc/design-2.3.rst \
277
	doc/design-htools-2.3.rst \
278
	doc/design-2.4.rst \
279
	doc/design-draft.rst \
280
	doc/design-oob.rst \
281
	doc/design-cpu-pinning.rst \
282
	doc/design-query2.rst \
283
	doc/design-x509-ca.rst \
284
	doc/design-http-server.rst \
285
	doc/design-impexp2.rst \
286
	doc/design-lu-generated-jobs.rst \
287
	doc/design-multi-reloc.rst \
288
	doc/design-network.rst \
289
	doc/cluster-merge.rst \
290
	doc/design-shared-storage.rst \
291
	doc/devnotes.rst \
292
	doc/glossary.rst \
293
	doc/hooks.rst \
294
	doc/iallocator.rst \
295
	doc/index.rst \
296
	doc/install-quick.rst \
297
	doc/install.rst \
298
	doc/locking.rst \
299
	doc/move-instance.rst \
300
	doc/news.rst \
301
	doc/rapi.rst \
302
	doc/security.rst \
303
	doc/upgrade.rst \
304
	doc/walkthrough.rst
305

    
306
HS_PROGS = \
307
	htools/hbal \
308
	htools/hscan \
309
	htools/hail \
310
	htools/hspace
311

    
312
HS_ALL_PROGS = $(HS_PROGS) htools/test
313
HS_PROG_SRCS = $(patsubst %,%.hs,$(HS_ALL_PROGS))
314
# we don't add -Werror by default
315
HFLAGS = -O -Wall -fwarn-monomorphism-restriction -fwarn-tabs -ihtools
316
# extra flags that can be overriden on the command line
317
HEXTRA =
318
# exclude options for coverage reports
319
HPCEXCL = --exclude Main --exclude Ganeti.HTools.QC
320

    
321
HS_LIB_SRCS = \
322
	htools/Ganeti/HTools/CLI.hs \
323
	htools/Ganeti/HTools/Cluster.hs \
324
	htools/Ganeti/HTools/Container.hs \
325
	htools/Ganeti/HTools/ExtLoader.hs \
326
	htools/Ganeti/HTools/Group.hs \
327
	htools/Ganeti/HTools/IAlloc.hs \
328
	htools/Ganeti/HTools/Instance.hs \
329
	htools/Ganeti/HTools/Loader.hs \
330
	htools/Ganeti/HTools/Luxi.hs \
331
	htools/Ganeti/HTools/Node.hs \
332
	htools/Ganeti/HTools/PeerMap.hs \
333
	htools/Ganeti/HTools/QC.hs \
334
	htools/Ganeti/HTools/Rapi.hs \
335
	htools/Ganeti/HTools/Simu.hs \
336
	htools/Ganeti/HTools/Text.hs \
337
	htools/Ganeti/HTools/Types.hs \
338
	htools/Ganeti/HTools/Utils.hs \
339
	htools/Ganeti/Jobs.hs \
340
	htools/Ganeti/Luxi.hs \
341
	htools/Ganeti/OpCodes.hs
342

    
343
HS_BUILT_SRCS = htools/Ganeti/HTools/Version.hs htools/Ganeti/Constants.hs
344
HS_BUILT_SRCS_IN = $(patsubst %,%.in,$(HS_BUILT_SRCS))
345

    
346
$(RUN_IN_TEMPDIR): | $(all_dirfiles)
347

    
348
# Note: we use here an order-only prerequisite, as the contents of
349
# _autoconf.py are not actually influencing the html build output: it
350
# has to exist in order for the sphinx module to be loaded
351
# successfully, but we certainly don't want the docs to be rebuilt if
352
# it changes
353
doc/html/index.html: $(docrst) $(docpng) doc/conf.py configure.ac \
354
	$(RUN_IN_TEMPDIR) lib/build/sphinx_ext.py lib/opcodes.py lib/ht.py \
355
	| lib/_autoconf.py
356
	@test -n "$(SPHINX)" || \
357
	    { echo 'sphinx-build' not found during configure; exit 1; }
358
	@mkdir_p@ $(dir $@)
359
	PYTHONPATH=. $(RUN_IN_TEMPDIR) $(SPHINX) -q -W -b html \
360
	    -d . \
361
	    -D version="$(VERSION_MAJOR).$(VERSION_MINOR)" \
362
	    -D release="$(PACKAGE_VERSION)" \
363
	    $(abs_top_srcdir)/doc $(CURDIR)/doc/html
364
	rm -f doc/html/.buildinfo doc/html/objects.inv
365
	touch $@
366

    
367
doc/html: doc/html/index.html
368

    
369
doc/install-quick.rst: INSTALL
370
doc/news.rst: NEWS
371
doc/upgrade.rst: UPGRADE
372

    
373
doc/install-quick.rst doc/news.rst doc/upgrade.rst:
374
	set -e; \
375
	{ echo '.. This file is automatically updated at build time from $<.'; \
376
	  echo '.. Do not edit.'; \
377
	  echo; \
378
	  cat $<; \
379
	} > $@
380

    
381
docdot = \
382
	doc/arch-2.0.dot \
383
	doc/design-2.1-lock-acquire.dot \
384
	doc/design-2.1-lock-release.dot
385

    
386
docpng = $(patsubst %.dot,%.png,$(docdot))
387

    
388
# Things to build but not to install (add it to EXTRA_DIST if it should be
389
# distributed)
390
noinst_DATA = \
391
	devel/upload \
392
	doc/html \
393
	doc/examples/bash_completion \
394
	doc/examples/ganeti.cron \
395
	doc/examples/ganeti.initd \
396
	doc/examples/ganeti-kvm-poweroff.initd \
397
	doc/examples/gnt-config-backup \
398
	doc/examples/hooks/ipsec \
399
	$(manhtml)
400

    
401
gnt_scripts = \
402
	scripts/gnt-backup \
403
	scripts/gnt-cluster \
404
	scripts/gnt-debug \
405
	scripts/gnt-group \
406
	scripts/gnt-instance \
407
	scripts/gnt-job \
408
	scripts/gnt-node \
409
	scripts/gnt-os
410

    
411
PYTHON_BOOTSTRAP_SBIN = \
412
	daemons/ganeti-confd \
413
	daemons/ganeti-masterd \
414
	daemons/ganeti-noded \
415
	daemons/ganeti-watcher \
416
	daemons/ganeti-rapi \
417
	scripts/gnt-backup \
418
	scripts/gnt-cluster \
419
	scripts/gnt-debug \
420
	scripts/gnt-group \
421
	scripts/gnt-instance \
422
	scripts/gnt-job \
423
	scripts/gnt-node \
424
	scripts/gnt-os
425

    
426
PYTHON_BOOTSTRAP = \
427
	$(PYTHON_BOOTSTRAP_SBIN) \
428
	tools/ensure-dirs
429

    
430
qa_scripts = \
431
	qa/ganeti-qa.py \
432
	qa/qa_cluster.py \
433
	qa/qa_config.py \
434
	qa/qa_daemon.py \
435
	qa/qa_env.py \
436
	qa/qa_error.py \
437
	qa/qa_instance.py \
438
	qa/qa_node.py \
439
	qa/qa_os.py \
440
	qa/qa_rapi.py \
441
	qa/qa_tags.py \
442
	qa/qa_utils.py
443

    
444
bin_SCRIPTS =
445
iallocators_SCRIPTS =
446
if WANT_HTOOLS
447
bin_SCRIPTS += $(filter-out htools/hail,$(HS_PROGS))
448
iallocators_SCRIPTS += $(filter htools/hail,$(HS_PROGS))
449
endif
450

    
451
$(HS_ALL_PROGS): %: %.hs $(HS_LIB_SRCS) $(HS_BUILT_SRCS) Makefile
452
	@if [ -z "$(HTOOLS)" ]; then \
453
	  echo "Error: htools compilation disabled at configure time" 1>&2 ;\
454
	  exit 1; \
455
	fi
456
	@BINARY=$(@:htools/%=%); \
457
	if [ "$BINARY" = "test" ] && [ -z "$(GHC_PKG_QUICKCHECK)" ]; then \
458
	  echo "Error: cannot run unittests without the QuickCheck library (see devnotes.rst)" 1>&2; \
459
	  exit 1; \
460
	fi
461
	BINARY=$(@:htools/%=%); $(GHC) --make \
462
	  $(HFLAGS) $(HEXTRA) $(HTOOLS_NOCURL) \
463
	  -osuf $$BINARY.o -hisuf $$BINARY.hi $@
464

    
465
# for the htools/test binary, we need to enable profiling/coverage
466
htools/test: HEXTRA=-fhpc -Wwarn -fno-warn-missing-signatures \
467
	-fno-warn-monomorphism-restriction -fno-warn-orphans \
468
	-fno-warn-missing-methods -fno-warn-unused-imports
469

    
470
dist_sbin_SCRIPTS = \
471
	tools/ganeti-listrunner
472

    
473
nodist_sbin_SCRIPTS = \
474
	$(PYTHON_BOOTSTRAP_SBIN) \
475
	daemons/ganeti-cleaner
476

    
477
dist_tools_SCRIPTS = \
478
	tools/burnin \
479
	tools/cfgshell \
480
	tools/cfgupgrade \
481
	tools/cfgupgrade12 \
482
	tools/cluster-merge \
483
	tools/lvmstrap \
484
	tools/move-instance \
485
	tools/setup-ssh \
486
	tools/sanitize-config
487

    
488
pkglib_python_scripts = \
489
	daemons/import-export \
490
	tools/check-cert-expired
491

    
492
nodist_pkglib_python_scripts = \
493
	tools/ensure-dirs
494

    
495
pkglib_SCRIPTS = \
496
	daemons/daemon-util \
497
	tools/kvm-ifup \
498
	tools/xm-console-wrapper \
499
	$(pkglib_python_scripts)
500

    
501
nodist_pkglib_SCRIPTS = \
502
	$(nodist_pkglib_python_scripts)
503

    
504
EXTRA_DIST = \
505
	NEWS \
506
	UPGRADE \
507
	epydoc.conf.in \
508
	pylintrc \
509
	autotools/build-bash-completion \
510
	autotools/check-python-code \
511
	autotools/check-man \
512
	autotools/check-news \
513
	autotools/check-tar \
514
	autotools/check-version \
515
	autotools/convert-constants \
516
	autotools/docpp \
517
	autotools/gen-coverage \
518
	autotools/testrunner \
519
	$(RUN_IN_TEMPDIR) \
520
	daemons/daemon-util.in \
521
	daemons/ganeti-cleaner.in \
522
	$(pkglib_python_scripts) \
523
	devel/upload.in \
524
	tools/kvm-ifup.in \
525
	$(docdot) \
526
	$(docpng) \
527
	$(docrst) \
528
	doc/conf.py \
529
	doc/html \
530
	doc/examples/ganeti.initd.in \
531
	doc/examples/ganeti-kvm-poweroff.initd.in \
532
	doc/examples/ganeti.cron.in \
533
	doc/examples/gnt-config-backup.in \
534
	doc/examples/ganeti.default \
535
	doc/examples/ganeti.default-debug \
536
	doc/examples/hooks/ethers \
537
	doc/examples/hooks/ipsec.in \
538
	doc/examples/gnt-debug/README \
539
	doc/examples/gnt-debug/delay0.json \
540
	doc/examples/gnt-debug/delay50.json \
541
	test/testutils.py \
542
	test/mocks.py \
543
	$(dist_TESTS) \
544
	$(TEST_FILES) \
545
	man/footer.rst \
546
	$(manrst) \
547
	$(maninput) \
548
	qa/qa-sample.json \
549
	$(qa_scripts) \
550
	$(HS_LIB_SRCS) $(HS_BUILT_SRCS_IN) \
551
	$(HS_PROG_SRCS)
552

    
553
man_MANS = \
554
	man/ganeti.7 \
555
	man/ganeti-cleaner.8 \
556
	man/ganeti-confd.8 \
557
	man/ganeti-listrunner.8 \
558
	man/ganeti-masterd.8 \
559
	man/ganeti-noded.8 \
560
	man/ganeti-os-interface.7 \
561
	man/ganeti-rapi.8 \
562
	man/ganeti-watcher.8 \
563
	man/gnt-backup.8 \
564
	man/gnt-cluster.8 \
565
	man/gnt-debug.8 \
566
	man/gnt-group.8 \
567
	man/gnt-instance.8 \
568
	man/gnt-job.8 \
569
	man/gnt-node.8 \
570
	man/gnt-os.8 \
571
	man/hail.1 \
572
	man/hbal.1 \
573
	man/hscan.1 \
574
	man/hspace.1
575

    
576
manrst = $(patsubst %.1,%.rst,$(patsubst %.7,%.rst,$(patsubst %.8,%.rst,$(man_MANS))))
577
manhtml = $(patsubst %.rst,%.html,$(manrst))
578
mangen = $(patsubst %.rst,%.gen,$(manrst))
579
maninput = \
580
	$(patsubst %.1,%.1.in,$(patsubst %.7,%.7.in,$(patsubst %.8,%.8.in,$(man_MANS)))) \
581
	$(patsubst %.html,%.html.in,$(manhtml)) \
582
	man/footer.man man/footer.html $(mangen)
583

    
584
TEST_FILES = \
585
	test/data/bdev-drbd-8.0.txt \
586
	test/data/bdev-drbd-8.3.txt \
587
	test/data/bdev-drbd-disk.txt \
588
	test/data/bdev-drbd-net-ip4.txt \
589
	test/data/bdev-drbd-net-ip6.txt \
590
	test/data/cert1.pem \
591
	test/data/proc_drbd8.txt \
592
	test/data/proc_drbd80-emptyline.txt \
593
	test/data/proc_drbd83.txt \
594
	test/data/sys_drbd_usermode_helper.txt \
595
	test/import-export_unittest-helper
596

    
597
python_tests = \
598
	test/ganeti.asyncnotifier_unittest.py \
599
	test/ganeti.backend_unittest.py \
600
	test/ganeti.bdev_unittest.py \
601
	test/ganeti.cli_unittest.py \
602
	test/ganeti.client.gnt_cluster_unittest.py \
603
	test/ganeti.client.gnt_instance_unittest.py \
604
	test/ganeti.daemon_unittest.py \
605
	test/ganeti.cmdlib_unittest.py \
606
	test/ganeti.compat_unittest.py \
607
	test/ganeti.confd.client_unittest.py \
608
	test/ganeti.config_unittest.py \
609
	test/ganeti.constants_unittest.py \
610
	test/ganeti.errors_unittest.py \
611
	test/ganeti.hooks_unittest.py \
612
	test/ganeti.ht_unittest.py \
613
	test/ganeti.http_unittest.py \
614
	test/ganeti.hypervisor_unittest.py \
615
	test/ganeti.hypervisor.hv_chroot_unittest.py \
616
	test/ganeti.hypervisor.hv_fake_unittest.py \
617
	test/ganeti.hypervisor.hv_kvm_unittest.py \
618
	test/ganeti.hypervisor.hv_lxc_unittest.py \
619
	test/ganeti.hypervisor.hv_xen_unittest.py \
620
	test/ganeti.impexpd_unittest.py \
621
	test/ganeti.jqueue_unittest.py \
622
	test/ganeti.locking_unittest.py \
623
	test/ganeti.luxi_unittest.py \
624
	test/ganeti.masterd.instance_unittest.py \
625
	test/ganeti.mcpu_unittest.py \
626
	test/ganeti.netutils_unittest.py \
627
	test/ganeti.objects_unittest.py \
628
	test/ganeti.opcodes_unittest.py \
629
	test/ganeti.qlang_unittest.py \
630
	test/ganeti.query_unittest.py \
631
	test/ganeti.rapi.baserlib_unittest.py \
632
	test/ganeti.rapi.client_unittest.py \
633
	test/ganeti.rapi.resources_unittest.py \
634
	test/ganeti.rapi.rlib2_unittest.py \
635
	test/ganeti.rpc_unittest.py \
636
	test/ganeti.runtime_unittest.py \
637
	test/ganeti.serializer_unittest.py \
638
	test/ganeti.ssh_unittest.py \
639
	test/ganeti.tools.ensure_dirs_unittest.py \
640
	test/ganeti.uidpool_unittest.py \
641
	test/ganeti.utils.algo_unittest.py \
642
	test/ganeti.utils.filelock_unittest.py \
643
	test/ganeti.utils.hash_unittest.py \
644
	test/ganeti.utils.io_unittest.py \
645
	test/ganeti.utils.log_unittest.py \
646
	test/ganeti.utils.mlock_unittest.py \
647
	test/ganeti.utils.nodesetup_unittest.py \
648
	test/ganeti.utils.process_unittest.py \
649
	test/ganeti.utils.retry_unittest.py \
650
	test/ganeti.utils.text_unittest.py \
651
	test/ganeti.utils.wrapper_unittest.py \
652
	test/ganeti.utils.x509_unittest.py \
653
	test/ganeti.utils_unittest.py \
654
	test/ganeti.workerpool_unittest.py \
655
	test/cfgupgrade_unittest.py \
656
	test/docs_unittest.py \
657
	test/tempfile_fork_unittest.py
658

    
659
haskell_tests = htools/test
660

    
661
dist_TESTS = \
662
	test/check-cert-expired_unittest.bash \
663
	test/daemon-util_unittest.bash \
664
	test/ganeti-cleaner_unittest.bash \
665
	test/import-export_unittest.bash \
666
	$(python_tests)
667

    
668
nodist_TESTS =
669
if WANT_HTOOLSTESTS
670
nodist_TESTS += $(haskell_tests)
671
endif
672

    
673
TESTS = $(dist_TESTS) $(nodist_TESTS)
674

    
675
# Environment for all tests
676
PLAIN_TESTS_ENVIRONMENT = \
677
	PYTHONPATH=. TOP_SRCDIR=$(abs_top_srcdir) PYTHON=$(PYTHON) $(RUN_IN_TEMPDIR)
678

    
679
# Environment for tests run by automake
680
TESTS_ENVIRONMENT = \
681
	$(PLAIN_TESTS_ENVIRONMENT) $(abs_top_srcdir)/autotools/testrunner
682

    
683
all_python_code = \
684
	$(dist_sbin_SCRIPTS) \
685
	$(dist_tools_SCRIPTS) \
686
	$(pkglib_python_scripts) \
687
	$(nodist_pkglib_python_scripts) \
688
	$(python_tests) \
689
	$(pkgpython_PYTHON) \
690
	$(client_PYTHON) \
691
	$(hypervisor_PYTHON) \
692
	$(rapi_PYTHON) \
693
	$(server_PYTHON) \
694
	$(pytools_PYTHON) \
695
	$(http_PYTHON) \
696
	$(confd_PYTHON) \
697
	$(masterd_PYTHON) \
698
	$(impexpd_PYTHON) \
699
	$(utils_PYTHON) \
700
	$(watcher_PYTHON) \
701
	$(noinst_PYTHON) \
702
	$(qa_scripts)
703

    
704
srclink_files = \
705
	man/footer.rst \
706
	test/check-cert-expired_unittest.bash \
707
	test/daemon-util_unittest.bash \
708
	test/ganeti-cleaner_unittest.bash \
709
	test/import-export_unittest.bash \
710
	$(all_python_code) \
711
	$(HS_LIB_SRCS) $(HS_PROG_SRCS)
712

    
713
check_python_code = \
714
	$(BUILD_BASH_COMPLETION) \
715
	$(DOCPP) \
716
	$(all_python_code)
717

    
718
lint_python_code = \
719
	ganeti \
720
	ganeti/http/server.py \
721
	$(dist_sbin_SCRIPTS) \
722
	$(dist_tools_SCRIPTS) \
723
	$(pkglib_python_scripts) \
724
	$(BUILD_BASH_COMPLETION) \
725
	$(DOCPP) \
726
	$(PYTHON_BOOTSTRAP)
727

    
728
test/daemon-util_unittest.bash: daemons/daemon-util
729

    
730
test/ganeti-cleaner_unittest.bash: daemons/ganeti-cleaner
731

    
732
tools/kvm-ifup: tools/kvm-ifup.in $(REPLACE_VARS_SED)
733
	sed -f $(REPLACE_VARS_SED) < $< > $@
734
	chmod +x $@
735

    
736
devel/upload: devel/upload.in $(REPLACE_VARS_SED)
737
	sed -f $(REPLACE_VARS_SED) < $< > $@
738
	chmod u+x $@
739

    
740
daemons/%: daemons/%.in $(REPLACE_VARS_SED)
741
	sed -f $(REPLACE_VARS_SED) < $< > $@
742
	chmod +x $@
743

    
744
doc/examples/%: doc/examples/%.in $(REPLACE_VARS_SED)
745
	sed -f $(REPLACE_VARS_SED) < $< > $@
746

    
747
doc/examples/hooks/%: doc/examples/hooks/%.in $(REPLACE_VARS_SED)
748
	sed -f $(REPLACE_VARS_SED) < $< > $@
749

    
750
doc/examples/bash_completion: $(BUILD_BASH_COMPLETION) $(RUN_IN_TEMPDIR) \
751
	lib/cli.py $(gnt_scripts) $(client_PYTHON) tools/burnin
752
	PYTHONPATH=. $(RUN_IN_TEMPDIR) $(CURDIR)/$(BUILD_BASH_COMPLETION) > $@
753

    
754
doc/%.png: doc/%.dot
755
	@test -n "$(DOT)" || { echo 'dot' not found during configure; exit 1; }
756
	$(DOT) -Tpng -o $@ $<
757

    
758
man/footer.man: man/footer.rst
759
	@test -n "$(PANDOC)" || \
760
	  { echo 'pandoc' not found during configure; exit 1; }
761
	$(PANDOC) -f rst -t man -o $@ $<
762

    
763
man/footer.html: man/footer.rst
764
	@test -n "$(PANDOC)" || \
765
	  { echo 'pandoc' not found during configure; exit 1; }
766
	$(PANDOC) -f rst -t html -o $@ $<
767

    
768
man/%.gen: man/%.rst lib/query.py lib/build/sphinx_ext.py
769
	PYTHONPATH=. $(RUN_IN_TEMPDIR) $(CURDIR)/$(DOCPP) < $< > $@
770

    
771
man/%.7.in man/%.8.in man/%.1.in: man/%.gen man/footer.man
772
	@test -n "$(PANDOC)" || \
773
	  { echo 'pandoc' not found during configure; exit 1; }
774
	set -o pipefail ; \
775
	$(PANDOC) -s -f rst -t man -A man/footer.man $< | \
776
	  sed -e 's/\\@/@/g' > $@
777
	if test -n "$(MAN_HAS_WARNINGS)"; then $(CHECK_MAN) $@; fi
778

    
779
man/%.html.in: man/%.gen man/footer.html
780
	@test -n "$(PANDOC)" || \
781
	  { echo 'pandoc' not found during configure; exit 1; }
782
	set -o pipefail ; \
783
	$(PANDOC) -s -f rst -t html -A man/footer.html $< | \
784
	  sed -e 's/\\@/@/g' > $@
785

    
786
man/%.1: man/%.1.in $(REPLACE_VARS_SED)
787
	sed -f $(REPLACE_VARS_SED) < $< > $@
788

    
789
man/%.7: man/%.7.in $(REPLACE_VARS_SED)
790
	sed -f $(REPLACE_VARS_SED) < $< > $@
791

    
792
man/%.8: man/%.8.in $(REPLACE_VARS_SED)
793
	sed -f $(REPLACE_VARS_SED) < $< > $@
794

    
795
man/%.html: man/%.html.in $(REPLACE_VARS_SED)
796
	sed -f $(REPLACE_VARS_SED) < $< > $@
797

    
798
epydoc.conf: epydoc.conf.in Makefile
799
	sed -e 's#@MODULES@#$(strip $(lint_python_code))#g' < $< > $@
800

    
801
vcs-version:
802
	if test -d .git; then \
803
	  git describe > $@; \
804
	elif test ! -f $@ ; then \
805
	  echo "Cannot auto-generate $@ file"; exit 1; \
806
	fi
807

    
808
.PHONY: regen-vcs-version
809
regen-vcs-version:
810
	set -e; \
811
	cd $(srcdir); \
812
	if test -d .git; then \
813
	  rm -f vcs-version; \
814
	  $(MAKE) vcs-version; \
815
	fi
816

    
817
htools/Ganeti/HTools/Version.hs: htools/Ganeti/HTools/Version.hs.in vcs-version
818
	set -e; \
819
	VCSVER=`cat $(abs_top_srcdir)/vcs-version`; \
820
	sed -e "s/%ver%/$$VCSVER/" < $< > $@
821

    
822
htools/Ganeti/Constants.hs: htools/Ganeti/Constants.hs.in \
823
	lib/constants.py lib/_autoconf.py $(CONVERT_CONSTANTS)
824
	set -e; \
825
	{ cat $< ; PYTHONPATH=. $(CONVERT_CONSTANTS); } > $@
826

    
827
lib/_autoconf.py: Makefile vcs-version | lib/.dir
828
	set -e; \
829
	VCSVER=`cat $(abs_top_srcdir)/vcs-version`; \
830
	{ echo '# This file is automatically generated, do not edit!'; \
831
	  echo '#'; \
832
	  echo ''; \
833
	  echo '"""Build-time configuration for Ganeti.'; \
834
	  echo '';\
835
	  echo 'This file is autogenerated by the build process.'; \
836
	  echo 'For any changes you need to re-run ./configure (and'; \
837
	  echo 'not edit by hand).'; \
838
	  echo ''; \
839
	  echo '"""'; \
840
	  echo ''; \
841
	  echo '# pylint: disable-msg=C0301,C0324'; \
842
	  echo '# because this is autogenerated, we do not want'; \
843
	  echo '# style warnings' ; \
844
	  echo ''; \
845
	  echo "PACKAGE_VERSION = '$(PACKAGE_VERSION)'"; \
846
	  echo "VERSION_MAJOR = '$(VERSION_MAJOR)'"; \
847
	  echo "VERSION_MINOR = '$(VERSION_MINOR)'"; \
848
	  echo "VERSION_REVISION = '$(VERSION_REVISION)'"; \
849
	  echo "VERSION_SUFFIX = '$(VERSION_SUFFIX)'"; \
850
	  echo "VERSION_FULL = '$(VERSION_FULL)'"; \
851
	  echo "LOCALSTATEDIR = '$(localstatedir)'"; \
852
	  echo "SYSCONFDIR = '$(sysconfdir)'"; \
853
	  echo "SSH_CONFIG_DIR = '$(SSH_CONFIG_DIR)'"; \
854
	  echo "EXPORT_DIR = '$(EXPORT_DIR)'"; \
855
	  echo "OS_SEARCH_PATH = [$(OS_SEARCH_PATH)]"; \
856
	  echo "XEN_BOOTLOADER = '$(XEN_BOOTLOADER)'"; \
857
	  echo "XEN_KERNEL = '$(XEN_KERNEL)'"; \
858
	  echo "XEN_INITRD = '$(XEN_INITRD)'"; \
859
	  echo "FILE_STORAGE_DIR = '$(FILE_STORAGE_DIR)'"; \
860
	  echo "ENABLE_FILE_STORAGE = $(ENABLE_FILE_STORAGE)"; \
861
	  echo "SHARED_FILE_STORAGE_DIR = '$(SHARED_FILE_STORAGE_DIR)'"; \
862
	  echo "ENABLE_SHARED_FILE_STORAGE = $(ENABLE_SHARED_FILE_STORAGE)"; \
863
	  echo "IALLOCATOR_SEARCH_PATH = [$(IALLOCATOR_SEARCH_PATH)]"; \
864
	  echo "KVM_PATH = '$(KVM_PATH)'"; \
865
	  echo "SOCAT_PATH = '$(SOCAT)'"; \
866
	  echo "SOCAT_USE_ESCAPE = $(SOCAT_USE_ESCAPE)"; \
867
	  echo "SOCAT_USE_COMPRESS = $(SOCAT_USE_COMPRESS)"; \
868
	  echo "LVM_STRIPECOUNT = $(LVM_STRIPECOUNT)"; \
869
	  echo "TOOLSDIR = '$(toolsdir)'"; \
870
	  echo "GNT_SCRIPTS = [$(foreach i,$(notdir $(gnt_scripts)),'$(i)',)]"; \
871
	  echo "PKGLIBDIR = '$(pkglibdir)'"; \
872
	  echo "DRBD_BARRIERS = $(DRBD_BARRIERS)"; \
873
	  echo "SYSLOG_USAGE = '$(SYSLOG_USAGE)'"; \
874
	  echo "DAEMONS_GROUP = '$(DAEMONS_GROUP)'"; \
875
	  echo "ADMIN_GROUP = '$(ADMIN_GROUP)'"; \
876
	  echo "MASTERD_USER = '$(MASTERD_USER)'"; \
877
	  echo "MASTERD_GROUP = '$(MASTERD_GROUP)'"; \
878
	  echo "RAPI_USER = '$(RAPI_USER)'"; \
879
	  echo "RAPI_GROUP = '$(RAPI_GROUP)'"; \
880
	  echo "CONFD_USER = '$(CONFD_USER)'"; \
881
	  echo "CONFD_GROUP = '$(CONFD_GROUP)'"; \
882
	  echo "NODED_USER = '$(NODED_USER)'"; \
883
	  echo "NODED_GROUP = '$(NODED_GROUP)'"; \
884
	  echo "VCS_VERSION = '$$VCSVER'"; \
885
	  echo "DISK_SEPARATOR = '$(DISK_SEPARATOR)'"; \
886
	  if [ "$(HTOOLS)" ]; then \
887
	    echo "HTOOLS = True"; \
888
	  else \
889
	    echo "HTOOLS = False"; \
890
	  fi; \
891
	} > $@
892

    
893
$(REPLACE_VARS_SED): Makefile
894
	set -e; \
895
	{ echo 's#@PREFIX@#$(prefix)#g'; \
896
	  echo 's#@SYSCONFDIR@#$(sysconfdir)#g'; \
897
	  echo 's#@LOCALSTATEDIR@#$(localstatedir)#g'; \
898
	  echo 's#@BINDIR@#$(bindir)#g'; \
899
	  echo 's#@SBINDIR@#$(sbindir)#g'; \
900
	  echo 's#@GANETI_VERSION@#$(PACKAGE_VERSION)#g'; \
901
	  echo 's#@CUSTOM_XEN_BOOTLOADER@#$(XEN_BOOTLOADER)#g'; \
902
	  echo 's#@CUSTOM_XEN_KERNEL@#$(XEN_KERNEL)#g'; \
903
	  echo 's#@CUSTOM_XEN_INITRD@#$(XEN_INITRD)#g'; \
904
	  echo 's#@CUSTOM_IALLOCATOR_SEARCH_PATH@#$(IALLOCATOR_SEARCH_PATH)#g'; \
905
	  echo 's#@CUSTOM_EXPORT_DIR@#$(EXPORT_DIR)#g'; \
906
	  echo 's#@RPL_FILE_STORAGE_DIR@#$(FILE_STORAGE_DIR)#g'; \
907
	  echo 's#@RPL_SSH_INITD_SCRIPT@#$(SSH_INITD_SCRIPT)#g'; \
908
	  echo 's#@PKGLIBDIR@#$(pkglibdir)#g'; \
909
	  echo 's#@GNTMASTERUSER@#$(MASTERD_USER)#g'; \
910
	  echo 's#@GNTRAPIUSER@#$(RAPI_USER)#g'; \
911
	  echo 's#@GNTCONFDUSER@#$(CONFD_USER)#g'; \
912
	  echo 's#@GNTNODEDUSER@#$(NODED_USER)#g'; \
913
	  echo 's#@GNTRAPIGROUP@#$(RAPI_GROUP)#g'; \
914
	  echo 's#@GNTADMINGROUP@#$(ADMIN_GROUP)#g'; \
915
	  echo 's#@GNTCONFDGROUP@#$(CONFD_GROUP)#g'; \
916
	  echo 's#@GNTMASTERDGROUP@#$(MASTERD_GROUP)#g'; \
917
	  echo 's#@GNTDAEMONSGROUP@#$(DAEMONS_GROUP)#g'; \
918
	} > $@
919

    
920
# Using deferred evaluation
921
daemons/ganeti-%: MODULE = ganeti.server.$(patsubst ganeti-%,%,$(notdir $@))
922
daemons/ganeti-watcher: MODULE = ganeti.watcher
923
scripts/%: MODULE = ganeti.client.$(subst -,_,$(notdir $@))
924
tools/ensure-dirs: MODULE = ganeti.tools.ensure_dirs
925

    
926
$(PYTHON_BOOTSTRAP): Makefile | $(all_dirfiles)
927
	test -n "$(MODULE)" || { echo Missing module; exit 1; }
928
	set -e; \
929
	{ echo '#!/usr/bin/python'; \
930
	  echo '# This file is automatically generated, do not edit!'; \
931
	  echo "# Edit $(MODULE) instead."; \
932
	  echo; \
933
	  echo '"""Bootstrap script for L{$(MODULE)}"""'; \
934
	  echo; \
935
	  echo '# pylint: disable-msg=C0103'; \
936
	  echo '# C0103: Invalid name'; \
937
	  echo; \
938
	  echo 'import sys'; \
939
	  echo 'import $(MODULE) as main'; \
940
	  echo; \
941
	  echo '# Temporarily alias commands until bash completion'; \
942
	  echo '# generator is changed'; \
943
	  echo 'if hasattr(main, "commands"):'; \
944
		echo '  commands = main.commands # pylint: disable-msg=E1101'; \
945
	  echo; \
946
	  echo 'if __name__ == "__main__":'; \
947
	  echo '  sys.exit(main.Main())'; \
948
	} > $@
949
	chmod u+x $@
950

    
951
# We need to create symlinks because "make distcheck" will not install Python
952
# files when building.
953
stamp-srclinks: Makefile | $(all_dirfiles)
954
	set -e; \
955
	for i in $(srclink_files); do \
956
		if test ! -f $$i -a -f $(abs_top_srcdir)/$$i; then \
957
			$(LN_S) $(abs_top_srcdir)/$$i $$i; \
958
		fi; \
959
	done
960
	touch $@
961

    
962
.PHONY: ganeti
963
ganeti:
964
	cd $(top_builddir) && test -h "$@" || { rm -f $@ && $(LN_S) lib $@; }
965

    
966
.PHONY: check-dirs
967
check-dirs: $(BUILT_SOURCES)
968
	@set -e; \
969
	find . -type d \( \( -name . \) -o \( \
970
		-name .git -o \
971
		-name autom4te.cache \
972
		\) -prune -o -print \) | { \
973
		error=; \
974
		while read dir; do \
975
			case "$$dir" in \
976
				$(strip $(patsubst %,(./%) ;;,$(DIRCHECK_EXCLUDE) $(DIRS))) \
977
				*) error=1; echo "Directory $$dir not listed in Makefile" >&2 ;; \
978
			esac; \
979
		done; \
980
		for dir in $(DIRS); do \
981
			if ! test -d "$$dir"; then \
982
				echo "Directory $$dir listed in DIRS does not exist" >&2; \
983
				error=1; \
984
			fi \
985
		done; \
986
		if test -n "$$error"; then exit 1; else exit 0; fi; \
987
	}
988

    
989
check-local: check-dirs
990
	$(CHECK_PYTHON_CODE) $(check_python_code)
991
	$(CHECK_VERSION) $(VERSION) $(top_srcdir)/NEWS
992
	$(CHECK_NEWS) < $(top_srcdir)/NEWS
993
	expver=$(VERSION_MAJOR).$(VERSION_MINOR); \
994
	if test "`head -n 1 $(top_srcdir)/README`" != "Ganeti $$expver"; then \
995
		echo "Incorrect version in README, expected $$expver"; \
996
		exit 1; \
997
	fi; \
998
	if test "`sed -ne '4 p' $(top_srcdir)/doc/iallocator.rst`" != \
999
					"Documents Ganeti version $$expver"; then \
1000
		echo "Incorrect version in iallocator.rst, expected $$expver"; \
1001
		exit 1; \
1002
	fi
1003

    
1004
.PHONY: hs-check
1005
hs-check: htools/test
1006
	@rm -f test.tix
1007
	./htools/test
1008

    
1009
.PHONY: lint
1010
lint: $(BUILT_SOURCES)
1011
	@test -n "$(PYLINT)" || { echo 'pylint' not found during configure; exit 1; }
1012
	$(PYLINT) $(LINT_OPTS) $(lint_python_code)
1013
	cd $(top_srcdir)/qa && \
1014
	  PYTHONPATH=$(abs_top_srcdir) $(PYLINT) $(LINT_OPTS) \
1015
	  --rcfile  ../pylintrc $(patsubst qa/%.py,%,$(qa_scripts))
1016

    
1017
.PHONY: hlint
1018
hlint: $(HS_BUILT_SRCS)
1019
	if tty -s; then C="-c"; else C=""; fi; \
1020
	hlint --report=doc/hs-lint.html $$C htools
1021

    
1022
# a dist hook rule for updating the vcs-version file; this is
1023
# hardcoded due to where it needs to build the file...
1024
dist-hook:
1025
	$(MAKE) regen-vcs-version && \
1026
	rm -f $(top_distdir)/vcs-version && \
1027
	cp -p $(srcdir)/vcs-version $(top_distdir)
1028

    
1029
# a distcheck hook rule for catching revision control directories
1030
distcheck-hook:
1031
	if find $(top_distdir) -name .svn -or -name .git | grep .; then \
1032
		echo "Found revision control files in final archive." 1>&2; \
1033
		exit 1; \
1034
	fi
1035
	if find $(top_distdir) -name '*.py[co]' | grep .; then \
1036
		echo "Found Python byte code in final archive." 1>&2; \
1037
		exit 1; \
1038
	fi
1039
	if find $(top_distdir) -name '*~' | grep .; then \
1040
		echo "Found backup files in final archive." 1>&2; \
1041
		exit 1; \
1042
	fi
1043
# Empty files or directories should not be distributed. They can cause
1044
# unnecessary warnings for packagers. Directories used by automake during
1045
# distcheck must be excluded.
1046
	if find $(top_distdir) -empty -and -not \( \
1047
			-path $(top_distdir)/_build -or \
1048
			-path $(top_distdir)/_inst \) | grep .; then \
1049
		echo "Found empty files or directories in final archive." 1>&2; \
1050
		exit 1; \
1051
	fi
1052
	if test -n "$(BUILD_RELEASE)" && \
1053
	   grep -n -H -E '^\*.*unreleased' $(top_distdir)/NEWS; then \
1054
		echo "Found unreleased version in NEWS." >&2; \
1055
		exit 1; \
1056
	fi
1057

    
1058
# When building a release, stricter checks should be used
1059
distcheck-release dist-release: export BUILD_RELEASE = 1
1060
distcheck-release: distcheck
1061

    
1062
dist-release: dist
1063
	set -e; \
1064
	for i in $(DIST_ARCHIVES); do \
1065
		echo -n "Checking $$i ... "; \
1066
		autotools/check-tar < $$i; \
1067
		echo OK; \
1068
	done
1069

    
1070
install-exec-local:
1071
	@mkdir_p@ "$(DESTDIR)${localstatedir}/lib/ganeti" \
1072
	  "$(DESTDIR)${localstatedir}/log/ganeti" \
1073
	  "$(DESTDIR)${localstatedir}/run/ganeti"
1074

    
1075
# To avoid conflicts between directory names and other targets, a file inside
1076
# the directory is used to ensure its existence.
1077
%.dir:
1078
	@mkdir_p@ $* && touch $@
1079

    
1080
.PHONY: apidoc
1081
if WANT_HTOOLSAPIDOC
1082
apidoc: py-apidoc hs-apidoc
1083
else
1084
apidoc: py-apidoc
1085
endif
1086

    
1087
.PHONY: py-apidoc
1088
py-apidoc: epydoc.conf $(RUN_IN_TEMPDIR) $(BUILT_SOURCES)
1089
	$(RUN_IN_TEMPDIR) epydoc -v \
1090
		--conf $(CURDIR)/epydoc.conf \
1091
		--output $(CURDIR)/$(APIDOC_PY_DIR)
1092

    
1093
.PHONY: hs-apidoc
1094
hs-apidoc: $(HS_BUILT_SRCS)
1095
	@test -n "$(HSCOLOUR)" || \
1096
	    { echo 'HsColour' not found during configure; exit 1; }
1097
	@test -n "$(HADDOCK)" || \
1098
	    { echo 'haddock' not found during configure; exit 1; }
1099
	rm -rf $(APIDOC_HS_DIR)/*
1100
	@mkdir_p@ $(APIDOC_HS_DIR)/Ganeti/HTools
1101
	$(HSCOLOUR) -print-css > $(APIDOC_HS_DIR)/Ganeti/hscolour.css
1102
	ln -s ../hscolour.css $(APIDOC_HS_DIR)/Ganeti/HTools/hscolour.css
1103
	set -e ; \
1104
	cd htools; \
1105
	if [ "$(HTOOLS_NOCURL)" ]; \
1106
	then OPTGHC="--optghc=$(HTOOLS_NOCURL)"; \
1107
	else OPTGHC=""; \
1108
	fi; \
1109
	RELSRCS="$(HS_LIB_SRCS:htools/%=%)"; \
1110
	for file in $$RELSRCS; do \
1111
		hfile=`echo $$file|sed 's/\\.hs$$//'`.html; \
1112
		$(HSCOLOUR) -css -anchor $$file > ../$(APIDOC_HS_DIR)/$$hfile ; \
1113
	done ; \
1114
	$(HADDOCK) --odir ../$(APIDOC_HS_DIR) --html --ignore-all-exports -w \
1115
		-t ganeti-htools -p haddock-prologue \
1116
		--source-module="%{MODULE/.//}.html" \
1117
		--source-entity="%{MODULE/.//}.html#%{NAME}" \
1118
		$$OPTGHC \
1119
		$(filter-out Ganeti/HTools/ExtLoader.hs,$(HS_LIB_SRCS:htools/%=%))
1120

    
1121
.PHONY: TAGS
1122
TAGS: $(BUILT_SOURCES)
1123
	rm -f TAGS
1124
	find . -path './lib/*.py' -o -path './scripts/gnt-*' -o \
1125
	  -path './daemons/ganeti-*' -o -path './tools/*' -o \
1126
	  -path './qa/*.py' | \
1127
	  etags -l python -
1128

    
1129
.PHONY: coverage
1130
if WANT_HTOOLS
1131
coverage: py-coverage hs-coverage
1132
else
1133
coverage: py-coverage
1134
endif
1135

    
1136
.PHONY: py-coverage
1137
py-coverage: $(BUILT_SOURCES) $(python_tests)
1138
	set -e; \
1139
	COVERAGE_FILE=$(CURDIR)/$(COVERAGE_PY_DIR)/data \
1140
	TEXT_COVERAGE=$(CURDIR)/$(COVERAGE_PY_DIR)/report.txt \
1141
	HTML_COVERAGE=$(CURDIR)/$(COVERAGE_PY_DIR) \
1142
	$(PLAIN_TESTS_ENVIRONMENT) $(abs_top_srcdir)/autotools/gen-coverage \
1143
	$(python_tests)
1144

    
1145
.PHONY: hs-coverage
1146
hs-coverage: $(haskell_tests)
1147
	cd htools && rm -f *.tix *.mix && ./test
1148
	mkdir -p $(COVERAGE_HS_DIR)
1149
	hpc markup --destdir=$(COVERAGE_HS_DIR) htools/test $(HPCEXCL)
1150
	hpc report htools/test $(HPCEXCL)
1151
	ln -sf hpc_index.html $(COVERAGE_HS_DIR)/index.html
1152

    
1153
# Special "kind-of-QA" target for htools, needs special setup (all
1154
# tools compiled with -fhpc)
1155
.PHONY: live-test
1156
live-test: all
1157
	set -e ; \
1158
	cd htools; \
1159
	rm -f .hpc; ln -s ../.hpc .hpc; \
1160
	rm -f *.tix *.mix; \
1161
	./live-test.sh; \
1162
	hpc sum --union $(HPCEXCL) $(addsuffix .tix,$(HS_PROGS:htools/%=%)) \
1163
	  --output=live-test.tix ; \
1164
	@mkdir_p@ ../$(COVERAGE_HS_DIR) ; \
1165
	hpc markup --destdir=../$(COVERAGE_HS_DIR) live-test \
1166
		--srcdir=.. $(HPCEXCL) ; \
1167
	hpc report --srcdir=.. live-test $(HPCEXCL)
1168

    
1169
commit-check: distcheck lint apidoc
1170

    
1171
-include ./Makefile.local
1172

    
1173
# vim: set noet :