Statistics
| Branch: | Tag: | Revision:

root / Makefile.am @ ef3ad027

History | View | Annotate | Download (48.8 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
	lib/tools/prepare_node_join.py
320

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

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

    
389
HS_PROGS = htools/htools
390
HS_BIN_ROLES = hbal hscan hspace hinfo hcheck
391
HS_HTOOLS_PROGS = $(HS_BIN_ROLES) hail
392

    
393
HS_ALL_PROGS = \
394
	$(HS_PROGS) \
395
	htest/hpc-htools \
396
	htest/test \
397
	htools/hconfd \
398
	htools/rpc-test
399

    
400
HS_PROG_SRCS = $(patsubst %,%.hs,$(HS_ALL_PROGS))
401
HS_BUILT_TEST_HELPERS = $(HS_BIN_ROLES:%=htest/%) htest/hail
402

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

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

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

    
505
HS_LIBTEST_SRCS = $(HS_LIB_SRCS) $(HS_TEST_SRCS)
506

    
507
HS_BUILT_SRCS = \
508
	htest/Test/Ganeti/TestImports.hs \
509
	htools/Ganeti/Constants.hs \
510
	htools/Ganeti/Version.hs
511
HS_BUILT_SRCS_IN = $(patsubst %,%.in,$(HS_BUILT_SRCS))
512

    
513
$(RUN_IN_TEMPDIR): | stamp-directories
514

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

    
535
doc/html: doc/html/index.html
536

    
537
doc/install-quick.rst: INSTALL
538
doc/news.rst: NEWS
539
doc/upgrade.rst: UPGRADE
540

    
541
doc/install-quick.rst doc/news.rst doc/upgrade.rst:
542
	set -e; \
543
	{ echo '.. This file is automatically updated at build time from $<.'; \
544
	  echo '.. Do not edit.'; \
545
	  echo; \
546
	  cat $<; \
547
	} > $@
548

    
549
docdot = \
550
	doc/arch-2.0.dot \
551
	doc/design-2.1-lock-acquire.dot \
552
	doc/design-2.1-lock-release.dot
553

    
554
docpng = $(patsubst %.dot,%.png,$(docdot))
555

    
556
# Things to build but not to install (add it to EXTRA_DIST if it should be
557
# distributed)
558
noinst_DATA = \
559
	devel/upload \
560
	doc/html \
561
	$(BUILT_EXAMPLES) \
562
	doc/examples/bash_completion \
563
	doc/examples/bash_completion-debug \
564
	$(manhtml)
565

    
566
gnt_scripts = \
567
	scripts/gnt-backup \
568
	scripts/gnt-cluster \
569
	scripts/gnt-debug \
570
	scripts/gnt-group \
571
	scripts/gnt-instance \
572
	scripts/gnt-job \
573
	scripts/gnt-node \
574
	scripts/gnt-os
575

    
576
PYTHON_BOOTSTRAP_SBIN = \
577
	daemons/ganeti-masterd \
578
	daemons/ganeti-noded \
579
	daemons/ganeti-rapi \
580
	daemons/ganeti-watcher \
581
	$(gnt_scripts)
582

    
583
PYTHON_BOOTSTRAP = \
584
	$(PYTHON_BOOTSTRAP_SBIN) \
585
	tools/ensure-dirs \
586
	tools/prepare-node-join
587

    
588
qa_scripts = \
589
	qa/__init__.py \
590
	qa/ganeti-qa.py \
591
	qa/qa_cluster.py \
592
	qa/qa_config.py \
593
	qa/qa_daemon.py \
594
	qa/qa_env.py \
595
	qa/qa_error.py \
596
	qa/qa_group.py \
597
	qa/qa_instance.py \
598
	qa/qa_job.py \
599
	qa/qa_node.py \
600
	qa/qa_os.py \
601
	qa/qa_rapi.py \
602
	qa/qa_tags.py \
603
	qa/qa_utils.py
604

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

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

    
633
# for the htest/test binary, we need to enable profiling/coverage
634
htest/test: HEXTRA_INT=-fhpc -ihtest
635

    
636
# we compile the hpc-htools binary with the program coverage
637
htest/hpc-htools: HEXTRA_INT=-fhpc
638

    
639
# test dependency
640
htest/offline-tests.sh: htest/hpc-htools
641

    
642
# rules for building profiling-enabled versions of the haskell
643
# programs: hs-prof does the full two-step build, whereas
644
# hs-prof-quick does only the final rebuild (hs-prof must have been
645
# run before)
646
.PHONY: hs-prof hs-prof-quick
647
hs-prof:
648
	$(MAKE) $(AM_MAKEFLAGS) clean
649
	$(MAKE) $(AM_MAKEFLAGS) $(HS_ALL_PROGS) HEXTRA="-osuf .o"
650
	rm -f $(HS_ALL_PROGS)
651
	$(MAKE) $(AM_MAKEFLAGS) hs-prof-quick
652

    
653
hs-prof-quick:
654
	$(MAKE) $(AM_MAKEFLAGS) $(HS_ALL_PROGS) HEXTRA="-osuf .prof_o -prof -auto-all"
655

    
656
dist_sbin_SCRIPTS = \
657
	tools/ganeti-listrunner
658

    
659
nodist_sbin_SCRIPTS = \
660
	$(PYTHON_BOOTSTRAP_SBIN) \
661
	daemons/ganeti-cleaner
662

    
663
if ENABLE_CONFD
664
htools/ganeti-confd: htools/hconfd
665
	cp -f $< $@
666

    
667
nodist_sbin_SCRIPTS += htools/ganeti-confd
668
endif
669

    
670
python_scripts = \
671
	tools/burnin \
672
	tools/cfgshell \
673
	tools/cfgupgrade \
674
	tools/cfgupgrade12 \
675
	tools/cluster-merge \
676
	tools/confd-client \
677
	tools/fmtjson \
678
	tools/lvmstrap \
679
	tools/move-instance \
680
	tools/ovfconverter \
681
	tools/sanitize-config \
682
	tools/setup-ssh
683

    
684
dist_tools_SCRIPTS = \
685
	$(python_scripts) \
686
	tools/kvm-console-wrapper \
687
	tools/master-ip-setup \
688
	tools/xm-console-wrapper
689

    
690
nodist_tools_SCRIPTS = \
691
	tools/vcluster-setup
692

    
693
pkglib_python_scripts = \
694
	daemons/import-export \
695
	tools/check-cert-expired
696

    
697
nodist_pkglib_python_scripts = \
698
	tools/ensure-dirs \
699
	tools/prepare-node-join
700

    
701
myexeclib_SCRIPTS = \
702
	daemons/daemon-util \
703
	tools/kvm-ifup \
704
	$(pkglib_python_scripts)
705

    
706
nodist_myexeclib_SCRIPTS = \
707
	$(nodist_pkglib_python_scripts)
708

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

    
764
man_MANS = \
765
	man/ganeti-cleaner.8 \
766
	man/ganeti-confd.8 \
767
	man/ganeti-listrunner.8 \
768
	man/ganeti-masterd.8 \
769
	man/ganeti-noded.8 \
770
	man/ganeti-os-interface.7 \
771
	man/ganeti-rapi.8 \
772
	man/ganeti-watcher.8 \
773
	man/ganeti.7 \
774
	man/gnt-backup.8 \
775
	man/gnt-cluster.8 \
776
	man/gnt-debug.8 \
777
	man/gnt-group.8 \
778
	man/gnt-instance.8 \
779
	man/gnt-job.8 \
780
	man/gnt-node.8 \
781
	man/gnt-os.8 \
782
	man/hail.1 \
783
	man/hbal.1 \
784
	man/hcheck.1 \
785
	man/hinfo.1 \
786
	man/hscan.1 \
787
	man/hspace.1 \
788
	man/htools.1
789

    
790
manrst = $(patsubst %.1,%.rst,$(patsubst %.7,%.rst,$(patsubst %.8,%.rst,$(man_MANS))))
791
manhtml = $(patsubst %.rst,%.html,$(manrst))
792
mangen = $(patsubst %.rst,%.gen,$(manrst))
793
maninput = \
794
	$(patsubst %.1,%.1.in,$(patsubst %.7,%.7.in,$(patsubst %.8,%.8.in,$(man_MANS)))) \
795
	$(patsubst %.html,%.html.in,$(manhtml)) \
796
	man/footer.man man/footer.html $(mangen)
797

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

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

    
958
haskell_tests = htest/test
959

    
960
dist_TESTS = \
961
	test/check-cert-expired_unittest.bash \
962
	test/daemon-util_unittest.bash \
963
	test/ganeti-cleaner_unittest.bash \
964
	test/import-export_unittest.bash \
965
	test/cli-test.bash \
966
	test/bash_completion.bash \
967
	$(python_tests)
968

    
969
nodist_TESTS =
970
check_SCRIPTS =
971

    
972
if WANT_HTOOLSTESTS
973
nodist_TESTS += $(haskell_tests)
974
dist_TESTS += htest/offline-test.sh
975
check_SCRIPTS += htest/hpc-htools $(HS_BUILT_TEST_HELPERS)
976
endif
977

    
978
TESTS = $(dist_TESTS) $(nodist_TESTS)
979

    
980
# Environment for all tests
981
PLAIN_TESTS_ENVIRONMENT = \
982
	PYTHONPATH=. \
983
	TOP_SRCDIR=$(abs_top_srcdir) TOP_BUILDDIR=$(abs_top_builddir) \
984
	PYTHON=$(PYTHON) FAKEROOT=$(FAKEROOT_PATH) \
985
	$(RUN_IN_TEMPDIR)
986

    
987
# Environment for tests run by automake
988
TESTS_ENVIRONMENT = \
989
	$(PLAIN_TESTS_ENVIRONMENT) $(abs_top_srcdir)/autotools/testrunner
990

    
991
all_python_code = \
992
	$(dist_sbin_SCRIPTS) \
993
	$(python_scripts) \
994
	$(pkglib_python_scripts) \
995
	$(nodist_pkglib_python_scripts) \
996
	$(python_tests) \
997
	$(pkgpython_PYTHON) \
998
	$(client_PYTHON) \
999
	$(hypervisor_PYTHON) \
1000
	$(rapi_PYTHON) \
1001
	$(server_PYTHON) \
1002
	$(pytools_PYTHON) \
1003
	$(http_PYTHON) \
1004
	$(confd_PYTHON) \
1005
	$(masterd_PYTHON) \
1006
	$(impexpd_PYTHON) \
1007
	$(utils_PYTHON) \
1008
	$(watcher_PYTHON) \
1009
	$(noinst_PYTHON) \
1010
	$(qa_scripts)
1011

    
1012
srclink_files = \
1013
	man/footer.rst \
1014
	test/check-cert-expired_unittest.bash \
1015
	test/daemon-util_unittest.bash \
1016
	test/ganeti-cleaner_unittest.bash \
1017
	test/import-export_unittest.bash \
1018
	test/cli-test.bash \
1019
	test/bash_completion.bash \
1020
	htest/offline-test.sh \
1021
	htest/cli-tests-defs.sh \
1022
	$(all_python_code) \
1023
	$(HS_LIBTEST_SRCS) $(HS_PROG_SRCS)
1024

    
1025
check_python_code = \
1026
	$(BUILD_BASH_COMPLETION) \
1027
	$(CHECK_IMPORTS) \
1028
	$(CHECK_HEADER) \
1029
	$(DOCPP) \
1030
	$(all_python_code)
1031

    
1032
lint_python_code = \
1033
	ganeti \
1034
	ganeti/http/server.py \
1035
	$(dist_sbin_SCRIPTS) \
1036
	$(python_scripts) \
1037
	$(pkglib_python_scripts) \
1038
	$(BUILD_BASH_COMPLETION) \
1039
	$(CHECK_IMPORTS) \
1040
	$(CHECK_HEADER) \
1041
	$(DOCPP) \
1042
	$(PYTHON_BOOTSTRAP)
1043

    
1044
standalone_python_modules = \
1045
	lib/rapi/client.py \
1046
	tools/ganeti-listrunner
1047

    
1048
pep8_python_code = \
1049
	ganeti \
1050
	ganeti/http/server.py \
1051
	$(dist_sbin_SCRIPTS) \
1052
	$(python_scripts) \
1053
	$(pkglib_python_scripts) \
1054
	$(BUILD_BASH_COMPLETION) \
1055
	$(CHECK_HEADER) \
1056
	$(DOCPP) \
1057
	$(PYTHON_BOOTSTRAP) \
1058
	qa
1059

    
1060
test/daemon-util_unittest.bash: daemons/daemon-util
1061

    
1062
test/ganeti-cleaner_unittest.bash: daemons/ganeti-cleaner
1063

    
1064
test/bash_completion.bash: doc/examples/bash_completion-debug
1065

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

    
1070
devel/upload: devel/upload.in $(REPLACE_VARS_SED)
1071
	sed -f $(REPLACE_VARS_SED) < $< > $@
1072
	chmod u+x $@
1073

    
1074
tools/vcluster-setup: tools/vcluster-setup.in $(REPLACE_VARS_SED)
1075
	sed -f $(REPLACE_VARS_SED) < $< > $@
1076
	chmod +x $@
1077

    
1078
daemons/%:: daemons/%.in $(REPLACE_VARS_SED)
1079
	sed -f $(REPLACE_VARS_SED) < $< > $@
1080
	chmod +x $@
1081

    
1082
doc/examples/%:: doc/examples/%.in $(REPLACE_VARS_SED)
1083
	sed -f $(REPLACE_VARS_SED) < $< > $@
1084

    
1085
doc/examples/bash_completion: BC_ARGS = --compact
1086
doc/examples/bash_completion-debug: BC_ARGS =
1087

    
1088
doc/examples/bash_completion doc/examples/bash_completion-debug: \
1089
	$(BUILD_BASH_COMPLETION) $(RUN_IN_TEMPDIR) \
1090
	lib/cli.py $(gnt_scripts) $(client_PYTHON) tools/burnin \
1091
	daemons/ganeti-cleaner \
1092
	$(GENERATED_FILES) $(HTOOLS_GENERATED_FILES)
1093
	PYTHONPATH=. $(RUN_IN_TEMPDIR) \
1094
	  $(CURDIR)/$(BUILD_BASH_COMPLETION) $(BC_ARGS) > $@
1095

    
1096
doc/%.png: doc/%.dot
1097
	@test -n "$(DOT)" || { echo 'dot' not found during configure; exit 1; }
1098
	$(DOT) -Tpng -o $@ $<
1099

    
1100
man/footer.man: man/footer.rst
1101
	@test -n "$(PANDOC)" || \
1102
	  { echo 'pandoc' not found during configure; exit 1; }
1103
	$(PANDOC) -f rst -t man -o $@ $<
1104

    
1105
man/footer.html: man/footer.rst
1106
	@test -n "$(PANDOC)" || \
1107
	  { echo 'pandoc' not found during configure; exit 1; }
1108
	$(PANDOC) -f rst -t html -o $@ $<
1109

    
1110
man/%.gen: man/%.rst lib/query.py lib/build/sphinx_ext.py \
1111
	lib/build/shell_example_lexer.py \
1112
	| $(RUN_IN_TEMPDIR) $(BUILT_PYTHON_SOURCES)
1113
	@echo "Checking $< for hardcoded paths..."
1114
	@if grep -nEf autotools/wrong-hardcoded-paths $<; then \
1115
	  echo "Man page $< has harcoded paths (see above)!" 1>&2 ; \
1116
	  exit 1; \
1117
	fi
1118
	set -e ; \
1119
	trap 'echo auto-removing $@; rm $@' EXIT; \
1120
	PYTHONPATH=. $(RUN_IN_TEMPDIR) $(CURDIR)/$(DOCPP) < $< > $@ ;\
1121
	trap - EXIT
1122

    
1123
man/%.7.in man/%.8.in man/%.1.in: man/%.gen man/footer.man
1124
	@test -n "$(PANDOC)" || \
1125
	  { echo 'pandoc' not found during configure; exit 1; }
1126
	set -o pipefail ; \
1127
	trap 'echo auto-removing $@; rm $@' EXIT; \
1128
	$(PANDOC) -s -f rst -t man -A man/footer.man $< | \
1129
	  sed -e 's/\\@/@/g' > $@; \
1130
	if test -n "$(MAN_HAS_WARNINGS)"; then $(CHECK_MAN_WARNINGS) $@; fi; \
1131
	$(CHECK_MAN_DASHES) $@; \
1132
	trap - EXIT
1133

    
1134

    
1135
man/%.html.in: man/%.gen man/footer.html
1136
	@test -n "$(PANDOC)" || \
1137
	  { echo 'pandoc' not found during configure; exit 1; }
1138
	set -o pipefail ; \
1139
	$(PANDOC) -s -f rst -t html -A man/footer.html $< | \
1140
	  sed -e 's/\\@/@/g' > $@
1141

    
1142
man/%: man/%.in  $(REPLACE_VARS_SED)
1143
	sed -f $(REPLACE_VARS_SED) < $< > $@
1144

    
1145
epydoc.conf: epydoc.conf.in $(REPLACE_VARS_SED)
1146
	sed -f $(REPLACE_VARS_SED) < $< > $@
1147

    
1148
vcs-version:
1149
	if test -d .git; then \
1150
	  git describe > $@; \
1151
	elif test ! -f $@ ; then \
1152
	  echo "Cannot auto-generate $@ file"; exit 1; \
1153
	fi
1154

    
1155
.PHONY: clean-vcs-version
1156
clean-vcs-version:
1157
	rm -f vcs-version
1158

    
1159
.PHONY: regen-vcs-version
1160
regen-vcs-version:
1161
	set -e; \
1162
	cd $(srcdir); \
1163
	if test -d .git; then \
1164
	  $(MAKE) $(AM_MAKEFLAGS) clean-vcs-version; \
1165
	  $(MAKE) $(AM_MAKEFLAGS) vcs-version; \
1166
	fi
1167

    
1168
htools/Ganeti/Version.hs: htools/Ganeti/Version.hs.in \
1169
	vcs-version $(built_base_sources)
1170
	set -e; \
1171
	VCSVER=`cat $(abs_top_srcdir)/vcs-version`; \
1172
	sed -e "s/%ver%/$$VCSVER/" < $< > $@
1173

    
1174
htools/Ganeti/Constants.hs: htools/Ganeti/Constants.hs.in \
1175
	lib/constants.py lib/_autoconf.py lib/luxi.py \
1176
	$(CONVERT_CONSTANTS) $(built_base_sources) \
1177
	| lib/_vcsversion.py
1178
	set -e; \
1179
	{ cat $< ; PYTHONPATH=. $(CONVERT_CONSTANTS); } > $@
1180

    
1181
htest/Test/Ganeti/TestImports.hs: htest/Test/Ganeti/TestImports.hs.in \
1182
	$(built_base_sources)
1183
	set -e; \
1184
	{ cat $< ; \
1185
	  echo ; \
1186
	  for name in $(filter-out Ganeti.THH,$(subst /,.,$(patsubst %.hs,%,$(patsubst htools/%,%,$(HS_LIB_SRCS))))) ; do \
1187
	    echo "import $$name ()" ; \
1188
	  done ; \
1189
	} > $@
1190

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

    
1261
lib/_vcsversion.py: Makefile vcs-version | stamp-directories
1262
	set -e; \
1263
	VCSVER=`cat $(abs_top_srcdir)/vcs-version`; \
1264
	{ echo '# This file is automatically generated, do not edit!'; \
1265
	  echo '#'; \
1266
	  echo ''; \
1267
	  echo '"""Build-time VCS version number for Ganeti.'; \
1268
	  echo '';\
1269
	  echo 'This file is autogenerated by the build process.'; \
1270
	  echo 'For any changes you need to re-run ./configure (and'; \
1271
	  echo 'not edit by hand).'; \
1272
	  echo ''; \
1273
	  echo '"""'; \
1274
	  echo ''; \
1275
	  echo '# pylint: disable=C0301,C0324'; \
1276
	  echo '# because this is autogenerated, we do not want'; \
1277
	  echo '# style warnings' ; \
1278
	  echo ''; \
1279
	  echo "VCS_VERSION = '$$VCSVER'"; \
1280
	} > $@
1281

    
1282
lib/_generated_rpc.py: lib/rpc_defs.py $(BUILD_RPC)
1283
	PYTHONPATH=. $(RUN_IN_TEMPDIR) $(CURDIR)/$(BUILD_RPC) lib/rpc_defs.py > $@
1284

    
1285
$(SHELL_ENV_INIT): Makefile stamp-directories
1286
	set -e; \
1287
	{ echo '# Allow overriding for tests'; \
1288
	  echo 'readonly LOCALSTATEDIR=$${LOCALSTATEDIR:-$${GANETI_ROOTDIR:-}$(localstatedir)}'; \
1289
	  echo 'readonly SYSCONFDIR=$${SYSCONFDIR:-$${GANETI_ROOTDIR:-}$(sysconfdir)}'; \
1290
	  echo; \
1291
	  echo 'readonly PKGLIBDIR=$(pkglibdir)'; \
1292
	  echo 'readonly LOG_DIR="$$LOCALSTATEDIR/log/ganeti"'; \
1293
	  echo 'readonly RUN_DIR="$$LOCALSTATEDIR/run/ganeti"'; \
1294
	  echo 'readonly DATA_DIR="$$LOCALSTATEDIR/lib/ganeti"'; \
1295
	  echo 'readonly CONF_DIR="$$SYSCONFDIR/ganeti"'; \
1296
	} > $@
1297

    
1298
$(REPLACE_VARS_SED): $(SHELL_ENV_INIT) Makefile stamp-directories
1299
	set -e; \
1300
	{ echo 's#@PREFIX@#$(prefix)#g'; \
1301
	  echo 's#@SYSCONFDIR@#$(sysconfdir)#g'; \
1302
	  echo 's#@LOCALSTATEDIR@#$(localstatedir)#g'; \
1303
	  echo 's#@BINDIR@#$(bindir)#g'; \
1304
	  echo 's#@SBINDIR@#$(sbindir)#g'; \
1305
	  echo 's#@LIBDIR@#$(libdir)#g'; \
1306
	  echo 's#@GANETI_VERSION@#$(PACKAGE_VERSION)#g'; \
1307
	  echo 's#@CUSTOM_XEN_BOOTLOADER@#$(XEN_BOOTLOADER)#g'; \
1308
	  echo 's#@CUSTOM_XEN_KERNEL@#$(XEN_KERNEL)#g'; \
1309
	  echo 's#@CUSTOM_XEN_INITRD@#$(XEN_INITRD)#g'; \
1310
	  echo 's#@CUSTOM_IALLOCATOR_SEARCH_PATH@#$(IALLOCATOR_SEARCH_PATH)#g'; \
1311
	  echo 's#@CUSTOM_EXPORT_DIR@#$(EXPORT_DIR)#g'; \
1312
	  echo 's#@RPL_FILE_STORAGE_DIR@#$(FILE_STORAGE_DIR)#g'; \
1313
	  echo 's#@RPL_SSH_INITD_SCRIPT@#$(SSH_INITD_SCRIPT)#g'; \
1314
	  echo 's#@PKGLIBDIR@#$(pkglibdir)#g'; \
1315
	  echo 's#@GNTMASTERUSER@#$(MASTERD_USER)#g'; \
1316
	  echo 's#@GNTRAPIUSER@#$(RAPI_USER)#g'; \
1317
	  echo 's#@GNTCONFDUSER@#$(CONFD_USER)#g'; \
1318
	  echo 's#@GNTNODEDUSER@#$(NODED_USER)#g'; \
1319
	  echo 's#@GNTRAPIGROUP@#$(RAPI_GROUP)#g'; \
1320
	  echo 's#@GNTADMINGROUP@#$(ADMIN_GROUP)#g'; \
1321
	  echo 's#@GNTCONFDGROUP@#$(CONFD_GROUP)#g'; \
1322
	  echo 's#@GNTMASTERDGROUP@#$(MASTERD_GROUP)#g'; \
1323
	  echo 's#@GNTDAEMONSGROUP@#$(DAEMONS_GROUP)#g'; \
1324
	  echo 's#@CUSTOM_ENABLE_CONFD@#$(ENABLE_CONFD)#g'; \
1325
	  echo 's#@MODULES@#$(strip $(lint_python_code))#g'; \
1326
	  echo 's#@ENABLE_SPLIT_QUERY@#$(ENABLE_SPLIT_QUERY)#g'; \
1327
	  echo; \
1328
	  echo '/^@SHELL_ENV_INIT@$$/ {'; \
1329
	  echo '  r $(SHELL_ENV_INIT)'; \
1330
	  echo '  d'; \
1331
	  echo '}'; \
1332
	} > $@
1333

    
1334
# Using deferred evaluation
1335
daemons/ganeti-%: MODULE = ganeti.server.$(patsubst ganeti-%,%,$(notdir $@))
1336
daemons/ganeti-watcher: MODULE = ganeti.watcher
1337
scripts/%: MODULE = ganeti.client.$(subst -,_,$(notdir $@))
1338
tools/ensure-dirs: MODULE = ganeti.tools.ensure_dirs
1339
tools/prepare-node-join: MODULE = ganeti.tools.prepare_node_join
1340
$(HS_BUILT_TEST_HELPERS): TESTROLE = $(patsubst htest/%,%,$@)
1341

    
1342
$(PYTHON_BOOTSTRAP): Makefile | stamp-directories
1343
	test -n "$(MODULE)" || { echo Missing module; exit 1; }
1344
	set -e; \
1345
	{ echo '#!/usr/bin/python'; \
1346
	  echo '# This file is automatically generated, do not edit!'; \
1347
	  echo "# Edit $(MODULE) instead."; \
1348
	  echo; \
1349
	  echo '"""Bootstrap script for L{$(MODULE)}"""'; \
1350
	  echo; \
1351
	  echo '# pylint: disable=C0103'; \
1352
	  echo '# C0103: Invalid name'; \
1353
	  echo; \
1354
	  echo 'import sys'; \
1355
	  echo 'import $(MODULE) as main'; \
1356
	  echo; \
1357
	  echo '# Temporarily alias commands until bash completion'; \
1358
	  echo '# generator is changed'; \
1359
	  echo 'if hasattr(main, "commands"):'; \
1360
	  echo '  commands = main.commands # pylint: disable=E1101'; \
1361
	  echo 'if hasattr(main, "aliases"):'; \
1362
	  echo '  aliases = main.aliases # pylint: disable=E1101'; \
1363
	  echo; \
1364
	  echo 'if __name__ == "__main__":'; \
1365
	  echo '  sys.exit(main.Main())'; \
1366
	} > $@
1367
	chmod u+x $@
1368

    
1369
$(HS_BUILT_TEST_HELPERS): Makefile
1370
	@test -n "$(TESTROLE)" || { echo Missing TESTROLE; exit 1; }
1371
	set -e; \
1372
	{ echo '#!/bin/sh'; \
1373
	  echo '# This file is automatically generated, do not edit!'; \
1374
	  echo "# Edit Makefile.am instead."; \
1375
	  echo; \
1376
	  echo "HTOOLS=$(TESTROLE) exec ./htest/hpc-htools \"\$$@\""; \
1377
	} > $@
1378
	chmod u+x $@
1379

    
1380
stamp-directories: Makefile
1381
	$(MAKE) $(AM_MAKEFLAGS) ganeti
1382
	@mkdir_p@ $(DIRS) $(BUILDTIME_DIR_AUTOCREATE)
1383
	touch $@
1384

    
1385
# We need to create symlinks because "make distcheck" will not install Python
1386
# files when building.
1387
stamp-srclinks: Makefile | stamp-directories
1388
	set -e; \
1389
	for i in $(srclink_files); do \
1390
		if test ! -f $$i -a -f $(abs_top_srcdir)/$$i; then \
1391
			$(LN_S) $(abs_top_srcdir)/$$i $$i; \
1392
		fi; \
1393
	done
1394
	touch $@
1395

    
1396
.PHONY: ganeti
1397
ganeti:
1398
	cd $(top_builddir) && test -h "$@" || { rm -f $@ && $(LN_S) lib $@; }
1399

    
1400
.PHONY: check-dirs
1401
check-dirs: $(GENERATED_FILES)
1402
	@set -e; \
1403
	find . -type d \( \( -name . \) -o \( \
1404
		-name .git -o \
1405
		-name autom4te.cache \
1406
		\) -prune -o -print \) | { \
1407
		error=; \
1408
		while read dir; do \
1409
			case "$$dir" in \
1410
				$(strip $(patsubst %,(./%) ;;,$(DIRCHECK_EXCLUDE) $(DIRS))) \
1411
				*) error=1; echo "Directory $$dir not listed in Makefile" >&2 ;; \
1412
			esac; \
1413
		done; \
1414
		for dir in $(DIRS); do \
1415
			if ! test -d "$$dir"; then \
1416
				echo "Directory $$dir listed in DIRS does not exist" >&2; \
1417
				error=1; \
1418
			fi \
1419
		done; \
1420
		if test -n "$$error"; then exit 1; else exit 0; fi; \
1421
	}
