Statistics
| Branch: | Tag: | Revision:

root / Makefile.am @ fef919b7

History | View | Annotate | Download (51.5 kB)

1
# Ganeti makefile
2
# - Indent with tabs only.
3
# - Keep files sorted; one line per file.
4
# - Directories in lib/ must have their own *dir variable (see hypervisor).
5
# - All directories must be listed DIRS.
6
# - Use autogen.sh to generate Makefile.in and configure script.
7

    
8
# Automake doesn't export these variables before version 1.10.
9
abs_top_builddir = @abs_top_builddir@
10
abs_top_srcdir = @abs_top_srcdir@
11

    
12
# Helper values for calling builtin functions
13
empty :=
14
space := $(empty) $(empty)
15
comma := ,
16

    
17
# Use bash in order to be able to use pipefail
18
SHELL=/bin/bash
19

    
20
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/DataCollectors \
64
	htools/Ganeti/HTools \
65
	htools/Ganeti/HTools/Backend \
66
	htools/Ganeti/HTools/Program \
67
	htools/Ganeti/Query \
68
	htest \
69
	htest/Test \
70
	htest/Test/Ganeti \
71
	htest/Test/Ganeti/Block \
72
	htest/Test/Ganeti/Block/Drbd \
73
	htest/Test/Ganeti/Confd \
74
	htest/Test/Ganeti/HTools \
75
	htest/Test/Ganeti/HTools/Backend \
76
	htest/Test/Ganeti/Query
77

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

    
111
ALL_APIDOC_HS_DIRS = \
112
	$(APIDOC_HS_DIR) \
113
	$(APIDOC_HS_DIR)/Ganeti \
114
	$(APIDOC_HS_DIR)/Ganeti/Block \
115
	$(APIDOC_HS_DIR)/Ganeti/Block/Drbd \
116
	$(APIDOC_HS_DIR)/Ganeti/Confd \
117
	$(APIDOC_HS_DIR)/Ganeti/DataCollectors \
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

    
123
BUILDTIME_DIR_AUTOCREATE = \
124
	scripts \
125
	$(APIDOC_DIR) \
126
	$(ALL_APIDOC_HS_DIRS) \
127
	$(APIDOC_PY_DIR) \
128
	$(COVERAGE_DIR) \
129
	$(COVERAGE_HS_DIR) \
130
	$(COVERAGE_PY_DIR) \
131
	.hpc
132

    
133
BUILDTIME_DIRS = \
134
	$(BUILDTIME_DIR_AUTOCREATE) \
135
	doc/html
136

    
137
DIRCHECK_EXCLUDE = \
138
	$(BUILDTIME_DIRS) \
139
	ganeti-[0-9]*.[0-9]*.[0-9]* \
140
	doc/html/_* \
141
	autom4te.cache
142

    
143
# some helper vars
144
COVERAGE_DIR = doc/coverage
145
COVERAGE_PY_DIR = $(COVERAGE_DIR)/py
146
COVERAGE_HS_DIR = $(COVERAGE_DIR)/hs
147
APIDOC_DIR = doc/api
148
APIDOC_PY_DIR = $(APIDOC_DIR)/py
149
APIDOC_HS_DIR = $(APIDOC_DIR)/hs
150

    
151
MAINTAINERCLEANFILES = \
152
	$(docpng) \
153
	$(maninput) \
154
	doc/install-quick.rst \
155
	doc/news.rst \
156
	doc/upgrade.rst \
157
	vcs-version
158

    
159
maintainer-clean-local:
160
	rm -rf $(BUILDTIME_DIRS)
161

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

    
189
GENERATED_FILES = \
190
	$(built_base_sources) \
191
	$(BUILT_PYTHON_SOURCES) \
192
	$(PYTHON_BOOTSTRAP)
193

    
194
HTOOLS_GENERATED_FILES =
195
if WANT_HTOOLS
196
HTOOLS_GENERATED_FILES += $(HS_PROGS)
197
if ENABLE_CONFD
198
HTOOLS_GENERATED_FILES += htools/hconfd htools/ganeti-confd
199
endif
200
endif
201

    
202
built_base_sources = \
203
	stamp-directories \
204
	stamp-srclinks
205

    
206
built_python_base_sources = \
207
	lib/_autoconf.py \
208
	lib/_vcsversion.py
209

    
210
BUILT_PYTHON_SOURCES = \
211
	$(built_python_base_sources) \
212
	lib/_generated_rpc.py
213

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

    
218
# these are all built from the underlying %.in sources
219
BUILT_EXAMPLES = \
220
	doc/examples/ganeti-kvm-poweroff.initd \
221
	doc/examples/ganeti.cron \
222
	doc/examples/ganeti.initd \
223
	doc/examples/ganeti-master-role.ocf \
224
	doc/examples/ganeti-node-role.ocf \
225
	doc/examples/gnt-config-backup \
226
	doc/examples/hooks/ipsec
227

    
228
nodist_pkgpython_PYTHON = \
229
	$(BUILT_PYTHON_SOURCES)
230

    
231
noinst_PYTHON = \
232
	lib/build/__init__.py \
233
	lib/build/shell_example_lexer.py \
234
	lib/build/sphinx_ext.py
235

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

    
275
client_PYTHON = \
276
	lib/client/__init__.py \
277
	lib/client/gnt_backup.py \
278
	lib/client/gnt_cluster.py \
279
	lib/client/gnt_debug.py \
280
	lib/client/gnt_group.py \
281
	lib/client/gnt_instance.py \
282
	lib/client/gnt_job.py \
283
	lib/client/gnt_node.py \
284
	lib/client/gnt_network.py \
285
	lib/client/gnt_os.py
286

    
287
hypervisor_PYTHON = \
288
	lib/hypervisor/__init__.py \
289
	lib/hypervisor/hv_base.py \
290
	lib/hypervisor/hv_chroot.py \
291
	lib/hypervisor/hv_fake.py \
292
	lib/hypervisor/hv_kvm.py \
293
	lib/hypervisor/hv_lxc.py \
294
	lib/hypervisor/hv_xen.py
295

    
296
rapi_PYTHON = \
297
	lib/rapi/__init__.py \
298
	lib/rapi/baserlib.py \
299
	lib/rapi/client.py \
300
	lib/rapi/client_utils.py \
301
	lib/rapi/connector.py \
302
	lib/rapi/rlib2.py \
303
	lib/rapi/testutils.py
304

    
305
http_PYTHON = \
306
	lib/http/__init__.py \
307
	lib/http/auth.py \
308
	lib/http/client.py \
309
	lib/http/server.py
310

    
311
confd_PYTHON = \
312
	lib/confd/__init__.py \
313
	lib/confd/client.py
314

    
315
masterd_PYTHON = \
316
	lib/masterd/__init__.py \
317
	lib/masterd/iallocator.py \
318
	lib/masterd/instance.py
319

    
320
impexpd_PYTHON = \
321
	lib/impexpd/__init__.py
322

    
323
watcher_PYTHON = \
324
	lib/watcher/__init__.py \
325
	lib/watcher/nodemaint.py \
326
	lib/watcher/state.py
327

    
328
server_PYTHON = \
329
	lib/server/__init__.py \
330
	lib/server/masterd.py \
331
	lib/server/noded.py \
332
	lib/server/rapi.py
333

    
334
pytools_PYTHON = \
335
	lib/tools/__init__.py \
336
	lib/tools/ensure_dirs.py \
337
	lib/tools/node_cleanup.py \
338
	lib/tools/node_daemon_setup.py \
339
	lib/tools/prepare_node_join.py
340

    
341
utils_PYTHON = \
342
	lib/utils/__init__.py \
343
	lib/utils/algo.py \
344
	lib/utils/filelock.py \
345
	lib/utils/hash.py \
346
	lib/utils/io.py \
347
	lib/utils/log.py \
348
	lib/utils/mlock.py \
349
	lib/utils/nodesetup.py \
350
	lib/utils/process.py \
351
	lib/utils/retry.py \
352
	lib/utils/text.py \
353
	lib/utils/wrapper.py \
354
	lib/utils/x509.py
355

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

    
409
HS_PROGS = htools/htools htools/mon-collector
410
HS_BIN_ROLES = hbal hscan hspace hinfo hcheck
411
HS_HTOOLS_PROGS = $(HS_BIN_ROLES) hail
412

    
413
HS_ALL_PROGS = \
414
	$(HS_PROGS) \
415
	htest/hpc-htools \
416
	htest/hpc-mon-collector \
417
	htest/test \
418
	htools/hconfd \
419
	htools/rpc-test
420

    
421
HS_PROG_SRCS = $(patsubst %,%.hs,$(HS_ALL_PROGS))
422
HS_BUILT_TEST_HELPERS = $(HS_BIN_ROLES:%=htest/%) htest/hail
423

    
424
HFLAGS = \
425
	-O -Wall -Werror -ihtools \
426
	-fwarn-monomorphism-restriction \
427
	-fwarn-tabs \
428
	$(GHC_BYVERSION_FLAGS)
429

    
430
# extra flags that can be overriden on the command line (e.g. -Wwarn, etc.)
431
HEXTRA =
432
# internal extra flags (used for htest/test mainly)
433
HEXTRA_INT =
434
# exclude options for coverage reports
435
HPCEXCL = --exclude Main \
436
	--exclude Ganeti.Constants \
437
	--exclude Ganeti.HTools.QC \
438
	--exclude Ganeti.THH \
439
	--exclude Ganeti.Version \
440
	--exclude Test.Ganeti.Attoparsec \
441
	--exclude Test.Ganeti.TestCommon \
442
	--exclude Test.Ganeti.TestHTools \
443
	--exclude Test.Ganeti.TestHelper \
444
	--exclude Test.Ganeti.TestImports \
445
	$(patsubst htools.%,--exclude Test.%,$(subst /,.,$(patsubst %.hs,%, $(HS_LIB_SRCS))))
446

    
447
HS_LIB_SRCS = \
448
	htools/Ganeti/Block/Drbd/Types.hs \
449
	htools/Ganeti/Block/Drbd/Parser.hs \
450
	htools/Ganeti/BasicTypes.hs \
451
	htools/Ganeti/Common.hs \
452
	htools/Ganeti/Compat.hs \
453
	htools/Ganeti/Confd/Server.hs \
