Statistics
| Branch: | Tag: | Revision:

root / Makefile.am @ 201b6c34

History | View | Annotate | Download (32.7 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
	htools/Ganeti/HTools/Program
51

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

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

    
92
BUILDTIME_DIRS = \
93
	$(BUILDTIME_DIR_AUTOCREATE) \
94
	doc/html
95

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

    
101
all_dirfiles = $(addsuffix /.dir,$(DIRS) $(BUILDTIME_DIR_AUTOCREATE))
102

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

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

    
119
maintainer-clean-local:
120
	rm -rf $(BUILDTIME_DIRS)
121

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

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

    
157
nodist_pkgpython_PYTHON = \
158
	lib/_autoconf.py
159

    
160
noinst_PYTHON = \
161
	lib/build/__init__.py \
162
	lib/build/sphinx_ext.py
163

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

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

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

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

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

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

    
237
masterd_PYTHON = \
238
	lib/masterd/__init__.py \
239
	lib/masterd/instance.py
240

    
241
impexpd_PYTHON = \
242
	lib/impexpd/__init__.py
243

    
244
watcher_PYTHON = \
245
	lib/watcher/__init__.py
246

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

    
254
pytools_PYTHON = \
255
	lib/tools/__init__.py \
256
	lib/tools/ensure_dirs.py
257

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

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

    
309
HS_PROGS = \
310
	htools/hscan \
311
	htools/hspace \
312
	htools/htools
313
HS_BIN_ROLES = hbal
314

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

    
326
HS_LIB_SRCS = \
327
	htools/Ganeti/HTools/CLI.hs \
328
	htools/Ganeti/HTools/Cluster.hs \
329
	htools/Ganeti/HTools/Compat.hs \
330
	htools/Ganeti/HTools/Container.hs \
331
	htools/Ganeti/HTools/ExtLoader.hs \
332
	htools/Ganeti/HTools/Group.hs \
333
	htools/Ganeti/HTools/IAlloc.hs \
334
	htools/Ganeti/HTools/Instance.hs \
335
	htools/Ganeti/HTools/Loader.hs \
336
	htools/Ganeti/HTools/Luxi.hs \
337
	htools/Ganeti/HTools/Node.hs \
338
	htools/Ganeti/HTools/PeerMap.hs \
339
	htools/Ganeti/HTools/QC.hs \
340
	htools/Ganeti/HTools/Rapi.hs \
341
	htools/Ganeti/HTools/Simu.hs \
342
	htools/Ganeti/HTools/Text.hs \
343
	htools/Ganeti/HTools/Types.hs \
344
	htools/Ganeti/HTools/Utils.hs \
345
	htools/Ganeti/HTools/Program/Hail.hs \
346
	htools/Ganeti/HTools/Program/Hbal.hs \
347
	htools/Ganeti/Jobs.hs \
348
	htools/Ganeti/Luxi.hs \
349
	htools/Ganeti/OpCodes.hs
350

    
351
HS_BUILT_SRCS = htools/Ganeti/HTools/Version.hs htools/Ganeti/Constants.hs
352
HS_BUILT_SRCS_IN = $(patsubst %,%.in,$(HS_BUILT_SRCS))
353

    
354
$(RUN_IN_TEMPDIR): | $(all_dirfiles)
355

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

    
375
doc/html: doc/html/index.html
376

    
377
doc/install-quick.rst: INSTALL
378
doc/news.rst: NEWS
379
doc/upgrade.rst: UPGRADE
380

    
381
doc/install-quick.rst doc/news.rst doc/upgrade.rst:
382
	set -e; \
383
	{ echo '.. This file is automatically updated at build time from $<.'; \
384
	  echo '.. Do not edit.'; \
385
	  echo; \
386
	  cat $<; \
387
	} > $@
388

    
389
docdot = \
390
	doc/arch-2.0.dot \
391
	doc/design-2.1-lock-acquire.dot \
392
	doc/design-2.1-lock-release.dot
393

    
394
docpng = $(patsubst %.dot,%.png,$(docdot))
395

    
396
# Things to build but not to install (add it to EXTRA_DIST if it should be
397
# distributed)
398
noinst_DATA = \
399
	devel/upload \
400
	doc/html \
401
	doc/examples/bash_completion \
402
	doc/examples/ganeti.cron \
403
	doc/examples/ganeti.initd \
404
	doc/examples/ganeti-kvm-poweroff.initd \
405
	doc/examples/gnt-config-backup \
406
	doc/examples/hooks/ipsec \
407
	$(manhtml)
408

    
409
gnt_scripts = \
410
	scripts/gnt-backup \
411
	scripts/gnt-cluster \
412
	scripts/gnt-debug \
413
	scripts/gnt-group \
414
	scripts/gnt-instance \
415
	scripts/gnt-job \
416
	scripts/gnt-node \
417
	scripts/gnt-os
418

    
419
PYTHON_BOOTSTRAP_SBIN = \
420
	daemons/ganeti-confd \
421
	daemons/ganeti-masterd \
422
	daemons/ganeti-noded \
423
	daemons/ganeti-watcher \
424
	daemons/ganeti-rapi \
425
	scripts/gnt-backup \
426
	scripts/gnt-cluster \
427
	scripts/gnt-debug \
428
	scripts/gnt-group \
429
	scripts/gnt-instance \
430
	scripts/gnt-job \
431
	scripts/gnt-node \
432
	scripts/gnt-os
433

    
434
PYTHON_BOOTSTRAP = \
435
	$(PYTHON_BOOTSTRAP_SBIN) \
436
	tools/ensure-dirs
437

    
438
qa_scripts = \
439
	qa/ganeti-qa.py \
440
	qa/qa_cluster.py \
441
	qa/qa_config.py \
442
	qa/qa_daemon.py \
443
	qa/qa_env.py \
444
	qa/qa_error.py \
445
	qa/qa_instance.py \
446
	qa/qa_node.py \
447
	qa/qa_os.py \
448
	qa/qa_rapi.py \
449
	qa/qa_tags.py \
450
	qa/qa_utils.py
451

    
452
bin_SCRIPTS =
453
if WANT_HTOOLS
454
bin_SCRIPTS += $(filter-out htools/hail,$(HS_PROGS))
455
install-exec-hook:
456
	@mkdir_p@ $(DESTDIR)$(iallocatorsdir)
457
	$(LN_S) -f $(DESTDIR)$(bindir)/htools \
458
		   $(DESTDIR)$(iallocatorsdir)/hail
459
	for role in $(HS_BIN_ROLES); do \
460
		$(LN_S) -f $(DESTDIR)$(bindir)/htools \
461
			   $(DESTDIR)$(bindir)/$$role ; \
462
	done
463
endif
464

    
465
$(HS_ALL_PROGS): %: %.hs $(HS_LIB_SRCS) $(HS_BUILT_SRCS) Makefile
466
	@if [ -z "$(HTOOLS)" ]; then \
467
	  echo "Error: htools compilation disabled at configure time" 1>&2 ;\
468
	  exit 1; \
469
	fi
470
	@BINARY=$(@:htools/%=%); \
471
	if [ "$BINARY" = "test" ] && [ -z "$(GHC_PKG_QUICKCHECK)" ]; then \
472
	  echo "Error: cannot run unittests without the QuickCheck library (see devnotes.rst)" 1>&2; \
473
	  exit 1; \
474
	fi
475
	BINARY=$(@:htools/%=%); $(GHC) --make \
476
	  $(HFLAGS) $(HEXTRA) \
477
	  $(HTOOLS_NOCURL) $(HTOOLS_PARALLEL3) \
478
	  -osuf $$BINARY.o -hisuf $$BINARY.hi $@
479

    
480
# for the htools/test binary, we need to enable profiling/coverage
481
htools/test: HEXTRA=-fhpc -Wwarn -fno-warn-missing-signatures \
482
	-fno-warn-monomorphism-restriction -fno-warn-orphans \
483
	-fno-warn-missing-methods -fno-warn-unused-imports
484

    
485
dist_sbin_SCRIPTS = \
486
	tools/ganeti-listrunner
487

    
488
nodist_sbin_SCRIPTS = \
489
	$(PYTHON_BOOTSTRAP_SBIN) \
490
	daemons/ganeti-cleaner
491

    
492
dist_tools_PYTHON = \
493
	tools/burnin \
494
	tools/cfgshell \
495
	tools/cfgupgrade \
496
	tools/cfgupgrade12 \
497
	tools/cluster-merge \
498
	tools/lvmstrap \
499
	tools/move-instance \
500
	tools/setup-ssh \
501
	tools/sanitize-config
502

    
503
dist_tools_SCRIPTS = \
504
	$(dist_tools_PYTHON) \
505
	tools/kvm-console-wrapper \
506
	tools/xm-console-wrapper
507

    
508
pkglib_python_scripts = \
509
	daemons/import-export \
510
	tools/check-cert-expired
511

    
512
nodist_pkglib_python_scripts = \
513
	tools/ensure-dirs
514

    
515
pkglib_SCRIPTS = \
516
	daemons/daemon-util \
517
	tools/kvm-ifup \
518
	$(pkglib_python_scripts)
519

    
520
nodist_pkglib_SCRIPTS = \
521
	$(nodist_pkglib_python_scripts)
522

    
523
EXTRA_DIST = \
524
	NEWS \
525
	UPGRADE \
526
	epydoc.conf.in \
527
	pylintrc \
528
	autotools/build-bash-completion \
529
	autotools/check-python-code \
530
	autotools/check-man \
531
	autotools/check-news \
532
	autotools/check-tar \
533
	autotools/check-version \
534
	autotools/convert-constants \
535
	autotools/docpp \
536
	autotools/gen-coverage \
537
	autotools/testrunner \
538
	$(RUN_IN_TEMPDIR) \
539
	daemons/daemon-util.in \
540
	daemons/ganeti-cleaner.in \
541
	$(pkglib_python_scripts) \
542
	devel/upload.in \
543
	tools/kvm-ifup.in \
544
	$(docdot) \
545
	$(docpng) \
546
	$(docrst) \
547
	doc/conf.py \
548
	doc/html \
549
	doc/examples/ganeti.initd.in \
550
	doc/examples/ganeti-kvm-poweroff.initd.in \
551
	doc/examples/ganeti.cron.in \
552
	doc/examples/gnt-config-backup.in \
553
	doc/examples/ganeti.default \
554
	doc/examples/ganeti.default-debug \
555
	doc/examples/hooks/ethers \
556
	doc/examples/hooks/ipsec.in \
557
	doc/examples/gnt-debug/README \
558
	doc/examples/gnt-debug/delay0.json \
559
	doc/examples/gnt-debug/delay50.json \
560
	test/testutils.py \
561
	test/mocks.py \
562
	$(dist_TESTS) \
563
	$(TEST_FILES) \
564
	man/footer.rst \
565
	$(manrst) \
566
	$(maninput) \
567
	qa/qa-sample.json \
568
	$(qa_scripts) \
569
	$(HS_LIB_SRCS) $(HS_BUILT_SRCS_IN) \
570
	$(HS_PROG_SRCS)
571

    
572
man_MANS = \
573
	man/ganeti.7 \
574
	man/ganeti-cleaner.8 \
575
	man/ganeti-confd.8 \
576
	man/ganeti-listrunner.8 \
577
	man/ganeti-masterd.8 \
578
	man/ganeti-noded.8 \
579
	man/ganeti-os-interface.7 \
580
	man/ganeti-rapi.8 \
581
	man/ganeti-watcher.8 \
582
	man/gnt-backup.8 \
583
	man/gnt-cluster.8 \
584
	man/gnt-debug.8 \
585
	man/gnt-group.8 \
586
	man/gnt-instance.8 \
587
	man/gnt-job.8 \
588
	man/gnt-node.8 \
589
	man/gnt-os.8 \
590
	man/hail.1 \
591
	man/hbal.1 \
592
	man/hscan.1 \
593
	man/hspace.1 \
594
	man/htools.1
595

    
596
manrst = $(patsubst %.1,%.rst,$(patsubst %.7,%.rst,$(patsubst %.8,%.rst,$(man_MANS))))
597
manhtml = $(patsubst %.rst,%.html,$(manrst))
598
mangen = $(patsubst %.rst,%.gen,$(manrst))
599
maninput = \
600
	$(patsubst %.1,%.1.in,$(patsubst %.7,%.7.in,$(patsubst %.8,%.8.in,$(man_MANS)))) \
601
	$(patsubst %.html,%.html.in,$(manhtml)) \
602
	man/footer.man man/footer.html $(mangen)
603

    
604
TEST_FILES = \
605
	test/data/bdev-drbd-8.0.txt \
606
	test/data/bdev-drbd-8.3.txt \
607
	test/data/bdev-drbd-disk.txt \
608
	test/data/bdev-drbd-net-ip4.txt \
609
	test/data/bdev-drbd-net-ip6.txt \
610
	test/data/cert1.pem \
611
	test/data/proc_drbd8.txt \
612
	test/data/proc_drbd80-emptyline.txt \
613
	test/data/proc_drbd83.txt \
614
	test/data/sys_drbd_usermode_helper.txt \
615
	test/import-export_unittest-helper
616

    
617
python_tests = \
618
	test/ganeti.asyncnotifier_unittest.py \
619
	test/ganeti.backend_unittest.py \
620
	test/ganeti.bdev_unittest.py \
621
	test/ganeti.cli_unittest.py \
622
	test/ganeti.client.gnt_cluster_unittest.py \
623
	test/ganeti.client.gnt_instance_unittest.py \
624
	test/ganeti.daemon_unittest.py \
625
	test/ganeti.cmdlib_unittest.py \
626
	test/ganeti.compat_unittest.py \
627
	test/ganeti.confd.client_unittest.py \
628
	test/ganeti.config_unittest.py \
629
	test/ganeti.constants_unittest.py \
630
	test/ganeti.errors_unittest.py \
631
	test/ganeti.hooks_unittest.py \
632
	test/ganeti.ht_unittest.py \
633
	test/ganeti.http_unittest.py \
634
	test/ganeti.hypervisor_unittest.py \
635
	test/ganeti.hypervisor.hv_chroot_unittest.py \
636
	test/ganeti.hypervisor.hv_fake_unittest.py \
637
	test/ganeti.hypervisor.hv_kvm_unittest.py \
638
	test/ganeti.hypervisor.hv_lxc_unittest.py \
639
	test/ganeti.hypervisor.hv_xen_unittest.py \
640
	test/ganeti.impexpd_unittest.py \
641
	test/ganeti.jqueue_unittest.py \
642
	test/ganeti.locking_unittest.py \
643
	test/ganeti.luxi_unittest.py \
644
	test/ganeti.masterd.instance_unittest.py \
645
	test/ganeti.mcpu_unittest.py \
646
	test/ganeti.netutils_unittest.py \
647
	test/ganeti.objects_unittest.py \
648
	test/ganeti.opcodes_unittest.py \
649
	test/ganeti.qlang_unittest.py \
650
	test/ganeti.query_unittest.py \
651
	test/ganeti.rapi.baserlib_unittest.py \
652
	test/ganeti.rapi.client_unittest.py \
653
	test/ganeti.rapi.resources_unittest.py \
654
	test/ganeti.rapi.rlib2_unittest.py \
655
	test/ganeti.rpc_unittest.py \
656
	test/ganeti.runtime_unittest.py \
657
	test/ganeti.serializer_unittest.py \
658
	test/ganeti.ssh_unittest.py \
659
	test/ganeti.tools.ensure_dirs_unittest.py \
660
	test/ganeti.uidpool_unittest.py \
661
	test/ganeti.utils.algo_unittest.py \
662
	test/ganeti.utils.filelock_unittest.py \
663
	test/ganeti.utils.hash_unittest.py \
664
	test/ganeti.utils.io_unittest.py \
665
	test/ganeti.utils.log_unittest.py \
666
	test/ganeti.utils.mlock_unittest.py \
667
	test/ganeti.utils.nodesetup_unittest.py \
668
	test/ganeti.utils.process_unittest.py \
669
	test/ganeti.utils.retry_unittest.py \
670
	test/ganeti.utils.text_unittest.py \
671
	test/ganeti.utils.wrapper_unittest.py \
672
	test/ganeti.utils.x509_unittest.py \
673
	test/ganeti.utils_unittest.py \
674
	test/ganeti.workerpool_unittest.py \
675
	test/cfgupgrade_unittest.py \
676
	test/docs_unittest.py \
677
	test/tempfile_fork_unittest.py
678

    
679
haskell_tests = htools/test
680

    
681
dist_TESTS = \
682
	test/check-cert-expired_unittest.bash \
683
	test/daemon-util_unittest.bash \
684
	test/ganeti-cleaner_unittest.bash \
685
	test/import-export_unittest.bash \
686
	$(python_tests)
687

    
688
nodist_TESTS =
689
if WANT_HTOOLSTESTS
690
nodist_TESTS += $(haskell_tests)
691
endif
692

    
693
TESTS = $(dist_TESTS) $(nodist_TESTS)
694

    
695
# Environment for all tests
696
PLAIN_TESTS_ENVIRONMENT = \
697
	PYTHONPATH=. TOP_SRCDIR=$(abs_top_srcdir) PYTHON=$(PYTHON) $(RUN_IN_TEMPDIR)
698

    
699
# Environment for tests run by automake
700
TESTS_ENVIRONMENT = \
701
	$(PLAIN_TESTS_ENVIRONMENT) $(abs_top_srcdir)/autotools/testrunner
702

    
703
all_python_code = \
704
	$(dist_sbin_SCRIPTS) \
705
	$(dist_tools_PYTHON) \
706
	$(pkglib_python_scripts) \
707
	$(nodist_pkglib_python_scripts) \
708
	$(python_tests) \
709
	$(pkgpython_PYTHON) \
710
	$(client_PYTHON) \
711
	$(hypervisor_PYTHON) \
712
	$(rapi_PYTHON) \
713
	$(server_PYTHON) \
714
	$(pytools_PYTHON) \
715
	$(http_PYTHON) \
716
	$(confd_PYTHON) \
717
	$(masterd_PYTHON) \
718
	$(impexpd_PYTHON) \
719
	$(utils_PYTHON) \
720
	$(watcher_PYTHON) \
721
	$(noinst_PYTHON) \
722
	$(qa_scripts)
723

    
724
srclink_files = \
725
	man/footer.rst \
726
	test/check-cert-expired_unittest.bash \
727
	test/daemon-util_unittest.bash \
728
	test/ganeti-cleaner_unittest.bash \
729
	test/import-export_unittest.bash \
730
	$(all_python_code) \
731
	$(HS_LIB_SRCS) $(HS_PROG_SRCS)
732

    
733
check_python_code = \
734
	$(BUILD_BASH_COMPLETION) \
735
	$(DOCPP) \
736
	$(all_python_code)
737

    
738
lint_python_code = \
739
	ganeti \
740
	ganeti/http/server.py \
741
	$(dist_sbin_SCRIPTS) \
742
	$(dist_tools_PYTHON) \
743
	$(pkglib_python_scripts) \
744
	$(BUILD_BASH_COMPLETION) \
745
	$(DOCPP) \
746
	$(PYTHON_BOOTSTRAP)
747

    
748
test/daemon-util_unittest.bash: daemons/daemon-util
749

    
750
test/ganeti-cleaner_unittest.bash: daemons/ganeti-cleaner
751

    
752
tools/kvm-ifup: tools/kvm-ifup.in $(REPLACE_VARS_SED)
753
	sed -f $(REPLACE_VARS_SED) < $< > $@
754
	chmod +x $@
755

    
756
devel/upload: devel/upload.in $(REPLACE_VARS_SED)
757
	sed -f $(REPLACE_VARS_SED) < $< > $@
758
	chmod u+x $@
759

    
760
daemons/%: daemons/%.in $(REPLACE_VARS_SED)
761
	sed -f $(REPLACE_VARS_SED) < $< > $@
762
	chmod +x $@
763

    
764
doc/examples/%: doc/examples/%.in $(REPLACE_VARS_SED)
765
	sed -f $(REPLACE_VARS_SED) < $< > $@
766

    
767
doc/examples/hooks/%: doc/examples/hooks/%.in $(REPLACE_VARS_SED)
768
	sed -f $(REPLACE_VARS_SED) < $< > $@
769

    
770
doc/examples/bash_completion: $(BUILD_BASH_COMPLETION) $(RUN_IN_TEMPDIR) \
771
	lib/cli.py $(gnt_scripts) $(client_PYTHON) tools/burnin
772
	PYTHONPATH=. $(RUN_IN_TEMPDIR) $(CURDIR)/$(BUILD_BASH_COMPLETION) > $@
773

    
774
doc/%.png: doc/%.dot
775
	@test -n "$(DOT)" || { echo 'dot' not found during configure; exit 1; }
776
	$(DOT) -Tpng -o $@ $<
777

    
778
man/footer.man: man/footer.rst
779
	@test -n "$(PANDOC)" || \
780
	  { echo 'pandoc' not found during configure; exit 1; }
781
	$(PANDOC) -f rst -t man -o $@ $<
782

    
783
man/footer.html: man/footer.rst
784
	@test -n "$(PANDOC)" || \
785
	  { echo 'pandoc' not found during configure; exit 1; }
786
	$(PANDOC) -f rst -t html -o $@ $<
787

    
788
man/%.gen: man/%.rst lib/query.py lib/build/sphinx_ext.py
789
	PYTHONPATH=. $(RUN_IN_TEMPDIR) $(CURDIR)/$(DOCPP) < $< > $@
790

    
791
man/%.7.in man/%.8.in man/%.1.in: man/%.gen man/footer.man
792
	@test -n "$(PANDOC)" || \
793
	  { echo 'pandoc' not found during configure; exit 1; }
794
	set -o pipefail ; \
795
	$(PANDOC) -s -f rst -t man -A man/footer.man $< | \
796
	  sed -e 's/\\@/@/g' > $@
797
	if test -n "$(MAN_HAS_WARNINGS)"; then $(CHECK_MAN) $@; fi
798

    
799
man/%.html.in: man/%.gen man/footer.html
800
	@test -n "$(PANDOC)" || \
801
	  { echo 'pandoc' not found during configure; exit 1; }
802
	set -o pipefail ; \
803
	$(PANDOC) -s -f rst -t html -A man/footer.html $< | \
804
	  sed -e 's/\\@/@/g' > $@
805

    
806
man/%.1: man/%.1.in $(REPLACE_VARS_SED)
807
	sed -f $(REPLACE_VARS_SED) < $< > $@
808

    
809
man/%.7: man/%.7.in $(REPLACE_VARS_SED)
810
	sed -f $(REPLACE_VARS_SED) < $< > $@
811

    
812
man/%.8: man/%.8.in $(REPLACE_VARS_SED)
813
	sed -f $(REPLACE_VARS_SED) < $< > $@
814

    
815
man/%.html: man/%.html.in $(REPLACE_VARS_SED)
816
	sed -f $(REPLACE_VARS_SED) < $< > $@
817

    
818
epydoc.conf: epydoc.conf.in Makefile
819
	sed -e 's#@MODULES@#$(strip $(lint_python_code))#g' < $< > $@
820

    
821
vcs-version:
822
	if test -d .git; then \
823
	  git describe > $@; \
824
	elif test ! -f $@ ; then \
825
	  echo "Cannot auto-generate $@ file"; exit 1; \
826
	fi
827

    
828
.PHONY: regen-vcs-version
829
regen-vcs-version:
830
	set -e; \
831
	cd $(srcdir); \
832
	if test -d .git; then \
833
	  rm -f vcs-version; \
834
	  $(MAKE) vcs-version; \
835
	fi
836

    
837
htools/Ganeti/HTools/Version.hs: htools/Ganeti/HTools/Version.hs.in vcs-version
838
	set -e; \
839
	VCSVER=`cat $(abs_top_srcdir)/vcs-version`; \
840
	sed -e "s/%ver%/$$VCSVER/" < $< > $@
841

    
842
htools/Ganeti/Constants.hs: htools/Ganeti/Constants.hs.in \
843
	lib/constants.py lib/_autoconf.py $(CONVERT_CONSTANTS)
844
	set -e; \
845
	{ cat $< ; PYTHONPATH=. $(CONVERT_CONSTANTS); } > $@
846

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

    
913
$(REPLACE_VARS_SED): Makefile
914
	set -e; \
915
	{ echo 's#@PREFIX@#$(prefix)#g'; \
916
	  echo 's#@SYSCONFDIR@#$(sysconfdir)#g'; \
917
	  echo 's#@LOCALSTATEDIR@#$(localstatedir)#g'; \
918
	  echo 's#@BINDIR@#$(bindir)#g'; \
919
	  echo 's#@SBINDIR@#$(sbindir)#g'; \
920
	  echo 's#@GANETI_VERSION@#$(PACKAGE_VERSION)#g'; \
921
	  echo 's#@CUSTOM_XEN_BOOTLOADER@#$(XEN_BOOTLOADER)#g'; \
922
	  echo 's#@CUSTOM_XEN_KERNEL@#$(XEN_KERNEL)#g'; \
923
	  echo 's#@CUSTOM_XEN_INITRD@#$(XEN_INITRD)#g'; \
924
	  echo 's#@CUSTOM_IALLOCATOR_SEARCH_PATH@#$(IALLOCATOR_SEARCH_PATH)#g'; \
925
	  echo 's#@CUSTOM_EXPORT_DIR@#$(EXPORT_DIR)#g'; \
926
	  echo 's#@RPL_FILE_STORAGE_DIR@#$(FILE_STORAGE_DIR)#g'; \
927
	  echo 's#@RPL_SSH_INITD_SCRIPT@#$(SSH_INITD_SCRIPT)#g'; \
928
	  echo 's#@PKGLIBDIR@#$(pkglibdir)#g'; \
929
	  echo 's#@GNTMASTERUSER@#$(MASTERD_USER)#g'; \
930
	  echo 's#@GNTRAPIUSER@#$(RAPI_USER)#g'; \
931
	  echo 's#@GNTCONFDUSER@#$(CONFD_USER)#g'; \
932
	  echo 's#@GNTNODEDUSER@#$(NODED_USER)#g'; \
933
	  echo 's#@GNTRAPIGROUP@#$(RAPI_GROUP)#g'; \
934
	  echo 's#@GNTADMINGROUP@#$(ADMIN_GROUP)#g'; \
935
	  echo 's#@GNTCONFDGROUP@#$(CONFD_GROUP)#g'; \
936
	  echo 's#@GNTMASTERDGROUP@#$(MASTERD_GROUP)#g'; \
937
	  echo 's#@GNTDAEMONSGROUP@#$(DAEMONS_GROUP)#g'; \
938
	} > $@
939

    
940
# Using deferred evaluation
941
daemons/ganeti-%: MODULE = ganeti.server.$(patsubst ganeti-%,%,$(notdir $@))
942
daemons/ganeti-watcher: MODULE = ganeti.watcher
943
scripts/%: MODULE = ganeti.client.$(subst -,_,$(notdir $@))
944
tools/ensure-dirs: MODULE = ganeti.tools.ensure_dirs
945

    
946
$(PYTHON_BOOTSTRAP): Makefile | $(all_dirfiles)
947
	test -n "$(MODULE)" || { echo Missing module; exit 1; }
948
	set -e; \
949
	{ echo '#!/usr/bin/python'; \
950
	  echo '# This file is automatically generated, do not edit!'; \
951
	  echo "# Edit $(MODULE) instead."; \
952
	  echo; \
953
	  echo '"""Bootstrap script for L{$(MODULE)}"""'; \
954
	  echo; \
955
	  echo '# pylint: disable-msg=C0103'; \
956
	  echo '# C0103: Invalid name'; \
957
	  echo; \
958
	  echo 'import sys'; \
959
	  echo 'import $(MODULE) as main'; \
960
	  echo; \
961
	  echo '# Temporarily alias commands until bash completion'; \
962
	  echo '# generator is changed'; \
963
	  echo 'if hasattr(main, "commands"):'; \
964
		echo '  commands = main.commands # pylint: disable-msg=E1101'; \
965
	  echo; \
966
	  echo 'if __name__ == "__main__":'; \
967
	  echo '  sys.exit(main.Main())'; \
968
	} > $@
969
	chmod u+x $@
970

    
971
# We need to create symlinks because "make distcheck" will not install Python
972
# files when building.
973
stamp-srclinks: Makefile | $(all_dirfiles)
974
	set -e; \
975
	for i in $(srclink_files); do \
976
		if test ! -f $$i -a -f $(abs_top_srcdir)/$$i; then \
977
			$(LN_S) $(abs_top_srcdir)/$$i $$i; \
978
		fi; \
979
	done
980
	touch $@
981

    
982
.PHONY: ganeti
983
ganeti:
984
	cd $(top_builddir) && test -h "$@" || { rm -f $@ && $(LN_S) lib $@; }
985

    
986
.PHONY: check-dirs
987
check-dirs: $(BUILT_SOURCES)
988
	@set -e; \
989
	find . -type d \( \( -name . \) -o \( \
990
		-name .git -o \
991
		-name autom4te.cache \
992
		\) -prune -o -print \) | { \
993
		error=; \
994
		while read dir; do \
995
			case "$$dir" in \
996
				$(strip $(patsubst %,(./%) ;;,$(DIRCHECK_EXCLUDE) $(DIRS))) \
997
				*) error=1; echo "Directory $$dir not listed in Makefile" >&2 ;; \
998
			esac; \
999
		done; \
1000
		for dir in $(DIRS); do \
1001
			if ! test -d "$$dir"; then \
1002
				echo "Directory $$dir listed in DIRS does not exist" >&2; \
1003
				error=1; \
1004
			fi \
1005
		done; \
1006
		if test -n "$$error"; then exit 1; else exit 0; fi; \
1007
	}
