Statistics
| Branch: | Tag: | Revision:

root / Makefile.am @ 911dfc49

History | View | Annotate | Download (50 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/Block \
61
	htools/Ganeti/Block/Drbd \
62
	htools/Ganeti/Confd \
63
	htools/Ganeti/HTools \
64
	htools/Ganeti/HTools/Backend \
65
	htools/Ganeti/HTools/Program \
66
	htools/Ganeti/Query \
67
	htest \
68
	htest/Test \
69
	htest/Test/Ganeti \
70
	htest/Test/Ganeti/Block \
71
	htest/Test/Ganeti/Block/Drbd \
72
	htest/Test/Ganeti/Confd \
73
	htest/Test/Ganeti/HTools \
74
	htest/Test/Ganeti/HTools/Backend \
75
	htest/Test/Ganeti/Query
76

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

    
110
BUILDTIME_DIR_AUTOCREATE = \
111
	scripts \
112
	$(APIDOC_DIR) \
113
	$(APIDOC_HS_DIR) \
114
	$(APIDOC_HS_DIR)/Ganeti \
115
	$(APIDOC_HS_DIR)/Ganeti/Block \
116
	$(APIDOC_HS_DIR)/Ganeti/Block/Drbd \
117
	$(APIDOC_HS_DIR)/Ganeti/Confd \
118
	$(APIDOC_HS_DIR)/Ganeti/HTools \
119
	$(APIDOC_HS_DIR)/Ganeti/HTools/Backend \
120
	$(APIDOC_HS_DIR)/Ganeti/HTools/Program \
121
	$(APIDOC_HS_DIR)/Ganeti/Query \
122
	$(APIDOC_PY_DIR) \
123
	$(COVERAGE_DIR) \
124
	$(COVERAGE_HS_DIR) \
125
	$(COVERAGE_PY_DIR) \
126
	.hpc
127

    
128
BUILDTIME_DIRS = \
129
	$(BUILDTIME_DIR_AUTOCREATE) \
130
	doc/html
131

    
132
DIRCHECK_EXCLUDE = \
133
	$(BUILDTIME_DIRS) \
134
	ganeti-[0-9]*.[0-9]*.[0-9]* \
135
	doc/html/_*
136

    
137
# some helper vars
138
COVERAGE_DIR = doc/coverage
139
COVERAGE_PY_DIR = $(COVERAGE_DIR)/py
140
COVERAGE_HS_DIR = $(COVERAGE_DIR)/hs
141
APIDOC_DIR = doc/api
142
APIDOC_PY_DIR = $(APIDOC_DIR)/py
143
APIDOC_HS_DIR = $(APIDOC_DIR)/hs
144

    
145
MAINTAINERCLEANFILES = \
146
	$(docpng) \
147
	$(maninput) \
148
	doc/install-quick.rst \
149
	doc/news.rst \
150
	doc/upgrade.rst \
151
	vcs-version
152

    
153
maintainer-clean-local:
154
	rm -rf $(BUILDTIME_DIRS)
155

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

    
183
GENERATED_FILES = \
184
	$(built_base_sources) \
185
	$(BUILT_PYTHON_SOURCES) \
186
	$(PYTHON_BOOTSTRAP)
187

    
188
HTOOLS_GENERATED_FILES =
189
if WANT_HTOOLS
190
HTOOLS_GENERATED_FILES += $(HS_PROGS)
191
if ENABLE_CONFD
192
HTOOLS_GENERATED_FILES += htools/hconfd htools/ganeti-confd
193
endif
194
endif
195

    
196
built_base_sources = \
197
	stamp-directories \
198
	stamp-srclinks
199

    
200
built_python_base_sources = \
201
	lib/_autoconf.py \
202
	lib/_vcsversion.py
203

    
204
BUILT_PYTHON_SOURCES = \
205
	$(built_python_base_sources) \
206
	lib/_generated_rpc.py
207

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

    
212
# these are all built from the underlying %.in sources
213
BUILT_EXAMPLES = \
214
	doc/examples/ganeti-kvm-poweroff.initd \
215
	doc/examples/ganeti.cron \
216
	doc/examples/ganeti.initd \
217
	doc/examples/ganeti-master-role.ocf \
218
	doc/examples/ganeti-node-role.ocf \
219
	doc/examples/gnt-config-backup \
220
	doc/examples/hooks/ipsec
221

    
222
nodist_pkgpython_PYTHON = \
223
	$(BUILT_PYTHON_SOURCES)
224

    
225
noinst_PYTHON = \
226
	lib/build/__init__.py \
227
	lib/build/shell_example_lexer.py \
228
	lib/build/sphinx_ext.py
229

    
230
pkgpython_PYTHON = \
231
	lib/__init__.py \
232
	lib/asyncnotifier.py \
233
	lib/backend.py \
234
	lib/bdev.py \
235
	lib/bootstrap.py \
236
	lib/cli.py \
237
	lib/cmdlib.py \
238
	lib/compat.py \
239
	lib/config.py \
240
	lib/constants.py \
241
	lib/daemon.py \
242
	lib/errors.py \
243
	lib/ht.py \
244
	lib/jqueue.py \
245
	lib/jstore.py \
246
	lib/locking.py \
247
	lib/luxi.py \
248
	lib/mcpu.py \
249
	lib/netutils.py \
250
	lib/objects.py \
251
	lib/objectutils.py \
252
	lib/opcodes.py \
253
	lib/ovf.py \
254
	lib/pathutils.py \
255
	lib/qlang.py \
256
	lib/query.py \
257
	lib/rpc.py \
258
	lib/rpc_defs.py \
259
	lib/runtime.py \
260
	lib/serializer.py \
261
	lib/ssconf.py \
262
	lib/ssh.py \
263
	lib/storage.py \
264
	lib/uidpool.py \
265
	lib/vcluster.py \
266
	lib/network.py \
267
	lib/workerpool.py
268

    
269
client_PYTHON = \
270
	lib/client/__init__.py \
271
	lib/client/gnt_backup.py \
272
	lib/client/gnt_cluster.py \
273
	lib/client/gnt_debug.py \
274
	lib/client/gnt_group.py \
275
	lib/client/gnt_instance.py \
276
	lib/client/gnt_job.py \
277
	lib/client/gnt_node.py \
278
	lib/client/gnt_network.py \
279
	lib/client/gnt_os.py
280

    
281
hypervisor_PYTHON = \
282
	lib/hypervisor/__init__.py \
283
	lib/hypervisor/hv_base.py \
284
	lib/hypervisor/hv_chroot.py \
285
	lib/hypervisor/hv_fake.py \
286
	lib/hypervisor/hv_kvm.py \
287
	lib/hypervisor/hv_lxc.py \
288
	lib/hypervisor/hv_xen.py
289

    
290
rapi_PYTHON = \
291
	lib/rapi/__init__.py \
292
	lib/rapi/baserlib.py \
293
	lib/rapi/client.py \
294
	lib/rapi/client_utils.py \
295
	lib/rapi/connector.py \
296
	lib/rapi/rlib2.py \
297
	lib/rapi/testutils.py
298

    
299
http_PYTHON = \
300
	lib/http/__init__.py \
301
	lib/http/auth.py \
302
	lib/http/client.py \
303
	lib/http/server.py
304

    
305
confd_PYTHON = \
306
	lib/confd/__init__.py \
307
	lib/confd/client.py
308

    
309
masterd_PYTHON = \
310
	lib/masterd/__init__.py \
311
	lib/masterd/iallocator.py \
312
	lib/masterd/instance.py
313

    
314
impexpd_PYTHON = \
315
	lib/impexpd/__init__.py
316

    
317
watcher_PYTHON = \
318
	lib/watcher/__init__.py \
319
	lib/watcher/nodemaint.py \
320
	lib/watcher/state.py
321

    
322
server_PYTHON = \
323
	lib/server/__init__.py \
324
	lib/server/masterd.py \
325
	lib/server/noded.py \
326
	lib/server/rapi.py
327

    
328
pytools_PYTHON = \
329
	lib/tools/__init__.py \
330
	lib/tools/ensure_dirs.py \
331
	lib/tools/prepare_node_join.py
332

    
333
utils_PYTHON = \
334
	lib/utils/__init__.py \
335
	lib/utils/algo.py \
336
	lib/utils/filelock.py \
337
	lib/utils/hash.py \
338
	lib/utils/io.py \
339
	lib/utils/log.py \
340
	lib/utils/mlock.py \
341
	lib/utils/nodesetup.py \
342
	lib/utils/process.py \
343
	lib/utils/retry.py \
344
	lib/utils/text.py \
345
	lib/utils/wrapper.py \
346
	lib/utils/x509.py
347

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

    
400
HS_PROGS = htools/htools
401
HS_BIN_ROLES = hbal hscan hspace hinfo hcheck
402
HS_HTOOLS_PROGS = $(HS_BIN_ROLES) hail
403

    
404
HS_ALL_PROGS = \
405
	$(HS_PROGS) \
406
	htest/hpc-htools \
407
	htest/test \
408
	htools/hconfd \
409
	htools/rpc-test
410

    
411
HS_PROG_SRCS = $(patsubst %,%.hs,$(HS_ALL_PROGS))
412
HS_BUILT_TEST_HELPERS = $(HS_BIN_ROLES:%=htest/%) htest/hail
413

    
414
HFLAGS = \
415
	-O -Wall -Werror -ihtools \
416
	-fwarn-monomorphism-restriction \
417
	-fwarn-tabs \
418
	$(GHC_BYVERSION_FLAGS)
419

    
420
# extra flags that can be overriden on the command line (e.g. -Wwarn, etc.)
421
HEXTRA =
422
# internal extra flags (used for htest/test mainly)
423
HEXTRA_INT =
424
# exclude options for coverage reports
425
HPCEXCL = --exclude Main \
426
	--exclude Ganeti.Constants \
427
	--exclude Ganeti.HTools.QC \
428
	--exclude Ganeti.THH \
429
	--exclude Ganeti.Version \
430
	--exclude Test.Ganeti.TestCommon \
431
	--exclude Test.Ganeti.TestHTools \
432
	--exclude Test.Ganeti.TestHelper \
433
	--exclude Test.Ganeti.TestImports \
434
	$(patsubst htools.%,--exclude Test.%,$(subst /,.,$(patsubst %.hs,%, $(HS_LIB_SRCS))))
435

    
436
HS_LIB_SRCS = \
437
	htools/Ganeti/Block/Drbd/Types.hs \
438
	htools/Ganeti/Block/Drbd/Parser.hs \
439
	htools/Ganeti/BasicTypes.hs \
440
	htools/Ganeti/Common.hs \
441
	htools/Ganeti/Compat.hs \
442
	htools/Ganeti/Confd/Server.hs \
443
	htools/Ganeti/Confd/Types.hs \
444
	htools/Ganeti/Confd/Utils.hs \
445
	htools/Ganeti/Config.hs \
446
	htools/Ganeti/Daemon.hs \
447
	htools/Ganeti/Errors.hs \
448
	htools/Ganeti/HTools/Backend/IAlloc.hs \
449
	htools/Ganeti/HTools/Backend/Luxi.hs \
450
	htools/Ganeti/HTools/Backend/Rapi.hs \
451
	htools/Ganeti/HTools/Backend/Simu.hs \
452
	htools/Ganeti/HTools/Backend/Text.hs \
453
	htools/Ganeti/HTools/CLI.hs \
454
	htools/Ganeti/HTools/Cluster.hs \
455
	htools/Ganeti/HTools/Container.hs \
456
	htools/Ganeti/HTools/ExtLoader.hs \
457
	htools/Ganeti/HTools/Group.hs \
458
	htools/Ganeti/HTools/Instance.hs \
459
	htools/Ganeti/HTools/Loader.hs \
460
	htools/Ganeti/HTools/Node.hs \
461
	htools/Ganeti/HTools/PeerMap.hs \
462
	htools/Ganeti/HTools/Program.hs \
463
	htools/Ganeti/HTools/Program/Hail.hs \
464
	htools/Ganeti/HTools/Program/Hbal.hs \
465
	htools/Ganeti/HTools/Program/Hcheck.hs \
466
	htools/Ganeti/HTools/Program/Hinfo.hs \
467
	htools/Ganeti/HTools/Program/Hscan.hs \
468
	htools/Ganeti/HTools/Program/Hspace.hs \
469
	htools/Ganeti/HTools/Types.hs \
470
	htools/Ganeti/Hash.hs \
471
	htools/Ganeti/JSON.hs \
472
	htools/Ganeti/Jobs.hs \
473
	htools/Ganeti/Logging.hs \
474
	htools/Ganeti/Luxi.hs \
475
	htools/Ganeti/Objects.hs \
476
	htools/Ganeti/OpCodes.hs \
477
	htools/Ganeti/OpParams.hs \
478
	htools/Ganeti/Path.hs \
479
	htools/Ganeti/Query/Common.hs \
480
	htools/Ganeti/Query/Filter.hs \
481
	htools/Ganeti/Query/Group.hs \
482
	htools/Ganeti/Query/Language.hs \
483
	htools/Ganeti/Query/Node.hs \
484
	htools/Ganeti/Query/Query.hs \
485
	htools/Ganeti/Query/Server.hs \
486
	htools/Ganeti/Query/Types.hs \
487
	htools/Ganeti/Rpc.hs \
488
	htools/Ganeti/Runtime.hs \
489
	htools/Ganeti/Ssconf.hs \
490
	htools/Ganeti/THH.hs \
491
	htools/Ganeti/Types.hs \
492
	htools/Ganeti/Utils.hs
493

    
494
HS_TEST_SRCS = \
495
	htest/Test/Ganeti/Attoparsec.hs \
496
	htest/Test/Ganeti/BasicTypes.hs \
497
	htest/Test/Ganeti/Block/Drbd/Parser.hs \
498
	htest/Test/Ganeti/Common.hs \
499
	htest/Test/Ganeti/Confd/Utils.hs \
500
	htest/Test/Ganeti/Daemon.hs \
501
	htest/Test/Ganeti/Errors.hs \
502
	htest/Test/Ganeti/HTools/Backend/Simu.hs \
503
	htest/Test/Ganeti/HTools/Backend/Text.hs \
504
	htest/Test/Ganeti/HTools/CLI.hs \
505
	htest/Test/Ganeti/HTools/Cluster.hs \
506
	htest/Test/Ganeti/HTools/Container.hs \
507
	htest/Test/Ganeti/HTools/Instance.hs \
508
	htest/Test/Ganeti/HTools/Loader.hs \
509
	htest/Test/Ganeti/HTools/Node.hs \
510
	htest/Test/Ganeti/HTools/PeerMap.hs \
511
	htest/Test/Ganeti/HTools/Types.hs \
512
	htest/Test/Ganeti/JSON.hs \
513
	htest/Test/Ganeti/Jobs.hs \
514
	htest/Test/Ganeti/Luxi.hs \
515
	htest/Test/Ganeti/Objects.hs \
516
	htest/Test/Ganeti/OpCodes.hs \
517
	htest/Test/Ganeti/Query/Filter.hs \
518
	htest/Test/Ganeti/Query/Language.hs \
519
	htest/Test/Ganeti/Query/Query.hs \
520
	htest/Test/Ganeti/Rpc.hs \
521
	htest/Test/Ganeti/Ssconf.hs \
522
	htest/Test/Ganeti/THH.hs \
523
	htest/Test/Ganeti/TestCommon.hs \
524
	htest/Test/Ganeti/TestHTools.hs \
525
	htest/Test/Ganeti/TestHelper.hs \
526
	htest/Test/Ganeti/Types.hs \
527
	htest/Test/Ganeti/Utils.hs
528

    
529
HS_LIBTEST_SRCS = $(HS_LIB_SRCS) $(HS_TEST_SRCS)
530

    
531
HS_BUILT_SRCS = \
532
	htest/Test/Ganeti/TestImports.hs \
533
	htools/Ganeti/Constants.hs \
534
	htools/Ganeti/Version.hs
535
HS_BUILT_SRCS_IN = $(patsubst %,%.in,$(HS_BUILT_SRCS))
536

    
537
$(RUN_IN_TEMPDIR): | stamp-directories
538

    
539
# Note: we use here an order-only prerequisite, as the contents of
540
# _autoconf.py are not actually influencing the html build output: it
541
# has to exist in order for the sphinx module to be loaded
542
# successfully, but we certainly don't want the docs to be rebuilt if
543
# it changes
544
doc/html/index.html: $(docrst) $(docpng) doc/conf.py configure.ac \
545
	$(RUN_IN_TEMPDIR) lib/build/sphinx_ext.py \
546
	lib/build/shell_example_lexer.py lib/opcodes.py lib/ht.py \
547
	| $(BUILT_PYTHON_SOURCES)
548
	@test -n "$(SPHINX)" || \
549
	    { echo 'sphinx-build' not found during configure; exit 1; }
550
	@mkdir_p@ $(dir $@)
551
	PYTHONPATH=. $(RUN_IN_TEMPDIR) $(SPHINX) -q -W -b html \
552
	    -d . \
553
	    -D version="$(VERSION_MAJOR).$(VERSION_MINOR)" \
554
	    -D release="$(PACKAGE_VERSION)" \
555
	    $(abs_top_srcdir)/doc $(CURDIR)/doc/html
556
	rm -f doc/html/.buildinfo doc/html/objects.inv
557
	touch $@
558

    
559
doc/html: doc/html/index.html
560

    
561
doc/install-quick.rst: INSTALL
562
doc/news.rst: NEWS
563
doc/upgrade.rst: UPGRADE
564

    
565
doc/install-quick.rst doc/news.rst doc/upgrade.rst:
566
	set -e; \
567
	{ echo '.. This file is automatically updated at build time from $<.'; \
568
	  echo '.. Do not edit.'; \
569
	  echo; \
570
	  cat $<; \
571
	} > $@
572

    
573
docdot = \
574
	doc/arch-2.0.dot \
575
	doc/design-2.1-lock-acquire.dot \
576
	doc/design-2.1-lock-release.dot
577

    
578
docpng = $(patsubst %.dot,%.png,$(docdot))
579

    
580
# Things to build but not to install (add it to EXTRA_DIST if it should be
581
# distributed)
582
noinst_DATA = \
583
	doc/html \
584
	$(BUILT_EXAMPLES) \
585
	doc/examples/bash_completion \
586
	doc/examples/bash_completion-debug \
587
	$(manhtml)
588

    
589
gnt_scripts = \
590
	scripts/gnt-backup \
591
	scripts/gnt-cluster \
592
	scripts/gnt-debug \
593
	scripts/gnt-group \
594
	scripts/gnt-instance \
595
	scripts/gnt-job \
596
	scripts/gnt-network \
597
	scripts/gnt-node \
598
	scripts/gnt-os
599

    
600
PYTHON_BOOTSTRAP_SBIN = \
601
	daemons/ganeti-masterd \
602
	daemons/ganeti-noded \
603
	daemons/ganeti-rapi \
604
	daemons/ganeti-watcher \
605
	$(gnt_scripts)
606

    
607
PYTHON_BOOTSTRAP = \
608
	$(PYTHON_BOOTSTRAP_SBIN) \
609
	tools/ensure-dirs \
610
	tools/prepare-node-join
611

    
612
qa_scripts = \
613
	qa/__init__.py \
614
	qa/ganeti-qa.py \
615
	qa/qa_cluster.py \
616
	qa/qa_config.py \
617
	qa/qa_daemon.py \
618
	qa/qa_env.py \
619
	qa/qa_error.py \
620
	qa/qa_group.py \
621
	qa/qa_instance.py \
622
	qa/qa_job.py \
623
	qa/qa_node.py \
624
	qa/qa_os.py \
625
	qa/qa_rapi.py \
626
	qa/qa_tags.py \
627
	qa/qa_utils.py
628

    
629
bin_SCRIPTS =
630
if WANT_HTOOLS
631
bin_SCRIPTS += $(filter-out htools/hail,$(HS_PROGS))
632
install-exec-hook:
633
	@mkdir_p@ $(DESTDIR)$(iallocatorsdir)
634
# FIXME: this is a hardcoded logic, instead of auto-resolving
635
	$(LN_S) -f ../../../bin/htools \
636
		   $(DESTDIR)$(iallocatorsdir)/hail
637
	for role in $(HS_BIN_ROLES); do \
638
		$(LN_S) -f htools \
639
			   $(DESTDIR)$(bindir)/$$role ; \
640
	done
641
endif
642

    
643
$(HS_ALL_PROGS): %: %.hs $(HS_LIBTEST_SRCS) $(HS_BUILT_SRCS) Makefile
644
	@if [ "$(notdir $@)" = "test" ] && [ "$(HTOOLS_NODEV)" ]; then \
645
	  echo "Error: cannot run unittests without the development" \
646
	       " libraries (see devnotes.rst)" 1>&2; \
647
	  exit 1; \
648
	fi
649
	@rm -f $(notdir $@).tix
650
	$(GHC) --make \
651
	  $(HFLAGS) \
652
	  $(HTOOLS_NOCURL) $(HTOOLS_PARALLEL3) $(HTOOLS_REGEX_PCRE) \
653
	  -osuf $(notdir $@).o -hisuf $(notdir $@).hi \
654
	  $(HEXTRA) $(HEXTRA_INT) $@
655
	@touch "$@"
656

    
657
# for the htest/test binary, we need to enable profiling/coverage
658
htest/test: HEXTRA_INT=-fhpc -ihtest
659

    
660
# we compile the hpc-htools binary with the program coverage
661
htest/hpc-htools: HEXTRA_INT=-fhpc
662

    
663
# test dependency
664
htest/offline-tests.sh: htest/hpc-htools
665

    
666
# rules for building profiling-enabled versions of the haskell
667
# programs: hs-prof does the full two-step build, whereas
668
# hs-prof-quick does only the final rebuild (hs-prof must have been
669
# run before)
670
.PHONY: hs-prof hs-prof-quick
671
hs-prof:
672
	$(MAKE) $(AM_MAKEFLAGS) clean
673
	$(MAKE) $(AM_MAKEFLAGS) $(HS_ALL_PROGS) HEXTRA="-osuf .o"
674
	rm -f $(HS_ALL_PROGS)
675
	$(MAKE) $(AM_MAKEFLAGS) hs-prof-quick
676

    
677
hs-prof-quick:
678
	$(MAKE) $(AM_MAKEFLAGS) $(HS_ALL_PROGS) HEXTRA="-osuf .prof_o -prof -auto-all"
679

    
680
dist_sbin_SCRIPTS = \
681
	tools/ganeti-listrunner
682

    
683
nodist_sbin_SCRIPTS = \
684
	$(PYTHON_BOOTSTRAP_SBIN) \
685
	daemons/ganeti-cleaner
686

    
687
if ENABLE_CONFD
688
htools/ganeti-confd: htools/hconfd
689
	cp -f $< $@
690

    
691
nodist_sbin_SCRIPTS += htools/ganeti-confd
692
endif
693

    
694
python_scripts = \
695
	tools/burnin \
696
	tools/cfgshell \
697
	tools/cfgupgrade \
698
	tools/cfgupgrade12 \
699
	tools/cluster-merge \
700
	tools/confd-client \
701
	tools/fmtjson \
702
	tools/lvmstrap \
703
	tools/move-instance \
704
	tools/ovfconverter \
705
	tools/sanitize-config
706

    
707
dist_tools_SCRIPTS = \
708
	$(python_scripts) \
709
	tools/kvm-console-wrapper \
710
	tools/master-ip-setup \
711
	tools/xen-console-wrapper
712

    
713
nodist_tools_SCRIPTS = \
714
	tools/vcluster-setup
715

    
716
pkglib_python_scripts = \
717
	daemons/import-export \
718
	tools/check-cert-expired
719

    
720
nodist_pkglib_python_scripts = \
721
	tools/ensure-dirs \
722
	tools/prepare-node-join
723

    
724
myexeclib_SCRIPTS = \
725
	daemons/daemon-util \
726
	tools/kvm-ifup \
727
	$(pkglib_python_scripts)
728

    
729
nodist_myexeclib_SCRIPTS = \
730
	$(nodist_pkglib_python_scripts)
731

    
732
EXTRA_DIST = \
733
	NEWS \
734
	UPGRADE \
735
	epydoc.conf.in \
736
	pylintrc \
737
	autotools/build-bash-completion \
738
	autotools/build-rpc \
739
	autotools/check-header \
740
	autotools/check-imports \
741
	autotools/check-man-dashes \
742
	autotools/check-man-warnings \
743
	autotools/check-news \
744
	autotools/check-python-code \
745
	autotools/check-tar \
746
	autotools/check-version \
747
	autotools/convert-constants \
748
	autotools/docpp \
749
	autotools/gen-coverage \
750
	autotools/testrunner \
751
	autotools/wrong-hardcoded-paths \
752
	$(RUN_IN_TEMPDIR) \
753
	daemons/daemon-util.in \
754
	daemons/ganeti-cleaner.in \
755
	$(pkglib_python_scripts) \
756
	devel/upload \
757
	tools/kvm-ifup.in \
758
	tools/vcluster-setup.in \
759
	$(docdot) \
760
	$(docpng) \
761
	$(docrst) \
762
	doc/conf.py \
763
	doc/html \
764
	$(BUILT_EXAMPLES:%=%.in) \
765
	doc/examples/ganeti.default \
766
	doc/examples/ganeti.default-debug \
767
	doc/examples/hooks/ethers \
768
	doc/examples/gnt-debug/README \
769
	doc/examples/gnt-debug/delay0.json \
770
	doc/examples/gnt-debug/delay50.json \
771
	test/lockperf.py \
772
	test/testutils.py \
773
	test/mocks.py \
774
	$(dist_TESTS) \
775
	$(TEST_FILES) \
776
	man/footer.rst \
777
	$(manrst) \
778
	$(maninput) \
779
	qa/qa-sample.json \
780
	$(qa_scripts) \
781
	$(HS_LIBTEST_SRCS) $(HS_BUILT_SRCS_IN) \
782
	$(HS_PROG_SRCS) \
783
	htools/lint-hints.hs \
784
	htest/cli-tests-defs.sh \
785
	htest/offline-test.sh \
786
	.ghci
787

    
788
man_MANS = \
789
	man/ganeti-cleaner.8 \
790
	man/ganeti-confd.8 \
791
	man/ganeti-listrunner.8 \
792
	man/ganeti-masterd.8 \
793
	man/ganeti-noded.8 \
794
	man/ganeti-os-interface.7 \
795
	man/ganeti-rapi.8 \
796
	man/ganeti-watcher.8 \
797
	man/ganeti.7 \
798
	man/gnt-backup.8 \
799
	man/gnt-cluster.8 \
800
	man/gnt-debug.8 \
801
	man/gnt-group.8 \
802
	man/gnt-network.8 \
803
	man/gnt-instance.8 \
804
	man/gnt-job.8 \
805
	man/gnt-node.8 \
806
	man/gnt-os.8 \
807
	man/hail.1 \
808
	man/hbal.1 \
809
	man/hcheck.1 \
810
	man/hinfo.1 \
811
	man/hscan.1 \
812
	man/hspace.1 \
813
	man/htools.1
814

    
815
manrst = $(patsubst %.1,%.rst,$(patsubst %.7,%.rst,$(patsubst %.8,%.rst,$(man_MANS))))
816
manhtml = $(patsubst %.rst,%.html,$(manrst))
817
mangen = $(patsubst %.rst,%.gen,$(manrst))
818
maninput = \
819
	$(patsubst %.1,%.1.in,$(patsubst %.7,%.7.in,$(patsubst %.8,%.8.in,$(man_MANS)))) \
820
	$(patsubst %.html,%.html.in,$(manhtml)) \
821
	man/footer.man man/footer.html $(mangen)
822

    
823
TEST_FILES = \
824
	htest/data/common-suffix.data \
825
	htest/data/hail-alloc-drbd.json \
826
	htest/data/hail-change-group.json \
827
	htest/data/hail-invalid-reloc.json \
828
	htest/data/hail-node-evac.json \
829
	htest/data/hail-reloc-drbd.json \
830
	htest/data/hbal-excl-tags.data \
831
	htest/data/hbal-split-insts.data \
832
	htest/data/invalid-node.data \
833
	htest/data/missing-resources.data \
834
	htest/data/rapi/groups.json \
835
	htest/data/rapi/info.json \
836
	htest/data/rapi/instances.json \
837
	htest/data/rapi/nodes.json \
838
	htest/shelltests/htools-balancing.test \
839
	htest/shelltests/htools-basic.test \
840
	htest/shelltests/htools-dynutil.test \
841
	htest/shelltests/htools-excl.test \
842
	htest/shelltests/htools-hail.test \
843
	htest/shelltests/htools-hspace.test \
844
	htest/shelltests/htools-invalid.test \
845
	htest/shelltests/htools-multi-group.test \
846
	htest/shelltests/htools-no-backend.test \
847
	htest/shelltests/htools-rapi.test \
848
	htest/shelltests/htools-single-group.test \
849
	htest/shelltests/htools-text-backend.test \
850
	test/data/bdev-drbd-8.0.txt \
851
	test/data/bdev-drbd-8.3.txt \
852
	test/data/bdev-drbd-disk.txt \
853
	test/data/bdev-drbd-net-ip4.txt \
854
	test/data/bdev-drbd-net-ip6.txt \
855
	test/data/cert1.pem \
856
	test/data/cert2.pem \
857
	test/data/ip-addr-show-dummy0.txt \
858
	test/data/ip-addr-show-lo-ipv4.txt \
859
	test/data/ip-addr-show-lo-ipv6.txt \
860
	test/data/ip-addr-show-lo-oneline-ipv4.txt \
861
	test/data/ip-addr-show-lo-oneline-ipv6.txt \
862
	test/data/ip-addr-show-lo-oneline.txt \
863
	test/data/ip-addr-show-lo.txt \
864
	test/data/kvm_0.12.5_help.txt \
865
	test/data/kvm_0.15.90_help.txt \
866
	test/data/kvm_0.9.1_help.txt \
867
	test/data/kvm_1.0_help.txt \
868
	test/data/ovfdata/compr_disk.vmdk.gz \
869
	test/data/ovfdata/config.ini \
870
	test/data/ovfdata/corrupted_resources.ovf \
871
	test/data/ovfdata/empty.ini \
872
	test/data/ovfdata/empty.ovf \
873
	test/data/ovfdata/ganeti.mf \
874
	test/data/ovfdata/ganeti.ovf \
875
	test/data/ovfdata/gzip_disk.ovf \
876
	test/data/ovfdata/new_disk.vmdk \
877
	test/data/ovfdata/no_disk.ini \
878
	test/data/ovfdata/no_disk_in_ref.ovf \
879
	test/data/ovfdata/no_os.ini \
880
	test/data/ovfdata/no_ovf.ova \
881
	test/data/ovfdata/other/rawdisk.raw \
882
	test/data/ovfdata/ova.ova \
883
	test/data/ovfdata/rawdisk.raw \
884
	test/data/ovfdata/second_disk.vmdk \
885
	test/data/ovfdata/unsafe_path.ini \
886
	test/data/ovfdata/virtualbox.ovf \
887
	test/data/ovfdata/wrong_config.ini \
888
	test/data/ovfdata/wrong_extension.ovd \
889
	test/data/ovfdata/wrong_manifest.mf \
890
	test/data/ovfdata/wrong_manifest.ovf \
891
	test/data/ovfdata/wrong_ova.ova \
892
	test/data/ovfdata/wrong_xml.ovf \
893
	test/data/proc_drbd8.txt \
894
	test/data/proc_drbd80-emptyline.txt \
895
	test/data/proc_drbd83.txt \
896
	test/data/proc_drbd83_sync.txt \
897
	test/data/proc_drbd83_sync_want.txt \
898
	test/data/proc_drbd83_sync_krnl2.6.39.txt \
899
	test/data/sys_drbd_usermode_helper.txt \
900
	test/data/vgreduce-removemissing-2.02.02.txt \
901
	test/data/vgreduce-removemissing-2.02.66-fail.txt \
902
	test/data/vgreduce-removemissing-2.02.66-ok.txt \
903
	test/data/vgs-missing-pvs-2.02.02.txt \
904
	test/data/vgs-missing-pvs-2.02.66.txt \
905
	test/ganeti-cli.test \
906
	test/gnt-cli.test \
907
	test/import-export_unittest-helper
908

    
909
python_tests = \
910
	doc/examples/rapi_testutils.py \
911
	test/cfgupgrade_unittest.py \
912
	test/docs_unittest.py \
913
	test/ganeti.asyncnotifier_unittest.py \
914
	test/ganeti.backend_unittest-runasroot.py \
915
	test/ganeti.backend_unittest.py \
916
	test/ganeti.bdev_unittest.py \
917
	test/ganeti.cli_unittest.py \
918
	test/ganeti.client.gnt_cluster_unittest.py \
919
	test/ganeti.client.gnt_instance_unittest.py \
920
	test/ganeti.client.gnt_job_unittest.py \
921
	test/ganeti.cmdlib_unittest.py \
922
	test/ganeti.compat_unittest.py \
923
	test/ganeti.confd.client_unittest.py \
924
	test/ganeti.config_unittest.py \
925
	test/ganeti.constants_unittest.py \
926
	test/ganeti.daemon_unittest.py \
927
	test/ganeti.errors_unittest.py \
928
	test/ganeti.hooks_unittest.py \
929
	test/ganeti.ht_unittest.py \
930
	test/ganeti.http_unittest.py \
931
	test/ganeti.hypervisor.hv_chroot_unittest.py \
932
	test/ganeti.hypervisor.hv_fake_unittest.py \
933
	test/ganeti.hypervisor.hv_kvm_unittest.py \
934
	test/ganeti.hypervisor.hv_lxc_unittest.py \
935
	test/ganeti.hypervisor.hv_xen_unittest.py \
936
	test/ganeti.hypervisor_unittest.py \
937
	test/ganeti.impexpd_unittest.py \
938
	test/ganeti.jqueue_unittest.py \
939
	test/ganeti.jstore_unittest.py \
940
	test/ganeti.locking_unittest.py \
941
	test/ganeti.luxi_unittest.py \
942
	test/ganeti.masterd.iallocator_unittest.py \
943
	test/ganeti.masterd.instance_unittest.py \
944
	test/ganeti.mcpu_unittest.py \
945
	test/ganeti.netutils_unittest.py \
946
	test/ganeti.objects_unittest.py \
947
	test/ganeti.objectutils_unittest.py \
948
	test/ganeti.opcodes_unittest.py \
949
	test/ganeti.ovf_unittest.py \
950
	test/ganeti.qlang_unittest.py \
951
	test/ganeti.query_unittest.py \
952
	test/ganeti.rapi.baserlib_unittest.py \
953
	test/ganeti.rapi.client_unittest.py \
954
	test/ganeti.rapi.resources_unittest.py \
955
	test/ganeti.rapi.rlib2_unittest.py \
956
	test/ganeti.rapi.testutils_unittest.py \
957
	test/ganeti.rpc_unittest.py \
958
	test/ganeti.runtime_unittest.py \
959
	test/ganeti.serializer_unittest.py \
960
	test/ganeti.server.rapi_unittest.py \
961
	test/ganeti.ssconf_unittest.py \
962
	test/ganeti.ssh_unittest.py \
963
	test/ganeti.storage_unittest.py \
964
	test/ganeti.tools.ensure_dirs_unittest.py \
965
	test/ganeti.tools.prepare_node_join_unittest.py \
966
	test/ganeti.uidpool_unittest.py \
967
	test/ganeti.utils.algo_unittest.py \
968
	test/ganeti.utils.filelock_unittest.py \
969
	test/ganeti.utils.hash_unittest.py \
970
	test/ganeti.utils.io_unittest-runasroot.py \
971
	test/ganeti.utils.io_unittest.py \
972
	test/ganeti.utils.log_unittest.py \
973
	test/ganeti.utils.mlock_unittest.py \
974
	test/ganeti.utils.nodesetup_unittest.py \
975
	test/ganeti.utils.process_unittest.py \
976
	test/ganeti.utils.retry_unittest.py \
977
	test/ganeti.utils.text_unittest.py \
978
	test/ganeti.utils.wrapper_unittest.py \
979
	test/ganeti.utils.x509_unittest.py \
980
	test/ganeti.utils_unittest.py \
981
	test/ganeti.vcluster_unittest.py \
982
	test/ganeti.workerpool_unittest.py \
983
	test/pycurl_reset_unittest.py \
984
	test/qa.qa_config_unittest.py \
985
	test/tempfile_fork_unittest.py
986

    
987
haskell_tests = htest/test
988

    
989
dist_TESTS = \
990
	test/check-cert-expired_unittest.bash \
991
	test/daemon-util_unittest.bash \
992
	test/ganeti-cleaner_unittest.bash \
993
	test/import-export_unittest.bash \
994
	test/cli-test.bash \
995
	test/bash_completion.bash \
996
	$(python_tests)
997

    
998
nodist_TESTS =
999
check_SCRIPTS =
1000

    
1001
if WANT_HTOOLSTESTS
1002
nodist_TESTS += $(haskell_tests)
1003
dist_TESTS += htest/offline-test.sh
1004
check_SCRIPTS += htest/hpc-htools $(HS_BUILT_TEST_HELPERS)
1005
endif
1006

    
1007
TESTS = $(dist_TESTS) $(nodist_TESTS)
1008

    
1009
# Environment for all tests
1010
PLAIN_TESTS_ENVIRONMENT = \
1011
	PYTHONPATH=. \
1012
	TOP_SRCDIR=$(abs_top_srcdir) TOP_BUILDDIR=$(abs_top_builddir) \
1013
	PYTHON=$(PYTHON) FAKEROOT=$(FAKEROOT_PATH) \
1014
	$(RUN_IN_TEMPDIR)
1015

    
1016
# Environment for tests run by automake
1017
TESTS_ENVIRONMENT = \
1018
	$(PLAIN_TESTS_ENVIRONMENT) $(abs_top_srcdir)/autotools/testrunner
1019

    
1020
all_python_code = \
1021
	$(dist_sbin_SCRIPTS) \
1022
	$(python_scripts) \
1023
	$(pkglib_python_scripts) \
1024
	$(nodist_pkglib_python_scripts) \
1025
	$(python_tests) \
1026
	$(pkgpython_PYTHON) \
1027
	$(client_PYTHON) \
1028
	$(hypervisor_PYTHON) \
1029
	$(rapi_PYTHON) \
1030
	$(server_PYTHON) \
1031
	$(pytools_PYTHON) \
1032
	$(http_PYTHON) \
1033
	$(confd_PYTHON) \
1034
	$(masterd_PYTHON) \
1035
	$(impexpd_PYTHON) \
1036
	$(utils_PYTHON) \
1037
	$(watcher_PYTHON) \
1038
	$(noinst_PYTHON) \
1039
	$(qa_scripts)
1040

    
1041
srclink_files = \
1042
	man/footer.rst \
1043
	test/check-cert-expired_unittest.bash \
1044
	test/daemon-util_unittest.bash \
1045
	test/ganeti-cleaner_unittest.bash \
1046
	test/import-export_unittest.bash \
1047
	test/cli-test.bash \
1048
	test/bash_completion.bash \
1049
	htest/offline-test.sh \
1050
	htest/cli-tests-defs.sh \
1051
	$(all_python_code) \
1052
	$(HS_LIBTEST_SRCS) $(HS_PROG_SRCS)
1053

    
1054
check_python_code = \
1055
	$(BUILD_BASH_COMPLETION) \
1056
	$(CHECK_IMPORTS) \
1057
	$(CHECK_HEADER) \
1058
	$(DOCPP) \
1059
	$(all_python_code)
1060

    
1061
lint_python_code = \
1062
	ganeti \
1063
	ganeti/http/server.py \
1064
	$(dist_sbin_SCRIPTS) \
1065
	$(python_scripts) \
1066
	$(pkglib_python_scripts) \
1067
	$(BUILD_BASH_COMPLETION) \
1068
	$(CHECK_IMPORTS) \
1069
	$(CHECK_HEADER) \
1070
	$(DOCPP) \
1071
	$(PYTHON_BOOTSTRAP)
1072

    
1073
standalone_python_modules = \
1074
	lib/rapi/client.py \
1075
	tools/ganeti-listrunner
1076

    
1077
pep8_python_code = \
1078
	ganeti \
1079
	ganeti/http/server.py \
1080
	$(dist_sbin_SCRIPTS) \
1081
	$(python_scripts) \
1082
	$(pkglib_python_scripts) \
1083
	$(BUILD_BASH_COMPLETION) \
1084
	$(CHECK_HEADER) \
1085
	$(DOCPP) \
1086
	$(PYTHON_BOOTSTRAP) \
1087
	qa
1088

    
1089
test/daemon-util_unittest.bash: daemons/daemon-util
1090

    
1091
test/ganeti-cleaner_unittest.bash: daemons/ganeti-cleaner
1092

    
1093
test/bash_completion.bash: doc/examples/bash_completion-debug
1094

    
1095
tools/kvm-ifup: tools/kvm-ifup.in $(REPLACE_VARS_SED)
1096
	sed -f $(REPLACE_VARS_SED) < $< > $@
1097
	chmod +x $@
1098

    
1099
tools/vcluster-setup: tools/vcluster-setup.in $(REPLACE_VARS_SED)
1100
	sed -f $(REPLACE_VARS_SED) < $< > $@
1101
	chmod +x $@
1102

    
1103
daemons/%:: daemons/%.in $(REPLACE_VARS_SED)
1104
	sed -f $(REPLACE_VARS_SED) < $< > $@
1105
	chmod +x $@
1106

    
1107
doc/examples/%:: doc/examples/%.in $(REPLACE_VARS_SED)
1108
	sed -f $(REPLACE_VARS_SED) < $< > $@
1109

    
1110
doc/examples/bash_completion: BC_ARGS = --compact
1111
doc/examples/bash_completion-debug: BC_ARGS =
1112

    
1113
doc/examples/bash_completion doc/examples/bash_completion-debug: \
1114
	$(BUILD_BASH_COMPLETION) $(RUN_IN_TEMPDIR) \
1115
	lib/cli.py $(gnt_scripts) $(client_PYTHON) tools/burnin \
1116
	daemons/ganeti-cleaner \
1117
	$(GENERATED_FILES) $(HTOOLS_GENERATED_FILES)
1118
	PYTHONPATH=. $(RUN_IN_TEMPDIR) \
1119
	  $(CURDIR)/$(BUILD_BASH_COMPLETION) $(BC_ARGS) > $@
1120

    
1121
doc/%.png: doc/%.dot
1122
	@test -n "$(DOT)" || { echo 'dot' not found during configure; exit 1; }
1123
	$(DOT) -Tpng -o $@ $<
1124

    
1125
man/footer.man: man/footer.rst
1126
	@test -n "$(PANDOC)" || \
1127
	  { echo 'pandoc' not found during configure; exit 1; }
1128
	$(PANDOC) -f rst -t man -o $@ $<
1129

    
1130
man/footer.html: man/footer.rst
1131
	@test -n "$(PANDOC)" || \
1132
	  { echo 'pandoc' not found during configure; exit 1; }
1133
	$(PANDOC) -f rst -t html -o $@ $<
1134

    
1135
man/%.gen: man/%.rst lib/query.py lib/build/sphinx_ext.py \
1136
	lib/build/shell_example_lexer.py \
1137
	| $(RUN_IN_TEMPDIR) $(BUILT_PYTHON_SOURCES)
1138
	@echo "Checking $< for hardcoded paths..."
1139
	@if grep -nEf autotools/wrong-hardcoded-paths $<; then \
1140
	  echo "Man page $< has harcoded paths (see above)!" 1>&2 ; \
1141
	  exit 1; \
1142
	fi
1143
	set -e ; \
1144
	trap 'echo auto-removing $@; rm $@' EXIT; \
1145
	PYTHONPATH=. $(RUN_IN_TEMPDIR) $(CURDIR)/$(DOCPP) < $< > $@ ;\
1146
	trap - EXIT
1147

    
1148
man/%.7.in man/%.8.in man/%.1.in: man/%.gen man/footer.man
1149
	@test -n "$(PANDOC)" || \
1150
	  { echo 'pandoc' not found during configure; exit 1; }
1151
	set -o pipefail ; \
1152
	trap 'echo auto-removing $@; rm $@' EXIT; \
1153
	$(PANDOC) -s -f rst -t man -A man/footer.man $< | \
1154
	  sed -e 's/\\@/@/g' > $@; \
1155
	if test -n "$(MAN_HAS_WARNINGS)"; then $(CHECK_MAN_WARNINGS) $@; fi; \
1156
	$(CHECK_MAN_DASHES) $@; \
1157
	trap - EXIT
1158

    
1159

    
1160
man/%.html.in: man/%.gen man/footer.html
1161
	@test -n "$(PANDOC)" || \
1162
	  { echo 'pandoc' not found during configure; exit 1; }
1163
	set -o pipefail ; \
1164
	$(PANDOC) -s -f rst -t html -A man/footer.html $< | \
1165
	  sed -e 's/\\@/@/g' > $@
1166

    
1167
man/%: man/%.in  $(REPLACE_VARS_SED)
1168
	sed -f $(REPLACE_VARS_SED) < $< > $@
1169

    
1170
epydoc.conf: epydoc.conf.in $(REPLACE_VARS_SED)
1171
	sed -f $(REPLACE_VARS_SED) < $< > $@
1172

    
1173
vcs-version:
1174
	if test -d .git; then \
1175
	  git describe > $@; \
1176
	elif test ! -f $@ ; then \
1177
	  echo "Cannot auto-generate $@ file"; exit 1; \
1178
	fi
1179

    
1180
.PHONY: clean-vcs-version
1181
clean-vcs-version:
1182
	rm -f vcs-version
1183

    
1184
.PHONY: regen-vcs-version
1185
regen-vcs-version:
1186
	@set -e; \
1187
	cd $(srcdir); \
1188
	if test -d .git; then \
1189
	  T=`mktemp` ; trap 'rm -f $$T' EXIT; \
1190
	  git describe > $$T; \
1191
	  if ! cmp --quiet $$T vcs-version; then \
1192
	    mv $$T vcs-version; \
1193
	  fi; \
1194
	fi
1195

    
1196
htools/Ganeti/Version.hs: htools/Ganeti/Version.hs.in \
1197
	vcs-version $(built_base_sources)
1198
	set -e; \
1199
	VCSVER=`cat $(abs_top_srcdir)/vcs-version`; \
1200
	sed -e "s/%ver%/$$VCSVER/" < $< > $@
1201

    
1202
htools/Ganeti/Constants.hs: htools/Ganeti/Constants.hs.in \
1203
	lib/constants.py lib/_autoconf.py lib/luxi.py \
1204
	$(CONVERT_CONSTANTS) $(built_base_sources) \
1205
	| lib/_vcsversion.py
1206
	set -e; \
1207
	{ cat $< ; PYTHONPATH=. $(CONVERT_CONSTANTS); } > $@
1208

    
1209
htest/Test/Ganeti/TestImports.hs: htest/Test/Ganeti/TestImports.hs.in \
1210
	$(built_base_sources)
1211
	set -e; \
1212
	{ cat $< ; \
1213
	  echo ; \
1214
	  for name in $(filter-out Ganeti.THH,$(subst /,.,$(patsubst %.hs,%,$(patsubst htools/%,%,$(HS_LIB_SRCS))))) ; do \
1215
	    echo "import $$name ()" ; \
1216
	  done ; \
1217
	} > $@
1218

    
1219
lib/_autoconf.py: Makefile | stamp-directories
1220
	set -e; \
1221
	{ echo '# This file is automatically generated, do not edit!'; \
1222
	  echo '#'; \
1223
	  echo ''; \
1224
	  echo '"""Build-time configuration for Ganeti.'; \
1225
	  echo '';\
1226
	  echo 'This file is autogenerated by the build process.'; \
1227
	  echo 'For any changes you need to re-run ./configure (and'; \
1228
	  echo 'not edit by hand).'; \
1229
	  echo ''; \
1230
	  echo '"""'; \
1231
	  echo ''; \
1232
	  echo '# pylint: disable=C0301,C0324'; \
1233
	  echo '# because this is autogenerated, we do not want'; \
1234
	  echo '# style warnings' ; \
1235
	  echo ''; \
1236
	  echo "PACKAGE_VERSION = '$(PACKAGE_VERSION)'"; \
1237
	  echo "VERSION_MAJOR = '$(VERSION_MAJOR)'"; \
1238
	  echo "VERSION_MINOR = '$(VERSION_MINOR)'"; \
1239
	  echo "VERSION_REVISION = '$(VERSION_REVISION)'"; \
1240
	  echo "VERSION_SUFFIX = '$(VERSION_SUFFIX)'"; \
1241
	  echo "VERSION_FULL = '$(VERSION_FULL)'"; \
1242
	  echo "LOCALSTATEDIR = '$(localstatedir)'"; \
1243
	  echo "SYSCONFDIR = '$(sysconfdir)'"; \
1244
	  echo "SSH_CONFIG_DIR = '$(SSH_CONFIG_DIR)'"; \
1245
	  echo "SSH_LOGIN_USER = '$(SSH_LOGIN_USER)'"; \
1246
	  echo "SSH_CONSOLE_USER = '$(SSH_CONSOLE_USER)'"; \
1247
	  echo "EXPORT_DIR = '$(EXPORT_DIR)'"; \
1248
	  echo "OS_SEARCH_PATH = [$(OS_SEARCH_PATH)]"; \
1249
	  echo "XEN_BOOTLOADER = '$(XEN_BOOTLOADER)'"; \
1250
	  echo "XEN_KERNEL = '$(XEN_KERNEL)'"; \
1251
	  echo "XEN_INITRD = '$(XEN_INITRD)'"; \
1252
	  echo "KVM_KERNEL = '$(KVM_KERNEL)'"; \
1253
	  echo "FILE_STORAGE_DIR = '$(FILE_STORAGE_DIR)'"; \
1254
	  echo "ENABLE_FILE_STORAGE = $(ENABLE_FILE_STORAGE)"; \
1255
	  echo "SHARED_FILE_STORAGE_DIR = '$(SHARED_FILE_STORAGE_DIR)'"; \
1256
	  echo "ENABLE_SHARED_FILE_STORAGE = $(ENABLE_SHARED_FILE_STORAGE)"; \
1257
	  echo "IALLOCATOR_SEARCH_PATH = [$(IALLOCATOR_SEARCH_PATH)]"; \
1258
	  echo "KVM_PATH = '$(KVM_PATH)'"; \
1259
	  echo "IP_PATH = '$(IP_PATH)'"; \
1260
	  echo "SOCAT_PATH = '$(SOCAT)'"; \
1261
	  echo "SOCAT_USE_ESCAPE = $(SOCAT_USE_ESCAPE)"; \
1262
	  echo "SOCAT_USE_COMPRESS = $(SOCAT_USE_COMPRESS)"; \
1263
	  echo "LVM_STRIPECOUNT = $(LVM_STRIPECOUNT)"; \
1264
	  echo "TOOLSDIR = '$(toolsdir)'"; \
1265
	  echo "GNT_SCRIPTS = [$(foreach i,$(notdir $(gnt_scripts)),'$(i)',)]"; \
1266
	  echo "HTOOLS_PROGS = [$(foreach i,$(HS_HTOOLS_PROGS),'$(i)',)]"; \
1267
	  echo "PKGLIBDIR = '$(pkglibdir)'"; \
1268
	  echo "DRBD_BARRIERS = '$(DRBD_BARRIERS)'"; \
1269
	  echo "DRBD_NO_META_FLUSH = $(DRBD_NO_META_FLUSH)"; \
1270
	  echo "SYSLOG_USAGE = '$(SYSLOG_USAGE)'"; \
1271
	  echo "DAEMONS_GROUP = '$(DAEMONS_GROUP)'"; \
1272
	  echo "ADMIN_GROUP = '$(ADMIN_GROUP)'"; \
1273
	  echo "MASTERD_USER = '$(MASTERD_USER)'"; \
1274
	  echo "MASTERD_GROUP = '$(MASTERD_GROUP)'"; \
1275
	  echo "RAPI_USER = '$(RAPI_USER)'"; \
1276
	  echo "RAPI_GROUP = '$(RAPI_GROUP)'"; \
1277
	  echo "CONFD_USER = '$(CONFD_USER)'"; \
1278
	  echo "CONFD_GROUP = '$(CONFD_GROUP)'"; \
1279
	  echo "NODED_USER = '$(NODED_USER)'"; \
1280
	  echo "NODED_GROUP = '$(NODED_GROUP)'"; \
1281
	  echo "DISK_SEPARATOR = '$(DISK_SEPARATOR)'"; \
1282
	  echo "QEMUIMG_PATH = '$(QEMUIMG_PATH)'"; \
1283
	  echo "HTOOLS = True"; \
1284
	  echo "ENABLE_CONFD = $(ENABLE_CONFD)"; \
1285
	  echo "XEN_CMD = '$(XEN_CMD)'"; \
1286
	  echo "ENABLE_SPLIT_QUERY = $(ENABLE_SPLIT_QUERY)"; \
1287
	  echo "ENABLE_RESTRICTED_COMMANDS = $(ENABLE_RESTRICTED_COMMANDS)"; \
1288
	} > $@
1289

    
1290
lib/_vcsversion.py: Makefile vcs-version | stamp-directories
1291
	set -e; \
1292
	VCSVER=`cat $(abs_top_srcdir)/vcs-version`; \
1293
	{ echo '# This file is automatically generated, do not edit!'; \
1294
	  echo '#'; \
1295
	  echo ''; \
1296
	  echo '"""Build-time VCS version number for Ganeti.'; \
1297
	  echo '';\
1298
	  echo 'This file is autogenerated by the build process.'; \
1299
	  echo 'For any changes you need to re-run ./configure (and'; \
1300
	  echo 'not edit by hand).'; \
1301
	  echo ''; \
1302
	  echo '"""'; \
1303
	  echo ''; \
1304
	  echo '# pylint: disable=C0301,C0324'; \
1305
	  echo '# because this is autogenerated, we do not want'; \
1306
	  echo '# style warnings' ; \
1307
	  echo ''; \
1308
	  echo "VCS_VERSION = '$$VCSVER'"; \
1309
	} > $@
1310

    
1311
lib/_generated_rpc.py: lib/rpc_defs.py $(BUILD_RPC)
1312
	PYTHONPATH=. $(RUN_IN_TEMPDIR) $(CURDIR)/$(BUILD_RPC) lib/rpc_defs.py > $@
1313

    
1314
$(SHELL_ENV_INIT): Makefile stamp-directories
1315
	set -e; \
1316
	{ echo '# Allow overriding for tests'; \
1317
	  echo 'readonly LOCALSTATEDIR=$${LOCALSTATEDIR:-$${GANETI_ROOTDIR:-}$(localstatedir)}'; \
1318
	  echo 'readonly SYSCONFDIR=$${SYSCONFDIR:-$${GANETI_ROOTDIR:-}$(sysconfdir)}'; \
1319
	  echo; \
1320
	  echo 'readonly PKGLIBDIR=$(pkglibdir)'; \
1321
	  echo 'readonly LOG_DIR="$$LOCALSTATEDIR/log/ganeti"'; \
1322
	  echo 'readonly RUN_DIR="$$LOCALSTATEDIR/run/ganeti"'; \
1323
	  echo 'readonly DATA_DIR="$$LOCALSTATEDIR/lib/ganeti"'; \
1324
	  echo 'readonly CONF_DIR="$$SYSCONFDIR/ganeti"'; \
1325
	} > $@
1326

    
1327
$(REPLACE_VARS_SED): $(SHELL_ENV_INIT) Makefile stamp-directories
1328
	set -e; \
1329
	{ echo 's#@PREFIX@#$(prefix)#g'; \
1330
	  echo 's#@SYSCONFDIR@#$(sysconfdir)#g'; \
1331
	  echo 's#@LOCALSTATEDIR@#$(localstatedir)#g'; \
1332
	  echo 's#@BINDIR@#$(bindir)#g'; \
1333
	  echo 's#@SBINDIR@#$(sbindir)#g'; \
1334
	  echo 's#@LIBDIR@#$(libdir)#g'; \
1335
	  echo 's#@GANETI_VERSION@#$(PACKAGE_VERSION)#g'; \
1336
	  echo 's#@CUSTOM_XEN_BOOTLOADER@#$(XEN_BOOTLOADER)#g'; \
1337
	  echo 's#@CUSTOM_XEN_KERNEL@#$(XEN_KERNEL)#g'; \
1338
	  echo 's#@CUSTOM_XEN_INITRD@#$(XEN_INITRD)#g'; \
1339
	  echo 's#@CUSTOM_IALLOCATOR_SEARCH_PATH@#$(IALLOCATOR_SEARCH_PATH)#g'; \
1340
	  echo 's#@CUSTOM_EXPORT_DIR@#$(EXPORT_DIR)#g'; \
1341
	  echo 's#@RPL_FILE_STORAGE_DIR@#$(FILE_STORAGE_DIR)#g'; \
1342
	  echo 's#@RPL_SSH_INITD_SCRIPT@#$(SSH_INITD_SCRIPT)#g'; \
1343
	  echo 's#@PKGLIBDIR@#$(pkglibdir)#g'; \
1344
	  echo 's#@GNTMASTERUSER@#$(MASTERD_USER)#g'; \
1345
	  echo 's#@GNTRAPIUSER@#$(RAPI_USER)#g'; \
1346
	  echo 's#@GNTCONFDUSER@#$(CONFD_USER)#g'; \
1347
	  echo 's#@GNTNODEDUSER@#$(NODED_USER)#g'; \
1348
	  echo 's#@GNTRAPIGROUP@#$(RAPI_GROUP)#g'; \
1349
	  echo 's#@GNTADMINGROUP@#$(ADMIN_GROUP)#g'; \
1350
	  echo 's#@GNTCONFDGROUP@#$(CONFD_GROUP)#g'; \
1351
	  echo 's#@GNTMASTERDGROUP@#$(MASTERD_GROUP)#g'; \
1352
	  echo 's#@GNTDAEMONSGROUP@#$(DAEMONS_GROUP)#g'; \
1353
	  echo 's#@CUSTOM_ENABLE_CONFD@#$(ENABLE_CONFD)#g'; \
1354
	  echo 's#@MODULES@#$(strip $(lint_python_code))#g'; \
1355
	  echo 's#@ENABLE_SPLIT_QUERY@#$(ENABLE_SPLIT_QUERY)#g'; \
1356
	  echo; \
1357
	  echo '/^@SHELL_ENV_INIT@$$/ {'; \
1358
	  echo '  r $(SHELL_ENV_INIT)'; \
1359
	  echo '  d'; \
1360
	  echo '}'; \
1361
	} > $@
1362

    
1363
# Using deferred evaluation
1364
daemons/ganeti-%: MODULE = ganeti.server.$(patsubst ganeti-%,%,$(notdir $@))
1365
daemons/ganeti-watcher: MODULE = ganeti.watcher
1366
scripts/%: MODULE = ganeti.client.$(subst -,_,$(notdir $@))
1367
tools/ensure-dirs: MODULE = ganeti.tools.ensure_dirs
1368
tools/prepare-node-join: MODULE = ganeti.tools.prepare_node_join
1369
$(HS_BUILT_TEST_HELPERS): TESTROLE = $(patsubst htest/%,%,$@)
1370

    
1371
$(PYTHON_BOOTSTRAP): Makefile | stamp-directories
1372
	test -n "$(MODULE)" || { echo Missing module; exit 1; }
1373
	set -e; \
1374
	{ echo '#!/usr/bin/python'; \
1375
	  echo '# This file is automatically generated, do not edit!'; \
1376
	  echo "# Edit $(MODULE) instead."; \
1377
	  echo; \
1378
	  echo '"""Bootstrap script for L{$(MODULE)}"""'; \
1379
	  echo; \
1380
	  echo '# pylint: disable=C0103'; \
1381
	  echo '# C0103: Invalid name'; \
1382
	  echo; \
1383
	  echo 'import sys'; \
1384
	  echo 'import $(MODULE) as main'; \
1385
	  echo; \
1386
	  echo '# Temporarily alias commands until bash completion'; \
1387
	  echo '# generator is changed'; \
1388
	  echo 'if hasattr(main, "commands"):'; \
1389
	  echo '  commands = main.commands # pylint: disable=E1101'; \
1390
	  echo 'if hasattr(main, "aliases"):'; \
1391
	  echo '  aliases = main.aliases # pylint: disable=E1101'; \
1392
	  echo; \
1393
	  echo 'if __name__ == "__main__":'; \
1394
	  echo '  sys.exit(main.Main())'; \
1395
	} > $@
1396
	chmod u+x $@
1397

    
1398
$(HS_BUILT_TEST_HELPERS): Makefile
1399
	@test -n "$(TESTROLE)" || { echo Missing TESTROLE; exit 1; }
1400
	set -e; \
1401
	{ echo '#!/bin/sh'; \
1402
	  echo '# This file is automatically generated, do not edit!'; \
1403
	  echo "# Edit Makefile.am instead."; \
1404
	  echo; \
1405
	  echo "HTOOLS=$(TESTROLE) exec ./htest/hpc-htools \"\$$@\""; \
1406
	} > $@
1407
	chmod u+x $@
1408

    
1409
stamp-directories: Makefile
1410
	$(MAKE) $(AM_MAKEFLAGS) ganeti
1411
	@mkdir_p@ $(DIRS) $(BUILDTIME_DIR_AUTOCREATE)
1412
	touch $@
1413

    
1414
# We need to create symlinks because "make distcheck" will not install Python
1415
# files when building.
1416
stamp-srclinks: Makefile | stamp-directories
1417
	set -e; \
1418
	for i in $(srclink_files); do \
1419
		if test ! -f $$i -a -f $(abs_top_srcdir)/$$i; then \
1420
			$(LN_S) $(abs_top_srcdir)/$$i $$i; \
1421
		fi; \
1422
	done
1423
	touch $@
1424

    
1425
.PHONY: ganeti
1426
ganeti:
1427
	cd $(top_builddir) && test -h "$@" || { rm -f $@ && $(LN_S) lib $@; }
1428

    
1429
.PHONY: check-dirs
1430
check-dirs: $(GENERATED_FILES)
1431
	@set -e; \
1432
	find . -type d \( \( -name . \) -o \( \
1433
		-name .git -o \
1434
		-name autom4te.cache \
1435
		\) -prune -o -print \) | { \
1436
		error=; \
1437
		while read dir; do \
1438
			case "$$dir" in \
1439
				$(strip $(patsubst %,(./%) ;;,$(DIRCHECK_EXCLUDE) $(DIRS))) \
1440
				*) error=1; echo "Directory $$dir not listed in Makefile" >&2 ;; \
1441
			esac; \
1442
		done; \
1443
		for dir in $(DIRS); do \
1444
			if ! test -d "$$dir"; then \
1445
				echo "Directory $$dir listed in DIRS does not exist" >&2; \
1446
				error=1; \
1447
			fi \
1448
		done; \
1449
		if test -n "$$error"; then exit 1; else exit 0; fi; \
1450
	}
