Statistics
| Branch: | Tag: | Revision:

root / Makefile.am @ 1ca709c1

History | View | Annotate | Download (57.2 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_REFERENCES = $(top_srcdir)/autotools/check-man-references
27
CHECK_MAN_WARNINGS = $(top_srcdir)/autotools/check-man-warnings
28
CHECK_VERSION = $(top_srcdir)/autotools/check-version
29
CHECK_NEWS = $(top_srcdir)/autotools/check-news
30
CHECK_IMPORTS = $(top_srcdir)/autotools/check-imports
31
DOCPP = $(top_srcdir)/autotools/docpp
32
REPLACE_VARS_SED = autotools/replace_vars.sed
33
CONVERT_CONSTANTS = $(top_srcdir)/autotools/convert-constants
34
BUILD_RPC = $(top_srcdir)/autotools/build-rpc
35
SHELL_ENV_INIT = autotools/shell-env-init
36

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

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

    
58
HS_DIRS = \
59
	src \
60
	src/Ganeti \
61
	src/Ganeti/Block \
62
	src/Ganeti/Block/Drbd \
63
	src/Ganeti/Confd \
64
	src/Ganeti/DataCollectors \
65
	src/Ganeti/HTools \
66
	src/Ganeti/HTools/Backend \
67
	src/Ganeti/HTools/Program \
68
	src/Ganeti/Hypervisor \
69
	src/Ganeti/Hypervisor/Xen \
70
	src/Ganeti/Query \
71
	test/hs \
72
	test/hs/Test \
73
	test/hs/Test/Ganeti \
74
	test/hs/Test/Ganeti/Block \
75
	test/hs/Test/Ganeti/Block/Drbd \
76
	test/hs/Test/Ganeti/Confd \
77
	test/hs/Test/Ganeti/HTools \
78
	test/hs/Test/Ganeti/HTools/Backend \
79
	test/hs/Test/Ganeti/Hypervisor \
80
	test/hs/Test/Ganeti/Hypervisor/Xen \
81
	test/hs/Test/Ganeti/Query
82

    
83
DIRS = \
84
	$(HS_DIRS) \
85
	autotools \
86
	daemons \
87
	devel \
88
	doc \
89
	doc/css \
90
	doc/examples \
91
	doc/examples/gnt-debug \
92
	doc/examples/hooks \
93
	test/data/htools \
94
	test/data/htools/rapi \
95
	test/hs/shelltests \
96
	lib \
97
	lib/build \
98
	lib/client \
99
	lib/confd \
100
	lib/http \
101
	lib/hypervisor \
102
	lib/impexpd \
103
	lib/masterd \
104
	lib/rapi \
105
	lib/server \
106
	lib/tools \
107
	lib/utils \
108
	lib/watcher \
109
	man \
110
	qa \
111
	test \
112
	test/data \
113
	test/data/bdev-rbd \
114
	test/data/ovfdata \
115
	test/data/ovfdata/other \
116
	test/py \
117
	tools
118

    
119
ALL_APIDOC_HS_DIRS = \
120
	$(APIDOC_HS_DIR) \
121
	$(APIDOC_HS_DIR)/Ganeti \
122
	$(APIDOC_HS_DIR)/Ganeti/Block \
123
	$(APIDOC_HS_DIR)/Ganeti/Block/Drbd \
124
	$(APIDOC_HS_DIR)/Ganeti/Confd \
125
	$(APIDOC_HS_DIR)/Ganeti/DataCollectors \
126
	$(APIDOC_HS_DIR)/Ganeti/HTools \
127
	$(APIDOC_HS_DIR)/Ganeti/HTools/Backend \
128
	$(APIDOC_HS_DIR)/Ganeti/HTools/Program \
129
	$(APIDOC_HS_DIR)/Ganeti/Hypervisor \
130
	$(APIDOC_HS_DIR)/Ganeti/Hypervisor/Xen \
131
	$(APIDOC_HS_DIR)/Ganeti/Query
132

    
133
BUILDTIME_DIR_AUTOCREATE = \
134
	scripts \
135
	$(APIDOC_DIR) \
136
	$(ALL_APIDOC_HS_DIRS) \
137
	$(APIDOC_PY_DIR) \
138
	$(COVERAGE_DIR) \
139
	$(COVERAGE_HS_DIR) \
140
	$(COVERAGE_PY_DIR) \
141
	.hpc
142

    
143
BUILDTIME_DIRS = \
144
	$(BUILDTIME_DIR_AUTOCREATE) \
145
	doc/html \
146
	doc/man-html
147

    
148
DIRCHECK_EXCLUDE = \
149
	$(BUILDTIME_DIRS) \
150
	ganeti-[0-9]*.[0-9]*.[0-9]* \
151
	doc/html/_* \
152
	doc/man-html/_* \
153
	autom4te.cache
154

    
155
# some helper vars
156
COVERAGE_DIR = doc/coverage
157
COVERAGE_PY_DIR = $(COVERAGE_DIR)/py
158
COVERAGE_HS_DIR = $(COVERAGE_DIR)/hs
159
APIDOC_DIR = doc/api
160
APIDOC_PY_DIR = $(APIDOC_DIR)/py
161
APIDOC_HS_DIR = $(APIDOC_DIR)/hs
162

    
163
MAINTAINERCLEANFILES = \
164
	$(maninput) \
165
	doc/install-quick.rst \
166
	doc/news.rst \
167
	doc/upgrade.rst \
168
	vcs-version
169

    
170
maintainer-clean-local:
171
	rm -rf $(BUILDTIME_DIRS)
172

    
173
CLEANFILES = \
174
	$(addsuffix /*.py[co],$(DIRS)) \
175
	$(addsuffix /*.hi,$(HS_DIRS)) \
176
	$(addsuffix /*.o,$(HS_DIRS)) \
177
	$(PYTHON_BOOTSTRAP) \
178
	epydoc.conf \
179
	$(REPLACE_VARS_SED) \
180
	$(SHELL_ENV_INIT) \
181
	daemons/daemon-util \
182
	daemons/ganeti-cleaner \
183
	$(mandocrst) \
184
	doc/manpages-enabled.rst \
185
	$(BUILT_EXAMPLES) \
186
	doc/examples/bash_completion \
187
	doc/examples/bash_completion-debug \
188
	lib/_generated_rpc.py \
189
	$(man_MANS) \
190
	$(manhtml) \
191
	tools/kvm-ifup \
192
	tools/vcluster-setup \
193
	stamp-directories \
194
	stamp-srclinks \
195
	$(nodist_pkgpython_PYTHON) \
196
	$(HS_ALL_PROGS) $(HS_BUILT_SRCS) \
197
	$(HS_BUILT_TEST_HELPERS) \
198
	src/ganeti-confd \
199
	.hpc/*.mix src/*.tix test/hs/*.tix \
200
	doc/hs-lint.html
201

    
202
GENERATED_FILES = \
203
	$(built_base_sources) \
204
	$(BUILT_PYTHON_SOURCES) \
205
	$(PYTHON_BOOTSTRAP)
206

    
207
HS_GENERATED_FILES =
208
if WANT_HTOOLS
209
HS_GENERATED_FILES += $(HS_PROGS)
210
if ENABLE_CONFD
211
HS_GENERATED_FILES += src/hconfd src/ganeti-confd
212
endif
213
endif
214

    
215
built_base_sources = \
216
	stamp-directories \
217
	stamp-srclinks
218

    
219
built_python_base_sources = \
220
	lib/_autoconf.py \
221
	lib/_vcsversion.py
222

    
223
BUILT_PYTHON_SOURCES = \
224
	$(built_python_base_sources) \
225
	lib/_generated_rpc.py
226

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

    
231
# these are all built from the underlying %.in sources
232
BUILT_EXAMPLES = \
233
	doc/examples/ganeti-kvm-poweroff.initd \
234
	doc/examples/ganeti.cron \
235
	doc/examples/ganeti.initd \
236
	doc/examples/ganeti-master-role.ocf \
237
	doc/examples/ganeti-node-role.ocf \
238
	doc/examples/gnt-config-backup \
239
	doc/examples/hooks/ipsec
240

    
241
nodist_pkgpython_PYTHON = \
242
	$(BUILT_PYTHON_SOURCES)
243

    
244
noinst_PYTHON = \
245
	lib/build/__init__.py \
246
	lib/build/shell_example_lexer.py \
247
	lib/build/sphinx_ext.py
248

    
249
pkgpython_PYTHON = \
250
	lib/__init__.py \
251
	lib/asyncnotifier.py \
252
	lib/backend.py \
253
	lib/bdev.py \
254
	lib/bootstrap.py \
255
	lib/cli.py \
256
	lib/cmdlib.py \
257
	lib/compat.py \
258
	lib/config.py \
259
	lib/constants.py \
260
	lib/daemon.py \
261
	lib/errors.py \
262
	lib/ht.py \
263
	lib/jqueue.py \
264
	lib/jstore.py \
265
	lib/locking.py \
266
	lib/luxi.py \
267
	lib/mcpu.py \
268
	lib/netutils.py \
269
	lib/objects.py \
270
	lib/opcodes.py \
271
	lib/outils.py \
272
	lib/ovf.py \
273
	lib/pathutils.py \
274
	lib/qlang.py \
275
	lib/query.py \
276
	lib/rpc.py \
277
	lib/rpc_defs.py \
278
	lib/runtime.py \
279
	lib/serializer.py \
280
	lib/ssconf.py \
281
	lib/ssh.py \
282
	lib/storage.py \
283
	lib/uidpool.py \
284
	lib/vcluster.py \
285
	lib/network.py \
286
	lib/workerpool.py
287

    
288
client_PYTHON = \
289
	lib/client/__init__.py \
290
	lib/client/gnt_backup.py \
291
	lib/client/gnt_cluster.py \
292
	lib/client/gnt_debug.py \
293
	lib/client/gnt_group.py \
294
	lib/client/gnt_instance.py \
295
	lib/client/gnt_job.py \
296
	lib/client/gnt_node.py \
297
	lib/client/gnt_network.py \
298
	lib/client/gnt_os.py \
299
	lib/client/gnt_storage.py
300

    
301
hypervisor_PYTHON = \
302
	lib/hypervisor/__init__.py \
303
	lib/hypervisor/hv_base.py \
304
	lib/hypervisor/hv_chroot.py \
305
	lib/hypervisor/hv_fake.py \
306
	lib/hypervisor/hv_kvm.py \
307
	lib/hypervisor/hv_lxc.py \
308
	lib/hypervisor/hv_xen.py
309

    
310
rapi_PYTHON = \
311
	lib/rapi/__init__.py \
312
	lib/rapi/baserlib.py \
313
	lib/rapi/client.py \
314
	lib/rapi/client_utils.py \
315
	lib/rapi/connector.py \
316
	lib/rapi/rlib2.py \
317
	lib/rapi/testutils.py
318

    
319
http_PYTHON = \
320
	lib/http/__init__.py \
321
	lib/http/auth.py \
322
	lib/http/client.py \
323
	lib/http/server.py
324

    
325
confd_PYTHON = \
326
	lib/confd/__init__.py \
327
	lib/confd/client.py
328

    
329
masterd_PYTHON = \
330
	lib/masterd/__init__.py \
331
	lib/masterd/iallocator.py \
332
	lib/masterd/instance.py
333

    
334
impexpd_PYTHON = \
335
	lib/impexpd/__init__.py
336

    
337
watcher_PYTHON = \
338
	lib/watcher/__init__.py \
339
	lib/watcher/nodemaint.py \
340
	lib/watcher/state.py
341

    
342
server_PYTHON = \
343
	lib/server/__init__.py \
344
	lib/server/masterd.py \
345
	lib/server/noded.py \
346
	lib/server/rapi.py
347

    
348
pytools_PYTHON = \
349
	lib/tools/__init__.py \
350
	lib/tools/burnin.py \
351
	lib/tools/ensure_dirs.py \
352
	lib/tools/node_cleanup.py \
353
	lib/tools/node_daemon_setup.py \
354
	lib/tools/prepare_node_join.py
355

    
356
utils_PYTHON = \
357
	lib/utils/__init__.py \
358
	lib/utils/algo.py \
359
	lib/utils/filelock.py \
360
	lib/utils/hash.py \
361
	lib/utils/io.py \
362
	lib/utils/log.py \
363
	lib/utils/lvm.py \
364
	lib/utils/mlock.py \
365
	lib/utils/nodesetup.py \
366
	lib/utils/process.py \
367
	lib/utils/retry.py \
368
	lib/utils/text.py \
369
	lib/utils/wrapper.py \
370
	lib/utils/x509.py
371

    
372
docinput = \
373
	doc/conf.py \
374
	doc/css/style.css \
375
	doc/admin.rst \
376
	doc/cluster-merge.rst \
377
	doc/design-2.0.rst \
378
	doc/design-2.1.rst \
379
	doc/design-2.2.rst \
380
	doc/design-2.3.rst \
381
	doc/design-2.4.rst \
382
	doc/design-2.5.rst \
383
	doc/design-2.6.rst \
384
	doc/design-2.7.rst \
385
	doc/design-autorepair.rst \
386
	doc/design-bulk-create.rst \
387
	doc/design-chained-jobs.rst \
388
	doc/design-cpu-pinning.rst \
389
	doc/design-draft.rst \
390
	doc/design-htools-2.3.rst \
391
	doc/design-http-server.rst \
392
	doc/design-impexp2.rst \
393
	doc/design-lu-generated-jobs.rst \
394
	doc/design-linuxha.rst \
395
	doc/design-multi-reloc.rst \
396
	doc/design-network.rst \
397
	doc/design-node-add.rst \
398
	doc/design-oob.rst \
399
	doc/design-ovf-support.rst \
400
	doc/design-opportunistic-locking.rst \
401
	doc/design-partitioned.rst \
402
	doc/design-query-splitting.rst \
403
	doc/design-query2.rst \
404
	doc/design-resource-model.rst \
405
	doc/design-restricted-commands.rst \
406
	doc/design-shared-storage.rst \
407
	doc/design-monitoring-agent.rst \
408
	doc/design-virtual-clusters.rst \
409
	doc/design-x509-ca.rst \
410
	doc/design-hroller.rst \
411
	doc/design-storagespace.rst \
412
	doc/devnotes.rst \
413
	doc/glossary.rst \
414
	doc/hooks.rst \
415
	doc/iallocator.rst \
416
	doc/index.rst \
417
	doc/install-quick.rst \
418
	doc/install.rst \
419
	doc/locking.rst \
420
	doc/manpages-disabled.rst \
421
	doc/move-instance.rst \
422
	doc/news.rst \
423
	doc/ovfconverter.rst \
424
	doc/rapi.rst \
425
	doc/security.rst \
426
	doc/upgrade.rst \
427
	doc/virtual-cluster.rst \
428
	doc/walkthrough.rst
429

    
430
# Generates file names such as "doc/man-gnt-instance.rst"
431
mandocrst = $(addprefix doc/man-,$(notdir $(manrst)))
432

    
433
# Haskell programs to be installed in $PREFIX/bin
434
HS_BIN_PROGS=src/htools
435

    
436
# Haskell programs to be installed in the MYEXECLIB dir
437
HS_MYEXECLIB_PROGS=src/mon-collector
438

    
439
# Haskell programs to compiled but not installed automatically
440
# Usually they have their own specific installation rules
441
HS_COMPILE_PROGS= \
442
	src/hconfd \
443
	src/rpc-test
444

    
445
# All Haskell non-test programs to be compiled but not automatically installed
446
HS_PROGS = $(HS_BIN_PROGS) $(HS_MYEXECLIB_PROGS)
447

    
448
HS_BIN_ROLES = harep hbal hscan hspace hinfo hcheck hroller
449
HS_HTOOLS_PROGS = $(HS_BIN_ROLES) hail
450

    
451
HS_ALL_PROGS = \
452
	$(HS_PROGS) \
453
	test/hs/hpc-htools \
454
	test/hs/hpc-mon-collector \
455
	test/hs/htest \
456
	$(HS_COMPILE_PROGS)
457

    
458
HS_PROG_SRCS = $(patsubst %,%.hs,$(HS_ALL_PROGS))
459
HS_BUILT_TEST_HELPERS = $(HS_BIN_ROLES:%=test/hs/%) test/hs/hail
460

    
461
HFLAGS = \
462
	-O -Wall -Werror -isrc \
463
	-fwarn-monomorphism-restriction \
464
	-fwarn-tabs \
465
	$(GHC_BYVERSION_FLAGS)
466

    
467
# extra flags that can be overriden on the command line (e.g. -Wwarn, etc.)
468
HEXTRA =
469
# internal extra flags (used for test/hs/htest mainly)
470
HEXTRA_INT =
471
# exclude options for coverage reports
472
HPCEXCL = --exclude Main \
473
	--exclude Ganeti.Constants \
474
	--exclude Ganeti.HTools.QC \
475
	--exclude Ganeti.THH \
476
	--exclude Ganeti.Version \
477
	--exclude Test.Ganeti.Attoparsec \
478
	--exclude Test.Ganeti.TestCommon \
479
	--exclude Test.Ganeti.TestHTools \
480
	--exclude Test.Ganeti.TestHelper \
481
	--exclude Test.Ganeti.TestImports \
482
	$(patsubst src.%,--exclude Test.%,$(subst /,.,$(patsubst %.hs,%, $(HS_LIB_SRCS))))
483

    
484
HS_LIB_SRCS = \
485
	src/Ganeti/Block/Drbd/Types.hs \
486
	src/Ganeti/Block/Drbd/Parser.hs \
487
	src/Ganeti/BasicTypes.hs \
488
	src/Ganeti/Common.hs \
489
	src/Ganeti/Compat.hs \
490
	src/Ganeti/Confd/Client.hs \
491
	src/Ganeti/Confd/Server.hs \
492
	src/Ganeti/Confd/Types.hs \
493
	src/Ganeti/Confd/Utils.hs \
494
	src/Ganeti/Config.hs \
495
	src/Ganeti/Daemon.hs \
496
	src/Ganeti/DataCollectors/CLI.hs \
497
	src/Ganeti/DataCollectors/Drbd.hs \
498
	src/Ganeti/DataCollectors/Program.hs \
499
	src/Ganeti/DataCollectors/Types.hs \
500
	src/Ganeti/Errors.hs \
501
	src/Ganeti/HTools/Backend/IAlloc.hs \
502
	src/Ganeti/HTools/Backend/Luxi.hs \
503
	src/Ganeti/HTools/Backend/Rapi.hs \
504
	src/Ganeti/HTools/Backend/Simu.hs \
505
	src/Ganeti/HTools/Backend/Text.hs \
506
	src/Ganeti/HTools/CLI.hs \
507
	src/Ganeti/HTools/Cluster.hs \
508
	src/Ganeti/HTools/Container.hs \
509
	src/Ganeti/HTools/ExtLoader.hs \
510
	src/Ganeti/HTools/Graph.hs \
511
	src/Ganeti/HTools/Group.hs \
512
	src/Ganeti/HTools/Instance.hs \
513
	src/Ganeti/HTools/Loader.hs \
514
	src/Ganeti/HTools/Node.hs \
515
	src/Ganeti/HTools/PeerMap.hs \
516
	src/Ganeti/HTools/Program/Hail.hs \
517
	src/Ganeti/HTools/Program/Harep.hs \
518
	src/Ganeti/HTools/Program/Hbal.hs \
519
	src/Ganeti/HTools/Program/Hcheck.hs \
520
	src/Ganeti/HTools/Program/Hinfo.hs \
521
	src/Ganeti/HTools/Program/Hscan.hs \
522
	src/Ganeti/HTools/Program/Hspace.hs \
523
	src/Ganeti/HTools/Program/Hroller.hs \
524
	src/Ganeti/HTools/Program/Main.hs \
525
	src/Ganeti/HTools/Types.hs \
526
	src/Ganeti/Hypervisor/Xen/XmParser.hs \
527
	src/Ganeti/Hypervisor/Xen/Types.hs \
528
	src/Ganeti/Hash.hs \
529
	src/Ganeti/JQueue.hs \
530
	src/Ganeti/JSON.hs \
531
	src/Ganeti/Jobs.hs \
532
	src/Ganeti/Logging.hs \
533
	src/Ganeti/Luxi.hs \
534
	src/Ganeti/Network.hs \
535
	src/Ganeti/Objects.hs \
536
	src/Ganeti/OpCodes.hs \
537
	src/Ganeti/OpParams.hs \
538
	src/Ganeti/Path.hs \
539
	src/Ganeti/Query/Common.hs \
540
	src/Ganeti/Query/Filter.hs \
541
	src/Ganeti/Query/Group.hs \
542
	src/Ganeti/Query/Job.hs \
543
	src/Ganeti/Query/Language.hs \
544
	src/Ganeti/Query/Network.hs \
545
	src/Ganeti/Query/Node.hs \
546
	src/Ganeti/Query/Query.hs \
547
	src/Ganeti/Query/Server.hs \
548
	src/Ganeti/Query/Types.hs \
549
	src/Ganeti/Rpc.hs \
550
	src/Ganeti/Runtime.hs \
551
	src/Ganeti/Ssconf.hs \
552
	src/Ganeti/THH.hs \
553
	src/Ganeti/Types.hs \
554
	src/Ganeti/Utils.hs
555

    
556
HS_TEST_SRCS = \
557
	test/hs/Test/Ganeti/Attoparsec.hs \
558
	test/hs/Test/Ganeti/BasicTypes.hs \
559
	test/hs/Test/Ganeti/Block/Drbd/Parser.hs \
560
	test/hs/Test/Ganeti/Block/Drbd/Types.hs \
561
	test/hs/Test/Ganeti/Common.hs \
562
	test/hs/Test/Ganeti/Confd/Types.hs \
563
	test/hs/Test/Ganeti/Confd/Utils.hs \
564
	test/hs/Test/Ganeti/Daemon.hs \
565
	test/hs/Test/Ganeti/Errors.hs \
566
	test/hs/Test/Ganeti/HTools/Backend/Simu.hs \
567
	test/hs/Test/Ganeti/HTools/Backend/Text.hs \
568
	test/hs/Test/Ganeti/HTools/CLI.hs \
569
	test/hs/Test/Ganeti/HTools/Cluster.hs \
570
	test/hs/Test/Ganeti/HTools/Container.hs \
571
	test/hs/Test/Ganeti/HTools/Graph.hs \
572
	test/hs/Test/Ganeti/HTools/Instance.hs \
573
	test/hs/Test/Ganeti/HTools/Loader.hs \
574
	test/hs/Test/Ganeti/HTools/Node.hs \
575
	test/hs/Test/Ganeti/HTools/PeerMap.hs \
576
	test/hs/Test/Ganeti/HTools/Types.hs \
577
	test/hs/Test/Ganeti/Hypervisor/Xen/XmParser.hs \
578
	test/hs/Test/Ganeti/JSON.hs \
579
	test/hs/Test/Ganeti/Jobs.hs \
580
	test/hs/Test/Ganeti/JQueue.hs \
581
	test/hs/Test/Ganeti/Luxi.hs \
582
	test/hs/Test/Ganeti/Network.hs \
583
	test/hs/Test/Ganeti/Objects.hs \
584
	test/hs/Test/Ganeti/OpCodes.hs \
585
	test/hs/Test/Ganeti/Query/Filter.hs \
586
	test/hs/Test/Ganeti/Query/Language.hs \
587
	test/hs/Test/Ganeti/Query/Network.hs \
588
	test/hs/Test/Ganeti/Query/Query.hs \
589
	test/hs/Test/Ganeti/Rpc.hs \
590
	test/hs/Test/Ganeti/Runtime.hs \
591
	test/hs/Test/Ganeti/Ssconf.hs \
592
	test/hs/Test/Ganeti/THH.hs \
593
	test/hs/Test/Ganeti/TestCommon.hs \
594
	test/hs/Test/Ganeti/TestHTools.hs \
595
	test/hs/Test/Ganeti/TestHelper.hs \
596
	test/hs/Test/Ganeti/Types.hs \
597
	test/hs/Test/Ganeti/Utils.hs
598

    
599
HS_LIBTEST_SRCS = $(HS_LIB_SRCS) $(HS_TEST_SRCS)
600

    
601
HS_BUILT_SRCS = \
602
	test/hs/Test/Ganeti/TestImports.hs \
603
	src/Ganeti/Constants.hs \
604
	src/Ganeti/Version.hs
605
HS_BUILT_SRCS_IN = $(patsubst %,%.in,$(HS_BUILT_SRCS))
606

    
607
$(RUN_IN_TEMPDIR): | stamp-directories
608

    
609
doc/html/index.html: ENABLE_MANPAGES =
610
doc/man-html/index.html: ENABLE_MANPAGES = 1
611
doc/man-html/index.html: doc/manpages-enabled.rst $(mandocrst)
612

    
613
# Note: we use here an order-only prerequisite, as the contents of
614
# _autoconf.py are not actually influencing the html build output: it
615
# has to exist in order for the sphinx module to be loaded
616
# successfully, but we certainly don't want the docs to be rebuilt if
617
# it changes
618
doc/html/index.html doc/man-html/index.html: $(docinput) doc/conf.py \
619
	configure.ac $(RUN_IN_TEMPDIR) lib/build/sphinx_ext.py \
620
	lib/build/shell_example_lexer.py lib/opcodes.py lib/ht.py \
621
	doc/css/style.css lib/rapi/connector.py lib/rapi/rlib2.py \
622
	| $(BUILT_PYTHON_SOURCES)
623
	@test -n "$(SPHINX)" || \
624
	    { echo 'sphinx-build' not found during configure; exit 1; }
625
if !MANPAGES_IN_DOC
626
	if test -n '$(ENABLE_MANPAGES)'; then \
627
	  echo 'Man pages in documentation were disabled at configure time' >&2; \
628
	  exit 1; \
629
	fi
630
endif
631
## Sphinx provides little control over what content should be included. Some
632
## mechanisms exist, but they all have drawbacks or actual issues. Since we
633
## build two different versions of the documentation--once without man pages and
634
## once, if enabled, with them--some control is necessary. xmpp-wrapper provides
635
## us with this, but requires running in a temporary directory. It moves the
636
## correct files into place depending on environment variables.
637
	dir=$(dir $@) && \
638
	@mkdir_p@ $$dir && \
639
	PYTHONPATH=. ENABLE_MANPAGES=$(ENABLE_MANPAGES) COPY_DOC=1 \
640
	$(RUN_IN_TEMPDIR) autotools/sphinx-wrapper $(SPHINX) -q -W -b html \
641
	    -d . \
642
	    -D version="$(VERSION_MAJOR).$(VERSION_MINOR)" \
643
	    -D release="$(PACKAGE_VERSION)" \
644
	    -D graphviz_dot="$(DOT)" \
645
	    -D enable_manpages="$(ENABLE_MANPAGES)" \
646
	    doc $(CURDIR)/$$dir && \
647
	rm -f $$dir/.buildinfo $$dir/objects.inv
648
	touch $@
649

    
650
doc/html: doc/html/index.html
651

    
652
doc/man-html: doc/man-html/index.html
653

    
654
doc/install-quick.rst: INSTALL
655
doc/news.rst: NEWS
656
doc/upgrade.rst: UPGRADE
657

    
658
doc/install-quick.rst doc/news.rst doc/upgrade.rst:
659
	set -e; \
660
	{ echo '.. This file is automatically updated at build time from $<.'; \
661
	  echo '.. Do not edit.'; \
662
	  echo; \
663
	  cat $<; \
664
	} > $@
665

    
666
doc/manpages-enabled.rst: Makefile | $(built_base_sources)
667
	{ echo '.. This file is automatically generated, do not edit!'; \
668
	  echo ''; \
669
	  echo 'Man pages'; \
670
	  echo '========='; \
671
	  echo; \
672
	  echo '.. toctree::'; \
673
	  echo '   :maxdepth: 1'; \
674
	  echo; \
675
	  for i in $(notdir $(mandocrst)); do \
676
	    echo "   $$i"; \
677
	  done | LC_ALL=C sort; \
678
	} > $@
679

    
680
doc/man-%.rst: man/%.gen Makefile $(REPLACE_VARS_SED) | $(built_base_sources)
681
if MANPAGES_IN_DOC
682
	{ echo '.. This file is automatically updated at build time from $<.'; \
683
	  echo '.. Do not edit.'; \
684
	  echo; \
685
	  echo "$*"; \
686
	  echo '=========================================='; \
687
	  tail -n +3 $< | sed -f $(REPLACE_VARS_SED); \
688
	} > $@
689
else
690
	echo 'Man pages in documentation were disabled at configure time' >&2; \
691
	exit 1;
692
endif
693

    
694
# Things to build but not to install (add it to EXTRA_DIST if it should be
695
# distributed)
696
noinst_DATA = \
697
	doc/html \
698
	$(BUILT_EXAMPLES) \
699
	doc/examples/bash_completion \
700
	doc/examples/bash_completion-debug \
701
	$(manhtml)
702

    
703
if MANPAGES_IN_DOC
704
noinst_DATA += doc/man-html
705
endif
706

    
707
gnt_scripts = \
708
	scripts/gnt-backup \
709
	scripts/gnt-cluster \
710
	scripts/gnt-debug \
711
	scripts/gnt-group \
712
	scripts/gnt-instance \
713
	scripts/gnt-job \
714
	scripts/gnt-network \
715
	scripts/gnt-node \
716
	scripts/gnt-os \
717
	scripts/gnt-storage
718

    
719
PYTHON_BOOTSTRAP_SBIN = \
720
	daemons/ganeti-masterd \
721
	daemons/ganeti-noded \
722
	daemons/ganeti-rapi \
723
	daemons/ganeti-watcher \
724
	$(gnt_scripts)
725

    
726
PYTHON_BOOTSTRAP = \
727
	$(PYTHON_BOOTSTRAP_SBIN) \
728
	tools/burnin \
729
	tools/ensure-dirs \
730
	tools/node-cleanup \
731
	tools/node-daemon-setup \
732
	tools/prepare-node-join
733

    
734
qa_scripts = \
735
	qa/__init__.py \
736
	qa/ganeti-qa.py \
737
	qa/qa_cluster.py \
738
	qa/qa_config.py \
739
	qa/qa_daemon.py \
740
	qa/qa_env.py \
741
	qa/qa_error.py \
742
	qa/qa_group.py \
743
	qa/qa_instance.py \
744
	qa/qa_job.py \
745
	qa/qa_node.py \
746
	qa/qa_os.py \
747
	qa/qa_rapi.py \
748
	qa/qa_tags.py \
749
	qa/qa_utils.py
750

    
751
bin_SCRIPTS =
752
if WANT_HTOOLS
753
bin_SCRIPTS += $(HS_BIN_PROGS)
754
install-exec-hook:
755
	@mkdir_p@ $(DESTDIR)$(iallocatorsdir)
756
# FIXME: this is a hardcoded logic, instead of auto-resolving
757
	$(LN_S) -f ../../../bin/htools \
758
	  $(DESTDIR)$(iallocatorsdir)/hail
759
	for role in $(HS_BIN_ROLES); do \
760
	  $(LN_S) -f htools $(DESTDIR)$(bindir)/$$role ; \
761
	done
762
endif
763

    
764
$(HS_ALL_PROGS): %: %.hs $(HS_LIBTEST_SRCS) $(HS_BUILT_SRCS) Makefile
765
	@if [ "$(notdir $@)" = "test" ] && [ "$(HS_NODEV)" ]; then \
766
	  echo "Error: cannot run unittests without the development" \
767
	       " libraries (see devnotes.rst)" 1>&2; \
768
	  exit 1; \
769
	fi
770
	@rm -f $(notdir $@).tix
771
	$(GHC) --make \
772
	  $(HFLAGS) \
773
	  $(HS_PARALLEL3) $(HS_REGEX_PCRE) \
774
	  -osuf $(notdir $@).o -hisuf $(notdir $@).hi \
775
	  $(HEXTRA) $(HEXTRA_INT) $@
776
	@touch "$@"
777

    
778
# for the test/hs/htest binary, we need to enable profiling/coverage
779
test/hs/htest: HEXTRA_INT=-fhpc -itest/hs
780

    
781
# we compile the hpc-htools binary with the program coverage
782
test/hs/hpc-htools: HEXTRA_INT=-fhpc
783

    
784
# we compile the hpc-mon-collector binary with the program coverage
785
test/hs/hpc-mon-collector: HEXTRA_INT=-fhpc
786

    
787
# test dependency
788
test/hs/offline-tests.sh: test/hs/hpc-htools test/hs/hpc-mon-collector
789

    
790
# rules for building profiling-enabled versions of the haskell
791
# programs: hs-prof does the full two-step build, whereas
792
# hs-prof-quick does only the final rebuild (hs-prof must have been
793
# run before)
794
.PHONY: hs-prof hs-prof-quick
795
hs-prof:
796
	@if [ -z "$(TARGET)" ]; then \
797
	  echo "You need to define TARGET when running this rule" 1>&2; \
798
	  exit 1; \
799
	fi
800
	$(MAKE) $(AM_MAKEFLAGS) clean
801
	$(MAKE) $(AM_MAKEFLAGS) $(TARGET) HEXTRA="-osuf o"
802
	rm -f $(HS_ALL_PROGS)
803
	$(MAKE) $(AM_MAKEFLAGS) hs-prof-quick
804

    
805
hs-prof-quick:
806
	@if [ -z "$(TARGET)" ]; then \
807
	  echo "You need to define TARGET when running this rule" 1>&2; \
808
	  exit 1; \
809
	fi
810
	$(MAKE) $(AM_MAKEFLAGS) $(TARGET) HEXTRA="-osuf prof_o -prof -auto-all"
811

    
812
dist_sbin_SCRIPTS = \
813
	tools/ganeti-listrunner
814

    
815
nodist_sbin_SCRIPTS = \
816
	$(PYTHON_BOOTSTRAP_SBIN) \
817
	daemons/ganeti-cleaner
818

    
819
if ENABLE_CONFD
820
src/ganeti-confd: src/hconfd
821
	cp -f $< $@
822

    
823
nodist_sbin_SCRIPTS += src/ganeti-confd
824
endif
825

    
826
python_scripts = \
827
	tools/cfgshell \
828
	tools/cfgupgrade \
829
	tools/cfgupgrade12 \
830
	tools/cluster-merge \
831
	tools/confd-client \
832
	tools/fmtjson \
833
	tools/lvmstrap \
834
	tools/move-instance \
835
	tools/ovfconverter \
836
	tools/sanitize-config
837

    
838
dist_tools_SCRIPTS = \
839
	$(python_scripts) \
840
	tools/kvm-console-wrapper \
841
	tools/master-ip-setup \
842
	tools/xen-console-wrapper
843

    
844
nodist_tools_python_scripts = \
845
	tools/node-cleanup
846

    
847
nodist_tools_SCRIPTS = \
848
	$(nodist_tools_python_scripts) \
849
	tools/vcluster-setup
850

    
851
pkglib_python_scripts = \
852
	daemons/import-export \
853
	tools/check-cert-expired
854

    
855
nodist_pkglib_python_scripts = \
856
	tools/burnin \
857
	tools/ensure-dirs \
858
	tools/node-daemon-setup \
859
	tools/prepare-node-join
860

    
861
myexeclib_SCRIPTS = \
862
	daemons/daemon-util \
863
	tools/kvm-ifup \
864
	$(pkglib_python_scripts) \
865
	$(HS_MYEXECLIB_PROGS)
866

    
867
nodist_myexeclib_SCRIPTS = \
868
	$(nodist_pkglib_python_scripts)
869

    
870
EXTRA_DIST = \
871
	NEWS \
872
	UPGRADE \
873
	epydoc.conf.in \
874
	pylintrc \
875
	autotools/build-bash-completion \
876
	autotools/build-rpc \
877
	autotools/check-header \
878
	autotools/check-imports \
879
	autotools/check-man-dashes \
880
	autotools/check-man-references \
881
	autotools/check-man-warnings \
882
	autotools/check-news \
883
	autotools/check-python-code \
884
	autotools/check-tar \
885
	autotools/check-version \
886
	autotools/convert-constants \
887
	autotools/docpp \
888
	autotools/gen-py-coverage \
889
	autotools/sphinx-wrapper \
890
	autotools/testrunner \
891
	autotools/wrong-hardcoded-paths \
892
	$(RUN_IN_TEMPDIR) \
893
	daemons/daemon-util.in \
894
	daemons/ganeti-cleaner.in \
895
	$(pkglib_python_scripts) \
896
	devel/upload \
897
	devel/webserver \
898
	tools/kvm-ifup.in \
899
	tools/vcluster-setup.in \
900
	$(docinput) \
901
	doc/html \
902
	$(BUILT_EXAMPLES:%=%.in) \
903
	doc/examples/ganeti.default \
904
	doc/examples/ganeti.default-debug \
905
	doc/examples/hooks/ethers \
906
	doc/examples/gnt-debug/README \
907
	doc/examples/gnt-debug/delay0.json \
908
	doc/examples/gnt-debug/delay50.json \
909
	test/py/lockperf.py \
910
	test/py/testutils.py \
911
	test/py/mocks.py \
912
	$(dist_TESTS) \
913
	$(TEST_FILES) \
914
	man/footer.rst \
915
	$(manrst) \
916
	$(maninput) \
917
	qa/qa-sample.json \
918
	$(qa_scripts) \
919
	$(HS_LIBTEST_SRCS) $(HS_BUILT_SRCS_IN) \
920
	$(HS_PROG_SRCS) \
921
	src/lint-hints.hs \
922
	test/hs/cli-tests-defs.sh \
923
	test/hs/offline-test.sh \
924
	.ghci
925

    
926
man_MANS = \
927
	man/ganeti-cleaner.8 \
928
	man/ganeti-confd.8 \
929
	man/ganeti-listrunner.8 \
930
	man/ganeti-masterd.8 \
931
	man/ganeti-noded.8 \
932
	man/ganeti-os-interface.7 \
933
	man/ganeti-extstorage-interface.7 \
934
	man/ganeti-rapi.8 \
935
	man/ganeti-watcher.8 \
936
	man/ganeti.7 \
937
	man/gnt-backup.8 \
938
	man/gnt-cluster.8 \
939
	man/gnt-debug.8 \
940
	man/gnt-group.8 \
941
	man/gnt-network.8 \
942
	man/gnt-instance.8 \
943
	man/gnt-job.8 \
944
	man/gnt-node.8 \
945
	man/gnt-os.8 \
946
	man/gnt-storage.8 \
947
	man/hail.1 \
948
	man/hbal.1 \
949
	man/hcheck.1 \
950
	man/hinfo.1 \
951
	man/hscan.1 \
952
	man/hspace.1 \
953
	man/hroller.1 \
954
	man/htools.1 \
955
	man/mon-collector.7
956

    
957
# Remove extensions from all filenames in man_MANS
958
mannoext = $(patsubst %.1,%,$(patsubst %.7,%,$(patsubst %.8,%,$(man_MANS))))
959

    
960
manrst = $(patsubst %,%.rst,$(mannoext))
961
manhtml = $(patsubst %.rst,%.html,$(manrst))
962
mangen = $(patsubst %.rst,%.gen,$(manrst))
963
maninput = \
964
	$(patsubst %.1,%.1.in,$(patsubst %.7,%.7.in,$(patsubst %.8,%.8.in,$(man_MANS)))) \
965
	$(patsubst %.html,%.html.in,$(manhtml)) \
966
	$(mangen)
967

    
968
TEST_FILES = \
969
	test/data/htools/clean-nonzero-score.data \
970
	test/data/htools/common-suffix.data \
971
	test/data/htools/empty-cluster.data \
972
	test/data/htools/hail-alloc-drbd.json \
973
	test/data/htools/hail-change-group.json \
974
	test/data/htools/hail-invalid-reloc.json \
975
	test/data/htools/hail-node-evac.json \
976
	test/data/htools/hail-reloc-drbd.json \
977
	test/data/htools/hbal-excl-tags.data \
978
	test/data/htools/hbal-split-insts.data \
979
	test/data/htools/invalid-node.data \
980
	test/data/htools/missing-resources.data \
981
	test/data/htools/n1-failure.data \
982
	test/data/htools/rapi/groups.json \
983
	test/data/htools/rapi/info.json \
984
	test/data/htools/rapi/instances.json \
985
	test/data/htools/rapi/nodes.json \
986
	test/hs/shelltests/htools-balancing.test \
987
	test/hs/shelltests/htools-basic.test \
988
	test/hs/shelltests/htools-dynutil.test \
989
	test/hs/shelltests/htools-excl.test \
990
	test/hs/shelltests/htools-hail.test \
991
	test/hs/shelltests/htools-hspace.test \
992
	test/hs/shelltests/htools-invalid.test \
993
	test/hs/shelltests/htools-multi-group.test \
994
	test/hs/shelltests/htools-no-backend.test \
995
	test/hs/shelltests/htools-rapi.test \
996
	test/hs/shelltests/htools-single-group.test \
997
	test/hs/shelltests/htools-text-backend.test \
998
	test/hs/shelltests/htools-mon-collector.test \
999
	test/data/bdev-drbd-8.0.txt \
1000
	test/data/bdev-drbd-8.3.txt \
1001
	test/data/bdev-drbd-disk.txt \
1002
	test/data/bdev-drbd-net-ip4.txt \
1003
	test/data/bdev-drbd-net-ip6.txt \
1004
	test/data/bdev-rbd/json_output_empty.txt \
1005
	test/data/bdev-rbd/json_output_extra_matches.txt \
1006
	test/data/bdev-rbd/json_output_no_matches.txt \
1007
	test/data/bdev-rbd/json_output_ok.txt \
1008
	test/data/bdev-rbd/plain_output_new_extra_matches.txt \
1009
	test/data/bdev-rbd/plain_output_new_no_matches.txt \
1010
	test/data/bdev-rbd/plain_output_new_ok.txt \
1011
	test/data/bdev-rbd/plain_output_old_empty.txt \
1012
	test/data/bdev-rbd/plain_output_old_extra_matches.txt \
1013
	test/data/bdev-rbd/plain_output_old_no_matches.txt \
1014
	test/data/bdev-rbd/plain_output_old_ok.txt \
1015
	test/data/bdev-rbd/output_invalid.txt \
1016
	test/data/cert1.pem \
1017
	test/data/cert2.pem \
1018
	test/data/instance-minor-pairing.txt \
1019
	test/data/ip-addr-show-dummy0.txt \
1020
	test/data/ip-addr-show-lo-ipv4.txt \
1021
	test/data/ip-addr-show-lo-ipv6.txt \
1022
	test/data/ip-addr-show-lo-oneline-ipv4.txt \
1023
	test/data/ip-addr-show-lo-oneline-ipv6.txt \
1024
	test/data/ip-addr-show-lo-oneline.txt \
1025
	test/data/ip-addr-show-lo.txt \
1026
	test/data/kvm_0.12.5_help.txt \
1027
	test/data/kvm_0.15.90_help.txt \
1028
	test/data/kvm_0.9.1_help.txt \
1029
	test/data/kvm_0.9.1_help_boot_test.txt \
1030
	test/data/kvm_1.0_help.txt \
1031
	test/data/kvm_1.1.2_help.txt \
1032
	test/data/ovfdata/compr_disk.vmdk.gz \
1033
	test/data/ovfdata/config.ini \
1034
	test/data/ovfdata/corrupted_resources.ovf \
1035
	test/data/ovfdata/empty.ini \
1036
	test/data/ovfdata/empty.ovf \
1037
	test/data/ovfdata/ganeti.mf \
1038
	test/data/ovfdata/ganeti.ovf \
1039
	test/data/ovfdata/gzip_disk.ovf \
1040
	test/data/ovfdata/new_disk.vmdk \
1041
	test/data/ovfdata/no_disk.ini \
1042
	test/data/ovfdata/no_disk_in_ref.ovf \
1043
	test/data/ovfdata/no_os.ini \
1044
	test/data/ovfdata/no_ovf.ova \
1045
	test/data/ovfdata/other/rawdisk.raw \
1046
	test/data/ovfdata/ova.ova \
1047
	test/data/ovfdata/rawdisk.raw \
1048
	test/data/ovfdata/second_disk.vmdk \
1049
	test/data/ovfdata/unsafe_path.ini \
1050
	test/data/ovfdata/virtualbox.ovf \
1051
	test/data/ovfdata/wrong_config.ini \
1052
	test/data/ovfdata/wrong_extension.ovd \
1053
	test/data/ovfdata/wrong_manifest.mf \
1054
	test/data/ovfdata/wrong_manifest.ovf \
1055
	test/data/ovfdata/wrong_ova.ova \
1056
	test/data/ovfdata/wrong_xml.ovf \
1057
	test/data/proc_drbd8.txt \
1058
	test/data/proc_drbd80-emptyline.txt \
1059
	test/data/proc_drbd83.txt \
1060
	test/data/proc_drbd83_sync.txt \
1061
	test/data/proc_drbd83_sync_want.txt \
1062
	test/data/proc_drbd83_sync_krnl2.6.39.txt \
1063
	test/data/qa-minimal-nodes-instances-only.json \
1064
	test/data/sys_drbd_usermode_helper.txt \
1065
	test/data/vgreduce-removemissing-2.02.02.txt \
1066
	test/data/vgreduce-removemissing-2.02.66-fail.txt \
1067
	test/data/vgreduce-removemissing-2.02.66-ok.txt \
1068
	test/data/vgs-missing-pvs-2.02.02.txt \
1069
	test/data/vgs-missing-pvs-2.02.66.txt \
1070
	test/data/xen-xm-info-4.0.1.txt \
1071
	test/data/xen-xm-list-4.0.1-dom0-only.txt \
1072
	test/data/xen-xm-list-4.0.1-four-instances.txt \
1073
	test/data/xen-xm-list-long-4.0.1.txt \
1074
	test/data/xen-xm-uptime-4.0.1.txt \
1075
	test/py/ganeti-cli.test \
1076
	test/py/gnt-cli.test \
1077
	test/py/import-export_unittest-helper
1078

    
1079
python_tests = \
1080
	doc/examples/rapi_testutils.py \
1081
	test/py/cfgupgrade_unittest.py \
1082
	test/py/docs_unittest.py \
1083
	test/py/ganeti.asyncnotifier_unittest.py \
1084
	test/py/ganeti.backend_unittest-runasroot.py \
1085
	test/py/ganeti.backend_unittest.py \
1086
	test/py/ganeti.bdev_unittest.py \
1087
	test/py/ganeti.cli_unittest.py \
1088
	test/py/ganeti.client.gnt_cluster_unittest.py \
1089
	test/py/ganeti.client.gnt_instance_unittest.py \
1090
	test/py/ganeti.client.gnt_job_unittest.py \
1091
	test/py/ganeti.cmdlib_unittest.py \
1092
	test/py/ganeti.compat_unittest.py \
1093
	test/py/ganeti.confd.client_unittest.py \
1094
	test/py/ganeti.config_unittest.py \
1095
	test/py/ganeti.constants_unittest.py \
1096
	test/py/ganeti.daemon_unittest.py \
1097
	test/py/ganeti.errors_unittest.py \
1098
	test/py/ganeti.hooks_unittest.py \
1099
	test/py/ganeti.ht_unittest.py \
1100
	test/py/ganeti.http_unittest.py \
1101
	test/py/ganeti.hypervisor.hv_chroot_unittest.py \
1102
	test/py/ganeti.hypervisor.hv_fake_unittest.py \
1103
	test/py/ganeti.hypervisor.hv_kvm_unittest.py \
1104
	test/py/ganeti.hypervisor.hv_lxc_unittest.py \
1105
	test/py/ganeti.hypervisor.hv_xen_unittest.py \
1106
	test/py/ganeti.hypervisor_unittest.py \
1107
	test/py/ganeti.impexpd_unittest.py \
1108
	test/py/ganeti.jqueue_unittest.py \
1109
	test/py/ganeti.jstore_unittest.py \
1110
	test/py/ganeti.locking_unittest.py \
1111
	test/py/ganeti.luxi_unittest.py \
1112
	test/py/ganeti.masterd.iallocator_unittest.py \
1113
	test/py/ganeti.masterd.instance_unittest.py \
1114
	test/py/ganeti.mcpu_unittest.py \
1115
	test/py/ganeti.netutils_unittest.py \
1116
	test/py/ganeti.objects_unittest.py \
1117
	test/py/ganeti.opcodes_unittest.py \
1118
	test/py/ganeti.outils_unittest.py \
1119
	test/py/ganeti.ovf_unittest.py \
1120
	test/py/ganeti.qlang_unittest.py \
1121
	test/py/ganeti.query_unittest.py \
1122
	test/py/ganeti.rapi.baserlib_unittest.py \
1123
	test/py/ganeti.rapi.client_unittest.py \
1124
	test/py/ganeti.rapi.resources_unittest.py \
1125
	test/py/ganeti.rapi.rlib2_unittest.py \
1126
	test/py/ganeti.rapi.testutils_unittest.py \
1127
	test/py/ganeti.rpc_unittest.py \
1128
	test/py/ganeti.runtime_unittest.py \
1129
	test/py/ganeti.serializer_unittest.py \
1130
	test/py/ganeti.server.rapi_unittest.py \
1131
	test/py/ganeti.ssconf_unittest.py \
1132
	test/py/ganeti.ssh_unittest.py \
1133
	test/py/ganeti.storage_unittest.py \
1134
	test/py/ganeti.tools.burnin_unittest.py \
1135
	test/py/ganeti.tools.ensure_dirs_unittest.py \
1136
	test/py/ganeti.tools.node_daemon_setup_unittest.py \
1137
	test/py/ganeti.tools.prepare_node_join_unittest.py \
1138
	test/py/ganeti.uidpool_unittest.py \
1139
	test/py/ganeti.utils.algo_unittest.py \
1140
	test/py/ganeti.utils.filelock_unittest.py \
1141
	test/py/ganeti.utils.hash_unittest.py \
1142
	test/py/ganeti.utils.io_unittest-runasroot.py \
1143
	test/py/ganeti.utils.io_unittest.py \
1144
	test/py/ganeti.utils.log_unittest.py \
1145
	test/py/ganeti.utils.lvm_unittest.py \
1146
	test/py/ganeti.utils.mlock_unittest.py \
1147
	test/py/ganeti.utils.nodesetup_unittest.py \
1148
	test/py/ganeti.utils.process_unittest.py \
1149
	test/py/ganeti.utils.retry_unittest.py \
1150
	test/py/ganeti.utils.text_unittest.py \
1151
	test/py/ganeti.utils.wrapper_unittest.py \
1152
	test/py/ganeti.utils.x509_unittest.py \
1153
	test/py/ganeti.utils_unittest.py \
1154
	test/py/ganeti.vcluster_unittest.py \
1155
	test/py/ganeti.workerpool_unittest.py \
1156
	test/py/pycurl_reset_unittest.py \
1157
	test/py/qa.qa_config_unittest.py \
1158
	test/py/tempfile_fork_unittest.py
1159

    
1160
haskell_tests = test/hs/htest
1161

    
1162
dist_TESTS = \
1163
	test/py/check-cert-expired_unittest.bash \
1164
	test/py/daemon-util_unittest.bash \
1165
	test/py/ganeti-cleaner_unittest.bash \
1166
	test/py/import-export_unittest.bash \
1167
	test/py/cli-test.bash \
1168
	test/py/bash_completion.bash \
1169
	$(python_tests)
1170

    
1171
nodist_TESTS =
1172
check_SCRIPTS =
1173

    
1174
if WANT_HSTESTS
1175
nodist_TESTS += $(haskell_tests)
1176
dist_TESTS += test/hs/offline-test.sh
1177
check_SCRIPTS += \
1178
	test/hs/hpc-htools \
1179
	test/hs/hpc-mon-collector \
1180
	$(HS_BUILT_TEST_HELPERS)
1181
endif
1182

    
1183
TESTS = $(dist_TESTS) $(nodist_TESTS)
1184

    
1185
# Environment for all tests
1186
PLAIN_TESTS_ENVIRONMENT = \
1187
	PYTHONPATH=. \
1188
	TOP_SRCDIR=$(abs_top_srcdir) TOP_BUILDDIR=$(abs_top_builddir) \
1189
	PYTHON=$(PYTHON) FAKEROOT=$(FAKEROOT_PATH) \
1190
	$(RUN_IN_TEMPDIR)
1191

    
1192
# Environment for tests run by automake
1193
TESTS_ENVIRONMENT = \
1194
	$(PLAIN_TESTS_ENVIRONMENT) $(abs_top_srcdir)/autotools/testrunner
1195

    
1196
all_python_code = \
1197
	$(dist_sbin_SCRIPTS) \
1198
	$(python_scripts) \
1199
	$(pkglib_python_scripts) \
1200
	$(nodist_pkglib_python_scripts) \
1201
	$(nodist_tools_python_scripts) \
1202
	$(python_tests) \
1203
	$(pkgpython_PYTHON) \
1204
	$(client_PYTHON) \
1205
	$(hypervisor_PYTHON) \
1206
	$(rapi_PYTHON) \
1207
	$(server_PYTHON) \
1208
	$(pytools_PYTHON) \
1209
	$(http_PYTHON) \
1210
	$(confd_PYTHON) \
1211
	$(masterd_PYTHON) \
1212
	$(impexpd_PYTHON) \
1213
	$(utils_PYTHON) \
1214
	$(watcher_PYTHON) \
1215
	$(noinst_PYTHON) \
1216
	$(qa_scripts)
1217

    
1218
srclink_files = \
1219
	man/footer.rst \
1220
	test/py/check-cert-expired_unittest.bash \
1221
	test/py/daemon-util_unittest.bash \
1222
	test/py/ganeti-cleaner_unittest.bash \
1223
	test/py/import-export_unittest.bash \
1224
	test/py/cli-test.bash \
1225
	test/py/bash_completion.bash \
1226
	test/hs/offline-test.sh \
1227
	test/hs/cli-tests-defs.sh \
1228
	$(all_python_code) \
1229
	$(HS_LIBTEST_SRCS) $(HS_PROG_SRCS) \
1230
	$(docinput)
1231

    
1232
check_python_code = \
1233
	$(BUILD_BASH_COMPLETION) \
1234
	$(CHECK_IMPORTS) \
1235
	$(CHECK_HEADER) \
1236
	$(DOCPP) \
1237
	$(all_python_code)
1238

    
1239
lint_python_code = \
1240
	ganeti \
1241
	ganeti/http/server.py \
1242
	$(dist_sbin_SCRIPTS) \
1243
	$(python_scripts) \
1244
	$(pkglib_python_scripts) \
1245
	$(BUILD_BASH_COMPLETION) \
1246
	$(CHECK_IMPORTS) \
1247
	$(CHECK_HEADER) \
1248
	$(DOCPP) \
1249
	$(PYTHON_BOOTSTRAP)
1250

    
1251
standalone_python_modules = \
1252
	lib/rapi/client.py \
1253
	tools/ganeti-listrunner
1254

    
1255
pep8_python_code = \
1256
	ganeti \
1257
	ganeti/http/server.py \
1258
	$(dist_sbin_SCRIPTS) \
1259
	$(python_scripts) \
1260
	$(pkglib_python_scripts) \
1261
	$(BUILD_BASH_COMPLETION) \
1262
	$(CHECK_HEADER) \
1263
	$(DOCPP) \
1264
	$(PYTHON_BOOTSTRAP) \
1265
	qa
1266

    
1267
test/py/daemon-util_unittest.bash: daemons/daemon-util
1268

    
1269
test/py/ganeti-cleaner_unittest.bash: daemons/ganeti-cleaner
1270

    
1271
test/py/bash_completion.bash: doc/examples/bash_completion-debug
1272

    
1273
tools/kvm-ifup: tools/kvm-ifup.in $(REPLACE_VARS_SED)
1274
	sed -f $(REPLACE_VARS_SED) < $< > $@
1275
	chmod +x $@
1276

    
1277
tools/vcluster-setup: tools/vcluster-setup.in $(REPLACE_VARS_SED)
1278
	sed -f $(REPLACE_VARS_SED) < $< > $@
1279
	chmod +x $@
1280

    
1281
daemons/%:: daemons/%.in $(REPLACE_VARS_SED)
1282
	sed -f $(REPLACE_VARS_SED) < $< > $@
1283
	chmod +x $@
1284

    
1285
doc/examples/%:: doc/examples/%.in $(REPLACE_VARS_SED)
1286
	sed -f $(REPLACE_VARS_SED) < $< > $@
1287

    
1288
doc/examples/bash_completion: BC_ARGS = --compact
1289
doc/examples/bash_completion-debug: BC_ARGS =
1290

    
1291
doc/examples/bash_completion doc/examples/bash_completion-debug: \
1292
	$(BUILD_BASH_COMPLETION) $(RUN_IN_TEMPDIR) \
1293
	lib/cli.py $(gnt_scripts) $(client_PYTHON) tools/burnin \
1294
	daemons/ganeti-cleaner \
1295
	$(GENERATED_FILES) $(HS_GENERATED_FILES)
1296
	PYTHONPATH=. $(RUN_IN_TEMPDIR) \
1297
	  $(CURDIR)/$(BUILD_BASH_COMPLETION) $(BC_ARGS) > $@
1298

    
1299
man/%.gen: man/%.rst lib/query.py lib/build/sphinx_ext.py \
1300
	lib/build/shell_example_lexer.py \
1301
	| $(RUN_IN_TEMPDIR) $(BUILT_PYTHON_SOURCES)
1302
	@echo "Checking $< for hardcoded paths..."
1303
	@if grep -nEf autotools/wrong-hardcoded-paths $<; then \
1304
	  echo "Man page $< has hardcoded paths (see above)!" 1>&2 ; \
1305
	  exit 1; \
1306
	fi
1307
	set -e ; \
1308
	trap 'echo auto-removing $@; rm $@' EXIT; \
1309
	PYTHONPATH=. $(RUN_IN_TEMPDIR) $(CURDIR)/$(DOCPP) < $< > $@ ;\
1310
	$(CHECK_MAN_REFERENCES) $@; \
1311
	trap - EXIT
1312

    
1313
man/%.7.in man/%.8.in man/%.1.in: man/%.gen man/footer.rst
1314
	@test -n "$(PANDOC)" || \
1315
	  { echo 'pandoc' not found during configure; exit 1; }
1316
	set -o pipefail ; \
1317
	trap 'echo auto-removing $@; rm $@' EXIT; \
1318
	$(PANDOC) -s -f rst -t man $< man/footer.rst | \
1319
	  sed -e 's/\\@/@/g' > $@; \
1320
	if test -n "$(MAN_HAS_WARNINGS)"; then $(CHECK_MAN_WARNINGS) $@; fi; \
1321
	$(CHECK_MAN_DASHES) $@; \
1322
	trap - EXIT
1323

    
1324
man/%.html.in: man/%.gen man/footer.rst
1325
	@test -n "$(PANDOC)" || \
1326
	  { echo 'pandoc' not found during configure; exit 1; }
1327
	set -o pipefail ; \
1328
	$(PANDOC) --toc -s -f rst -t html $< man/footer.rst | \
1329
	  sed -e 's/\\@/@/g' > $@
1330

    
1331
man/%: man/%.in  $(REPLACE_VARS_SED)
1332
	sed -f $(REPLACE_VARS_SED) < $< > $@
1333

    
1334
epydoc.conf: epydoc.conf.in $(REPLACE_VARS_SED)
1335
	sed -f $(REPLACE_VARS_SED) < $< > $@
1336

    
1337
vcs-version:
1338
	if test -d .git; then \
1339
	  git describe > $@; \
1340
	elif test ! -f $@ ; then \
1341
	  echo "Cannot auto-generate $@ file"; exit 1; \
1342
	fi
1343

    
1344
.PHONY: clean-vcs-version
1345
clean-vcs-version:
1346
	rm -f vcs-version
1347

    
1348
.PHONY: regen-vcs-version
1349
regen-vcs-version:
1350
	@set -e; \
1351
	cd $(srcdir); \
1352
	if test -d .git; then \
1353
	  T=`mktemp` ; trap 'rm -f $$T' EXIT; \
1354
	  git describe > $$T; \
1355
	  if ! cmp --quiet $$T vcs-version; then \
1356
	    mv $$T vcs-version; \
1357
	  fi; \
1358
	fi
1359

    
1360
src/Ganeti/Version.hs: src/Ganeti/Version.hs.in \
1361
	vcs-version $(built_base_sources)
1362
	set -e; \
1363
	VCSVER=`cat $(abs_top_srcdir)/vcs-version`; \
1364
	sed -e "s/%ver%/$$VCSVER/" < $< > $@
1365

    
1366
src/Ganeti/Constants.hs: src/Ganeti/Constants.hs.in \
1367
	lib/constants.py lib/_autoconf.py lib/luxi.py lib/errors.py \
1368
	lib/jstore.py $(RUN_IN_TEMPDIR) \
1369
	$(CONVERT_CONSTANTS) $(built_base_sources) \
1370
	| lib/_vcsversion.py
1371
	set -e; \
1372
	{ cat $< ; \
1373
	  PYTHONPATH=. $(RUN_IN_TEMPDIR) $(CURDIR)/$(CONVERT_CONSTANTS); \
1374
	} > $@
1375

    
1376
test/hs/Test/Ganeti/TestImports.hs: test/hs/Test/Ganeti/TestImports.hs.in \
1377
	$(built_base_sources)
1378
	set -e; \
1379
	{ cat $< ; \
1380
	  echo ; \
1381
	  for name in $(filter-out Ganeti.THH,$(subst /,.,$(patsubst %.hs,%,$(patsubst src/%,%,$(HS_LIB_SRCS))))) ; do \
1382
	    echo "import $$name ()" ; \
1383
	  done ; \
1384
	} > $@
1385

    
1386
lib/_autoconf.py: Makefile | stamp-directories
1387
	set -e; \
1388
	{ echo '# This file is automatically generated, do not edit!'; \
1389
	  echo '#'; \
1390
	  echo ''; \
1391
	  echo '"""Build-time configuration for Ganeti.'; \
1392
	  echo '';\
1393
	  echo 'This file is autogenerated by the build process.'; \
1394
	  echo 'For any changes you need to re-run ./configure (and'; \
1395
	  echo 'not edit by hand).'; \
1396
	  echo ''; \
1397
	  echo '"""'; \
1398
	  echo ''; \
1399
	  echo '# pylint: disable=C0301,C0324'; \
1400
	  echo '# because this is autogenerated, we do not want'; \
1401
	  echo '# style warnings' ; \
1402
	  echo ''; \
1403
	  echo "PACKAGE_VERSION = '$(PACKAGE_VERSION)'"; \
1404
	  echo "VERSION_MAJOR = '$(VERSION_MAJOR)'"; \
1405
	  echo "VERSION_MINOR = '$(VERSION_MINOR)'"; \
1406
	  echo "VERSION_REVISION = '$(VERSION_REVISION)'"; \
1407
	  echo "VERSION_SUFFIX = '$(VERSION_SUFFIX)'"; \
1408
	  echo "VERSION_FULL = '$(VERSION_FULL)'"; \
1409
	  echo "LOCALSTATEDIR = '$(localstatedir)'"; \
1410
	  echo "SYSCONFDIR = '$(sysconfdir)'"; \
1411
	  echo "SSH_CONFIG_DIR = '$(SSH_CONFIG_DIR)'"; \
1412
	  echo "SSH_LOGIN_USER = '$(SSH_LOGIN_USER)'"; \
1413
	  echo "SSH_CONSOLE_USER = '$(SSH_CONSOLE_USER)'"; \
1414
	  echo "EXPORT_DIR = '$(EXPORT_DIR)'"; \
1415
	  echo "OS_SEARCH_PATH = [$(OS_SEARCH_PATH)]"; \
1416
	  echo "ES_SEARCH_PATH = [$(ES_SEARCH_PATH)]"; \
1417
	  echo "XEN_BOOTLOADER = '$(XEN_BOOTLOADER)'"; \
1418
	  echo "XEN_CONFIG_DIR = '$(XEN_CONFIG_DIR)'"; \
1419
	  echo "XEN_KERNEL = '$(XEN_KERNEL)'"; \
1420
	  echo "XEN_INITRD = '$(XEN_INITRD)'"; \
1421
	  echo "KVM_KERNEL = '$(KVM_KERNEL)'"; \
1422
	  echo "FILE_STORAGE_DIR = '$(FILE_STORAGE_DIR)'"; \
1423
	  echo "ENABLE_FILE_STORAGE = $(ENABLE_FILE_STORAGE)"; \
1424
	  echo "SHARED_FILE_STORAGE_DIR = '$(SHARED_FILE_STORAGE_DIR)'"; \
1425
	  echo "ENABLE_SHARED_FILE_STORAGE = $(ENABLE_SHARED_FILE_STORAGE)"; \
1426
	  echo "IALLOCATOR_SEARCH_PATH = [$(IALLOCATOR_SEARCH_PATH)]"; \
1427
	  echo "KVM_PATH = '$(KVM_PATH)'"; \
1428
	  echo "IP_PATH = '$(IP_PATH)'"; \
1429
	  echo "SOCAT_PATH = '$(SOCAT)'"; \
1430
	  echo "SOCAT_USE_ESCAPE = $(SOCAT_USE_ESCAPE)"; \
1431
	  echo "SOCAT_USE_COMPRESS = $(SOCAT_USE_COMPRESS)"; \
1432
	  echo "LVM_STRIPECOUNT = $(LVM_STRIPECOUNT)"; \
1433
	  echo "TOOLSDIR = '$(toolsdir)'"; \
1434
	  echo "GNT_SCRIPTS = [$(foreach i,$(notdir $(gnt_scripts)),'$(i)',)]"; \
1435
	  echo "HTOOLS_PROGS = [$(foreach i,$(HS_HTOOLS_PROGS),'$(i)',)]"; \
1436
	  echo "PKGLIBDIR = '$(pkglibdir)'"; \
1437
	  echo "DRBD_BARRIERS = '$(DRBD_BARRIERS)'"; \
1438
	  echo "DRBD_NO_META_FLUSH = $(DRBD_NO_META_FLUSH)"; \
1439
	  echo "SYSLOG_USAGE = '$(SYSLOG_USAGE)'"; \
1440
	  echo "DAEMONS_GROUP = '$(DAEMONS_GROUP)'"; \
1441
	  echo "ADMIN_GROUP = '$(ADMIN_GROUP)'"; \
1442
	  echo "MASTERD_USER = '$(MASTERD_USER)'"; \
1443
	  echo "MASTERD_GROUP = '$(MASTERD_GROUP)'"; \
1444
	  echo "RAPI_USER = '$(RAPI_USER)'"; \
1445
	  echo "RAPI_GROUP = '$(RAPI_GROUP)'"; \
1446
	  echo "CONFD_USER = '$(CONFD_USER)'"; \
1447
	  echo "CONFD_GROUP = '$(CONFD_GROUP)'"; \
1448
	  echo "NODED_USER = '$(NODED_USER)'"; \
1449
	  echo "NODED_GROUP = '$(NODED_GROUP)'"; \
1450
	  echo "DISK_SEPARATOR = '$(DISK_SEPARATOR)'"; \
1451
	  echo "QEMUIMG_PATH = '$(QEMUIMG_PATH)'"; \
1452
	  echo "HTOOLS = True"; \
1453
	  echo "ENABLE_CONFD = $(ENABLE_CONFD)"; \
1454
	  echo "XEN_CMD = '$(XEN_CMD)'"; \
1455
	  echo "ENABLE_SPLIT_QUERY = $(ENABLE_SPLIT_QUERY)"; \
1456
	  echo "ENABLE_RESTRICTED_COMMANDS = $(ENABLE_RESTRICTED_COMMANDS)"; \
1457
	  echo "ENABLE_MONITORING = $(ENABLE_MONITORING)"; \
1458
## Write dictionary with man page name as the key and the section number as the
1459
## value
1460
	  echo "MAN_PAGES = {"; \
1461
	  for i in $(notdir $(man_MANS)); do \
1462
	    echo "$$i" | sed -re 's/^(.*)\.([0-9]+)$$/  "\1": \2,/g'; \
1463
	  done; \
1464
	  echo "}"; \
1465
	} > $@
1466

    
1467
lib/_vcsversion.py: Makefile vcs-version | stamp-directories
1468
	set -e; \
1469
	VCSVER=`cat $(abs_top_srcdir)/vcs-version`; \
1470
	{ echo '# This file is automatically generated, do not edit!'; \
1471
	  echo '#'; \
1472
	  echo ''; \
1473
	  echo '"""Build-time VCS version number for Ganeti.'; \
1474
	  echo '';\
1475
	  echo 'This file is autogenerated by the build process.'; \
1476
	  echo 'For any changes you need to re-run ./configure (and'; \
1477
	  echo 'not edit by hand).'; \
1478
	  echo ''; \
1479
	  echo '"""'; \
1480
	  echo ''; \
1481
	  echo '# pylint: disable=C0301,C0324'; \
1482
	  echo '# because this is autogenerated, we do not want'; \
1483
	  echo '# style warnings' ; \
1484
	  echo ''; \
1485
	  echo "VCS_VERSION = '$$VCSVER'"; \
1486
	} > $@
1487

    
1488
lib/_generated_rpc.py: lib/rpc_defs.py $(BUILD_RPC)
1489
	PYTHONPATH=. $(RUN_IN_TEMPDIR) $(CURDIR)/$(BUILD_RPC) lib/rpc_defs.py > $@
1490

    
1491
$(SHELL_ENV_INIT): Makefile stamp-directories
1492
	set -e; \
1493
	{ echo '# Allow overriding for tests'; \
1494
	  echo 'readonly LOCALSTATEDIR=$${LOCALSTATEDIR:-$${GANETI_ROOTDIR:-}$(localstatedir)}'; \
1495
	  echo 'readonly SYSCONFDIR=$${SYSCONFDIR:-$${GANETI_ROOTDIR:-}$(sysconfdir)}'; \
1496
	  echo; \
1497
	  echo 'readonly PKGLIBDIR=$(pkglibdir)'; \
1498
	  echo 'readonly LOG_DIR="$$LOCALSTATEDIR/log/ganeti"'; \
1499
	  echo 'readonly RUN_DIR="$$LOCALSTATEDIR/run/ganeti"'; \
1500
	  echo 'readonly DATA_DIR="$$LOCALSTATEDIR/lib/ganeti"'; \
1501
	  echo 'readonly CONF_DIR="$$SYSCONFDIR/ganeti"'; \
1502
	} > $@
1503

    
1504
## Writes sed script to replace placeholders with build-time values. The
1505
## additional quotes after the first @ sign are necessary to stop configure
1506
## from replacing those values as well.
1507
$(REPLACE_VARS_SED): $(SHELL_ENV_INIT) Makefile stamp-directories
1508
	set -e; \
1509
	{ echo 's#@''PREFIX@#$(prefix)#g'; \
1510
	  echo 's#@''SYSCONFDIR@#$(sysconfdir)#g'; \
1511
	  echo 's#@''LOCALSTATEDIR@#$(localstatedir)#g'; \
1512
	  echo 's#@''BINDIR@#$(bindir)#g'; \
1513
	  echo 's#@''SBINDIR@#$(sbindir)#g'; \
1514
	  echo 's#@''LIBDIR@#$(libdir)#g'; \
1515
	  echo 's#@''GANETI_VERSION@#$(PACKAGE_VERSION)#g'; \
1516
	  echo 's#@''CUSTOM_XEN_BOOTLOADER@#$(XEN_BOOTLOADER)#g'; \
1517
	  echo 's#@''CUSTOM_XEN_KERNEL@#$(XEN_KERNEL)#g'; \
1518
	  echo 's#@''CUSTOM_XEN_INITRD@#$(XEN_INITRD)#g'; \
1519
	  echo 's#@''CUSTOM_IALLOCATOR_SEARCH_PATH@#$(IALLOCATOR_SEARCH_PATH)#g'; \
1520
	  echo 's#@''CUSTOM_EXPORT_DIR@#$(EXPORT_DIR)#g'; \
1521
	  echo 's#@''RPL_FILE_STORAGE_DIR@#$(FILE_STORAGE_DIR)#g'; \
1522
	  echo 's#@''RPL_SSH_INITD_SCRIPT@#$(SSH_INITD_SCRIPT)#g'; \
1523
	  echo 's#@''PKGLIBDIR@#$(pkglibdir)#g'; \
1524
	  echo 's#@''GNTMASTERUSER@#$(MASTERD_USER)#g'; \
1525
	  echo 's#@''GNTRAPIUSER@#$(RAPI_USER)#g'; \
1526
	  echo 's#@''GNTCONFDUSER@#$(CONFD_USER)#g'; \
1527
	  echo 's#@''GNTNODEDUSER@#$(NODED_USER)#g'; \
1528
	  echo 's#@''GNTRAPIGROUP@#$(RAPI_GROUP)#g'; \
1529
	  echo 's#@''GNTADMINGROUP@#$(ADMIN_GROUP)#g'; \
1530
	  echo 's#@''GNTCONFDGROUP@#$(CONFD_GROUP)#g'; \
1531
	  echo 's#@''GNTMASTERDGROUP@#$(MASTERD_GROUP)#g'; \
1532
	  echo 's#@''GNTDAEMONSGROUP@#$(DAEMONS_GROUP)#g'; \
1533
	  echo 's#@''CUSTOM_ENABLE_CONFD@#$(ENABLE_CONFD)#g'; \
1534
	  echo 's#@''MODULES@#$(strip $(lint_python_code))#g'; \
1535
	  echo 's#@''XEN_CONFIG_DIR@#$(XEN_CONFIG_DIR)#g'; \
1536
	  echo; \
1537
	  echo '/^@SHELL_ENV_INIT@$$/ {'; \
1538
	  echo '  r $(SHELL_ENV_INIT)'; \
1539
	  echo '  d'; \
1540
	  echo '}'; \
1541
	} > $@
1542

    
1543
# Using deferred evaluation
1544
daemons/ganeti-%: MODULE = ganeti.server.$(patsubst ganeti-%,%,$(notdir $@))
1545
daemons/ganeti-watcher: MODULE = ganeti.watcher
1546
scripts/%: MODULE = ganeti.client.$(subst -,_,$(notdir $@))
1547
tools/burnin: MODULE = ganeti.tools.burnin
1548
tools/ensure-dirs: MODULE = ganeti.tools.ensure_dirs
1549
tools/node-daemon-setup: MODULE = ganeti.tools.node_daemon_setup
1550
tools/prepare-node-join: MODULE = ganeti.tools.prepare_node_join
1551
tools/node-cleanup: MODULE = ganeti.tools.node_cleanup
1552
$(HS_BUILT_TEST_HELPERS): TESTROLE = $(patsubst test/hs/%,%,$@)
1553

    
1554
$(PYTHON_BOOTSTRAP): Makefile | stamp-directories
1555
	test -n "$(MODULE)" || { echo Missing module; exit 1; }
1556
	set -e; \
1557
	{ echo '#!/usr/bin/python'; \
1558
	  echo '# This file is automatically generated, do not edit!'; \
1559
	  echo "# Edit $(MODULE) instead."; \
1560
	  echo; \
1561
	  echo '"""Bootstrap script for L{$(MODULE)}"""'; \
1562
	  echo; \
1563
	  echo '# pylint: disable=C0103'; \
1564
	  echo '# C0103: Invalid name'; \
1565
	  echo; \
1566
	  echo 'import sys'; \
1567
	  echo 'import $(MODULE) as main'; \
1568
	  echo; \
1569
	  echo '# Temporarily alias commands until bash completion'; \
1570
	  echo '# generator is changed'; \
1571
	  echo 'if hasattr(main, "commands"):'; \
1572
	  echo '  commands = main.commands # pylint: disable=E1101'; \
1573
	  echo 'if hasattr(main, "aliases"):'; \
1574
	  echo '  aliases = main.aliases # pylint: disable=E1101'; \
1575
	  echo; \
1576
	  echo 'if __name__ == "__main__":'; \
1577
	  echo '  sys.exit(main.Main())'; \
1578
	} > $@
1579
	chmod u+x $@
1580

    
1581
$(HS_BUILT_TEST_HELPERS): Makefile
1582
	@test -n "$(TESTROLE)" || { echo Missing TESTROLE; exit 1; }
1583
	set -e; \
1584
	{ echo '#!/bin/sh'; \
1585
	  echo '# This file is automatically generated, do not edit!'; \
1586
	  echo "# Edit Makefile.am instead."; \
1587
	  echo; \
1588
	  echo "HTOOLS=$(TESTROLE) exec ./test/hs/hpc-htools \"\$$@\""; \
1589
	} > $@
1590
	chmod u+x $@
1591

    
1592
stamp-directories: Makefile
1593
	$(MAKE) $(AM_MAKEFLAGS) ganeti
1594
	@mkdir_p@ $(DIRS) $(BUILDTIME_DIR_AUTOCREATE)
1595
	touch $@
1596

    
1597
# We need to create symlinks because "make distcheck" will not install Python
1598
# files when building.
1599
stamp-srclinks: Makefile | stamp-directories
1600
	set -e; \
1601
	for i in $(srclink_files); do \
1602
	  if test ! -f $$i -a -f $(abs_top_srcdir)/$$i; then \
1603
	    $(LN_S) $(abs_top_srcdir)/$$i $$i; \
1604
	  fi; \
1605
	done
1606
	touch $@
1607

    
1608
.PHONY: ganeti
1609
ganeti:
1610
	cd $(top_builddir) && test -h "$@" || { rm -f $@ && $(LN_S) lib $@; }
1611

    
1612
.PHONY: check-dirs
1613
check-dirs: $(GENERATED_FILES)
1614
	@set -e; \
1615
	find . -type d \( -name . -o -name .git -prune -o -print \) | { \
1616
	  error=; \
1617
	  while read dir; do \
1618
	    case "$$dir" in \
1619
	      $(strip $(patsubst %,(./%) ;;,$(DIRCHECK_EXCLUDE) $(DIRS))) \
1620
	      *) error=1; echo "Directory $$dir not listed in Makefile" >&2 ;; \
1621
	    esac; \
1622
	  done; \
1623
	  for dir in $(DIRS); do \
1624
	    if ! test -d "$$dir"; then \
1625
	      echo "Directory $$dir listed in DIRS does not exist" >&2; \
1626
	      error=1; \
1627
	    fi \
1628
	  done; \
1629
	  test -z "$$error"; \
1630
	}
1631

    
1632
.PHONY: check-local
1633
check-local: check-dirs $(GENERATED_FILES)
1634
	$(CHECK_PYTHON_CODE) $(check_python_code)
1635
	PYTHONPATH=. $(CHECK_HEADER) $(check_python_code)
1636
	$(CHECK_VERSION) $(VERSION) $(top_srcdir)/NEWS
1637
	$(CHECK_NEWS) < $(top_srcdir)/NEWS
1638
	PYTHONPATH=. $(RUN_IN_TEMPDIR) $(CURDIR)/$(CHECK_IMPORTS) . $(standalone_python_modules)
1639
	@expver=$(VERSION_MAJOR).$(VERSION_MINOR); \
1640
	error= ; \
1641
	if test "`head -n 1 $(top_srcdir)/README`" != "Ganeti $$expver"; then \
1642
	  echo "Incorrect version in README, expected $$expver" >&2; \
1643
	  error=1; \
1644
	fi; \
1645
	for file in doc/iallocator.rst doc/hooks.rst doc/virtual-cluster.rst \
1646
	    doc/security.rst; do \
1647
	  if test "`sed -ne '4 p' $(top_srcdir)/$$file`" != \
1648
	    "Documents Ganeti version $$expver"; then \
1649
	    echo "Incorrect version in $$file, expected $$expver" >&2; \
1650
	    error=1; \
1651
	  fi; \
1652
	done; \
1653
	if ! test -f $(top_srcdir)/doc/design-$$expver.rst; then \
1654
	  echo "File $(top_srcdir)/doc/design-$$expver.rst not found" >&2; \
1655
	  error=1; \
1656
	fi; \
1657
	if test "`sed -ne '5 p' $(top_srcdir)/doc/design-draft.rst`" != \
1658
	  ".. Last updated for Ganeti $$expver"; then \
1659
	  echo "doc/design-draft.rst was not updated for version $$expver" >&2; \
1660
	  error=1; \
1661
	fi; \
1662
	for file in configure.ac $(HS_LIBTEST_SRCS) $(HS_PROG_SRCS); do \
1663
	  if test $$(wc --max-line-length < $(top_srcdir)/$$file) -gt 80; then \
1664
	    echo "Longest line in $$file is longer than 80 characters" >&2; \
1665
	    error=1; \
1666
	  fi; \
1667
	done; \
1668
	test -z "$$error"
1669

    
1670
.PHONY: hs-tests
1671
hs-tests: test/hs/htest | $(BUILT_PYTHON_SOURCES)
1672
	@rm -f htest.tix
1673
	./test/hs/htest
1674

    
1675
.PHONY: hs-shell
1676
hs-shell: test/hs/hpc-htools test/hs/hpc-mon-collector $(HS_BUILT_TEST_HELPERS)
1677
	@rm -f hpc-htools.tix hpc-mon-collector.tix
1678
	HBINARY="./test/hs/hpc-htools" ./test/hs/offline-test.sh
1679

    
1680
.PHONY: hs-check
1681
hs-check: hs-tests hs-shell
1682

    
1683
# E111: indentation is not a multiple of four
1684
# E121: continuation line indentation is not a multiple of four
1685
#       (since our indent level is not 4)
1686
# E125: continuation line does not distinguish itself from next logical line
1687
#       (since our indent level is not 4)
1688
# E127: continuation line over-indented for visual indent
1689
#       (since our indent level is not 4)
1690
# note: do NOT add E128 here; it's a valid style error in most cases!
1691
# I've seen real errors, but also some cases were we indent wrongly
1692
# due to line length; try to rework the cases where it is triggered,
1693
# instead of silencing it
1694
# E261: at least two spaces before inline comment
1695
# E501: line too long (80 characters)
1696
PEP8_IGNORE = E111,E121,E125,E127,E261,E501
1697

    
1698
# For excluding pep8 expects filenames only, not whole paths
1699
PEP8_EXCLUDE = $(subst $(space),$(comma),$(strip $(notdir $(BUILT_PYTHON_SOURCES))))
1700

    
1701
LINT_TARGETS = pylint pylint-qa
1702
if HAS_PEP8
1703
LINT_TARGETS += pep8
1704
endif
1705
if HAS_HLINT
1706
LINT_TARGETS += hlint
1707
endif
1708

    
1709
.PHONY: lint
1710
lint: $(LINT_TARGETS)
1711

    
1712
.PHONY: pylint
1713
pylint: $(GENERATED_FILES)
1714
	@test -n "$(PYLINT)" || { echo 'pylint' not found during configure; exit 1; }
1715
	$(PYLINT) $(LINT_OPTS) $(lint_python_code)
1716

    
1717
.PHONY: pylint-qa
1718
pylint-qa: $(GENERATED_FILES)
1719
	@test -n "$(PYLINT)" || { echo 'pylint' not found during configure; exit 1; }
1720
	cd $(top_srcdir)/qa && \
1721
	  PYTHONPATH=$(abs_top_srcdir) $(PYLINT) $(LINT_OPTS) \
1722
	  --rcfile  ../pylintrc $(patsubst qa/%.py,%,$(qa_scripts))
1723

    
1724
.PHONY: pep8
1725
pep8: $(GENERATED_FILES)
1726
	@test -n "$(PEP8)" || { echo 'pep8' not found during configure; exit 1; }
1727
	$(PEP8) --ignore='$(PEP8_IGNORE)' --exclude='$(PEP8_EXCLUDE)' \
1728
	  --repeat $(pep8_python_code)
1729

    
1730
# FIXME: remove ignore "Use void" when GHC 6.x is deprecated
1731
HLINT_EXCLUDES = src/Ganeti/THH.hs test/hs/hpc-htools.hs
1732
.PHONY: hlint
1733
hlint: $(HS_BUILT_SRCS) src/lint-hints.hs
1734
	@test -n "$(HLINT)" || { echo 'hlint' not found during configure; exit 1; }
1735
	@rm -f doc/hs-lint.html
1736
	if tty -s; then C="-c"; else C=""; fi; \
1737
	$(HLINT) --utf8 --report=doc/hs-lint.html --cross $$C \
1738
	  --ignore "Use first" \
1739
	  --ignore "Use &&&" \
1740
	  --ignore "Use void" \
1741
	  --ignore "Reduce duplication" \
1742
	  --hint src/lint-hints \
1743
	  $(filter-out $(HLINT_EXCLUDES),$(HS_LIBTEST_SRCS) $(HS_PROG_SRCS))
1744
	@if [ ! -f doc/hs-lint.html ]; then \
1745
	  echo "All good" > doc/hs-lint.html; \
1746
	fi
1747

    
1748
# a dist hook rule for updating the vcs-version file; this is
1749
# hardcoded due to where it needs to build the file...
1750
dist-hook:
1751
	$(MAKE) $(AM_MAKEFLAGS) regen-vcs-version
1752
	rm -f $(top_distdir)/vcs-version
1753
	cp -p $(srcdir)/vcs-version $(top_distdir)
1754

    
1755
# a distcheck hook rule for catching revision control directories
1756
distcheck-hook:
1757
	if find $(top_distdir) -name .svn -or -name .git | grep .; then \
1758
	  echo "Found revision control files in final archive." 1>&2; \
1759
	  exit 1; \
1760
	fi
1761
	if find $(top_distdir) -name '*.py[co]' | grep .; then \
1762
	  echo "Found Python byte code in final archive." 1>&2; \
1763
	  exit 1; \
1764
	fi
1765
	if find $(top_distdir) -name '*~' | grep .; then \
1766
	  echo "Found backup files in final archive." 1>&2; \
1767
	  exit 1; \
1768
	fi
1769
# Empty files or directories should not be distributed. They can cause
1770
# unnecessary warnings for packagers. Directories used by automake during
1771
# distcheck must be excluded.
1772
	if find $(top_distdir) -empty -and -not \( \
1773
	    -path $(top_distdir)/_build -or \
1774
	    -path $(top_distdir)/_inst \) | grep .; then \
1775
	  echo "Found empty files or directories in final archive." 1>&2; \
1776
	  exit 1; \
1777
	fi
1778
	if test -n "$(BUILD_RELEASE)" && \
1779
	   grep -n -H -E '^\*.*unreleased' $(top_distdir)/NEWS; then \
1780
	   echo "Found unreleased version in NEWS." >&2; \
1781
	   exit 1; \
1782
	fi
1783
	if test -e $(top_distdir)/doc/man-html; then \
1784
	  echo "Found documentation including man pages in final archive" >&2; \
1785
	  exit 1; \
1786
	fi
1787

    
1788
# When building a release, stricter checks should be used
1789
distcheck-release dist-release: export BUILD_RELEASE = 1
1790
distcheck-release: distcheck
1791

    
1792
distrebuildcheck: dist
1793
	set -e; \
1794
	builddir=$$(mktemp -d $(abs_srcdir)/distrebuildcheck.XXXXXXX); \
1795
	trap "echo Removing $$builddir; cd $(abs_srcdir); rm -rf $$builddir" EXIT; \
1796
	cd $$builddir; \
1797
	tar xzf $(abs_srcdir)/$(distdir).tar.gz; \
1798
	cd $(distdir); \
1799
	./configure; \
1800
	$(MAKE) maintainer-clean; \
1801
	cp $(abs_srcdir)/vcs-version .; \
1802
	./configure; \
1803
	$(MAKE) $(AM_MAKEFLAGS)
1804

    
1805
dist-release: dist
1806
	set -e; \
1807
	for i in $(DIST_ARCHIVES); do \
1808
	  echo -n "Checking $$i ... "; \
1809
	  autotools/check-tar < $$i; \
1810
	  echo OK; \
1811
	done
1812

    
1813
install-exec-local:
1814
	@mkdir_p@ "$(DESTDIR)${localstatedir}/lib/ganeti" \
1815
	  "$(DESTDIR)${localstatedir}/log/ganeti" \
1816
	  "$(DESTDIR)${localstatedir}/run/ganeti"
1817

    
1818
.PHONY: apidoc
1819
if WANT_HSAPIDOC
1820
apidoc: py-apidoc hs-apidoc
1821
else
1822
apidoc: py-apidoc
1823
endif
1824

    
1825
.PHONY: py-apidoc
1826
py-apidoc: epydoc.conf $(RUN_IN_TEMPDIR) $(GENERATED_FILES)
1827
	env - PATH="$$PATH" PYTHONPATH="$$PYTHONPATH" \
1828
	$(RUN_IN_TEMPDIR) epydoc -v \
1829
	  --conf $(CURDIR)/epydoc.conf \
1830
	  --output $(CURDIR)/$(APIDOC_PY_DIR)
1831

    
1832
.PHONY: hs-apidoc
1833
hs-apidoc: $(HS_BUILT_SRCS)
1834
	@test -n "$(HSCOLOUR)" || \
1835
	    { echo 'HsColour' not found during configure; exit 1; }
1836
	@test -n "$(HADDOCK)" || \
1837
	    { echo 'haddock' not found during configure; exit 1; }
1838
	rm -rf $(APIDOC_HS_DIR)/*
1839
	for i in $(ALL_APIDOC_HS_DIRS); do \
1840
	  @mkdir_p@ $$i; \
1841
	done
1842
	$(HSCOLOUR) -print-css > $(APIDOC_HS_DIR)/Ganeti/hscolour.css
1843
	$(LN_S) ../hscolour.css $(APIDOC_HS_DIR)/Ganeti/HTools/hscolour.css
1844
	$(LN_S) ../hscolour.css $(APIDOC_HS_DIR)/Ganeti/Confd/hscolour.css
1845
	set -e ; \
1846
	cd src; \
1847
	OPTGHC=""; \
1848
	if [ "$(HS_PARALLEL3)" ]; \
1849
	then OPTGHC="$$OPTGHC --optghc=$(HS_PARALLEL3)"; \
1850
	fi; \
1851
	if [ "$(HS_REGEX_PCRE)" ]; \
1852
	then OPTGHC="$$OPTGHC --optghc=$(HS_REGEX_PCRE)"; \
1853
	fi; \
1854
	RELSRCS="$(HS_LIB_SRCS:src/%=%) $(patsubst src/%,%,$(filter src/%,$(HS_BUILT_SRCS)))"; \
1855
	for file in $$RELSRCS; do \
1856
	  hfile=`echo $$file|sed 's/\\.hs$$//'`.html; \
1857
	  $(HSCOLOUR) -css -anchor $$file > ../$(APIDOC_HS_DIR)/$$hfile ; \
1858
	done ; \
1859
	$(HADDOCK) --odir ../$(APIDOC_HS_DIR) --html --ignore-all-exports -w \
1860
	  -t ganeti -p haddock-prologue \
1861
	  --source-module="%{MODULE/.//}.html" \
1862
	  --source-entity="%{MODULE/.//}.html#%{NAME}" \
1863
	  $$OPTGHC \
1864
	  $(filter-out Ganeti/HTools/ExtLoader.hs,$(HS_LIB_SRCS:src/%=%))
1865

    
1866
.PHONY: TAGS
1867
TAGS: $(GENERATED_FILES)
1868
	rm -f TAGS
1869
	$(GHC) -e ":etags" -v0 \
1870
	  $(filter-out -O -Werror,$(HFLAGS)) \
1871
	  $(HS_PARALLEL3) $(HS_REGEX_PCRE) \
1872
	  $(HS_LIBTEST_SRCS)
1873
	find . -path './lib/*.py' -o -path './scripts/gnt-*' -o \
1874
	  -path './daemons/ganeti-*' -o -path './tools/*' -o \
1875
	  -path './qa/*.py' | \
1876
	  etags -l python -a -
1877

    
1878
.PHONY: coverage
1879
if WANT_HTOOLS
1880
coverage: py-coverage hs-coverage
1881
else
1882
coverage: py-coverage
1883
endif
1884

    
1885
.PHONY: py-coverage
1886
py-coverage: $(GENERATED_FILES) $(python_tests)
1887
	@test -n "$(PYCOVERAGE)" || \
1888
	    { echo 'python-coverage' not found during configure; exit 1; }
1889
	set -e; \
1890
	COVERAGE=$(PYCOVERAGE) \
1891
	COVERAGE_FILE=$(CURDIR)/$(COVERAGE_PY_DIR)/data \
1892
	TEXT_COVERAGE=$(CURDIR)/$(COVERAGE_PY_DIR)/report.txt \
1893
	HTML_COVERAGE=$(CURDIR)/$(COVERAGE_PY_DIR) \
1894
	$(PLAIN_TESTS_ENVIRONMENT) \
1895
	$(abs_top_srcdir)/autotools/gen-py-coverage \
1896
	$(python_tests)
1897

    
1898
.PHONY: hs-coverage
1899
hs-coverage: $(haskell_tests) test/hs/hpc-htools test/hs/hpc-mon-collector
1900
	rm -f *.tix
1901
	$(MAKE) $(AM_MAKEFLAGS) hs-check
1902
	@mkdir_p@ $(COVERAGE_HS_DIR)
1903
	hpc sum --union $(HPCEXCL) \
1904
	  htest.tix hpc-htools.tix hpc-mon-collector.tix > coverage-hs.tix
1905
	hpc markup --destdir=$(COVERAGE_HS_DIR) coverage-hs.tix
1906
	hpc report coverage-hs.tix
1907
	$(LN_S) -f hpc_index.html $(COVERAGE_HS_DIR)/index.html
1908

    
1909
# Special "kind-of-QA" target for htools, needs special setup (all
1910
# tools compiled with -fhpc)
1911
.PHONY: live-test
1912
live-test: all
1913
	set -e ; \
1914
	cd src; \
1915
	rm -f .hpc; $(LN_S) ../.hpc .hpc; \
1916
	rm -f *.tix *.mix; \
1917
	./live-test.sh; \
1918
	hpc sum --union $(HPCEXCL) $(addsuffix .tix,$(HS_PROGS:src/%=%)) \
1919
	  --output=live-test.tix ; \
1920
	@mkdir_p@ ../$(COVERAGE_HS_DIR) ; \
1921
	hpc markup --destdir=../$(COVERAGE_HS_DIR) live-test \
1922
	  --srcdir=.. $(HPCEXCL) ; \
1923
	hpc report --srcdir=.. live-test $(HPCEXCL)
1924

    
1925
commit-check: distcheck lint apidoc
1926

    
1927
.PHONY: gitignore-check
1928
gitignore-check:
1929
	@if [ -n "`git status --short`" ]; then \
1930
	  echo "Git status is not clean!" 1>&2 ; \
1931
	  git status --short; \
1932
	  exit 1; \
1933
	fi
1934

    
1935
# target to rebuild all man pages (both groff and html output)
1936
.PHONY: man
1937
man: $(man_MANS) $(manhtml)
1938

    
1939
# Target that builds all binaries (including those that are not
1940
# rebuilt except when running the tests)
1941
.PHONY: really-all
1942
really-all: all $(check_SCRIPTS) $(haskell_tests) $(HS_ALL_PROGS)
1943

    
1944
# we don't need the ancient implicit rules:
1945
%: %,v
1946
%: RCS/%,v
1947
%: RCS/%
1948
%: s.%
1949
%: SCCS/s.%
1950

    
1951
-include ./Makefile.local
1952

    
1953
# vim: set noet :