1008

    
1009
check-local: check-dirs
1010
	$(CHECK_PYTHON_CODE) $(check_python_code)
1011
	$(CHECK_VERSION) $(VERSION) $(top_srcdir)/NEWS
1012
	$(CHECK_NEWS) < $(top_srcdir)/NEWS
1013
	expver=$(VERSION_MAJOR).$(VERSION_MINOR); \
1014
	if test "`head -n 1 $(top_srcdir)/README`" != "Ganeti $$expver"; then \
1015
		echo "Incorrect version in README, expected $$expver"; \
1016
		exit 1; \
1017
	fi; \
1018
	if test "`sed -ne '4 p' $(top_srcdir)/doc/iallocator.rst`" != \
1019
					"Documents Ganeti version $$expver"; then \
1020
		echo "Incorrect version in iallocator.rst, expected $$expver"; \
1021
		exit 1; \
1022
	fi
1023

    
1024
.PHONY: hs-check
1025
hs-check: htools/test
1026
	@rm -f test.tix
1027
	./htools/test
1028

    
1029
.PHONY: lint
1030
lint: $(BUILT_SOURCES)
1031
	@test -n "$(PYLINT)" || { echo 'pylint' not found during configure; exit 1; }
1032
	$(PYLINT) $(LINT_OPTS) $(lint_python_code)
