Statistics
| Branch: | Tag: | Revision:

root / Makefile.am @ f6cbcc06

History | View | Annotate | Download (34.9 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
# 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
	tools
85

    
86
BUILDTIME_DIR_AUTOCREATE = \
87
	scripts \
88
	$(APIDOC_DIR) \
89
	$(APIDOC_PY_DIR) \
90
	$(APIDOC_HS_DIR) \
91
	$(APIDOC_HS_DIR)/Ganeti $(APIDOC_HS_DIR)/Ganeti/HTools \
92
	$(APIDOC_HS_DIR)/Ganeti/HTools/Program \
93
	$(COVERAGE_DIR) \
94
	$(COVERAGE_PY_DIR) \
95
	$(COVERAGE_HS_DIR) \
96
	.hpc
97

    
98
BUILDTIME_DIRS = \
99
	$(BUILDTIME_DIR_AUTOCREATE) \
100
	doc/html
101

    
102
DIRCHECK_EXCLUDE = \
103
	$(BUILDTIME_DIRS) \
104
	ganeti-[0-9]*.[0-9]*.[0-9]* \
105
	doc/html/_*
106

    
107
all_dirfiles = $(addsuffix /.dir,$(DIRS) $(BUILDTIME_DIR_AUTOCREATE))
108

    
109
# some helper vars
110
COVERAGE_DIR = doc/coverage
111
COVERAGE_PY_DIR = $(COVERAGE_DIR)/py
112
COVERAGE_HS_DIR = $(COVERAGE_DIR)/hs
113
APIDOC_DIR = doc/api
114
APIDOC_PY_DIR = $(APIDOC_DIR)/py
115
APIDOC_HS_DIR = $(APIDOC_DIR)/hs
116

    
117
MAINTAINERCLEANFILES = \
118
	$(docpng) \
119
	$(maninput) \
120
	doc/install-quick.rst \
121
	doc/news.rst \
122
	doc/upgrade.rst \
123
	vcs-version
124

    
125
maintainer-clean-local:
126
	rm -rf $(BUILDTIME_DIRS)
127

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

    
154
# BUILT_SOURCES should only be used as a dependency on phony targets. Otherwise
155
# it'll cause the target to rebuild every time.
156
BUILT_SOURCES = \
157
	ganeti \
158
	stamp-srclinks \
159
	$(all_dirfiles) \
160
	$(PYTHON_BOOTSTRAP) \
161
	$(BUILT_PYTHON_SOURCES)
162

    
163
BUILT_PYTHON_SOURCES = \
164
	lib/_autoconf.py \
165
	lib/_vcsversion.py
166

    
167
nodist_pkgpython_PYTHON = \
168
	$(BUILT_PYTHON_SOURCES)
169

    
170
noinst_PYTHON = \
171
	lib/build/__init__.py \
172
	lib/build/sphinx_ext.py
173

    
174
pkgpython_PYTHON = \
175
	lib/__init__.py \
176
	lib/asyncnotifier.py \
177
	lib/backend.py \
178
	lib/bdev.py \
179
	lib/bootstrap.py \
180
	lib/cli.py \
181
	lib/cmdlib.py \
182
	lib/compat.py \
183
	lib/config.py \
184
	lib/constants.py \
185
	lib/daemon.py \
186
	lib/errors.py \
187
	lib/ht.py \
188
	lib/jqueue.py \
189
	lib/jstore.py \
190
	lib/locking.py \
191
	lib/luxi.py \
192
	lib/mcpu.py \
193
	lib/netutils.py \
194
	lib/objects.py \
195
	lib/opcodes.py \
196
	lib/qlang.py \
197
	lib/query.py \
198
	lib/rpc.py \
199
	lib/runtime.py \
200
	lib/serializer.py \
201
	lib/ssconf.py \
202
	lib/ssh.py \
203
	lib/storage.py \
204
	lib/uidpool.py \
205
	lib/workerpool.py
206

    
207
client_PYTHON = \
208
	lib/client/__init__.py \
209
	lib/client/gnt_backup.py \
210
	lib/client/gnt_cluster.py \
211
	lib/client/gnt_debug.py \
212
	lib/client/gnt_group.py \
213
	lib/client/gnt_instance.py \
214
	lib/client/gnt_job.py \
215
	lib/client/gnt_node.py \
216
	lib/client/gnt_os.py
217

    
218
hypervisor_PYTHON = \
219
	lib/hypervisor/__init__.py \
220
	lib/hypervisor/hv_base.py \
221
	lib/hypervisor/hv_chroot.py \
222
	lib/hypervisor/hv_fake.py \
223
	lib/hypervisor/hv_kvm.py \
224
	lib/hypervisor/hv_lxc.py \
225
	lib/hypervisor/hv_xen.py
226

    
227
rapi_PYTHON = \
228
	lib/rapi/__init__.py \
229
	lib/rapi/baserlib.py \
230
	lib/rapi/client.py \
231
	lib/rapi/client_utils.py \
232
	lib/rapi/connector.py \
233
	lib/rapi/rlib2.py
234

    
235
http_PYTHON = \
236
	lib/http/__init__.py \
237
	lib/http/auth.py \
238
	lib/http/client.py \
239
	lib/http/server.py
240

    
241
confd_PYTHON = \
242
	lib/confd/__init__.py \
243
	lib/confd/client.py \
244
	lib/confd/querylib.py \
245
	lib/confd/server.py
246

    
247
masterd_PYTHON = \
248
	lib/masterd/__init__.py \
249
	lib/masterd/instance.py
250

    
251
impexpd_PYTHON = \
252
	lib/impexpd/__init__.py
253

    
254
watcher_PYTHON = \
255
	lib/watcher/__init__.py \
256
	lib/watcher/nodemaint.py \
257
	lib/watcher/state.py
258

    
259
server_PYTHON = \
260
	lib/server/__init__.py \
261
	lib/server/confd.py \
262
	lib/server/masterd.py \
263
	lib/server/noded.py \
264
	lib/server/rapi.py
265

    
266
pytools_PYTHON = \
267
	lib/tools/__init__.py \
268
	lib/tools/ensure_dirs.py
269

    
270
utils_PYTHON = \
271
	lib/utils/__init__.py \
272
	lib/utils/algo.py \
273
	lib/utils/filelock.py \
274
	lib/utils/hash.py \
275
	lib/utils/io.py \
276
	lib/utils/log.py \
277
	lib/utils/mlock.py \
278
	lib/utils/nodesetup.py \
279
	lib/utils/process.py \
280
	lib/utils/retry.py \
281
	lib/utils/text.py \
282
	lib/utils/wrapper.py \
283
	lib/utils/x509.py
284

    
285
docrst = \
286
	doc/admin.rst \
287
	doc/design-2.0.rst \
288
	doc/design-2.1.rst \
289
	doc/design-2.2.rst \
290
	doc/design-2.3.rst \
291
	doc/design-htools-2.3.rst \
292
	doc/design-2.4.rst \
293
	doc/design-2.5.rst \
294
	doc/design-draft.rst \
295
	doc/design-oob.rst \
296
	doc/design-cpu-pinning.rst \
297
	doc/design-query2.rst \
298
	doc/design-x509-ca.rst \
299
	doc/design-http-server.rst \
300
	doc/design-impexp2.rst \
301
	doc/design-lu-generated-jobs.rst \
302
	doc/design-multi-reloc.rst \
303
	doc/design-network.rst \
304
	doc/design-chained-jobs.rst \
305
	doc/design-ovf-support.rst \
306
	doc/cluster-merge.rst \
307
	doc/design-shared-storage.rst \
308
	doc/devnotes.rst \
309
	doc/glossary.rst \
310
	doc/hooks.rst \
311
	doc/iallocator.rst \
312
	doc/index.rst \
313
	doc/install-quick.rst \
314
	doc/install.rst \
315
	doc/locking.rst \
316
	doc/move-instance.rst \
317
	doc/news.rst \
318
	doc/rapi.rst \
319
	doc/security.rst \
320
	doc/upgrade.rst \
321
	doc/walkthrough.rst
322

    
323
HS_PROGS = htools/htools
324
HS_BIN_ROLES = hbal hscan hspace
325

    
326
HS_ALL_PROGS = $(HS_PROGS) htools/test
327
HS_PROG_SRCS = $(patsubst %,%.hs,$(HS_ALL_PROGS))
328
# we don't add -Werror by default
329
HFLAGS = -O -Wall -fwarn-monomorphism-restriction -fwarn-tabs -ihtools
330
# extra flags that can be overriden on the command line
331
HEXTRA =
332
# exclude options for coverage reports
333
HPCEXCL = --exclude Main --exclude Ganeti.HTools.QC \
334
	--exclude Ganeti.Constants \
335
	--exclude Ganeti.HTools.Version
336

    
337
HS_LIB_SRCS = \
338
	htools/Ganeti/HTools/CLI.hs \
339
	htools/Ganeti/HTools/Cluster.hs \
340
	htools/Ganeti/HTools/Compat.hs \
341
	htools/Ganeti/HTools/Container.hs \
342
	htools/Ganeti/HTools/ExtLoader.hs \
343
	htools/Ganeti/HTools/Group.hs \
344
	htools/Ganeti/HTools/IAlloc.hs \
345
	htools/Ganeti/HTools/Instance.hs \
346
	htools/Ganeti/HTools/Loader.hs \
347
	htools/Ganeti/HTools/Luxi.hs \
348
	htools/Ganeti/HTools/Node.hs \
349
	htools/Ganeti/HTools/PeerMap.hs \
350
	htools/Ganeti/HTools/QC.hs \
351
	htools/Ganeti/HTools/Rapi.hs \
352
	htools/Ganeti/HTools/Simu.hs \
353
	htools/Ganeti/HTools/Text.hs \
354
	htools/Ganeti/HTools/Types.hs \
355
	htools/Ganeti/HTools/Utils.hs \
356
	htools/Ganeti/HTools/Program/Hail.hs \
357
	htools/Ganeti/HTools/Program/Hbal.hs \
358
	htools/Ganeti/HTools/Program/Hscan.hs \
359
	htools/Ganeti/HTools/Program/Hspace.hs \
360
	htools/Ganeti/Jobs.hs \
361
	htools/Ganeti/Luxi.hs \
362
	htools/Ganeti/OpCodes.hs
363

    
364
HS_BUILT_SRCS = htools/Ganeti/HTools/Version.hs htools/Ganeti/Constants.hs
365
HS_BUILT_SRCS_IN = $(patsubst %,%.in,$(HS_BUILT_SRCS))
366

    
367
$(RUN_IN_TEMPDIR): | $(all_dirfiles)
368

    
369
# Note: we use here an order-only prerequisite, as the contents of
370
# _autoconf.py are not actually influencing the html build output: it
371
# has to exist in order for the sphinx module to be loaded
372
# successfully, but we certainly don't want the docs to be rebuilt if
373
# it changes
374
doc/html/index.html: $(docrst) $(docpng) doc/conf.py configure.ac \
375
	$(RUN_IN_TEMPDIR) lib/build/sphinx_ext.py lib/opcodes.py lib/ht.py \
376
	| $(BUILT_PYTHON_SOURCES)
377
	@test -n "$(SPHINX)" || \
378
	    { echo 'sphinx-build' not found during configure; exit 1; }
379
	@mkdir_p@ $(dir $@)
380
	PYTHONPATH=. $(RUN_IN_TEMPDIR) $(SPHINX) -q -W -b html \
381
	    -d . \
382
	    -D version="$(VERSION_MAJOR).$(VERSION_MINOR)" \
383
	    -D release="$(PACKAGE_VERSION)" \
384
	    $(abs_top_srcdir)/doc $(CURDIR)/doc/html
385
	rm -f doc/html/.buildinfo doc/html/objects.inv
386
	touch $@
387

    
388
doc/html: doc/html/index.html
389

    
390
doc/install-quick.rst: INSTALL
391
doc/news.rst: NEWS
392
doc/upgrade.rst: UPGRADE
393

    
394
doc/install-quick.rst doc/news.rst doc/upgrade.rst:
395
	set -e; \
396
	{ echo '.. This file is automatically updated at build time from $<.'; \
397
	  echo '.. Do not edit.'; \
398
	  echo; \
399
	  cat $<; \
400
	} > $@
401

    
402
docdot = \
403
	doc/arch-2.0.dot \
404
	doc/design-2.1-lock-acquire.dot \
405
	doc/design-2.1-lock-release.dot
406

    
407
docpng = $(patsubst %.dot,%.png,$(docdot))
408

    
409
# Things to build but not to install (add it to EXTRA_DIST if it should be
410
# distributed)
411
noinst_DATA = \
412
	devel/upload \
413
	doc/html \
414
	doc/examples/bash_completion \
415
	doc/examples/ganeti.cron \
416
	doc/examples/ganeti.initd \
417
	doc/examples/ganeti-kvm-poweroff.initd \
418
	doc/examples/gnt-config-backup \
419
	doc/examples/hooks/ipsec \
420
	$(manhtml)
421

    
422
gnt_scripts = \
423
	scripts/gnt-backup \
424
	scripts/gnt-cluster \
425
	scripts/gnt-debug \
426
	scripts/gnt-group \
427
	scripts/gnt-instance \
428
	scripts/gnt-job \
429
	scripts/gnt-node \
430
	scripts/gnt-os
431

    
432
PYTHON_BOOTSTRAP_SBIN = \
433
	daemons/ganeti-confd \
434
	daemons/ganeti-masterd \
435
	daemons/ganeti-noded \
436
	daemons/ganeti-watcher \
437
	daemons/ganeti-rapi \
438
	scripts/gnt-backup \
439
	scripts/gnt-cluster \
440
	scripts/gnt-debug \
441
	scripts/gnt-group \
442
	scripts/gnt-instance \
443
	scripts/gnt-job \
444
	scripts/gnt-node \
445
	scripts/gnt-os
446

    
447
PYTHON_BOOTSTRAP = \
448
	$(PYTHON_BOOTSTRAP_SBIN) \
449
	tools/ensure-dirs
450

    
451
qa_scripts = \
452
	qa/ganeti-qa.py \
453
	qa/qa_cluster.py \
454
	qa/qa_config.py \
455
	qa/qa_daemon.py \
456
	qa/qa_env.py \
457
	qa/qa_error.py \
458
	qa/qa_instance.py \
459
	qa/qa_node.py \
460
	qa/qa_os.py \
461
	qa/qa_rapi.py \
462
	qa/qa_tags.py \
463
	qa/qa_utils.py
464

    
465
bin_SCRIPTS =
466
if WANT_HTOOLS
467
bin_SCRIPTS += $(filter-out htools/hail,$(HS_PROGS))
468
install-exec-hook:
469
	@mkdir_p@ $(DESTDIR)$(iallocatorsdir)
470
# FIXME: this is a hardcoded logic, instead of auto-resolving
471
	$(LN_S) -f ../../../bin/htools \
472
		   $(DESTDIR)$(iallocatorsdir)/hail
473
	for role in $(HS_BIN_ROLES); do \
474
		$(LN_S) -f htools \
475
			   $(DESTDIR)$(bindir)/$$role ; \
476
	done
477
endif
478

    
479
$(HS_ALL_PROGS): %: %.hs $(HS_LIB_SRCS) $(HS_BUILT_SRCS) Makefile
480
	@if [ -z "$(HTOOLS)" ]; then \
481
	  echo "Error: htools compilation disabled at configure time" 1>&2 ;\
482
	  exit 1; \
483
	fi
484
	@BINARY=$(@:htools/%=%); \
485
	if [ "$BINARY" = "test" ] && [ -z "$(GHC_PKG_QUICKCHECK)" ]; then \
486
	  echo "Error: cannot run unittests without the QuickCheck library (see devnotes.rst)" 1>&2; \
487
	  exit 1; \
488
	fi
489
	BINARY=$(@:htools/%=%); $(GHC) --make \
490
	  $(HFLAGS) $(HEXTRA) \
491
	  $(HTOOLS_NOCURL) $(HTOOLS_PARALLEL3) \
492
	  -osuf $$BINARY.o -hisuf $$BINARY.hi $@
493

    
494
# for the htools/test binary, we need to enable profiling/coverage
495
htools/test: HEXTRA=-fhpc -Wwarn -fno-warn-missing-signatures \
496
	-fno-warn-monomorphism-restriction -fno-warn-orphans \
497
	-fno-warn-missing-methods -fno-warn-unused-imports
498

    
499
dist_sbin_SCRIPTS = \
500
	tools/ganeti-listrunner
501

    
502
nodist_sbin_SCRIPTS = \
503
	$(PYTHON_BOOTSTRAP_SBIN) \
504
	daemons/ganeti-cleaner
505

    
506
dist_tools_PYTHON = \
507
	tools/burnin \
508
	tools/cfgshell \
509
	tools/cfgupgrade \
510
	tools/cfgupgrade12 \
511
	tools/cluster-merge \
512
	tools/lvmstrap \
513
	tools/move-instance \
514
	tools/setup-ssh \
515
	tools/sanitize-config
516

    
517
dist_tools_SCRIPTS = \
518
	$(dist_tools_PYTHON) \
519
	tools/kvm-console-wrapper \
520
	tools/xm-console-wrapper
521

    
522
pkglib_python_scripts = \
523
	daemons/import-export \
524
	tools/check-cert-expired
525

    
526
nodist_pkglib_python_scripts = \
527
	tools/ensure-dirs
528

    
529
pkglib_SCRIPTS = \
530
	daemons/daemon-util \
531
	tools/kvm-ifup \
532
	$(pkglib_python_scripts)
533

    
534
nodist_pkglib_SCRIPTS = \
535
	$(nodist_pkglib_python_scripts)
536

    
537
EXTRA_DIST = \
538
	NEWS \
539
	UPGRADE \
540
	epydoc.conf.in \
541
	pylintrc \
542
	autotools/build-bash-completion \
543
	autotools/check-python-code \
544
	autotools/check-imports \
545
	autotools/check-man \
546
	autotools/check-news \
547
	autotools/check-tar \
548
	autotools/check-version \
549
	autotools/convert-constants \
550
	autotools/docpp \
551
	autotools/gen-coverage \
552
	autotools/testrunner \
553
	$(RUN_IN_TEMPDIR) \
554
	daemons/daemon-util.in \
555
	daemons/ganeti-cleaner.in \
556
	$(pkglib_python_scripts) \
557
	devel/upload.in \
558
	tools/kvm-ifup.in \
559
	$(docdot) \
560
	$(docpng) \
561
	$(docrst) \
562
	doc/conf.py \
563
	doc/html \
564
	doc/examples/ganeti.initd.in \
565
	doc/examples/ganeti-kvm-poweroff.initd.in \
566
	doc/examples/ganeti.cron.in \
567
	doc/examples/gnt-config-backup.in \
568
	doc/examples/ganeti.default \
569
	doc/examples/ganeti.default-debug \
570
	doc/examples/hooks/ethers \
571
	doc/examples/hooks/ipsec.in \
572
	doc/examples/gnt-debug/README \
573
	doc/examples/gnt-debug/delay0.json \
574
	doc/examples/gnt-debug/delay50.json \
575
	test/testutils.py \
576
	test/mocks.py \
577
	$(dist_TESTS) \
578
	$(TEST_FILES) \
579
	man/footer.rst \
580
	$(manrst) \
581
	$(maninput) \
582
	qa/qa-sample.json \
583
	$(qa_scripts) \
584
	$(HS_LIB_SRCS) $(HS_BUILT_SRCS_IN) \
585
	$(HS_PROG_SRCS)
586

    
587
man_MANS = \
588
	man/ganeti.7 \
589
	man/ganeti-cleaner.8 \
590
	man/ganeti-confd.8 \
591
	man/ganeti-listrunner.8 \
592
	man/ganeti-masterd.8 \
593
	man/ganeti-noded.8 \
594
	man/ganeti-os-interface.7 \
595
	man/ganeti-rapi.8 \
596
	man/ganeti-watcher.8 \
597
	man/gnt-backup.8 \
598
	man/gnt-cluster.8 \
599
	man/gnt-debug.8 \
600
	man/gnt-group.8 \
601
	man/gnt-instance.8 \
602
	man/gnt-job.8 \
603
	man/gnt-node.8 \
604
	man/gnt-os.8 \
605
	man/hail.1 \
606
	man/hbal.1 \
607
	man/hscan.1 \
608
	man/hspace.1 \
609
	man/htools.1
610

    
611
manrst = $(patsubst %.1,%.rst,$(patsubst %.7,%.rst,$(patsubst %.8,%.rst,$(man_MANS))))
612
manhtml = $(patsubst %.rst,%.html,$(manrst))
613
mangen = $(patsubst %.rst,%.gen,$(manrst))
614
maninput = \
615
	$(patsubst %.1,%.1.in,$(patsubst %.7,%.7.in,$(patsubst %.8,%.8.in,$(man_MANS)))) \
616
	$(patsubst %.html,%.html.in,$(manhtml)) \
617
	man/footer.man man/footer.html $(mangen)
618

    
619
TEST_FILES = \
620
	test/data/bdev-drbd-8.0.txt \
621
	test/data/bdev-drbd-8.3.txt \
622
	test/data/bdev-drbd-disk.txt \
623
	test/data/bdev-drbd-net-ip4.txt \
624
	test/data/bdev-drbd-net-ip6.txt \
625
	test/data/cert1.pem \
626
	test/data/ip-addr-show-dummy0.txt \
627
	test/data/ip-addr-show-lo-ipv4.txt \
628
	test/data/ip-addr-show-lo-ipv6.txt \
629
	test/data/ip-addr-show-lo-oneline-ipv4.txt \
630
	test/data/ip-addr-show-lo-oneline-ipv6.txt \
631
	test/data/ip-addr-show-lo-oneline.txt \
632
	test/data/ip-addr-show-lo.txt \
633
	test/data/proc_drbd8.txt \
634
	test/data/proc_drbd80-emptyline.txt \
635
	test/data/proc_drbd83.txt \
636
	test/data/sys_drbd_usermode_helper.txt \
637
	test/import-export_unittest-helper
638

    
639
python_tests = \
640
	test/ganeti.asyncnotifier_unittest.py \
641
	test/ganeti.backend_unittest.py \
642
	test/ganeti.bdev_unittest.py \
643
	test/ganeti.cli_unittest.py \
644
	test/ganeti.client.gnt_cluster_unittest.py \
645
	test/ganeti.client.gnt_instance_unittest.py \
646
	test/ganeti.daemon_unittest.py \
647
	test/ganeti.cmdlib_unittest.py \
648
	test/ganeti.compat_unittest.py \
649
	test/ganeti.confd.client_unittest.py \
650
	test/ganeti.config_unittest.py \
651
	test/ganeti.constants_unittest.py \
652
	test/ganeti.errors_unittest.py \
653
	test/ganeti.hooks_unittest.py \
654
	test/ganeti.ht_unittest.py \
655
	test/ganeti.http_unittest.py \
656
	test/ganeti.hypervisor_unittest.py \
657
	test/ganeti.hypervisor.hv_chroot_unittest.py \
658
	test/ganeti.hypervisor.hv_fake_unittest.py \
659
	test/ganeti.hypervisor.hv_kvm_unittest.py \
660
	test/ganeti.hypervisor.hv_lxc_unittest.py \
661
	test/ganeti.hypervisor.hv_xen_unittest.py \
662
	test/ganeti.impexpd_unittest.py \
663
	test/ganeti.jqueue_unittest.py \
664
	test/ganeti.locking_unittest.py \
665
	test/ganeti.luxi_unittest.py \
666
	test/ganeti.masterd.instance_unittest.py \
667
	test/ganeti.mcpu_unittest.py \
668
	test/ganeti.netutils_unittest.py \
669
	test/ganeti.objects_unittest.py \
670
	test/ganeti.opcodes_unittest.py \
671
	test/ganeti.qlang_unittest.py \
672
	test/ganeti.query_unittest.py \
673
	test/ganeti.rapi.baserlib_unittest.py \
674
	test/ganeti.rapi.client_unittest.py \
675
	test/ganeti.rapi.resources_unittest.py \
676
	test/ganeti.rapi.rlib2_unittest.py \
677
	test/ganeti.rpc_unittest.py \
678
	test/ganeti.runtime_unittest.py \
679
	test/ganeti.serializer_unittest.py \
680
	test/ganeti.ssh_unittest.py \
681
	test/ganeti.tools.ensure_dirs_unittest.py \
682
	test/ganeti.uidpool_unittest.py \
683
	test/ganeti.utils.algo_unittest.py \
684
	test/ganeti.utils.filelock_unittest.py \
685
	test/ganeti.utils.hash_unittest.py \
686
	test/ganeti.utils.io_unittest.py \
687
	test/ganeti.utils.log_unittest.py \
688
	test/ganeti.utils.mlock_unittest.py \
689
	test/ganeti.utils.nodesetup_unittest.py \
690
	test/ganeti.utils.process_unittest.py \
691
	test/ganeti.utils.retry_unittest.py \
692
	test/ganeti.utils.text_unittest.py \
693
	test/ganeti.utils.wrapper_unittest.py \
694
	test/ganeti.utils.x509_unittest.py \
695
	test/ganeti.utils_unittest.py \
696
	test/ganeti.workerpool_unittest.py \
697
	test/cfgupgrade_unittest.py \
698
	test/docs_unittest.py \
699
	test/tempfile_fork_unittest.py
700

    
701
haskell_tests = htools/test
702

    
703
dist_TESTS = \
704
	test/check-cert-expired_unittest.bash \
705
	test/daemon-util_unittest.bash \
706
	test/ganeti-cleaner_unittest.bash \
707
	test/import-export_unittest.bash \
708
	$(python_tests)
709

    
710
nodist_TESTS =
711
if WANT_HTOOLSTESTS
712
nodist_TESTS += $(haskell_tests)
713
endif
714

    
715
TESTS = $(dist_TESTS) $(nodist_TESTS)
716

    
717
# Environment for all tests
718
PLAIN_TESTS_ENVIRONMENT = \
719
	PYTHONPATH=. TOP_SRCDIR=$(abs_top_srcdir) PYTHON=$(PYTHON) $(RUN_IN_TEMPDIR)
720

    
721
# Environment for tests run by automake
722
TESTS_ENVIRONMENT = \
723
	$(PLAIN_TESTS_ENVIRONMENT) $(abs_top_srcdir)/autotools/testrunner
724

    
725
all_python_code = \
726
	$(dist_sbin_SCRIPTS) \
727
	$(dist_tools_PYTHON) \
728
	$(pkglib_python_scripts) \
729
	$(nodist_pkglib_python_scripts) \
730
	$(python_tests) \
731
	$(pkgpython_PYTHON) \
732
	$(client_PYTHON) \
733
	$(hypervisor_PYTHON) \
734
	$(rapi_PYTHON) \
735
	$(server_PYTHON) \
736
	$(pytools_PYTHON) \
737
	$(http_PYTHON) \
738
	$(confd_PYTHON) \
739
	$(masterd_PYTHON) \
740
	$(impexpd_PYTHON) \
741
	$(utils_PYTHON) \
742
	$(watcher_PYTHON) \
743
	$(noinst_PYTHON) \
744
	$(qa_scripts)
745

    
746
srclink_files = \
747
	man/footer.rst \
748
	test/check-cert-expired_unittest.bash \
749
	test/daemon-util_unittest.bash \
750
	test/ganeti-cleaner_unittest.bash \
751
	test/import-export_unittest.bash \
752
	$(all_python_code) \
753
	$(HS_LIB_SRCS) $(HS_PROG_SRCS)
754

    
755
check_python_code = \
756
	$(BUILD_BASH_COMPLETION) \
757
	$(CHECK_IMPORTS) \
758
	$(DOCPP) \
759
	$(all_python_code)
760

    
761
lint_python_code = \
762
	ganeti \
763
	ganeti/http/server.py \
764
	$(dist_sbin_SCRIPTS) \
765
	$(dist_tools_PYTHON) \
766
	$(pkglib_python_scripts) \
767
	$(BUILD_BASH_COMPLETION) \
768
	$(CHECK_IMPORTS) \
769
	$(DOCPP) \
770
	$(PYTHON_BOOTSTRAP)
771

    
772
standalone_python_modules = \
773
	lib/rapi/client.py \
774
	tools/ganeti-listrunner
775

    
776
test/daemon-util_unittest.bash: daemons/daemon-util
777

    
778
test/ganeti-cleaner_unittest.bash: daemons/ganeti-cleaner
779

    
780
tools/kvm-ifup: tools/kvm-ifup.in $(REPLACE_VARS_SED)
781
	sed -f $(REPLACE_VARS_SED) < $< > $@
782
	chmod +x $@
783

    
784
devel/upload: devel/upload.in $(REPLACE_VARS_SED)
785
	sed -f $(REPLACE_VARS_SED) < $< > $@
786
	chmod u+x $@
787

    
788
daemons/%: daemons/%.in $(REPLACE_VARS_SED)
789
	sed -f $(REPLACE_VARS_SED) < $< > $@
790
	chmod +x $@
791

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

    
795
doc/examples/hooks/%: doc/examples/hooks/%.in $(REPLACE_VARS_SED)
796
	sed -f $(REPLACE_VARS_SED) < $< > $@
797

    
798
doc/examples/bash_completion: $(BUILD_BASH_COMPLETION) $(RUN_IN_TEMPDIR) \
799
	lib/cli.py $(gnt_scripts) $(client_PYTHON) tools/burnin
800
	PYTHONPATH=. $(RUN_IN_TEMPDIR) $(CURDIR)/$(BUILD_BASH_COMPLETION) > $@
801

    
802
doc/%.png: doc/%.dot
803
	@test -n "$(DOT)" || { echo 'dot' not found during configure; exit 1; }
804
	$(DOT) -Tpng -o $@ $<
805

    
806
man/footer.man: man/footer.rst
807
	@test -n "$(PANDOC)" || \
808
	  { echo 'pandoc' not found during configure; exit 1; }
809
	$(PANDOC) -f rst -t man -o $@ $<
810

    
811
man/footer.html: man/footer.rst
812
	@test -n "$(PANDOC)" || \
813
	  { echo 'pandoc' not found during configure; exit 1; }
814
	$(PANDOC) -f rst -t html -o $@ $<
815

    
816
man/%.gen: man/%.rst lib/query.py lib/build/sphinx_ext.py
817
	PYTHONPATH=. $(RUN_IN_TEMPDIR) $(CURDIR)/$(DOCPP) < $< > $@
818

    
819
man/%.7.in man/%.8.in man/%.1.in: man/%.gen man/footer.man
820
	@test -n "$(PANDOC)" || \
821
	  { echo 'pandoc' not found during configure; exit 1; }
822
	set -o pipefail ; \
823
	$(PANDOC) -s -f rst -t man -A man/footer.man $< | \
824
	  sed -e 's/\\@/@/g' > $@
825
	if test -n "$(MAN_HAS_WARNINGS)"; then $(CHECK_MAN) $@; fi
826

    
827
man/%.html.in: man/%.gen man/footer.html
828
	@test -n "$(PANDOC)" || \
829
	  { echo 'pandoc' not found during configure; exit 1; }
830
	set -o pipefail ; \
831
	$(PANDOC) -s -f rst -t html -A man/footer.html $< | \
832
	  sed -e 's/\\@/@/g' > $@
833

    
834
man/%.1: man/%.1.in $(REPLACE_VARS_SED)
835
	sed -f $(REPLACE_VARS_SED) < $< > $@
836

    
837
man/%.7: man/%.7.in $(REPLACE_VARS_SED)
838
	sed -f $(REPLACE_VARS_SED) < $< > $@
839

    
840
man/%.8: man/%.8.in $(REPLACE_VARS_SED)
841
	sed -f $(REPLACE_VARS_SED) < $< > $@
842

    
843
man/%.html: man/%.html.in $(REPLACE_VARS_SED)
844
	sed -f $(REPLACE_VARS_SED) < $< > $@
845

    
846
epydoc.conf: epydoc.conf.in Makefile
847
	sed -e 's#@MODULES@#$(strip $(lint_python_code))#g' < $< > $@
848

    
849
vcs-version:
850
	if test -d .git; then \
851
	  git describe > $@; \
852
	elif test ! -f $@ ; then \
853
	  echo "Cannot auto-generate $@ file"; exit 1; \
854
	fi
855

    
856
.PHONY: regen-vcs-version
857
regen-vcs-version:
858
	set -e; \
859
	cd $(srcdir); \
860
	if test -d .git; then \
861
	  rm -f vcs-version; \
862
	  $(MAKE) vcs-version; \
863
	fi
864

    
865
htools/Ganeti/HTools/Version.hs: htools/Ganeti/HTools/Version.hs.in vcs-version
866
	set -e; \
867
	VCSVER=`cat $(abs_top_srcdir)/vcs-version`; \
868
	sed -e "s/%ver%/$$VCSVER/" < $< > $@
869

    
870
htools/Ganeti/Constants.hs: htools/Ganeti/Constants.hs.in \
871
	lib/constants.py lib/_autoconf.py $(CONVERT_CONSTANTS)
872
	set -e; \
873
	{ cat $< ; PYTHONPATH=. $(CONVERT_CONSTANTS); } > $@
874

    
875
lib/_autoconf.py: Makefile | lib/.dir
876
	set -e; \
877
	{ echo '# This file is automatically generated, do not edit!'; \
878
	  echo '#'; \
879
	  echo ''; \
880
	  echo '"""Build-time configuration for Ganeti.'; \
881
	  echo '';\
882
	  echo 'This file is autogenerated by the build process.'; \
883
	  echo 'For any changes you need to re-run ./configure (and'; \
884
	  echo 'not edit by hand).'; \
885
	  echo ''; \
886
	  echo '"""'; \
887
	  echo ''; \
888
	  echo '# pylint: disable-msg=C0301,C0324'; \
889
	  echo '# because this is autogenerated, we do not want'; \
890
	  echo '# style warnings' ; \
891
	  echo ''; \
892
	  echo "PACKAGE_VERSION = '$(PACKAGE_VERSION)'"; \
893
	  echo "VERSION_MAJOR = '$(VERSION_MAJOR)'"; \
894
	  echo "VERSION_MINOR = '$(VERSION_MINOR)'"; \
895
	  echo "VERSION_REVISION = '$(VERSION_REVISION)'"; \
896
	  echo "VERSION_SUFFIX = '$(VERSION_SUFFIX)'"; \
897
	  echo "VERSION_FULL = '$(VERSION_FULL)'"; \
898
	  echo "LOCALSTATEDIR = '$(localstatedir)'"; \
899
	  echo "SYSCONFDIR = '$(sysconfdir)'"; \
900
	  echo "SSH_CONFIG_DIR = '$(SSH_CONFIG_DIR)'"; \
901
	  echo "EXPORT_DIR = '$(EXPORT_DIR)'"; \
902
	  echo "OS_SEARCH_PATH = [$(OS_SEARCH_PATH)]"; \
903
	  echo "XEN_BOOTLOADER = '$(XEN_BOOTLOADER)'"; \
904
	  echo "XEN_KERNEL = '$(XEN_KERNEL)'"; \
905
	  echo "XEN_INITRD = '$(XEN_INITRD)'"; \
906
	  echo "FILE_STORAGE_DIR = '$(FILE_STORAGE_DIR)'"; \
907
	  echo "ENABLE_FILE_STORAGE = $(ENABLE_FILE_STORAGE)"; \
908
	  echo "SHARED_FILE_STORAGE_DIR = '$(SHARED_FILE_STORAGE_DIR)'"; \
909
	  echo "ENABLE_SHARED_FILE_STORAGE = $(ENABLE_SHARED_FILE_STORAGE)"; \
910
	  echo "IALLOCATOR_SEARCH_PATH = [$(IALLOCATOR_SEARCH_PATH)]"; \
911
	  echo "KVM_PATH = '$(KVM_PATH)'"; \
912
	  echo "IP_PATH = '$(IP_PATH)'"; \
913
	  echo "SOCAT_PATH = '$(SOCAT)'"; \
914
	  echo "SOCAT_USE_ESCAPE = $(SOCAT_USE_ESCAPE)"; \
915
	  echo "SOCAT_USE_COMPRESS = $(SOCAT_USE_COMPRESS)"; \
916
	  echo "LVM_STRIPECOUNT = $(LVM_STRIPECOUNT)"; \
917
	  echo "TOOLSDIR = '$(toolsdir)'"; \
918
	  echo "GNT_SCRIPTS = [$(foreach i,$(notdir $(gnt_scripts)),'$(i)',)]"; \
919
	  echo "PKGLIBDIR = '$(pkglibdir)'"; \
920
	  echo "DRBD_BARRIERS = $(DRBD_BARRIERS)"; \
921
	  echo "SYSLOG_USAGE = '$(SYSLOG_USAGE)'"; \
922
	  echo "DAEMONS_GROUP = '$(DAEMONS_GROUP)'"; \
923
	  echo "ADMIN_GROUP = '$(ADMIN_GROUP)'"; \
924
	  echo "MASTERD_USER = '$(MASTERD_USER)'"; \
925
	  echo "MASTERD_GROUP = '$(MASTERD_GROUP)'"; \
926
	  echo "RAPI_USER = '$(RAPI_USER)'"; \
927
	  echo "RAPI_GROUP = '$(RAPI_GROUP)'"; \
928
	  echo "CONFD_USER = '$(CONFD_USER)'"; \
929
	  echo "CONFD_GROUP = '$(CONFD_GROUP)'"; \
930
	  echo "NODED_USER = '$(NODED_USER)'"; \
931
	  echo "NODED_GROUP = '$(NODED_GROUP)'"; \
932
	  echo "DISK_SEPARATOR = '$(DISK_SEPARATOR)'"; \
933
	  if [ "$(HTOOLS)" ]; then \
934
	    echo "HTOOLS = True"; \
935
	  else \
936
	    echo "HTOOLS = False"; \
937
	  fi; \
938
	} > $@
939

    
940
lib/_vcsversion.py: Makefile vcs-version | lib/.dir
941
	set -e; \
942
	VCSVER=`cat $(abs_top_srcdir)/vcs-version`; \
943
	{ echo '# This file is automatically generated, do not edit!'; \
944
	  echo '#'; \
945
	  echo ''; \
946
	  echo '"""Build-time VCS version number for Ganeti.'; \
947
	  echo '';\
948
	  echo 'This file is autogenerated by the build process.'; \
949
	  echo 'For any changes you need to re-run ./configure (and'; \
950
	  echo 'not edit by hand).'; \
951
	  echo ''; \
952
	  echo '"""'; \
953
	  echo ''; \
954
	  echo '# pylint: disable-msg=C0301,C0324'; \
955
	  echo '# because this is autogenerated, we do not want'; \
956
	  echo '# style warnings' ; \
957
	  echo ''; \
958
	  echo "VCS_VERSION = '$$VCSVER'"; \
959
	} > $@
960

    
961
$(REPLACE_VARS_SED): Makefile
962
	set -e; \
963
	{ echo 's#@PREFIX@#$(prefix)#g'; \
964
	  echo 's#@SYSCONFDIR@#$(sysconfdir)#g'; \
965
	  echo 's#@LOCALSTATEDIR@#$(localstatedir)#g'; \
966
	  echo 's#@BINDIR@#$(bindir)#g'; \
967
	  echo 's#@SBINDIR@#$(sbindir)#g'; \
968
	  echo 's#@GANETI_VERSION@#$(PACKAGE_VERSION)#g'; \
969
	  echo 's#@CUSTOM_XEN_BOOTLOADER@#$(XEN_BOOTLOADER)#g'; \
970
	  echo 's#@CUSTOM_XEN_KERNEL@#$(XEN_KERNEL)#g'; \
971
	  echo 's#@CUSTOM_XEN_INITRD@#$(XEN_INITRD)#g'; \
972
	  echo 's#@CUSTOM_IALLOCATOR_SEARCH_PATH@#$(IALLOCATOR_SEARCH_PATH)#g'; \
973
	  echo 's#@CUSTOM_EXPORT_DIR@#$(EXPORT_DIR)#g'; \
974
	  echo 's#@RPL_FILE_STORAGE_DIR@#$(FILE_STORAGE_DIR)#g'; \
975
	  echo 's#@RPL_SSH_INITD_SCRIPT@#$(SSH_INITD_SCRIPT)#g'; \
976
	  echo 's#@PKGLIBDIR@#$(pkglibdir)#g'; \
977
	  echo 's#@GNTMASTERUSER@#$(MASTERD_USER)#g'; \
978
	  echo 's#@GNTRAPIUSER@#$(RAPI_USER)#g'; \
979
	  echo 's#@GNTCONFDUSER@#$(CONFD_USER)#g'; \
980
	  echo 's#@GNTNODEDUSER@#$(NODED_USER)#g'; \
981
	  echo 's#@GNTRAPIGROUP@#$(RAPI_GROUP)#g'; \
982
	  echo 's#@GNTADMINGROUP@#$(ADMIN_GROUP)#g'; \
983
	  echo 's#@GNTCONFDGROUP@#$(CONFD_GROUP)#g'; \
984
	  echo 's#@GNTMASTERDGROUP@#$(MASTERD_GROUP)#g'; \
985
	  echo 's#@GNTDAEMONSGROUP@#$(DAEMONS_GROUP)#g'; \
986
	} > $@
987

    
988
# Using deferred evaluation
989
daemons/ganeti-%: MODULE = ganeti.server.$(patsubst ganeti-%,%,$(notdir $@))
990
daemons/ganeti-watcher: MODULE = ganeti.watcher
991
scripts/%: MODULE = ganeti.client.$(subst -,_,$(notdir $@))
992
tools/ensure-dirs: MODULE = ganeti.tools.ensure_dirs
993

    
994
$(PYTHON_BOOTSTRAP): Makefile | $(all_dirfiles)
995
	test -n "$(MODULE)" || { echo Missing module; exit 1; }
996
	set -e; \
997
	{ echo '#!/usr/bin/python'; \
998
	  echo '# This file is automatically generated, do not edit!'; \
999
	  echo "# Edit $(MODULE) instead."; \
1000
	  echo; \
1001
	  echo '"""Bootstrap script for L{$(MODULE)}"""'; \
1002
	  echo; \
1003
	  echo '# pylint: disable-msg=C0103'; \
1004
	  echo '# C0103: Invalid name'; \
1005
	  echo; \
1006
	  echo 'import sys'; \
1007
	  echo 'import $(MODULE) as main'; \
1008
	  echo; \
1009
	  echo '# Temporarily alias commands until bash completion'; \
1010
	  echo '# generator is changed'; \
1011
	  echo 'if hasattr(main, "commands"):'; \
1012
	  echo '  commands = main.commands # pylint: disable-msg=E1101'; \
1013
	  echo 'if hasattr(main, "aliases"):'; \
1014
	  echo '  aliases = main.aliases # pylint: disable-msg=E1101'; \
1015
	  echo; \
1016
	  echo 'if __name__ == "__main__":'; \
1017
	  echo '  sys.exit(main.Main())'; \
1018
	} > $@
1019
	chmod u+x $@
1020

    
1021
# We need to create symlinks because "make distcheck" will not install Python
1022
# files when building.
1023
stamp-srclinks: Makefile | $(all_dirfiles)
1024
	set -e; \
1025
	for i in $(srclink_files); do \
1026
		if test ! -f $$i -a -f $(abs_top_srcdir)/$$i; then \
1027
			$(LN_S) $(abs_top_srcdir)/$$i $$i; \
1028
		fi; \
1029
	done
1030
	touch $@
1031

    
1032
.PHONY: ganeti
1033
ganeti:
1034
	cd $(top_builddir) && test -h "$@" || { rm -f $@ && $(LN_S) lib $@; }
1035

    
1036
.PHONY: check-dirs
1037
check-dirs: $(BUILT_SOURCES)
1038
	@set -e; \
1039
	find . -type d \( \( -name . \) -o \( \
1040
		-name .git -o \
1041
		-name autom4te.cache \
1042
		\) -prune -o -print \) | { \
1043
		error=; \
1044
		while read dir; do \
1045
			case "$$dir" in \
1046
				$(strip $(patsubst %,(./%) ;;,$(DIRCHECK_EXCLUDE) $(DIRS))) \
1047
				*) error=1; echo "Directory $$dir not listed in Makefile" >&2 ;; \
1048
			esac; \
1049
		done; \
1050
		for dir in $(DIRS); do \
1051
			if ! test -d "$$dir"; then \
1052
				echo "Directory $$dir listed in DIRS does not exist" >&2; \
1053
				error=1; \
1054
			fi \
1055
		done; \
1056
		if test -n "$$error"; then exit 1; else exit 0; fi; \
1057
	}