1422

    
1423
.PHONY: check-local
1424
check-local: check-dirs $(GENERATED_FILES)
1425
	$(CHECK_PYTHON_CODE) $(check_python_code)
1426
	PYTHONPATH=. $(CHECK_HEADER) $(check_python_code)
1427
	$(CHECK_VERSION) $(VERSION) $(top_srcdir)/NEWS
1428
	$(CHECK_NEWS) < $(top_srcdir)/NEWS
1429
	PYTHONPATH=. $(RUN_IN_TEMPDIR) $(CURDIR)/$(CHECK_IMPORTS) . $(standalone_python_modules)
1430
	@expver=$(VERSION_MAJOR).$(VERSION_MINOR); \
1431
	if test "`head -n 1 $(top_srcdir)/README`" != "Ganeti $$expver"; then \
1432
		echo "Incorrect version in README, expected $$expver"; \
1433
		exit 1; \
1434
	fi; \
1435
	for file in doc/iallocator.rst doc/hooks.rst doc/virtual-cluster.rst \
1436
			doc/security.rst; do \
1437
		if test "`sed -ne '4 p' $(top_srcdir)/$$file`" != \
1438
			"Documents Ganeti version $$expver"; then \
1439
			echo "Incorrect version in $$file, expected $$expver"; \
