Statistics
| Branch: | Tag: | Revision:

root / Makefile.am @ 6d2e1c12

History | View | Annotate | Download (57.6 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
# Helper function to strip src/ and test/hs/ from a list
18
strip_hsroot = $(patsubst src/%,%,$(patsubst test/hs/%,%,$(1)))
19

    
20
# Use bash in order to be able to use pipefail
21
SHELL=/bin/bash
22

    
23
ACLOCAL_AMFLAGS = -I autotools
24
BUILD_BASH_COMPLETION = $(top_srcdir)/autotools/build-bash-completion
25
RUN_IN_TEMPDIR = $(top_srcdir)/autotools/run-in-tempdir
26
CHECK_PYTHON_CODE = $(top_srcdir)/autotools/check-python-code
27
CHECK_HEADER = $(top_srcdir)/autotools/check-header
28
CHECK_MAN_DASHES = $(top_srcdir)/autotools/check-man-dashes
29
CHECK_MAN_REFERENCES = $(top_srcdir)/autotools/check-man-references
30
CHECK_MAN_WARNINGS = $(top_srcdir)/autotools/check-man-warnings
31
CHECK_VERSION = $(top_srcdir)/autotools/check-version
32
CHECK_NEWS = $(top_srcdir)/autotools/check-news
33
CHECK_IMPORTS = $(top_srcdir)/autotools/check-imports
34
DOCPP = $(top_srcdir)/autotools/docpp
35
REPLACE_VARS_SED = autotools/replace_vars.sed
36
CONVERT_CONSTANTS = $(top_srcdir)/autotools/convert-constants
37
BUILD_RPC = $(top_srcdir)/autotools/build-rpc
38
SHELL_ENV_INIT = autotools/shell-env-init
39

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

    
58
# Delete output file if an error occurred while building it
59
.DELETE_ON_ERROR:
60

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

    
87
# Haskell directories without the roots (src, test/hs)
88
HS_DIRS_NOROOT = $(filter-out src,$(filter-out test/hs,$(HS_DIRS)))
89

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

    
126
ALL_APIDOC_HS_DIRS = \
127
	$(APIDOC_HS_DIR) \
128
	$(patsubst %,$(APIDOC_HS_DIR)/%,$(call strip_hsroot,$(HS_DIRS_NOROOT)))
129

    
130
BUILDTIME_DIR_AUTOCREATE = \
131
	scripts \
132
	$(APIDOC_DIR) \
133
	$(ALL_APIDOC_HS_DIRS) \
134
	$(APIDOC_PY_DIR) \
135
	$(COVERAGE_DIR) \
136
	$(COVERAGE_HS_DIR) \
137
	$(COVERAGE_PY_DIR) \
138
	.hpc
139

    
140
BUILDTIME_DIRS = \
141
	$(BUILDTIME_DIR_AUTOCREATE) \
142
	doc/html \
143
	doc/man-html
144

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

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

    
160
MAINTAINERCLEANFILES = \
161
	$(maninput) \
162
	doc/install-quick.rst \
163
	doc/news.rst \
164
	doc/upgrade.rst \
165
	vcs-version
166

    
167
maintainer-clean-local:
168
	rm -rf $(BUILDTIME_DIRS)
169

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

    
199
GENERATED_FILES = \
200
	$(built_base_sources) \
201
	$(BUILT_PYTHON_SOURCES) \
202
	$(PYTHON_BOOTSTRAP)
203

    
204
HS_GENERATED_FILES =
205
if WANT_HTOOLS
206
HS_GENERATED_FILES += $(HS_PROGS)
207
if ENABLE_CONFD
208
HS_GENERATED_FILES += src/hconfd src/ganeti-confd
209
endif
210
endif
211

    
212
built_base_sources = \
213
	stamp-directories \
214
	stamp-srclinks
215

    
216
built_python_base_sources = \
217
	lib/_autoconf.py \
218
	lib/_vcsversion.py
219

    
220
BUILT_PYTHON_SOURCES = \
221
	$(built_python_base_sources) \
222
	lib/_generated_rpc.py
223

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

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

    
238
nodist_pkgpython_PYTHON = \
239
	$(BUILT_PYTHON_SOURCES)
240

    
241
noinst_PYTHON = \
242
	lib/build/__init__.py \
243
	lib/build/shell_example_lexer.py \
244
	lib/build/sphinx_ext.py
245

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

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

    
298
hypervisor_PYTHON = \
299
	lib/hypervisor/__init__.py \
300
	lib/hypervisor/hv_base.py \
301
	lib/hypervisor/hv_chroot.py \
302
	lib/hypervisor/hv_fake.py \
303
	lib/hypervisor/hv_kvm.py \
304
	lib/hypervisor/hv_lxc.py \
305
	lib/hypervisor/hv_xen.py
306

    
307
rapi_PYTHON = \
308
	lib/rapi/__init__.py \
309
	lib/rapi/baserlib.py \
310
	lib/rapi/client.py \
311
	lib/rapi/client_utils.py \
312
	lib/rapi/connector.py \
313
	lib/rapi/rlib2.py \
314
	lib/rapi/testutils.py
315

    
316
http_PYTHON = \
317
	lib/http/__init__.py \
318
	lib/http/auth.py \
319
	lib/http/client.py \
320
	lib/http/server.py
321

    
322
confd_PYTHON = \
323
	lib/confd/__init__.py \
324
	lib/confd/client.py
325

    
326
masterd_PYTHON = \
327
	lib/masterd/__init__.py \
328
	lib/masterd/iallocator.py \
329
	lib/masterd/instance.py
330

    
331
impexpd_PYTHON = \
332
	lib/impexpd/__init__.py
333

    
334
watcher_PYTHON = \
335
	lib/watcher/__init__.py \
336
	lib/watcher/nodemaint.py \
337
	lib/watcher/state.py
338

    
339
server_PYTHON = \
340
	lib/server/__init__.py \
341
	lib/server/masterd.py \
342
	lib/server/noded.py \
343
	lib/server/rapi.py
344

    
345
pytools_PYTHON = \
346
	lib/tools/__init__.py \
347
	lib/tools/burnin.py \
348
	lib/tools/ensure_dirs.py \
349
	lib/tools/node_cleanup.py \
350
	lib/tools/node_daemon_setup.py \
351
	lib/tools/prepare_node_join.py
352

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

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

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

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

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

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

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

    
446
HS_BIN_ROLES = harep hbal hscan hspace hinfo hcheck hroller
447
HS_HTOOLS_PROGS = $(HS_BIN_ROLES) hail
448

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

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

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

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

    
482
HS_LIB_SRCS = \
483
	src/Ganeti/Block/Drbd/Types.hs \
484
	src/Ganeti/Block/Drbd/Parser.hs \
485
	src/Ganeti/BasicTypes.hs \
486
	src/Ganeti/Common.hs \
487
	src/Ganeti/Compat.hs \
488
	src/Ganeti/Confd/Client.hs \
489
	src/Ganeti/Confd/Server.hs \
490
	src/Ganeti/Confd/Types.hs \
491
	src/Ganeti/Confd/Utils.hs \
492
	src/Ganeti/Config.hs \
493
	src/Ganeti/Curl/Multi.hs \
494
	src/Ganeti/Daemon.hs \
495
	src/Ganeti/DataCollectors/CLI.hs \
496
	src/Ganeti/DataCollectors/Drbd.hs \
497
	src/Ganeti/DataCollectors/Program.hs \
498
	src/Ganeti/DataCollectors/Types.hs \
499
	src/Ganeti/Errors.hs \
500
	src/Ganeti/HTools/Backend/IAlloc.hs \
501
	src/Ganeti/HTools/Backend/Luxi.hs \
502
	src/Ganeti/HTools/Backend/Rapi.hs \
503
	src/Ganeti/HTools/Backend/Simu.hs \
504
	src/Ganeti/HTools/Backend/Text.hs \
505
	src/Ganeti/HTools/CLI.hs \
506
	src/Ganeti/HTools/Cluster.hs \
507
	src/Ganeti/HTools/Container.hs \
508
	src/Ganeti/HTools/ExtLoader.hs \
509
	src/Ganeti/HTools/Graph.hs \
510
	src/Ganeti/HTools/Group.hs \
511
	src/Ganeti/HTools/Instance.hs \
512
	src/Ganeti/HTools/Loader.hs \
513
	src/Ganeti/HTools/Node.hs \
514
	src/Ganeti/HTools/PeerMap.hs \
515
	src/Ganeti/HTools/Program/Hail.hs \
516
	src/Ganeti/HTools/Program/Harep.hs \
517
	src/Ganeti/HTools/Program/Hbal.hs \
518
	src/Ganeti/HTools/Program/Hcheck.hs \
519
	src/Ganeti/HTools/Program/Hinfo.hs \
520
	src/Ganeti/HTools/Program/Hscan.hs \
521
	src/Ganeti/HTools/Program/Hspace.hs \
522
	src/Ganeti/HTools/Program/Hroller.hs \
523
	src/Ganeti/HTools/Program/Main.hs \
524
	src/Ganeti/HTools/Types.hs \
525
	src/Ganeti/Hypervisor/Xen/XmParser.hs \
526
	src/Ganeti/Hypervisor/Xen/Types.hs \
527
	src/Ganeti/Hash.hs \
528
	src/Ganeti/JQueue.hs \
529
	src/Ganeti/JSON.hs \
530
	src/Ganeti/Jobs.hs \
531
	src/Ganeti/Logging.hs \
532
	src/Ganeti/Luxi.hs \
533
	src/Ganeti/Network.hs \
534
	src/Ganeti/Objects.hs \
535
	src/Ganeti/OpCodes.hs \
536
	src/Ganeti/OpParams.hs \
537
	src/Ganeti/Path.hs \
538
	src/Ganeti/Query/Common.hs \
539
	src/Ganeti/Query/Export.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/Curl/Internal.hs \
605
	src/Ganeti/Version.hs
606
HS_BUILT_SRCS_IN = \
607
	$(patsubst %,%.in,$(filter-out src/Ganeti/Curl/Internal.hs,$(HS_BUILT_SRCS))) \
608
	src/Ganeti/Curl/Internal.hsc
609

    
610
HS_LIBTESTBUILT_SRCS = $(HS_LIBTEST_SRCS) $(HS_BUILT_SRCS)
611

    
612
$(RUN_IN_TEMPDIR): | stamp-directories
613

    
614
doc/html/index.html: ENABLE_MANPAGES =
615
doc/man-html/index.html: ENABLE_MANPAGES = 1
616
doc/man-html/index.html: doc/manpages-enabled.rst $(mandocrst)
617

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

    
655
doc/html: doc/html/index.html
656

    
657
doc/man-html: doc/man-html/index.html
658

    
659
doc/install-quick.rst: INSTALL
660
doc/news.rst: NEWS
661
doc/upgrade.rst: UPGRADE
662

    
663
doc/install-quick.rst doc/news.rst doc/upgrade.rst:
664
	set -e; \
665
	{ echo '.. This file is automatically updated at build time from $<.'; \
666
	  echo '.. Do not edit.'; \
667
	  echo; \
668
	  cat $<; \
669
	} > $@
670

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

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

    
699
# Things to build but not to install (add it to EXTRA_DIST if it should be
700
# distributed)
701
noinst_DATA = \
702
	doc/html \
703
	$(BUILT_EXAMPLES) \
704
	doc/examples/bash_completion \
705
	doc/examples/bash_completion-debug \
706
	$(manhtml)
707

    
708
if MANPAGES_IN_DOC
709
noinst_DATA += doc/man-html
710
endif
711

    
712
gnt_scripts = \
713
	scripts/gnt-backup \
714
	scripts/gnt-cluster \
715
	scripts/gnt-debug \
716
	scripts/gnt-group \
717
	scripts/gnt-instance \
718
	scripts/gnt-job \
719
	scripts/gnt-network \
720
	scripts/gnt-node \
721
	scripts/gnt-os \
722
	scripts/gnt-storage
723

    
724
PYTHON_BOOTSTRAP_SBIN = \
725
	daemons/ganeti-masterd \
726
	daemons/ganeti-noded \
727
	daemons/ganeti-rapi \
728
	daemons/ganeti-watcher \
729
	$(gnt_scripts)
730

    
731
PYTHON_BOOTSTRAP = \
732
	$(PYTHON_BOOTSTRAP_SBIN) \
733
	tools/burnin \
734
	tools/ensure-dirs \
735
	tools/node-cleanup \
736
	tools/node-daemon-setup \
737
	tools/prepare-node-join
738

    
739
qa_scripts = \
740
	qa/__init__.py \
741
	qa/ganeti-qa.py \
742
	qa/qa_cluster.py \
743
	qa/qa_config.py \
744
	qa/qa_daemon.py \
745
	qa/qa_env.py \
746
	qa/qa_error.py \
747
	qa/qa_group.py \
748
	qa/qa_instance.py \
749
	qa/qa_job.py \
750
	qa/qa_node.py \
751
	qa/qa_os.py \
752
	qa/qa_rapi.py \
753
	qa/qa_tags.py \
754
	qa/qa_utils.py
755

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

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

    
783
# for the test/hs/htest binary, we need to enable profiling/coverage
784
test/hs/htest: HEXTRA_INT=-fhpc -itest/hs
785

    
786
# we compile the hpc-htools binary with the program coverage
787
test/hs/hpc-htools: HEXTRA_INT=-fhpc
788

    
789
# we compile the hpc-mon-collector binary with the program coverage
790
test/hs/hpc-mon-collector: HEXTRA_INT=-fhpc
791

    
792
# test dependency
793
test/hs/offline-tests.sh: test/hs/hpc-htools test/hs/hpc-mon-collector
794

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

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

    
817
dist_sbin_SCRIPTS = \
818
	tools/ganeti-listrunner
819

    
820
nodist_sbin_SCRIPTS = \
821
	$(PYTHON_BOOTSTRAP_SBIN) \
822
	daemons/ganeti-cleaner
823

    
824
if ENABLE_CONFD
825
src/ganeti-confd: src/hconfd
826
	cp -f $< $@
827

    
828
nodist_sbin_SCRIPTS += src/ganeti-confd
829
endif
830

    
831
python_scripts = \
832
	tools/cfgshell \
833
	tools/cfgupgrade \
834
	tools/cfgupgrade12 \
835
	tools/cluster-merge \
836
	tools/confd-client \
837
	tools/fmtjson \
838
	tools/lvmstrap \
839
	tools/move-instance \
840
	tools/ovfconverter \
841
	tools/sanitize-config
842

    
843
dist_tools_SCRIPTS = \
844
	$(python_scripts) \
845
	tools/kvm-console-wrapper \
846
	tools/master-ip-setup \
847
	tools/xen-console-wrapper
848

    
849
nodist_tools_python_scripts = \
850
	tools/node-cleanup
851

    
852
nodist_tools_SCRIPTS = \
853
	$(nodist_tools_python_scripts) \
854
	tools/vcluster-setup
855

    
856
pkglib_python_scripts = \
857
	daemons/import-export \
858
	tools/check-cert-expired
859

    
860
nodist_pkglib_python_scripts = \
861
	tools/burnin \
862
	tools/ensure-dirs \
863
	tools/node-daemon-setup \
864
	tools/prepare-node-join
865

    
866
myexeclib_SCRIPTS = \
867
	daemons/daemon-util \
868
	tools/kvm-ifup \
869
	$(pkglib_python_scripts) \
870
	$(HS_MYEXECLIB_PROGS)
871

    
872
nodist_myexeclib_SCRIPTS = \
873
	$(nodist_pkglib_python_scripts)
874

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

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

    
962
# Remove extensions from all filenames in man_MANS
963
mannoext = $(patsubst %.1,%,$(patsubst %.7,%,$(patsubst %.8,%,$(man_MANS))))
964

    
965
manrst = $(patsubst %,%.rst,$(mannoext))
966
manhtml = $(patsubst %.rst,%.html,$(manrst))
967
mangen = $(patsubst %.rst,%.gen,$(manrst))
968
maninput = \
969
	$(patsubst %.1,%.1.in,$(patsubst %.7,%.7.in,$(patsubst %.8,%.8.in,$(man_MANS)))) \
970
	$(patsubst %.html,%.html.in,$(manhtml)) \
971
	$(mangen)
972

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

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

    
1165
haskell_tests = test/hs/htest
1166

    
1167
dist_TESTS = \
1168
	test/py/check-cert-expired_unittest.bash \
1169
	test/py/daemon-util_unittest.bash \
1170
	test/py/ganeti-cleaner_unittest.bash \
1171
	test/py/import-export_unittest.bash \
1172
	test/py/cli-test.bash \
1173
	test/py/bash_completion.bash \
1174
	$(python_tests)
1175

    
1176
nodist_TESTS =
1177
check_SCRIPTS =
1178

    
1179
if WANT_HSTESTS
1180
nodist_TESTS += $(haskell_tests)
1181
dist_TESTS += test/hs/offline-test.sh
1182
check_SCRIPTS += \
1183
	test/hs/hpc-htools \
1184
	test/hs/hpc-mon-collector \
1185
	$(HS_BUILT_TEST_HELPERS)
1186
endif
1187

    
1188
TESTS = $(dist_TESTS) $(nodist_TESTS)
1189

    
1190
# Environment for all tests
1191
PLAIN_TESTS_ENVIRONMENT = \
1192
	PYTHONPATH=. \
1193
	TOP_SRCDIR=$(abs_top_srcdir) TOP_BUILDDIR=$(abs_top_builddir) \
1194
	PYTHON=$(PYTHON) FAKEROOT=$(FAKEROOT_PATH) \
1195
	$(RUN_IN_TEMPDIR)
1196

    
1197
# Environment for tests run by automake
1198
TESTS_ENVIRONMENT = \
1199
	$(PLAIN_TESTS_ENVIRONMENT) $(abs_top_srcdir)/autotools/testrunner
1200

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

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

    
1237
check_python_code = \
1238
	$(BUILD_BASH_COMPLETION) \
1239
	$(CHECK_IMPORTS) \
1240
	$(CHECK_HEADER) \
1241
	$(DOCPP) \
1242
	$(all_python_code)
1243

    
1244
lint_python_code = \
1245
	ganeti \
1246
	ganeti/http/server.py \
1247
	$(dist_sbin_SCRIPTS) \
1248
	$(python_scripts) \
1249
	$(pkglib_python_scripts) \
1250
	$(BUILD_BASH_COMPLETION) \
1251
	$(CHECK_IMPORTS) \
1252
	$(CHECK_HEADER) \
1253
	$(DOCPP) \
1254
	$(PYTHON_BOOTSTRAP)
1255

    
1256
standalone_python_modules = \
1257
	lib/rapi/client.py \
1258
	tools/ganeti-listrunner
1259

    
1260
pep8_python_code = \
1261
	ganeti \
1262
	ganeti/http/server.py \
1263
	$(dist_sbin_SCRIPTS) \
1264
	$(python_scripts) \
1265
	$(pkglib_python_scripts) \
1266
	$(BUILD_BASH_COMPLETION) \
1267
	$(CHECK_HEADER) \
1268
	$(DOCPP) \
1269
	$(PYTHON_BOOTSTRAP) \
1270
	qa
1271

    
1272
test/py/daemon-util_unittest.bash: daemons/daemon-util
1273

    
1274
test/py/ganeti-cleaner_unittest.bash: daemons/ganeti-cleaner
1275

    
1276
test/py/bash_completion.bash: doc/examples/bash_completion-debug
1277

    
1278
tools/kvm-ifup: tools/kvm-ifup.in $(REPLACE_VARS_SED)
1279
	sed -f $(REPLACE_VARS_SED) < $< > $@
1280
	chmod +x $@
1281

    
1282
tools/vcluster-setup: tools/vcluster-setup.in $(REPLACE_VARS_SED)
1283
	sed -f $(REPLACE_VARS_SED) < $< > $@
1284
	chmod +x $@
1285

    
1286
daemons/%:: daemons/%.in $(REPLACE_VARS_SED)
1287
	sed -f $(REPLACE_VARS_SED) < $< > $@
1288
	chmod +x $@
1289

    
1290
doc/examples/%:: doc/examples/%.in $(REPLACE_VARS_SED)
1291
	sed -f $(REPLACE_VARS_SED) < $< > $@
1292

    
1293
doc/examples/bash_completion: BC_ARGS = --compact
1294
doc/examples/bash_completion-debug: BC_ARGS =
1295

    
1296
doc/examples/bash_completion doc/examples/bash_completion-debug: \
1297
	$(BUILD_BASH_COMPLETION) $(RUN_IN_TEMPDIR) \
1298
	lib/cli.py $(gnt_scripts) $(client_PYTHON) tools/burnin \
1299
	daemons/ganeti-cleaner \
1300
	$(GENERATED_FILES) $(HS_GENERATED_FILES)
1301
	PYTHONPATH=. $(RUN_IN_TEMPDIR) \
1302
	  $(CURDIR)/$(BUILD_BASH_COMPLETION) $(BC_ARGS) > $@
1303

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

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

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

    
1336
man/%: man/%.in  $(REPLACE_VARS_SED)
1337
	sed -f $(REPLACE_VARS_SED) < $< > $@
1338

    
1339
epydoc.conf: epydoc.conf.in $(REPLACE_VARS_SED)
1340
	sed -f $(REPLACE_VARS_SED) < $< > $@
1341

    
1342
vcs-version:
1343
	if test -d .git; then \
1344
	  git describe > $@; \
1345
	elif test ! -f $@ ; then \
1346
	  echo "Cannot auto-generate $@ file"; exit 1; \
1347
	fi
1348

    
1349
.PHONY: clean-vcs-version
1350
clean-vcs-version:
1351
	rm -f vcs-version
1352

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

    
1365
src/Ganeti/Version.hs: src/Ganeti/Version.hs.in \
1366
	vcs-version $(built_base_sources)
1367
	set -e; \
1368
	VCSVER=`cat $(abs_top_srcdir)/vcs-version`; \
1369
	sed -e "s/%ver%/$$VCSVER/" < $< > $@
1370

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

    
1381
src/Ganeti/Curl/Internal.hs: src/Ganeti/Curl/Internal.hsc | stamp-directories
1382
	hsc2hs -o $@ $<
1383

    
1384
test/hs/Test/Ganeti/TestImports.hs: test/hs/Test/Ganeti/TestImports.hs.in \
1385
	$(built_base_sources)
1386
	set -e; \
1387
	{ cat $< ; \
1388
	  echo ; \
1389
	  for name in $(filter-out Ganeti.THH,$(subst /,.,$(patsubst %.hs,%,$(patsubst src/%,%,$(HS_LIB_SRCS))))) ; do \
1390
	    echo "import $$name ()" ; \
1391
	  done ; \
1392
	} > $@
1393

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

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

    
1498
lib/_generated_rpc.py: lib/rpc_defs.py $(BUILD_RPC)
1499
	PYTHONPATH=. $(RUN_IN_TEMPDIR) $(CURDIR)/$(BUILD_RPC) lib/rpc_defs.py > $@
1500

    
1501
$(SHELL_ENV_INIT): Makefile stamp-directories
1502
	set -e; \
1503
	{ echo '# Allow overriding for tests'; \
1504
	  echo 'readonly LOCALSTATEDIR=$${LOCALSTATEDIR:-$${GANETI_ROOTDIR:-}$(localstatedir)}'; \
1505
	  echo 'readonly SYSCONFDIR=$${SYSCONFDIR:-$${GANETI_ROOTDIR:-}$(sysconfdir)}'; \
1506
	  echo; \
1507
	  echo 'readonly PKGLIBDIR=$(pkglibdir)'; \
1508
	  echo 'readonly LOG_DIR="$$LOCALSTATEDIR/log/ganeti"'; \
1509
	  echo 'readonly RUN_DIR="$$LOCALSTATEDIR/run/ganeti"'; \
1510
	  echo 'readonly DATA_DIR="$$LOCALSTATEDIR/lib/ganeti"'; \
1511
	  echo 'readonly CONF_DIR="$$SYSCONFDIR/ganeti"'; \
1512
	} > $@
1513

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

    
1556
# Using deferred evaluation
1557
daemons/ganeti-%: MODULE = ganeti.server.$(patsubst ganeti-%,%,$(notdir $@))
1558
daemons/ganeti-watcher: MODULE = ganeti.watcher
1559
scripts/%: MODULE = ganeti.client.$(subst -,_,$(notdir $@))
1560
tools/burnin: MODULE = ganeti.tools.burnin
1561
tools/ensure-dirs: MODULE = ganeti.tools.ensure_dirs
1562
tools/node-daemon-setup: MODULE = ganeti.tools.node_daemon_setup
1563
tools/prepare-node-join: MODULE = ganeti.tools.prepare_node_join
1564
tools/node-cleanup: MODULE = ganeti.tools.node_cleanup
1565
$(HS_BUILT_TEST_HELPERS): TESTROLE = $(patsubst test/hs/%,%,$@)
1566

    
1567
$(PYTHON_BOOTSTRAP): Makefile | stamp-directories
1568
	test -n "$(MODULE)" || { echo Missing module; exit 1; }
1569
	set -e; \
1570
	{ echo '#!/usr/bin/python'; \
1571
	  echo '# This file is automatically generated, do not edit!'; \
1572
	  echo "# Edit $(MODULE) instead."; \
1573
	  echo; \
1574
	  echo '"""Bootstrap script for L{$(MODULE)}"""'; \
1575
	  echo; \
1576
	  echo '# pylint: disable=C0103'; \
1577
	  echo '# C0103: Invalid name'; \
1578
	  echo; \
1579
	  echo 'import sys'; \
1580
	  echo 'import $(MODULE) as main'; \
1581
	  echo; \
1582
	  echo '# Temporarily alias commands until bash completion'; \
1583
	  echo '# generator is changed'; \
1584
	  echo 'if hasattr(main, "commands"):'; \
1585
	  echo '  commands = main.commands # pylint: disable=E1101'; \
1586
	  echo 'if hasattr(main, "aliases"):'; \
1587
	  echo '  aliases = main.aliases # pylint: disable=E1101'; \
1588
	  echo; \
1589
	  echo 'if __name__ == "__main__":'; \
1590
	  echo '  sys.exit(main.Main())'; \
1591
	} > $@
1592
	chmod u+x $@
1593

    
1594
$(HS_BUILT_TEST_HELPERS): Makefile
1595
	@test -n "$(TESTROLE)" || { echo Missing TESTROLE; exit 1; }
1596
	set -e; \
1597
	{ echo '#!/bin/sh'; \
1598
	  echo '# This file is automatically generated, do not edit!'; \
1599
	  echo "# Edit Makefile.am instead."; \
1600
	  echo; \
1601
	  echo "HTOOLS=$(TESTROLE) exec ./test/hs/hpc-htools \"\$$@\""; \
1602
	} > $@
1603
	chmod u+x $@
1604

    
1605
stamp-directories: Makefile
1606
	$(MAKE) $(AM_MAKEFLAGS) ganeti
1607
	@mkdir_p@ $(DIRS) $(BUILDTIME_DIR_AUTOCREATE)
1608
	touch $@
1609

    
1610
# We need to create symlinks because "make distcheck" will not install Python
1611
# files when building.
1612
stamp-srclinks: Makefile | stamp-directories
1613
	set -e; \
1614
	for i in $(srclink_files); do \
1615
	  if test ! -f $$i -a -f $(abs_top_srcdir)/$$i; then \
1616
	    $(LN_S) $(abs_top_srcdir)/$$i $$i; \
1617
	  fi; \
1618
	done
1619
	touch $@
1620

    
1621
.PHONY: ganeti
1622
ganeti:
1623
	cd $(top_builddir) && test -h "$@" || { rm -f $@ && $(LN_S) lib $@; }
1624

    
1625
.PHONY: check-dirs
1626
check-dirs: $(GENERATED_FILES)
1627
	@set -e; \
1628
	find . -type d \( -name . -o -name .git -prune -o -print \) | { \
1629
	  error=; \
1630
	  while read dir; do \
1631
	    case "$$dir" in \
1632
	      $(strip $(patsubst %,(./%) ;;,$(DIRCHECK_EXCLUDE) $(DIRS))) \
1633
	      *) error=1; echo "Directory $$dir not listed in Makefile" >&2 ;; \
1634
	    esac; \
1635
	  done; \
1636
	  for dir in $(DIRS); do \
1637
	    if ! test -d "$$dir"; then \
1638
	      echo "Directory $$dir listed in DIRS does not exist" >&2; \
1639
	      error=1; \
1640
	    fi \
1641
	  done; \
1642
	  test -z "$$error"; \
1643
	}