1058

    
1059
.PHONY: check-local
1060
check-local: check-dirs $(BUILT_SOURCES)
1061
	$(CHECK_PYTHON_CODE) $(check_python_code)
1062
	$(CHECK_VERSION) $(VERSION) $(top_srcdir)/NEWS
1063
	$(CHECK_NEWS) < $(top_srcdir)/NEWS
1064
	PYTHONPATH=. $(RUN_IN_TEMPDIR) $(CURDIR)/$(CHECK_IMPORTS) $(CURDIR) $(standalone_python_modules)
1065
	expver=$(VERSION_MAJOR).$(VERSION_MINOR); \
1066
	if test "`head -n 1 $(top_srcdir)/README`" != "Ganeti $$expver"; then \
1067
		echo "Incorrect version in README, expected $$expver"; \
1068
		exit 1; \
1069
	fi; \
1070
	for file in doc/iallocator.rst doc/hooks.rst; do \
1071
		if test "`sed -ne '4 p' $(top_srcdir)/$$file`" != \
1072
		        "Documents Ganeti version $$expver"; then \
1073
			echo "Incorrect version in $$file, expected $$expver"; \
1074
			exit 1; \
1075
		fi; \
1076
	done
1077

    
1078
.PHONY: hs-check
1079
hs-check: htools/test
1080
	@rm -f test.tix