1440
			exit 1; \
1441
		fi; \
1442
	done; \
1443
	if ! test -f $(top_srcdir)/doc/design-$$expver.rst; then \
1444
		echo "File $(top_srcdir)/doc/design-$$expver.rst not found"; \
1445
		exit 1; \
1446
	fi
1447

    
1448
.PHONY: hs-check
1449
hs-check: htest/test htest/hpc-htools $(HS_BUILT_TEST_HELPERS)
1450
	@rm -f test.tix
1451
	./htest/test
1452
	HBINARY="./htest/hpc-htools" ./htest/offline-test.sh
1453

    
1454
# E111: indentation is not a multiple of four
1455
# E121: continuation line indentation is not a multiple of four
1456
#       (since our indent level is not 4)
1457
# E125: continuation line does not distinguish itself from next logical line
1458
#       (since our indent level is not 4)
1459
# E127: continuation line over-indented for visual indent
1460
#       (since our indent level is not 4)
1461
# note: do NOT add E128 here; it's a valid style error in most cases!
1462
# I've seen real errors, but also some cases were we indent wrongly
1463
# due to line length; try to rework the cases where it is triggered,
1464
# instead of silencing it
1465
# E261: at least two spaces before inline comment
1466
# E501: line too long (80 characters)
1467
PEP8_IGNORE = E111,E121,E125,E127,E261,E501
1468

    
1469
# For excluding pep8 expects filenames only, not whole paths
1470
PEP8_EXCLUDE = $(subst $(space),$(comma),$(strip $(notdir $(BUILT_PYTHON_SOURCES))))
1471

    
1472
LINT_TARGETS = pylint pylint-qa
1473
if HAS_PEP8
1474
LINT_TARGETS += pep8
1475
endif
1476
if HAS_HLINT
1477
LINT_TARGETS += hlint
1478
endif
1479

    
1480
.PHONY: lint
1481
lint: $(LINT_TARGETS)
1482

    
1483
.PHONY: pylint
1484
pylint: $(GENERATED_FILES)
1485
	@test -n "$(PYLINT)" || { echo 'pylint' not found during configure; exit 1; }
