Statistics
| Branch: | Tag: | Revision:

root / Makefile.am @ cc40185c

History | View | Annotate | Download (57.5 kB)

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

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

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

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

    
20
ACLOCAL_AMFLAGS = -I autotools
21
BUILD_BASH_COMPLETION = $(top_srcdir)/autotools/build-bash-completion
22
RUN_IN_TEMPDIR = $(top_srcdir)/autotools/run-in-tempdir
23
CHECK_PYTHON_CODE = $(top_srcdir)/autotools/check-python-code
24
CHECK_HEADER = $(top_srcdir)/autotools/check-header
25
CHECK_MAN_DASHES = $(top_srcdir)/autotools/check-man-dashes
26
CHECK_MAN_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/Curl \
65
	src/Ganeti/DataCollectors \
66
	src/Ganeti/HTools \
67
	src/Ganeti/HTools/Backend \
68
	src/Ganeti/HTools/Program \
69
	src/Ganeti/Hypervisor \
70
	src/Ganeti/Hypervisor/Xen \
71
	src/Ganeti/Query \
72
	test/hs \
73
	test/hs/Test \
74
	test/hs/Test/Ganeti \
75
	test/hs/Test/Ganeti/Block \
76
	test/hs/Test/Ganeti/Block/Drbd \
77
	test/hs/Test/Ganeti/Confd \
78
	test/hs/Test/Ganeti/HTools \
79
	test/hs/Test/Ganeti/HTools/Backend \
80
	test/hs/Test/Ganeti/Hypervisor \
81
	test/hs/Test/Ganeti/Hypervisor/Xen \
82
	test/hs/Test/Ganeti/Query
83

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

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

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

    
145
BUILDTIME_DIRS = \
146
	$(BUILDTIME_DIR_AUTOCREATE) \
147
	doc/html \
148
	doc/man-html
149

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

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

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

    
172
maintainer-clean-local:
173
	rm -rf $(BUILDTIME_DIRS)
174

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

    
204
GENERATED_FILES = \
205
	$(built_base_sources) \
206
	$(BUILT_PYTHON_SOURCES) \
207
	$(PYTHON_BOOTSTRAP)
208

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

    
217
built_base_sources = \
218
	stamp-directories \
219
	stamp-srclinks
220

    
221
built_python_base_sources = \
222
	lib/_autoconf.py \
223
	lib/_vcsversion.py
224

    
225
BUILT_PYTHON_SOURCES = \
226
	$(built_python_base_sources) \
227
	lib/_generated_rpc.py
228

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

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

    
243
nodist_pkgpython_PYTHON = \
244
	$(BUILT_PYTHON_SOURCES)
245

    
246
noinst_PYTHON = \
247
	lib/build/__init__.py \
248
	lib/build/shell_example_lexer.py \
249
	lib/build/sphinx_ext.py
250

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

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

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

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

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

    
327
confd_PYTHON = \
328
	lib/confd/__init__.py \
329
	lib/confd/client.py
330

    
331
masterd_PYTHON = \
332
	lib/masterd/__init__.py \
333
	lib/masterd/iallocator.py \
334
	lib/masterd/instance.py
335

    
336
impexpd_PYTHON = \
337
	lib/impexpd/__init__.py
338

    
339
watcher_PYTHON = \
340
	lib/watcher/__init__.py \
341
	lib/watcher/nodemaint.py \
342
	lib/watcher/state.py
343

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

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

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

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

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

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

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

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

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

    
450
HS_BIN_ROLES = harep hbal hscan hspace hinfo hcheck hroller
451
HS_HTOOLS_PROGS = $(HS_BIN_ROLES) hail
452

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

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

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

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

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

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

    
602
HS_LIBTEST_SRCS = $(HS_LIB_SRCS) $(HS_TEST_SRCS)
603

    
604
HS_BUILT_SRCS = \
605
	test/hs/Test/Ganeti/TestImports.hs \
606
	src/Ganeti/Constants.hs \
607
	src/Ganeti/Curl/Internal.hs \
608
	src/Ganeti/Version.hs
609
HS_BUILT_SRCS_IN = \
610
	$(patsubst %,%.in,$(filter-out src/Ganeti/Curl/Internal.hs,$(HS_BUILT_SRCS))) \
611
	src/Ganeti/Curl/Internal.hsc
612

    
613
$(RUN_IN_TEMPDIR): | stamp-directories
614

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

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

    
656
doc/html: doc/html/index.html
657

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
818
dist_sbin_SCRIPTS = \
819
	tools/ganeti-listrunner
820

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

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

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

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

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

    
850
nodist_tools_python_scripts = \
851
	tools/node-cleanup