1081
	./htools/test
1082

    
1083
# E111: indentation is not a multiple of four
1084
# E261: at least two spaces before inline comment
1085
# E501: line too long (80 characters)
1086
PEP8_IGNORE = E111,E261,E501
1087

    
1088
# For excluding pep8 expects filenames only, not whole paths
1089
PEP8_EXCLUDE = $(subst $(space),$(comma),$(strip $(notdir $(BUILT_PYTHON_SOURCES))))
1090

    
1091
.PHONY: lint
1092
lint: $(BUILT_SOURCES)
1093
	@test -n "$(PYLINT)" || { echo 'pylint' not found during configure; exit 1; }
1094
	if test -z "$(PEP8)"; then \
1095
		echo '"pep8" not found during configure' >&2; \
1096
	else \
1097
		$(PEP8) --repeat --ignore='$(PEP8_IGNORE)' --exclude='$(PEP8_EXCLUDE)' \
1098
			$(lint_python_code); \
1099
	fi
1100
	$(PYLINT) $(LINT_OPTS) $(lint_python_code)
1101
	cd $(top_srcdir)/qa && \
1102
	  PYTHONPATH=$(abs_top_srcdir) $(PYLINT) $(LINT_OPTS) \
1103
	  --rcfile  ../pylintrc $(patsubst qa/%.py,%,$(qa_scripts))