1451

    
1452
.PHONY: check-local
1453
check-local: check-dirs $(GENERATED_FILES)
1454
	$(CHECK_PYTHON_CODE) $(check_python_code)
1455
	PYTHONPATH=. $(CHECK_HEADER) $(check_python_code)
1456
	$(CHECK_VERSION) $(VERSION) $(top_srcdir)/NEWS
1457
	$(CHECK_NEWS) < $(top_srcdir)/NEWS
1458
	PYTHONPATH=. $(RUN_IN_TEMPDIR) $(CURDIR)/$(CHECK_IMPORTS) . $(standalone_python_modules)
1459
	@expver=$(VERSION_MAJOR).$(VERSION_MINOR); \
1460
	if test "`head -n 1 $(top_srcdir)/README`" != "Ganeti $$expver"; then \
1461
		echo "Incorrect version in README, expected $$expver"; \
1462
		exit 1; \
1463
	fi; \
1464
	for file in doc/iallocator.rst doc/hooks.rst doc/virtual-cluster.rst \
1465
			doc/security.rst; do \
1466
		if test "`sed -ne '4 p' $(top_srcdir)/$$file`" != \
1467
			"Documents Ganeti version $$expver"; then \
1468
			echo "Incorrect version in $$file, expected $$expver"; \