1644

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

    
1683
.PHONY: hs-tests
1684
hs-tests: test/hs/htest | $(BUILT_PYTHON_SOURCES)
1685
	@rm -f htest.tix
1686
	./test/hs/htest
1687

    
1688
.PHONY: hs-shell
1689
hs-shell: test/hs/hpc-htools test/hs/hpc-mon-collector $(HS_BUILT_TEST_HELPERS)
1690
	@rm -f hpc-htools.tix hpc-mon-collector.tix
1691
	HBINARY="./test/hs/hpc-htools" ./test/hs/offline-test.sh
1692

    
1693
.PHONY: hs-check
1694
hs-check: hs-tests hs-shell
1695

    
1696
# E111: indentation is not a multiple of four
1697
# E121: continuation line indentation is not a multiple of four
1698
#       (since our indent level is not 4)
1699
# E125: continuation line does not distinguish itself from next logical line
1700
#       (since our indent level is not 4)
1701
# E127: continuation line over-indented for visual indent
1702
#       (since our indent level is not 4)
1703
# note: do NOT add E128 here; it's a valid style error in most cases!
1704
# I've seen real errors, but also some cases were we indent wrongly
1705
# due to line length; try to rework the cases where it is triggered,
1706
# instead of silencing it
1707
# E261: at least two spaces before inline comment
1708
# E501: line too long (80 characters)
1709
PEP8_IGNORE = E111,E121,E125,E127,E261,E501
1710

    
1711
# For excluding pep8 expects filenames only, not whole paths
1712
PEP8_EXCLUDE = $(subst $(space),$(comma),$(strip $(notdir $(BUILT_PYTHON_SOURCES))))
1713

    
1714
LINT_TARGETS = pylint pylint-qa
1715
if HAS_PEP8
1716
LINT_TARGETS += pep8
1717
endif
1718
if HAS_HLINT
1719
LINT_TARGETS += hlint
1720
endif
1721

    
1722
.PHONY: lint
1723
lint: $(LINT_TARGETS)
1724

    
1725
.PHONY: pylint
1726
pylint: $(GENERATED_FILES)
1727
	@test -n "$(PYLINT)" || { echo 'pylint' not found during configure; exit 1; }