454
	htools/Ganeti/Confd/Types.hs \
455
	htools/Ganeti/Confd/Utils.hs \
456
	htools/Ganeti/Config.hs \
457
	htools/Ganeti/Daemon.hs \
458
	htools/Ganeti/DataCollectors/Drbd.hs \
459
	htools/Ganeti/DataCollectors/Program.hs \
460
	htools/Ganeti/Errors.hs \
461
	htools/Ganeti/HTools/Backend/IAlloc.hs \
462
	htools/Ganeti/HTools/Backend/Luxi.hs \
463
	htools/Ganeti/HTools/Backend/Rapi.hs \
464
	htools/Ganeti/HTools/Backend/Simu.hs \
465
	htools/Ganeti/HTools/Backend/Text.hs \
466
	htools/Ganeti/HTools/CLI.hs \
467
	htools/Ganeti/HTools/Cluster.hs \
468
	htools/Ganeti/HTools/Container.hs \
469
	htools/Ganeti/HTools/ExtLoader.hs \
470
	htools/Ganeti/HTools/Graph.hs \
471
	htools/Ganeti/HTools/Group.hs \
472
	htools/Ganeti/HTools/Instance.hs \
473
	htools/Ganeti/HTools/Loader.hs \
474
	htools/Ganeti/HTools/Node.hs \
475
	htools/Ganeti/HTools/PeerMap.hs \
476
	htools/Ganeti/HTools/Program.hs \
477
	htools/Ganeti/HTools/Program/Hail.hs \
478
	htools/Ganeti/HTools/Program/Hbal.hs \
479
	htools/Ganeti/HTools/Program/Hcheck.hs \
480
	htools/Ganeti/HTools/Program/Hinfo.hs \
481
	htools/Ganeti/HTools/Program/Hscan.hs \
482
	htools/Ganeti/HTools/Program/Hspace.hs \
483
	htools/Ganeti/HTools/Types.hs \
484
	htools/Ganeti/Hash.hs \
485
	htools/Ganeti/JSON.hs \
486
	htools/Ganeti/Jobs.hs \
487
	htools/Ganeti/Logging.hs \
488
	htools/Ganeti/Luxi.hs \
489
	htools/Ganeti/Network.hs \
490
	htools/Ganeti/Objects.hs \
491
	htools/Ganeti/OpCodes.hs \
492
	htools/Ganeti/OpParams.hs \
493
	htools/Ganeti/Path.hs \
494
	htools/Ganeti/Query/Common.hs \
495
	htools/Ganeti/Query/Filter.hs \
496
	htools/Ganeti/Query/Group.hs \
497
	htools/Ganeti/Query/Language.hs \
498
	htools/Ganeti/Query/Node.hs \
499
	htools/Ganeti/Query/Query.hs \
500
	htools/Ganeti/Query/Server.hs \
501
	htools/Ganeti/Query/Types.hs \
502
	htools/Ganeti/Rpc.hs \
503
	htools/Ganeti/Runtime.hs \
504
	htools/Ganeti/Ssconf.hs \
505
	htools/Ganeti/THH.hs \
506
	htools/Ganeti/Types.hs \
507
	htools/Ganeti/Utils.hs
508

    
509
HS_TEST_SRCS = \
510
	htest/Test/Ganeti/Attoparsec.hs \
511
	htest/Test/Ganeti/BasicTypes.hs \
512
	htest/Test/Ganeti/Block/Drbd/Parser.hs \
513
	htest/Test/Ganeti/Block/Drbd/Types.hs \
514
	htest/Test/Ganeti/Common.hs \
515
	htest/Test/Ganeti/Confd/Types.hs \
516
	htest/Test/Ganeti/Confd/Utils.hs \
517
	htest/Test/Ganeti/Daemon.hs \
518
	htest/Test/Ganeti/Errors.hs \
519
	htest/Test/Ganeti/HTools/Backend/Simu.hs \
520
	htest/Test/Ganeti/HTools/Backend/Text.hs \
521
	htest/Test/Ganeti/HTools/CLI.hs \
522
	htest/Test/Ganeti/HTools/Cluster.hs \
523
	htest/Test/Ganeti/HTools/Container.hs \
524
	htest/Test/Ganeti/HTools/Graph.hs \
525
	htest/Test/Ganeti/HTools/Instance.hs \
526
	htest/Test/Ganeti/HTools/Loader.hs \
527
	htest/Test/Ganeti/HTools/Node.hs \
528
	htest/Test/Ganeti/HTools/PeerMap.hs \
529
	htest/Test/Ganeti/HTools/Types.hs \
530
	htest/Test/Ganeti/JSON.hs \
531
	htest/Test/Ganeti/Jobs.hs \
532
	htest/Test/Ganeti/Luxi.hs \
533
	htest/Test/Ganeti/Network.hs \
534
	htest/Test/Ganeti/Objects.hs \
535
	htest/Test/Ganeti/OpCodes.hs \
536
	htest/Test/Ganeti/Query/Filter.hs \
537
	htest/Test/Ganeti/Query/Language.hs \
538
	htest/Test/Ganeti/Query/Query.hs \
539
	htest/Test/Ganeti/Rpc.hs \
540
	htest/Test/Ganeti/Ssconf.hs \
541
	htest/Test/Ganeti/THH.hs \
542
	htest/Test/Ganeti/TestCommon.hs \
543
	htest/Test/Ganeti/TestHTools.hs \
544
	htest/Test/Ganeti/TestHelper.hs \
545
	htest/Test/Ganeti/Types.hs \
546
	htest/Test/Ganeti/Utils.hs
547

    
548
HS_LIBTEST_SRCS = $(HS_LIB_SRCS) $(HS_TEST_SRCS)
549

    
550
HS_BUILT_SRCS = \
551
	htest/Test/Ganeti/TestImports.hs \
552
	htools/Ganeti/Constants.hs \
553
	htools/Ganeti/Version.hs
554
HS_BUILT_SRCS_IN = $(patsubst %,%.in,$(HS_BUILT_SRCS))
555

    
556
$(RUN_IN_TEMPDIR): | stamp-directories
557

    
558
# Note: we use here an order-only prerequisite, as the contents of
559
# _autoconf.py are not actually influencing the html build output: it
560
# has to exist in order for the sphinx module to be loaded
561
# successfully, but we certainly don't want the docs to be rebuilt if
562
# it changes
563
doc/html/index.html: $(docrst) $(docpng) doc/conf.py configure.ac \
564
	$(RUN_IN_TEMPDIR) lib/build/sphinx_ext.py \
565
	lib/build/shell_example_lexer.py lib/opcodes.py lib/ht.py \
566
	| $(BUILT_PYTHON_SOURCES)
567
	@test -n "$(SPHINX)" || \
568
	    { echo 'sphinx-build' not found during configure; exit 1; }
569
	@mkdir_p@ $(dir $@)
570
	PYTHONPATH=. $(RUN_IN_TEMPDIR) $(SPHINX) -q -W -b html \
571
	    -d . \
572
	    -D version="$(VERSION_MAJOR).$(VERSION_MINOR)" \
573
	    -D release="$(PACKAGE_VERSION)" \
574
	    $(abs_top_srcdir)/doc $(CURDIR)/doc/html
575
	rm -f doc/html/.buildinfo doc/html/objects.inv
576
	touch $@
577

    
578
doc/html: doc/html/index.html
579

    
580
doc/install-quick.rst: INSTALL
581
doc/news.rst: NEWS
582
doc/upgrade.rst: UPGRADE
583

    
584
doc/install-quick.rst doc/news.rst doc/upgrade.rst:
585
	set -e; \
586
	{ echo '.. This file is automatically updated at build time from $<.'; \
587
	  echo '.. Do not edit.'; \
588
	  echo; \
589
	  cat $<; \
590
	} > $@
591

    
592
docdot = \
593
	doc/arch-2.0.dot \
594
	doc/design-2.1-lock-acquire.dot \
595
	doc/design-2.1-lock-release.dot
596

    
597
docpng = $(patsubst %.dot,%.png,$(docdot))
598

    
599
# Things to build but not to install (add it to EXTRA_DIST if it should be
600
# distributed)
601
noinst_DATA = \
602
	doc/html \
603
	$(BUILT_EXAMPLES) \
604
	doc/examples/bash_completion \
605
	doc/examples/bash_completion-debug \
606
	$(manhtml)
607

    
608
gnt_scripts = \
609
	scripts/gnt-backup \
610
	scripts/gnt-cluster \
611
	scripts/gnt-debug \
612
	scripts/gnt-group \
613
	scripts/gnt-instance \
614
	scripts/gnt-job \
615
	scripts/gnt-network \
616
	scripts/gnt-node \
617
	scripts/gnt-os
618

    
619
PYTHON_BOOTSTRAP_SBIN = \
620
	daemons/ganeti-masterd \
621
	daemons/ganeti-noded \
622
	daemons/ganeti-rapi \
623
	daemons/ganeti-watcher \
624
	$(gnt_scripts)
625

    
626
PYTHON_BOOTSTRAP = \
627
	$(PYTHON_BOOTSTRAP_SBIN) \
628
	tools/ensure-dirs \
629
	tools/node-cleanup \
630
	tools/node-daemon-setup \
631
	tools/prepare-node-join
632

    
633
qa_scripts = \
634
	qa/__init__.py \
635
	qa/ganeti-qa.py \
636
	qa/qa_cluster.py \
637
	qa/qa_config.py \
638
	qa/qa_daemon.py \
639
	qa/qa_env.py \
640
	qa/qa_error.py \
641
	qa/qa_group.py \
642
	qa/qa_instance.py \
643
	qa/qa_job.py \
644
	qa/qa_node.py \
645
	qa/qa_os.py \
646
	qa/qa_rapi.py \
647
	qa/qa_tags.py \
648
	qa/qa_utils.py
649

    
650
bin_SCRIPTS =
651
if WANT_HTOOLS
652
bin_SCRIPTS += $(filter-out htools/hail,$(HS_PROGS))
653
install-exec-hook:
654
	@mkdir_p@ $(DESTDIR)$(iallocatorsdir)
655
# FIXME: this is a hardcoded logic, instead of auto-resolving
656
	$(LN_S) -f ../../../bin/htools \
657
	  $(DESTDIR)$(iallocatorsdir)/hail