1469
			exit 1; \
1470
		fi; \
1471
	done; \
1472
	if ! test -f $(top_srcdir)/doc/design-$$expver.rst; then \
1473
		echo "File $(top_srcdir)/doc/design-$$expver.rst not found"; \
1474
		exit 1; \
1475
	fi; \
1476
	if test $$(wc --max-line-length < $(top_srcdir)/configure.ac) -gt 80; then \
1477
		echo 'Longest line in configure.ac is longer than 80 characters' >&2; \
1478
	fi
1479

    
1480
.PHONY: hs-check
1481
hs-check: htest/test htest/hpc-htools $(HS_BUILT_TEST_HELPERS)
1482
	@rm -f test.tix
1483
	./htest/test
1484
	HBINARY="./htest/hpc-htools" ./htest/offline-test.sh
1485

    
1486
# E111: indentation is not a multiple of four
1487
# E121: continuation line indentation is not a multiple of four
1488
#       (since our indent level is not 4)
1489
# E125: continuation line does not distinguish itself from next logical line
1490
#       (since our indent level is not 4)
1491
# E127: continuation line over-indented for visual indent
1492
#       (since our indent level is not 4)
1493
# note: do NOT add E128 here; it's a valid style error in most cases!
1494
# I've seen real errors, but also some cases were we indent wrongly
1495
# due to line length; try to rework the cases where it is triggered,
1496
# instead of silencing it
1497
# E261: at least two spaces before inline comment
1498
# E501: line too long (80 characters)
1499
PEP8_IGNORE = E111,E121,E125,E127,E261,E501
1500

    
1501
# For excluding pep8 expects filenames only, not whole paths
1502
PEP8_EXCLUDE = $(subst $(space),$(comma),$(strip $(notdir $(BUILT_PYTHON_SOURCES))))
1503

    
1504
LINT_TARGETS = pylint pylint-qa
1505
if HAS_PEP8
1506
LINT_TARGETS += pep8
1507
endif
1508
if HAS_HLINT
1509
LINT_TARGETS += hlint
1510
endif
1511

    
1512
.PHONY: lint
1513
lint: $(LINT_TARGETS)
1514

    
1515
.PHONY: pylint
1516
pylint: $(GENERATED_FILES)
1517
	@test -n "$(PYLINT)" || { echo 'pylint' not found during configure; exit 1; }