1486
	$(PYLINT) $(LINT_OPTS) $(lint_python_code)
1487

    
1488
.PHONY: pylint-qa
1489
pylint-qa: $(GENERATED_FILES)
1490
	@test -n "$(PYLINT)" || { echo 'pylint' not found during configure; exit 1; }
1491
	cd $(top_srcdir)/qa && \
1492
	  PYTHONPATH=$(abs_top_srcdir) $(PYLINT) $(LINT_OPTS) \
1493
	  --rcfile  ../pylintrc $(patsubst qa/%.py,%,$(qa_scripts))
1494

    
1495
.PHONY: pep8
1496
pep8: $(GENERATED_FILES)
1497
	@test -n "$(PEP8)" || { echo 'pep8' not found during configure; exit 1; }
1498
	$(PEP8) --ignore='$(PEP8_IGNORE)' --exclude='$(PEP8_EXCLUDE)' \
1499
		--repeat $(pep8_python_code)
1500

    
1501
# FIXME: remove ignore "Use void" when GHC 6.x is deprecated
1502
.PHONY: hlint
1503
hlint: $(HS_BUILT_SRCS) htools/lint-hints.hs
1504
	@test -n "$(HLINT)" || { echo 'hlint' not found during configure; exit 1; }
1505
	if tty -s; then C="-c"; else C=""; fi; \