658
	for role in $(HS_BIN_ROLES); do \
659
	  $(LN_S) -f htools $(DESTDIR)$(bindir)/$$role ; \
660
	done
661
endif
662

    
663
$(HS_ALL_PROGS): %: %.hs $(HS_LIBTEST_SRCS) $(HS_BUILT_SRCS) Makefile
664
	@if [ "$(notdir $@)" = "test" ] && [ "$(HTOOLS_NODEV)" ]; then \
665
	  echo "Error: cannot run unittests without the development" \
666
	       " libraries (see devnotes.rst)" 1>&2; \
667
	  exit 1; \
668
	fi
669
	@rm -f $(notdir $@).tix
670
	$(GHC) --make \
671
	  $(HFLAGS) \
672
	  $(HTOOLS_NOCURL) $(HTOOLS_PARALLEL3) $(HTOOLS_REGEX_PCRE) \
673
	  -osuf $(notdir $@).o -hisuf $(notdir $@).hi \
674
	  $(HEXTRA) $(HEXTRA_INT) $@
675
	@touch "$@"
676

    
677
# for the htest/test binary, we need to enable profiling/coverage
678
htest/test: HEXTRA_INT=-fhpc -ihtest
679

    
680
# we compile the hpc-htools binary with the program coverage
681
htest/hpc-htools: HEXTRA_INT=-fhpc
682

    
683
# we compile the hpc-mon-collector binary with the program coverage
684
htest/hpc-mon-collector: HEXTRA_INT=-fhpc
685

    
686
# test dependency
687
htest/offline-tests.sh: htest/hpc-htools htest/hpc-mon-collector
688

    
689
# rules for building profiling-enabled versions of the haskell
690
# programs: hs-prof does the full two-step build, whereas
691
# hs-prof-quick does only the final rebuild (hs-prof must have been
692
# run before)
693
.PHONY: hs-prof hs-prof-quick
694
hs-prof:
695
	$(MAKE) $(AM_MAKEFLAGS) clean
696
	$(MAKE) $(AM_MAKEFLAGS) $(HS_ALL_PROGS) HEXTRA="-osuf o"
697
	rm -f $(HS_ALL_PROGS)
698
	$(MAKE) $(AM_MAKEFLAGS) hs-prof-quick
699

    
700
hs-prof-quick:
701
	$(MAKE) $(AM_MAKEFLAGS) $(HS_ALL_PROGS) HEXTRA="-osuf prof_o -prof -auto-all"
702

    
703
dist_sbin_SCRIPTS = \
704
	tools/ganeti-listrunner
705

    
706
nodist_sbin_SCRIPTS = \
707
	$(PYTHON_BOOTSTRAP_SBIN) \
708
	daemons/ganeti-cleaner
709

    
710
if ENABLE_CONFD
711
htools/ganeti-confd: htools/hconfd
712
	cp -f $< $@
713

    
714
nodist_sbin_SCRIPTS += htools/ganeti-confd
715
endif
716

    
717
python_scripts = \
718
	tools/burnin \
719
	tools/cfgshell \
720
	tools/cfgupgrade \
721
	tools/cfgupgrade12 \
722
	tools/cluster-merge \
723
	tools/confd-client \
724
	tools/fmtjson \
725
	tools/lvmstrap \
726
	tools/move-instance \
727
	tools/ovfconverter \
728
	tools/sanitize-config
729

    
730
dist_tools_SCRIPTS = \
731
	$(python_scripts) \
732
	tools/kvm-console-wrapper \
733
	tools/master-ip-setup \
734
	tools/xen-console-wrapper
735

    
736
nodist_tools_python_scripts = \
737
	tools/node-cleanup
738

    
739
nodist_tools_SCRIPTS = \
740
	$(nodist_tools_python_scripts) \
741
	tools/vcluster-setup
742

    
743
pkglib_python_scripts = \
744
	daemons/import-export \
745
	tools/check-cert-expired
746

    
747
nodist_pkglib_python_scripts = \
748
	tools/ensure-dirs \
749
	tools/node-daemon-setup \
750
	tools/prepare-node-join
751

    
752
myexeclib_SCRIPTS = \
753
	daemons/daemon-util \
754
	tools/kvm-ifup \
755
	$(pkglib_python_scripts) \
756
	htools/mon-collector
757

    
758
nodist_myexeclib_SCRIPTS = \
759
	$(nodist_pkglib_python_scripts)
760

    
761
EXTRA_DIST = \
762
	NEWS \
763
	UPGRADE \
764
	epydoc.conf.in \
765
	pylintrc \
766
	autotools/build-bash-completion \
767
	autotools/build-rpc \
768
	autotools/check-header \
769
	autotools/check-imports \
770
	autotools/check-man-dashes \
771
	autotools/check-man-warnings \
772
	autotools/check-news \
773
	autotools/check-python-code \
774
	autotools/check-tar \
775
	autotools/check-version \
776
	autotools/convert-constants \
777
	autotools/docpp \
778
	autotools/gen-coverage \
779
	autotools/testrunner \
780
	autotools/wrong-hardcoded-paths \
781
	$(RUN_IN_TEMPDIR) \
782
	daemons/daemon-util.in \
783
	daemons/ganeti-cleaner.in \
784
	$(pkglib_python_scripts) \
785
	devel/upload \
786
	tools/kvm-ifup.in \
787
	tools/vcluster-setup.in \
788
	$(docdot) \
789
	$(docpng) \
790
	$(docrst) \
791
	doc/conf.py \
792
	doc/html \
793
	$(BUILT_EXAMPLES:%=%.in) \
794
	doc/examples/ganeti.default \
795
	doc/examples/ganeti.default-debug \
796
	doc/examples/hooks/ethers \
797
	doc/examples/gnt-debug/README \
798
	doc/examples/gnt-debug/delay0.json \
799
	doc/examples/gnt-debug/delay50.json \
800
	test/lockperf.py \
801
	test/testutils.py \
802
	test/mocks.py \
803
	$(dist_TESTS) \
804
	$(TEST_FILES) \
805
	man/footer.rst \
806
	$(manrst) \
807
	$(maninput) \
808
	qa/qa-sample.json \
809
	$(qa_scripts) \
810
	$(HS_LIBTEST_SRCS) $(HS_BUILT_SRCS_IN) \
811
	$(HS_PROG_SRCS) \
812
	htools/lint-hints.hs \
813
	htest/cli-tests-defs.sh \
814
	htest/offline-test.sh \
815
	.ghci
816

    
817
man_MANS = \
818
	man/ganeti-cleaner.8 \
819
	man/ganeti-confd.8 \
820
	man/ganeti-listrunner.8 \
821
	man/ganeti-masterd.8 \
822
	man/ganeti-noded.8 \
823
	man/ganeti-os-interface.7 \
824
	man/ganeti-rapi.8 \
825
	man/ganeti-watcher.8 \
826
	man/ganeti.7 \
827
	man/gnt-backup.8 \
828
	man/gnt-cluster.8 \
829
	man/gnt-debug.8 \
830
	man/gnt-group.8 \
831
	man/gnt-network.8 \
832
	man/gnt-instance.8 \
833
	man/gnt-job.8 \
834
	man/gnt-node.8 \
835
	man/gnt-os.8 \
836
	man/hail.1 \
837
	man/hbal.1 \
838
	man/hcheck.1 \
839
	man/hinfo.1 \
840
	man/hscan.1 \
841
	man/hspace.1 \
842
	man/htools.1 \
843
	man/mon-collector.7
844

    
845
manrst = $(patsubst %.1,%.rst,$(patsubst %.7,%.rst,$(patsubst %.8,%.rst,$(man_MANS))))
846
manhtml = $(patsubst %.rst,%.html,$(manrst))
847
mangen = $(patsubst %.rst,%.gen,$(manrst))
848
maninput = \
849
	$(patsubst %.1,%.1.in,$(patsubst %.7,%.7.in,$(patsubst %.8,%.8.in,$(man_MANS)))) \
850
	$(patsubst %.html,%.html.in,$(manhtml)) \
851
	man/footer.man man/footer.html $(mangen)
852

    
853
TEST_FILES = \
854
	htest/data/common-suffix.data \
855
	htest/data/hail-alloc-drbd.json \
856
	htest/data/hail-change-group.json \
857
	htest/data/hail-invalid-reloc.json \
858
	htest/data/hail-node-evac.json \
859
	htest/data/hail-reloc-drbd.json \
860
	htest/data/hbal-excl-tags.data \
861
	htest/data/hbal-split-insts.data \
862
	htest/data/invalid-node.data \
863
	htest/data/missing-resources.data \
864
	htest/data/rapi/groups.json \
865
	htest/data/rapi/info.json \
866
	htest/data/rapi/instances.json \
867
	htest/data/rapi/nodes.json \
868
	htest/shelltests/htools-balancing.test \
869
	htest/shelltests/htools-basic.test \
870
	htest/shelltests/htools-dynutil.test \
871
	htest/shelltests/htools-excl.test \
872
	htest/shelltests/htools-hail.test \
873
	htest/shelltests/htools-hspace.test \
874
	htest/shelltests/htools-invalid.test \
875
	htest/shelltests/htools-multi-group.test \
876
	htest/shelltests/htools-no-backend.test \
877
	htest/shelltests/htools-rapi.test \
878
	htest/shelltests/htools-single-group.test \
879
	htest/shelltests/htools-text-backend.test \
880
	htest/shelltests/htools-mon-collector.test \
881
	test/data/bdev-drbd-8.0.txt \
882
	test/data/bdev-drbd-8.3.txt \
883
	test/data/bdev-drbd-disk.txt \
884
	test/data/bdev-drbd-net-ip4.txt \
885
	test/data/bdev-drbd-net-ip6.txt \
886
	test/data/cert1.pem \
887
	test/data/cert2.pem \
888
	test/data/ip-addr-show-dummy0.txt \
889
	test/data/ip-addr-show-lo-ipv4.txt \
890
	test/data/ip-addr-show-lo-ipv6.txt \
891
	test/data/ip-addr-show-lo-oneline-ipv4.txt \
892
	test/data/ip-addr-show-lo-oneline-ipv6.txt \
893
	test/data/ip-addr-show-lo-oneline.txt \
894
	test/data/ip-addr-show-lo.txt \