1728
	$(PYLINT) $(LINT_OPTS) $(lint_python_code)
1729

    
1730
.PHONY: pylint-qa
1731
pylint-qa: $(GENERATED_FILES)
1732
	@test -n "$(PYLINT)" || { echo 'pylint' not found during configure; exit 1; }
1733
	cd $(top_srcdir)/qa && \
1734
	  PYTHONPATH=$(abs_top_srcdir) $(PYLINT) $(LINT_OPTS) \
1735
	  --rcfile  ../pylintrc $(patsubst qa/%.py,%,$(qa_scripts))
1736

    
1737
.PHONY: pep8
1738
pep8: $(GENERATED_FILES)
1739
	@test -n "$(PEP8)" || { echo 'pep8' not found during configure; exit 1; }
1740
	$(PEP8) --ignore='$(PEP8_IGNORE)' --exclude='$(PEP8_EXCLUDE)' \
1741
	  --repeat $(pep8_python_code)
1742

    
1743
# FIXME: remove ignore "Use void" when GHC 6.x is deprecated
1744
HLINT_EXCLUDES = src/Ganeti/THH.hs test/hs/hpc-htools.hs
1745
.PHONY: hlint
1746
hlint: $(HS_BUILT_SRCS) src/lint-hints.hs
1747
	@test -n "$(HLINT)" || { echo 'hlint' not found during configure; exit 1; }