1033
	cd $(top_srcdir)/qa && \
1034
	  PYTHONPATH=$(abs_top_srcdir) $(PYLINT) $(LINT_OPTS) \
1035
	  --rcfile  ../pylintrc $(patsubst qa/%.py,%,$(qa_scripts))
1036

    
1037
.PHONY: hlint
1038
hlint: $(HS_BUILT_SRCS)
1039
	if tty -s; then C="-c"; else C=""; fi; \
1040
	hlint --report=doc/hs-lint.html $$C htools
1041

    
1042
# a dist hook rule for updating the vcs-version file; this is
1043
# hardcoded due to where it needs to build the file...
1044
dist-hook:
1045
	$(MAKE) regen-vcs-version && \
1046
	rm -f $(top_distdir)/vcs-version && \
1047
	cp -p $(srcdir)/vcs-version $(top_distdir)
1048

    
1049
# a distcheck hook rule for catching revision control directories
1050
distcheck-hook:
1051
	if find $(top_distdir) -name .svn -or -name .git | grep .; then \
1052
		echo "Found revision control files in final archive." 1>&2; \
1053
		exit 1; \
1054
	fi
1055
	if find $(top_distdir) -name '*.py[co]' | grep .; then \
1056
		echo "Found Python byte code in final archive." 1>&2; \