1506
	$(HLINT) --report=doc/hs-lint.html --cross $$C \
1507
	  --ignore "Use first" \
1508
	  --ignore "Use comparing" \
1509
	  --ignore "Use on" \
1510
	  --ignore "Reduce duplication" \
1511
	  --ignore "Use &&&" \
1512
	  --ignore "Use void" \
1513
	  --hint htools/lint-hints \
1514
	  $(filter-out htools/Ganeti/THH.hs,$(HS_LIBTEST_SRCS) $(HS_PROG_SRCS))
1515

    
1516
# a dist hook rule for updating the vcs-version file; this is
1517
# hardcoded due to where it needs to build the file...
1518
dist-hook:
1519
	$(MAKE) $(AM_MAKEFLAGS) regen-vcs-version
1520
	rm -f $(top_distdir)/vcs-version
1521
	cp -p $(srcdir)/vcs-version $(top_distdir)
1522

    
1523
# a distcheck hook rule for catching revision control directories
1524
distcheck-hook:
1525
	if find $(top_distdir) -name .svn -or -name .git | grep .; then \
1526
		echo "Found revision control files in final archive." 1>&2; \
1527
		exit 1; \
1528
	fi
1529
	if find $(top_distdir) -name '*.py[co]' | grep .; then \
1530
		echo "Found Python byte code in final archive." 1>&2; \