1748
	@rm -f doc/hs-lint.html
1749
	if tty -s; then C="-c"; else C=""; fi; \
1750
	$(HLINT) --utf8 --report=doc/hs-lint.html --cross $$C \
1751
	  --ignore "Use first" \
1752
	  --ignore "Use &&&" \
1753
	  --ignore "Use void" \
1754
	  --ignore "Reduce duplication" \
1755
	  --hint src/lint-hints \
1756
	  $(filter-out $(HLINT_EXCLUDES),$(HS_LIBTEST_SRCS) $(HS_PROG_SRCS))
1757
	@if [ ! -f doc/hs-lint.html ]; then \
1758
	  echo "All good" > doc/hs-lint.html; \
1759
	fi
1760

    
1761
# a dist hook rule for updating the vcs-version file; this is
1762
# hardcoded due to where it needs to build the file...
1763
dist-hook:
1764
	$(MAKE) $(AM_MAKEFLAGS) regen-vcs-version
1765
	rm -f $(top_distdir)/vcs-version
1766
	cp -p $(srcdir)/vcs-version $(top_distdir)
1767

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

    
1801
# When building a release, stricter checks should be used
1802
distcheck-release dist-release: export BUILD_RELEASE = 1
1803
distcheck-release: distcheck
1804

    
1805
distrebuildcheck: dist
1806
	set -e; \