1057
		exit 1; \
1058
	fi
1059
	if find $(top_distdir) -name '*~' | grep .; then \
1060
		echo "Found backup files in final archive." 1>&2; \
1061
		exit 1; \
1062
	fi
1063
# Empty files or directories should not be distributed. They can cause
1064
# unnecessary warnings for packagers. Directories used by automake during
1065
# distcheck must be excluded.
1066
	if find $(top_distdir) -empty -and -not \( \
1067
			-path $(top_distdir)/_build -or \
1068
			-path $(top_distdir)/_inst \) | grep .; then \
1069
		echo "Found empty files or directories in final archive." 1>&2; \
1070
		exit 1; \
1071
	fi
1072
	if test -n "$(BUILD_RELEASE)" && \
1073
	   grep -n -H -E '^\*.*unreleased' $(top_distdir)/NEWS; then \
1074
		echo "Found unreleased version in NEWS." >&2; \
1075
		exit 1; \
1076
	fi
1077

    
1078
# When building a release, stricter checks should be used
1079
distcheck-release dist-release: export BUILD_RELEASE = 1
1080
distcheck-release: distcheck
1081

    
1082
dist-release: dist
1083
	set -e; \
1084
	for i in $(DIST_ARCHIVES); do \
1085
		echo -n "Checking $$i ... "; \