1104

    
1105
.PHONY: hlint
1106
hlint: $(HS_BUILT_SRCS)
1107
	if tty -s; then C="-c"; else C=""; fi; \
1108
	hlint --report=doc/hs-lint.html $$C htools
1109

    
1110
# a dist hook rule for updating the vcs-version file; this is
1111
# hardcoded due to where it needs to build the file...
1112
dist-hook:
1113
	$(MAKE) regen-vcs-version && \
1114
	rm -f $(top_distdir)/vcs-version && \
1115
	cp -p $(srcdir)/vcs-version $(top_distdir)
1116

    
1117
# a distcheck hook rule for catching revision control directories
1118
distcheck-hook:
1119
	if find $(top_distdir) -name .svn -or -name .git | grep .; then \
1120
		echo "Found revision control files in final archive." 1>&2; \
1121
		exit 1; \
1122
	fi
1123
	if find $(top_distdir) -name '*.py[co]' | grep .; then \
1124
		echo "Found Python byte code in final archive." 1>&2; \
1125
		exit 1; \
1126
	fi
1127
	if find $(top_distdir) -name '*~' | grep .; then \
1128
		echo "Found backup files in final archive." 1>&2; \
1129
		exit 1; \
1130
	fi
1131
# Empty files or directories should not be distributed. They can cause
1132
# unnecessary warnings for packagers. Directories used by automake during
1133
# distcheck must be excluded.
1134
	if find $(top_distdir) -empty -and -not \( \
1135
			-path $(top_distdir)/_build -or \
1136
			-path $(top_distdir)/_inst \) | grep .; then \