1807
	builddir=$$(mktemp -d $(abs_srcdir)/distrebuildcheck.XXXXXXX); \
1808
	trap "echo Removing $$builddir; cd $(abs_srcdir); rm -rf $$builddir" EXIT; \
1809
	cd $$builddir; \
1810
	tar xzf $(abs_srcdir)/$(distdir).tar.gz; \
1811
	cd $(distdir); \
1812
	./configure; \
1813
	$(MAKE) maintainer-clean; \
1814
	cp $(abs_srcdir)/vcs-version .; \
1815
	./configure; \
1816
	$(MAKE) $(AM_MAKEFLAGS)
1817

    
1818
dist-release: dist
1819
	set -e; \
1820
	for i in $(DIST_ARCHIVES); do \
1821
	  echo -n "Checking $$i ... "; \
1822
	  autotools/check-tar < $$i; \
1823
	  echo OK; \
1824
	done
1825

    
1826
install-exec-local:
1827
	@mkdir_p@ "$(DESTDIR)${localstatedir}/lib/ganeti" \
1828
	  "$(DESTDIR)${localstatedir}/log/ganeti" \
1829
	  "$(DESTDIR)${localstatedir}/run/ganeti"
1830

    
1831
.PHONY: apidoc
1832
if WANT_HSAPIDOC
1833
apidoc: py-apidoc hs-apidoc
1834
else
1835
apidoc: py-apidoc
1836
endif
1837

    
1838
.PHONY: py-apidoc
1839
py-apidoc: epydoc.conf $(RUN_IN_TEMPDIR) $(GENERATED_FILES)
1840
	env - PATH="$$PATH" PYTHONPATH="$$PYTHONPATH" \