1086
		autotools/check-tar < $$i; \
1087
		echo OK; \
1088
	done
1089

    
1090
install-exec-local:
1091
	@mkdir_p@ "$(DESTDIR)${localstatedir}/lib/ganeti" \
1092
	  "$(DESTDIR)${localstatedir}/log/ganeti" \
1093
	  "$(DESTDIR)${localstatedir}/run/ganeti"
1094

    
1095
# To avoid conflicts between directory names and other targets, a file inside
1096
# the directory is used to ensure its existence.
1097
%.dir:
1098
	@mkdir_p@ $* && touch $@
1099

    
1100
.PHONY: apidoc
1101
if WANT_HTOOLSAPIDOC
1102
apidoc: py-apidoc hs-apidoc
1103
else
1104
apidoc: py-apidoc
1105
endif
1106

    
1107
.PHONY: py-apidoc
1108
py-apidoc: epydoc.conf $(RUN_IN_TEMPDIR) $(BUILT_SOURCES)
1109
	$(RUN_IN_TEMPDIR) epydoc -v \
1110
		--conf $(CURDIR)/epydoc.conf \
1111
		--output $(CURDIR)/$(APIDOC_PY_DIR)
1112

    
1113
.PHONY: hs-apidoc
1114
hs-apidoc: $(HS_BUILT_SRCS)
1115
	@test -n "$(HSCOLOUR)" || \
