Statistics
| Branch: | Tag: | Revision:

root / Makefile.am @ 33b4fa9f

History | View | Annotate | Download (46.4 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
	doc/examples/bash_completion-debug \
159
	lib/_generated_rpc.py \
160
	$(man_MANS) \
161
	$(manhtml) \
162
	tools/kvm-ifup \
163
	stamp-directories \
164
	stamp-srclinks \
165
	$(nodist_pkgpython_PYTHON) \
166
	$(HS_ALL_PROGS) $(HS_BUILT_SRCS) \
167
	$(HS_BUILT_TEST_HELPERS) \
168
	.hpc/*.mix htools/*.tix htest/*.tix \
169
	doc/hs-lint.html
170

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

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

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

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

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

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

    
200
nodist_pkgpython_PYTHON = \
201
	$(BUILT_PYTHON_SOURCES)
202

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

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

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

    
257
hypervisor_PYTHON = \
258
	lib/hypervisor/__init__.py \
259
	lib/hypervisor/hv_base.py \
260
	lib/hypervisor/hv_chroot.py \
261
	lib/hypervisor/hv_fake.py \
262
	lib/hypervisor/hv_kvm.py \
263
	lib/hypervisor/hv_lxc.py \
264
	lib/hypervisor/hv_xen.py
265

    
266
rapi_PYTHON = \
267
	lib/rapi/__init__.py \
268
	lib/rapi/baserlib.py \
269
	lib/rapi/client.py \
270
	lib/rapi/client_utils.py \
271
	lib/rapi/connector.py \
272
	lib/rapi/rlib2.py \
273
	lib/rapi/testutils.py
274

    
275
http_PYTHON = \
276
	lib/http/__init__.py \
277
	lib/http/auth.py \
278
	lib/http/client.py \
279
	lib/http/server.py
280

    
281
confd_PYTHON = \
282
	lib/confd/__init__.py \
283
	lib/confd/client.py \
284
	lib/confd/querylib.py \
285
	lib/confd/server.py
286

    
287
masterd_PYTHON = \
288
	lib/masterd/__init__.py \
289
	lib/masterd/iallocator.py \
290
	lib/masterd/instance.py
291

    
292
impexpd_PYTHON = \
293
	lib/impexpd/__init__.py
294

    
295
watcher_PYTHON = \
296
	lib/watcher/__init__.py \
297
	lib/watcher/nodemaint.py \
298
	lib/watcher/state.py
299

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

    
307
pytools_PYTHON = \
308
	lib/tools/__init__.py \
309
	lib/tools/ensure_dirs.py
310

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

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

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

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

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

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

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

    
477
HS_LIBTEST_SRCS = $(HS_LIB_SRCS) $(HS_TEST_SRCS)
478

    
479
HS_BUILT_SRCS = \
480
	htest/Test/Ganeti/TestImports.hs \
481
	htools/Ganeti/Constants.hs \
482
	htools/Ganeti/Version.hs
483
HS_BUILT_SRCS_IN = $(patsubst %,%.in,$(HS_BUILT_SRCS))
484

    
485
$(RUN_IN_TEMPDIR): | stamp-directories
486

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

    
507
doc/html: doc/html/index.html
508

    
509
doc/install-quick.rst: INSTALL
510
doc/news.rst: NEWS
511
doc/upgrade.rst: UPGRADE
512

    
513
doc/install-quick.rst doc/news.rst doc/upgrade.rst:
514
	set -e; \
515
	{ echo '.. This file is automatically updated at build time from $<.'; \
516
	  echo '.. Do not edit.'; \
517
	  echo; \
518
	  cat $<; \
519
	} > $@
520

    
521
docdot = \
522
	doc/arch-2.0.dot \
523
	doc/design-2.1-lock-acquire.dot \
524
	doc/design-2.1-lock-release.dot
525

    
526
docpng = $(patsubst %.dot,%.png,$(docdot))
527

    
528
# Things to build but not to install (add it to EXTRA_DIST if it should be
529
# distributed)
530
noinst_DATA = \
531
	devel/upload \
532
	doc/html \
533
	$(BUILT_EXAMPLES) \
534
	doc/examples/bash_completion \
535
	doc/examples/bash_completion-debug \
536
	$(manhtml)
537

    
538
gnt_scripts = \
539
	scripts/gnt-backup \
540
	scripts/gnt-cluster \
541
	scripts/gnt-debug \
542
	scripts/gnt-group \
543
	scripts/gnt-instance \
544
	scripts/gnt-job \
545
	scripts/gnt-node \
546
	scripts/gnt-os
547

    
548
PYTHON_BOOTSTRAP_SBIN = \
549
	daemons/ganeti-masterd \
550
	daemons/ganeti-noded \
551
	daemons/ganeti-watcher \
552
	daemons/ganeti-rapi \
553
	$(gnt_scripts)
554

    
555
if PY_CONFD
556
PYTHON_BOOTSTRAP_SBIN += daemons/ganeti-confd
557
endif
558

    
559
PYTHON_BOOTSTRAP = \
560
	$(PYTHON_BOOTSTRAP_SBIN) \
561
	tools/ensure-dirs
562

    
563
qa_scripts = \
564
	qa/__init__.py \
565
	qa/ganeti-qa.py \
566
	qa/qa_cluster.py \
567
	qa/qa_config.py \
568
	qa/qa_daemon.py \
569
	qa/qa_env.py \
570
	qa/qa_error.py \
571
	qa/qa_group.py \
572
	qa/qa_instance.py \
573
	qa/qa_job.py \
574
	qa/qa_node.py \
575
	qa/qa_os.py \
576
	qa/qa_rapi.py \
577
	qa/qa_tags.py \
578
	qa/qa_utils.py
579

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

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

    
614
# for the htest/test binary, we need to enable profiling/coverage
615
htest/test: HEXTRA_INT=-fhpc -ihtest
616

    
617
# we compile the hpc-htools binary with the program coverage
618
htest/hpc-htools: HEXTRA_INT=-fhpc
619

    
620
# test dependency
621
htest/offline-tests.sh: htest/hpc-htools
622

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

    
634
hs-prof-quick:
635
	$(MAKE) $(AM_MAKEFLAGS) $(HS_ALL_PROGS) HEXTRA="-osuf .prof_o -prof -auto-all"
636

    
637
dist_sbin_SCRIPTS = \
638
	tools/ganeti-listrunner
639

    
640
nodist_sbin_SCRIPTS = \
641
	$(PYTHON_BOOTSTRAP_SBIN) \
642
	daemons/ganeti-cleaner
643

    
644
if HS_CONFD
645
nodist_sbin_SCRIPTS += htools/hconfd
646
endif
647

    
648
python_scripts = \
649
	tools/burnin \
650
	tools/cfgshell \
651
	tools/cfgupgrade \
652
	tools/cfgupgrade12 \
653
	tools/cluster-merge \
654
	tools/confd-client \
655
	tools/fmtjson \
656
	tools/lvmstrap \
657
	tools/move-instance \
658
	tools/ovfconverter \
659
	tools/setup-ssh \
660
	tools/sanitize-config
661

    
662
dist_tools_SCRIPTS = \
663
	$(python_scripts) \
664
	tools/kvm-console-wrapper \
665
	tools/xm-console-wrapper \
666
	tools/master-ip-setup
667

    
668
pkglib_python_scripts = \
669
	daemons/import-export \
670
	tools/check-cert-expired
671

    
672
nodist_pkglib_python_scripts = \
673
	tools/ensure-dirs
674

    
675
myexeclib_SCRIPTS = \
676
	daemons/daemon-util \
677
	tools/kvm-ifup \
678
	$(pkglib_python_scripts)
679

    
680
nodist_myexeclib_SCRIPTS = \
681
	$(nodist_pkglib_python_scripts)
682

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

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

    
763
manrst = $(patsubst %.1,%.rst,$(patsubst %.7,%.rst,$(patsubst %.8,%.rst,$(man_MANS))))
764
manhtml = $(patsubst %.rst,%.html,$(manrst))
765
mangen = $(patsubst %.rst,%.gen,$(manrst))
766
maninput = \
767
	$(patsubst %.1,%.1.in,$(patsubst %.7,%.7.in,$(patsubst %.8,%.8.in,$(man_MANS)))) \
768
	$(patsubst %.html,%.html.in,$(manhtml)) \
769
	man/footer.man man/footer.html $(mangen)
770

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

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

    
929
haskell_tests = htest/test
930

    
931
dist_TESTS = \
932
	test/check-cert-expired_unittest.bash \
933
	test/daemon-util_unittest.bash \
934
	test/ganeti-cleaner_unittest.bash \
935
	test/import-export_unittest.bash \
936
	test/cli-test.bash \
937
	$(python_tests)
938

    
939
nodist_TESTS =
940
check_SCRIPTS =
941

    
942
if WANT_HTOOLSTESTS
943
nodist_TESTS += $(haskell_tests)
944
dist_TESTS += htest/offline-test.sh
945
check_SCRIPTS += htest/hpc-htools $(HS_BUILT_TEST_HELPERS)
946
endif
947

    
948
TESTS = $(dist_TESTS) $(nodist_TESTS)
949

    
950
# Environment for all tests
951
PLAIN_TESTS_ENVIRONMENT = \
952
	PYTHONPATH=. \
953
	TOP_SRCDIR=$(abs_top_srcdir) TOP_BUILDDIR=$(abs_top_builddir) \
954
	PYTHON=$(PYTHON) FAKEROOT=$(FAKEROOT_PATH) \
955
	$(RUN_IN_TEMPDIR)
956

    
957
# Environment for tests run by automake
958
TESTS_ENVIRONMENT = \
959
	$(PLAIN_TESTS_ENVIRONMENT) $(abs_top_srcdir)/autotools/testrunner
960

    
961
all_python_code = \
962
	$(dist_sbin_SCRIPTS) \
963
	$(python_scripts) \
964
	$(pkglib_python_scripts) \
965
	$(nodist_pkglib_python_scripts) \
966
	$(python_tests) \
967
	$(pkgpython_PYTHON) \
968
	$(client_PYTHON) \
969
	$(hypervisor_PYTHON) \
970
	$(rapi_PYTHON) \
971
	$(server_PYTHON) \
972
	$(pytools_PYTHON) \
973
	$(http_PYTHON) \
974
	$(confd_PYTHON) \
975
	$(masterd_PYTHON) \
976
	$(impexpd_PYTHON) \
977
	$(utils_PYTHON) \
978
	$(watcher_PYTHON) \
979
	$(noinst_PYTHON) \
980
	$(qa_scripts)
981

    
982
srclink_files = \
983
	man/footer.rst \
984
	test/check-cert-expired_unittest.bash \
985
	test/daemon-util_unittest.bash \
986
	test/ganeti-cleaner_unittest.bash \
987
	test/import-export_unittest.bash \
988
	test/cli-test.bash \
989
	htest/offline-test.sh \
990
	htest/cli-tests-defs.sh \
991
	$(all_python_code) \
992
	$(HS_LIBTEST_SRCS) $(HS_PROG_SRCS)
993

    
994
check_python_code = \
995
	$(BUILD_BASH_COMPLETION) \
996
	$(CHECK_IMPORTS) \
997
	$(CHECK_HEADER) \
998
	$(DOCPP) \
999
	$(all_python_code)
1000

    
1001
lint_python_code = \
1002
	ganeti \
1003
	ganeti/http/server.py \
1004
	$(dist_sbin_SCRIPTS) \
1005
	$(python_scripts) \
1006
	$(pkglib_python_scripts) \
1007
	$(BUILD_BASH_COMPLETION) \
1008
	$(CHECK_IMPORTS) \
1009
	$(CHECK_HEADER) \
1010
	$(DOCPP) \
1011
	$(PYTHON_BOOTSTRAP)
1012

    
1013
standalone_python_modules = \
1014
	lib/rapi/client.py \
1015
	tools/ganeti-listrunner
1016

    
1017
pep8_python_code = \
1018
	ganeti \
1019
	ganeti/http/server.py \
1020
	$(dist_sbin_SCRIPTS) \
1021
	$(python_scripts) \
1022
	$(pkglib_python_scripts) \
1023
	$(BUILD_BASH_COMPLETION) \
1024
	$(CHECK_HEADER) \
1025
	$(DOCPP) \
1026
	$(PYTHON_BOOTSTRAP) \
1027
	qa
1028

    
1029
test/daemon-util_unittest.bash: daemons/daemon-util
1030

    
1031
test/ganeti-cleaner_unittest.bash: daemons/ganeti-cleaner
1032

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

    
1037
devel/upload: devel/upload.in $(REPLACE_VARS_SED)
1038
	sed -f $(REPLACE_VARS_SED) < $< > $@
1039
	chmod u+x $@
1040

    
1041
daemons/%:: daemons/%.in $(REPLACE_VARS_SED)
1042
	sed -f $(REPLACE_VARS_SED) < $< > $@
1043
	chmod +x $@
1044

    
1045
doc/examples/%:: doc/examples/%.in $(REPLACE_VARS_SED)
1046
	sed -f $(REPLACE_VARS_SED) < $< > $@
1047

    
1048
doc/examples/bash_completion: BC_ARGS = --compact
1049
doc/examples/bash_completion-debug: BC_ARGS =
1050

    
1051
doc/examples/bash_completion doc/examples/bash_completion-debug: \
1052
	$(BUILD_BASH_COMPLETION) $(RUN_IN_TEMPDIR) \
1053
	lib/cli.py $(gnt_scripts) $(client_PYTHON) tools/burnin \
1054
	$(GENERATED_FILES)
1055
	PYTHONPATH=. $(RUN_IN_TEMPDIR) \
1056
	  $(CURDIR)/$(BUILD_BASH_COMPLETION) $(BC_ARGS) > $@
1057

    
1058
doc/%.png: doc/%.dot
1059
	@test -n "$(DOT)" || { echo 'dot' not found during configure; exit 1; }
1060
	$(DOT) -Tpng -o $@ $<
1061

    
1062
man/footer.man: man/footer.rst
1063
	@test -n "$(PANDOC)" || \
1064
	  { echo 'pandoc' not found during configure; exit 1; }
1065
	$(PANDOC) -f rst -t man -o $@ $<
1066

    
1067
man/footer.html: man/footer.rst
1068
	@test -n "$(PANDOC)" || \
1069
	  { echo 'pandoc' not found during configure; exit 1; }
1070
	$(PANDOC) -f rst -t html -o $@ $<
1071

    
1072
man/%.gen: man/%.rst lib/query.py lib/build/sphinx_ext.py \
1073
	lib/build/shell_example_lexer.py \
1074
	| $(RUN_IN_TEMPDIR) $(BUILT_PYTHON_SOURCES)
1075
	@echo "Checking $< for hardcoded paths..."
1076
	@if grep -nEf autotools/wrong-hardcoded-paths $<; then \
1077
	  echo "Man page $< has harcoded paths (see above)!" 1>&2 ; \
1078
	  exit 1; \
1079
	fi
1080
	set -e ; \
1081
	trap 'echo auto-removing $@; rm $@' EXIT; \
1082
	PYTHONPATH=. $(RUN_IN_TEMPDIR) $(CURDIR)/$(DOCPP) < $< > $@ ;\
1083
	trap - EXIT
1084

    
1085
man/%.7.in man/%.8.in man/%.1.in: man/%.gen man/footer.man
1086
	@test -n "$(PANDOC)" || \
1087
	  { echo 'pandoc' not found during configure; exit 1; }
1088
	set -o pipefail ; \
1089
	trap 'echo auto-removing $@; rm $@' EXIT; \
1090
	$(PANDOC) -s -f rst -t man -A man/footer.man $< | \
1091
	  sed -e 's/\\@/@/g' > $@; \
1092
	if test -n "$(MAN_HAS_WARNINGS)"; then $(CHECK_MAN_WARNINGS) $@; fi; \
1093
	$(CHECK_MAN_DASHES) $@; \
1094
	trap - EXIT
1095

    
1096

    
1097
man/%.html.in: man/%.gen man/footer.html
1098
	@test -n "$(PANDOC)" || \
1099
	  { echo 'pandoc' not found during configure; exit 1; }
1100
	set -o pipefail ; \
1101
	$(PANDOC) -s -f rst -t html -A man/footer.html $< | \
1102
	  sed -e 's/\\@/@/g' > $@
1103

    
1104
man/%: man/%.in  $(REPLACE_VARS_SED)
1105
	sed -f $(REPLACE_VARS_SED) < $< > $@
1106

    
1107
epydoc.conf: epydoc.conf.in $(REPLACE_VARS_SED)
1108
	sed -f $(REPLACE_VARS_SED) < $< > $@
1109

    
1110
vcs-version:
1111
	if test -d .git; then \
1112
	  git describe > $@; \
1113
	elif test ! -f $@ ; then \
1114
	  echo "Cannot auto-generate $@ file"; exit 1; \
1115
	fi
1116

    
1117
.PHONY: clean-vcs-version
1118
clean-vcs-version:
1119
	rm -f vcs-version
1120

    
1121
.PHONY: regen-vcs-version
1122
regen-vcs-version:
1123
	set -e; \
1124
	cd $(srcdir); \
1125
	if test -d .git; then \
1126
	  $(MAKE) $(AM_MAKEFLAGS) clean-vcs-version; \
1127
	  $(MAKE) $(AM_MAKEFLAGS) vcs-version; \
1128
	fi
1129

    
1130
htools/Ganeti/Version.hs: htools/Ganeti/Version.hs.in \
1131
	vcs-version $(built_base_sources)
1132
	set -e; \
1133
	VCSVER=`cat $(abs_top_srcdir)/vcs-version`; \
1134
	sed -e "s/%ver%/$$VCSVER/" < $< > $@
1135

    
1136
htools/Ganeti/Constants.hs: htools/Ganeti/Constants.hs.in \
1137
	lib/constants.py lib/_autoconf.py lib/luxi.py \
1138
	$(CONVERT_CONSTANTS) $(built_base_sources) \
1139
	| lib/_vcsversion.py
1140
	set -e; \
1141
	{ cat $< ; PYTHONPATH=. $(CONVERT_CONSTANTS); } > $@
1142

    
1143
htest/Test/Ganeti/TestImports.hs: htest/Test/Ganeti/TestImports.hs.in \
1144
	$(built_base_sources)
1145
	set -e; \
1146
	{ cat $< ; \
1147
	  echo ; \
1148
	  for name in $(filter-out Ganeti.THH,$(subst /,.,$(patsubst %.hs,%,$(patsubst htools/%,%,$(HS_LIB_SRCS))))) ; do \
1149
	    echo "import $$name ()" ; \
1150
	  done ; \
1151
	} > $@
1152

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

    
1226
lib/_vcsversion.py: Makefile vcs-version | stamp-directories
1227
	set -e; \
1228
	VCSVER=`cat $(abs_top_srcdir)/vcs-version`; \
1229
	{ echo '# This file is automatically generated, do not edit!'; \
1230
	  echo '#'; \
1231
	  echo ''; \
1232
	  echo '"""Build-time VCS version number for Ganeti.'; \
1233
	  echo '';\
1234
	  echo 'This file is autogenerated by the build process.'; \
1235
	  echo 'For any changes you need to re-run ./configure (and'; \
1236
	  echo 'not edit by hand).'; \
1237
	  echo ''; \
1238
	  echo '"""'; \
1239
	  echo ''; \
1240
	  echo '# pylint: disable=C0301,C0324'; \
1241
	  echo '# because this is autogenerated, we do not want'; \
1242
	  echo '# style warnings' ; \
1243
	  echo ''; \
1244
	  echo "VCS_VERSION = '$$VCSVER'"; \
1245
	} > $@
1246

    
1247
lib/_generated_rpc.py: lib/rpc_defs.py $(BUILD_RPC)
1248
	PYTHONPATH=. $(RUN_IN_TEMPDIR) $(CURDIR)/$(BUILD_RPC) lib/rpc_defs.py > $@
1249

    
1250
$(REPLACE_VARS_SED): Makefile stamp-directories
1251
	set -e; \
1252
	{ echo 's#@PREFIX@#$(prefix)#g'; \
1253
	  echo 's#@SYSCONFDIR@#$(sysconfdir)#g'; \
1254
	  echo 's#@LOCALSTATEDIR@#$(localstatedir)#g'; \
1255
	  echo 's#@BINDIR@#$(bindir)#g'; \
1256
	  echo 's#@SBINDIR@#$(sbindir)#g'; \
1257
	  echo 's#@GANETI_VERSION@#$(PACKAGE_VERSION)#g'; \
1258
	  echo 's#@CUSTOM_XEN_BOOTLOADER@#$(XEN_BOOTLOADER)#g'; \
1259
	  echo 's#@CUSTOM_XEN_KERNEL@#$(XEN_KERNEL)#g'; \
1260
	  echo 's#@CUSTOM_XEN_INITRD@#$(XEN_INITRD)#g'; \
1261
	  echo 's#@CUSTOM_IALLOCATOR_SEARCH_PATH@#$(IALLOCATOR_SEARCH_PATH)#g'; \
1262
	  echo 's#@CUSTOM_EXPORT_DIR@#$(EXPORT_DIR)#g'; \
1263
	  echo 's#@RPL_FILE_STORAGE_DIR@#$(FILE_STORAGE_DIR)#g'; \
1264
	  echo 's#@RPL_SSH_INITD_SCRIPT@#$(SSH_INITD_SCRIPT)#g'; \
1265
	  echo 's#@PKGLIBDIR@#$(pkglibdir)#g'; \
1266
	  echo 's#@GNTMASTERUSER@#$(MASTERD_USER)#g'; \
1267
	  echo 's#@GNTRAPIUSER@#$(RAPI_USER)#g'; \
1268
	  echo 's#@GNTCONFDUSER@#$(CONFD_USER)#g'; \
1269
	  echo 's#@GNTNODEDUSER@#$(NODED_USER)#g'; \
1270
	  echo 's#@GNTRAPIGROUP@#$(RAPI_GROUP)#g'; \
1271
	  echo 's#@GNTADMINGROUP@#$(ADMIN_GROUP)#g'; \
1272
	  echo 's#@GNTCONFDGROUP@#$(CONFD_GROUP)#g'; \
1273
	  echo 's#@GNTMASTERDGROUP@#$(MASTERD_GROUP)#g'; \
1274
	  echo 's#@GNTDAEMONSGROUP@#$(DAEMONS_GROUP)#g'; \
1275
	  echo 's#@CUSTOM_ENABLE_CONFD@#$(ENABLE_CONFD)#g'; \
1276
	  echo 's#@MODULES@#$(strip $(lint_python_code))#g'; \
1277
	  echo 's#@ENABLE_SPLIT_QUERY@#$(ENABLE_SPLIT_QUERY)#g'; \
1278
	} > $@
1279

    
1280
# Using deferred evaluation
1281
daemons/ganeti-%: MODULE = ganeti.server.$(patsubst ganeti-%,%,$(notdir $@))
1282
daemons/ganeti-watcher: MODULE = ganeti.watcher
1283
scripts/%: MODULE = ganeti.client.$(subst -,_,$(notdir $@))
1284
tools/ensure-dirs: MODULE = ganeti.tools.ensure_dirs
1285
$(HS_BUILT_TEST_HELPERS): TESTROLE = $(patsubst htest/%,%,$@)
1286

    
1287
$(PYTHON_BOOTSTRAP): Makefile | stamp-directories
1288
	test -n "$(MODULE)" || { echo Missing module; exit 1; }
1289
	set -e; \
1290
	{ echo '#!/usr/bin/python'; \
1291
	  echo '# This file is automatically generated, do not edit!'; \
1292
	  echo "# Edit $(MODULE) instead."; \
1293
	  echo; \
1294
	  echo '"""Bootstrap script for L{$(MODULE)}"""'; \
1295
	  echo; \
1296
	  echo '# pylint: disable=C0103'; \
1297
	  echo '# C0103: Invalid name'; \
1298
	  echo; \
1299
	  echo 'import sys'; \
1300
	  echo 'import $(MODULE) as main'; \
1301
	  echo; \
1302
	  echo '# Temporarily alias commands until bash completion'; \
1303
	  echo '# generator is changed'; \
1304
	  echo 'if hasattr(main, "commands"):'; \
1305
	  echo '  commands = main.commands # pylint: disable=E1101'; \
1306
	  echo 'if hasattr(main, "aliases"):'; \
1307
	  echo '  aliases = main.aliases # pylint: disable=E1101'; \
1308
	  echo; \
1309
	  echo 'if __name__ == "__main__":'; \
1310
	  echo '  sys.exit(main.Main())'; \
1311
	} > $@
1312
	chmod u+x $@
1313

    
1314
$(HS_BUILT_TEST_HELPERS): Makefile
1315
	@test -n "$(TESTROLE)" || { echo Missing TESTROLE; exit 1; }
1316
	set -e; \
1317
	{ echo '#!/bin/sh'; \
1318
	  echo '# This file is automatically generated, do not edit!'; \
1319
	  echo "# Edit Makefile.am instead."; \
1320
	  echo; \
1321
	  echo "HTOOLS=$(TESTROLE) exec ./htest/hpc-htools \"\$$@\""; \
1322
	} > $@
1323
	chmod u+x $@
1324

    
1325
stamp-directories: Makefile
1326
	$(MAKE) $(AM_MAKEFLAGS) ganeti
1327
	@mkdir_p@ $(DIRS) $(BUILDTIME_DIR_AUTOCREATE)
1328
	touch $@
1329

    
1330
# We need to create symlinks because "make distcheck" will not install Python
1331
# files when building.
1332
stamp-srclinks: Makefile | stamp-directories
1333
	set -e; \
1334
	for i in $(srclink_files); do \
1335
		if test ! -f $$i -a -f $(abs_top_srcdir)/$$i; then \
1336
			$(LN_S) $(abs_top_srcdir)/$$i $$i; \
1337
		fi; \
1338
	done
1339
	touch $@
1340

    
1341
.PHONY: ganeti
1342
ganeti:
1343
	cd $(top_builddir) && test -h "$@" || { rm -f $@ && $(LN_S) lib $@; }
1344

    
1345
.PHONY: check-dirs
1346
check-dirs: $(GENERATED_FILES)
1347
	@set -e; \
1348
	find . -type d \( \( -name . \) -o \( \
1349
		-name .git -o \
1350
		-name autom4te.cache \
1351
		\) -prune -o -print \) | { \
1352
		error=; \
1353
		while read dir; do \
1354
			case "$$dir" in \
1355
				$(strip $(patsubst %,(./%) ;;,$(DIRCHECK_EXCLUDE) $(DIRS))) \
1356
				*) error=1; echo "Directory $$dir not listed in Makefile" >&2 ;; \
1357
			esac; \
1358
		done; \
1359
		for dir in $(DIRS); do \
1360
			if ! test -d "$$dir"; then \
1361
				echo "Directory $$dir listed in DIRS does not exist" >&2; \
1362
				error=1; \
1363
			fi \
1364
		done; \
1365
		if test -n "$$error"; then exit 1; else exit 0; fi; \
1366
	}
1367

    
1368
.PHONY: check-local
1369
check-local: check-dirs $(GENERATED_FILES)
1370
	$(CHECK_PYTHON_CODE) $(check_python_code)
1371
	PYTHONPATH=. $(CHECK_HEADER) $(check_python_code)
1372
	$(CHECK_VERSION) $(VERSION) $(top_srcdir)/NEWS
1373
	$(CHECK_NEWS) < $(top_srcdir)/NEWS
1374
	PYTHONPATH=. $(RUN_IN_TEMPDIR) $(CURDIR)/$(CHECK_IMPORTS) . $(standalone_python_modules)
1375
	expver=$(VERSION_MAJOR).$(VERSION_MINOR); \
1376
	if test "`head -n 1 $(top_srcdir)/README`" != "Ganeti $$expver"; then \
1377
		echo "Incorrect version in README, expected $$expver"; \
1378
		exit 1; \
1379
	fi; \
1380
	for file in doc/iallocator.rst doc/hooks.rst; do \
1381
		if test "`sed -ne '4 p' $(top_srcdir)/$$file`" != \
1382
			"Documents Ganeti version $$expver"; then \
1383
			echo "Incorrect version in $$file, expected $$expver"; \
1384
			exit 1; \
1385
		fi; \
1386
	done
1387

    
1388
.PHONY: hs-check
1389
hs-check: htest/test htest/hpc-htools $(HS_BUILT_TEST_HELPERS)
1390
	@rm -f test.tix
1391
	./htest/test
1392
	HBINARY="./htest/hpc-htools" ./htest/offline-test.sh
1393

    
1394
# E111: indentation is not a multiple of four
1395
# E121: continuation line indentation is not a multiple of four
1396
#       (since our indent level is not 4)
1397
# E125: continuation line does not distinguish itself from next logical line
1398
#       (since our indent level is not 4)
1399
# E127: continuation line over-indented for visual indent
1400
#       (since our indent level is not 4)
1401
# note: do NOT add E128 here; it's a valid style error in most cases!
1402
# I've seen real errors, but also some cases were we indent wrongly
1403
# due to line length; try to rework the cases where it is triggered,
1404
# instead of silencing it
1405
# E261: at least two spaces before inline comment
1406
# E501: line too long (80 characters)
1407
PEP8_IGNORE = E111,E121,E125,E127,E261,E501
1408

    
1409
# For excluding pep8 expects filenames only, not whole paths
1410
PEP8_EXCLUDE = $(subst $(space),$(comma),$(strip $(notdir $(BUILT_PYTHON_SOURCES))))
1411

    
1412
LINT_TARGETS = pylint pylint-qa
1413
if HAS_PEP8
1414
LINT_TARGETS += pep8
1415
endif
1416
if HAS_HLINT
1417
LINT_TARGETS += hlint
1418
endif
1419

    
1420
.PHONY: lint
1421
lint: $(LINT_TARGETS)
1422

    
1423
.PHONY: pylint
1424
pylint: $(GENERATED_FILES)
1425
	@test -n "$(PYLINT)" || { echo 'pylint' not found during configure; exit 1; }
1426
	$(PYLINT) $(LINT_OPTS) $(lint_python_code)
1427

    
1428
.PHONY: pylint-qa
1429
pylint-qa: $(GENERATED_FILES)
1430
	@test -n "$(PYLINT)" || { echo 'pylint' not found during configure; exit 1; }
1431
	cd $(top_srcdir)/qa && \
1432
	  PYTHONPATH=$(abs_top_srcdir) $(PYLINT) $(LINT_OPTS) \
1433
	  --rcfile  ../pylintrc $(patsubst qa/%.py,%,$(qa_scripts))
1434

    
1435
.PHONY: pep8
1436
pep8: $(GENERATED_FILES)
1437
	@test -n "$(PEP8)" || { echo 'pep8' not found during configure; exit 1; }
1438
	$(PEP8) --ignore='$(PEP8_IGNORE)' --exclude='$(PEP8_EXCLUDE)' \
1439
		--repeat $(pep8_python_code)
1440

    
1441
# FIXME: remove ignore "Use void" when GHC 6.x is deprecated
1442
.PHONY: hlint
1443
hlint: $(HS_BUILT_SRCS) htools/lint-hints.hs
1444
	@test -n "$(HLINT)" || { echo 'hlint' not found during configure; exit 1; }
1445
	if tty -s; then C="-c"; else C=""; fi; \
1446
	$(HLINT) --report=doc/hs-lint.html --cross $$C \
1447
	  --ignore "Use first" \
1448
	  --ignore "Use comparing" \
1449
	  --ignore "Use on" \
1450
	  --ignore "Reduce duplication" \
1451
	  --ignore "Use &&&" \
1452
	  --ignore "Use void" \
1453
	  --hint htools/lint-hints \
1454
	  $(filter-out htools/Ganeti/THH.hs,$(HS_LIBTEST_SRCS))
1455

    
1456
# a dist hook rule for updating the vcs-version file; this is
1457
# hardcoded due to where it needs to build the file...
1458
dist-hook:
1459
	$(MAKE) $(AM_MAKEFLAGS) regen-vcs-version
1460
	rm -f $(top_distdir)/vcs-version
1461
	cp -p $(srcdir)/vcs-version $(top_distdir)
1462

    
1463
# a distcheck hook rule for catching revision control directories
1464
distcheck-hook:
1465
	if find $(top_distdir) -name .svn -or -name .git | grep .; then \
1466
		echo "Found revision control files in final archive." 1>&2; \
1467
		exit 1; \
1468
	fi
1469
	if find $(top_distdir) -name '*.py[co]' | grep .; then \
1470
		echo "Found Python byte code in final archive." 1>&2; \
1471
		exit 1; \
1472
	fi
1473
	if find $(top_distdir) -name '*~' | grep .; then \
1474
		echo "Found backup files in final archive." 1>&2; \
1475
		exit 1; \
1476
	fi
1477
# Empty files or directories should not be distributed. They can cause
1478
# unnecessary warnings for packagers. Directories used by automake during
1479
# distcheck must be excluded.
1480
	if find $(top_distdir) -empty -and -not \( \
1481
			-path $(top_distdir)/_build -or \
1482
			-path $(top_distdir)/_inst \) | grep .; then \
1483
		echo "Found empty files or directories in final archive." 1>&2; \
1484
		exit 1; \
1485
	fi
1486
	if test -n "$(BUILD_RELEASE)" && \
1487
	   grep -n -H -E '^\*.*unreleased' $(top_distdir)/NEWS; then \
1488
		echo "Found unreleased version in NEWS." >&2; \
1489
		exit 1; \
1490
	fi
1491

    
1492
# When building a release, stricter checks should be used
1493
distcheck-release dist-release: export BUILD_RELEASE = 1
1494
distcheck-release: distcheck
1495

    
1496
distrebuildcheck: dist
1497
	set -e; \
1498
	builddir=$$(mktemp -d $(abs_srcdir)/distrebuildcheck.XXXXXXX); \
1499
	trap "echo Removing $$builddir; cd $(abs_srcdir); rm -rf $$builddir" EXIT; \
1500
	cd $$builddir; \
1501
	tar xzf $(abs_srcdir)/$(distdir).tar.gz; \
1502
	cd $(distdir); \
1503
	./configure; \
1504
	$(MAKE) maintainer-clean; \
1505
	cp $(abs_srcdir)/vcs-version .; \
1506
	./configure; \
1507
	$(MAKE) $(AM_MAKEFLAGS)
1508

    
1509
dist-release: dist
1510
	set -e; \
1511
	for i in $(DIST_ARCHIVES); do \
1512
		echo -n "Checking $$i ... "; \
1513
		autotools/check-tar < $$i; \
1514
		echo OK; \
1515
	done
1516

    
1517
install-exec-local:
1518
	@mkdir_p@ "$(DESTDIR)${localstatedir}/lib/ganeti" \
1519
	  "$(DESTDIR)${localstatedir}/log/ganeti" \
1520
	  "$(DESTDIR)${localstatedir}/run/ganeti"
1521

    
1522
.PHONY: apidoc
1523
if WANT_HTOOLSAPIDOC
1524
apidoc: py-apidoc hs-apidoc
1525
else
1526
apidoc: py-apidoc
1527
endif
1528

    
1529
.PHONY: py-apidoc
1530
py-apidoc: epydoc.conf $(RUN_IN_TEMPDIR) $(GENERATED_FILES)
1531
	$(RUN_IN_TEMPDIR) epydoc -v \
1532
		--conf $(CURDIR)/epydoc.conf \
1533
		--output $(CURDIR)/$(APIDOC_PY_DIR)
1534

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

    
1569
.PHONY: TAGS
1570
TAGS: $(GENERATED_FILES)
1571
	rm -f TAGS
1572
	$(GHC) -e ":etags" -v0 $(HFLAGS) $(HS_LIBTEST_SRCS)
1573
	find . -path './lib/*.py' -o -path './scripts/gnt-*' -o \
1574
	  -path './daemons/ganeti-*' -o -path './tools/*' -o \
1575
	  -path './qa/*.py' | \
1576
	  etags -l python -a -
1577

    
1578
.PHONY: coverage
1579
if WANT_HTOOLS
1580
coverage: py-coverage hs-coverage
1581
else
1582
coverage: py-coverage
1583
endif
1584

    
1585
.PHONY: py-coverage
1586
py-coverage: $(GENERATED_FILES) $(python_tests)
1587
	set -e; \
1588
	COVERAGE_FILE=$(CURDIR)/$(COVERAGE_PY_DIR)/data \
1589
	TEXT_COVERAGE=$(CURDIR)/$(COVERAGE_PY_DIR)/report.txt \
1590
	HTML_COVERAGE=$(CURDIR)/$(COVERAGE_PY_DIR) \
1591
	$(PLAIN_TESTS_ENVIRONMENT) $(abs_top_srcdir)/autotools/gen-coverage \
1592
	$(python_tests)
1593

    
1594
.PHONY: hs-coverage
1595
hs-coverage: $(haskell_tests) htest/hpc-htools
1596
	rm -f *.tix
1597
	$(MAKE) $(AM_MAKEFLAGS) hs-check
1598
	@mkdir_p@ $(COVERAGE_HS_DIR)
1599
	hpc combine --union $(HPCEXCL) \
1600
	  test.tix hpc-htools.tix > coverage-htools.tix
1601
	hpc markup --destdir=$(COVERAGE_HS_DIR) coverage-htools.tix
1602
	hpc report coverage-htools.tix
1603
	$(LN_S) -f hpc_index.html $(COVERAGE_HS_DIR)/index.html
1604

    
1605
# Special "kind-of-QA" target for htools, needs special setup (all
1606
# tools compiled with -fhpc)
1607
.PHONY: live-test
1608
live-test: all
1609
	set -e ; \
1610
	cd htools; \
1611
	rm -f .hpc; $(LN_S) ../.hpc .hpc; \
1612
	rm -f *.tix *.mix; \
1613
	./live-test.sh; \
1614
	hpc sum --union $(HPCEXCL) $(addsuffix .tix,$(HS_PROGS:htools/%=%)) \
1615
	  --output=live-test.tix ; \
1616
	@mkdir_p@ ../$(COVERAGE_HS_DIR) ; \
1617
	hpc markup --destdir=../$(COVERAGE_HS_DIR) live-test \
1618
		--srcdir=.. $(HPCEXCL) ; \
1619
	hpc report --srcdir=.. live-test $(HPCEXCL)
1620

    
1621
commit-check: distcheck lint apidoc
1622

    
1623
.PHONY: gitignore-check
1624
gitignore-check:
1625
	@if [ -n "`git status --short`" ]; then \
1626
	  echo "Git status is not clean!" 1>&2 ; \
1627
	  git status --short; \
1628
	  exit 1; \
1629
	fi
1630

    
1631
# we don't need the ancient implicit rules:
1632
%: %,v
1633
%: RCS/%,v
1634
%: RCS/%
1635
%: s.%
1636
%: SCCS/s.%
1637

    
1638
-include ./Makefile.local
1639

    
1640
# vim: set noet :