895
	test/data/kvm_0.12.5_help.txt \
896
	test/data/kvm_0.15.90_help.txt \
897
	test/data/kvm_0.9.1_help.txt \
898
	test/data/kvm_1.0_help.txt \
899
	test/data/ovfdata/compr_disk.vmdk.gz \
900
	test/data/ovfdata/config.ini \
901
	test/data/ovfdata/corrupted_resources.ovf \
902
	test/data/ovfdata/empty.ini \
903
	test/data/ovfdata/empty.ovf \
904
	test/data/ovfdata/ganeti.mf \
905
	test/data/ovfdata/ganeti.ovf \
906
	test/data/ovfdata/gzip_disk.ovf \
907
	test/data/ovfdata/new_disk.vmdk \
908
	test/data/ovfdata/no_disk.ini \
909
	test/data/ovfdata/no_disk_in_ref.ovf \
910
	test/data/ovfdata/no_os.ini \
911
	test/data/ovfdata/no_ovf.ova \
912
	test/data/ovfdata/other/rawdisk.raw \
913
	test/data/ovfdata/ova.ova \
914
	test/data/ovfdata/rawdisk.raw \
915
	test/data/ovfdata/second_disk.vmdk \
916
	test/data/ovfdata/unsafe_path.ini \
917
	test/data/ovfdata/virtualbox.ovf \
918
	test/data/ovfdata/wrong_config.ini \
919
	test/data/ovfdata/wrong_extension.ovd \
920
	test/data/ovfdata/wrong_manifest.mf \
921
	test/data/ovfdata/wrong_manifest.ovf \
922
	test/data/ovfdata/wrong_ova.ova \
923
	test/data/ovfdata/wrong_xml.ovf \
924
	test/data/proc_drbd8.txt \
925
	test/data/proc_drbd80-emptyline.txt \
926
	test/data/proc_drbd83.txt \
927
	test/data/proc_drbd83_sync.txt \
928
	test/data/proc_drbd83_sync_want.txt \
929
	test/data/proc_drbd83_sync_krnl2.6.39.txt \
930
	test/data/sys_drbd_usermode_helper.txt \
931
	test/data/vgreduce-removemissing-2.02.02.txt \
932
	test/data/vgreduce-removemissing-2.02.66-fail.txt \
933
	test/data/vgreduce-removemissing-2.02.66-ok.txt \
934
	test/data/vgs-missing-pvs-2.02.02.txt \
935
	test/data/vgs-missing-pvs-2.02.66.txt \
936
	test/ganeti-cli.test \
937
	test/gnt-cli.test \
938
	test/import-export_unittest-helper
939

    
940
python_tests = \
941
	doc/examples/rapi_testutils.py \
942
	test/cfgupgrade_unittest.py \
943
	test/docs_unittest.py \
944
	test/ganeti.asyncnotifier_unittest.py \
945
	test/ganeti.backend_unittest-runasroot.py \
946
	test/ganeti.backend_unittest.py \
947
	test/ganeti.bdev_unittest.py \
948
	test/ganeti.cli_unittest.py \
949
	test/ganeti.client.gnt_cluster_unittest.py \
950
	test/ganeti.client.gnt_instance_unittest.py \
951
	test/ganeti.client.gnt_job_unittest.py \
952
	test/ganeti.cmdlib_unittest.py \
953
	test/ganeti.compat_unittest.py \
954
	test/ganeti.confd.client_unittest.py \
955
	test/ganeti.config_unittest.py \
956
	test/ganeti.constants_unittest.py \
957
	test/ganeti.daemon_unittest.py \
958
	test/ganeti.errors_unittest.py \
959
	test/ganeti.hooks_unittest.py \
960
	test/ganeti.ht_unittest.py \
961
	test/ganeti.http_unittest.py \
962
	test/ganeti.hypervisor.hv_chroot_unittest.py \
963
	test/ganeti.hypervisor.hv_fake_unittest.py \
964
	test/ganeti.hypervisor.hv_kvm_unittest.py \
965
	test/ganeti.hypervisor.hv_lxc_unittest.py \
966
	test/ganeti.hypervisor.hv_xen_unittest.py \
967
	test/ganeti.hypervisor_unittest.py \
968
	test/ganeti.impexpd_unittest.py \
969
	test/ganeti.jqueue_unittest.py \
970
	test/ganeti.jstore_unittest.py \
971
	test/ganeti.locking_unittest.py \
972
	test/ganeti.luxi_unittest.py \
973
	test/ganeti.masterd.iallocator_unittest.py \
974
	test/ganeti.masterd.instance_unittest.py \
975
	test/ganeti.mcpu_unittest.py \
976
	test/ganeti.netutils_unittest.py \
977
	test/ganeti.objects_unittest.py \
978
	test/ganeti.objectutils_unittest.py \
979
	test/ganeti.opcodes_unittest.py \
980
	test/ganeti.ovf_unittest.py \
981
	test/ganeti.qlang_unittest.py \
982
	test/ganeti.query_unittest.py \
983
	test/ganeti.rapi.baserlib_unittest.py \
984
	test/ganeti.rapi.client_unittest.py \
985
	test/ganeti.rapi.resources_unittest.py \
986
	test/ganeti.rapi.rlib2_unittest.py \
987
	test/ganeti.rapi.testutils_unittest.py \
988
	test/ganeti.rpc_unittest.py \
989
	test/ganeti.runtime_unittest.py \
990
	test/ganeti.serializer_unittest.py \
991
	test/ganeti.server.rapi_unittest.py \
992
	test/ganeti.ssconf_unittest.py \
993
	test/ganeti.ssh_unittest.py \
994
	test/ganeti.storage_unittest.py \
995
	test/ganeti.tools.ensure_dirs_unittest.py \
996
	test/ganeti.tools.node_daemon_setup_unittest.py \
997
	test/ganeti.tools.prepare_node_join_unittest.py \
998
	test/ganeti.uidpool_unittest.py \
999
	test/ganeti.utils.algo_unittest.py \
1000
	test/ganeti.utils.filelock_unittest.py \
1001
	test/ganeti.utils.hash_unittest.py \
1002
	test/ganeti.utils.io_unittest-runasroot.py \
1003
	test/ganeti.utils.io_unittest.py \
1004
	test/ganeti.utils.log_unittest.py \
1005
	test/ganeti.utils.mlock_unittest.py \
1006
	test/ganeti.utils.nodesetup_unittest.py \
1007
	test/ganeti.utils.process_unittest.py \
1008
	test/ganeti.utils.retry_unittest.py \
1009
	test/ganeti.utils.text_unittest.py \
1010
	test/ganeti.utils.wrapper_unittest.py \
1011
	test/ganeti.utils.x509_unittest.py \
1012
	test/ganeti.utils_unittest.py \
1013
	test/ganeti.vcluster_unittest.py \
1014
	test/ganeti.workerpool_unittest.py \
1015
	test/pycurl_reset_unittest.py \
1016
	test/qa.qa_config_unittest.py \
1017
	test/tempfile_fork_unittest.py
1018

    
1019
haskell_tests = htest/test
1020

    
1021
dist_TESTS = \
1022
	test/check-cert-expired_unittest.bash \
1023
	test/daemon-util_unittest.bash \
1024
	test/ganeti-cleaner_unittest.bash \
1025
	test/import-export_unittest.bash \
1026
	test/cli-test.bash \
1027
	test/bash_completion.bash \
1028
	$(python_tests)
1029

    
1030
nodist_TESTS =
1031
check_SCRIPTS =
1032

    
1033
if WANT_HTOOLSTESTS
1034
nodist_TESTS += $(haskell_tests)
1035
dist_TESTS += htest/offline-test.sh
1036
check_SCRIPTS += \
1037
	htest/hpc-htools \
1038
	htest/hpc-mon-collector \
1039
	$(HS_BUILT_TEST_HELPERS)
1040
endif
1041

    
1042
TESTS = $(dist_TESTS) $(nodist_TESTS)
1043

    
1044
# Environment for all tests
1045
PLAIN_TESTS_ENVIRONMENT = \
1046
	PYTHONPATH=. \
1047
	TOP_SRCDIR=$(abs_top_srcdir) TOP_BUILDDIR=$(abs_top_builddir) \
1048
	PYTHON=$(PYTHON) FAKEROOT=$(FAKEROOT_PATH) \
1049
	$(RUN_IN_TEMPDIR)
1050

    
1051
# Environment for tests run by automake
1052
TESTS_ENVIRONMENT = \
1053
	$(PLAIN_TESTS_ENVIRONMENT) $(abs_top_srcdir)/autotools/testrunner
1054

    
1055
all_python_code = \
1056
	$(dist_sbin_SCRIPTS) \
1057
	$(python_scripts) \
1058
	$(pkglib_python_scripts) \
1059
	$(nodist_pkglib_python_scripts) \
1060
	$(nodist_tools_python_scripts) \
1061
	$(python_tests) \
1062
	$(pkgpython_PYTHON) \
1063
	$(client_PYTHON) \
1064
	$(hypervisor_PYTHON) \
1065
	$(rapi_PYTHON) \
1066
	$(server_PYTHON) \
1067
	$(pytools_PYTHON) \
1068
	$(http_PYTHON) \
1069
	$(confd_PYTHON) \
1070
	$(masterd_PYTHON) \
1071
	$(impexpd_PYTHON) \
1072
	$(utils_PYTHON) \
1073
	$(watcher_PYTHON) \
1074
	$(noinst_PYTHON) \
1075
	$(qa_scripts)
1076

    
1077
srclink_files = \
1078
	man/footer.rst \
1079
	test/check-cert-expired_unittest.bash \
1080
	test/daemon-util_unittest.bash \
1081
	test/ganeti-cleaner_unittest.bash \
1082
	test/import-export_unittest.bash \
1083
	test/cli-test.bash \
1084
	test/bash_completion.bash \
1085
	htest/offline-test.sh \
1086
	htest/cli-tests-defs.sh \
1087
	$(all_python_code) \
1088
	$(HS_LIBTEST_SRCS) $(HS_PROG_SRCS)
1089

    
1090
check_python_code = \
1091
	$(BUILD_BASH_COMPLETION) \
1092
	$(CHECK_IMPORTS) \
1093
	$(CHECK_HEADER) \
