Statistics
| Branch: | Tag: | Revision:

root / Makefile.am @ 19e21a6c

History | View | Annotate | Download (48 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
SHELL_ENV_INIT = autotools/shell-env-init
35

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

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

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

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

    
104
BUILDTIME_DIR_AUTOCREATE = \
105
	scripts \
106
	$(APIDOC_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
	$(APIDOC_PY_DIR) \
114
	$(COVERAGE_DIR) \
115
	$(COVERAGE_HS_DIR) \
116
	$(COVERAGE_PY_DIR) \
117
	.hpc
118

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

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

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

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

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

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

    
175
GENERATED_FILES = \
176
	$(built_base_sources) \
177
	$(BUILT_PYTHON_SOURCES) \
178
	$(PYTHON_BOOTSTRAP)
179

    
180
HTOOLS_GENERATED_FILES =
181
if WANT_HTOOLS
182
HTOOLS_GENERATED_FILES += $(HS_PROGS)
183
if ENABLE_CONFD
184
HTOOLS_GENERATED_FILES += htools/hconfd htools/ganeti-confd
185
endif
186
endif
187

    
188
built_base_sources = \
189
	stamp-directories \
190
	stamp-srclinks
191

    
192
built_python_base_sources = \
193
	lib/_autoconf.py \
194
	lib/_vcsversion.py
195

    
196
BUILT_PYTHON_SOURCES = \
197
	$(built_python_base_sources) \
198
	lib/_generated_rpc.py
199

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

    
204
# these are all built from the underlying %.in sources
205
BUILT_EXAMPLES = \
206
	doc/examples/ganeti-kvm-poweroff.initd \
207
	doc/examples/ganeti.cron \
208
	doc/examples/ganeti.initd \
209
	doc/examples/gnt-config-backup \
210
	doc/examples/hooks/ipsec
211

    
212
nodist_pkgpython_PYTHON = \
213
	$(BUILT_PYTHON_SOURCES)
214

    
215
noinst_PYTHON = \
216
	lib/build/__init__.py \
217
	lib/build/shell_example_lexer.py \
218
	lib/build/sphinx_ext.py
219

    
220
pkgpython_PYTHON = \
221
	lib/__init__.py \
222
	lib/asyncnotifier.py \
223
	lib/backend.py \
224
	lib/bdev.py \
225
	lib/bootstrap.py \
226
	lib/cli.py \
227
	lib/cmdlib.py \
228
	lib/compat.py \
229
	lib/config.py \
230
	lib/constants.py \
231
	lib/daemon.py \
232
	lib/errors.py \
233
	lib/ht.py \
234
	lib/jqueue.py \
235
	lib/jstore.py \
236
	lib/locking.py \
237
	lib/luxi.py \
238
	lib/mcpu.py \
239
	lib/netutils.py \
240
	lib/objects.py \
241
	lib/objectutils.py \
242
	lib/opcodes.py \
243
	lib/ovf.py \
244
	lib/pathutils.py \
245
	lib/qlang.py \
246
	lib/query.py \
247
	lib/rpc.py \
248
	lib/rpc_defs.py \
249
	lib/runtime.py \
250
	lib/serializer.py \
251
	lib/ssconf.py \
252
	lib/ssh.py \
253
	lib/storage.py \
254
	lib/uidpool.py \
255
	lib/vcluster.py \
256
	lib/workerpool.py
257

    
258
client_PYTHON = \
259
	lib/client/__init__.py \
260
	lib/client/gnt_backup.py \
261
	lib/client/gnt_cluster.py \
262
	lib/client/gnt_debug.py \
263
	lib/client/gnt_group.py \
264
	lib/client/gnt_instance.py \
265
	lib/client/gnt_job.py \
266
	lib/client/gnt_node.py \
267
	lib/client/gnt_os.py
268

    
269
hypervisor_PYTHON = \
270
	lib/hypervisor/__init__.py \
271
	lib/hypervisor/hv_base.py \
272
	lib/hypervisor/hv_chroot.py \
273
	lib/hypervisor/hv_fake.py \
274
	lib/hypervisor/hv_kvm.py \
275
	lib/hypervisor/hv_lxc.py \
276
	lib/hypervisor/hv_xen.py
277

    
278
rapi_PYTHON = \
279
	lib/rapi/__init__.py \
280
	lib/rapi/baserlib.py \
281
	lib/rapi/client.py \
282
	lib/rapi/client_utils.py \
283
	lib/rapi/connector.py \
284
	lib/rapi/rlib2.py \
285
	lib/rapi/testutils.py
286

    
287
http_PYTHON = \
288
	lib/http/__init__.py \
289
	lib/http/auth.py \
290
	lib/http/client.py \
291
	lib/http/server.py
292

    
293
confd_PYTHON = \
294
	lib/confd/__init__.py \
295
	lib/confd/client.py
296

    
297
masterd_PYTHON = \
298
	lib/masterd/__init__.py \
299
	lib/masterd/iallocator.py \
300
	lib/masterd/instance.py
301

    
302
impexpd_PYTHON = \
303
	lib/impexpd/__init__.py
304

    
305
watcher_PYTHON = \
306
	lib/watcher/__init__.py \
307
	lib/watcher/nodemaint.py \
308
	lib/watcher/state.py
309

    
310
server_PYTHON = \
311
	lib/server/__init__.py \
312
	lib/server/masterd.py \
313
	lib/server/noded.py \
314
	lib/server/rapi.py
315

    
316
pytools_PYTHON = \
317
	lib/tools/__init__.py \
318
	lib/tools/ensure_dirs.py
319

    
320
utils_PYTHON = \
321
	lib/utils/__init__.py \
322
	lib/utils/algo.py \
323
	lib/utils/filelock.py \
324
	lib/utils/hash.py \
325
	lib/utils/io.py \
326
	lib/utils/log.py \
327
	lib/utils/mlock.py \
328
	lib/utils/nodesetup.py \
329
	lib/utils/process.py \
330
	lib/utils/retry.py \
331
	lib/utils/text.py \
332
	lib/utils/wrapper.py \
333
	lib/utils/x509.py
334

    
335
docrst = \
336
	doc/admin.rst \
337
	doc/cluster-merge.rst \
338
	doc/design-2.0.rst \
339
	doc/design-2.1.rst \
340
	doc/design-2.2.rst \
341
	doc/design-2.3.rst \
342
	doc/design-2.4.rst \
343
	doc/design-2.5.rst \
344
	doc/design-2.6.rst \
345
	doc/design-2.7.rst \
346
	doc/design-autorepair.rst \
347
	doc/design-bulk-create.rst \
348
	doc/design-chained-jobs.rst \
349
	doc/design-cpu-pinning.rst \
350
	doc/design-draft.rst \
351
	doc/design-htools-2.3.rst \
352
	doc/design-http-server.rst \
353
	doc/design-impexp2.rst \
354
	doc/design-lu-generated-jobs.rst \
355
	doc/design-multi-reloc.rst \
356
	doc/design-network.rst \
357
	doc/design-node-state-cache.rst \
358
	doc/design-oob.rst \
359
	doc/design-ovf-support.rst \
360
	doc/design-partitioned.rst \
361
	doc/design-query-splitting.rst \
362
	doc/design-query2.rst \
363
	doc/design-resource-model.rst \
364
	doc/design-shared-storage.rst \
365
	doc/design-ssh-setup.rst \
366
	doc/design-virtual-clusters.rst \
367
	doc/design-x509-ca.rst \
368
	doc/devnotes.rst \
369
	doc/glossary.rst \
370
	doc/hooks.rst \
371
	doc/iallocator.rst \
372
	doc/index.rst \
373
	doc/install-quick.rst \
374
	doc/install.rst \
375
	doc/locking.rst \
376
	doc/move-instance.rst \
377
	doc/news.rst \
378
	doc/ovfconverter.rst \
379
	doc/rapi.rst \
380
	doc/security.rst \
381
	doc/upgrade.rst \
382
	doc/virtual-cluster.rst \
383
	doc/walkthrough.rst
384

    
385
HS_PROGS = htools/htools
386
HS_BIN_ROLES = hbal hscan hspace hinfo hcheck
387
HS_HTOOLS_PROGS = $(HS_BIN_ROLES) hail
388

    
389
HS_ALL_PROGS = \
390
	$(HS_PROGS) \
391
	htest/hpc-htools \
392
	htest/test \
393
	htools/hconfd \
394
	htools/rpc-test
395

    
396
HS_PROG_SRCS = $(patsubst %,%.hs,$(HS_ALL_PROGS))
397
HS_BUILT_TEST_HELPERS = $(HS_BIN_ROLES:%=htest/%) htest/hail
398

    
399
HFLAGS = -O -Wall -Werror -fwarn-monomorphism-restriction -fwarn-tabs -ihtools
400
# extra flags that can be overriden on the command line (e.g. -Wwarn, etc.)
401
HEXTRA =
402
# internal extra flags (used for htest/test mainly)
403
HEXTRA_INT =
404
# exclude options for coverage reports
405
HPCEXCL = --exclude Main \
406
	--exclude Ganeti.Constants \
407
	--exclude Ganeti.HTools.QC \
408
	--exclude Ganeti.THH \
409
	--exclude Ganeti.Version \
410
	--exclude Test.Ganeti.TestCommon \
411
	--exclude Test.Ganeti.TestHTools \
412
	--exclude Test.Ganeti.TestHelper \
413
	--exclude Test.Ganeti.TestImports \
414
	$(patsubst htools.%,--exclude Test.%,$(subst /,.,$(patsubst %.hs,%, $(HS_LIB_SRCS))))
415

    
416
HS_LIB_SRCS = \
417
	htools/Ganeti/BasicTypes.hs \
418
	htools/Ganeti/Common.hs \
419
	htools/Ganeti/Compat.hs \
420
	htools/Ganeti/Confd.hs \
421
	htools/Ganeti/Confd/Server.hs \
422
	htools/Ganeti/Confd/Utils.hs \
423
	htools/Ganeti/Config.hs \
424
	htools/Ganeti/Daemon.hs \
425
	htools/Ganeti/HTools/CLI.hs \
426
	htools/Ganeti/HTools/Cluster.hs \
427
	htools/Ganeti/HTools/Container.hs \
428
	htools/Ganeti/HTools/ExtLoader.hs \
429
	htools/Ganeti/HTools/Group.hs \
430
	htools/Ganeti/HTools/IAlloc.hs \
431
	htools/Ganeti/HTools/Instance.hs \
432
	htools/Ganeti/HTools/Loader.hs \
433
	htools/Ganeti/HTools/Luxi.hs \
434
	htools/Ganeti/HTools/Node.hs \
435
	htools/Ganeti/HTools/PeerMap.hs \
436
	htools/Ganeti/HTools/Program.hs \
437
	htools/Ganeti/HTools/Program/Hail.hs \
438
	htools/Ganeti/HTools/Program/Hbal.hs \
439
	htools/Ganeti/HTools/Program/Hcheck.hs \
440
	htools/Ganeti/HTools/Program/Hinfo.hs \
441
	htools/Ganeti/HTools/Program/Hscan.hs \
442
	htools/Ganeti/HTools/Program/Hspace.hs \
443
	htools/Ganeti/HTools/Rapi.hs \
444
	htools/Ganeti/HTools/Simu.hs \
445
	htools/Ganeti/HTools/Text.hs \
446
	htools/Ganeti/HTools/Types.hs \
447
	htools/Ganeti/Hash.hs \
448
	htools/Ganeti/JSON.hs \
449
	htools/Ganeti/Jobs.hs \
450
	htools/Ganeti/Logging.hs \
451
	htools/Ganeti/Luxi.hs \
452
	htools/Ganeti/Objects.hs \
453
	htools/Ganeti/OpCodes.hs \
454
	htools/Ganeti/Path.hs \
455
	htools/Ganeti/Query/Common.hs \
456
	htools/Ganeti/Query/Filter.hs \
457
	htools/Ganeti/Query/Group.hs \
458
	htools/Ganeti/Query/Language.hs \
459
	htools/Ganeti/Query/Node.hs \
460
	htools/Ganeti/Query/Query.hs \
461
	htools/Ganeti/Query/Server.hs \
462
	htools/Ganeti/Query/Types.hs \
463
	htools/Ganeti/Rpc.hs \
464
	htools/Ganeti/Runtime.hs \
465
	htools/Ganeti/Ssconf.hs \
466
	htools/Ganeti/THH.hs \
467
	htools/Ganeti/Utils.hs
468

    
469
HS_TEST_SRCS = \
470
	htest/Test/Ganeti/BasicTypes.hs \
471
	htest/Test/Ganeti/Common.hs \
472
	htest/Test/Ganeti/Confd/Utils.hs \
473
	htest/Test/Ganeti/Daemon.hs \
474
	htest/Test/Ganeti/HTools/CLI.hs \
475
	htest/Test/Ganeti/HTools/Cluster.hs \
476
	htest/Test/Ganeti/HTools/Container.hs \
477
	htest/Test/Ganeti/HTools/Instance.hs \
478
	htest/Test/Ganeti/HTools/Loader.hs \
479
	htest/Test/Ganeti/HTools/Node.hs \
480
	htest/Test/Ganeti/HTools/PeerMap.hs \
481
	htest/Test/Ganeti/HTools/Simu.hs \
482
	htest/Test/Ganeti/HTools/Text.hs \
483
	htest/Test/Ganeti/HTools/Types.hs \
484
	htest/Test/Ganeti/JSON.hs \
485
	htest/Test/Ganeti/Jobs.hs \
486
	htest/Test/Ganeti/Luxi.hs \
487
	htest/Test/Ganeti/Objects.hs \
488
	htest/Test/Ganeti/OpCodes.hs \
489
	htest/Test/Ganeti/Query/Filter.hs \
490
	htest/Test/Ganeti/Query/Language.hs \
491
	htest/Test/Ganeti/Query/Query.hs \
492
	htest/Test/Ganeti/Rpc.hs \
493
	htest/Test/Ganeti/Ssconf.hs \
494
	htest/Test/Ganeti/TestCommon.hs \
495
	htest/Test/Ganeti/TestHTools.hs \
496
	htest/Test/Ganeti/TestHelper.hs \
497
	htest/Test/Ganeti/Utils.hs
498

    
499
HS_LIBTEST_SRCS = $(HS_LIB_SRCS) $(HS_TEST_SRCS)
500

    
501
HS_BUILT_SRCS = \
502
	htest/Test/Ganeti/TestImports.hs \
503
	htools/Ganeti/Constants.hs \
504
	htools/Ganeti/Version.hs
505
HS_BUILT_SRCS_IN = $(patsubst %,%.in,$(HS_BUILT_SRCS))
506

    
507
$(RUN_IN_TEMPDIR): | stamp-directories
508

    
509
# Note: we use here an order-only prerequisite, as the contents of
510
# _autoconf.py are not actually influencing the html build output: it
511
# has to exist in order for the sphinx module to be loaded
512
# successfully, but we certainly don't want the docs to be rebuilt if
513
# it changes
514
doc/html/index.html: $(docrst) $(docpng) doc/conf.py configure.ac \
515
	$(RUN_IN_TEMPDIR) lib/build/sphinx_ext.py \
516
	lib/build/shell_example_lexer.py lib/opcodes.py lib/ht.py \
517
	| $(BUILT_PYTHON_SOURCES)
518
	@test -n "$(SPHINX)" || \
519
	    { echo 'sphinx-build' not found during configure; exit 1; }
520
	@mkdir_p@ $(dir $@)
521
	PYTHONPATH=. $(RUN_IN_TEMPDIR) $(SPHINX) -q -W -b html \
522
	    -d . \
523
	    -D version="$(VERSION_MAJOR).$(VERSION_MINOR)" \
524
	    -D release="$(PACKAGE_VERSION)" \
525
	    $(abs_top_srcdir)/doc $(CURDIR)/doc/html
526
	rm -f doc/html/.buildinfo doc/html/objects.inv
527
	touch $@
528

    
529
doc/html: doc/html/index.html
530

    
531
doc/install-quick.rst: INSTALL
532
doc/news.rst: NEWS
533
doc/upgrade.rst: UPGRADE
534

    
535
doc/install-quick.rst doc/news.rst doc/upgrade.rst:
536
	set -e; \
537
	{ echo '.. This file is automatically updated at build time from $<.'; \
538
	  echo '.. Do not edit.'; \
539
	  echo; \
540
	  cat $<; \
541
	} > $@
542

    
543
docdot = \
544
	doc/arch-2.0.dot \
545
	doc/design-2.1-lock-acquire.dot \
546
	doc/design-2.1-lock-release.dot
547

    
548
docpng = $(patsubst %.dot,%.png,$(docdot))
549

    
550
# Things to build but not to install (add it to EXTRA_DIST if it should be
551
# distributed)
552
noinst_DATA = \
553
	devel/upload \
554
	doc/html \
555
	$(BUILT_EXAMPLES) \
556
	doc/examples/bash_completion \
557
	doc/examples/bash_completion-debug \
558
	$(manhtml)
559

    
560
gnt_scripts = \
561
	scripts/gnt-backup \
562
	scripts/gnt-cluster \
563
	scripts/gnt-debug \
564
	scripts/gnt-group \
565
	scripts/gnt-instance \
566
	scripts/gnt-job \
567
	scripts/gnt-node \
568
	scripts/gnt-os
569

    
570
PYTHON_BOOTSTRAP_SBIN = \
571
	daemons/ganeti-masterd \
572
	daemons/ganeti-noded \
573
	daemons/ganeti-rapi \
574
	daemons/ganeti-watcher \
575
	$(gnt_scripts)
576

    
577
PYTHON_BOOTSTRAP = \
578
	$(PYTHON_BOOTSTRAP_SBIN) \
579
	tools/ensure-dirs
580

    
581
qa_scripts = \
582
	qa/__init__.py \
583
	qa/ganeti-qa.py \
584
	qa/qa_cluster.py \
585
	qa/qa_config.py \
586
	qa/qa_daemon.py \
587
	qa/qa_env.py \
588
	qa/qa_error.py \
589
	qa/qa_group.py \
590
	qa/qa_instance.py \
591
	qa/qa_job.py \
592
	qa/qa_node.py \
593
	qa/qa_os.py \
594
	qa/qa_rapi.py \
595
	qa/qa_tags.py \
596
	qa/qa_utils.py
597

    
598
bin_SCRIPTS =
599
if WANT_HTOOLS
600
bin_SCRIPTS += $(filter-out htools/hail,$(HS_PROGS))
601
install-exec-hook:
602
	@mkdir_p@ $(DESTDIR)$(iallocatorsdir)
603
# FIXME: this is a hardcoded logic, instead of auto-resolving
604
	$(LN_S) -f ../../../bin/htools \
605
		   $(DESTDIR)$(iallocatorsdir)/hail
606
	for role in $(HS_BIN_ROLES); do \
607
		$(LN_S) -f htools \
608
			   $(DESTDIR)$(bindir)/$$role ; \
609
	done
610
endif
611

    
612
$(HS_ALL_PROGS): %: %.hs $(HS_LIBTEST_SRCS) $(HS_BUILT_SRCS) Makefile
613
	@if [ "$(notdir $@)" = "test" ] && [ "$(HTOOLS_NODEV)" ]; then \
614
	  echo "Error: cannot run unittests without the development" \
615
	       " libraries (see devnotes.rst)" 1>&2; \
616
	  exit 1; \
617
	fi
618
	@rm -f $(notdir $@).tix
619
	$(GHC) --make \
620
	  $(HFLAGS) \
621
	  $(HTOOLS_NOCURL) $(HTOOLS_PARALLEL3) $(HTOOLS_REGEX_PCRE) \
622
	  -osuf $(notdir $@).o -hisuf $(notdir $@).hi \
623
	  $(HEXTRA) $(HEXTRA_INT) $@
624
	@touch "$@"
625

    
626
# for the htest/test binary, we need to enable profiling/coverage
627
htest/test: HEXTRA_INT=-fhpc -ihtest
628

    
629
# we compile the hpc-htools binary with the program coverage
630
htest/hpc-htools: HEXTRA_INT=-fhpc
631

    
632
# test dependency
633
htest/offline-tests.sh: htest/hpc-htools
634

    
635
# rules for building profiling-enabled versions of the haskell
636
# programs: hs-prof does the full two-step build, whereas
637
# hs-prof-quick does only the final rebuild (hs-prof must have been
638
# run before)
639
.PHONY: hs-prof hs-prof-quick
640
hs-prof:
641
	$(MAKE) $(AM_MAKEFLAGS) clean
642
	$(MAKE) $(AM_MAKEFLAGS) $(HS_ALL_PROGS) HEXTRA="-osuf .o"
643
	rm -f $(HS_ALL_PROGS)
644
	$(MAKE) $(AM_MAKEFLAGS) hs-prof-quick
645

    
646
hs-prof-quick:
647
	$(MAKE) $(AM_MAKEFLAGS) $(HS_ALL_PROGS) HEXTRA="-osuf .prof_o -prof -auto-all"
648

    
649
dist_sbin_SCRIPTS = \
650
	tools/ganeti-listrunner
651

    
652
nodist_sbin_SCRIPTS = \
653
	$(PYTHON_BOOTSTRAP_SBIN) \
654
	daemons/ganeti-cleaner
655

    
656
if ENABLE_CONFD
657
htools/ganeti-confd: htools/hconfd
658
	cp -f $< $@
659

    
660
nodist_sbin_SCRIPTS += htools/ganeti-confd
661
endif
662

    
663
python_scripts = \
664
	tools/burnin \
665
	tools/cfgshell \
666
	tools/cfgupgrade \
667
	tools/cfgupgrade12 \
668
	tools/cluster-merge \
669
	tools/confd-client \
670
	tools/fmtjson \
671
	tools/lvmstrap \
672
	tools/move-instance \
673
	tools/ovfconverter \
674
	tools/sanitize-config \
675
	tools/setup-ssh
676

    
677
dist_tools_SCRIPTS = \
678
	$(python_scripts) \
679
	tools/kvm-console-wrapper \
680
	tools/master-ip-setup \
681
	tools/xm-console-wrapper
682

    
683
nodist_tools_SCRIPTS = \
684
	tools/vcluster-setup
685

    
686
pkglib_python_scripts = \
687
	daemons/import-export \
688
	tools/check-cert-expired
689

    
690
nodist_pkglib_python_scripts = \
691
	tools/ensure-dirs
692

    
693
myexeclib_SCRIPTS = \
694
	daemons/daemon-util \
695
	tools/kvm-ifup \
696
	$(pkglib_python_scripts)
697

    
698
nodist_myexeclib_SCRIPTS = \
699
	$(nodist_pkglib_python_scripts)
700

    
701
EXTRA_DIST = \
702
	NEWS \
703
	UPGRADE \
704
	epydoc.conf.in \
705
	pylintrc \
706
	autotools/build-bash-completion \
707
	autotools/build-rpc \
708
	autotools/check-header \
709
	autotools/check-imports \
710
	autotools/check-man-dashes \
711
	autotools/check-man-warnings \
712
	autotools/check-news \
713
	autotools/check-python-code \
714
	autotools/check-tar \
715
	autotools/check-version \
716
	autotools/convert-constants \
717
	autotools/docpp \
718
	autotools/gen-coverage \
719
	autotools/testrunner \
720
	autotools/wrong-hardcoded-paths \
721
	$(RUN_IN_TEMPDIR) \
722
	daemons/daemon-util.in \
723
	daemons/ganeti-cleaner.in \
724
	$(pkglib_python_scripts) \
725
	devel/upload.in \
726
	tools/kvm-ifup.in \
727
	tools/vcluster-setup.in \
728
	$(docdot) \
729
	$(docpng) \
730
	$(docrst) \
731
	doc/conf.py \
732
	doc/html \
733
	$(BUILT_EXAMPLES:%=%.in) \
734
	doc/examples/ganeti.default \
735
	doc/examples/ganeti.default-debug \
736
	doc/examples/hooks/ethers \
737
	doc/examples/gnt-debug/README \
738
	doc/examples/gnt-debug/delay0.json \
739
	doc/examples/gnt-debug/delay50.json \
740
	test/lockperf.py \
741
	test/testutils.py \
742
	test/mocks.py \
743
	$(dist_TESTS) \
744
	$(TEST_FILES) \
745
	man/footer.rst \
746
	$(manrst) \
747
	$(maninput) \
748
	qa/qa-sample.json \
749
	$(qa_scripts) \
750
	$(HS_LIBTEST_SRCS) $(HS_BUILT_SRCS_IN) \
751
	$(HS_PROG_SRCS) \
752
	htools/lint-hints.hs \
753
	htest/cli-tests-defs.sh \
754
	htest/offline-test.sh
755

    
756
man_MANS = \
757
	man/ganeti-cleaner.8 \
758
	man/ganeti-confd.8 \
759
	man/ganeti-listrunner.8 \
760
	man/ganeti-masterd.8 \
761
	man/ganeti-noded.8 \
762
	man/ganeti-os-interface.7 \
763
	man/ganeti-rapi.8 \
764
	man/ganeti-watcher.8 \
765
	man/ganeti.7 \
766
	man/gnt-backup.8 \
767
	man/gnt-cluster.8 \
768
	man/gnt-debug.8 \
769
	man/gnt-group.8 \
770
	man/gnt-instance.8 \
771
	man/gnt-job.8 \
772
	man/gnt-node.8 \
773
	man/gnt-os.8 \
774
	man/hail.1 \
775
	man/hbal.1 \
776
	man/hcheck.1 \
777
	man/hinfo.1 \
778
	man/hscan.1 \
779
	man/hspace.1 \
780
	man/htools.1
781

    
782
manrst = $(patsubst %.1,%.rst,$(patsubst %.7,%.rst,$(patsubst %.8,%.rst,$(man_MANS))))
783
manhtml = $(patsubst %.rst,%.html,$(manrst))
784
mangen = $(patsubst %.rst,%.gen,$(manrst))
785
maninput = \
786
	$(patsubst %.1,%.1.in,$(patsubst %.7,%.7.in,$(patsubst %.8,%.8.in,$(man_MANS)))) \
787
	$(patsubst %.html,%.html.in,$(manhtml)) \
788
	man/footer.man man/footer.html $(mangen)
789

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

    
873
python_tests = \
874
	doc/examples/rapi_testutils.py \
875
	test/cfgupgrade_unittest.py \
876
	test/docs_unittest.py \
877
	test/ganeti.asyncnotifier_unittest.py \
878
	test/ganeti.backend_unittest.py \
879
	test/ganeti.bdev_unittest.py \
880
	test/ganeti.cli_unittest.py \
881
	test/ganeti.client.gnt_cluster_unittest.py \
882
	test/ganeti.client.gnt_instance_unittest.py \
883
	test/ganeti.cmdlib_unittest.py \
884
	test/ganeti.compat_unittest.py \
885
	test/ganeti.confd.client_unittest.py \
886
	test/ganeti.config_unittest.py \
887
	test/ganeti.constants_unittest.py \
888
	test/ganeti.daemon_unittest.py \
889
	test/ganeti.errors_unittest.py \
890
	test/ganeti.hooks_unittest.py \
891
	test/ganeti.ht_unittest.py \
892
	test/ganeti.http_unittest.py \
893
	test/ganeti.hypervisor.hv_chroot_unittest.py \
894
	test/ganeti.hypervisor.hv_fake_unittest.py \
895
	test/ganeti.hypervisor.hv_kvm_unittest.py \
896
	test/ganeti.hypervisor.hv_lxc_unittest.py \
897
	test/ganeti.hypervisor.hv_xen_unittest.py \
898
	test/ganeti.hypervisor_unittest.py \
899
	test/ganeti.impexpd_unittest.py \
900
	test/ganeti.jqueue_unittest.py \
901
	test/ganeti.jstore_unittest.py \
902
	test/ganeti.locking_unittest.py \
903
	test/ganeti.luxi_unittest.py \
904
	test/ganeti.masterd.iallocator_unittest.py \
905
	test/ganeti.masterd.instance_unittest.py \
906
	test/ganeti.mcpu_unittest.py \
907
	test/ganeti.netutils_unittest.py \
908
	test/ganeti.objects_unittest.py \
909
	test/ganeti.objectutils_unittest.py \
910
	test/ganeti.opcodes_unittest.py \
911
	test/ganeti.ovf_unittest.py \
912
	test/ganeti.qlang_unittest.py \
913
	test/ganeti.query_unittest.py \
914
	test/ganeti.rapi.baserlib_unittest.py \
915
	test/ganeti.rapi.client_unittest.py \
916
	test/ganeti.rapi.resources_unittest.py \
917
	test/ganeti.rapi.rlib2_unittest.py \
918
	test/ganeti.rapi.testutils_unittest.py \
919
	test/ganeti.rpc_unittest.py \
920
	test/ganeti.runtime_unittest.py \
921
	test/ganeti.serializer_unittest.py \
922
	test/ganeti.ssh_unittest.py \
923
	test/ganeti.storage_unittest.py \
924
	test/ganeti.tools.ensure_dirs_unittest.py \
925
	test/ganeti.uidpool_unittest.py \
926
	test/ganeti.utils.algo_unittest.py \
927
	test/ganeti.utils.filelock_unittest.py \
928
	test/ganeti.utils.hash_unittest.py \
929
	test/ganeti.utils.io_unittest-runasroot.py \
930
	test/ganeti.utils.io_unittest.py \
931
	test/ganeti.utils.log_unittest.py \
932
	test/ganeti.utils.mlock_unittest.py \
933
	test/ganeti.utils.nodesetup_unittest.py \
934
	test/ganeti.utils.process_unittest.py \
935
	test/ganeti.utils.retry_unittest.py \
936
	test/ganeti.utils.text_unittest.py \
937
	test/ganeti.utils.wrapper_unittest.py \
938
	test/ganeti.utils.x509_unittest.py \
939
	test/ganeti.utils_unittest.py \
940
	test/ganeti.vcluster_unittest.py \
941
	test/ganeti.workerpool_unittest.py \
942
	test/pycurl_reset_unittest.py \
943
	test/qa.qa_config_unittest.py \
944
	test/tempfile_fork_unittest.py
945

    
946
haskell_tests = htest/test
947

    
948
dist_TESTS = \
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
	test/bash_completion.bash \
955
	$(python_tests)
956

    
957
nodist_TESTS =
958
check_SCRIPTS =
959

    
960
if WANT_HTOOLSTESTS
961
nodist_TESTS += $(haskell_tests)
962
dist_TESTS += htest/offline-test.sh
963
check_SCRIPTS += htest/hpc-htools $(HS_BUILT_TEST_HELPERS)
964
endif
965

    
966
TESTS = $(dist_TESTS) $(nodist_TESTS)
967

    
968
# Environment for all tests
969
PLAIN_TESTS_ENVIRONMENT = \
970
	PYTHONPATH=. \
971
	TOP_SRCDIR=$(abs_top_srcdir) TOP_BUILDDIR=$(abs_top_builddir) \
972
	PYTHON=$(PYTHON) FAKEROOT=$(FAKEROOT_PATH) \
973
	$(RUN_IN_TEMPDIR)
974

    
975
# Environment for tests run by automake
976
TESTS_ENVIRONMENT = \
977
	$(PLAIN_TESTS_ENVIRONMENT) $(abs_top_srcdir)/autotools/testrunner
978

    
979
all_python_code = \
980
	$(dist_sbin_SCRIPTS) \
981
	$(python_scripts) \
982
	$(pkglib_python_scripts) \
983
	$(nodist_pkglib_python_scripts) \
984
	$(python_tests) \
985
	$(pkgpython_PYTHON) \
986
	$(client_PYTHON) \
987
	$(hypervisor_PYTHON) \
988
	$(rapi_PYTHON) \
989
	$(server_PYTHON) \
990
	$(pytools_PYTHON) \
991
	$(http_PYTHON) \
992
	$(confd_PYTHON) \
993
	$(masterd_PYTHON) \
994
	$(impexpd_PYTHON) \
995
	$(utils_PYTHON) \
996
	$(watcher_PYTHON) \
997
	$(noinst_PYTHON) \
998
	$(qa_scripts)
999

    
1000
srclink_files = \
1001
	man/footer.rst \
1002
	test/check-cert-expired_unittest.bash \
1003
	test/daemon-util_unittest.bash \
1004
	test/ganeti-cleaner_unittest.bash \
1005
	test/import-export_unittest.bash \
1006
	test/cli-test.bash \
1007
	test/bash_completion.bash \
1008
	htest/offline-test.sh \
1009
	htest/cli-tests-defs.sh \
1010
	$(all_python_code) \
1011
	$(HS_LIBTEST_SRCS) $(HS_PROG_SRCS)
1012

    
1013
check_python_code = \
1014
	$(BUILD_BASH_COMPLETION) \
1015
	$(CHECK_IMPORTS) \
1016
	$(CHECK_HEADER) \
1017
	$(DOCPP) \
1018
	$(all_python_code)
1019

    
1020
lint_python_code = \
1021
	ganeti \
1022
	ganeti/http/server.py \
1023
	$(dist_sbin_SCRIPTS) \
1024
	$(python_scripts) \
1025
	$(pkglib_python_scripts) \
1026
	$(BUILD_BASH_COMPLETION) \
1027
	$(CHECK_IMPORTS) \
1028
	$(CHECK_HEADER) \
1029
	$(DOCPP) \
1030
	$(PYTHON_BOOTSTRAP)
1031

    
1032
standalone_python_modules = \
1033
	lib/rapi/client.py \
1034
	tools/ganeti-listrunner
1035

    
1036
pep8_python_code = \
1037
	ganeti \
1038
	ganeti/http/server.py \
1039
	$(dist_sbin_SCRIPTS) \
1040
	$(python_scripts) \
1041
	$(pkglib_python_scripts) \
1042
	$(BUILD_BASH_COMPLETION) \
1043
	$(CHECK_HEADER) \
1044
	$(DOCPP) \
1045
	$(PYTHON_BOOTSTRAP) \
1046
	qa
1047

    
1048
test/daemon-util_unittest.bash: daemons/daemon-util
1049

    
1050
test/ganeti-cleaner_unittest.bash: daemons/ganeti-cleaner
1051

    
1052
test/bash_completion.bash: doc/examples/bash_completion-debug
1053

    
1054
tools/kvm-ifup: tools/kvm-ifup.in $(REPLACE_VARS_SED)
1055
	sed -f $(REPLACE_VARS_SED) < $< > $@
1056
	chmod +x $@
1057

    
1058
devel/upload: devel/upload.in $(REPLACE_VARS_SED)
1059
	sed -f $(REPLACE_VARS_SED) < $< > $@
1060
	chmod u+x $@
1061

    
1062
tools/vcluster-setup: tools/vcluster-setup.in $(REPLACE_VARS_SED)
1063
	sed -f $(REPLACE_VARS_SED) < $< > $@
1064
	chmod +x $@
1065

    
1066
daemons/%:: daemons/%.in $(REPLACE_VARS_SED)
1067
	sed -f $(REPLACE_VARS_SED) < $< > $@
1068
	chmod +x $@
1069

    
1070
doc/examples/%:: doc/examples/%.in $(REPLACE_VARS_SED)
1071
	sed -f $(REPLACE_VARS_SED) < $< > $@
1072

    
1073
doc/examples/bash_completion: BC_ARGS = --compact
1074
doc/examples/bash_completion-debug: BC_ARGS =
1075

    
1076
doc/examples/bash_completion doc/examples/bash_completion-debug: \
1077
	$(BUILD_BASH_COMPLETION) $(RUN_IN_TEMPDIR) \
1078
	lib/cli.py $(gnt_scripts) $(client_PYTHON) tools/burnin \
1079
	daemons/ganeti-cleaner \
1080
	$(GENERATED_FILES) $(HTOOLS_GENERATED_FILES)
1081
	PYTHONPATH=. $(RUN_IN_TEMPDIR) \
1082
	  $(CURDIR)/$(BUILD_BASH_COMPLETION) $(BC_ARGS) > $@
1083

    
1084
doc/%.png: doc/%.dot
1085
	@test -n "$(DOT)" || { echo 'dot' not found during configure; exit 1; }
1086
	$(DOT) -Tpng -o $@ $<
1087

    
1088
man/footer.man: man/footer.rst
1089
	@test -n "$(PANDOC)" || \
1090
	  { echo 'pandoc' not found during configure; exit 1; }
1091
	$(PANDOC) -f rst -t man -o $@ $<
1092

    
1093
man/footer.html: man/footer.rst
1094
	@test -n "$(PANDOC)" || \
1095
	  { echo 'pandoc' not found during configure; exit 1; }
1096
	$(PANDOC) -f rst -t html -o $@ $<
1097

    
1098
man/%.gen: man/%.rst lib/query.py lib/build/sphinx_ext.py \
1099
	lib/build/shell_example_lexer.py \
1100
	| $(RUN_IN_TEMPDIR) $(BUILT_PYTHON_SOURCES)
1101
	@echo "Checking $< for hardcoded paths..."
1102
	@if grep -nEf autotools/wrong-hardcoded-paths $<; then \
1103
	  echo "Man page $< has harcoded paths (see above)!" 1>&2 ; \
1104
	  exit 1; \
1105
	fi
1106
	set -e ; \
1107
	trap 'echo auto-removing $@; rm $@' EXIT; \
1108
	PYTHONPATH=. $(RUN_IN_TEMPDIR) $(CURDIR)/$(DOCPP) < $< > $@ ;\
1109
	trap - EXIT
1110

    
1111
man/%.7.in man/%.8.in man/%.1.in: man/%.gen man/footer.man
1112
	@test -n "$(PANDOC)" || \
1113
	  { echo 'pandoc' not found during configure; exit 1; }
1114
	set -o pipefail ; \
1115
	trap 'echo auto-removing $@; rm $@' EXIT; \
1116
	$(PANDOC) -s -f rst -t man -A man/footer.man $< | \
1117
	  sed -e 's/\\@/@/g' > $@; \
1118
	if test -n "$(MAN_HAS_WARNINGS)"; then $(CHECK_MAN_WARNINGS) $@; fi; \
1119
	$(CHECK_MAN_DASHES) $@; \
1120
	trap - EXIT
1121

    
1122

    
1123
man/%.html.in: man/%.gen man/footer.html
1124
	@test -n "$(PANDOC)" || \
1125
	  { echo 'pandoc' not found during configure; exit 1; }
1126
	set -o pipefail ; \
1127
	$(PANDOC) -s -f rst -t html -A man/footer.html $< | \
1128
	  sed -e 's/\\@/@/g' > $@
1129

    
1130
man/%: man/%.in  $(REPLACE_VARS_SED)
1131
	sed -f $(REPLACE_VARS_SED) < $< > $@
1132

    
1133
epydoc.conf: epydoc.conf.in $(REPLACE_VARS_SED)
1134
	sed -f $(REPLACE_VARS_SED) < $< > $@
1135

    
1136
vcs-version:
1137
	if test -d .git; then \
1138
	  git describe > $@; \
1139
	elif test ! -f $@ ; then \
1140
	  echo "Cannot auto-generate $@ file"; exit 1; \
1141
	fi
1142

    
1143
.PHONY: clean-vcs-version
1144
clean-vcs-version:
1145
	rm -f vcs-version
1146

    
1147
.PHONY: regen-vcs-version
1148
regen-vcs-version:
1149
	set -e; \
1150
	cd $(srcdir); \
1151
	if test -d .git; then \
1152
	  $(MAKE) $(AM_MAKEFLAGS) clean-vcs-version; \
1153
	  $(MAKE) $(AM_MAKEFLAGS) vcs-version; \
1154
	fi
1155

    
1156
htools/Ganeti/Version.hs: htools/Ganeti/Version.hs.in \
1157
	vcs-version $(built_base_sources)
1158
	set -e; \
1159
	VCSVER=`cat $(abs_top_srcdir)/vcs-version`; \
1160
	sed -e "s/%ver%/$$VCSVER/" < $< > $@
1161

    
1162
htools/Ganeti/Constants.hs: htools/Ganeti/Constants.hs.in \
1163
	lib/constants.py lib/_autoconf.py lib/luxi.py \
1164
	$(CONVERT_CONSTANTS) $(built_base_sources) \
1165
	| lib/_vcsversion.py
1166
	set -e; \
1167
	{ cat $< ; PYTHONPATH=. $(CONVERT_CONSTANTS); } > $@
1168

    
1169
htest/Test/Ganeti/TestImports.hs: htest/Test/Ganeti/TestImports.hs.in \
1170
	$(built_base_sources)
1171
	set -e; \
1172
	{ cat $< ; \
1173
	  echo ; \
1174
	  for name in $(filter-out Ganeti.THH,$(subst /,.,$(patsubst %.hs,%,$(patsubst htools/%,%,$(HS_LIB_SRCS))))) ; do \
1175
	    echo "import $$name ()" ; \
1176
	  done ; \
1177
	} > $@
1178

    
1179
lib/_autoconf.py: Makefile | stamp-directories
1180
	set -e; \
1181
	{ echo '# This file is automatically generated, do not edit!'; \
1182
	  echo '#'; \
1183
	  echo ''; \
1184
	  echo '"""Build-time configuration for Ganeti.'; \
1185
	  echo '';\
1186
	  echo 'This file is autogenerated by the build process.'; \
1187
	  echo 'For any changes you need to re-run ./configure (and'; \
1188
	  echo 'not edit by hand).'; \
1189
	  echo ''; \
1190
	  echo '"""'; \
1191
	  echo ''; \
1192
	  echo '# pylint: disable=C0301,C0324'; \
1193
	  echo '# because this is autogenerated, we do not want'; \
1194
	  echo '# style warnings' ; \
1195
	  echo ''; \
1196
	  echo "PACKAGE_VERSION = '$(PACKAGE_VERSION)'"; \
1197
	  echo "VERSION_MAJOR = '$(VERSION_MAJOR)'"; \
1198
	  echo "VERSION_MINOR = '$(VERSION_MINOR)'"; \
1199
	  echo "VERSION_REVISION = '$(VERSION_REVISION)'"; \
1200
	  echo "VERSION_SUFFIX = '$(VERSION_SUFFIX)'"; \
1201
	  echo "VERSION_FULL = '$(VERSION_FULL)'"; \
1202
	  echo "LOCALSTATEDIR = '$(localstatedir)'"; \
1203
	  echo "SYSCONFDIR = '$(sysconfdir)'"; \
1204
	  echo "SSH_CONFIG_DIR = '$(SSH_CONFIG_DIR)'"; \
1205
	  echo "SSH_LOGIN_USER = '$(SSH_LOGIN_USER)'"; \
1206
	  echo "SSH_CONSOLE_USER = '$(SSH_CONSOLE_USER)'"; \
1207
	  echo "EXPORT_DIR = '$(EXPORT_DIR)'"; \
1208
	  echo "OS_SEARCH_PATH = [$(OS_SEARCH_PATH)]"; \
1209
	  echo "XEN_BOOTLOADER = '$(XEN_BOOTLOADER)'"; \
1210
	  echo "XEN_KERNEL = '$(XEN_KERNEL)'"; \
1211
	  echo "XEN_INITRD = '$(XEN_INITRD)'"; \
1212
	  echo "KVM_KERNEL = '$(KVM_KERNEL)'"; \
1213
	  echo "FILE_STORAGE_DIR = '$(FILE_STORAGE_DIR)'"; \
1214
	  echo "ENABLE_FILE_STORAGE = $(ENABLE_FILE_STORAGE)"; \
1215
	  echo "SHARED_FILE_STORAGE_DIR = '$(SHARED_FILE_STORAGE_DIR)'"; \
1216
	  echo "ENABLE_SHARED_FILE_STORAGE = $(ENABLE_SHARED_FILE_STORAGE)"; \
1217
	  echo "IALLOCATOR_SEARCH_PATH = [$(IALLOCATOR_SEARCH_PATH)]"; \
1218
	  echo "KVM_PATH = '$(KVM_PATH)'"; \
1219
	  echo "IP_PATH = '$(IP_PATH)'"; \
1220
	  echo "SOCAT_PATH = '$(SOCAT)'"; \
1221
	  echo "SOCAT_USE_ESCAPE = $(SOCAT_USE_ESCAPE)"; \
1222
	  echo "SOCAT_USE_COMPRESS = $(SOCAT_USE_COMPRESS)"; \
1223
	  echo "LVM_STRIPECOUNT = $(LVM_STRIPECOUNT)"; \
1224
	  echo "TOOLSDIR = '$(toolsdir)'"; \
1225
	  echo "GNT_SCRIPTS = [$(foreach i,$(notdir $(gnt_scripts)),'$(i)',)]"; \
1226
	  echo "HTOOLS_PROGS = [$(foreach i,$(HS_HTOOLS_PROGS),'$(i)',)]"; \
1227
	  echo "PKGLIBDIR = '$(pkglibdir)'"; \
1228
	  echo "DRBD_BARRIERS = '$(DRBD_BARRIERS)'"; \
1229
	  echo "DRBD_NO_META_FLUSH = $(DRBD_NO_META_FLUSH)"; \
1230
	  echo "SYSLOG_USAGE = '$(SYSLOG_USAGE)'"; \
1231
	  echo "DAEMONS_GROUP = '$(DAEMONS_GROUP)'"; \
1232
	  echo "ADMIN_GROUP = '$(ADMIN_GROUP)'"; \
1233
	  echo "MASTERD_USER = '$(MASTERD_USER)'"; \
1234
	  echo "MASTERD_GROUP = '$(MASTERD_GROUP)'"; \
1235
	  echo "RAPI_USER = '$(RAPI_USER)'"; \
1236
	  echo "RAPI_GROUP = '$(RAPI_GROUP)'"; \
1237
	  echo "CONFD_USER = '$(CONFD_USER)'"; \
1238
	  echo "CONFD_GROUP = '$(CONFD_GROUP)'"; \
1239
	  echo "NODED_USER = '$(NODED_USER)'"; \
1240
	  echo "NODED_GROUP = '$(NODED_GROUP)'"; \
1241
	  echo "DISK_SEPARATOR = '$(DISK_SEPARATOR)'"; \
1242
	  echo "QEMUIMG_PATH = '$(QEMUIMG_PATH)'"; \
1243
	  echo "HTOOLS = True"; \
1244
	  echo "ENABLE_CONFD = $(ENABLE_CONFD)"; \
1245
	  echo "XEN_CMD = '$(XEN_CMD)'"; \
1246
	  echo "ENABLE_SPLIT_QUERY = $(ENABLE_SPLIT_QUERY)"; \
1247
	} > $@
1248

    
1249
lib/_vcsversion.py: Makefile vcs-version | stamp-directories
1250
	set -e; \
1251
	VCSVER=`cat $(abs_top_srcdir)/vcs-version`; \
1252
	{ echo '# This file is automatically generated, do not edit!'; \
1253
	  echo '#'; \
1254
	  echo ''; \
1255
	  echo '"""Build-time VCS version number for Ganeti.'; \
1256
	  echo '';\
1257
	  echo 'This file is autogenerated by the build process.'; \
1258
	  echo 'For any changes you need to re-run ./configure (and'; \
1259
	  echo 'not edit by hand).'; \
1260
	  echo ''; \
1261
	  echo '"""'; \
1262
	  echo ''; \
1263
	  echo '# pylint: disable=C0301,C0324'; \
1264
	  echo '# because this is autogenerated, we do not want'; \
1265
	  echo '# style warnings' ; \
1266
	  echo ''; \
1267
	  echo "VCS_VERSION = '$$VCSVER'"; \
1268
	} > $@
1269

    
1270
lib/_generated_rpc.py: lib/rpc_defs.py $(BUILD_RPC)
1271
	PYTHONPATH=. $(RUN_IN_TEMPDIR) $(CURDIR)/$(BUILD_RPC) lib/rpc_defs.py > $@
1272

    
1273
$(SHELL_ENV_INIT): Makefile stamp-directories
1274
	set -e; \
1275
	{ echo '# Allow overriding for tests'; \
1276
	  echo 'readonly LOCALSTATEDIR=$${LOCALSTATEDIR:-$${GANETI_ROOTDIR:-}$(localstatedir)}'; \
1277
	  echo 'readonly SYSCONFDIR=$${SYSCONFDIR:-$${GANETI_ROOTDIR:-}$(sysconfdir)}'; \
1278
	  echo; \
1279
	  echo 'readonly PKGLIBDIR=$(pkglibdir)'; \
1280
	  echo 'readonly LOG_DIR="$$LOCALSTATEDIR/log/ganeti"'; \
1281
	  echo 'readonly RUN_DIR="$$LOCALSTATEDIR/run/ganeti"'; \
1282
	  echo 'readonly DATA_DIR="$$LOCALSTATEDIR/lib/ganeti"'; \
1283
	  echo 'readonly CONF_DIR="$$SYSCONFDIR/ganeti"'; \
1284
	} > $@
1285

    
1286
$(REPLACE_VARS_SED): $(SHELL_ENV_INIT) Makefile stamp-directories
1287
	set -e; \
1288
	{ echo 's#@PREFIX@#$(prefix)#g'; \
1289
	  echo 's#@SYSCONFDIR@#$(sysconfdir)#g'; \
1290
	  echo 's#@LOCALSTATEDIR@#$(localstatedir)#g'; \
1291
	  echo 's#@BINDIR@#$(bindir)#g'; \
1292
	  echo 's#@SBINDIR@#$(sbindir)#g'; \
1293
	  echo 's#@GANETI_VERSION@#$(PACKAGE_VERSION)#g'; \
1294
	  echo 's#@CUSTOM_XEN_BOOTLOADER@#$(XEN_BOOTLOADER)#g'; \
1295
	  echo 's#@CUSTOM_XEN_KERNEL@#$(XEN_KERNEL)#g'; \
1296
	  echo 's#@CUSTOM_XEN_INITRD@#$(XEN_INITRD)#g'; \
1297
	  echo 's#@CUSTOM_IALLOCATOR_SEARCH_PATH@#$(IALLOCATOR_SEARCH_PATH)#g'; \
1298
	  echo 's#@CUSTOM_EXPORT_DIR@#$(EXPORT_DIR)#g'; \
1299
	  echo 's#@RPL_FILE_STORAGE_DIR@#$(FILE_STORAGE_DIR)#g'; \
1300
	  echo 's#@RPL_SSH_INITD_SCRIPT@#$(SSH_INITD_SCRIPT)#g'; \
1301
	  echo 's#@PKGLIBDIR@#$(pkglibdir)#g'; \
1302
	  echo 's#@GNTMASTERUSER@#$(MASTERD_USER)#g'; \
1303
	  echo 's#@GNTRAPIUSER@#$(RAPI_USER)#g'; \
1304
	  echo 's#@GNTCONFDUSER@#$(CONFD_USER)#g'; \
1305
	  echo 's#@GNTNODEDUSER@#$(NODED_USER)#g'; \
1306
	  echo 's#@GNTRAPIGROUP@#$(RAPI_GROUP)#g'; \
1307
	  echo 's#@GNTADMINGROUP@#$(ADMIN_GROUP)#g'; \
1308
	  echo 's#@GNTCONFDGROUP@#$(CONFD_GROUP)#g'; \
1309
	  echo 's#@GNTMASTERDGROUP@#$(MASTERD_GROUP)#g'; \
1310
	  echo 's#@GNTDAEMONSGROUP@#$(DAEMONS_GROUP)#g'; \
1311
	  echo 's#@CUSTOM_ENABLE_CONFD@#$(ENABLE_CONFD)#g'; \
1312
	  echo 's#@MODULES@#$(strip $(lint_python_code))#g'; \
1313
	  echo 's#@ENABLE_SPLIT_QUERY@#$(ENABLE_SPLIT_QUERY)#g'; \
1314
	  echo; \
1315
	  echo '/^@SHELL_ENV_INIT@$$/ {'; \
1316
	  echo '  r $(SHELL_ENV_INIT)'; \
1317
	  echo '  d'; \
1318
	  echo '}'; \
1319
	} > $@
1320

    
1321
# Using deferred evaluation
1322
daemons/ganeti-%: MODULE = ganeti.server.$(patsubst ganeti-%,%,$(notdir $@))
1323
daemons/ganeti-watcher: MODULE = ganeti.watcher
1324
scripts/%: MODULE = ganeti.client.$(subst -,_,$(notdir $@))
1325
tools/ensure-dirs: MODULE = ganeti.tools.ensure_dirs
1326
$(HS_BUILT_TEST_HELPERS): TESTROLE = $(patsubst htest/%,%,$@)
1327

    
1328
$(PYTHON_BOOTSTRAP): Makefile | stamp-directories
1329
	test -n "$(MODULE)" || { echo Missing module; exit 1; }
1330
	set -e; \
1331
	{ echo '#!/usr/bin/python'; \
1332
	  echo '# This file is automatically generated, do not edit!'; \
1333
	  echo "# Edit $(MODULE) instead."; \
1334
	  echo; \
1335
	  echo '"""Bootstrap script for L{$(MODULE)}"""'; \
1336
	  echo; \
1337
	  echo '# pylint: disable=C0103'; \
1338
	  echo '# C0103: Invalid name'; \
1339
	  echo; \
1340
	  echo 'import sys'; \
1341
	  echo 'import $(MODULE) as main'; \
1342
	  echo; \
1343
	  echo '# Temporarily alias commands until bash completion'; \
1344
	  echo '# generator is changed'; \
1345
	  echo 'if hasattr(main, "commands"):'; \
1346
	  echo '  commands = main.commands # pylint: disable=E1101'; \
1347
	  echo 'if hasattr(main, "aliases"):'; \
1348
	  echo '  aliases = main.aliases # pylint: disable=E1101'; \
1349
	  echo; \
1350
	  echo 'if __name__ == "__main__":'; \
1351
	  echo '  sys.exit(main.Main())'; \
1352
	} > $@
1353
	chmod u+x $@
1354

    
1355
$(HS_BUILT_TEST_HELPERS): Makefile
1356
	@test -n "$(TESTROLE)" || { echo Missing TESTROLE; exit 1; }
1357
	set -e; \
1358
	{ echo '#!/bin/sh'; \
1359
	  echo '# This file is automatically generated, do not edit!'; \
1360
	  echo "# Edit Makefile.am instead."; \
1361
	  echo; \
1362
	  echo "HTOOLS=$(TESTROLE) exec ./htest/hpc-htools \"\$$@\""; \
1363
	} > $@
1364
	chmod u+x $@
1365

    
1366
stamp-directories: Makefile
1367
	$(MAKE) $(AM_MAKEFLAGS) ganeti
1368
	@mkdir_p@ $(DIRS) $(BUILDTIME_DIR_AUTOCREATE)
1369
	touch $@
1370

    
1371
# We need to create symlinks because "make distcheck" will not install Python
1372
# files when building.
1373
stamp-srclinks: Makefile | stamp-directories
1374
	set -e; \
1375
	for i in $(srclink_files); do \
1376
		if test ! -f $$i -a -f $(abs_top_srcdir)/$$i; then \
1377
			$(LN_S) $(abs_top_srcdir)/$$i $$i; \
1378
		fi; \
1379
	done
1380
	touch $@
1381

    
1382
.PHONY: ganeti
1383
ganeti:
1384
	cd $(top_builddir) && test -h "$@" || { rm -f $@ && $(LN_S) lib $@; }
1385

    
1386
.PHONY: check-dirs
1387
check-dirs: $(GENERATED_FILES)
1388
	@set -e; \
1389
	find . -type d \( \( -name . \) -o \( \
1390
		-name .git -o \
1391
		-name autom4te.cache \
1392
		\) -prune -o -print \) | { \
1393
		error=; \
1394
		while read dir; do \
1395
			case "$$dir" in \
1396
				$(strip $(patsubst %,(./%) ;;,$(DIRCHECK_EXCLUDE) $(DIRS))) \
1397
				*) error=1; echo "Directory $$dir not listed in Makefile" >&2 ;; \
1398
			esac; \
1399
		done; \
1400
		for dir in $(DIRS); do \
1401
			if ! test -d "$$dir"; then \
1402
				echo "Directory $$dir listed in DIRS does not exist" >&2; \
1403
				error=1; \
1404
			fi \
1405
		done; \
1406
		if test -n "$$error"; then exit 1; else exit 0; fi; \
1407
	}
1408

    
1409
.PHONY: check-local
1410
check-local: check-dirs $(GENERATED_FILES)
1411
	$(CHECK_PYTHON_CODE) $(check_python_code)
1412
	PYTHONPATH=. $(CHECK_HEADER) $(check_python_code)
1413
	$(CHECK_VERSION) $(VERSION) $(top_srcdir)/NEWS
1414
	$(CHECK_NEWS) < $(top_srcdir)/NEWS
1415
	PYTHONPATH=. $(RUN_IN_TEMPDIR) $(CURDIR)/$(CHECK_IMPORTS) . $(standalone_python_modules)
1416
	@expver=$(VERSION_MAJOR).$(VERSION_MINOR); \
1417
	if test "`head -n 1 $(top_srcdir)/README`" != "Ganeti $$expver"; then \
1418
		echo "Incorrect version in README, expected $$expver"; \
1419
		exit 1; \
1420
	fi; \
1421
	for file in doc/iallocator.rst doc/hooks.rst doc/virtual-cluster.rst; do \
1422
		if test "`sed -ne '4 p' $(top_srcdir)/$$file`" != \
1423
			"Documents Ganeti version $$expver"; then \
1424
			echo "Incorrect version in $$file, expected $$expver"; \
1425
			exit 1; \
1426
		fi; \
1427
	done; \
1428
	if ! test -f $(top_srcdir)/doc/design-$$expver.rst; then \
1429
		echo "File $(top_srcdir)/doc/design-$$expver.rst not found"; \
1430
		exit 1; \
1431
	fi
1432

    
1433
.PHONY: hs-check
1434
hs-check: htest/test htest/hpc-htools $(HS_BUILT_TEST_HELPERS)
1435
	@rm -f test.tix
1436
	./htest/test
1437
	HBINARY="./htest/hpc-htools" ./htest/offline-test.sh
1438

    
1439
# E111: indentation is not a multiple of four
1440
# E121: continuation line indentation is not a multiple of four
1441
#       (since our indent level is not 4)
1442
# E125: continuation line does not distinguish itself from next logical line
1443
#       (since our indent level is not 4)
1444
# E127: continuation line over-indented for visual indent
1445
#       (since our indent level is not 4)
1446
# note: do NOT add E128 here; it's a valid style error in most cases!
1447
# I've seen real errors, but also some cases were we indent wrongly
1448
# due to line length; try to rework the cases where it is triggered,
1449
# instead of silencing it
1450
# E261: at least two spaces before inline comment
1451
# E501: line too long (80 characters)
1452
PEP8_IGNORE = E111,E121,E125,E127,E261,E501
1453

    
1454
# For excluding pep8 expects filenames only, not whole paths
1455
PEP8_EXCLUDE = $(subst $(space),$(comma),$(strip $(notdir $(BUILT_PYTHON_SOURCES))))
1456

    
1457
LINT_TARGETS = pylint pylint-qa
1458
if HAS_PEP8
1459
LINT_TARGETS += pep8
1460
endif
1461
if HAS_HLINT
1462
LINT_TARGETS += hlint
1463
endif
1464

    
1465
.PHONY: lint
1466
lint: $(LINT_TARGETS)
1467

    
1468
.PHONY: pylint
1469
pylint: $(GENERATED_FILES)
1470
	@test -n "$(PYLINT)" || { echo 'pylint' not found during configure; exit 1; }
1471
	$(PYLINT) $(LINT_OPTS) $(lint_python_code)
1472

    
1473
.PHONY: pylint-qa
1474
pylint-qa: $(GENERATED_FILES)
1475
	@test -n "$(PYLINT)" || { echo 'pylint' not found during configure; exit 1; }
1476
	cd $(top_srcdir)/qa && \
1477
	  PYTHONPATH=$(abs_top_srcdir) $(PYLINT) $(LINT_OPTS) \
1478
	  --rcfile  ../pylintrc $(patsubst qa/%.py,%,$(qa_scripts))
1479

    
1480
.PHONY: pep8
1481
pep8: $(GENERATED_FILES)
1482
	@test -n "$(PEP8)" || { echo 'pep8' not found during configure; exit 1; }
1483
	$(PEP8) --ignore='$(PEP8_IGNORE)' --exclude='$(PEP8_EXCLUDE)' \
1484
		--repeat $(pep8_python_code)
1485

    
1486
# FIXME: remove ignore "Use void" when GHC 6.x is deprecated
1487
.PHONY: hlint
1488
hlint: $(HS_BUILT_SRCS) htools/lint-hints.hs
1489
	@test -n "$(HLINT)" || { echo 'hlint' not found during configure; exit 1; }
1490
	if tty -s; then C="-c"; else C=""; fi; \
1491
	$(HLINT) --report=doc/hs-lint.html --cross $$C \
1492
	  --ignore "Use first" \
1493
	  --ignore "Use comparing" \
1494
	  --ignore "Use on" \
1495
	  --ignore "Reduce duplication" \
1496
	  --ignore "Use &&&" \
1497
	  --ignore "Use void" \
1498
	  --hint htools/lint-hints \
1499
	  $(filter-out htools/Ganeti/THH.hs,$(HS_LIBTEST_SRCS) $(HS_PROG_SRCS))
1500

    
1501
# a dist hook rule for updating the vcs-version file; this is
1502
# hardcoded due to where it needs to build the file...
1503
dist-hook:
1504
	$(MAKE) $(AM_MAKEFLAGS) regen-vcs-version
1505
	rm -f $(top_distdir)/vcs-version
1506
	cp -p $(srcdir)/vcs-version $(top_distdir)
1507

    
1508
# a distcheck hook rule for catching revision control directories
1509
distcheck-hook:
1510
	if find $(top_distdir) -name .svn -or -name .git | grep .; then \
1511
		echo "Found revision control files in final archive." 1>&2; \
1512
		exit 1; \
1513
	fi
1514
	if find $(top_distdir) -name '*.py[co]' | grep .; then \
1515
		echo "Found Python byte code in final archive." 1>&2; \
1516
		exit 1; \
1517
	fi
1518
	if find $(top_distdir) -name '*~' | grep .; then \
1519
		echo "Found backup files in final archive." 1>&2; \
1520
		exit 1; \
1521
	fi
1522
# Empty files or directories should not be distributed. They can cause
1523
# unnecessary warnings for packagers. Directories used by automake during
1524
# distcheck must be excluded.
1525
	if find $(top_distdir) -empty -and -not \( \
1526
			-path $(top_distdir)/_build -or \
1527
			-path $(top_distdir)/_inst \) | grep .; then \
1528
		echo "Found empty files or directories in final archive." 1>&2; \
1529
		exit 1; \
1530
	fi
1531
	if test -n "$(BUILD_RELEASE)" && \
1532
	   grep -n -H -E '^\*.*unreleased' $(top_distdir)/NEWS; then \
1533
		echo "Found unreleased version in NEWS." >&2; \
1534
		exit 1; \
1535
	fi
1536

    
1537
# When building a release, stricter checks should be used
1538
distcheck-release dist-release: export BUILD_RELEASE = 1
1539
distcheck-release: distcheck
1540

    
1541
distrebuildcheck: dist
1542
	set -e; \
1543
	builddir=$$(mktemp -d $(abs_srcdir)/distrebuildcheck.XXXXXXX); \
1544
	trap "echo Removing $$builddir; cd $(abs_srcdir); rm -rf $$builddir" EXIT; \
1545
	cd $$builddir; \
1546
	tar xzf $(abs_srcdir)/$(distdir).tar.gz; \
1547
	cd $(distdir); \
1548
	./configure; \
1549
	$(MAKE) maintainer-clean; \
1550
	cp $(abs_srcdir)/vcs-version .; \
1551
	./configure; \
1552
	$(MAKE) $(AM_MAKEFLAGS)
1553

    
1554
dist-release: dist
1555
	set -e; \
1556
	for i in $(DIST_ARCHIVES); do \
1557
		echo -n "Checking $$i ... "; \
1558
		autotools/check-tar < $$i; \
1559
		echo OK; \
1560
	done
1561

    
1562
install-exec-local:
1563
	@mkdir_p@ "$(DESTDIR)${localstatedir}/lib/ganeti" \
1564
	  "$(DESTDIR)${localstatedir}/log/ganeti" \
1565
	  "$(DESTDIR)${localstatedir}/run/ganeti"
1566

    
1567
.PHONY: apidoc
1568
if WANT_HTOOLSAPIDOC
1569
apidoc: py-apidoc hs-apidoc
1570
else
1571
apidoc: py-apidoc
1572
endif
1573

    
1574
.PHONY: py-apidoc
1575
py-apidoc: epydoc.conf $(RUN_IN_TEMPDIR) $(GENERATED_FILES)
1576
	$(RUN_IN_TEMPDIR) epydoc -v \
1577
		--conf $(CURDIR)/epydoc.conf \
1578
		--output $(CURDIR)/$(APIDOC_PY_DIR)
1579

    
1580
.PHONY: hs-apidoc
1581
hs-apidoc: $(HS_BUILT_SRCS)
1582
	@test -n "$(HSCOLOUR)" || \
1583
	    { echo 'HsColour' not found during configure; exit 1; }
1584
	@test -n "$(HADDOCK)" || \
1585
	    { echo 'haddock' not found during configure; exit 1; }
1586
	rm -rf $(APIDOC_HS_DIR)/*
1587
	@mkdir_p@ $(APIDOC_HS_DIR)/Ganeti/HTools/Program
1588
	@mkdir_p@ $(APIDOC_HS_DIR)/Ganeti/Confd
1589
	@mkdir_p@ $(APIDOC_HS_DIR)/Ganeti/Query
1590
	$(HSCOLOUR) -print-css > $(APIDOC_HS_DIR)/Ganeti/hscolour.css
1591
	$(LN_S) ../hscolour.css $(APIDOC_HS_DIR)/Ganeti/HTools/hscolour.css
1592
	$(LN_S) ../hscolour.css $(APIDOC_HS_DIR)/Ganeti/Confd/hscolour.css
1593
	set -e ; \
1594
	cd htools; \
1595
	if [ "$(HTOOLS_NOCURL)" ]; \
1596
	then OPTGHC="--optghc=$(HTOOLS_NOCURL)"; \
1597
	else OPTGHC=""; \
1598
	fi; \
1599
	if [ "$(HTOOLS_PARALLEL3)" ]; \
1600
	then OPTGHC="$$OPTGHC --optghc=$(HTOOLS_PARALLEL3)"; \
1601
	fi; \
1602
	if [ "$(HTOOLS_REGEX_PCRE)" ]; \
1603
	then OPTGHC="$$OPTGHC --optghc=$(HTOOLS_REGEX_PCRE)"; \
1604
	fi; \
1605
	RELSRCS="$(HS_LIB_SRCS:htools/%=%) $(patsubst htools/%,%,$(filter htools/%,$(HS_BUILT_SRCS)))"; \
1606
	for file in $$RELSRCS; do \
1607
		hfile=`echo $$file|sed 's/\\.hs$$//'`.html; \
1608
		$(HSCOLOUR) -css -anchor $$file > ../$(APIDOC_HS_DIR)/$$hfile ; \
1609
	done ; \
1610
	$(HADDOCK) --odir ../$(APIDOC_HS_DIR) --html --ignore-all-exports -w \
1611
		-t ganeti -p haddock-prologue \
1612
		--source-module="%{MODULE/.//}.html" \
1613
		--source-entity="%{MODULE/.//}.html#%{NAME}" \
1614
		$$OPTGHC \
1615
		$(filter-out Ganeti/HTools/ExtLoader.hs,$(HS_LIB_SRCS:htools/%=%))
1616

    
1617
.PHONY: TAGS
1618
TAGS: $(GENERATED_FILES)
1619
	rm -f TAGS
1620
	$(GHC) -e ":etags" -v0 \
1621
	  $(filter-out -O -Werror,$(HFLAGS)) \
1622
	  $(HTOOLS_NOCURL) $(HTOOLS_PARALLEL3) $(HTOOLS_REGEX_PCRE) \
1623
	  $(HS_LIBTEST_SRCS)
1624
	find . -path './lib/*.py' -o -path './scripts/gnt-*' -o \
1625
	  -path './daemons/ganeti-*' -o -path './tools/*' -o \
1626
	  -path './qa/*.py' | \
1627
	  etags -l python -a -
1628

    
1629
.PHONY: coverage
1630
if WANT_HTOOLS
1631
coverage: py-coverage hs-coverage
1632
else
1633
coverage: py-coverage
1634
endif
1635

    
1636
.PHONY: py-coverage
1637
py-coverage: $(GENERATED_FILES) $(python_tests)
1638
	set -e; \
1639
	COVERAGE_FILE=$(CURDIR)/$(COVERAGE_PY_DIR)/data \
1640
	TEXT_COVERAGE=$(CURDIR)/$(COVERAGE_PY_DIR)/report.txt \
1641
	HTML_COVERAGE=$(CURDIR)/$(COVERAGE_PY_DIR) \
1642
	$(PLAIN_TESTS_ENVIRONMENT) $(abs_top_srcdir)/autotools/gen-coverage \
1643
	$(python_tests)
1644

    
1645
.PHONY: hs-coverage
1646
hs-coverage: $(haskell_tests) htest/hpc-htools
1647
	rm -f *.tix
1648
	$(MAKE) $(AM_MAKEFLAGS) hs-check
1649
	@mkdir_p@ $(COVERAGE_HS_DIR)
1650
	hpc combine --union $(HPCEXCL) \
1651
	  test.tix hpc-htools.tix > coverage-htools.tix
1652
	hpc markup --destdir=$(COVERAGE_HS_DIR) coverage-htools.tix
1653
	hpc report coverage-htools.tix
1654
	$(LN_S) -f hpc_index.html $(COVERAGE_HS_DIR)/index.html
1655

    
1656
# Special "kind-of-QA" target for htools, needs special setup (all
1657
# tools compiled with -fhpc)
1658
.PHONY: live-test
1659
live-test: all
1660
	set -e ; \
1661
	cd htools; \
1662
	rm -f .hpc; $(LN_S) ../.hpc .hpc; \
1663
	rm -f *.tix *.mix; \
1664
	./live-test.sh; \
1665
	hpc sum --union $(HPCEXCL) $(addsuffix .tix,$(HS_PROGS:htools/%=%)) \
1666
	  --output=live-test.tix ; \
1667
	@mkdir_p@ ../$(COVERAGE_HS_DIR) ; \
1668
	hpc markup --destdir=../$(COVERAGE_HS_DIR) live-test \
1669
		--srcdir=.. $(HPCEXCL) ; \
1670
	hpc report --srcdir=.. live-test $(HPCEXCL)
1671

    
1672
commit-check: distcheck lint apidoc
1673

    
1674
.PHONY: gitignore-check
1675
gitignore-check:
1676
	@if [ -n "`git status --short`" ]; then \
1677
	  echo "Git status is not clean!" 1>&2 ; \
1678
	  git status --short; \
1679
	  exit 1; \
1680
	fi
1681

    
1682
# we don't need the ancient implicit rules:
1683
%: %,v
1684
%: RCS/%,v
1685
%: RCS/%
1686
%: s.%
1687
%: SCCS/s.%
1688

    
1689
-include ./Makefile.local
1690

    
1691
# vim: set noet :