1531
		exit 1; \
1532
	fi
1533
	if find $(top_distdir) -name '*~' | grep .; then \
1534
		echo "Found backup files in final archive." 1>&2; \
1535
		exit 1; \
1536
	fi
1537
# Empty files or directories should not be distributed. They can cause
1538
# unnecessary warnings for packagers. Directories used by automake during
1539
# distcheck must be excluded.
1540
	if find $(top_distdir) -empty -and -not \( \
1541
			-path $(top_distdir)/_build -or \
1542
			-path $(top_distdir)/_inst \) | grep .; then \
1543
		echo "Found empty files or directories in final archive." 1>&2; \
1544
		exit 1; \
1545
	fi
1546
	if test -n "$(BUILD_RELEASE)" && \
1547
	   grep -n -H -E '^\*.*unreleased' $(top_distdir)/NEWS; then \
1548
		echo "Found unreleased version in NEWS." >&2; \
1549
		exit 1; \
1550
	fi
1551

    
1552
# When building a release, stricter checks should be used
1553
distcheck-release dist-release: export BUILD_RELEASE = 1
1554
distcheck-release: distcheck
1555

    
1556
distrebuildcheck: dist
1557
	set -e; \
1558
	builddir=$$(mktemp -d $(abs_srcdir)/distrebuildcheck.XXXXXXX); \
