Statistics
| Branch: | Tag: | Revision:

root / Makefile.am @ 32683096

History | View | Annotate | Download (46 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_HEADER = $(top_srcdir)/autotools/check-header
25
CHECK_MAN_DASHES = $(top_srcdir)/autotools/check-man-dashes
26
CHECK_MAN_WARNINGS = $(top_srcdir)/autotools/check-man-warnings
27
CHECK_VERSION = $(top_srcdir)/autotools/check-version
28
CHECK_NEWS = $(top_srcdir)/autotools/check-news
29
CHECK_IMPORTS = $(top_srcdir)/autotools/check-imports
30
DOCPP = $(top_srcdir)/autotools/docpp
31
REPLACE_VARS_SED = autotools/replace_vars.sed
32
CONVERT_CONSTANTS = $(top_srcdir)/autotools/convert-constants
33
BUILD_RPC = $(top_srcdir)/autotools/build-rpc
34

    
35
# Note: these are automake-specific variables, and must be named after
36
# the directory + 'dir' suffix
37
clientdir = $(pkgpythondir)/client
38
hypervisordir = $(pkgpythondir)/hypervisor
39
httpdir = $(pkgpythondir)/http
40
masterddir = $(pkgpythondir)/masterd
41
confddir = $(pkgpythondir)/confd
42
rapidir = $(pkgpythondir)/rapi
43
serverdir = $(pkgpythondir)/server
44
watcherdir = $(pkgpythondir)/watcher
45
impexpddir = $(pkgpythondir)/impexpd
46
utilsdir = $(pkgpythondir)/utils
47
toolsdir = $(pkglibdir)/tools
48
iallocatorsdir = $(pkglibdir)/iallocators
49
pytoolsdir = $(pkgpythondir)/tools
50
docdir = $(datadir)/doc/$(PACKAGE)
51
myexeclibdir = $(pkglibdir)
52

    
53
# Delete output file if an error occurred while building it
54
.DELETE_ON_ERROR:
55

    
56
HTOOLS_DIRS = \
57
	htools \
58
	htools/Ganeti \
59
	htools/Ganeti/Confd \
60
	htools/Ganeti/HTools \
61
	htools/Ganeti/HTools/Program \
62
	htools/Ganeti/Query \
63
	htest \
64
	htest/Test \
65
	htest/Test/Ganeti \
66
	htest/Test/Ganeti/Confd \
67
	htest/Test/Ganeti/HTools \
68
	htest/Test/Ganeti/Query
69

    
70
DIRS = \
71
	autotools \
72
	daemons \
73
	devel \
74
	doc \
75
	doc/examples \
76
	doc/examples/hooks \
77
	doc/examples/gnt-debug \
78
	$(HTOOLS_DIRS) \
79
	lib \
80
	lib/client \
81
	lib/build \
82
	lib/confd \
83
	lib/http \
84
	lib/hypervisor \
85
	lib/impexpd \
86
	lib/masterd \
87
	lib/rapi \
88
	lib/server \
89
	lib/tools \
90
	lib/utils \
91
	lib/watcher \
92
	man \
93
	qa \
94
	test \
95
	test/data \
96
	test/data/ovfdata \
97
	test/data/ovfdata/other \
98
	htest/data \
99
	htest/data/rapi \
100
	htest/shelltests \
101
	tools
102

    
103
BUILDTIME_DIR_AUTOCREATE = \
104
	scripts \
105
	$(APIDOC_DIR) \
106
	$(APIDOC_PY_DIR) \
107
	$(APIDOC_HS_DIR) \
108
	$(APIDOC_HS_DIR)/Ganeti \
109
	$(APIDOC_HS_DIR)/Ganeti/Confd \
110
	$(APIDOC_HS_DIR)/Ganeti/HTools \
111
	$(APIDOC_HS_DIR)/Ganeti/HTools/Program \
112
	$(APIDOC_HS_DIR)/Ganeti/Query \
113
	$(COVERAGE_DIR) \
114
	$(COVERAGE_PY_DIR) \
115
	$(COVERAGE_HS_DIR) \
116
	.hpc
117

    
118
BUILDTIME_DIRS = \
119
	$(BUILDTIME_DIR_AUTOCREATE) \
120
	doc/html
121

    
122
DIRCHECK_EXCLUDE = \
123
	$(BUILDTIME_DIRS) \
124
	ganeti-[0-9]*.[0-9]*.[0-9]* \
125
	doc/html/_*
126

    
127
# some helper vars
128
COVERAGE_DIR = doc/coverage
129
COVERAGE_PY_DIR = $(COVERAGE_DIR)/py
130
COVERAGE_HS_DIR = $(COVERAGE_DIR)/hs
131
APIDOC_DIR = doc/api
132
APIDOC_PY_DIR = $(APIDOC_DIR)/py
133
APIDOC_HS_DIR = $(APIDOC_DIR)/hs
134

    
135
MAINTAINERCLEANFILES = \
136
	$(docpng) \
137
	$(maninput) \
138
	doc/install-quick.rst \
139
	doc/news.rst \
140
	doc/upgrade.rst \
141
	vcs-version
142

    
143
maintainer-clean-local:
144
	rm -rf $(BUILDTIME_DIRS)
145

    
146
CLEANFILES = \
147
	$(addsuffix /*.py[co],$(DIRS)) \
148
	$(addsuffix /*.hi,$(HTOOLS_DIRS)) \
149
	$(addsuffix /*.o,$(HTOOLS_DIRS)) \
150
	$(PYTHON_BOOTSTRAP) \
151
	epydoc.conf \
152
	$(REPLACE_VARS_SED) \
153
	daemons/daemon-util \
154
	daemons/ganeti-cleaner \
155
	devel/upload \
156
	$(BUILT_EXAMPLES) \
157
	doc/examples/bash_completion \
158
	lib/_generated_rpc.py \
159
	$(man_MANS) \
160
	$(manhtml) \
161
	tools/kvm-ifup \
162
	stamp-directories \
163
	stamp-srclinks \
164
	$(nodist_pkgpython_PYTHON) \
165
	$(HS_ALL_PROGS) $(HS_BUILT_SRCS) \
166
	$(HS_BUILT_TEST_HELPERS) \
167
	.hpc/*.mix htools/*.tix htest/*.tix \
168
	doc/hs-lint.html
169

    
170
GENERATED_FILES = \
171
	$(built_base_sources) \
172
	$(BUILT_PYTHON_SOURCES) \
173
	$(PYTHON_BOOTSTRAP)
174

    
175
built_base_sources = \
176
	stamp-directories \
177
	stamp-srclinks
178

    
179
built_python_base_sources = \
180
	lib/_autoconf.py \
181
	lib/_vcsversion.py
182

    
183
BUILT_PYTHON_SOURCES = \
184
	$(built_python_base_sources) \
185
	lib/_generated_rpc.py
186

    
187
# Generating the RPC wrappers depends on many things, so make sure
188
# it's built at the end of the built sources
189
lib/_generated_rpc.py: | $(built_base_sources) $(built_python_base_sources)
190

    
191
# these are all built from the underlying %.in sources
192
BUILT_EXAMPLES = \
193
	doc/examples/ganeti-kvm-poweroff.initd \
194
	doc/examples/ganeti.cron \
195
	doc/examples/ganeti.initd \
196
	doc/examples/gnt-config-backup \
197
	doc/examples/hooks/ipsec
198

    
199
nodist_pkgpython_PYTHON = \
200
	$(BUILT_PYTHON_SOURCES)
201

    
202
noinst_PYTHON = \
203
	lib/build/__init__.py \
204
	lib/build/sphinx_ext.py \
205
	lib/build/shell_example_lexer.py
206

    
207
pkgpython_PYTHON = \
208
	lib/__init__.py \
209
	lib/asyncnotifier.py \
210
	lib/backend.py \
211
	lib/bdev.py \
212
	lib/bootstrap.py \
213
	lib/cli.py \
214
	lib/cmdlib.py \
215
	lib/compat.py \
216
	lib/config.py \
217
	lib/constants.py \
218
	lib/daemon.py \
219
	lib/errors.py \
220
	lib/ht.py \
221
	lib/jqueue.py \
222
	lib/jstore.py \
223
	lib/locking.py \
224
	lib/luxi.py \
225
	lib/mcpu.py \
226
	lib/netutils.py \
227
	lib/objects.py \
228
	lib/objectutils.py \
229
	lib/opcodes.py \
230
	lib/ovf.py \
231
	lib/qlang.py \
232
	lib/query.py \
233
	lib/rpc.py \
234
	lib/rpc_defs.py \
235
	lib/runtime.py \
236
	lib/serializer.py \
237
	lib/ssconf.py \
238
	lib/ssh.py \
239
	lib/storage.py \
240
	lib/uidpool.py \
241
	lib/workerpool.py
242

    
243
client_PYTHON = \
244
	lib/client/__init__.py \
245
	lib/client/gnt_backup.py \
246
	lib/client/gnt_cluster.py \
247
	lib/client/gnt_debug.py \
248
	lib/client/gnt_group.py \
249
	lib/client/gnt_instance.py \
250
	lib/client/gnt_job.py \
251
	lib/client/gnt_node.py \
252
	lib/client/gnt_os.py
253

    
254
hypervisor_PYTHON = \
255
	lib/hypervisor/__init__.py \
256
	lib/hypervisor/hv_base.py \
257
	lib/hypervisor/hv_chroot.py \
258
	lib/hypervisor/hv_fake.py \
259
	lib/hypervisor/hv_kvm.py \
260
	lib/hypervisor/hv_lxc.py \
261
	lib/hypervisor/hv_xen.py
262

    
263
rapi_PYTHON = \
264
	lib/rapi/__init__.py \
265
	lib/rapi/baserlib.py \
266
	lib/rapi/client.py \
267
	lib/rapi/client_utils.py \
268
	lib/rapi/connector.py \
269
	lib/rapi/rlib2.py \
270
	lib/rapi/testutils.py
271

    
272
http_PYTHON = \
273
	lib/http/__init__.py \
274
	lib/http/auth.py \
275
	lib/http/client.py \
276
	lib/http/server.py
277

    
278
confd_PYTHON = \
279
	lib/confd/__init__.py \
280
	lib/confd/client.py \
281
	lib/confd/querylib.py \
282
	lib/confd/server.py
283

    
284
masterd_PYTHON = \
285
	lib/masterd/__init__.py \
286
	lib/masterd/instance.py
287

    
288
impexpd_PYTHON = \
289
	lib/impexpd/__init__.py
290

    
291
watcher_PYTHON = \
292
	lib/watcher/__init__.py \
293
	lib/watcher/nodemaint.py \
294
	lib/watcher/state.py
295

    
296
server_PYTHON = \
297
	lib/server/__init__.py \
298
	lib/server/confd.py \
299
	lib/server/masterd.py \
300
	lib/server/noded.py \
301
	lib/server/rapi.py
302

    
303
pytools_PYTHON = \
304
	lib/tools/__init__.py \
305
	lib/tools/ensure_dirs.py
306

    
307
utils_PYTHON = \
308
	lib/utils/__init__.py \
309
	lib/utils/algo.py \
310
	lib/utils/filelock.py \
311
	lib/utils/hash.py \
312
	lib/utils/io.py \
313
	lib/utils/log.py \
314
	lib/utils/mlock.py \
315
	lib/utils/nodesetup.py \
316
	lib/utils/process.py \
317
	lib/utils/retry.py \
318
	lib/utils/text.py \
319
	lib/utils/wrapper.py \
320
	lib/utils/x509.py
321

    
322
docrst = \
323
	doc/admin.rst \
324
	doc/design-2.0.rst \
325
	doc/design-2.1.rst \
326
	doc/design-2.2.rst \
327
	doc/design-2.3.rst \
328
	doc/design-htools-2.3.rst \
329
	doc/design-2.4.rst \
330
	doc/design-2.5.rst \
331
	doc/design-draft.rst \
332
	doc/design-oob.rst \
333
	doc/design-cpu-pinning.rst \
334
	doc/design-query2.rst \
335
	doc/design-x509-ca.rst \
336
	doc/design-http-server.rst \
337
	doc/design-impexp2.rst \
338
	doc/design-lu-generated-jobs.rst \
339
	doc/design-multi-reloc.rst \
340
	doc/design-network.rst \
341
	doc/design-chained-jobs.rst \
342
	doc/design-ovf-support.rst \
343
	doc/design-autorepair.rst \
344
	doc/design-resource-model.rst \
345
	doc/cluster-merge.rst \
346
	doc/design-shared-storage.rst \
347
	doc/design-node-state-cache.rst \
348
	doc/design-virtual-clusters.rst \
349
	doc/design-bulk-create.rst \
350
	doc/design-query-splitting.rst \
351
	doc/devnotes.rst \
352
	doc/glossary.rst \
353
	doc/hooks.rst \
354
	doc/iallocator.rst \
355
	doc/index.rst \
356
	doc/install-quick.rst \
357
	doc/install.rst \
358
	doc/locking.rst \
359
	doc/move-instance.rst \
360
	doc/news.rst \
361
	doc/ovfconverter.rst \
362
	doc/rapi.rst \
363
	doc/security.rst \
364
	doc/upgrade.rst \
365
	doc/walkthrough.rst
366

    
367
HS_PROGS = htools/htools
368
HS_BIN_ROLES = hbal hscan hspace hinfo hcheck
369

    
370
HS_ALL_PROGS = $(HS_PROGS) htest/test htest/hpc-htools htools/hconfd
371
HS_PROG_SRCS = $(patsubst %,%.hs,$(HS_ALL_PROGS))
372
HS_BUILT_TEST_HELPERS = $(HS_BIN_ROLES:%=htest/%) htest/hail
373

    
374
HFLAGS = -O -Wall -Werror -fwarn-monomorphism-restriction -fwarn-tabs -ihtools
375
# extra flags that can be overriden on the command line (e.g. -Wwarn, etc.)
376
HEXTRA =
377
# internal extra flags (used for htest/test mainly)
378
HEXTRA_INT =
379
# exclude options for coverage reports
380
HPCEXCL = --exclude Main \
381
	--exclude Ganeti.Constants \
382
	--exclude Ganeti.THH \
383
	--exclude Ganeti.HTools.QC \
384
	--exclude Ganeti.Version \
385
	--exclude Test.Ganeti.TestCommon \
386
	--exclude Test.Ganeti.TestHTools \
387
	--exclude Test.Ganeti.TestHelper \
388
	--exclude Test.Ganeti.TestImports \
389
	$(patsubst htools.%,--exclude Test.%,$(subst /,.,$(patsubst %.hs,%, $(HS_LIB_SRCS))))
390

    
391
HS_LIB_SRCS = \
392
	htools/Ganeti/HTools/CLI.hs \
393
	htools/Ganeti/HTools/Cluster.hs \
394
	htools/Ganeti/HTools/Container.hs \
395
	htools/Ganeti/HTools/ExtLoader.hs \
396
	htools/Ganeti/HTools/Group.hs \
397
	htools/Ganeti/HTools/IAlloc.hs \
398
	htools/Ganeti/HTools/Instance.hs \
399
	htools/Ganeti/HTools/Loader.hs \
400
	htools/Ganeti/HTools/Luxi.hs \
401
	htools/Ganeti/HTools/Node.hs \
402
	htools/Ganeti/HTools/PeerMap.hs \
403
	htools/Ganeti/HTools/Rapi.hs \
404
	htools/Ganeti/HTools/Simu.hs \
405
	htools/Ganeti/HTools/Text.hs \
406
	htools/Ganeti/HTools/Types.hs \
407
	htools/Ganeti/HTools/Utils.hs \
408
	htools/Ganeti/HTools/Program.hs \
409
	htools/Ganeti/HTools/Program/Hail.hs \
410
	htools/Ganeti/HTools/Program/Hbal.hs \
411
	htools/Ganeti/HTools/Program/Hcheck.hs \
412
	htools/Ganeti/HTools/Program/Hinfo.hs \
413
	htools/Ganeti/HTools/Program/Hscan.hs \
414
	htools/Ganeti/HTools/Program/Hspace.hs \
415
	htools/Ganeti/BasicTypes.hs \
416
	htools/Ganeti/Common.hs \
417
	htools/Ganeti/Compat.hs \
418
	htools/Ganeti/Confd.hs \
419
	htools/Ganeti/Confd/Server.hs \
420
	htools/Ganeti/Confd/Utils.hs \
421
	htools/Ganeti/Config.hs \
422
	htools/Ganeti/Daemon.hs \
423
	htools/Ganeti/Hash.hs \
424
	htools/Ganeti/Jobs.hs \
425
	htools/Ganeti/JSON.hs \
426
	htools/Ganeti/Logging.hs \
427
	htools/Ganeti/Luxi.hs \
428
	htools/Ganeti/Objects.hs \
429
	htools/Ganeti/OpCodes.hs \
430
	htools/Ganeti/Query/Common.hs \
431
	htools/Ganeti/Query/Filter.hs \
432
	htools/Ganeti/Query/Language.hs \
433
	htools/Ganeti/Query/Node.hs \
434
	htools/Ganeti/Query/Query.hs \
435
	htools/Ganeti/Query/Server.hs \
436
	htools/Ganeti/Query/Types.hs \
437
	htools/Ganeti/Rpc.hs \
438
	htools/Ganeti/Runtime.hs \
439
	htools/Ganeti/Ssconf.hs \
440
	htools/Ganeti/THH.hs
441

    
442
HS_TEST_SRCS = \
443
	htest/Test/Ganeti/BasicTypes.hs \
444
	htest/Test/Ganeti/Common.hs \
445
	htest/Test/Ganeti/Daemon.hs \
446
	htest/Test/Ganeti/Confd/Utils.hs \
447
	htest/Test/Ganeti/HTools/CLI.hs \
448
	htest/Test/Ganeti/HTools/Cluster.hs \
449
	htest/Test/Ganeti/HTools/Container.hs \
450
	htest/Test/Ganeti/HTools/Instance.hs \
451
	htest/Test/Ganeti/HTools/Loader.hs \
452
	htest/Test/Ganeti/HTools/Node.hs \
453
	htest/Test/Ganeti/HTools/PeerMap.hs \
454
	htest/Test/Ganeti/HTools/Simu.hs \
455
	htest/Test/Ganeti/HTools/Text.hs \
456
	htest/Test/Ganeti/HTools/Types.hs \
457
	htest/Test/Ganeti/HTools/Utils.hs \
458
	htest/Test/Ganeti/JSON.hs \
459
	htest/Test/Ganeti/Jobs.hs \
460
	htest/Test/Ganeti/Luxi.hs \
461
	htest/Test/Ganeti/Objects.hs \
462
	htest/Test/Ganeti/OpCodes.hs \
463
	htest/Test/Ganeti/Query/Filter.hs \
464
	htest/Test/Ganeti/Query/Language.hs \
465
	htest/Test/Ganeti/Query/Query.hs \
466
	htest/Test/Ganeti/Rpc.hs \
467
	htest/Test/Ganeti/Ssconf.hs \
468
	htest/Test/Ganeti/TestCommon.hs \
469
	htest/Test/Ganeti/TestHTools.hs \
470
	htest/Test/Ganeti/TestHelper.hs
471

    
472
HS_LIBTEST_SRCS = $(HS_LIB_SRCS) $(HS_TEST_SRCS)
473

    
474
HS_BUILT_SRCS = \
475
	htest/Test/Ganeti/TestImports.hs \
476
	htools/Ganeti/Constants.hs \
477
	htools/Ganeti/Version.hs
478
HS_BUILT_SRCS_IN = $(patsubst %,%.in,$(HS_BUILT_SRCS))
479

    
480
$(RUN_IN_TEMPDIR): | stamp-directories
481

    
482
# Note: we use here an order-only prerequisite, as the contents of
483
# _autoconf.py are not actually influencing the html build output: it
484
# has to exist in order for the sphinx module to be loaded
485
# successfully, but we certainly don't want the docs to be rebuilt if
486
# it changes
487
doc/html/index.html: $(docrst) $(docpng) doc/conf.py configure.ac \
488
	$(RUN_IN_TEMPDIR) lib/build/sphinx_ext.py \
489
	lib/build/shell_example_lexer.py lib/opcodes.py lib/ht.py \
490
	| $(BUILT_PYTHON_SOURCES)
491
	@test -n "$(SPHINX)" || \
492
	    { echo 'sphinx-build' not found during configure; exit 1; }
493
	@mkdir_p@ $(dir $@)
494
	PYTHONPATH=. $(RUN_IN_TEMPDIR) $(SPHINX) -q -W -b html \
495
	    -d . \
496
	    -D version="$(VERSION_MAJOR).$(VERSION_MINOR)" \
497
	    -D release="$(PACKAGE_VERSION)" \
498
	    $(abs_top_srcdir)/doc $(CURDIR)/doc/html
499
	rm -f doc/html/.buildinfo doc/html/objects.inv
500
	touch $@
501

    
502
doc/html: doc/html/index.html
503

    
504
doc/install-quick.rst: INSTALL
505
doc/news.rst: NEWS
506
doc/upgrade.rst: UPGRADE
507

    
508
doc/install-quick.rst doc/news.rst doc/upgrade.rst:
509
	set -e; \
510
	{ echo '.. This file is automatically updated at build time from $<.'; \
511
	  echo '.. Do not edit.'; \
512
	  echo; \
513
	  cat $<; \
514
	} > $@
515

    
516
docdot = \
517
	doc/arch-2.0.dot \
518
	doc/design-2.1-lock-acquire.dot \
519
	doc/design-2.1-lock-release.dot
520

    
521
docpng = $(patsubst %.dot,%.png,$(docdot))
522

    
523
# Things to build but not to install (add it to EXTRA_DIST if it should be
524
# distributed)
525
noinst_DATA = \
526
	devel/upload \
527
	doc/html \
528
	$(BUILT_EXAMPLES) \
529
	doc/examples/bash_completion \
530
	$(manhtml)
531

    
532
gnt_scripts = \
533
	scripts/gnt-backup \
534
	scripts/gnt-cluster \
535
	scripts/gnt-debug \
536
	scripts/gnt-group \
537
	scripts/gnt-instance \
538
	scripts/gnt-job \
539
	scripts/gnt-node \
540
	scripts/gnt-os
541

    
542
PYTHON_BOOTSTRAP_SBIN = \
543
	daemons/ganeti-masterd \
544
	daemons/ganeti-noded \
545
	daemons/ganeti-watcher \
546
	daemons/ganeti-rapi \
547
	$(gnt_scripts)
548

    
549
if PY_CONFD
550
PYTHON_BOOTSTRAP_SBIN += daemons/ganeti-confd
551
endif
552

    
553
PYTHON_BOOTSTRAP = \
554
	$(PYTHON_BOOTSTRAP_SBIN) \
555
	tools/ensure-dirs
556

    
557
qa_scripts = \
558
	qa/__init__.py \
559
	qa/ganeti-qa.py \
560
	qa/qa_cluster.py \
561
	qa/qa_config.py \
562
	qa/qa_daemon.py \
563
	qa/qa_env.py \
564
	qa/qa_error.py \
565
	qa/qa_group.py \
566
	qa/qa_instance.py \
567
	qa/qa_job.py \
568
	qa/qa_node.py \
569
	qa/qa_os.py \
570
	qa/qa_rapi.py \
571
	qa/qa_tags.py \
572
	qa/qa_utils.py
573

    
574
bin_SCRIPTS =
575
if WANT_HTOOLS
576
bin_SCRIPTS += $(filter-out htools/hail,$(HS_PROGS))
577
install-exec-hook:
578
	@mkdir_p@ $(DESTDIR)$(iallocatorsdir)
579
# FIXME: this is a hardcoded logic, instead of auto-resolving
580
	$(LN_S) -f ../../../bin/htools \
581
		   $(DESTDIR)$(iallocatorsdir)/hail
582
	for role in $(HS_BIN_ROLES); do \
583
		$(LN_S) -f htools \
584
			   $(DESTDIR)$(bindir)/$$role ; \
585
	done
586
if HS_CONFD
587
	mv $(DESTDIR)$(sbindir)/hconfd $(DESTDIR)$(sbindir)/ganeti-confd
588
endif
589
endif
590

    
591
$(HS_ALL_PROGS): %: %.hs $(HS_LIBTEST_SRCS) $(HS_BUILT_SRCS) Makefile
592
	@if [ -z "$(HTOOLS)" ]; then \
593
	  echo "Error: htools compilation disabled at configure time" 1>&2 ;\
594
	  exit 1; \
595
	fi
596
	@if [ "$(notdir $@)" = "test" ] && [ -z "$(GHC_PKG_QUICKCHECK)" ]; then \
597
	  echo "Error: cannot run unittests without the QuickCheck library (see devnotes.rst)" 1>&2; \
598
	  exit 1; \
599
	fi
600
	@rm -f $(notdir $@).tix
601
	$(GHC) --make \
602
	  $(HFLAGS) \
603
	  $(HTOOLS_NOCURL) $(HTOOLS_PARALLEL3) \
604
	  -osuf $(notdir $@).o -hisuf $(notdir $@).hi \
605
	  $(HEXTRA) $(HEXTRA_INT) $@
606
	@touch "$@"
607

    
608
# for the htest/test binary, we need to enable profiling/coverage
609
htest/test: HEXTRA_INT=-fhpc -ihtest
610

    
611
# we compile the hpc-htools binary with the program coverage
612
htest/hpc-htools: HEXTRA_INT=-fhpc
613

    
614
# test dependency
615
htest/offline-tests.sh: htest/hpc-htools
616

    
617
# rules for building profiling-enabled versions of the haskell
618
# programs: hs-prof does the full two-step build, whereas
619
# hs-prof-quick does only the final rebuild (hs-prof must have been
620
# run before)
621
.PHONY: hs-prof hs-prof-quick
622
hs-prof:
623
	$(MAKE) $(AM_MAKEFLAGS) clean
624
	$(MAKE) $(AM_MAKEFLAGS) $(HS_ALL_PROGS) HEXTRA="-osuf .o"
625
	rm -f $(HS_ALL_PROGS)
626
	$(MAKE) $(AM_MAKEFLAGS) hs-prof-quick
627

    
628
hs-prof-quick:
629
	$(MAKE) $(AM_MAKEFLAGS) $(HS_ALL_PROGS) HEXTRA="-osuf .prof_o -prof -auto-all"
630

    
631
dist_sbin_SCRIPTS = \
632
	tools/ganeti-listrunner
633

    
634
nodist_sbin_SCRIPTS = \
635
	$(PYTHON_BOOTSTRAP_SBIN) \
636
	daemons/ganeti-cleaner
637

    
638
if HS_CONFD
639
nodist_sbin_SCRIPTS += htools/hconfd
640
endif
641

    
642
python_scripts = \
643
	tools/burnin \
644
	tools/cfgshell \
645
	tools/cfgupgrade \
646
	tools/cfgupgrade12 \
647
	tools/cluster-merge \
648
	tools/confd-client \
649
	tools/fmtjson \
650
	tools/lvmstrap \
651
	tools/move-instance \
652
	tools/ovfconverter \
653
	tools/setup-ssh \
654
	tools/sanitize-config
655

    
656
dist_tools_SCRIPTS = \
657
	$(python_scripts) \
658
	tools/kvm-console-wrapper \
659
	tools/xm-console-wrapper \
660
	tools/master-ip-setup
661

    
662
pkglib_python_scripts = \
663
	daemons/import-export \
664
	tools/check-cert-expired
665

    
666
nodist_pkglib_python_scripts = \
667
	tools/ensure-dirs
668

    
669
myexeclib_SCRIPTS = \
670
	daemons/daemon-util \
671
	tools/kvm-ifup \
672
	$(pkglib_python_scripts)
673

    
674
nodist_myexeclib_SCRIPTS = \
675
	$(nodist_pkglib_python_scripts)
676

    
677
EXTRA_DIST = \
678
	NEWS \
679
	UPGRADE \
680
	epydoc.conf.in \
681
	pylintrc \
682
	autotools/build-bash-completion \
683
	autotools/build-rpc \
684
	autotools/check-header \
685
	autotools/check-python-code \
686
	autotools/check-imports \
687
	autotools/check-man-dashes \
688
	autotools/check-man-warnings \
689
	autotools/check-news \
690
	autotools/check-tar \
691
	autotools/check-version \
692
	autotools/convert-constants \
693
	autotools/docpp \
694
	autotools/gen-coverage \
695
	autotools/testrunner \
696
	autotools/wrong-hardcoded-paths \
697
	$(RUN_IN_TEMPDIR) \
698
	daemons/daemon-util.in \
699
	daemons/ganeti-cleaner.in \
700
	$(pkglib_python_scripts) \
701
	devel/upload.in \
702
	tools/kvm-ifup.in \
703
	$(docdot) \
704
	$(docpng) \
705
	$(docrst) \
706
	doc/conf.py \
707
	doc/html \
708
	$(BUILT_EXAMPLES:%=%.in) \
709
	doc/examples/ganeti.default \
710
	doc/examples/ganeti.default-debug \
711
	doc/examples/hooks/ethers \
712
	doc/examples/gnt-debug/README \
713
	doc/examples/gnt-debug/delay0.json \
714
	doc/examples/gnt-debug/delay50.json \
715
	test/lockperf.py \
716
	test/testutils.py \
717
	test/mocks.py \
718
	$(dist_TESTS) \
719
	$(TEST_FILES) \
720
	man/footer.rst \
721
	$(manrst) \
722
	$(maninput) \
723
	qa/qa-sample.json \
724
	$(qa_scripts) \
725
	$(HS_LIBTEST_SRCS) $(HS_BUILT_SRCS_IN) \
726
	$(HS_PROG_SRCS) \
727
	htools/lint-hints.hs \
728
	htest/cli-tests-defs.sh \
729
	htest/offline-test.sh
730

    
731
man_MANS = \
732
	man/ganeti.7 \
733
	man/ganeti-cleaner.8 \
734
	man/ganeti-confd.8 \
735
	man/ganeti-listrunner.8 \
736
	man/ganeti-masterd.8 \
737
	man/ganeti-noded.8 \
738
	man/ganeti-os-interface.7 \
739
	man/ganeti-rapi.8 \
740
	man/ganeti-watcher.8 \
741
	man/gnt-backup.8 \
742
	man/gnt-cluster.8 \
743
	man/gnt-debug.8 \
744
	man/gnt-group.8 \
745
	man/gnt-instance.8 \
746
	man/gnt-job.8 \
747
	man/gnt-node.8 \
748
	man/gnt-os.8 \
749
	man/hail.1 \
750
	man/hbal.1 \
751
	man/hcheck.1 \
752
	man/hinfo.1 \
753
	man/hscan.1 \
754
	man/hspace.1 \
755
	man/htools.1
756

    
757
manrst = $(patsubst %.1,%.rst,$(patsubst %.7,%.rst,$(patsubst %.8,%.rst,$(man_MANS))))
758
manhtml = $(patsubst %.rst,%.html,$(manrst))
759
mangen = $(patsubst %.rst,%.gen,$(manrst))
760
maninput = \
761
	$(patsubst %.1,%.1.in,$(patsubst %.7,%.7.in,$(patsubst %.8,%.8.in,$(man_MANS)))) \
762
	$(patsubst %.html,%.html.in,$(manhtml)) \
763
	man/footer.man man/footer.html $(mangen)
764

    
765
TEST_FILES = \
766
	test/data/bdev-drbd-8.0.txt \
767
	test/data/bdev-drbd-8.3.txt \
768
	test/data/bdev-drbd-disk.txt \
769
	test/data/bdev-drbd-net-ip4.txt \
770
	test/data/bdev-drbd-net-ip6.txt \
771
	test/data/cert1.pem \
772
	test/data/ip-addr-show-dummy0.txt \
773
	test/data/ip-addr-show-lo-ipv4.txt \
774
	test/data/ip-addr-show-lo-ipv6.txt \
775
	test/data/ip-addr-show-lo-oneline-ipv4.txt \
776
	test/data/ip-addr-show-lo-oneline-ipv6.txt \
777
	test/data/ip-addr-show-lo-oneline.txt \
778
	test/data/ip-addr-show-lo.txt \
779
	test/data/proc_drbd8.txt \
780
	test/data/proc_drbd80-emptyline.txt \
781
	test/data/proc_drbd83.txt \
782
	test/data/proc_drbd83_sync.txt \
783
	test/data/proc_drbd83_sync_krnl2.6.39.txt \
784
	test/data/kvm_1.0_help.txt \
785
	test/data/kvm_0.15.90_help.txt \
786
	test/data/kvm_0.12.5_help.txt \
787
	test/data/kvm_0.9.1_help.txt \
788
	test/data/sys_drbd_usermode_helper.txt \
789
	test/data/ovfdata/compr_disk.vmdk.gz \
790
	test/data/ovfdata/config.ini \
791
	test/data/ovfdata/corrupted_resources.ovf \
792
	test/data/ovfdata/empty.ini \
793
	test/data/ovfdata/empty.ovf \
794
	test/data/ovfdata/ganeti.mf \
795
	test/data/ovfdata/ganeti.ovf \
796
	test/data/ovfdata/gzip_disk.ovf \
797
	test/data/ovfdata/new_disk.vmdk \
798
	test/data/ovfdata/no_disk.ini \
799
	test/data/ovfdata/no_disk_in_ref.ovf \
800
	test/data/ovfdata/no_os.ini \
801
	test/data/ovfdata/no_ovf.ova \
802
	test/data/ovfdata/ova.ova \
803
	test/data/ovfdata/second_disk.vmdk \
804
	test/data/ovfdata/rawdisk.raw \
805
	test/data/ovfdata/unsafe_path.ini \
806
	test/data/ovfdata/virtualbox.ovf \
807
	test/data/ovfdata/wrong_extension.ovd \
808
	test/data/ovfdata/wrong_config.ini \
809
	test/data/ovfdata/wrong_manifest.mf \
810
	test/data/ovfdata/wrong_manifest.ovf \
811
	test/data/ovfdata/wrong_ova.ova \
812
	test/data/ovfdata/wrong_xml.ovf \
813
	test/data/ovfdata/other/rawdisk.raw \
814
	test/data/vgreduce-removemissing-2.02.02.txt \
815
	test/data/vgreduce-removemissing-2.02.66-fail.txt \
816
	test/data/vgreduce-removemissing-2.02.66-ok.txt \
817
	test/data/vgs-missing-pvs-2.02.02.txt \
818
	test/data/vgs-missing-pvs-2.02.66.txt \
819
	test/import-export_unittest-helper \
820
	test/gnt-cli.test \
821
	test/ganeti-cli.test \
822
	htest/shelltests/htools-balancing.test \
823
	htest/shelltests/htools-basic.test \
824
	htest/shelltests/htools-dynutil.test \
825
	htest/shelltests/htools-excl.test \
826
	htest/shelltests/htools-hail.test \
827
	htest/shelltests/htools-hspace.test \
828
	htest/shelltests/htools-invalid.test \
829
	htest/shelltests/htools-multi-group.test \
830
	htest/shelltests/htools-no-backend.test \
831
	htest/shelltests/htools-rapi.test \
832
	htest/shelltests/htools-single-group.test \
833
	htest/shelltests/htools-text-backend.test \
834
	htest/data/hail-alloc-drbd.json \
835
	htest/data/hail-change-group.json \
836
	htest/data/hail-invalid-reloc.json \
837
	htest/data/hail-node-evac.json \
838
	htest/data/hail-reloc-drbd.json \
839
	htest/data/hbal-split-insts.data \
840
	htest/data/common-suffix.data \
841
	htest/data/invalid-node.data \
842
	htest/data/missing-resources.data \
843
	htest/data/rapi/groups.json \
844
	htest/data/rapi/info.json \
845
	htest/data/rapi/instances.json \
846
	htest/data/rapi/nodes.json
847

    
848
python_tests = \
849
	doc/examples/rapi_testutils.py \
850
	test/ganeti.asyncnotifier_unittest.py \
851
	test/ganeti.backend_unittest.py \
852
	test/ganeti.bdev_unittest.py \
853
	test/ganeti.cli_unittest.py \
854
	test/ganeti.client.gnt_cluster_unittest.py \
855
	test/ganeti.client.gnt_instance_unittest.py \
856
	test/ganeti.daemon_unittest.py \
857
	test/ganeti.cmdlib_unittest.py \
858
	test/ganeti.compat_unittest.py \
859
	test/ganeti.confd.client_unittest.py \
860
	test/ganeti.config_unittest.py \
861
	test/ganeti.constants_unittest.py \
862
	test/ganeti.errors_unittest.py \
863
	test/ganeti.hooks_unittest.py \
864
	test/ganeti.ht_unittest.py \
865
	test/ganeti.http_unittest.py \
866
	test/ganeti.hypervisor_unittest.py \
867
	test/ganeti.hypervisor.hv_chroot_unittest.py \
868
	test/ganeti.hypervisor.hv_fake_unittest.py \
869
	test/ganeti.hypervisor.hv_kvm_unittest.py \
870
	test/ganeti.hypervisor.hv_lxc_unittest.py \
871
	test/ganeti.hypervisor.hv_xen_unittest.py \
872
	test/ganeti.impexpd_unittest.py \
873
	test/ganeti.jqueue_unittest.py \
874
	test/ganeti.jstore_unittest.py \
875
	test/ganeti.locking_unittest.py \
876
	test/ganeti.luxi_unittest.py \
877
	test/ganeti.masterd.instance_unittest.py \
878
	test/ganeti.mcpu_unittest.py \
879
	test/ganeti.netutils_unittest.py \
880
	test/ganeti.objects_unittest.py \
881
	test/ganeti.objectutils_unittest.py \
882
	test/ganeti.opcodes_unittest.py \
883
	test/ganeti.ovf_unittest.py \
884
	test/ganeti.qlang_unittest.py \
885
	test/ganeti.query_unittest.py \
886
	test/ganeti.rapi.baserlib_unittest.py \
887
	test/ganeti.rapi.client_unittest.py \
888
	test/ganeti.rapi.resources_unittest.py \
889
	test/ganeti.rapi.rlib2_unittest.py \
890
	test/ganeti.rapi.testutils_unittest.py \
891
	test/ganeti.rpc_unittest.py \
892
	test/ganeti.runtime_unittest.py \
893
	test/ganeti.serializer_unittest.py \
894
	test/ganeti.ssh_unittest.py \
895
	test/ganeti.storage_unittest.py \
896
	test/ganeti.tools.ensure_dirs_unittest.py \
897
	test/ganeti.uidpool_unittest.py \
898
	test/ganeti.utils.algo_unittest.py \
899
	test/ganeti.utils.filelock_unittest.py \
900
	test/ganeti.utils.hash_unittest.py \
901
	test/ganeti.utils.io_unittest.py \
902
	test/ganeti.utils.log_unittest.py \
903
	test/ganeti.utils.mlock_unittest.py \
904
	test/ganeti.utils.nodesetup_unittest.py \
905
	test/ganeti.utils.process_unittest.py \
906
	test/ganeti.utils.retry_unittest.py \
907
	test/ganeti.utils.text_unittest.py \
908
	test/ganeti.utils.wrapper_unittest.py \
909
	test/ganeti.utils.x509_unittest.py \
910
	test/ganeti.utils_unittest.py \
911
	test/ganeti.workerpool_unittest.py \
912
	test/qa.qa_config_unittest.py \
913
	test/cfgupgrade_unittest.py \
914
	test/docs_unittest.py \
915
	test/pycurl_reset_unittest.py \
916
	test/tempfile_fork_unittest.py
917
if HAS_FAKEROOT
918
python_tests += test/ganeti.utils.io_unittest-runasroot.py
919
endif
920

    
921
haskell_tests = htest/test
922

    
923
dist_TESTS = \
924
	test/check-cert-expired_unittest.bash \
925
	test/daemon-util_unittest.bash \
926
	test/ganeti-cleaner_unittest.bash \
927
	test/import-export_unittest.bash \
928
	test/cli-test.bash \
929
	$(python_tests)
930

    
931
nodist_TESTS =
932
check_SCRIPTS =
933

    
934
if WANT_HTOOLSTESTS
935
nodist_TESTS += $(haskell_tests)
936
dist_TESTS += htest/offline-test.sh
937
check_SCRIPTS += htest/hpc-htools $(HS_BUILT_TEST_HELPERS)
938
endif
939

    
940
TESTS = $(dist_TESTS) $(nodist_TESTS)
941

    
942
# Environment for all tests
943
PLAIN_TESTS_ENVIRONMENT = \
944
	PYTHONPATH=. \
945
	TOP_SRCDIR=$(abs_top_srcdir) TOP_BUILDDIR=$(abs_top_builddir) \
946
	PYTHON=$(PYTHON) FAKEROOT=$(FAKEROOT_PATH) \
947
	$(RUN_IN_TEMPDIR)
948

    
949
# Environment for tests run by automake
950
TESTS_ENVIRONMENT = \
951
	$(PLAIN_TESTS_ENVIRONMENT) $(abs_top_srcdir)/autotools/testrunner
952

    
953
all_python_code = \
954
	$(dist_sbin_SCRIPTS) \
955
	$(python_scripts) \
956
	$(pkglib_python_scripts) \
957
	$(nodist_pkglib_python_scripts) \
958
	$(python_tests) \
959
	$(pkgpython_PYTHON) \
960
	$(client_PYTHON) \
961
	$(hypervisor_PYTHON) \
962
	$(rapi_PYTHON) \
963
	$(server_PYTHON) \
964
	$(pytools_PYTHON) \
965
	$(http_PYTHON) \
966
	$(confd_PYTHON) \
967
	$(masterd_PYTHON) \
968
	$(impexpd_PYTHON) \
969
	$(utils_PYTHON) \
970
	$(watcher_PYTHON) \
971
	$(noinst_PYTHON) \
972
	$(qa_scripts)
973

    
974
srclink_files = \
975
	man/footer.rst \
976
	test/check-cert-expired_unittest.bash \
977
	test/daemon-util_unittest.bash \
978
	test/ganeti-cleaner_unittest.bash \
979
	test/import-export_unittest.bash \
980
	test/cli-test.bash \
981
	htest/offline-test.sh \
982
	htest/cli-tests-defs.sh \
983
	$(all_python_code) \
984
	$(HS_LIBTEST_SRCS) $(HS_PROG_SRCS)
985

    
986
check_python_code = \
987
	$(BUILD_BASH_COMPLETION) \
988
	$(CHECK_IMPORTS) \
989
	$(CHECK_HEADER) \
990
	$(DOCPP) \
991
	$(all_python_code)
992

    
993
lint_python_code = \
994
	ganeti \
995
	ganeti/http/server.py \
996
	$(dist_sbin_SCRIPTS) \
997
	$(python_scripts) \
998
	$(pkglib_python_scripts) \
999
	$(BUILD_BASH_COMPLETION) \
1000
	$(CHECK_IMPORTS) \
1001
	$(CHECK_HEADER) \
1002
	$(DOCPP) \
1003
	$(PYTHON_BOOTSTRAP)
1004

    
1005
standalone_python_modules = \
1006
	lib/rapi/client.py \
1007
	tools/ganeti-listrunner
1008

    
1009
pep8_python_code = \
1010
	ganeti \
1011
	ganeti/http/server.py \
1012
	$(dist_sbin_SCRIPTS) \
1013
	$(python_scripts) \
1014
	$(pkglib_python_scripts) \
1015
	$(BUILD_BASH_COMPLETION) \
1016
	$(CHECK_HEADER) \
1017
	$(DOCPP) \
1018
	$(PYTHON_BOOTSTRAP) \
1019
	qa
1020

    
1021
test/daemon-util_unittest.bash: daemons/daemon-util
1022

    
1023
test/ganeti-cleaner_unittest.bash: daemons/ganeti-cleaner
1024

    
1025
tools/kvm-ifup: tools/kvm-ifup.in $(REPLACE_VARS_SED)
1026
	sed -f $(REPLACE_VARS_SED) < $< > $@
1027
	chmod +x $@
1028

    
1029
devel/upload: devel/upload.in $(REPLACE_VARS_SED)
1030
	sed -f $(REPLACE_VARS_SED) < $< > $@
1031
	chmod u+x $@
1032

    
1033
daemons/%:: daemons/%.in $(REPLACE_VARS_SED)
1034
	sed -f $(REPLACE_VARS_SED) < $< > $@
1035
	chmod +x $@
1036

    
1037
doc/examples/%:: doc/examples/%.in $(REPLACE_VARS_SED)
1038
	sed -f $(REPLACE_VARS_SED) < $< > $@
1039

    
1040
doc/examples/bash_completion: $(BUILD_BASH_COMPLETION) $(RUN_IN_TEMPDIR) \
1041
	lib/cli.py $(gnt_scripts) $(client_PYTHON) tools/burnin \
1042
	$(GENERATED_FILES)
1043
	PYTHONPATH=. $(RUN_IN_TEMPDIR) $(CURDIR)/$(BUILD_BASH_COMPLETION) > $@
1044

    
1045
doc/%.png: doc/%.dot
1046
	@test -n "$(DOT)" || { echo 'dot' not found during configure; exit 1; }
1047
	$(DOT) -Tpng -o $@ $<
1048

    
1049
man/footer.man: man/footer.rst
1050
	@test -n "$(PANDOC)" || \
1051
	  { echo 'pandoc' not found during configure; exit 1; }
1052
	$(PANDOC) -f rst -t man -o $@ $<
1053

    
1054
man/footer.html: man/footer.rst
1055
	@test -n "$(PANDOC)" || \
1056
	  { echo 'pandoc' not found during configure; exit 1; }
1057
	$(PANDOC) -f rst -t html -o $@ $<
1058

    
1059
man/%.gen: man/%.rst lib/query.py lib/build/sphinx_ext.py \
1060
	lib/build/shell_example_lexer.py \
1061
	| $(RUN_IN_TEMPDIR) $(BUILT_PYTHON_SOURCES)
1062
	@echo "Checking $< for hardcoded paths..."
1063
	@if grep -nEf autotools/wrong-hardcoded-paths $<; then \
1064
	  echo "Man page $< has harcoded paths (see above)!" 1>&2 ; \
1065
	  exit 1; \
1066
	fi
1067
	set -e ; \
1068
	trap 'echo auto-removing $@; rm $@' EXIT; \
1069
	PYTHONPATH=. $(RUN_IN_TEMPDIR) $(CURDIR)/$(DOCPP) < $< > $@ ;\
1070
	trap - EXIT
1071

    
1072
man/%.7.in man/%.8.in man/%.1.in: man/%.gen man/footer.man
1073
	@test -n "$(PANDOC)" || \
1074
	  { echo 'pandoc' not found during configure; exit 1; }
1075
	set -o pipefail ; \
1076
	trap 'echo auto-removing $@; rm $@' EXIT; \
1077
	$(PANDOC) -s -f rst -t man -A man/footer.man $< | \
1078
	  sed -e 's/\\@/@/g' > $@; \
1079
	if test -n "$(MAN_HAS_WARNINGS)"; then $(CHECK_MAN_WARNINGS) $@; fi; \
1080
	$(CHECK_MAN_DASHES) $@; \
1081
	trap - EXIT
1082

    
1083

    
1084
man/%.html.in: man/%.gen man/footer.html
1085
	@test -n "$(PANDOC)" || \
1086
	  { echo 'pandoc' not found during configure; exit 1; }
1087
	set -o pipefail ; \
1088
	$(PANDOC) -s -f rst -t html -A man/footer.html $< | \
1089
	  sed -e 's/\\@/@/g' > $@
1090

    
1091
man/%: man/%.in  $(REPLACE_VARS_SED)
1092
	sed -f $(REPLACE_VARS_SED) < $< > $@
1093

    
1094
epydoc.conf: epydoc.conf.in $(REPLACE_VARS_SED)
1095
	sed -f $(REPLACE_VARS_SED) < $< > $@
1096

    
1097
vcs-version:
1098
	if test -d .git; then \
1099
	  git describe > $@; \
1100
	elif test ! -f $@ ; then \
1101
	  echo "Cannot auto-generate $@ file"; exit 1; \
1102
	fi
1103

    
1104
.PHONY: clean-vcs-version
1105
clean-vcs-version:
1106
	rm -f vcs-version
1107

    
1108
.PHONY: regen-vcs-version
1109
regen-vcs-version:
1110
	set -e; \
1111
	cd $(srcdir); \
1112
	if test -d .git; then \
1113
	  $(MAKE) $(AM_MAKEFLAGS) clean-vcs-version; \
1114
	  $(MAKE) $(AM_MAKEFLAGS) vcs-version; \
1115
	fi
1116

    
1117
htools/Ganeti/Version.hs: htools/Ganeti/Version.hs.in \
1118
	vcs-version $(built_base_sources)
1119
	set -e; \
1120
	VCSVER=`cat $(abs_top_srcdir)/vcs-version`; \
1121
	sed -e "s/%ver%/$$VCSVER/" < $< > $@
1122

    
1123
htools/Ganeti/Constants.hs: htools/Ganeti/Constants.hs.in \
1124
	lib/constants.py lib/_autoconf.py lib/luxi.py \
1125
	$(CONVERT_CONSTANTS) $(built_base_sources) \
1126
	| lib/_vcsversion.py
1127
	set -e; \
1128
	{ cat $< ; PYTHONPATH=. $(CONVERT_CONSTANTS); } > $@
1129

    
1130
htest/Test/Ganeti/TestImports.hs: htest/Test/Ganeti/TestImports.hs.in \
1131
	$(built_base_sources)
1132
	set -e; \
1133
	{ cat $< ; \
1134
	  echo ; \
1135
	  for name in $(filter-out Ganeti.THH,$(subst /,.,$(patsubst %.hs,%,$(patsubst htools/%,%,$(HS_LIB_SRCS))))) ; do \
1136
	    echo "import $$name ()" ; \
1137
	  done ; \
1138
	} > $@
1139

    
1140
lib/_autoconf.py: Makefile | stamp-directories
1141
	set -e; \
1142
	{ echo '# This file is automatically generated, do not edit!'; \
1143
	  echo '#'; \
1144
	  echo ''; \
1145
	  echo '"""Build-time configuration for Ganeti.'; \
1146
	  echo '';\
1147
	  echo 'This file is autogenerated by the build process.'; \
1148
	  echo 'For any changes you need to re-run ./configure (and'; \
1149
	  echo 'not edit by hand).'; \
1150
	  echo ''; \
1151
	  echo '"""'; \
1152
	  echo ''; \
1153
	  echo '# pylint: disable=C0301,C0324'; \
1154
	  echo '# because this is autogenerated, we do not want'; \
1155
	  echo '# style warnings' ; \
1156
	  echo ''; \
1157
	  echo "PACKAGE_VERSION = '$(PACKAGE_VERSION)'"; \
1158
	  echo "VERSION_MAJOR = '$(VERSION_MAJOR)'"; \
1159
	  echo "VERSION_MINOR = '$(VERSION_MINOR)'"; \
1160
	  echo "VERSION_REVISION = '$(VERSION_REVISION)'"; \
1161
	  echo "VERSION_SUFFIX = '$(VERSION_SUFFIX)'"; \
1162
	  echo "VERSION_FULL = '$(VERSION_FULL)'"; \
1163
	  echo "LOCALSTATEDIR = '$(localstatedir)'"; \
1164
	  echo "SYSCONFDIR = '$(sysconfdir)'"; \
1165
	  echo "SSH_CONFIG_DIR = '$(SSH_CONFIG_DIR)'"; \
1166
	  echo "EXPORT_DIR = '$(EXPORT_DIR)'"; \
1167
	  echo "OS_SEARCH_PATH = [$(OS_SEARCH_PATH)]"; \
1168
	  echo "XEN_BOOTLOADER = '$(XEN_BOOTLOADER)'"; \
1169
	  echo "XEN_KERNEL = '$(XEN_KERNEL)'"; \
1170
	  echo "XEN_INITRD = '$(XEN_INITRD)'"; \
1171
	  echo "KVM_KERNEL = '$(KVM_KERNEL)'"; \
1172
	  echo "FILE_STORAGE_DIR = '$(FILE_STORAGE_DIR)'"; \
1173
	  echo "ENABLE_FILE_STORAGE = $(ENABLE_FILE_STORAGE)"; \
1174
	  echo "SHARED_FILE_STORAGE_DIR = '$(SHARED_FILE_STORAGE_DIR)'"; \
1175
	  echo "ENABLE_SHARED_FILE_STORAGE = $(ENABLE_SHARED_FILE_STORAGE)"; \
1176
	  echo "IALLOCATOR_SEARCH_PATH = [$(IALLOCATOR_SEARCH_PATH)]"; \
1177
	  echo "KVM_PATH = '$(KVM_PATH)'"; \
1178
	  echo "IP_PATH = '$(IP_PATH)'"; \
1179
	  echo "SOCAT_PATH = '$(SOCAT)'"; \
1180
	  echo "SOCAT_USE_ESCAPE = $(SOCAT_USE_ESCAPE)"; \
1181
	  echo "SOCAT_USE_COMPRESS = $(SOCAT_USE_COMPRESS)"; \
1182
	  echo "LVM_STRIPECOUNT = $(LVM_STRIPECOUNT)"; \
1183
	  echo "TOOLSDIR = '$(toolsdir)'"; \
1184
	  echo "GNT_SCRIPTS = [$(foreach i,$(notdir $(gnt_scripts)),'$(i)',)]"; \
1185
	  echo "PKGLIBDIR = '$(pkglibdir)'"; \
1186
	  echo "DRBD_BARRIERS = '$(DRBD_BARRIERS)'"; \
1187
	  echo "DRBD_NO_META_FLUSH = $(DRBD_NO_META_FLUSH)"; \
1188
	  echo "SYSLOG_USAGE = '$(SYSLOG_USAGE)'"; \
1189
	  echo "DAEMONS_GROUP = '$(DAEMONS_GROUP)'"; \
1190
	  echo "ADMIN_GROUP = '$(ADMIN_GROUP)'"; \
1191
	  echo "MASTERD_USER = '$(MASTERD_USER)'"; \
1192
	  echo "MASTERD_GROUP = '$(MASTERD_GROUP)'"; \
1193
	  echo "RAPI_USER = '$(RAPI_USER)'"; \
1194
	  echo "RAPI_GROUP = '$(RAPI_GROUP)'"; \
1195
	  echo "CONFD_USER = '$(CONFD_USER)'"; \
1196
	  echo "CONFD_GROUP = '$(CONFD_GROUP)'"; \
1197
	  echo "NODED_USER = '$(NODED_USER)'"; \
1198
	  echo "NODED_GROUP = '$(NODED_GROUP)'"; \
1199
	  echo "DISK_SEPARATOR = '$(DISK_SEPARATOR)'"; \
1200
	  echo "QEMUIMG_PATH = '$(QEMUIMG_PATH)'"; \
1201
	  if [ "$(HTOOLS)" ]; then \
1202
	    echo "HTOOLS = True"; \
1203
	  else \
1204
	    echo "HTOOLS = False"; \
1205
	  fi; \
1206
	  echo "ENABLE_CONFD = $(ENABLE_CONFD)"; \
1207
	  echo "PY_CONFD = $(PY_CONFD)"; \
1208
	  echo "HS_CONFD = $(HS_CONFD)"; \
1209
	  echo "XEN_CMD = '$(XEN_CMD)'"; \
1210
	  echo "ENABLE_SPLIT_QUERY = $(ENABLE_SPLIT_QUERY)"; \
1211
	} > $@
1212

    
1213
lib/_vcsversion.py: Makefile vcs-version | stamp-directories
1214
	set -e; \
1215
	VCSVER=`cat $(abs_top_srcdir)/vcs-version`; \
1216
	{ echo '# This file is automatically generated, do not edit!'; \
1217
	  echo '#'; \
1218
	  echo ''; \
1219
	  echo '"""Build-time VCS version number for Ganeti.'; \
1220
	  echo '';\
1221
	  echo 'This file is autogenerated by the build process.'; \
1222
	  echo 'For any changes you need to re-run ./configure (and'; \
1223
	  echo 'not edit by hand).'; \
1224
	  echo ''; \
1225
	  echo '"""'; \
1226
	  echo ''; \
1227
	  echo '# pylint: disable=C0301,C0324'; \
1228
	  echo '# because this is autogenerated, we do not want'; \
1229
	  echo '# style warnings' ; \
1230
	  echo ''; \
1231
	  echo "VCS_VERSION = '$$VCSVER'"; \
1232
	} > $@
1233

    
1234
lib/_generated_rpc.py: lib/rpc_defs.py $(BUILD_RPC)
1235
	PYTHONPATH=. $(RUN_IN_TEMPDIR) $(CURDIR)/$(BUILD_RPC) lib/rpc_defs.py > $@
1236

    
1237
$(REPLACE_VARS_SED): Makefile stamp-directories
1238
	set -e; \
1239
	{ echo 's#@PREFIX@#$(prefix)#g'; \
1240
	  echo 's#@SYSCONFDIR@#$(sysconfdir)#g'; \
1241
	  echo 's#@LOCALSTATEDIR@#$(localstatedir)#g'; \
1242
	  echo 's#@BINDIR@#$(bindir)#g'; \
1243
	  echo 's#@SBINDIR@#$(sbindir)#g'; \
1244
	  echo 's#@GANETI_VERSION@#$(PACKAGE_VERSION)#g'; \
1245
	  echo 's#@CUSTOM_XEN_BOOTLOADER@#$(XEN_BOOTLOADER)#g'; \
1246
	  echo 's#@CUSTOM_XEN_KERNEL@#$(XEN_KERNEL)#g'; \
1247
	  echo 's#@CUSTOM_XEN_INITRD@#$(XEN_INITRD)#g'; \
1248
	  echo 's#@CUSTOM_IALLOCATOR_SEARCH_PATH@#$(IALLOCATOR_SEARCH_PATH)#g'; \
1249
	  echo 's#@CUSTOM_EXPORT_DIR@#$(EXPORT_DIR)#g'; \
1250
	  echo 's#@RPL_FILE_STORAGE_DIR@#$(FILE_STORAGE_DIR)#g'; \
1251
	  echo 's#@RPL_SSH_INITD_SCRIPT@#$(SSH_INITD_SCRIPT)#g'; \
1252
	  echo 's#@PKGLIBDIR@#$(pkglibdir)#g'; \
1253
	  echo 's#@GNTMASTERUSER@#$(MASTERD_USER)#g'; \
1254
	  echo 's#@GNTRAPIUSER@#$(RAPI_USER)#g'; \
1255
	  echo 's#@GNTCONFDUSER@#$(CONFD_USER)#g'; \
1256
	  echo 's#@GNTNODEDUSER@#$(NODED_USER)#g'; \
1257
	  echo 's#@GNTRAPIGROUP@#$(RAPI_GROUP)#g'; \
1258
	  echo 's#@GNTADMINGROUP@#$(ADMIN_GROUP)#g'; \
1259
	  echo 's#@GNTCONFDGROUP@#$(CONFD_GROUP)#g'; \
1260
	  echo 's#@GNTMASTERDGROUP@#$(MASTERD_GROUP)#g'; \
1261
	  echo 's#@GNTDAEMONSGROUP@#$(DAEMONS_GROUP)#g'; \
1262
	  echo 's#@CUSTOM_ENABLE_CONFD@#$(ENABLE_CONFD)#g'; \
1263
	  echo 's#@MODULES@#$(strip $(lint_python_code))#g'; \
1264
	  echo 's#@ENABLE_SPLIT_QUERY@#$(ENABLE_SPLIT_QUERY)#g'; \
1265
	} > $@
1266

    
1267
# Using deferred evaluation
1268
daemons/ganeti-%: MODULE = ganeti.server.$(patsubst ganeti-%,%,$(notdir $@))
1269
daemons/ganeti-watcher: MODULE = ganeti.watcher
1270
scripts/%: MODULE = ganeti.client.$(subst -,_,$(notdir $@))
1271
tools/ensure-dirs: MODULE = ganeti.tools.ensure_dirs
1272
$(HS_BUILT_TEST_HELPERS): TESTROLE = $(patsubst htest/%,%,$@)
1273

    
1274
$(PYTHON_BOOTSTRAP): Makefile | stamp-directories
1275
	test -n "$(MODULE)" || { echo Missing module; exit 1; }
1276
	set -e; \
1277
	{ echo '#!/usr/bin/python'; \
1278
	  echo '# This file is automatically generated, do not edit!'; \
1279
	  echo "# Edit $(MODULE) instead."; \
1280
	  echo; \
1281
	  echo '"""Bootstrap script for L{$(MODULE)}"""'; \
1282
	  echo; \
1283
	  echo '# pylint: disable=C0103'; \
1284
	  echo '# C0103: Invalid name'; \
1285
	  echo; \
1286
	  echo 'import sys'; \
1287
	  echo 'import $(MODULE) as main'; \
1288
	  echo; \
1289
	  echo '# Temporarily alias commands until bash completion'; \
1290
	  echo '# generator is changed'; \
1291
	  echo 'if hasattr(main, "commands"):'; \
1292
	  echo '  commands = main.commands # pylint: disable=E1101'; \
1293
	  echo 'if hasattr(main, "aliases"):'; \
1294
	  echo '  aliases = main.aliases # pylint: disable=E1101'; \
1295
	  echo; \
1296
	  echo 'if __name__ == "__main__":'; \
1297
	  echo '  sys.exit(main.Main())'; \
1298
	} > $@
1299
	chmod u+x $@
1300

    
1301
$(HS_BUILT_TEST_HELPERS): Makefile
1302
	@test -n "$(TESTROLE)" || { echo Missing TESTROLE; exit 1; }
1303
	set -e; \
1304
	{ echo '#!/bin/sh'; \
1305
	  echo '# This file is automatically generated, do not edit!'; \
1306
	  echo "# Edit Makefile.am instead."; \
1307
	  echo; \
1308
	  echo "HTOOLS=$(TESTROLE) exec ./htest/hpc-htools \"\$$@\""; \
1309
	} > $@
1310
	chmod u+x $@
1311

    
1312
stamp-directories: Makefile
1313
	$(MAKE) $(AM_MAKEFLAGS) ganeti
1314
	@mkdir_p@ $(DIRS) $(BUILDTIME_DIR_AUTOCREATE)
1315
	touch $@
1316

    
1317
# We need to create symlinks because "make distcheck" will not install Python
1318
# files when building.
1319
stamp-srclinks: Makefile | stamp-directories
1320
	set -e; \
1321
	for i in $(srclink_files); do \
1322
		if test ! -f $$i -a -f $(abs_top_srcdir)/$$i; then \
1323
			$(LN_S) $(abs_top_srcdir)/$$i $$i; \
1324
		fi; \
1325
	done
1326
	touch $@
1327

    
1328
.PHONY: ganeti
1329
ganeti:
1330
	cd $(top_builddir) && test -h "$@" || { rm -f $@ && $(LN_S) lib $@; }
1331

    
1332
.PHONY: check-dirs
1333
check-dirs: $(GENERATED_FILES)
1334
	@set -e; \
1335
	find . -type d \( \( -name . \) -o \( \
1336
		-name .git -o \
1337
		-name autom4te.cache \
1338
		\) -prune -o -print \) | { \
1339
		error=; \
1340
		while read dir; do \
1341
			case "$$dir" in \
1342
				$(strip $(patsubst %,(./%) ;;,$(DIRCHECK_EXCLUDE) $(DIRS))) \
1343
				*) error=1; echo "Directory $$dir not listed in Makefile" >&2 ;; \
1344
			esac; \
1345
		done; \
1346
		for dir in $(DIRS); do \
1347
			if ! test -d "$$dir"; then \
1348
				echo "Directory $$dir listed in DIRS does not exist" >&2; \
1349
				error=1; \
1350
			fi \
1351
		done; \
1352
		if test -n "$$error"; then exit 1; else exit 0; fi; \
1353
	}
1354

    
1355
.PHONY: check-local
1356
check-local: check-dirs $(GENERATED_FILES)
1357
	$(CHECK_PYTHON_CODE) $(check_python_code)
1358
	PYTHONPATH=. $(CHECK_HEADER) $(check_python_code)
1359
	$(CHECK_VERSION) $(VERSION) $(top_srcdir)/NEWS
1360
	$(CHECK_NEWS) < $(top_srcdir)/NEWS
1361
	PYTHONPATH=. $(RUN_IN_TEMPDIR) $(CURDIR)/$(CHECK_IMPORTS) . $(standalone_python_modules)
1362
	expver=$(VERSION_MAJOR).$(VERSION_MINOR); \
1363
	if test "`head -n 1 $(top_srcdir)/README`" != "Ganeti $$expver"; then \
1364
		echo "Incorrect version in README, expected $$expver"; \
1365
		exit 1; \
1366
	fi; \
1367
	for file in doc/iallocator.rst doc/hooks.rst; do \
1368
		if test "`sed -ne '4 p' $(top_srcdir)/$$file`" != \
1369
			"Documents Ganeti version $$expver"; then \
1370
			echo "Incorrect version in $$file, expected $$expver"; \
1371
			exit 1; \
1372
		fi; \
1373
	done
1374

    
1375
.PHONY: hs-check
1376
hs-check: htest/test htest/hpc-htools $(HS_BUILT_TEST_HELPERS)
1377
	@rm -f test.tix
1378
	./htest/test
1379
	HBINARY="./htest/hpc-htools" ./htest/offline-test.sh
1380

    
1381
# E111: indentation is not a multiple of four
1382
# E121: continuation line indentation is not a multiple of four
1383
#       (since our indent level is not 4)
1384
# E125: continuation line does not distinguish itself from next logical line
1385
#       (since our indent level is not 4)
1386
# E127: continuation line over-indented for visual indent
1387
#       (since our indent level is not 4)
1388
# note: do NOT add E128 here; it's a valid style error in most cases!
1389
# I've seen real errors, but also some cases were we indent wrongly
1390
# due to line length; try to rework the cases where it is triggered,
1391
# instead of silencing it
1392
# E261: at least two spaces before inline comment
1393
# E501: line too long (80 characters)
1394
PEP8_IGNORE = E111,E121,E125,E127,E261,E501
1395

    
1396
# For excluding pep8 expects filenames only, not whole paths
1397
PEP8_EXCLUDE = $(subst $(space),$(comma),$(strip $(notdir $(BUILT_PYTHON_SOURCES))))
1398

    
1399
LINT_TARGETS = pylint pylint-qa
1400
if HAS_PEP8
1401
LINT_TARGETS += pep8
1402
endif
1403
if HAS_HLINT
1404
LINT_TARGETS += hlint
1405
endif
1406

    
1407
.PHONY: lint
1408
lint: $(LINT_TARGETS)
1409

    
1410
.PHONY: pylint
1411
pylint: $(GENERATED_FILES)
1412
	@test -n "$(PYLINT)" || { echo 'pylint' not found during configure; exit 1; }
1413
	$(PYLINT) $(LINT_OPTS) $(lint_python_code)
1414

    
1415
.PHONY: pylint-qa
1416
pylint-qa: $(GENERATED_FILES)
1417
	@test -n "$(PYLINT)" || { echo 'pylint' not found during configure; exit 1; }
1418
	cd $(top_srcdir)/qa && \
1419
	  PYTHONPATH=$(abs_top_srcdir) $(PYLINT) $(LINT_OPTS) \
1420
	  --rcfile  ../pylintrc $(patsubst qa/%.py,%,$(qa_scripts))
1421

    
1422
.PHONY: pep8
1423
pep8: $(GENERATED_FILES)
1424
	@test -n "$(PEP8)" || { echo 'pep8' not found during configure; exit 1; }
1425
	$(PEP8) --ignore='$(PEP8_IGNORE)' --exclude='$(PEP8_EXCLUDE)' \
1426
		--repeat $(pep8_python_code)
1427

    
1428
# FIXME: remove ignore "Use void" when GHC 6.x is deprecated
1429
.PHONY: hlint
1430
hlint: $(HS_BUILT_SRCS) htools/lint-hints.hs
1431
	@test -n "$(HLINT)" || { echo 'hlint' not found during configure; exit 1; }
1432
	if tty -s; then C="-c"; else C=""; fi; \
1433
	$(HLINT) --report=doc/hs-lint.html --cross $$C \
1434
	  --ignore "Use first" \
1435
	  --ignore "Use comparing" \
1436
	  --ignore "Use on" \
1437
	  --ignore "Reduce duplication" \
1438
	  --ignore "Use &&&" \
1439
	  --ignore "Use void" \
1440
	  --hint htools/lint-hints \
1441
	  $(filter-out htools/Ganeti/THH.hs,$(HS_LIBTEST_SRCS))
1442

    
1443
# a dist hook rule for updating the vcs-version file; this is
1444
# hardcoded due to where it needs to build the file...
1445
dist-hook:
1446
	$(MAKE) $(AM_MAKEFLAGS) regen-vcs-version
1447
	rm -f $(top_distdir)/vcs-version
1448
	cp -p $(srcdir)/vcs-version $(top_distdir)
1449

    
1450
# a distcheck hook rule for catching revision control directories
1451
distcheck-hook:
1452
	if find $(top_distdir) -name .svn -or -name .git | grep .; then \
1453
		echo "Found revision control files in final archive." 1>&2; \
1454
		exit 1; \
1455
	fi
1456
	if find $(top_distdir) -name '*.py[co]' | grep .; then \
1457
		echo "Found Python byte code in final archive." 1>&2; \
1458
		exit 1; \
1459
	fi
1460
	if find $(top_distdir) -name '*~' | grep .; then \
1461
		echo "Found backup files in final archive." 1>&2; \
1462
		exit 1; \
1463
	fi
1464
# Empty files or directories should not be distributed. They can cause
1465
# unnecessary warnings for packagers. Directories used by automake during
1466
# distcheck must be excluded.
1467
	if find $(top_distdir) -empty -and -not \( \
1468
			-path $(top_distdir)/_build -or \
1469
			-path $(top_distdir)/_inst \) | grep .; then \
1470
		echo "Found empty files or directories in final archive." 1>&2; \
1471
		exit 1; \
1472
	fi
1473
	if test -n "$(BUILD_RELEASE)" && \
1474
	   grep -n -H -E '^\*.*unreleased' $(top_distdir)/NEWS; then \
1475
		echo "Found unreleased version in NEWS." >&2; \
1476
		exit 1; \
1477
	fi
1478

    
1479
# When building a release, stricter checks should be used
1480
distcheck-release dist-release: export BUILD_RELEASE = 1
1481
distcheck-release: distcheck
1482

    
1483
distrebuildcheck: dist
1484
	set -e; \
1485
	builddir=$$(mktemp -d $(abs_srcdir)/distrebuildcheck.XXXXXXX); \
1486
	trap "echo Removing $$builddir; cd $(abs_srcdir); rm -rf $$builddir" EXIT; \
1487
	cd $$builddir; \
1488
	tar xzf $(abs_srcdir)/$(distdir).tar.gz; \
1489
	cd $(distdir); \
1490
	./configure; \
1491
	$(MAKE) maintainer-clean; \
1492
	cp $(abs_srcdir)/vcs-version .; \
1493
	./configure; \
1494
	$(MAKE) $(AM_MAKEFLAGS)
1495

    
1496
dist-release: dist
1497
	set -e; \
1498
	for i in $(DIST_ARCHIVES); do \
1499
		echo -n "Checking $$i ... "; \
1500
		autotools/check-tar < $$i; \
1501
		echo OK; \
1502
	done
1503

    
1504
install-exec-local:
1505
	@mkdir_p@ "$(DESTDIR)${localstatedir}/lib/ganeti" \
1506
	  "$(DESTDIR)${localstatedir}/log/ganeti" \
1507
	  "$(DESTDIR)${localstatedir}/run/ganeti"
1508

    
1509
.PHONY: apidoc
1510
if WANT_HTOOLSAPIDOC
1511
apidoc: py-apidoc hs-apidoc
1512
else
1513
apidoc: py-apidoc
1514
endif
1515

    
1516
.PHONY: py-apidoc
1517
py-apidoc: epydoc.conf $(RUN_IN_TEMPDIR) $(GENERATED_FILES)
1518
	$(RUN_IN_TEMPDIR) epydoc -v \
1519
		--conf $(CURDIR)/epydoc.conf \
1520
		--output $(CURDIR)/$(APIDOC_PY_DIR)
1521

    
1522
.PHONY: hs-apidoc
1523
hs-apidoc: $(HS_BUILT_SRCS)
1524
	@test -n "$(HSCOLOUR)" || \
1525
	    { echo 'HsColour' not found during configure; exit 1; }
1526
	@test -n "$(HADDOCK)" || \
1527
	    { echo 'haddock' not found during configure; exit 1; }
1528
	rm -rf $(APIDOC_HS_DIR)/*
1529
	@mkdir_p@ $(APIDOC_HS_DIR)/Ganeti/HTools/Program
1530
	@mkdir_p@ $(APIDOC_HS_DIR)/Ganeti/Confd
1531
	@mkdir_p@ $(APIDOC_HS_DIR)/Ganeti/Query
1532
	$(HSCOLOUR) -print-css > $(APIDOC_HS_DIR)/Ganeti/hscolour.css
1533
	$(LN_S) ../hscolour.css $(APIDOC_HS_DIR)/Ganeti/HTools/hscolour.css
1534
	$(LN_S) ../hscolour.css $(APIDOC_HS_DIR)/Ganeti/Confd/hscolour.css
1535
	set -e ; \
1536
	cd htools; \
1537
	if [ "$(HTOOLS_NOCURL)" ]; \
1538
	then OPTGHC="--optghc=$(HTOOLS_NOCURL)"; \
1539
	else OPTGHC=""; \
1540
	fi; \
1541
	if [ "$(HTOOLS_PARALLEL3)" ]; \
1542
	then OPTGHC="$$OPTGHC --optghc=$(HTOOLS_PARALLEL3)"; \
1543
	fi; \
1544
	RELSRCS="$(HS_LIB_SRCS:htools/%=%) $(patsubst htools/%,%,$(filter htools/%,$(HS_BUILT_SRCS)))"; \
1545
	for file in $$RELSRCS; do \
1546
		hfile=`echo $$file|sed 's/\\.hs$$//'`.html; \
1547
		$(HSCOLOUR) -css -anchor $$file > ../$(APIDOC_HS_DIR)/$$hfile ; \
1548
	done ; \
1549
	$(HADDOCK) --odir ../$(APIDOC_HS_DIR) --html --ignore-all-exports -w \
1550
		-t ganeti-htools -p haddock-prologue \
1551
		--source-module="%{MODULE/.//}.html" \
1552
		--source-entity="%{MODULE/.//}.html#%{NAME}" \
1553
		$$OPTGHC \
1554
		$(filter-out Ganeti/HTools/ExtLoader.hs,$(HS_LIB_SRCS:htools/%=%))
1555

    
1556
.PHONY: TAGS
1557
TAGS: $(GENERATED_FILES)
1558
	rm -f TAGS
1559
	$(GHC) -e ":etags" -v0 $(HFLAGS) $(HS_LIBTEST_SRCS)
1560
	find . -path './lib/*.py' -o -path './scripts/gnt-*' -o \
1561
	  -path './daemons/ganeti-*' -o -path './tools/*' -o \
1562
	  -path './qa/*.py' | \
1563
	  etags -l python -a -
1564

    
1565
.PHONY: coverage
1566
if WANT_HTOOLS
1567
coverage: py-coverage hs-coverage
1568
else
1569
coverage: py-coverage
1570
endif
1571

    
1572
.PHONY: py-coverage
1573
py-coverage: $(GENERATED_FILES) $(python_tests)
1574
	set -e; \
1575
	COVERAGE_FILE=$(CURDIR)/$(COVERAGE_PY_DIR)/data \
1576
	TEXT_COVERAGE=$(CURDIR)/$(COVERAGE_PY_DIR)/report.txt \
1577
	HTML_COVERAGE=$(CURDIR)/$(COVERAGE_PY_DIR) \
1578
	$(PLAIN_TESTS_ENVIRONMENT) $(abs_top_srcdir)/autotools/gen-coverage \
1579
	$(python_tests)
1580

    
1581
.PHONY: hs-coverage
1582
hs-coverage: $(haskell_tests) htest/hpc-htools
1583
	rm -f *.tix
1584
	$(MAKE) $(AM_MAKEFLAGS) hs-check
1585
	@mkdir_p@ $(COVERAGE_HS_DIR)
1586
	hpc combine --union $(HPCEXCL) \
1587
	  test.tix hpc-htools.tix > coverage-htools.tix
1588
	hpc markup --destdir=$(COVERAGE_HS_DIR) coverage-htools.tix
1589
	hpc report coverage-htools.tix
1590
	$(LN_S) -f hpc_index.html $(COVERAGE_HS_DIR)/index.html
1591

    
1592
# Special "kind-of-QA" target for htools, needs special setup (all
1593
# tools compiled with -fhpc)
1594
.PHONY: live-test
1595
live-test: all
1596
	set -e ; \
1597
	cd htools; \
1598
	rm -f .hpc; $(LN_S) ../.hpc .hpc; \
1599
	rm -f *.tix *.mix; \
1600
	./live-test.sh; \
1601
	hpc sum --union $(HPCEXCL) $(addsuffix .tix,$(HS_PROGS:htools/%=%)) \
1602
	  --output=live-test.tix ; \
1603
	@mkdir_p@ ../$(COVERAGE_HS_DIR) ; \
1604
	hpc markup --destdir=../$(COVERAGE_HS_DIR) live-test \
1605
		--srcdir=.. $(HPCEXCL) ; \
1606
	hpc report --srcdir=.. live-test $(HPCEXCL)
1607

    
1608
commit-check: distcheck lint apidoc
1609

    
1610
.PHONY: gitignore-check
1611
gitignore-check:
1612
	@if [ -n "`git status --short`" ]; then \
1613
	  echo "Git status is not clean!" 1>&2 ; \
1614
	  git status --short; \
1615
	  exit 1; \
1616
	fi
1617

    
1618
# we don't need the ancient implicit rules:
1619
%: %,v
1620
%: RCS/%,v
1621
%: RCS/%
1622
%: s.%
1623
%: SCCS/s.%
1624

    
1625
-include ./Makefile.local
1626

    
1627
# vim: set noet :