Statistics
| Branch: | Tag: | Revision:

root / Makefile.am @ 51000365

History | View | Annotate | Download (45.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_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/opcodes.py \
229
	lib/ovf.py \
230
	lib/qlang.py \
231
	lib/query.py \
232
	lib/rpc.py \
233
	lib/rpc_defs.py \
234
	lib/runtime.py \
235
	lib/serializer.py \
236
	lib/ssconf.py \
237
	lib/ssh.py \
238
	lib/storage.py \
239
	lib/uidpool.py \
240
	lib/workerpool.py
241

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
479
$(RUN_IN_TEMPDIR): | stamp-directories
480

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

    
501
doc/html: doc/html/index.html
502

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
630
dist_sbin_SCRIPTS = \
631
	tools/ganeti-listrunner
632

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

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

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

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

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

    
665
nodist_pkglib_python_scripts = \
666
	tools/ensure-dirs
667

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

    
673
nodist_myexeclib_SCRIPTS = \
674
	$(nodist_pkglib_python_scripts)
675

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

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

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

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

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

    
919
haskell_tests = htest/test
920

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

    
929
nodist_TESTS =
930
check_SCRIPTS =
931

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

    
938
TESTS = $(dist_TESTS) $(nodist_TESTS)
939

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

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

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

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

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

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

    
1003
standalone_python_modules = \
1004
	lib/rapi/client.py \
1005
	tools/ganeti-listrunner
1006

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

    
1019
test/daemon-util_unittest.bash: daemons/daemon-util
1020

    
1021
test/ganeti-cleaner_unittest.bash: daemons/ganeti-cleaner
1022

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

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

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

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

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

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

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

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

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

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

    
1081

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

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

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

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

    
1102
.PHONY: clean-vcs-version
1103
clean-vcs-version:
1104
	rm -f vcs-version
1105

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
1405
.PHONY: lint
1406
lint: $(LINT_TARGETS)
1407

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
1606
commit-check: distcheck lint apidoc
1607

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

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

    
1623
-include ./Makefile.local
1624

    
1625
# vim: set noet :