1518
	$(PYLINT) $(LINT_OPTS) $(lint_python_code)
1519

    
1520
.PHONY: pylint-qa
1521
pylint-qa: $(GENERATED_FILES)
1522
	@test -n "$(PYLINT)" || { echo 'pylint' not found during configure; exit 1; }
1523
	cd $(top_srcdir)/qa && \
1524
	  PYTHONPATH=$(abs_top_srcdir) $(PYLINT) $(LINT_OPTS) \
1525
	  --rcfile  ../pylintrc $(patsubst qa/%.py,%,$(qa_scripts))
1526

    
1527
.PHONY: pep8
1528
pep8: $(GENERATED_FILES)
1529
	@test -n "$(PEP8)" || { echo 'pep8' not found during configure; exit 1; }
1530
	$(PEP8) --ignore='$(PEP8_IGNORE)' --exclude='$(PEP8_EXCLUDE)' \
1531
		--repeat $(pep8_python_code)
1532

    
1533
# FIXME: remove ignore "Use void" when GHC 6.x is deprecated
1534
.PHONY: hlint
1535
hlint: $(HS_BUILT_SRCS) htools/lint-hints.hs
1536
	@test -n "$(HLINT)" || { echo 'hlint' not found during configure; exit 1; }
1537
	if tty -s; then C="-c"; else C=""; fi; \