1094
	$(DOCPP) \
1095
	$(all_python_code)
1096

    
1097
lint_python_code = \
1098
	ganeti \
1099
	ganeti/http/server.py \
1100
	$(dist_sbin_SCRIPTS) \
1101
	$(python_scripts) \
1102
	$(pkglib_python_scripts) \
1103
	$(BUILD_BASH_COMPLETION) \
1104
	$(CHECK_IMPORTS) \
1105
	$(CHECK_HEADER) \
1106
	$(DOCPP) \
1107
	$(PYTHON_BOOTSTRAP)
1108

    
1109
standalone_python_modules = \
1110
	lib/rapi/client.py \
1111
	tools/ganeti-listrunner
1112

    
1113
pep8_python_code = \
1114
	ganeti \
1115
	ganeti/http/server.py \
1116
	$(dist_sbin_SCRIPTS) \
1117
	$(python_scripts) \
1118
	$(pkglib_python_scripts) \
1119
	$(BUILD_BASH_COMPLETION) \
1120
	$(CHECK_HEADER) \
1121
	$(DOCPP) \
1122
	$(PYTHON_BOOTSTRAP) \
1123
	qa
1124

    
1125
test/daemon-util_unittest.bash: daemons/daemon-util
1126

    
1127
test/ganeti-cleaner_unittest.bash: daemons/ganeti-cleaner
1128

    
1129
test/bash_completion.bash: doc/examples/bash_completion-debug
1130

    
1131
tools/kvm-ifup: tools/kvm-ifup.in $(REPLACE_VARS_SED)
1132
	sed -f $(REPLACE_VARS_SED) < $< > $@
1133
	chmod +x $@
1134

    
1135
tools/vcluster-setup: tools/vcluster-setup.in $(REPLACE_VARS_SED)
1136
	sed -f $(REPLACE_VARS_SED) < $< > $@
1137
	chmod +x $@
1138

    
1139
daemons/%:: daemons/%.in $(REPLACE_VARS_SED)
1140
	sed -f $(REPLACE_VARS_SED) < $< > $@
1141
	chmod +x $@
1142

    
1143
doc/examples/%:: doc/examples/%.in $(REPLACE_VARS_SED)
1144
	sed -f $(REPLACE_VARS_SED) < $< > $@
1145

    
1146
doc/examples/bash_completion: BC_ARGS = --compact
1147
doc/examples/bash_completion-debug: BC_ARGS =
1148

    
1149
doc/examples/bash_completion doc/examples/bash_completion-debug: \
1150
	$(BUILD_BASH_COMPLETION) $(RUN_IN_TEMPDIR) \
1151
	lib/cli.py $(gnt_scripts) $(client_PYTHON) tools/burnin \
1152
	daemons/ganeti-cleaner \
1153
	$(GENERATED_FILES) $(HTOOLS_GENERATED_FILES)
1154
	PYTHONPATH=. $(RUN_IN_TEMPDIR) \
1155
	  $(CURDIR)/$(BUILD_BASH_COMPLETION) $(BC_ARGS) > $@
1156

    
1157
doc/%.png: doc/%.dot
1158
	@test -n "$(DOT)" || { echo 'dot' not found during configure; exit 1; }
1159
	$(DOT) -Tpng -o $@ $<
1160

    
1161
man/footer.man: man/footer.rst
1162
	@test -n "$(PANDOC)" || \
1163
	  { echo 'pandoc' not found during configure; exit 1; }
1164
	$(PANDOC) -f rst -t man -o $@ $<
1165

    
1166
man/footer.html: man/footer.rst
1167
	@test -n "$(PANDOC)" || \
1168
	  { echo 'pandoc' not found during configure; exit 1; }
1169
	$(PANDOC) -f rst -t html -o $@ $<
1170

    
1171
man/%.gen: man/%.rst lib/query.py lib/build/sphinx_ext.py \
1172
	lib/build/shell_example_lexer.py \
1173
	| $(RUN_IN_TEMPDIR) $(BUILT_PYTHON_SOURCES)
1174
	@echo "Checking $< for hardcoded paths..."
1175
	@if grep -nEf autotools/wrong-hardcoded-paths $<; then \
1176
	  echo "Man page $< has harcoded paths (see above)!" 1>&2 ; \
1177
	  exit 1; \
1178
	fi
1179
	set -e ; \
1180
	trap 'echo auto-removing $@; rm $@' EXIT; \
1181
	PYTHONPATH=. $(RUN_IN_TEMPDIR) $(CURDIR)/$(DOCPP) < $< > $@ ;\
1182
	trap - EXIT
1183

    
1184
man/%.7.in man/%.8.in man/%.1.in: man/%.gen man/footer.man
1185
	@test -n "$(PANDOC)" || \
1186
	  { echo 'pandoc' not found during configure; exit 1; }
1187
	set -o pipefail ; \
1188
	trap 'echo auto-removing $@; rm $@' EXIT; \
1189
	$(PANDOC) -s -f rst -t man -A man/footer.man $< | \
1190
	  sed -e 's/\\@/@/g' > $@; \
1191
	if test -n "$(MAN_HAS_WARNINGS)"; then $(CHECK_MAN_WARNINGS) $@; fi; \
1192
	$(CHECK_MAN_DASHES) $@; \
1193
	trap - EXIT
1194

    
1195

    
1196
man/%.html.in: man/%.gen man/footer.html
1197
	@test -n "$(PANDOC)" || \
1198
	  { echo 'pandoc' not found during configure; exit 1; }
1199
	set -o pipefail ; \
1200
	$(PANDOC) -s -f rst -t html -A man/footer.html $< | \
1201
	  sed -e 's/\\@/@/g' > $@
1202

    
1203
man/%: man/%.in  $(REPLACE_VARS_SED)
1204
	sed -f $(REPLACE_VARS_SED) < $< > $@
1205

    
1206
epydoc.conf: epydoc.conf.in $(REPLACE_VARS_SED)
1207
	sed -f $(REPLACE_VARS_SED) < $< > $@
1208

    
1209
vcs-version:
1210
	if test -d .git; then \
1211
	  git describe > $@; \
1212
	elif test ! -f $@ ; then \
1213
	  echo "Cannot auto-generate $@ file"; exit 1; \
1214
	fi
1215

    
1216
.PHONY: clean-vcs-version
1217
clean-vcs-version:
1218
	rm -f vcs-version
1219

    
1220
.PHONY: regen-vcs-version
1221
regen-vcs-version:
1222
	@set -e; \
1223
	cd $(srcdir); \
1224
	if test -d .git; then \
1225
	  T=`mktemp` ; trap 'rm -f $$T' EXIT; \
1226
	  git describe > $$T; \
1227
	  if ! cmp --quiet $$T vcs-version; then \
1228
	    mv $$T vcs-version; \
1229
	  fi; \
1230
	fi
1231

    
1232
htools/Ganeti/Version.hs: htools/Ganeti/Version.hs.in \
1233
	vcs-version $(built_base_sources)
1234
	set -e; \
1235
	VCSVER=`cat $(abs_top_srcdir)/vcs-version`; \
1236
	sed -e "s/%ver%/$$VCSVER/" < $< > $@
1237

    
1238
htools/Ganeti/Constants.hs: htools/Ganeti/Constants.hs.in \
1239
	lib/constants.py lib/_autoconf.py lib/luxi.py lib/errors.py \
1240
	lib/jstore.py \
1241
	$(CONVERT_CONSTANTS) $(built_base_sources) \
1242
	| lib/_vcsversion.py
1243
	set -e; \
1244
	{ cat $< ; PYTHONPATH=. $(CONVERT_CONSTANTS); } > $@
1245

    
1246
htest/Test/Ganeti/TestImports.hs: htest/Test/Ganeti/TestImports.hs.in \
1247
	$(built_base_sources)
1248
	set -e; \
1249
	{ cat $< ; \
1250
	  echo ; \
1251
	  for name in $(filter-out Ganeti.THH,$(subst /,.,$(patsubst %.hs,%,$(patsubst htools/%,%,$(HS_LIB_SRCS))))) ; do \
1252
	    echo "import $$name ()" ; \
1253
	  done ; \
1254
	} > $@
1255

    
1256
lib/_autoconf.py: Makefile | stamp-directories
1257
	set -e; \