1559
	trap "echo Removing $$builddir; cd $(abs_srcdir); rm -rf $$builddir" EXIT; \
1560
	cd $$builddir; \
1561
	tar xzf $(abs_srcdir)/$(distdir).tar.gz; \
1562
	cd $(distdir); \
1563
	./configure; \
1564
	$(MAKE) maintainer-clean; \
1565
	cp $(abs_srcdir)/vcs-version .; \
1566
	./configure; \
1567
	$(MAKE) $(AM_MAKEFLAGS)
1568

    
1569
dist-release: dist
1570
	set -e; \
1571
	for i in $(DIST_ARCHIVES); do \
1572
		echo -n "Checking $$i ... "; \
1573
		autotools/check-tar < $$i; \
1574
		echo OK; \
1575
	done
1576

    
1577
install-exec-local:
1578
	@mkdir_p@ "$(DESTDIR)${localstatedir}/lib/ganeti" \
1579
	  "$(DESTDIR)${localstatedir}/log/ganeti" \
1580
	  "$(DESTDIR)${localstatedir}/run/ganeti"
1581

    
1582
.PHONY: apidoc
1583
if WANT_HTOOLSAPIDOC
1584
apidoc: py-apidoc hs-apidoc
1585
else
1586
apidoc: py-apidoc
1587
endif
1588

    
1589
.PHONY: py-apidoc
1590
py-apidoc: epydoc.conf $(RUN_IN_TEMPDIR) $(GENERATED_FILES)
1591
	$(RUN_IN_TEMPDIR) epydoc -v \
1592
		--conf $(CURDIR)/epydoc.conf \
1593
		--output $(CURDIR)/$(APIDOC_PY_DIR)
1594

    
1595
.PHONY: hs-apidoc
1596
hs-apidoc: $(HS_BUILT_SRCS)
1597
	@test -n "$(HSCOLOUR)" || \
1598
	    { echo 'HsColour' not found during configure; exit 1; }
1599
	@test -n "$(HADDOCK)" || \
1600
	    { echo 'haddock' not found during configure; exit 1; }