852

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

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

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

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

    
873
nodist_myexeclib_SCRIPTS = \
874
	$(nodist_pkglib_python_scripts)
875

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

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

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

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

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

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

    
1166
haskell_tests = test/hs/htest
1167

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

    
1177
nodist_TESTS =
1178
check_SCRIPTS =
1179

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
1601
stamp-directories: Makefile
1602
	$(MAKE) $(AM_MAKEFLAGS) ganeti
1603
	@mkdir_p@ $(DIRS) $(BUILDTIME_DIR_AUTOCREATE)
1604
	touch $@
1605

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

    
1617
.PHONY: ganeti
1618
ganeti:
1619
	cd $(top_builddir) && test -h "$@" || { rm -f $@ && $(LN_S) lib $@; }
1620

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

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

    
1679
.PHONY: hs-tests
1680
hs-tests: test/hs/htest | $(BUILT_PYTHON_SOURCES)
1681
	@rm -f htest.tix
1682
	./test/hs/htest
1683

    
1684
.PHONY: hs-shell
1685
hs-shell: test/hs/hpc-htools test/hs/hpc-mon-collector $(HS_BUILT_TEST_HELPERS)
1686
	@rm -f hpc-htools.tix hpc-mon-collector.tix
1687
	HBINARY="./test/hs/hpc-htools" ./test/hs/offline-test.sh
1688

    
1689
.PHONY: hs-check
1690
hs-check: hs-tests hs-shell
1691

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

    
1707
# For excluding pep8 expects filenames only, not whole paths
1708
PEP8_EXCLUDE = $(subst $(space),$(comma),$(strip $(notdir $(BUILT_PYTHON_SOURCES))))
1709

    
1710
LINT_TARGETS = pylint pylint-qa
1711
if HAS_PEP8
1712
LINT_TARGETS += pep8
1713
endif
1714
if HAS_HLINT
1715
LINT_TARGETS += hlint
1716
endif
1717

    
1718
.PHONY: lint
1719
lint: $(LINT_TARGETS)
1720

    
1721
.PHONY: pylint
1722
pylint: $(GENERATED_FILES)
1723
	@test -n "$(PYLINT)" || { echo 'pylint' not found during configure; exit 1; }
1724
	$(PYLINT) $(LINT_OPTS) $(lint_python_code)
1725

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

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

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

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

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

    
1797
# When building a release, stricter checks should be used
1798
distcheck-release dist-release: export BUILD_RELEASE = 1
1799
distcheck-release: distcheck
1800

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

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

    
1822
install-exec-local:
1823
	@mkdir_p@ "$(DESTDIR)${localstatedir}/lib/ganeti" \
1824
	  "$(DESTDIR)${localstatedir}/log/ganeti" \
1825
	  "$(DESTDIR)${localstatedir}/run/ganeti"
1826

    
1827
.PHONY: apidoc
1828
if WANT_HSAPIDOC
1829
apidoc: py-apidoc hs-apidoc
1830
else
1831
apidoc: py-apidoc
1832
endif
1833

    
1834
.PHONY: py-apidoc
1835
py-apidoc: epydoc.conf $(RUN_IN_TEMPDIR) $(GENERATED_FILES)
1836
	env - PATH="$$PATH" PYTHONPATH="$$PYTHONPATH" \
1837
	$(RUN_IN_TEMPDIR) epydoc -v \
1838
	  --conf $(CURDIR)/epydoc.conf \
1839
	  --output $(CURDIR)/$(APIDOC_PY_DIR)
1840

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

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

    
1887
.PHONY: coverage
1888
if WANT_HTOOLS
1889
coverage: py-coverage hs-coverage
1890
else
1891
coverage: py-coverage
1892
endif
1893

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

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

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

    
1934
commit-check: distcheck lint apidoc
1935

    
1936
.PHONY: gitignore-check
1937
gitignore-check:
1938
	@if [ -n "`git status --short`" ]; then \
1939
	  echo "Git status is not clean!" 1>&2 ; \
1940
	  git status --short; \
1941
	  exit 1; \
1942
	fi
1943

    
1944
# target to rebuild all man pages (both groff and html output)
1945
.PHONY: man
1946
man: $(man_MANS) $(manhtml)
1947

    
1948
# Target that builds all binaries (including those that are not
1949
# rebuilt except when running the tests)
1950
.PHONY: really-all
1951
really-all: all $(check_SCRIPTS) $(haskell_tests) $(HS_ALL_PROGS)
1952

    
1953
# we don't need the ancient implicit rules:
1954
%: %,v
1955
%: RCS/%,v
1956
%: RCS/%
1957
%: s.%
1958
%: SCCS/s.%
1959

    
1960
-include ./Makefile.local
1961

    
1962
# vim: set noet :