1258
	{ echo '# This file is automatically generated, do not edit!'; \
1259
	  echo '#'; \
1260
	  echo ''; \
1261
	  echo '"""Build-time configuration for Ganeti.'; \
1262
	  echo '';\
1263
	  echo 'This file is autogenerated by the build process.'; \
1264
	  echo 'For any changes you need to re-run ./configure (and'; \
1265
	  echo 'not edit by hand).'; \
1266
	  echo ''; \
1267
	  echo '"""'; \
1268
	  echo ''; \
1269
	  echo '# pylint: disable=C0301,C0324'; \
1270
	  echo '# because this is autogenerated, we do not want'; \
1271
	  echo '# style warnings' ; \
1272
	  echo ''; \
1273
	  echo "PACKAGE_VERSION = '$(PACKAGE_VERSION)'"; \
1274
	  echo "VERSION_MAJOR = '$(VERSION_MAJOR)'"; \
1275
	  echo "VERSION_MINOR = '$(VERSION_MINOR)'"; \
1276
	  echo "VERSION_REVISION = '$(VERSION_REVISION)'"; \
1277
	  echo "VERSION_SUFFIX = '$(VERSION_SUFFIX)'"; \
1278
	  echo "VERSION_FULL = '$(VERSION_FULL)'"; \
1279
	  echo "LOCALSTATEDIR = '$(localstatedir)'"; \
1280
	  echo "SYSCONFDIR = '$(sysconfdir)'"; \
1281
	  echo "SSH_CONFIG_DIR = '$(SSH_CONFIG_DIR)'"; \
1282
	  echo "SSH_LOGIN_USER = '$(SSH_LOGIN_USER)'"; \
1283
	  echo "SSH_CONSOLE_USER = '$(SSH_CONSOLE_USER)'"; \
1284
	  echo "EXPORT_DIR = '$(EXPORT_DIR)'"; \
1285
	  echo "OS_SEARCH_PATH = [$(OS_SEARCH_PATH)]"; \
1286
	  echo "XEN_BOOTLOADER = '$(XEN_BOOTLOADER)'"; \
1287
	  echo "XEN_KERNEL = '$(XEN_KERNEL)'"; \
1288
	  echo "XEN_INITRD = '$(XEN_INITRD)'"; \
1289
	  echo "KVM_KERNEL = '$(KVM_KERNEL)'"; \
1290
	  echo "FILE_STORAGE_DIR = '$(FILE_STORAGE_DIR)'"; \
1291
	  echo "ENABLE_FILE_STORAGE = $(ENABLE_FILE_STORAGE)"; \
1292
	  echo "SHARED_FILE_STORAGE_DIR = '$(SHARED_FILE_STORAGE_DIR)'"; \
1293
	  echo "ENABLE_SHARED_FILE_STORAGE = $(ENABLE_SHARED_FILE_STORAGE)"; \
1294
	  echo "IALLOCATOR_SEARCH_PATH = [$(IALLOCATOR_SEARCH_PATH)]"; \
1295
	  echo "KVM_PATH = '$(KVM_PATH)'"; \
1296
	  echo "IP_PATH = '$(IP_PATH)'"; \
1297
	  echo "SOCAT_PATH = '$(SOCAT)'"; \
1298
	  echo "SOCAT_USE_ESCAPE = $(SOCAT_USE_ESCAPE)"; \
1299
	  echo "SOCAT_USE_COMPRESS = $(SOCAT_USE_COMPRESS)"; \
1300
	  echo "LVM_STRIPECOUNT = $(LVM_STRIPECOUNT)"; \
1301
	  echo "TOOLSDIR = '$(toolsdir)'"; \
1302
	  echo "GNT_SCRIPTS = [$(foreach i,$(notdir $(gnt_scripts)),'$(i)',)]"; \
1303
	  echo "HTOOLS_PROGS = [$(foreach i,$(HS_HTOOLS_PROGS),'$(i)',)]"; \
1304
	  echo "PKGLIBDIR = '$(pkglibdir)'"; \
1305
	  echo "DRBD_BARRIERS = '$(DRBD_BARRIERS)'"; \
1306
	  echo "DRBD_NO_META_FLUSH = $(DRBD_NO_META_FLUSH)"; \
1307
	  echo "SYSLOG_USAGE = '$(SYSLOG_USAGE)'"; \
1308
	  echo "DAEMONS_GROUP = '$(DAEMONS_GROUP)'"; \
1309
	  echo "ADMIN_GROUP = '$(ADMIN_GROUP)'"; \
1310
	  echo "MASTERD_USER = '$(MASTERD_USER)'"; \
1311
	  echo "MASTERD_GROUP = '$(MASTERD_GROUP)'"; \
1312
	  echo "RAPI_USER = '$(RAPI_USER)'"; \
1313
	  echo "RAPI_GROUP = '$(RAPI_GROUP)'"; \
1314
	  echo "CONFD_USER = '$(CONFD_USER)'"; \
1315
	  echo "CONFD_GROUP = '$(CONFD_GROUP)'"; \
1316
	  echo "NODED_USER = '$(NODED_USER)'"; \
1317
	  echo "NODED_GROUP = '$(NODED_GROUP)'"; \
1318
	  echo "DISK_SEPARATOR = '$(DISK_SEPARATOR)'"; \
1319
	  echo "QEMUIMG_PATH = '$(QEMUIMG_PATH)'"; \
1320
	  echo "HTOOLS = True"; \
1321
	  echo "ENABLE_CONFD = $(ENABLE_CONFD)"; \
1322
	  echo "XEN_CMD = '$(XEN_CMD)'"; \
1323
	  echo "ENABLE_SPLIT_QUERY = $(ENABLE_SPLIT_QUERY)"; \
1324
	  echo "ENABLE_RESTRICTED_COMMANDS = $(ENABLE_RESTRICTED_COMMANDS)"; \
1325
	} > $@
1326

    
1327
lib/_vcsversion.py: Makefile vcs-version | stamp-directories
1328
	set -e; \
1329
	VCSVER=`cat $(abs_top_srcdir)/vcs-version`; \
1330
	{ echo '# This file is automatically generated, do not edit!'; \
1331
	  echo '#'; \
1332
	  echo ''; \
1333
	  echo '"""Build-time VCS version number for Ganeti.'; \
1334
	  echo '';\
1335
	  echo 'This file is autogenerated by the build process.'; \
1336
	  echo 'For any changes you need to re-run ./configure (and'; \
1337
	  echo 'not edit by hand).'; \
1338
	  echo ''; \
1339
	  echo '"""'; \
1340
	  echo ''; \
1341
	  echo '# pylint: disable=C0301,C0324'; \
1342
	  echo '# because this is autogenerated, we do not want'; \
1343
	  echo '# style warnings' ; \
1344
	  echo ''; \
1345
	  echo "VCS_VERSION = '$$VCSVER'"; \
1346
	} > $@
1347

    
1348
lib/_generated_rpc.py: lib/rpc_defs.py $(BUILD_RPC)
1349
	PYTHONPATH=. $(RUN_IN_TEMPDIR) $(CURDIR)/$(BUILD_RPC) lib/rpc_defs.py > $@
1350

    
1351
$(SHELL_ENV_INIT): Makefile stamp-directories
1352
	set -e; \
1353
	{ echo '# Allow overriding for tests'; \
1354
	  echo 'readonly LOCALSTATEDIR=$${LOCALSTATEDIR:-$${GANETI_ROOTDIR:-}$(localstatedir)}'; \
1355
	  echo 'readonly SYSCONFDIR=$${SYSCONFDIR:-$${GANETI_ROOTDIR:-}$(sysconfdir)}'; \
1356
	  echo; \
1357
	  echo 'readonly PKGLIBDIR=$(pkglibdir)'; \
1358
	  echo 'readonly LOG_DIR="$$LOCALSTATEDIR/log/ganeti"'; \
1359
	  echo 'readonly RUN_DIR="$$LOCALSTATEDIR/run/ganeti"'; \
1360
	  echo 'readonly DATA_DIR="$$LOCALSTATEDIR/lib/ganeti"'; \
1361
	  echo 'readonly CONF_DIR="$$SYSCONFDIR/ganeti"'; \
1362
	} > $@
1363

    
1364
$(REPLACE_VARS_SED): $(SHELL_ENV_INIT) Makefile stamp-directories
1365
	set -e; \
1366
	{ echo 's#@PREFIX@#$(prefix)#g'; \
1367
	  echo 's#@SYSCONFDIR@#$(sysconfdir)#g'; \
1368
	  echo 's#@LOCALSTATEDIR@#$(localstatedir)#g'; \
1369
	  echo 's#@BINDIR@#$(bindir)#g'; \
1370
	  echo 's#@SBINDIR@#$(sbindir)#g'; \
1371
	  echo 's#@LIBDIR@#$(libdir)#g'; \
1372
	  echo 's#@GANETI_VERSION@#$(PACKAGE_VERSION)#g'; \
1373
	  echo 's#@CUSTOM_XEN_BOOTLOADER@#$(XEN_BOOTLOADER)#g'; \
1374
	  echo 's#@CUSTOM_XEN_KERNEL@#$(XEN_KERNEL)#g'; \
1375
	  echo 's#@CUSTOM_XEN_INITRD@#$(XEN_INITRD)#g'; \
1376
	  echo 's#@CUSTOM_IALLOCATOR_SEARCH_PATH@#$(IALLOCATOR_SEARCH_PATH)#g'; \
1377
	  echo 's#@CUSTOM_EXPORT_DIR@#$(EXPORT_DIR)#g'; \
1378
	  echo 's#@RPL_FILE_STORAGE_DIR@#$(FILE_STORAGE_DIR)#g'; \
1379
	  echo 's#@RPL_SSH_INITD_SCRIPT@#$(SSH_INITD_SCRIPT)#g'; \
1380
	  echo 's#@PKGLIBDIR@#$(pkglibdir)#g'; \
1381
	  echo 's#@GNTMASTERUSER@#$(MASTERD_USER)#g'; \
1382
	  echo 's#@GNTRAPIUSER@#$(RAPI_USER)#g'; \
1383
	  echo 's#@GNTCONFDUSER@#$(CONFD_USER)#g'; \
1384
	  echo 's#@GNTNODEDUSER@#$(NODED_USER)#g'; \
1385
	  echo 's#@GNTRAPIGROUP@#$(RAPI_GROUP)#g'; \
1386
	  echo 's#@GNTADMINGROUP@#$(ADMIN_GROUP)#g'; \
1387
	  echo 's#@GNTCONFDGROUP@#$(CONFD_GROUP)#g'; \
1388
	  echo 's#@GNTMASTERDGROUP@#$(MASTERD_GROUP)#g'; \
1389
	  echo 's#@GNTDAEMONSGROUP@#$(DAEMONS_GROUP)#g'; \
1390
	  echo 's#@CUSTOM_ENABLE_CONFD@#$(ENABLE_CONFD)#g'; \
1391
	  echo 's#@MODULES@#$(strip $(lint_python_code))#g'; \
1392
	  echo 's#@ENABLE_SPLIT_QUERY@#$(ENABLE_SPLIT_QUERY)#g'; \
1393
	  echo; \
1394
	  echo '/^@SHELL_ENV_INIT@$$/ {'; \
1395
	  echo '  r $(SHELL_ENV_INIT)'; \
1396
	  echo '  d'; \
1397
	  echo '}'; \
1398
	} > $@
1399

    
1400
# Using deferred evaluation
1401
daemons/ganeti-%: MODULE = ganeti.server.$(patsubst ganeti-%,%,$(notdir $@))
1402
daemons/ganeti-watcher: MODULE = ganeti.watcher
1403
scripts/%: MODULE = ganeti.client.$(subst -,_,$(notdir $@))
1404
tools/ensure-dirs: MODULE = ganeti.tools.ensure_dirs
1405
tools/node-daemon-setup: MODULE = ganeti.tools.node_daemon_setup
1406
tools/prepare-node-join: MODULE = ganeti.tools.prepare_node_join
1407
tools/node-cleanup: MODULE = ganeti.tools.node_cleanup
1408
$(HS_BUILT_TEST_HELPERS): TESTROLE = $(patsubst htest/%,%,$@)
1409

    
1410
$(PYTHON_BOOTSTRAP): Makefile | stamp-directories
1411
	test -n "$(MODULE)" || { echo Missing module; exit 1; }