1116
	    { echo 'HsColour' not found during configure; exit 1; }
1117
	@test -n "$(HADDOCK)" || \
1118
	    { echo 'haddock' not found during configure; exit 1; }
1119
	rm -rf $(APIDOC_HS_DIR)/*
1120
	@mkdir_p@ $(APIDOC_HS_DIR)/Ganeti/HTools/Program
1121
	$(HSCOLOUR) -print-css > $(APIDOC_HS_DIR)/Ganeti/hscolour.css
1122
	ln -s ../hscolour.css $(APIDOC_HS_DIR)/Ganeti/HTools/hscolour.css
1123
	set -e ; \
1124
	cd htools; \
1125
	if [ "$(HTOOLS_NOCURL)" ]; \
1126
	then OPTGHC="--optghc=$(HTOOLS_NOCURL)"; \
1127
	else OPTGHC=""; \
1128
	fi; \
1129
	if [ "$(HTOOLS_PARALLEL3)" ]; \
1130
	then OPTGHC="$$OPTGHC --optghc=$(HTOOLS_PARALLEL3)"; \
1131
	fi; \
1132
	RELSRCS="$(HS_LIB_SRCS:htools/%=%)  $(HS_BUILT_SRCS:htools/%=%)"; \
1133
	for file in $$RELSRCS; do \
1134
		hfile=`echo $$file|sed 's/\\.hs$$//'`.html; \
1135
		$(HSCOLOUR) -css -anchor $$file > ../$(APIDOC_HS_DIR)/$$hfile ; \
1136
	done ; \
1137
	$(HADDOCK) --odir ../$(APIDOC_HS_DIR) --html --ignore-all-exports -w \
1138
		-t ganeti-htools -p haddock-prologue \
1139
		--source-module="%{MODULE/.//}.html" \
1140
		--source-entity="%{MODULE/.//}.html#%{NAME}" \
1141
		$$OPTGHC \
1142
		$(filter-out Ganeti/HTools/ExtLoader.hs,$(HS_LIB_SRCS:htools/%=%))
1143

    
1144
.PHONY: TAGS
1145
TAGS: $(BUILT_SOURCES)
1146
	rm -f TAGS
1147
	find . -path './lib/*.py' -o -path './scripts/gnt-*' -o \
1148
	  -path './daemons/ganeti-*' -o -path './tools/*' -o \
1149
	  -path './qa/*.py' | \
1150
	  etags -l python -
1151

    
1152
.PHONY: coverage
1153
if WANT_HTOOLS
1154
coverage: py-coverage hs-coverage
1155
else
1156
coverage: py-coverage
1157
endif
1158

    
1159
.PHONY: py-coverage
1160
py-coverage: $(BUILT_SOURCES) $(python_tests)
1161
	set -e; \
1162
	COVERAGE_FILE=$(CURDIR)/$(COVERAGE_PY_DIR)/data \
1163
	TEXT_COVERAGE=$(CURDIR)/$(COVERAGE_PY_DIR)/report.txt \
1164
	HTML_COVERAGE=$(CURDIR)/$(COVERAGE_PY_DIR) \
1165
	$(PLAIN_TESTS_ENVIRONMENT) $(abs_top_srcdir)/autotools/gen-coverage \
1166
	$(python_tests)
1167

    
1168
.PHONY: hs-coverage
1169
hs-coverage: $(haskell_tests)
1170
	cd htools && rm -f *.tix *.mix && ./test
1171
	@mkdir_p@ $(COVERAGE_HS_DIR)
1172
	hpc markup --destdir=$(COVERAGE_HS_DIR) htools/test $(HPCEXCL)
1173
	hpc report htools/test $(HPCEXCL)
1174
	ln -sf hpc_index.html $(COVERAGE_HS_DIR)/index.html
1175

    
1176
# Special "kind-of-QA" target for htools, needs special setup (all
1177
# tools compiled with -fhpc)
1178
.PHONY: live-test
1179
live-test: all
1180
	set -e ; \
1181
	cd htools; \
1182
	rm -f .hpc; ln -s ../.hpc .hpc; \
1183
	rm -f *.tix *.mix; \
1184
	./live-test.sh; \
1185
	hpc sum --union $(HPCEXCL) $(addsuffix .tix,$(HS_PROGS:htools/%=%)) \
1186
	  --output=live-test.tix ; \
1187
	@mkdir_p@ ../$(COVERAGE_HS_DIR) ; \
1188
	hpc markup --destdir=../$(COVERAGE_HS_DIR) live-test \
1189
		--srcdir=.. $(HPCEXCL) ; \
1190
	hpc report --srcdir=.. live-test $(HPCEXCL)
1191

    
1192
commit-check: distcheck lint apidoc
1193

    
1194
-include ./Makefile.local
1195

    
1196
# vim: set noet :