1538
	$(HLINT) --utf8 --report=doc/hs-lint.html --cross $$C \
1539
	  --ignore "Use first" \
1540
	  --ignore "Use comparing" \
1541
	  --ignore "Use on" \
1542
	  --ignore "Reduce duplication" \
1543
	  --ignore "Use &&&" \
1544
	  --ignore "Use void" \
1545
	  --hint htools/lint-hints \
1546
	  $(filter-out htools/Ganeti/THH.hs,$(HS_LIBTEST_SRCS) $(HS_PROG_SRCS))
1547

    
1548
# a dist hook rule for updating the vcs-version file; this is
1549
# hardcoded due to where it needs to build the file...
1550
dist-hook:
1551
	$(MAKE) $(AM_MAKEFLAGS) regen-vcs-version
1552
	rm -f $(top_distdir)/vcs-version
1553
	cp -p $(srcdir)/vcs-version $(top_distdir)
1554

    
1555
# a distcheck hook rule for catching revision control directories
1556
distcheck-hook:
1557
	if find $(top_distdir) -name .svn -or -name .git | grep .; then \
1558
		echo "Found revision control files in final archive." 1>&2; \
1559
		exit 1; \
1560
	fi
1561
	if find $(top_distdir) -name '*.py[co]' | grep .; then \