1412
	set -e; \
1413
	{ echo '#!/usr/bin/python'; \
1414
	  echo '# This file is automatically generated, do not edit!'; \
1415
	  echo "# Edit $(MODULE) instead."; \
1416
	  echo; \
1417
	  echo '"""Bootstrap script for L{$(MODULE)}"""'; \
1418
	  echo; \
1419
	  echo '# pylint: disable=C0103'; \
1420
	  echo '# C0103: Invalid name'; \
1421
	  echo; \
1422
	  echo 'import sys'; \
1423
	  echo 'import $(MODULE) as main'; \
1424
	  echo; \
1425
	  echo '# Temporarily alias commands until bash completion'; \
1426
	  echo '# generator is changed'; \
1427
	  echo 'if hasattr(main, "commands"):'; \
1428
	  echo '  commands = main.commands # pylint: disable=E1101'; \
1429
	  echo 'if hasattr(main, "aliases"):'; \
1430
	  echo '  aliases = main.aliases # pylint: disable=E1101'; \
1431
	  echo; \
1432
	  echo 'if __name__ == "__main__":'; \
1433
	  echo '  sys.exit(main.Main())'; \
1434
	} > $@
1435
	chmod u+x $@
1436

    
1437
$(HS_BUILT_TEST_HELPERS): Makefile
1438
	@test -n "$(TESTROLE)" || { echo Missing TESTROLE; exit 1; }
1439
	set -e; \
1440
	{ echo '#!/bin/sh'; \
1441
	  echo '# This file is automatically generated, do not edit!'; \
1442
	  echo "# Edit Makefile.am instead."; \
1443
	  echo; \
1444
	  echo "HTOOLS=$(TESTROLE) exec ./htest/hpc-htools \"\$$@\""; \
1445
	} > $@
1446
	chmod u+x $@
1447

    
1448
stamp-directories: Makefile
1449
	$(MAKE) $(AM_MAKEFLAGS) ganeti
1450
	@mkdir_p@ $(DIRS) $(BUILDTIME_DIR_AUTOCREATE)
1451
	touch $@
1452

    
1453
# We need to create symlinks because "make distcheck" will not install Python
1454
# files when building.
1455
stamp-srclinks: Makefile | stamp-directories
1456
	set -e; \
1457
	for i in $(srclink_files); do \
1458
	  if test ! -f $$i -a -f $(abs_top_srcdir)/$$i; then \
1459
	    $(LN_S) $(abs_top_srcdir)/$$i $$i; \
1460
	  fi; \
1461
	done
1462
	touch $@
1463

    
1464
.PHONY: ganeti
1465
ganeti:
1466
	cd $(top_builddir) && test -h "$@" || { rm -f $@ && $(LN_S) lib $@; }
1467

    
1468
.PHONY: check-dirs
1469
check-dirs: $(GENERATED_FILES)
1470
	@set -e; \
1471
	find . -type d \( -name . -o -name .git -prune -o -print \) | { \
1472
	  error=; \
1473
	  while read dir; do \
1474
	    case "$$dir" in \
1475
	      $(strip $(patsubst %,(./%) ;;,$(DIRCHECK_EXCLUDE) $(DIRS))) \
1476
	      *) error=1; echo "Directory $$dir not listed in Makefile" >&2 ;; \
1477
	    esac; \
1478
	  done; \
1479
	  for dir in $(DIRS); do \
1480
	    if ! test -d "$$dir"; then \
1481
	      echo "Directory $$dir listed in DIRS does not exist" >&2; \
1482
	      error=1; \
1483
	    fi \
1484
	  done; \
1485
	  test -z "$$error"; \
1486
	}
1487

    
1488
.PHONY: check-local
1489
check-local: check-dirs $(GENERATED_FILES)
1490
	$(CHECK_PYTHON_CODE) $(check_python_code)
1491
	PYTHONPATH=. $(CHECK_HEADER) $(check_python_code)
1492
	$(CHECK_VERSION) $(VERSION) $(top_srcdir)/NEWS
1493
	$(CHECK_NEWS) < $(top_srcdir)/NEWS
1494
	PYTHONPATH=. $(RUN_IN_TEMPDIR) $(CURDIR)/$(CHECK_IMPORTS) . $(standalone_python_modules)
1495
	@expver=$(VERSION_MAJOR).$(VERSION_MINOR); \
1496
	error= ; \
1497
	if test "`head -n 1 $(top_srcdir)/README`" != "Ganeti $$expver"; then \
1498
	  echo "Incorrect version in README, expected $$expver" >&2; \
1499
	  error=1; \
1500
	fi; \
1501
	for file in doc/iallocator.rst doc/hooks.rst doc/virtual-cluster.rst \
1502
	    doc/security.rst; do \
1503
	  if test "`sed -ne '4 p' $(top_srcdir)/$$file`" != \
1504
	    "Documents Ganeti version $$expver"; then \
1505
	    echo "Incorrect version in $$file, expected $$expver" >&2; \
1506
	    error=1; \
1507
	  fi; \
1508
	done; \
1509
	if ! test -f $(top_srcdir)/doc/design-$$expver.rst; then \
1510
	  echo "File $(top_srcdir)/doc/design-$$expver.rst not found" >&2; \
1511
	  error=1; \
1512
	fi; \
1513
	if test "`sed -ne '5 p' $(top_srcdir)/doc/design-draft.rst`" != \
1514
	  ".. Last updated for Ganeti $$expver"; then \
1515
	  echo "doc/design-draft.rst was not updated for version $$expver" >&2; \
1516
	  error=1; \
1517
	fi; \
1518
	for file in configure.ac $(HS_LIBTEST_SRCS) $(HS_PROG_SRCS); do \
1519
	  if test $$(wc --max-line-length < $(top_srcdir)/$$file) -gt 80; then \
1520
	    echo "Longest line in $$file is longer than 80 characters" >&2; \
1521
	    error=1; \
1522
	  fi; \
1523
	done; \
1524
	test -z "$$error"
1525

    
1526
.PHONY: hs-check
1527
hs-check: htest/test htest/hpc-htools htest/hpc-mon-collector $(HS_BUILT_TEST_HELPERS)
1528
	@rm -f test.tix
1529
	./htest/test
1530
	HBINARY="./htest/hpc-htools" ./htest/offline-test.sh
1531

    
1532
# E111: indentation is not a multiple of four
1533
# E121: continuation line indentation is not a multiple of four
1534
#       (since our indent level is not 4)
1535
# E125: continuation line does not distinguish itself from next logical line
1536
#       (since our indent level is not 4)
1537
# E127: continuation line over-indented for visual indent
1538
#       (since our indent level is not 4)
1539
# note: do NOT add E128 here; it's a valid style error in most cases!
1540
# I've seen real errors, but also some cases were we indent wrongly
1541
# due to line length; try to rework the cases where it is triggered,
1542
# instead of silencing it
1543
# E261: at least two spaces before inline comment
1544
# E501: line too long (80 characters)
1545
PEP8_IGNORE = E111,E121,E125,E127,E261,E501
1546

    
1547
# For excluding pep8 expects filenames only, not whole paths
1548
PEP8_EXCLUDE = $(subst $(space),$(comma),$(strip $(notdir $(BUILT_PYTHON_SOURCES))))
1549

    
1550
LINT_TARGETS = pylint pylint-qa
1551
if HAS_PEP8
1552
LINT_TARGETS += pep8
1553
endif
1554
if HAS_HLINT
1555
LINT_TARGETS += hlint
1556
endif
1557

    
1558
.PHONY: lint
1559
lint: $(LINT_TARGETS)
1560

    
1561
.PHONY: pylint
1562
pylint: $(GENERATED_FILES)
1563
	@test -n "$(PYLINT)" || { echo 'pylint' not found during configure; exit 1; }
1564
	$(PYLINT) $(LINT_OPTS) $(lint_python_code)
1565

    
1566
.PHONY: pylint-qa
1567
pylint-qa: $(GENERATED_FILES)
1568
	@test -n "$(PYLINT)" || { echo 'pylint' not found during configure; exit 1; }
1569
	cd $(top_srcdir)/qa && \
1570
	  PYTHONPATH=$(abs_top_srcdir) $(PYLINT) $(LINT_OPTS) \
1571
	  --rcfile  ../pylintrc $(patsubst qa/%.py,%,$(qa_scripts))
1572

    
1573
.PHONY: pep8
1574
pep8: $(GENERATED_FILES)
1575
	@test -n "$(PEP8)" || { echo 'pep8' not found during configure; exit 1; }
1576
	$(PEP8) --ignore='$(PEP8_IGNORE)' --exclude='$(PEP8_EXCLUDE)' \
1577
	  --repeat $(pep8_python_code)
1578

    
1579
# FIXME: remove ignore "Use void" when GHC 6.x is deprecated
1580
HLINT_EXCLUDES = htools/Ganeti/THH.hs htest/hpc-htools.hs
1581
.PHONY: hlint
1582
hlint: $(HS_BUILT_SRCS) htools/lint-hints.hs
1583
	@test -n "$(HLINT)" || { echo 'hlint' not found during configure; exit 1; }
1584
	if tty -s; then C="-c"; else C=""; fi; \
1585
	$(HLINT) --utf8 --report=doc/hs-lint.html --cross $$C \
1586
	  --ignore "Use first" \
1587
	  --ignore "Use comparing" \
1588
	  --ignore "Use on" \
1589
	  --ignore "Reduce duplication" \
1590
	  --ignore "Use &&&" \
1591
	  --ignore "Use void" \
1592
	  --hint htools/lint-hints \
1593
	  $(filter-out $(HLINT_EXCLUDES),$(HS_LIBTEST_SRCS) $(HS_PROG_SRCS))
1594

    
1595
# a dist hook rule for updating the vcs-version file; this is
1596
# hardcoded due to where it needs to build the file...
1597
dist-hook:
1598
	$(MAKE) $(AM_MAKEFLAGS) regen-vcs-version
1599
	rm -f $(top_distdir)/vcs-version
1600
	cp -p $(srcdir)/vcs-version $(top_distdir)
1601

    
1602
# a distcheck hook rule for catching revision control directories
1603
distcheck-hook:
1604
	if find $(top_distdir) -name .svn -or -name .git | grep .; then \