1841
	$(RUN_IN_TEMPDIR) epydoc -v \
1842
	  --conf $(CURDIR)/epydoc.conf \
1843
	  --output $(CURDIR)/$(APIDOC_PY_DIR)
1844

    
1845
.PHONY: hs-apidoc
1846
hs-apidoc: $(APIDOC_HS_DIR)/index.html
1847

    
1848
$(APIDOC_HS_DIR)/index.html: $(HS_LIBTESTBUILT_SRCS) Makefile
1849
	@test -n "$(HSCOLOUR)" || \
1850
	    { echo 'HsColour' not found during configure; exit 1; }
1851
	@test -n "$(HADDOCK)" || \
1852
	    { echo 'haddock' not found during configure; exit 1; }
1853
	rm -rf $(APIDOC_HS_DIR)/*
1854
	for i in $(ALL_APIDOC_HS_DIRS); do \
1855
	  @mkdir_p@ $$i; \
1856
	  $(HSCOLOUR) -print-css > $$i/hscolour.css; \
1857
	done
1858
	set -e ; \
1859
	export LC_ALL=en_US.UTF-8; \
1860
	OPTGHC="--optghc=-isrc --optghc=-itest/hs"; \
1861
	if [ "$(HS_PARALLEL3)" ]; \
1862
	then OPTGHC="$$OPTGHC --optghc=$(HS_PARALLEL3)"; \
1863
	fi; \
1864
	if [ "$(HS_REGEX_PCRE)" ]; \
1865
	then OPTGHC="$$OPTGHC --optghc=$(HS_REGEX_PCRE)"; \
1866
	fi; \
1867
	for file in $(HS_LIBTESTBUILT_SRCS); do \
1868
	  f_nosrc=$${file##src/}; \
1869
	  f_notst=$${f_nosrc##test/hs/}; \
1870
	  f_html=$${f_notst%%.hs}.html; \
1871
	  $(HSCOLOUR) -css -anchor $$file > $(APIDOC_HS_DIR)/$$f_html ; \
1872
	done ; \
1873
	$(HADDOCK) --odir $(APIDOC_HS_DIR) --html --ignore-all-exports -w \
1874
	  -t ganeti -p src/haddock-prologue \
1875
	  --source-module="%{MODULE/.//}.html" \
1876
	  --source-entity="%{MODULE/.//}.html#%{NAME}" \
1877
	  $$OPTGHC \
1878
	  $(HS_LIBTESTBUILT_SRCS)
1879

    
1880
.PHONY: TAGS
1881
TAGS: $(GENERATED_FILES)
1882
	rm -f TAGS
1883
	$(GHC) -e ":etags" -v0 \
1884
	  $(filter-out -O -Werror,$(HFLAGS)) \
1885
	  $(HS_PARALLEL3) $(HS_REGEX_PCRE) \
1886
	  $(HS_LIBTEST_SRCS)
1887
	find . -path './lib/*.py' -o -path './scripts/gnt-*' -o \
1888
	  -path './daemons/ganeti-*' -o -path './tools/*' -o \
1889
	  -path './qa/*.py' | \
1890
	  etags -l python -a -
1891

    
1892
.PHONY: coverage
1893
if WANT_HTOOLS
1894
coverage: py-coverage hs-coverage
1895
else
1896
coverage: py-coverage
1897
endif
1898

    
1899
.PHONY: py-coverage
1900
py-coverage: $(GENERATED_FILES) $(python_tests)
1901
	@test -n "$(PYCOVERAGE)" || \
1902
	    { echo 'python-coverage' not found during configure; exit 1; }
1903
	set -e; \
1904
	COVERAGE=$(PYCOVERAGE) \
1905
	COVERAGE_FILE=$(CURDIR)/$(COVERAGE_PY_DIR)/data \
1906
	TEXT_COVERAGE=$(CURDIR)/$(COVERAGE_PY_DIR)/report.txt \
1907
	HTML_COVERAGE=$(CURDIR)/$(COVERAGE_PY_DIR) \
1908
	$(PLAIN_TESTS_ENVIRONMENT) \
1909
	$(abs_top_srcdir)/autotools/gen-py-coverage \
1910
	$(python_tests)
1911

    
1912
.PHONY: hs-coverage
1913
hs-coverage: $(haskell_tests) test/hs/hpc-htools test/hs/hpc-mon-collector
1914
	rm -f *.tix
1915
	$(MAKE) $(AM_MAKEFLAGS) hs-check
1916
	@mkdir_p@ $(COVERAGE_HS_DIR)
1917
	hpc sum --union $(HPCEXCL) \
1918
	  htest.tix hpc-htools.tix hpc-mon-collector.tix > coverage-hs.tix
1919
	hpc markup --destdir=$(COVERAGE_HS_DIR) coverage-hs.tix
1920
	hpc report coverage-hs.tix
1921
	$(LN_S) -f hpc_index.html $(COVERAGE_HS_DIR)/index.html
1922

    
1923
# Special "kind-of-QA" target for htools, needs special setup (all
1924
# tools compiled with -fhpc)
1925
.PHONY: live-test
1926
live-test: all
1927
	set -e ; \
1928
	cd src; \
1929
	rm -f .hpc; $(LN_S) ../.hpc .hpc; \
1930
	rm -f *.tix *.mix; \
1931
	./live-test.sh; \
1932
	hpc sum --union $(HPCEXCL) $(addsuffix .tix,$(HS_PROGS:src/%=%)) \
1933
	  --output=live-test.tix ; \
1934
	@mkdir_p@ ../$(COVERAGE_HS_DIR) ; \
1935
	hpc markup --destdir=../$(COVERAGE_HS_DIR) live-test \
1936
	  --srcdir=.. $(HPCEXCL) ; \
1937
	hpc report --srcdir=.. live-test $(HPCEXCL)
1938

    
1939
commit-check: distcheck lint apidoc
1940

    
1941
.PHONY: gitignore-check
1942
gitignore-check:
1943
	@if [ -n "`git status --short`" ]; then \
1944
	  echo "Git status is not clean!" 1>&2 ; \
1945
	  git status --short; \
1946
	  exit 1; \
1947
	fi
1948

    
1949
# target to rebuild all man pages (both groff and html output)
1950
.PHONY: man
1951
man: $(man_MANS) $(manhtml)
1952

    
1953
# Target that builds all binaries (including those that are not
1954
# rebuilt except when running the tests)
1955
.PHONY: really-all
1956
really-all: all $(check_SCRIPTS) $(haskell_tests) $(HS_ALL_PROGS)
1957

    
1958
# we don't need the ancient implicit rules:
1959
%: %,v
1960
%: RCS/%,v
1961
%: RCS/%
1962
%: s.%
1963
%: SCCS/s.%
1964

    
1965
-include ./Makefile.local
1966

    
1967
# vim: set noet :