1562
		echo "Found Python byte code in final archive." 1>&2; \
1563
		exit 1; \
1564
	fi
1565
	if find $(top_distdir) -name '*~' | grep .; then \
1566
		echo "Found backup files in final archive." 1>&2; \
1567
		exit 1; \
1568
	fi
1569
# Empty files or directories should not be distributed. They can cause
1570
# unnecessary warnings for packagers. Directories used by automake during
1571
# distcheck must be excluded.
1572
	if find $(top_distdir) -empty -and -not \( \
1573
			-path $(top_distdir)/_build -or \
1574
			-path $(top_distdir)/_inst \) | grep .; then \
1575
		echo "Found empty files or directories in final archive." 1>&2; \
1576
		exit 1; \
1577
	fi
1578
	if test -n "$(BUILD_RELEASE)" && \
1579
	   grep -n -H -E '^\*.*unreleased' $(top_distdir)/NEWS; then \
1580
		echo "Found unreleased version in NEWS." >&2; \
1581
		exit 1; \
1582
	fi
1583

    
1584
# When building a release, stricter checks should be used
1585
distcheck-release dist-release: export BUILD_RELEASE = 1
1586
distcheck-release: distcheck
1587

    
1588
distrebuildcheck: dist
1589
	set -e; \
1590
	builddir=$$(mktemp -d $(abs_srcdir)/distrebuildcheck.XXXXXXX); \