1137
		echo "Found empty files or directories in final archive." 1>&2; \
1138
		exit 1; \
1139
	fi
1140
	if test -n "$(BUILD_RELEASE)" && \
1141
	   grep -n -H -E '^\*.*unreleased' $(top_distdir)/NEWS; then \
1142
		echo "Found unreleased version in NEWS." >&2; \
1143
		exit 1; \
1144
	fi
1145

    
1146
# When building a release, stricter checks should be used
1147
distcheck-release dist-release: export BUILD_RELEASE = 1
1148
distcheck-release: distcheck
1149

    
1150
dist-release: dist
1151
	set -e; \
1152
	for i in $(DIST_ARCHIVES); do \
1153
		echo -n "Checking $$i ... "; \
1154
		autotools/check-tar < $$i; \
1155
		echo OK; \
1156
	done
1157

    
1158
install-exec-local:
1159
	@mkdir_p@ "$(DESTDIR)${localstatedir}/lib/ganeti" \
1160
	  "$(DESTDIR)${localstatedir}/log/ganeti" \
1161
	  "$(DESTDIR)${localstatedir}/run/ganeti"
1162

    
1163
# To avoid conflicts between directory names and other targets, a file inside
1164
# the directory is used to ensure its existence.
1165
%.dir:
1166
	@mkdir_p@ $* && touch $@