1601
	rm -rf $(APIDOC_HS_DIR)/*
1602
	@mkdir_p@ $(APIDOC_HS_DIR)/Ganeti/HTools/Program
1603
	@mkdir_p@ $(APIDOC_HS_DIR)/Ganeti/Confd
1604
	@mkdir_p@ $(APIDOC_HS_DIR)/Ganeti/Query
1605
	$(HSCOLOUR) -print-css > $(APIDOC_HS_DIR)/Ganeti/hscolour.css
1606
	$(LN_S) ../hscolour.css $(APIDOC_HS_DIR)/Ganeti/HTools/hscolour.css
1607
	$(LN_S) ../hscolour.css $(APIDOC_HS_DIR)/Ganeti/Confd/hscolour.css
1608
	set -e ; \
1609
	cd htools; \
1610
	if [ "$(HTOOLS_NOCURL)" ]; \
1611
	then OPTGHC="--optghc=$(HTOOLS_NOCURL)"; \
1612
	else OPTGHC=""; \
1613
	fi; \
1614
	if [ "$(HTOOLS_PARALLEL3)" ]; \
1615
	then OPTGHC="$$OPTGHC --optghc=$(HTOOLS_PARALLEL3)"; \
1616
	fi; \
1617
	if [ "$(HTOOLS_REGEX_PCRE)" ]; \
1618
	then OPTGHC="$$OPTGHC --optghc=$(HTOOLS_REGEX_PCRE)"; \
1619
	fi; \
1620
	RELSRCS="$(HS_LIB_SRCS:htools/%=%) $(patsubst htools/%,%,$(filter htools/%,$(HS_BUILT_SRCS)))"; \
1621
	for file in $$RELSRCS; do \
1622
		hfile=`echo $$file|sed 's/\\.hs$$//'`.html; \
1623
		$(HSCOLOUR) -css -anchor $$file > ../$(APIDOC_HS_DIR)/$$hfile ; \
1624
	done ; \
1625
	$(HADDOCK) --odir ../$(APIDOC_HS_DIR) --html --ignore-all-exports -w \
1626
		-t ganeti -p haddock-prologue \
1627
		--source-module="%{MODULE/.//}.html" \
1628
		--source-entity="%{MODULE/.//}.html#%{NAME}" \
1629
		$$OPTGHC \
1630
		$(filter-out Ganeti/HTools/ExtLoader.hs,$(HS_LIB_SRCS:htools/%=%))
1631

    
1632
.PHONY: TAGS
1633
TAGS: $(GENERATED_FILES)
1634
	rm -f TAGS
1635
	$(GHC) -e ":etags" -v0 \
1636
	  $(filter-out -O -Werror,$(HFLAGS)) \
1637
	  $(HTOOLS_NOCURL) $(HTOOLS_PARALLEL3) $(HTOOLS_REGEX_PCRE) \
1638
	  $(HS_LIBTEST_SRCS)
1639
	find . -path './lib/*.py' -o -path './scripts/gnt-*' -o \
1640
	  -path './daemons/ganeti-*' -o -path './tools/*' -o \
1641
	  -path './qa/*.py' | \
1642
	  etags -l python -a -
1643

    
1644
.PHONY: coverage
1645
if WANT_HTOOLS
1646
coverage: py-coverage hs-coverage
1647
else
1648
coverage: py-coverage
1649
endif
1650

    
1651
.PHONY: py-coverage
1652
py-coverage: $(GENERATED_FILES) $(python_tests)
1653
	@test -n "$(PYCOVERAGE)" || \
1654
	    { echo 'python-coverage' not found during configure; exit 1; }
1655
	set -e; \
1656
	COVERAGE=$(PYCOVERAGE) \
1657
	COVERAGE_FILE=$(CURDIR)/$(COVERAGE_PY_DIR)/data \
1658
	TEXT_COVERAGE=$(CURDIR)/$(COVERAGE_PY_DIR)/report.txt \
1659
	HTML_COVERAGE=$(CURDIR)/$(COVERAGE_PY_DIR) \
1660
	$(PLAIN_TESTS_ENVIRONMENT) $(abs_top_srcdir)/autotools/gen-coverage \
1661
	$(python_tests)
1662

    
1663
.PHONY: hs-coverage
1664
hs-coverage: $(haskell_tests) htest/hpc-htools
1665
	rm -f *.tix
1666
	$(MAKE) $(AM_MAKEFLAGS) hs-check
1667
	@mkdir_p@ $(COVERAGE_HS_DIR)
1668
	hpc combine --union $(HPCEXCL) \
1669
	  test.tix hpc-htools.tix > coverage-htools.tix
1670
	hpc markup --destdir=$(COVERAGE_HS_DIR) coverage-htools.tix
1671
	hpc report coverage-htools.tix
1672
	$(LN_S) -f hpc_index.html $(COVERAGE_HS_DIR)/index.html
1673

    
1674
# Special "kind-of-QA" target for htools, needs special setup (all
1675
# tools compiled with -fhpc)
1676
.PHONY: live-test
1677
live-test: all
1678
	set -e ; \
1679
	cd htools; \
1680
	rm -f .hpc; $(LN_S) ../.hpc .hpc; \
1681
	rm -f *.tix *.mix; \
1682
	./live-test.sh; \
1683
	hpc sum --union $(HPCEXCL) $(addsuffix .tix,$(HS_PROGS:htools/%=%)) \
1684
	  --output=live-test.tix ; \
1685
	@mkdir_p@ ../$(COVERAGE_HS_DIR) ; \
1686
	hpc markup --destdir=../$(COVERAGE_HS_DIR) live-test \
1687
		--srcdir=.. $(HPCEXCL) ; \
1688
	hpc report --srcdir=.. live-test $(HPCEXCL)
1689

    
1690
commit-check: distcheck lint apidoc
1691

    
1692
.PHONY: gitignore-check
1693
gitignore-check:
1694
	@if [ -n "`git status --short`" ]; then \
1695
	  echo "Git status is not clean!" 1>&2 ; \
1696
	  git status --short; \
1697
	  exit 1; \
1698
	fi
1699

    
1700
# Target that builds all binaries (including those that are not
1701
# rebuilt except when running the tests)
1702
.PHONY: really-all
1703
really-all: all $(check_SCRIPTS) $(haskell_tests)
1704

    
1705
# we don't need the ancient implicit rules:
1706
%: %,v
1707
%: RCS/%,v
1708
%: RCS/%
1709
%: s.%
1710
%: SCCS/s.%
1711

    
1712
-include ./Makefile.local
1713

    
1714
# vim: set noet :