1591
	trap "echo Removing $$builddir; cd $(abs_srcdir); rm -rf $$builddir" EXIT; \
1592
	cd $$builddir; \
1593
	tar xzf $(abs_srcdir)/$(distdir).tar.gz; \
1594
	cd $(distdir); \
1595
	./configure; \
1596
	$(MAKE) maintainer-clean; \
1597
	cp $(abs_srcdir)/vcs-version .; \
1598
	./configure; \
1599
	$(MAKE) $(AM_MAKEFLAGS)
1600

    
1601
dist-release: dist
1602
	set -e; \
1603
	for i in $(DIST_ARCHIVES); do \
1604
		echo -n "Checking $$i ... "; \
1605
		autotools/check-tar < $$i; \
1606
		echo OK; \
1607
	done
1608

    
1609
install-exec-local:
1610
	@mkdir_p@ "$(DESTDIR)${localstatedir}/lib/ganeti" \
1611
	  "$(DESTDIR)${localstatedir}/log/ganeti" \
1612
	  "$(DESTDIR)${localstatedir}/run/ganeti"
1613

    
1614
.PHONY: apidoc
1615
if WANT_HTOOLSAPIDOC
1616
apidoc: py-apidoc hs-apidoc
1617
else
1618
apidoc: py-apidoc
1619
endif
1620

    
1621
.PHONY: py-apidoc
1622
py-apidoc: epydoc.conf $(RUN_IN_TEMPDIR) $(GENERATED_FILES)
1623
	$(RUN_IN_TEMPDIR) epydoc -v \
