Statistics
| Branch: | Tag: | Revision:

root / Makefile.am @ 6051fd94

History | View | Annotate | Download (45.5 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
# During distcheck, don't try to access anything in the real Xen config
21
# directory (/etc/xen).
22
DISTCHECK_CONFIGURE_FLAGS="--with-xen-config-dir=/tmp"
23

    
24
ACLOCAL_AMFLAGS = -I autotools
25
BUILD_BASH_COMPLETION = $(top_srcdir)/autotools/build-bash-completion
26
RUN_IN_TEMPDIR = $(top_srcdir)/autotools/run-in-tempdir
27
CHECK_PYTHON_CODE = $(top_srcdir)/autotools/check-python-code
28
CHECK_HEADER = $(top_srcdir)/autotools/check-header
29
CHECK_MAN_DASHES = $(top_srcdir)/autotools/check-man-dashes
30
CHECK_MAN_WARNINGS = $(top_srcdir)/autotools/check-man-warnings
31
CHECK_VERSION = $(top_srcdir)/autotools/check-version
32
CHECK_NEWS = $(top_srcdir)/autotools/check-news
33
CHECK_IMPORTS = $(top_srcdir)/autotools/check-imports
34
DOCPP = $(top_srcdir)/autotools/docpp
35
REPLACE_VARS_SED = autotools/replace_vars.sed
36
CONVERT_CONSTANTS = $(top_srcdir)/autotools/convert-constants
37
BUILD_RPC = $(top_srcdir)/autotools/build-rpc
38
SHELL_ENV_INIT = autotools/shell-env-init
39

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

    
58
# Delete output file if an error occurred while building it
59
.DELETE_ON_ERROR:
60

    
61
HTOOLS_DIRS = \
62
	htools \
63
	htools/Ganeti \
64
	htools/Ganeti/Confd \
65
	htools/Ganeti/HTools \
66
	htools/Ganeti/HTools/Program
67

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

    
100
BUILDTIME_DIR_AUTOCREATE = \
101
	scripts \
102
	$(APIDOC_DIR) \
103
	$(APIDOC_PY_DIR) \
104
	$(APIDOC_HS_DIR) \
105
	$(APIDOC_HS_DIR)/Ganeti \
106
	$(APIDOC_HS_DIR)/Ganeti/Confd \
107
	$(APIDOC_HS_DIR)/Ganeti/HTools \
108
	$(APIDOC_HS_DIR)/Ganeti/HTools/Program \
109
	$(COVERAGE_DIR) \
110
	$(COVERAGE_PY_DIR) \
111
	$(COVERAGE_HS_DIR) \
112
	.hpc
113

    
114
BUILDTIME_DIRS = \
115
	$(BUILDTIME_DIR_AUTOCREATE) \
116
	doc/html
117

    
118
DIRCHECK_EXCLUDE = \
119
	$(BUILDTIME_DIRS) \
120
	ganeti-[0-9]*.[0-9]*.[0-9]* \
121
	doc/html/_*
122

    
123
all_dirfiles = $(addsuffix /.dir,$(DIRS) $(BUILDTIME_DIR_AUTOCREATE))
124

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

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

    
141
maintainer-clean-local:
142
	rm -rf $(BUILDTIME_DIRS)
143

    
144
CLEANFILES = \
145
	$(addsuffix /*.py[co],$(DIRS)) \
146
	$(addsuffix /*.hi,$(HTOOLS_DIRS)) \
147
	$(addsuffix /*.o,$(HTOOLS_DIRS)) \
148
	$(all_dirfiles) \
149
	$(PYTHON_BOOTSTRAP) \
150
	epydoc.conf \
151
	autotools/replace_vars.sed \
152
	$(SHELL_ENV_INIT) \
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
	tools/vif-ganeti \
163
	tools/net-common \
164
	stamp-srclinks \
165
	$(nodist_pkgpython_PYTHON) \
166
	$(HS_ALL_PROGS) $(HS_BUILT_SRCS) \
167
	$(HS_BUILT_TEST_HELPERS) \
168
	.hpc/*.mix htools/*.tix \
169
	doc/hs-lint.html
170

    
171
# BUILT_SOURCES should only be used as a dependency on phony
172
# targets. Otherwise it'll cause the target to rebuild every time.
173
BUILT_SOURCES = \
174
  $(built_base_sources) \
175
	$(BUILT_PYTHON_SOURCES) \
176
	$(PYTHON_BOOTSTRAP)
177

    
178
built_base_sources = \
179
	ganeti \
180
	stamp-srclinks \
181
	$(all_dirfiles)
182

    
183
built_python_base_sources = \
184
	lib/_autoconf.py \
185
	lib/_vcsversion.py
186

    
187
BUILT_PYTHON_SOURCES = \
188
	$(built_python_base_sources) \
189
	lib/_generated_rpc.py
190

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

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

    
203
nodist_pkgpython_PYTHON = \
204
	$(BUILT_PYTHON_SOURCES)
205

    
206
noinst_PYTHON = \
207
	lib/build/__init__.py \
208
	lib/build/sphinx_ext.py \
209
	lib/build/shell_example_lexer.py
210

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

    
247
client_PYTHON = \
248
	lib/client/__init__.py \
249
	lib/client/gnt_backup.py \
250
	lib/client/gnt_cluster.py \
251
	lib/client/gnt_debug.py \
252
	lib/client/gnt_group.py \
253
	lib/client/gnt_instance.py \
254
	lib/client/gnt_job.py \
255
	lib/client/gnt_node.py \
256
	lib/client/gnt_network.py \
257
	lib/client/gnt_os.py \
258
	lib/client/gnt_storage.py
259

    
260
hypervisor_PYTHON = \
261
	lib/hypervisor/__init__.py \
262
	lib/hypervisor/hv_base.py \
263
	lib/hypervisor/hv_chroot.py \
264
	lib/hypervisor/hv_fake.py \
265
	lib/hypervisor/hv_kvm.py \
266
	lib/hypervisor/hv_lxc.py \
267
	lib/hypervisor/hv_xen.py
268

    
269
rapi_PYTHON = \
270
	lib/rapi/__init__.py \
271
	lib/rapi/baserlib.py \
272
	lib/rapi/client.py \
273
	lib/rapi/client_utils.py \
274
	lib/rapi/connector.py \
275
	lib/rapi/rlib2.py \
276
	lib/rapi/testutils.py
277

    
278
http_PYTHON = \
279
	lib/http/__init__.py \
280
	lib/http/auth.py \
281
	lib/http/client.py \
282
	lib/http/server.py
283

    
284
confd_PYTHON = \
285
	lib/confd/__init__.py \
286
	lib/confd/client.py \
287
	lib/confd/querylib.py \
288
	lib/confd/server.py
289

    
290
masterd_PYTHON = \
291
	lib/masterd/__init__.py \
292
	lib/masterd/instance.py
293

    
294
impexpd_PYTHON = \
295
	lib/impexpd/__init__.py
296

    
297
watcher_PYTHON = \
298
	lib/watcher/__init__.py \
299
	lib/watcher/nodemaint.py \
300
	lib/watcher/state.py
301

    
302
server_PYTHON = \
303
	lib/server/__init__.py \
304
	lib/server/confd.py \
305
	lib/server/masterd.py \
306
	lib/server/noded.py \
307
	lib/server/rapi.py
308

    
309
pytools_PYTHON = \
310
	lib/tools/__init__.py \
311
	lib/tools/ensure_dirs.py
312

    
313
utils_PYTHON = \
314
	lib/utils/__init__.py \
315
	lib/utils/algo.py \
316
	lib/utils/filelock.py \
317
	lib/utils/hash.py \
318
	lib/utils/io.py \
319
	lib/utils/log.py \
320
	lib/utils/mlock.py \
321
	lib/utils/nodesetup.py \
322
	lib/utils/process.py \
323
	lib/utils/retry.py \
324
	lib/utils/text.py \
325
	lib/utils/wrapper.py \
326
	lib/utils/x509.py
327

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

    
372
HS_PROGS = htools/htools
373
HS_BIN_ROLES = hbal hscan hspace hinfo hcheck
374

    
375
HS_ALL_PROGS = $(HS_PROGS) htools/test htools/hpc-htools htools/hconfd
376
HS_PROG_SRCS = $(patsubst %,%.hs,$(HS_ALL_PROGS))
377
HS_BUILT_TEST_HELPERS = $(HS_BIN_ROLES:%=test/%) test/hail
378

    
379
HFLAGS = -O -Wall -Werror -fwarn-monomorphism-restriction -fwarn-tabs -ihtools
380
# extra flags that can be overriden on the command line (e.g. -Wwarn, etc.)
381
HEXTRA =
382
# internal extra flags (used for htools/test mainly)
383
HEXTRA_INT =
384
# exclude options for coverage reports
385
HPCEXCL = --exclude Main \
386
	--exclude Ganeti.Constants \
387
	--exclude Ganeti.THH \
388
	--exclude Ganeti.HTools.QC \
389
	--exclude Ganeti.HTools.QCHelper \
390
	--exclude Ganeti.HTools.Version
391

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

    
435
HS_BUILT_SRCS = htools/Ganeti/HTools/Version.hs htools/Ganeti/Constants.hs
436
HS_BUILT_SRCS_IN = $(patsubst %,%.in,$(HS_BUILT_SRCS))
437

    
438
$(RUN_IN_TEMPDIR): | $(all_dirfiles)
439

    
440
# Note: we use here an order-only prerequisite, as the contents of
441
# _autoconf.py are not actually influencing the html build output: it
442
# has to exist in order for the sphinx module to be loaded
443
# successfully, but we certainly don't want the docs to be rebuilt if
444
# it changes
445
doc/html/index.html: $(docrst) $(docpng) doc/conf.py configure.ac \
446
	$(RUN_IN_TEMPDIR) lib/build/sphinx_ext.py \
447
	lib/build/shell_example_lexer.py lib/opcodes.py lib/ht.py \
448
	| $(BUILT_PYTHON_SOURCES)
449
	@test -n "$(SPHINX)" || \
450
	    { echo 'sphinx-build' not found during configure; exit 1; }
451
	@mkdir_p@ $(dir $@)
452
	PYTHONPATH=. $(RUN_IN_TEMPDIR) $(SPHINX) -q -W -b html \
453
	    -d . \
454
	    -D version="$(VERSION_MAJOR).$(VERSION_MINOR)" \
455
	    -D release="$(PACKAGE_VERSION)" \
456
	    $(abs_top_srcdir)/doc $(CURDIR)/doc/html
457
	rm -f doc/html/.buildinfo doc/html/objects.inv
458
	touch $@
459

    
460
doc/html: doc/html/index.html
461

    
462
doc/install-quick.rst: INSTALL
463
doc/news.rst: NEWS
464
doc/upgrade.rst: UPGRADE
465

    
466
doc/install-quick.rst doc/news.rst doc/upgrade.rst:
467
	set -e; \
468
	{ echo '.. This file is automatically updated at build time from $<.'; \
469
	  echo '.. Do not edit.'; \
470
	  echo; \
471
	  cat $<; \
472
	} > $@
473

    
474
docdot = \
475
	doc/arch-2.0.dot \
476
	doc/design-2.1-lock-acquire.dot \
477
	doc/design-2.1-lock-release.dot
478

    
479
docpng = $(patsubst %.dot,%.png,$(docdot))
480

    
481
# Things to build but not to install (add it to EXTRA_DIST if it should be
482
# distributed)
483
noinst_DATA = \
484
	devel/upload \
485
	doc/html \
486
	$(BUILT_EXAMPLES) \
487
	doc/examples/bash_completion \
488
	$(manhtml)
489

    
490
gnt_scripts = \
491
	scripts/gnt-backup \
492
	scripts/gnt-cluster \
493
	scripts/gnt-debug \
494
	scripts/gnt-group \
495
	scripts/gnt-instance \
496
	scripts/gnt-job \
497
	scripts/gnt-network \
498
	scripts/gnt-node \
499
	scripts/gnt-os \
500
	scripts/gnt-storage
501

    
502
PYTHON_BOOTSTRAP_SBIN = \
503
	daemons/ganeti-masterd \
504
	daemons/ganeti-noded \
505
	daemons/ganeti-watcher \
506
	daemons/ganeti-rapi \
507
	$(gnt_scripts)
508

    
509
if PY_CONFD
510
PYTHON_BOOTSTRAP_SBIN += daemons/ganeti-confd
511
endif
512

    
513
PYTHON_BOOTSTRAP = \
514
	$(PYTHON_BOOTSTRAP_SBIN) \
515
	tools/ensure-dirs
516

    
517
qa_scripts = \
518
	qa/__init__.py \
519
	qa/ganeti-qa.py \
520
	qa/qa_cluster.py \
521
	qa/qa_config.py \
522
	qa/qa_daemon.py \
523
	qa/qa_env.py \
524
	qa/qa_error.py \
525
	qa/qa_group.py \
526
	qa/qa_instance.py \
527
	qa/qa_job.py \
528
	qa/qa_node.py \
529
	qa/qa_os.py \
530
	qa/qa_rapi.py \
531
	qa/qa_tags.py \
532
	qa/qa_utils.py
533

    
534
bin_SCRIPTS =
535
if WANT_HTOOLS
536
bin_SCRIPTS += $(filter-out htools/hail,$(HS_PROGS))
537
endif
538
install-exec-hook:
539
	@mkdir_p@ "$(DESTDIR)$(XEN_CONFIG_DIR)/scripts"
540
	$(LN_S) -f "$(DESTDIR)$(myexeclibdir)/vif-ganeti" \
541
		"$(DESTDIR)$(XEN_CONFIG_DIR)/scripts/vif-ganeti"
542
if WANT_HTOOLS
543
	@mkdir_p@ $(DESTDIR)$(iallocatorsdir)
544
# FIXME: this is a hardcoded logic, instead of auto-resolving
545
	$(LN_S) -f ../../../bin/htools \
546
		   $(DESTDIR)$(iallocatorsdir)/hail
547
	for role in $(HS_BIN_ROLES); do \
548
		$(LN_S) -f htools \
549
			   $(DESTDIR)$(bindir)/$$role ; \
550
	done
551
if HS_CONFD
552
	mv $(DESTDIR)$(sbindir)/hconfd $(DESTDIR)$(sbindir)/ganeti-confd
553
endif
554
endif
555

    
556
$(HS_ALL_PROGS): %: %.hs $(HS_LIB_SRCS) $(HS_BUILT_SRCS) Makefile
557
	@if [ -z "$(HTOOLS)" ]; then \
558
	  echo "Error: htools compilation disabled at configure time" 1>&2 ;\
559
	  exit 1; \
560
	fi
561
	@BINARY=$(@:htools/%=%); \
562
	if [ "$BINARY" = "test" ] && [ -z "$(GHC_PKG_QUICKCHECK)" ]; then \
563
	  echo "Error: cannot run unittests without the QuickCheck library (see devnotes.rst)" 1>&2; \
564
	  exit 1; \
565
	fi
566
	rm -f $(@:htools/%=%).tix
567
	BINARY=$(@:htools/%=%); $(GHC) --make \
568
	  $(HFLAGS) \
569
	  $(HTOOLS_NOCURL) $(HTOOLS_PARALLEL3) \
570
	  -osuf $$BINARY.o -hisuf $$BINARY.hi \
571
	  $(HEXTRA) $(HEXTRA_INT) $@
572
	@touch "$@"
573

    
574
# for the htools/test binary, we need to enable profiling/coverage
575
htools/test: HEXTRA_INT=-fhpc -Wwarn -fno-warn-missing-signatures \
576
	-fno-warn-monomorphism-restriction -fno-warn-orphans \
577
	-fno-warn-missing-methods -fno-warn-unused-imports
578

    
579
# we compile the hpc-htools binary with the program coverage
580
htools/hpc-htools: HEXTRA_INT=-fhpc
581

    
582
# test dependency
583
htools/offline-tests.sh: htools/hpc-htools
584

    
585
# rules for building profiling-enabled versions of the haskell
586
# programs: hs-prof does the full two-step build, whereas
587
# hs-prof-quick does only the final rebuild (hs-prof must have been
588
# run before)
589
.PHONY: hs-prof hs-prof-quick
590
hs-prof:
591
	$(MAKE) clean
592
	$(MAKE) $(HS_ALL_PROGS) HEXTRA="-osuf .o"
593
	rm -f $(HS_ALL_PROGS)
594
	$(MAKE) hs-prof-quick
595

    
596
hs-prof-quick:
597
	$(MAKE) $(HS_ALL_PROGS) HEXTRA="-osuf .prof_o -prof -auto-all"
598

    
599
dist_sbin_SCRIPTS = \
600
	tools/ganeti-listrunner
601

    
602
nodist_sbin_SCRIPTS = \
603
	$(PYTHON_BOOTSTRAP_SBIN) \
604
	daemons/ganeti-cleaner
605

    
606
if HS_CONFD
607
nodist_sbin_SCRIPTS += htools/hconfd
608
endif
609

    
610
python_scripts = \
611
	tools/burnin \
612
	tools/cfgshell \
613
	tools/cfgupgrade \
614
	tools/cfgupgrade12 \
615
	tools/cluster-merge \
616
	tools/confd-client \
617
	tools/fmtjson \
618
	tools/lvmstrap \
619
	tools/move-instance \
620
	tools/ovfconverter \
621
	tools/setup-ssh \
622
	tools/sanitize-config
623

    
624
dist_tools_SCRIPTS = \
625
	$(python_scripts) \
626
	tools/kvm-console-wrapper \
627
	tools/xen-console-wrapper \
628
	tools/master-ip-setup
629

    
630
pkglib_python_scripts = \
631
	daemons/import-export \
632
	tools/check-cert-expired
633

    
634
nodist_pkglib_python_scripts = \
635
	tools/ensure-dirs
636

    
637
myexeclib_SCRIPTS = \
638
	daemons/daemon-util \
639
	tools/kvm-ifup \
640
	tools/vif-ganeti \
641
	tools/net-common \
642
	$(pkglib_python_scripts)
643

    
644
nodist_myexeclib_SCRIPTS = \
645
	$(nodist_pkglib_python_scripts)
646

    
647
EXTRA_DIST = \
648
	NEWS \
649
	UPGRADE \
650
	epydoc.conf.in \
651
	pylintrc \
652
	autotools/build-bash-completion \
653
	autotools/build-rpc \
654
	autotools/check-header \
655
	autotools/check-python-code \
656
	autotools/check-imports \
657
	autotools/check-man-dashes \
658
	autotools/check-man-warnings \
659
	autotools/check-news \
660
	autotools/check-tar \
661
	autotools/check-version \
662
	autotools/convert-constants \
663
	autotools/docpp \
664
	autotools/gen-coverage \
665
	autotools/testrunner \
666
	autotools/wrong-hardcoded-paths \
667
	$(RUN_IN_TEMPDIR) \
668
	daemons/daemon-util.in \
669
	daemons/ganeti-cleaner.in \
670
	$(pkglib_python_scripts) \
671
	devel/upload.in \
672
	tools/kvm-ifup.in \
673
	$(docdot) \
674
	$(docpng) \
675
	$(docrst) \
676
	doc/conf.py \
677
	tools/vif-ganeti.in \
678
	tools/net-common.in \
679
	doc/html \
680
	$(BUILT_EXAMPLES:%=%.in) \
681
	doc/examples/ganeti.default \
682
	doc/examples/ganeti.default-debug \
683
	doc/examples/hooks/ethers \
684
	doc/examples/gnt-debug/README \
685
	doc/examples/gnt-debug/delay0.json \
686
	doc/examples/gnt-debug/delay50.json \
687
	test/lockperf.py \
688
	test/testutils.py \
689
	test/mocks.py \
690
	$(dist_TESTS) \
691
	$(TEST_FILES) \
692
	man/footer.rst \
693
	$(manrst) \
694
	$(maninput) \
695
	qa/qa-sample.json \
696
	$(qa_scripts) \
697
	$(HS_LIB_SRCS) $(HS_BUILT_SRCS_IN) \
698
	$(HS_PROG_SRCS) \
699
	htools/lint-hints.hs \
700
	htools/cli-tests-defs.sh \
701
	htools/offline-test.sh
702

    
703
man_MANS = \
704
	man/ganeti.7 \
705
	man/ganeti-cleaner.8 \
706
	man/ganeti-confd.8 \
707
	man/ganeti-listrunner.8 \
708
	man/ganeti-masterd.8 \
709
	man/ganeti-noded.8 \
710
	man/ganeti-os-interface.7 \
711
	man/ganeti-extstorage-interface.7 \
712
	man/ganeti-rapi.8 \
713
	man/ganeti-watcher.8 \
714
	man/gnt-backup.8 \
715
	man/gnt-cluster.8 \
716
	man/gnt-debug.8 \
717
	man/gnt-group.8 \
718
	man/gnt-network.8 \
719
	man/gnt-instance.8 \
720
	man/gnt-job.8 \
721
	man/gnt-node.8 \
722
	man/gnt-os.8 \
723
	man/gnt-storage.8 \
724
	man/hail.1 \
725
	man/hbal.1 \
726
	man/hcheck.1 \
727
	man/hinfo.1 \
728
	man/hscan.1 \
729
	man/hspace.1 \
730
	man/htools.1
731

    
732
manrst = $(patsubst %.1,%.rst,$(patsubst %.7,%.rst,$(patsubst %.8,%.rst,$(man_MANS))))
733
manhtml = $(patsubst %.rst,%.html,$(manrst))
734
mangen = $(patsubst %.rst,%.gen,$(manrst))
735
maninput = \
736
	$(patsubst %.1,%.1.in,$(patsubst %.7,%.7.in,$(patsubst %.8,%.8.in,$(man_MANS)))) \
737
	$(patsubst %.html,%.html.in,$(manhtml)) \
738
	man/footer.man man/footer.html $(mangen)
739

    
740
TEST_FILES = \
741
	test/data/bdev-drbd-8.0.txt \
742
	test/data/bdev-drbd-8.3.txt \
743
	test/data/bdev-drbd-disk.txt \
744
	test/data/bdev-drbd-net-ip4.txt \
745
	test/data/bdev-drbd-net-ip6.txt \
746
	test/data/cert1.pem \
747
	test/data/ip-addr-show-dummy0.txt \
748
	test/data/ip-addr-show-lo-ipv4.txt \
749
	test/data/ip-addr-show-lo-ipv6.txt \
750
	test/data/ip-addr-show-lo-oneline-ipv4.txt \
751
	test/data/ip-addr-show-lo-oneline-ipv6.txt \
752
	test/data/ip-addr-show-lo-oneline.txt \
753
	test/data/ip-addr-show-lo.txt \
754
	test/data/proc_drbd8.txt \
755
	test/data/proc_drbd80-emptyline.txt \
756
	test/data/proc_drbd83.txt \
757
	test/data/proc_drbd83_sync.txt \
758
	test/data/proc_drbd83_sync_krnl2.6.39.txt \
759
	test/data/kvm_1.0_help.txt \
760
	test/data/kvm_0.15.90_help.txt \
761
	test/data/kvm_0.12.5_help.txt \
762
	test/data/kvm_0.9.1_help.txt \
763
	test/data/sys_drbd_usermode_helper.txt \
764
	test/data/htools/hail-alloc-drbd.json \
765
	test/data/htools/hail-change-group.json \
766
	test/data/htools/hail-invalid-reloc.json \
767
	test/data/htools/hail-node-evac.json \
768
	test/data/htools/hail-reloc-drbd.json \
769
	test/data/htools/hbal-split-insts.data \
770
	test/data/htools/common-suffix.data \
771
	test/data/htools/invalid-node.data \
772
	test/data/htools/missing-resources.data \
773
	test/data/htools/rapi/groups.json \
774
	test/data/htools/rapi/info.json \
775
	test/data/htools/rapi/instances.json \
776
	test/data/htools/rapi/nodes.json \
777
	test/data/ovfdata/compr_disk.vmdk.gz \
778
	test/data/ovfdata/config.ini \
779
	test/data/ovfdata/corrupted_resources.ovf \
780
	test/data/ovfdata/empty.ini \
781
	test/data/ovfdata/empty.ovf \
782
	test/data/ovfdata/ganeti.mf \
783
	test/data/ovfdata/ganeti.ovf \
784
	test/data/ovfdata/gzip_disk.ovf \
785
	test/data/ovfdata/new_disk.vmdk \
786
	test/data/ovfdata/no_disk.ini \
787
	test/data/ovfdata/no_disk_in_ref.ovf \
788
	test/data/ovfdata/no_os.ini \
789
	test/data/ovfdata/no_ovf.ova \
790
	test/data/ovfdata/ova.ova \
791
	test/data/ovfdata/second_disk.vmdk \
792
	test/data/ovfdata/rawdisk.raw \
793
	test/data/ovfdata/unsafe_path.ini \
794
	test/data/ovfdata/virtualbox.ovf \
795
	test/data/ovfdata/wrong_extension.ovd \
796
	test/data/ovfdata/wrong_config.ini \
797
	test/data/ovfdata/wrong_manifest.mf \
798
	test/data/ovfdata/wrong_manifest.ovf \
799
	test/data/ovfdata/wrong_ova.ova \
800
	test/data/ovfdata/wrong_xml.ovf \
801
	test/data/ovfdata/other/rawdisk.raw \
802
	test/data/vgreduce-removemissing-2.02.02.txt \
803
	test/data/vgreduce-removemissing-2.02.66-fail.txt \
804
	test/data/vgreduce-removemissing-2.02.66-ok.txt \
805
	test/data/vgs-missing-pvs-2.02.02.txt \
806
	test/data/vgs-missing-pvs-2.02.66.txt \
807
	test/import-export_unittest-helper \
808
	test/gnt-cli.test \
809
	test/ganeti-cli.test \
810
	test/htools-balancing.test \
811
	test/htools-basic.test \
812
	test/htools-dynutil.test \
813
	test/htools-excl.test \
814
	test/htools-hail.test \
815
	test/htools-hspace.test \
816
	test/htools-invalid.test \
817
	test/htools-multi-group.test \
818
	test/htools-no-backend.test \
819
	test/htools-rapi.test \
820
	test/htools-single-group.test \
821
	test/htools-text-backend.test
822

    
823
python_tests = \
824
	doc/examples/rapi_testutils.py \
825
	test/ganeti.asyncnotifier_unittest.py \
826
	test/ganeti.backend_unittest.py \
827
	test/ganeti.bdev_unittest.py \
828
	test/ganeti.cli_unittest.py \
829
	test/ganeti.client.gnt_cluster_unittest.py \
830
	test/ganeti.client.gnt_instance_unittest.py \
831
	test/ganeti.daemon_unittest.py \
832
	test/ganeti.cmdlib_unittest.py \
833
	test/ganeti.compat_unittest.py \
834
	test/ganeti.confd.client_unittest.py \
835
	test/ganeti.config_unittest.py \
836
	test/ganeti.constants_unittest.py \
837
	test/ganeti.errors_unittest.py \
838
	test/ganeti.hooks_unittest.py \
839
	test/ganeti.ht_unittest.py \
840
	test/ganeti.http_unittest.py \
841
	test/ganeti.hypervisor_unittest.py \
842
	test/ganeti.hypervisor.hv_chroot_unittest.py \
843
	test/ganeti.hypervisor.hv_fake_unittest.py \
844
	test/ganeti.hypervisor.hv_kvm_unittest.py \
845
	test/ganeti.hypervisor.hv_lxc_unittest.py \
846
	test/ganeti.hypervisor.hv_xen_unittest.py \
847
	test/ganeti.impexpd_unittest.py \
848
	test/ganeti.jqueue_unittest.py \
849
	test/ganeti.locking_unittest.py \
850
	test/ganeti.luxi_unittest.py \
851
	test/ganeti.masterd.instance_unittest.py \
852
	test/ganeti.mcpu_unittest.py \
853
	test/ganeti.netutils_unittest.py \
854
	test/ganeti.objects_unittest.py \
855
	test/ganeti.opcodes_unittest.py \
856
	test/ganeti.ovf_unittest.py \
857
	test/ganeti.qlang_unittest.py \
858
	test/ganeti.query_unittest.py \
859
	test/ganeti.rapi.baserlib_unittest.py \
860
	test/ganeti.rapi.client_unittest.py \
861
	test/ganeti.rapi.resources_unittest.py \
862
	test/ganeti.rapi.rlib2_unittest.py \
863
	test/ganeti.rapi.testutils_unittest.py \
864
	test/ganeti.rpc_unittest.py \
865
	test/ganeti.runtime_unittest.py \
866
	test/ganeti.serializer_unittest.py \
867
	test/ganeti.ssh_unittest.py \
868
	test/ganeti.storage_unittest.py \
869
	test/ganeti.tools.ensure_dirs_unittest.py \
870
	test/ganeti.uidpool_unittest.py \
871
	test/ganeti.utils.algo_unittest.py \
872
	test/ganeti.utils.filelock_unittest.py \
873
	test/ganeti.utils.hash_unittest.py \
874
	test/ganeti.utils.io_unittest.py \
875
	test/ganeti.utils.log_unittest.py \
876
	test/ganeti.utils.mlock_unittest.py \
877
	test/ganeti.utils.nodesetup_unittest.py \
878
	test/ganeti.utils.process_unittest.py \
879
	test/ganeti.utils.retry_unittest.py \
880
	test/ganeti.utils.text_unittest.py \
881
	test/ganeti.utils.wrapper_unittest.py \
882
	test/ganeti.utils.x509_unittest.py \
883
	test/ganeti.utils_unittest.py \
884
	test/ganeti.workerpool_unittest.py \
885
	test/qa.qa_config_unittest.py \
886
	test/cfgupgrade_unittest.py \
887
	test/docs_unittest.py \
888
	test/pycurl_reset_unittest.py \
889
	test/tempfile_fork_unittest.py
890
if HAS_FAKEROOT
891
python_tests += test/ganeti.utils.io_unittest-runasroot.py
892
endif
893

    
894
haskell_tests = htools/test
895

    
896
dist_TESTS = \
897
	test/check-cert-expired_unittest.bash \
898
	test/daemon-util_unittest.bash \
899
	test/ganeti-cleaner_unittest.bash \
900
	test/import-export_unittest.bash \
901
	test/cli-test.bash \
902
	$(python_tests)
903

    
904
nodist_TESTS =
905
check_SCRIPTS =
906

    
907
if WANT_HTOOLSTESTS
908
nodist_TESTS += $(haskell_tests)
909
dist_TESTS += htools/offline-test.sh
910
check_SCRIPTS += htools/hpc-htools $(HS_BUILT_TEST_HELPERS)
911
endif
912

    
913
TESTS = $(dist_TESTS) $(nodist_TESTS)
914

    
915
# Environment for all tests
916
PLAIN_TESTS_ENVIRONMENT = \
917
	PYTHONPATH=. \
918
	TOP_SRCDIR=$(abs_top_srcdir) TOP_BUILDDIR=$(abs_top_builddir) \
919
	PYTHON=$(PYTHON) FAKEROOT=$(FAKEROOT_PATH) \
920
	$(RUN_IN_TEMPDIR)
921

    
922
# Environment for tests run by automake
923
TESTS_ENVIRONMENT = \
924
	$(PLAIN_TESTS_ENVIRONMENT) $(abs_top_srcdir)/autotools/testrunner
925

    
926
all_python_code = \
927
	$(dist_sbin_SCRIPTS) \
928
	$(python_scripts) \
929
	$(pkglib_python_scripts) \
930
	$(nodist_pkglib_python_scripts) \
931
	$(python_tests) \
932
	$(pkgpython_PYTHON) \
933
	$(client_PYTHON) \
934
	$(hypervisor_PYTHON) \
935
	$(rapi_PYTHON) \
936
	$(server_PYTHON) \
937
	$(pytools_PYTHON) \
938
	$(http_PYTHON) \
939
	$(confd_PYTHON) \
940
	$(masterd_PYTHON) \
941
	$(impexpd_PYTHON) \
942
	$(utils_PYTHON) \
943
	$(watcher_PYTHON) \
944
	$(noinst_PYTHON) \
945
	$(qa_scripts)
946

    
947
srclink_files = \
948
	man/footer.rst \
949
	test/check-cert-expired_unittest.bash \
950
	test/daemon-util_unittest.bash \
951
	test/ganeti-cleaner_unittest.bash \
952
	test/import-export_unittest.bash \
953
	test/cli-test.bash \
954
	htools/offline-test.sh \
955
	htools/cli-tests-defs.sh \
956
	$(all_python_code) \
957
	$(HS_LIB_SRCS) $(HS_PROG_SRCS)
958

    
959
check_python_code = \
960
	$(BUILD_BASH_COMPLETION) \
961
	$(CHECK_IMPORTS) \
962
	$(CHECK_HEADER) \
963
	$(DOCPP) \
964
	$(all_python_code)
965

    
966
lint_python_code = \
967
	ganeti \
968
	ganeti/http/server.py \
969
	$(dist_sbin_SCRIPTS) \
970
	$(python_scripts) \
971
	$(pkglib_python_scripts) \
972
	$(BUILD_BASH_COMPLETION) \
973
	$(CHECK_IMPORTS) \
974
	$(CHECK_HEADER) \
975
	$(DOCPP) \
976
	$(PYTHON_BOOTSTRAP)
977

    
978
standalone_python_modules = \
979
	lib/rapi/client.py \
980
	tools/ganeti-listrunner
981

    
982
pep8_python_code = \
983
	ganeti \
984
	ganeti/http/server.py \
985
	$(dist_sbin_SCRIPTS) \
986
	$(python_scripts) \
987
	$(pkglib_python_scripts) \
988
	$(BUILD_BASH_COMPLETION) \
989
	$(CHECK_HEADER) \
990
	$(DOCPP) \
991
	$(PYTHON_BOOTSTRAP) \
992
	qa
993

    
994
test/daemon-util_unittest.bash: daemons/daemon-util
995

    
996
test/ganeti-cleaner_unittest.bash: daemons/ganeti-cleaner
997

    
998
tools/kvm-ifup: tools/kvm-ifup.in $(REPLACE_VARS_SED)
999
	sed -f $(REPLACE_VARS_SED) < $< > $@
1000
	chmod +x $@
1001

    
1002
tools/vif-ganeti: tools/vif-ganeti.in $(REPLACE_VARS_SED)
1003
	sed -f $(REPLACE_VARS_SED) < $< > $@
1004
	chmod +x $@
1005

    
1006
tools/net-common: tools/net-common.in $(REPLACE_VARS_SED)
1007
	sed -f $(REPLACE_VARS_SED) < $< > $@
1008
	chmod +x $@
1009

    
1010
devel/upload: devel/upload.in $(REPLACE_VARS_SED)
1011
	sed -f $(REPLACE_VARS_SED) < $< > $@
1012
	chmod u+x $@
1013

    
1014
daemons/%: daemons/%.in $(REPLACE_VARS_SED)
1015
	sed -f $(REPLACE_VARS_SED) < $< > $@
1016
	chmod +x $@
1017

    
1018
doc/examples/%: doc/examples/%.in $(REPLACE_VARS_SED)
1019
	sed -f $(REPLACE_VARS_SED) < $< > $@
1020

    
1021
doc/examples/hooks/%: doc/examples/hooks/%.in $(REPLACE_VARS_SED)
1022
	sed -f $(REPLACE_VARS_SED) < $< > $@
1023

    
1024
doc/examples/bash_completion: $(BUILD_BASH_COMPLETION) $(RUN_IN_TEMPDIR) \
1025
	lib/cli.py $(gnt_scripts) $(client_PYTHON) tools/burnin
1026
	PYTHONPATH=. $(RUN_IN_TEMPDIR) $(CURDIR)/$(BUILD_BASH_COMPLETION) > $@
1027

    
1028
doc/%.png: doc/%.dot
1029
	@test -n "$(DOT)" || { echo 'dot' not found during configure; exit 1; }
1030
	$(DOT) -Tpng -o $@ $<
1031

    
1032
man/footer.man: man/footer.rst
1033
	@test -n "$(PANDOC)" || \
1034
	  { echo 'pandoc' not found during configure; exit 1; }
1035
	$(PANDOC) -f rst -t man -o $@ $<
1036

    
1037
man/footer.html: man/footer.rst
1038
	@test -n "$(PANDOC)" || \
1039
	  { echo 'pandoc' not found during configure; exit 1; }
1040
	$(PANDOC) -f rst -t html -o $@ $<
1041

    
1042
man/%.gen: man/%.rst lib/query.py lib/build/sphinx_ext.py \
1043
	lib/build/shell_example_lexer.py \
1044
	| $(RUN_IN_TEMPDIR) $(BUILT_PYTHON_SOURCES)
1045
	@echo "Checking $< for hardcoded paths..."
1046
	@if grep -nEf autotools/wrong-hardcoded-paths $<; then \
1047
	  echo "Man page $< has harcoded paths (see above)!" 1>&2 ; \
1048
	  exit 1; \
1049
	fi
1050
	set -e ; \
1051
	trap 'echo auto-removing $@; rm $@' EXIT; \
1052
	PYTHONPATH=. $(RUN_IN_TEMPDIR) $(CURDIR)/$(DOCPP) < $< > $@ ;\
1053
	trap - EXIT
1054

    
1055
man/%.7.in man/%.8.in man/%.1.in: man/%.gen man/footer.man
1056
	@test -n "$(PANDOC)" || \
1057
	  { echo 'pandoc' not found during configure; exit 1; }
1058
	set -o pipefail ; \
1059
	trap 'echo auto-removing $@; rm $@' EXIT; \
1060
	$(PANDOC) -s -f rst -t man -A man/footer.man $< | \
1061
	  sed -e 's/\\@/@/g' > $@; \
1062
	if test -n "$(MAN_HAS_WARNINGS)"; then $(CHECK_MAN_WARNINGS) $@; fi; \
1063
	$(CHECK_MAN_DASHES) $@; \
1064
	trap - EXIT
1065

    
1066

    
1067
man/%.html.in: man/%.gen man/footer.html
1068
	@test -n "$(PANDOC)" || \
1069
	  { echo 'pandoc' not found during configure; exit 1; }
1070
	set -o pipefail ; \
1071
	$(PANDOC) -s -f rst -t html -A man/footer.html $< | \
1072
	  sed -e 's/\\@/@/g' > $@
1073

    
1074
man/%.1: man/%.1.in $(REPLACE_VARS_SED)
1075
	sed -f $(REPLACE_VARS_SED) < $< > $@
1076

    
1077
man/%.7: man/%.7.in $(REPLACE_VARS_SED)
1078
	sed -f $(REPLACE_VARS_SED) < $< > $@
1079

    
1080
man/%.8: man/%.8.in $(REPLACE_VARS_SED)
1081
	sed -f $(REPLACE_VARS_SED) < $< > $@
1082

    
1083
man/%.html: man/%.html.in $(REPLACE_VARS_SED)
1084
	sed -f $(REPLACE_VARS_SED) < $< > $@
1085

    
1086
epydoc.conf: epydoc.conf.in Makefile
1087
	sed -e 's#@MODULES@#$(strip $(lint_python_code))#g' < $< > $@
1088

    
1089
vcs-version:
1090
	if test -d .git; then \
1091
	  git describe > $@; \
1092
	elif test ! -f $@ ; then \
1093
	  echo "Cannot auto-generate $@ file"; exit 1; \
1094
	fi
1095

    
1096
.PHONY: clean-vcs-version
1097
clean-vcs-version:
1098
	rm -f vcs-version
1099

    
1100
.PHONY: regen-vcs-version
1101
regen-vcs-version:
1102
	set -e; \
1103
	cd $(srcdir); \
1104
	if test -d .git; then \
1105
	  $(MAKE) clean-vcs-version; \
1106
	  $(MAKE) vcs-version; \
1107
	fi
1108

    
1109
htools/Ganeti/HTools/Version.hs: htools/Ganeti/HTools/Version.hs.in vcs-version
1110
	set -e; \
1111
	VCSVER=`cat $(abs_top_srcdir)/vcs-version`; \
1112
	sed -e "s/%ver%/$$VCSVER/" < $< > $@
1113

    
1114
htools/Ganeti/Constants.hs: htools/Ganeti/Constants.hs.in \
1115
	lib/constants.py lib/_autoconf.py lib/luxi.py \
1116
	$(CONVERT_CONSTANTS) \
1117
	| lib/_vcsversion.py
1118
	set -e; \
1119
	{ cat $< ; PYTHONPATH=. $(CONVERT_CONSTANTS); } > $@
1120

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

    
1195
lib/_vcsversion.py: Makefile vcs-version | lib/.dir
1196
	set -e; \
1197
	VCSVER=`cat $(abs_top_srcdir)/vcs-version`; \
1198
	{ echo '# This file is automatically generated, do not edit!'; \
1199
	  echo '#'; \
1200
	  echo ''; \
1201
	  echo '"""Build-time VCS version number for Ganeti.'; \
1202
	  echo '';\
1203
	  echo 'This file is autogenerated by the build process.'; \
1204
	  echo 'For any changes you need to re-run ./configure (and'; \
1205
	  echo 'not edit by hand).'; \
1206
	  echo ''; \
1207
	  echo '"""'; \
1208
	  echo ''; \
1209
	  echo '# pylint: disable=C0301,C0324'; \
1210
	  echo '# because this is autogenerated, we do not want'; \
1211
	  echo '# style warnings' ; \
1212
	  echo ''; \
1213
	  echo "VCS_VERSION = '$$VCSVER'"; \
1214
	} > $@
1215

    
1216
lib/_generated_rpc.py: lib/rpc_defs.py $(BUILD_RPC)
1217
	PYTHONPATH=. $(RUN_IN_TEMPDIR) $(CURDIR)/$(BUILD_RPC) lib/rpc_defs.py > $@
1218

    
1219
$(SHELL_ENV_INIT): Makefile
1220
	set -e; \
1221
	{ echo '# Allow overriding for tests'; \
1222
	 echo 'readonly LOCALSTATEDIR=$${LOCALSTATEDIR:-$${GANETI_ROOTDIR:-}$(localstatedir)}'; \
1223
	 echo 'readonly SYSCONFDIR=$${SYSCONFDIR:-$${GANETI_ROOTDIR:-}$(sysconfdir)}'; \
1224
	 echo; \
1225
	 echo 'readonly PKGLIBDIR=$(pkglibdir)'; \
1226
	 echo 'readonly LOG_DIR="$$LOCALSTATEDIR/log/ganeti"'; \
1227
	 echo 'readonly RUN_DIR="$$LOCALSTATEDIR/run/ganeti"'; \
1228
	 echo 'readonly DATA_DIR="$$LOCALSTATEDIR/lib/ganeti"'; \
1229
	 echo 'readonly CONF_DIR="$$SYSCONFDIR/ganeti"'; \
1230
	} > $@
1231

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

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

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

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

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

    
1322
.PHONY: ganeti
1323
ganeti:
1324
	cd $(top_builddir) && test -h "$@" || { rm -f $@ && $(LN_S) lib $@; }
1325

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

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

    
1369
.PHONY: hs-check
1370
hs-check: htools/test htools/hpc-htools $(HS_BUILT_TEST_HELPERS)
1371
	@rm -f test.tix
1372
	./htools/test
1373
	HBINARY="./htools/hpc-htools" ./htools/offline-test.sh
1374

    
1375
# E111: indentation is not a multiple of four
1376
# E121: continuation line indentation is not a multiple of four
1377
#       (since our indent level is not 4)
1378
# E125: continuation line does not distinguish itself from next logical line
1379
#       (since our indent level is not 4)
1380
# E127: continuation line over-indented for visual indent
1381
#       (since our indent level is not 4)
1382
# E122,E123,E126,E128,E262,E272,E502,E711,: added temporarily to not
1383
#       modify stable code; do NOT merge these into master!
1384
# E261: at least two spaces before inline comment
1385
# E501: line too long (80 characters)
1386
PEP8_IGNORE = E111,E121,E122,E123,E125,E126,E127,E128,E261,E262,E272,E501,E502,E711
1387

    
1388
# For excluding pep8 expects filenames only, not whole paths
1389
PEP8_EXCLUDE = $(subst $(space),$(comma),$(strip $(notdir $(BUILT_PYTHON_SOURCES))))
1390

    
1391
LINT_TARGETS = pylint pylint-qa
1392
if HAS_PEP8
1393
LINT_TARGETS += pep8
1394
endif
1395
if HAS_HLINT
1396
LINT_TARGETS += hlint
1397
endif
1398

    
1399
.PHONY: lint
1400
lint: $(LINT_TARGETS)
1401

    
1402
.PHONY: pylint
1403
pylint: $(BUILT_SOURCES)
1404
	@test -n "$(PYLINT)" || { echo 'pylint' not found during configure; exit 1; }
1405
	$(PYLINT) $(LINT_OPTS) $(lint_python_code)
1406

    
1407
.PHONY: pylint-qa
1408
pylint-qa: $(BUILT_SOURCES)
1409
	@test -n "$(PYLINT)" || { echo 'pylint' not found during configure; exit 1; }
1410
	cd $(top_srcdir)/qa && \
1411
	  PYTHONPATH=$(abs_top_srcdir) $(PYLINT) $(LINT_OPTS) \
1412
	  --rcfile  ../pylintrc $(patsubst qa/%.py,%,$(qa_scripts))
1413

    
1414
.PHONY: pep8
1415
pep8: $(BUILT_SOURCES)
1416
	@test -n "$(PEP8)" || { echo 'pep8' not found during configure; exit 1; }
1417
	$(PEP8) --ignore='$(PEP8_IGNORE)' --exclude='$(PEP8_EXCLUDE)' \
1418
		--repeat $(pep8_python_code)
1419

    
1420
.PHONY: hlint
1421
hlint: $(HS_BUILT_SRCS) htools/lint-hints.hs
1422
	@test -n "$(HLINT)" || { echo 'hlint' not found during configure; exit 1; }
1423
	if tty -s; then C="-c"; else C=""; fi; \
1424
	$(HLINT) --report=doc/hs-lint.html --cross $$C \
1425
	  --ignore "Use first" \
1426
	  --ignore "Use comparing" \
1427
	  --ignore "Use on" \
1428
	  --ignore "Reduce duplication" \
1429
	  --hint htools/lint-hints \
1430
	  $(filter-out htools/Ganeti/THH.hs,$(HS_LIB_SRCS))
1431

    
1432
# a dist hook rule for updating the vcs-version file; this is
1433
# hardcoded due to where it needs to build the file...
1434
dist-hook:
1435
	$(MAKE) regen-vcs-version
1436
	rm -f $(top_distdir)/vcs-version
1437
	cp -p $(srcdir)/vcs-version $(top_distdir)
1438

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

    
1468
# When building a release, stricter checks should be used
1469
distcheck-release dist-release: export BUILD_RELEASE = 1
1470
distcheck-release: distcheck
1471

    
1472
distrebuildcheck: dist
1473
	set -e; \
1474
	builddir=$$(mktemp -d $(abs_srcdir)/distrebuildcheck.XXXXXXX); \
1475
	trap "echo Removing $$builddir; cd $(abs_srcdir); rm -rf $$builddir" EXIT; \
1476
	cd $$builddir; \
1477
	tar xzf $(abs_srcdir)/$(distdir).tar.gz; \
1478
	cd $(distdir); \
1479
	./configure; \
1480
	$(MAKE) maintainer-clean; \
1481
	cp $(abs_srcdir)/vcs-version .; \
1482
	./configure; \
1483
	$(MAKE) $(AM_MAKEFLAGS)
1484

    
1485
dist-release: dist
1486
	set -e; \
1487
	for i in $(DIST_ARCHIVES); do \
1488
		echo -n "Checking $$i ... "; \
1489
		autotools/check-tar < $$i; \
1490
		echo OK; \
1491
	done
1492

    
1493
install-exec-local:
1494
	@mkdir_p@ "$(DESTDIR)${localstatedir}/lib/ganeti" \
1495
	  "$(DESTDIR)${localstatedir}/log/ganeti" \
1496
	  "$(DESTDIR)${localstatedir}/run/ganeti"
1497

    
1498
# To avoid conflicts between directory names and other targets, a file inside
1499
# the directory is used to ensure its existence.
1500
%.dir:
1501
	@mkdir_p@ $* && touch $@
1502

    
1503
.PHONY: apidoc
1504
if WANT_HTOOLSAPIDOC
1505
apidoc: py-apidoc hs-apidoc
1506
else
1507
apidoc: py-apidoc
1508
endif
1509

    
1510
.PHONY: py-apidoc
1511
py-apidoc: epydoc.conf $(RUN_IN_TEMPDIR) $(BUILT_SOURCES)
1512
	$(RUN_IN_TEMPDIR) epydoc -v \
1513
		--conf $(CURDIR)/epydoc.conf \
1514
		--output $(CURDIR)/$(APIDOC_PY_DIR)
1515

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

    
1549
.PHONY: TAGS
1550
TAGS: $(BUILT_SOURCES)
1551
	rm -f TAGS
1552
	find . -path './lib/*.py' -o -path './scripts/gnt-*' -o \
1553
	  -path './daemons/ganeti-*' -o -path './tools/*' -o \
1554
	  -path './qa/*.py' | \
1555
	  etags -l python -
1556

    
1557
.PHONY: coverage
1558
if WANT_HTOOLS
1559
coverage: py-coverage hs-coverage
1560
else
1561
coverage: py-coverage
1562
endif
1563

    
1564
.PHONY: py-coverage
1565
py-coverage: $(BUILT_SOURCES) $(python_tests)
1566
	set -e; \
1567
	COVERAGE_FILE=$(CURDIR)/$(COVERAGE_PY_DIR)/data \
1568
	TEXT_COVERAGE=$(CURDIR)/$(COVERAGE_PY_DIR)/report.txt \
1569
	HTML_COVERAGE=$(CURDIR)/$(COVERAGE_PY_DIR) \
1570
	$(PLAIN_TESTS_ENVIRONMENT) $(abs_top_srcdir)/autotools/gen-coverage \
1571
	$(python_tests)
1572

    
1573
.PHONY: hs-coverage
1574
hs-coverage: $(haskell_tests) htools/hpc-htools
1575
	rm -f *.tix
1576
	$(MAKE) hs-check
1577
	@mkdir_p@ $(COVERAGE_HS_DIR)
1578
	hpc combine $(HPCEXCL) test.tix hpc-htools.tix > coverage-htools.tix
1579
	hpc markup --destdir=$(COVERAGE_HS_DIR) coverage-htools.tix
1580
	hpc report coverage-htools.tix
1581
	$(LN_S) -f hpc_index.html $(COVERAGE_HS_DIR)/index.html
1582

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

    
1599
commit-check: distcheck lint apidoc
1600

    
1601
.PHONY: gitignore-check
1602
gitignore-check:
1603
	@if [ -n "`git status --short`" ]; then \
1604
	  echo "Git status is not clean!" 1>&2 ; \
1605
	  git status --short; \
1606
	  exit 1; \
1607
	fi
1608

    
1609
-include ./Makefile.local
1610

    
1611
# vim: set noet :