1605
	  echo "Found revision control files in final archive." 1>&2; \
1606
	  exit 1; \
1607
	fi
1608
	if find $(top_distdir) -name '*.py[co]' | grep .; then \
1609
	  echo "Found Python byte code in final archive." 1>&2; \
1610
	  exit 1; \
1611
	fi
1612
	if find $(top_distdir) -name '*~' | grep .; then \
1613
	  echo "Found backup files in final archive." 1>&2; \
1614
	  exit 1; \
1615
	fi
1616
# Empty files or directories should not be distributed. They can cause
1617
# unnecessary warnings for packagers. Directories used by automake during
1618
# distcheck must be excluded.
1619
	if find $(top_distdir) -empty -and -not \( \
1620
	    -path $(top_distdir)/_build -or \
1621
	    -path $(top_distdir)/_inst \) | grep .; then \
1622
	  echo "Found empty files or directories in final archive." 1>&2; \
1623
	  exit 1; \
1624
	fi
1625
	if test -n "$(BUILD_RELEASE)" && \
1626
	   grep -n -H -E '^\*.*unreleased' $(top_distdir)/NEWS; then \
1627
	   echo "Found unreleased version in NEWS." >&2; \
1628
	   exit 1; \
1629
	fi
1630

    
1631
# When building a release, stricter checks should be used
1632
distcheck-release dist-release: export BUILD_RELEASE = 1
1633
distcheck-release: distcheck
1634

    
1635
distrebuildcheck: dist
1636
	set -e; \
1637
	builddir=$$(mktemp -d $(abs_srcdir)/distrebuildcheck.XXXXXXX); \
1638
	trap "echo Removing $$builddir; cd $(abs_srcdir); rm -rf $$builddir" EXIT; \
1639
	cd $$builddir; \
1640
	tar xzf $(abs_srcdir)/$(distdir).tar.gz; \
1641
	cd $(distdir); \
1642
	./configure; \
1643
	$(MAKE) maintainer-clean; \
1644
	cp $(abs_srcdir)/vcs-version .; \
1645
	./configure; \
1646
	$(MAKE) $(AM_MAKEFLAGS)
1647

    
1648
dist-release: dist
1649
	set -e; \
1650
	for i in $(DIST_ARCHIVES); do \
1651
	  echo -n "Checking $$i ... "; \
1652
	  autotools/check-tar < $$i; \
1653
	  echo OK; \
1654
	done
1655

    
1656
install-exec-local:
1657
	@mkdir_p@ "$(DESTDIR)${localstatedir}/lib/ganeti" \
1658
	  "$(DESTDIR)${localstatedir}/log/ganeti" \
1659
	  "$(DESTDIR)${localstatedir}/run/ganeti"
1660

    
1661
.PHONY: apidoc
1662
if WANT_HTOOLSAPIDOC
1663
apidoc: py-apidoc hs-apidoc
1664
else
1665
apidoc: py-apidoc
1666
endif
1667

    
1668
.PHONY: py-apidoc
1669
py-apidoc: epydoc.conf $(RUN_IN_TEMPDIR) $(GENERATED_FILES)
1670
	env - PATH="$$PATH" PYTHONPATH="$$PYTHONPATH" \
1671
	$(RUN_IN_TEMPDIR) epydoc -v \
1672
	  --conf $(CURDIR)/epydoc.conf \
1673
	  --output $(CURDIR)/$(APIDOC_PY_DIR)
1674

    
1675
.PHONY: hs-apidoc
1676
hs-apidoc: $(HS_BUILT_SRCS)
1677
	@test -n "$(HSCOLOUR)" || \
1678
	    { echo 'HsColour' not found during configure; exit 1; }
1679
	@test -n "$(HADDOCK)" || \
1680
	    { echo 'haddock' not found during configure; exit 1; }
1681
	rm -rf $(APIDOC_HS_DIR)/*
1682
	for i in $(ALL_APIDOC_HS_DIRS); do \
1683
	  @mkdir_p@ $$i; \
1684
	done
1685
	$(HSCOLOUR) -print-css > $(APIDOC_HS_DIR)/Ganeti/hscolour.css
1686
	$(LN_S) ../hscolour.css $(APIDOC_HS_DIR)/Ganeti/HTools/hscolour.css
1687
	$(LN_S) ../hscolour.css $(APIDOC_HS_DIR)/Ganeti/Confd/hscolour.css
1688
	set -e ; \
1689
	cd htools; \
1690
	if [ "$(HTOOLS_NOCURL)" ]; \
1691
	then OPTGHC="--optghc=$(HTOOLS_NOCURL)"; \
1692
	else OPTGHC=""; \
1693
	fi; \
1694
	if [ "$(HTOOLS_PARALLEL3)" ]; \
1695
	then OPTGHC="$$OPTGHC --optghc=$(HTOOLS_PARALLEL3)"; \
1696
	fi; \
1697
	if [ "$(HTOOLS_REGEX_PCRE)" ]; \
1698
	then OPTGHC="$$OPTGHC --optghc=$(HTOOLS_REGEX_PCRE)"; \
1699
	fi; \
1700
	RELSRCS="$(HS_LIB_SRCS:htools/%=%) $(patsubst htools/%,%,$(filter htools/%,$(HS_BUILT_SRCS)))"; \
1701
	for file in $$RELSRCS; do \
1702
	  hfile=`echo $$file|sed 's/\\.hs$$//'`.html; \
1703
	  $(HSCOLOUR) -css -anchor $$file > ../$(APIDOC_HS_DIR)/$$hfile ; \
1704
	done ; \
1705
	$(HADDOCK) --odir ../$(APIDOC_HS_DIR) --html --ignore-all-exports -w \
1706
	  -t ganeti -p haddock-prologue \
1707
	  --source-module="%{MODULE/.//}.html" \
1708
	  --source-entity="%{MODULE/.//}.html#%{NAME}" \
1709
	  $$OPTGHC \
1710
	  $(filter-out Ganeti/HTools/ExtLoader.hs,$(HS_LIB_SRCS:htools/%=%))
1711

    
1712
.PHONY: TAGS
1713
TAGS: $(GENERATED_FILES)
1714
	rm -f TAGS
1715
	$(GHC) -e ":etags" -v0 \
1716
	  $(filter-out -O -Werror,$(HFLAGS)) \
1717
	  $(HTOOLS_NOCURL) $(HTOOLS_PARALLEL3) $(HTOOLS_REGEX_PCRE) \
1718
	  $(HS_LIBTEST_SRCS)
1719
	find . -path './lib/*.py' -o -path './scripts/gnt-*' -o \
1720
	  -path './daemons/ganeti-*' -o -path './tools/*' -o \
1721
	  -path './qa/*.py' | \
1722
	  etags -l python -a -
1723

    
1724
.PHONY: coverage
1725
if WANT_HTOOLS
1726
coverage: py-coverage hs-coverage
1727
else
1728
coverage: py-coverage
1729
endif
1730

    
1731
.PHONY: py-coverage
1732
py-coverage: $(GENERATED_FILES) $(python_tests)
1733
	@test -n "$(PYCOVERAGE)" || \
1734
	    { echo 'python-coverage' not found during configure; exit 1; }
1735
	set -e; \
1736
	COVERAGE=$(PYCOVERAGE) \
1737
	COVERAGE_FILE=$(CURDIR)/$(COVERAGE_PY_DIR)/data \
1738
	TEXT_COVERAGE=$(CURDIR)/$(COVERAGE_PY_DIR)/report.txt \
1739
	HTML_COVERAGE=$(CURDIR)/$(COVERAGE_PY_DIR) \
1740
	$(PLAIN_TESTS_ENVIRONMENT) $(abs_top_srcdir)/autotools/gen-coverage \
1741
	$(python_tests)
1742

    
1743
.PHONY: hs-coverage
1744
hs-coverage: $(haskell_tests) htest/hpc-htools htest/hpc-mon-collector
1745
	rm -f *.tix
1746
	$(MAKE) $(AM_MAKEFLAGS) hs-check
1747
	@mkdir_p@ $(COVERAGE_HS_DIR)
1748
	hpc sum --union $(HPCEXCL) \
1749
	  test.tix hpc-htools.tix hpc-mon-collector.tix > coverage-htools.tix
1750
	hpc markup --destdir=$(COVERAGE_HS_DIR) coverage-htools.tix
1751
	hpc report coverage-htools.tix
1752
	$(LN_S) -f hpc_index.html $(COVERAGE_HS_DIR)/index.html
1753

    
1754
# Special "kind-of-QA" target for htools, needs special setup (all
1755
# tools compiled with -fhpc)
1756
.PHONY: live-test
1757
live-test: all
1758
	set -e ; \
1759
	cd htools; \
1760
	rm -f .hpc; $(LN_S) ../.hpc .hpc; \
1761
	rm -f *.tix *.mix; \
1762
	./live-test.sh; \
1763
	hpc sum --union $(HPCEXCL) $(addsuffix .tix,$(HS_PROGS:htools/%=%)) \
1764
	  --output=live-test.tix ; \
1765
	@mkdir_p@ ../$(COVERAGE_HS_DIR) ; \
1766
	hpc markup --destdir=../$(COVERAGE_HS_DIR) live-test \
1767
	  --srcdir=.. $(HPCEXCL) ; \
1768
	hpc report --srcdir=.. live-test $(HPCEXCL)
1769

    
1770
commit-check: distcheck lint apidoc
1771

    
1772
.PHONY: gitignore-check
1773
gitignore-check:
1774
	@if [ -n "`git status --short`" ]; then \
1775
	  echo "Git status is not clean!" 1>&2 ; \
1776
	  git status --short; \
1777
	  exit 1; \
1778
	fi
1779

    
1780
# Target that builds all binaries (including those that are not
1781
# rebuilt except when running the tests)
1782
.PHONY: really-all
1783
really-all: all $(check_SCRIPTS) $(haskell_tests) $(HS_ALL_PROGS)
1784

    
1785
# we don't need the ancient implicit rules:
1786
%: %,v
1787
%: RCS/%,v
1788
%: RCS/%
1789
%: s.%
1790
%: SCCS/s.%
1791

    
1792
-include ./Makefile.local
1793

    
1794
# vim: set noet :