1624
		--conf $(CURDIR)/epydoc.conf \
1625
		--output $(CURDIR)/$(APIDOC_PY_DIR)
1626

    
1627
.PHONY: hs-apidoc
1628
hs-apidoc: $(HS_BUILT_SRCS)
1629
	@test -n "$(HSCOLOUR)" || \
1630
	    { echo 'HsColour' not found during configure; exit 1; }
1631
	@test -n "$(HADDOCK)" || \
1632
	    { echo 'haddock' not found during configure; exit 1; }
1633
	rm -rf $(APIDOC_HS_DIR)/*
1634
	@mkdir_p@ $(APIDOC_HS_DIR)/Ganeti/HTools/Backend
1635
	@mkdir_p@ $(APIDOC_HS_DIR)/Ganeti/HTools/Program
1636
	@mkdir_p@ $(APIDOC_HS_DIR)/Ganeti/Block
1637
	@mkdir_p@ $(APIDOC_HS_DIR)/Ganeti/Block/Drbd
1638
	@mkdir_p@ $(APIDOC_HS_DIR)/Ganeti/Confd
1639
	@mkdir_p@ $(APIDOC_HS_DIR)/Ganeti/Query
1640
	$(HSCOLOUR) -print-css > $(APIDOC_HS_DIR)/Ganeti/hscolour.css
1641
	$(LN_S) ../hscolour.css $(APIDOC_HS_DIR)/Ganeti/HTools/hscolour.css
1642
	$(LN_S) ../hscolour.css $(APIDOC_HS_DIR)/Ganeti/Confd/hscolour.css
1643
	set -e ; \
1644
	cd htools; \
1645
	if [ "$(HTOOLS_NOCURL)" ]; \
1646
	then OPTGHC="--optghc=$(HTOOLS_NOCURL)"; \
1647
	else OPTGHC=""; \
1648
	fi; \
1649
	if [ "$(HTOOLS_PARALLEL3)" ]; \
1650
	then OPTGHC="$$OPTGHC --optghc=$(HTOOLS_PARALLEL3)"; \
1651
	fi; \
1652
	if [ "$(HTOOLS_REGEX_PCRE)" ]; \
1653
	then OPTGHC="$$OPTGHC --optghc=$(HTOOLS_REGEX_PCRE)"; \
1654
	fi; \
1655
	RELSRCS="$(HS_LIB_SRCS:htools/%=%) $(patsubst htools/%,%,$(filter htools/%,$(HS_BUILT_SRCS)))"; \
1656
	for file in $$RELSRCS; do \
1657
		hfile=`echo $$file|sed 's/\\.hs$$//'`.html; \
1658
		$(HSCOLOUR) -css -anchor $$file > ../$(APIDOC_HS_DIR)/$$hfile ; \
1659
	done ; \
1660
	$(HADDOCK) --odir ../$(APIDOC_HS_DIR) --html --ignore-all-exports -w \
1661
		-t ganeti -p haddock-prologue \
1662
		--source-module="%{MODULE/.//}.html" \
1663
		--source-entity="%{MODULE/.//}.html#%{NAME}" \
1664
		$$OPTGHC \
1665
		$(filter-out Ganeti/HTools/ExtLoader.hs,$(HS_LIB_SRCS:htools/%=%))
1666

    
1667
.PHONY: TAGS
1668
TAGS: $(GENERATED_FILES)
1669
	rm -f TAGS
1670
	$(GHC) -e ":etags" -v0 \
1671
	  $(filter-out -O -Werror,$(HFLAGS)) \
1672
	  $(HTOOLS_NOCURL) $(HTOOLS_PARALLEL3) $(HTOOLS_REGEX_PCRE) \
1673
	  $(HS_LIBTEST_SRCS)
1674
	find . -path './lib/*.py' -o -path './scripts/gnt-*' -o \
1675
	  -path './daemons/ganeti-*' -o -path './tools/*' -o \
1676
	  -path './qa/*.py' | \
1677
	  etags -l python -a -
1678

    
1679
.PHONY: coverage
1680
if WANT_HTOOLS
1681
coverage: py-coverage hs-coverage
1682
else
1683
coverage: py-coverage
1684
endif
1685

    
1686
.PHONY: py-coverage
1687
py-coverage: $(GENERATED_FILES) $(python_tests)
1688
	@test -n "$(PYCOVERAGE)" || \
1689
	    { echo 'python-coverage' not found during configure; exit 1; }
1690
	set -e; \
1691
	COVERAGE=$(PYCOVERAGE) \
1692
	COVERAGE_FILE=$(CURDIR)/$(COVERAGE_PY_DIR)/data \
1693
	TEXT_COVERAGE=$(CURDIR)/$(COVERAGE_PY_DIR)/report.txt \
1694
	HTML_COVERAGE=$(CURDIR)/$(COVERAGE_PY_DIR) \
1695
	$(PLAIN_TESTS_ENVIRONMENT) $(abs_top_srcdir)/autotools/gen-coverage \
1696
	$(python_tests)
1697

    
1698
.PHONY: hs-coverage
1699
hs-coverage: $(haskell_tests) htest/hpc-htools
1700
	rm -f *.tix
1701
	$(MAKE) $(AM_MAKEFLAGS) hs-check
1702
	@mkdir_p@ $(COVERAGE_HS_DIR)
1703
	hpc combine --union $(HPCEXCL) \
1704
	  test.tix hpc-htools.tix > coverage-htools.tix
1705
	hpc markup --destdir=$(COVERAGE_HS_DIR) coverage-htools.tix
1706
	hpc report coverage-htools.tix
1707
	$(LN_S) -f hpc_index.html $(COVERAGE_HS_DIR)/index.html
1708

    
1709
# Special "kind-of-QA" target for htools, needs special setup (all
1710
# tools compiled with -fhpc)
1711
.PHONY: live-test
1712
live-test: all
1713
	set -e ; \
1714
	cd htools; \
1715
	rm -f .hpc; $(LN_S) ../.hpc .hpc; \
1716
	rm -f *.tix *.mix; \
1717
	./live-test.sh; \
1718
	hpc sum --union $(HPCEXCL) $(addsuffix .tix,$(HS_PROGS:htools/%=%)) \
1719
	  --output=live-test.tix ; \
1720
	@mkdir_p@ ../$(COVERAGE_HS_DIR) ; \
1721
	hpc markup --destdir=../$(COVERAGE_HS_DIR) live-test \
1722
		--srcdir=.. $(HPCEXCL) ; \
1723
	hpc report --srcdir=.. live-test $(HPCEXCL)
1724

    
1725
commit-check: distcheck lint apidoc
1726

    
1727
.PHONY: gitignore-check
1728
gitignore-check:
1729
	@if [ -n "`git status --short`" ]; then \
1730
	  echo "Git status is not clean!" 1>&2 ; \
1731
	  git status --short; \
1732
	  exit 1; \
1733
	fi
1734

    
1735
# Target that builds all binaries (including those that are not
1736
# rebuilt except when running the tests)
1737
.PHONY: really-all
1738
really-all: all $(check_SCRIPTS) $(haskell_tests)
1739

    
1740
# we don't need the ancient implicit rules:
1741
%: %,v
1742
%: RCS/%,v
1743
%: RCS/%
1744
%: s.%
1745
%: SCCS/s.%
1746

    
1747
-include ./Makefile.local
1748

    
1749
# vim: set noet :