1167

    
1168
.PHONY: apidoc
1169
if WANT_HTOOLSAPIDOC
1170
apidoc: py-apidoc hs-apidoc
1171
else
1172
apidoc: py-apidoc
1173
endif
1174

    
1175
.PHONY: py-apidoc
1176
py-apidoc: epydoc.conf $(RUN_IN_TEMPDIR) $(BUILT_SOURCES)
1177
	$(RUN_IN_TEMPDIR) epydoc -v \
1178
		--conf $(CURDIR)/epydoc.conf \
1179
		--output $(CURDIR)/$(APIDOC_PY_DIR)
1180

    
1181
.PHONY: hs-apidoc
1182
hs-apidoc: $(HS_BUILT_SRCS)
1183
	@test -n "$(HSCOLOUR)" || \
1184
	    { echo 'HsColour' not found during configure; exit 1; }
1185
	@test -n "$(HADDOCK)" || \
1186
	    { echo 'haddock' not found during configure; exit 1; }
1187
	rm -rf $(APIDOC_HS_DIR)/*
1188
	@mkdir_p@ $(APIDOC_HS_DIR)/Ganeti/HTools/Program
1189
	$(HSCOLOUR) -print-css > $(APIDOC_HS_DIR)/Ganeti/hscolour.css
1190
	ln -s ../hscolour.css $(APIDOC_HS_DIR)/Ganeti/HTools/hscolour.css
1191
	set -e ; \
1192
	cd htools; \
1193
	if [ "$(HTOOLS_NOCURL)" ]; \
1194
	then OPTGHC="--optghc=$(HTOOLS_NOCURL)"; \
1195
	else OPTGHC=""; \
1196
	fi; \
1197
	if [ "$(HTOOLS_PARALLEL3)" ]; \
1198
	then OPTGHC="$$OPTGHC --optghc=$(HTOOLS_PARALLEL3)"; \
1199
	fi; \
1200
	RELSRCS="$(HS_LIB_SRCS:htools/%=%)  $(HS_BUILT_SRCS:htools/%=%)"; \
1201
	for file in $$RELSRCS; do \
1202
		hfile=`echo $$file|sed 's/\\.hs$$//'`.html; \
1203
		$(HSCOLOUR) -css -anchor $$file > ../$(APIDOC_HS_DIR)/$$hfile ; \
1204
	done ; \
1205
	$(HADDOCK) --odir ../$(APIDOC_HS_DIR) --html --ignore-all-exports -w \
1206
		-t ganeti-htools -p haddock-prologue \
1207
		--source-module="%{MODULE/.//}.html" \
1208
		--source-entity="%{MODULE/.//}.html#%{NAME}" \
1209
		$$OPTGHC \
1210
		$(filter-out Ganeti/HTools/ExtLoader.hs,$(HS_LIB_SRCS:htools/%=%))
1211

    
1212
.PHONY: TAGS
1213
TAGS: $(BUILT_SOURCES)
1214
	rm -f TAGS
1215
	find . -path './lib/*.py' -o -path './scripts/gnt-*' -o \
1216
	  -path './daemons/ganeti-*' -o -path './tools/*' -o \
1217
	  -path './qa/*.py' | \
1218
	  etags -l python -
1219

    
1220
.PHONY: coverage
1221
if WANT_HTOOLS
1222
coverage: py-coverage hs-coverage
1223
else
1224
coverage: py-coverage
1225
endif
1226

    
1227
.PHONY: py-coverage
1228
py-coverage: $(BUILT_SOURCES) $(python_tests)
1229
	set -e; \
1230
	COVERAGE_FILE=$(CURDIR)/$(COVERAGE_PY_DIR)/data \
1231
	TEXT_COVERAGE=$(CURDIR)/$(COVERAGE_PY_DIR)/report.txt \
1232
	HTML_COVERAGE=$(CURDIR)/$(COVERAGE_PY_DIR) \
1233
	$(PLAIN_TESTS_ENVIRONMENT) $(abs_top_srcdir)/autotools/gen-coverage \
1234
	$(python_tests)
1235

    
1236
.PHONY: hs-coverage
1237
hs-coverage: $(haskell_tests)
1238
	cd htools && rm -f *.tix *.mix && ./test
1239
	@mkdir_p@ $(COVERAGE_HS_DIR)
1240
	hpc markup --destdir=$(COVERAGE_HS_DIR) htools/test $(HPCEXCL)
1241
	hpc report htools/test $(HPCEXCL)
1242
	ln -sf hpc_index.html $(COVERAGE_HS_DIR)/index.html
1243

    
1244
# Special "kind-of-QA" target for htools, needs special setup (all
1245
# tools compiled with -fhpc)
1246
.PHONY: live-test
1247
live-test: all
1248
	set -e ; \
1249
	cd htools; \
1250
	rm -f .hpc; ln -s ../.hpc .hpc; \
1251
	rm -f *.tix *.mix; \
1252
	./live-test.sh; \
1253
	hpc sum --union $(HPCEXCL) $(addsuffix .tix,$(HS_PROGS:htools/%=%)) \
1254
	  --output=live-test.tix ; \
1255
	@mkdir_p@ ../$(COVERAGE_HS_DIR) ; \
1256
	hpc markup --destdir=../$(COVERAGE_HS_DIR) live-test \
1257
		--srcdir=.. $(HPCEXCL) ; \
1258
	hpc report --srcdir=.. live-test $(HPCEXCL)
1259

    
1260
commit-check: distcheck lint apidoc
1261

    
1262
-include ./Makefile.local
1263

    
1264
# vim: set noet :