Statistics
| Branch: | Tag: | Revision:

root / Makefile.am @ 227c0ef3

History | View | Annotate | Download (75.8 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
# Enable colors in shelltest
24
SHELLTESTARGS = "-c"
25

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

    
43
# starting as of Ganeti 2.10, all files are stored in two directories,
44
# with only symbolic links added at other places.
45
#
46
# $(versiondir) contains most of Ganeti and all architecture-dependent files
47
# $(versionedsharedir) contains only architecture-independent files; all python
48
# executables need to go directly to $(versionedsharedir), as all ganeti python
49
# mdules are installed outside the usual python path, i.e., as private modules.
50
#
51
# $(defaultversiondir) and $(defaultversionedsharedir) are the corresponding
52
# directories for "the currently running" version of Ganeti. We never install
53
# there, but all symbolic links go there, rather than directory to $(versiondir)
54
# or $(versionedsharedir). Note that all links to $(default*dir) need to be stable;
55
# so, if some currently architecture-independent executable is replaced by an
56
# architecture-dependent one (and hence has to go under $(versiondir)), add a link
57
# under $(versionedsharedir) but do not change the external links.
58
if USE_VERSION_FULL
59
DIRVERSION=$(VERSION_FULL)
60
else
61
DIRVERSION=$(VERSION_MAJOR).$(VERSION_MINOR)
62
endif
63
versiondir = $(libdir)/ganeti/$(DIRVERSION)
64
defaultversiondir = $(libdir)/ganeti/default
65
versionedsharedir = $(prefix)/share/ganeti/$(DIRVERSION)
66
defaultversionedsharedir = $(prefix)/share/ganeti/default
67

    
68
# Note: these are automake-specific variables, and must be named after
69
# the directory + 'dir' suffix
70
pkglibdir = $(versiondir)$(libdir)/ganeti
71
myexeclibdir = $(pkglibdir)
72
bindir = $(versiondir)/$(BINDIR)
73
sbindir = $(versiondir)$(SBINDIR)
74
mandir = $(versionedsharedir)/root$(MANDIR)
75
pkgpythondir = $(versionedsharedir)/ganeti
76
pkgpython_rpc_stubdir = $(versionedsharedir)/ganeti/rpc/stub
77
gntpythondir = $(versionedsharedir)
78
pkgpython_bindir = $(versionedsharedir)
79
gnt_python_sbindir = $(versionedsharedir)
80
tools_pythondir = $(versionedsharedir)
81

    
82
clientdir = $(pkgpythondir)/client
83
cmdlibdir = $(pkgpythondir)/cmdlib
84
hypervisordir = $(pkgpythondir)/hypervisor
85
storagedir = $(pkgpythondir)/storage
86
httpdir = $(pkgpythondir)/http
87
masterddir = $(pkgpythondir)/masterd
88
confddir = $(pkgpythondir)/confd
89
rapidir = $(pkgpythondir)/rapi
90
rpcdir = $(pkgpythondir)/rpc
91
rpc_stubdir = $(pkgpythondir)/rpc/stub
92
serverdir = $(pkgpythondir)/server
93
watcherdir = $(pkgpythondir)/watcher
94
impexpddir = $(pkgpythondir)/impexpd
95
utilsdir = $(pkgpythondir)/utils
96
toolsdir = $(pkglibdir)/tools
97
iallocatorsdir = $(pkglibdir)/iallocators
98
pytoolsdir = $(pkgpythondir)/tools
99
docdir = $(versiondir)$(datadir)/doc/$(PACKAGE)
100
ifupdir = $(sysconfdir)/ganeti
101

    
102
SYMLINK_TARGET_DIRS = \
103
	$(sysconfdir)/ganeti \
104
	$(libdir)/ganeti/iallocators \
105
	$(libdir)/ganeti/tools \
106
	$(prefix)/share/ganeti \
107
	$(BINDIR) \
108
	$(SBINDIR) \
109
	$(MANDIR)/man1 \
110
	$(MANDIR)/man7 \
111
	$(MANDIR)/man8
112

    
113
# Delete output file if an error occurred while building it
114
.DELETE_ON_ERROR:
115

    
116
HS_DIRS = \
117
	src \
118
	src/Ganeti \
119
	src/Ganeti/Confd \
120
	src/Ganeti/Curl \
121
	src/Ganeti/Cpu \
122
	src/Ganeti/DataCollectors \
123
	src/Ganeti/Hs2Py \
124
	src/Ganeti/HTools \
125
	src/Ganeti/HTools/Backend \
126
	src/Ganeti/HTools/Program \
127
	src/Ganeti/Hypervisor \
128
	src/Ganeti/Hypervisor/Xen \
129
	src/Ganeti/Locking \
130
	src/Ganeti/Logging \
131
	src/Ganeti/Monitoring \
132
	src/Ganeti/Objects \
133
	src/Ganeti/Query \
134
	src/Ganeti/Storage \
135
	src/Ganeti/Storage/Diskstats \
136
	src/Ganeti/Storage/Drbd \
137
	src/Ganeti/Storage/Lvm \
138
	src/Ganeti/THH \
139
	src/Ganeti/Utils \
140
	src/Ganeti/WConfd \
141
	test/hs \
142
	test/hs/Test \
143
	test/hs/Test/Ganeti \
144
	test/hs/Test/Ganeti/Storage \
145
	test/hs/Test/Ganeti/Storage/Diskstats \
146
	test/hs/Test/Ganeti/Storage/Drbd \
147
	test/hs/Test/Ganeti/Storage/Lvm \
148
	test/hs/Test/Ganeti/Confd \
149
	test/hs/Test/Ganeti/HTools \
150
	test/hs/Test/Ganeti/HTools/Backend \
151
	test/hs/Test/Ganeti/Hypervisor \
152
	test/hs/Test/Ganeti/Hypervisor/Xen \
153
	test/hs/Test/Ganeti/Locking \
154
	test/hs/Test/Ganeti/Query \
155
	test/hs/Test/Ganeti/THH
156

    
157
# Haskell directories without the roots (src, test/hs)
158
HS_DIRS_NOROOT = $(filter-out src,$(filter-out test/hs,$(HS_DIRS)))
159

    
160
DIRS = \
161
	$(HS_DIRS) \
162
	autotools \
163
	daemons \
164
	devel \
165
	devel/data \
166
	doc \
167
	doc/css \
168
	doc/examples \
169
	doc/examples/gnt-debug \
170
	doc/examples/hooks \
171
	doc/users \
172
	test/data/htools \
173
	test/data/htools/rapi \
174
	test/hs/shelltests \
175
	test/autotools \
176
	lib \
177
	lib/build \
178
	lib/client \
179
	lib/cmdlib \
180
	lib/confd \
181
	lib/http \
182
	lib/hypervisor \
183
	lib/impexpd \
184
	lib/masterd \
185
	lib/rapi \
186
	lib/rpc \
187
	lib/rpc/stub \
188
	lib/server \
189
	lib/storage \
190
	lib/tools \
191
	lib/utils \
192
	lib/watcher \
193
	man \
194
	qa \
195
	test \
196
	test/data \
197
	test/data/bdev-rbd \
198
	test/data/ovfdata \
199
	test/data/ovfdata/other \
200
	test/py \
201
	test/py/cmdlib \
202
	test/py/cmdlib/testsupport \
203
	tools
204

    
205
ALL_APIDOC_HS_DIRS = \
206
	$(APIDOC_HS_DIR) \
207
	$(patsubst %,$(APIDOC_HS_DIR)/%,$(call strip_hsroot,$(HS_DIRS_NOROOT)))
208

    
209
BUILDTIME_DIR_AUTOCREATE = \
210
	scripts \
211
	$(APIDOC_DIR) \
212
	$(ALL_APIDOC_HS_DIRS) \
213
	$(APIDOC_PY_DIR) \
214
	$(COVERAGE_DIR) \
215
	$(COVERAGE_HS_DIR) \
216
	$(COVERAGE_PY_DIR) \
217
	.hpc
218

    
219
BUILDTIME_DIRS = \
220
	$(BUILDTIME_DIR_AUTOCREATE) \
221
	doc/html \
222
	doc/man-html
223

    
224
DIRCHECK_EXCLUDE = \
225
	$(BUILDTIME_DIRS) \
226
	ganeti-[0-9]*.[0-9]*.[0-9]* \
227
	doc/html/_* \
228
	doc/man-html/_* \
229
	autom4te.cache
230

    
231
# some helper vars
232
COVERAGE_DIR = doc/coverage
233
COVERAGE_PY_DIR = $(COVERAGE_DIR)/py
234
COVERAGE_HS_DIR = $(COVERAGE_DIR)/hs
235
APIDOC_DIR = doc/api
236
APIDOC_PY_DIR = $(APIDOC_DIR)/py
237
APIDOC_HS_DIR = $(APIDOC_DIR)/hs
238

    
239
MAINTAINERCLEANFILES = \
240
	$(maninput) \
241
	doc/install-quick.rst \
242
	doc/news.rst \
243
	doc/upgrade.rst \
244
	vcs-version
245

    
246
maintainer-clean-local:
247
	rm -rf $(BUILDTIME_DIRS)
248

    
249
CLEANFILES = \
250
	$(addsuffix /*.py[co],$(DIRS)) \
251
	$(addsuffix /*.hi,$(HS_DIRS)) \
252
	$(addsuffix /*.o,$(HS_DIRS)) \
253
	$(addsuffix /*.$(HTEST_SUFFIX)_hi,$(HS_DIRS)) \
254
	$(addsuffix /*.$(HTEST_SUFFIX)_o,$(HS_DIRS)) \
255
	Makefile.ghc \
256
	Makefile.ghc.bak \
257
	$(PYTHON_BOOTSTRAP) \
258
	$(gnt_python_sbin_SCRIPTS) \
259
	epydoc.conf \
260
	$(REPLACE_VARS_SED) \
261
	$(SHELL_ENV_INIT) \
262
	daemons/daemon-util \
263
	daemons/ganeti-cleaner \
264
	devel/squeeze-amd64.tar.gz \
265
	devel/squeeze-amd64.conf \
266
	$(mandocrst) \
267
	doc/manpages-enabled.rst \
268
	$(BUILT_EXAMPLES) \
269
	doc/examples/bash_completion \
270
	doc/examples/bash_completion-debug \
271
	$(userspecs) \
272
	lib/_generated_rpc.py \
273
	$(man_MANS) \
274
	$(manhtml) \
275
	tools/kvm-ifup \
276
	tools/kvm-ifup-os \
277
	tools/vif-ganeti \
278
	tools/net-common \
279
	tools/users-setup \
280
	tools/vcluster-setup \
281
	stamp-directories \
282
	stamp-srclinks \
283
	$(nodist_pkgpython_PYTHON) \
284
	$(nodist_pkgpython_rpc_stub_PYTHON) \
285
	$(gnt_scripts) \
286
	$(HS_ALL_PROGS) $(HS_BUILT_SRCS) \
287
	$(HS_BUILT_TEST_HELPERS) \
288
	src/ganeti-confd \
289
	src/ganeti-wconfd \
290
	src/ganeti-luxid \
291
	src/ganeti-mond \
292
	.hpc/*.mix src/*.tix test/hs/*.tix *.tix \
293
	doc/hs-lint.html
294

    
295
GENERATED_FILES = \
296
	$(built_base_sources) \
297
	$(built_python_sources) \
298
	$(PYTHON_BOOTSTRAP) \
299
	$(gnt_python_sbin_SCRIPTS)
300

    
301
HS_GENERATED_FILES = $(HS_PROGS) src/hluxid src/ganeti-luxid
302
if ENABLE_CONFD
303
HS_GENERATED_FILES += src/hconfd src/ganeti-confd
304
endif
305
if ENABLE_MOND
306
HS_GENERATED_FILES += src/ganeti-mond
307
endif
308

    
309
built_base_sources = \
310
	stamp-directories \
311
	stamp-srclinks
312

    
313
built_python_base_sources = \
314
	lib/_constants.py \
315
	lib/_vcsversion.py \
316
	lib/opcodes.py \
317
	lib/rpc/stub/wconfd.py
318

    
319
built_python_sources = \
320
	$(nodist_pkgpython_PYTHON) \
321
	$(nodist_pkgpython_rpc_stub_PYTHON)
322

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

    
327
# these are all built from the underlying %.in sources
328
BUILT_EXAMPLES = \
329
	doc/examples/ganeti-kvm-poweroff.initd \
330
	doc/examples/ganeti.cron \
331
	doc/examples/ganeti.initd \
332
	doc/examples/ganeti.logrotate \
333
	doc/examples/ganeti-master-role.ocf \
334
	doc/examples/ganeti-node-role.ocf \
335
	doc/examples/gnt-config-backup \
336
	doc/examples/hooks/ipsec
337

    
338
dist_ifup_SCRIPTS = \
339
	tools/kvm-ifup-os
340

    
341
nodist_pkgpython_PYTHON = \
342
	$(built_python_base_sources) \
343
	lib/_generated_rpc.py
344

    
345
nodist_pkgpython_rpc_stub_PYTHON = \
346
	lib/rpc/stub/wconfd.py
347

    
348
nodist_pkgpython_bin_SCRIPTS = \
349
	$(nodist_pkglib_python_scripts)
350

    
351
pkgpython_bin_SCRIPTS = \
352
	$(pkglib_python_scripts)
353

    
354
noinst_PYTHON = \
355
	lib/build/__init__.py \
356
	lib/build/shell_example_lexer.py \
357
	lib/build/sphinx_ext.py
358

    
359
pkgpython_PYTHON = \
360
	lib/__init__.py \
361
	lib/asyncnotifier.py \
362
	lib/backend.py \
363
	lib/bootstrap.py \
364
	lib/cli.py \
365
	lib/compat.py \
366
	lib/config.py \
367
	lib/constants.py \
368
	lib/daemon.py \
369
	lib/errors.py \
370
	lib/hooksmaster.py \
371
	lib/ht.py \
372
	lib/jqueue.py \
373
	lib/jstore.py \
374
	lib/locking.py \
375
	lib/luxi.py \
376
	lib/mcpu.py \
377
	lib/netutils.py \
378
	lib/objects.py \
379
	lib/opcodes_base.py \
380
	lib/outils.py \
381
	lib/ovf.py \
382
	lib/pathutils.py \
383
	lib/qlang.py \
384
	lib/query.py \
385
	lib/rpc_defs.py \
386
	lib/runtime.py \
387
	lib/serializer.py \
388
	lib/ssconf.py \
389
	lib/ssh.py \
390
	lib/uidpool.py \
391
	lib/vcluster.py \
392
	lib/network.py \
393
	lib/wconfd.py \
394
	lib/workerpool.py
395

    
396
client_PYTHON = \
397
	lib/client/__init__.py \
398
	lib/client/base.py \
399
	lib/client/gnt_backup.py \
400
	lib/client/gnt_cluster.py \
401
	lib/client/gnt_debug.py \
402
	lib/client/gnt_group.py \
403
	lib/client/gnt_instance.py \
404
	lib/client/gnt_job.py \
405
	lib/client/gnt_node.py \
406
	lib/client/gnt_network.py \
407
	lib/client/gnt_os.py \
408
	lib/client/gnt_storage.py
409

    
410
cmdlib_PYTHON = \
411
	lib/cmdlib/__init__.py \
412
	lib/cmdlib/backup.py \
413
	lib/cmdlib/base.py \
414
	lib/cmdlib/cluster.py \
415
	lib/cmdlib/common.py \
416
	lib/cmdlib/group.py \
417
	lib/cmdlib/instance.py \
418
	lib/cmdlib/instance_migration.py \
419
	lib/cmdlib/instance_operation.py \
420
	lib/cmdlib/instance_query.py \
421
	lib/cmdlib/instance_storage.py \
422
	lib/cmdlib/instance_utils.py \
423
	lib/cmdlib/misc.py \
424
	lib/cmdlib/network.py \
425
	lib/cmdlib/node.py \
426
	lib/cmdlib/operating_system.py \
427
	lib/cmdlib/query.py \
428
	lib/cmdlib/tags.py \
429
	lib/cmdlib/test.py
430

    
431
hypervisor_PYTHON = \
432
	lib/hypervisor/__init__.py \
433
	lib/hypervisor/hv_base.py \
434
	lib/hypervisor/hv_chroot.py \
435
	lib/hypervisor/hv_fake.py \
436
	lib/hypervisor/hv_kvm.py \
437
	lib/hypervisor/hv_lxc.py \
438
	lib/hypervisor/hv_xen.py
439

    
440
storage_PYTHON = \
441
	lib/storage/__init__.py \
442
	lib/storage/bdev.py \
443
	lib/storage/base.py \
444
	lib/storage/container.py \
445
	lib/storage/drbd.py \
446
	lib/storage/drbd_info.py \
447
	lib/storage/drbd_cmdgen.py \
448
	lib/storage/filestorage.py \
449
	lib/storage/gluster.py
450

    
451
rapi_PYTHON = \
452
	lib/rapi/__init__.py \
453
	lib/rapi/baserlib.py \
454
	lib/rapi/client.py \
455
	lib/rapi/client_utils.py \
456
	lib/rapi/connector.py \
457
	lib/rapi/rlib2.py \
458
	lib/rapi/testutils.py
459

    
460
http_PYTHON = \
461
	lib/http/__init__.py \
462
	lib/http/auth.py \
463
	lib/http/client.py \
464
	lib/http/server.py
465

    
466
confd_PYTHON = \
467
	lib/confd/__init__.py \
468
	lib/confd/client.py
469

    
470
masterd_PYTHON = \
471
	lib/masterd/__init__.py \
472
	lib/masterd/iallocator.py \
473
	lib/masterd/instance.py
474

    
475
impexpd_PYTHON = \
476
	lib/impexpd/__init__.py
477

    
478
watcher_PYTHON = \
479
	lib/watcher/__init__.py \
480
	lib/watcher/nodemaint.py \
481
	lib/watcher/state.py
482

    
483
server_PYTHON = \
484
	lib/server/__init__.py \
485
	lib/server/masterd.py \
486
	lib/server/noded.py \
487
	lib/server/rapi.py
488

    
489
rpc_PYTHON = \
490
	lib/rpc/__init__.py \
491
	lib/rpc/client.py \
492
	lib/rpc/errors.py \
493
	lib/rpc/node.py \
494
	lib/rpc/transport.py
495

    
496
rpc_stub_PYTHON = \
497
	lib/rpc/stub/__init__.py
498

    
499
pytools_PYTHON = \
500
	lib/tools/__init__.py \
501
	lib/tools/burnin.py \
502
	lib/tools/ensure_dirs.py \
503
	lib/tools/node_cleanup.py \
504
	lib/tools/node_daemon_setup.py \
505
	lib/tools/prepare_node_join.py
506

    
507
utils_PYTHON = \
508
	lib/utils/__init__.py \
509
	lib/utils/algo.py \
510
	lib/utils/filelock.py \
511
	lib/utils/hash.py \
512
	lib/utils/io.py \
513
	lib/utils/livelock.py \
514
	lib/utils/log.py \
515
	lib/utils/lvm.py \
516
	lib/utils/mlock.py \
517
	lib/utils/nodesetup.py \
518
	lib/utils/process.py \
519
	lib/utils/retry.py \
520
	lib/utils/security.py \
521
	lib/utils/storage.py \
522
	lib/utils/text.py \
523
	lib/utils/version.py \
524
	lib/utils/wrapper.py \
525
	lib/utils/x509.py
526

    
527
docinput = \
528
	doc/admin.rst \
529
	doc/cluster-keys-replacement.rst \
530
	doc/cluster-merge.rst \
531
	doc/conf.py \
532
	doc/css/style.css \
533
	doc/design-2.0.rst \
534
	doc/design-2.1.rst \
535
	doc/design-2.2.rst \
536
	doc/design-2.3.rst \
537
	doc/design-2.4.rst \
538
	doc/design-2.5.rst \
539
	doc/design-2.6.rst \
540
	doc/design-2.7.rst \
541
	doc/design-2.8.rst \
542
	doc/design-2.9.rst \
543
	doc/design-2.10.rst \
544
	doc/design-2.11.rst \
545
	doc/design-autorepair.rst \
546
	doc/design-bulk-create.rst \
547
	doc/design-ceph-ganeti-support.rst \
548
	doc/design-chained-jobs.rst \
549
	doc/design-cmdlib-unittests.rst \
550
	doc/design-cpu-pinning.rst \
551
	doc/design-daemons.rst \
552
	doc/design-device-uuid-name.rst \
553
	doc/design-draft.rst \
554
	doc/design-file-based-storage.rst \
555
	doc/design-glusterfs-ganeti-support.rst \
556
	doc/design-hotplug.rst \
557
	doc/design-hroller.rst \
558
	doc/design-hsqueeze.rst \
559
	doc/design-htools-2.3.rst \
560
	doc/design-http-server.rst \
561
	doc/design-hugepages-support.rst \
562
	doc/design-impexp2.rst \
563
	doc/design-internal-shutdown.rst \
564
	doc/design-kvmd.rst \
565
	doc/design-linuxha.rst \
566
	doc/design-lu-generated-jobs.rst \
567
	doc/design-monitoring-agent.rst \
568
	doc/design-multi-reloc.rst \
569
	doc/design-multi-version-tests.rst \
570
	doc/design-network.rst \
571
	doc/design-node-add.rst \
572
	doc/design-oob.rst \
573
	doc/design-openvswitch.rst \
574
	doc/design-opportunistic-locking.rst \
575
	doc/design-optables.rst \
576
	doc/design-os.rst \
577
	doc/design-ovf-support.rst \
578
	doc/design-partitioned.rst \
579
	doc/design-query2.rst \
580
	doc/design-query-splitting.rst \
581
	doc/design-reason-trail.rst \
582
	doc/design-resource-model.rst \
583
	doc/design-restricted-commands.rst \
584
	doc/design-shared-storage.rst \
585
	doc/design-ssh-ports.rst \
586
	doc/design-storagetypes.rst \
587
	doc/design-upgrade.rst \
588
	doc/design-virtual-clusters.rst \
589
	doc/design-x509-ca.rst \
590
	doc/dev-codestyle.rst \
591
	doc/devnotes.rst \
592
	doc/glossary.rst \
593
	doc/hooks.rst \
594
	doc/iallocator.rst \
595
	doc/index.rst \
596
	doc/install-quick.rst \
597
	doc/install.rst \
598
	doc/locking.rst \
599
	doc/manpages-disabled.rst \
600
	doc/monitoring-query-format.rst \
601
	doc/move-instance.rst \
602
	doc/news.rst \
603
	doc/ovfconverter.rst \
604
	doc/rapi.rst \
605
	doc/security.rst \
606
	doc/upgrade.rst \
607
	doc/virtual-cluster.rst \
608
	doc/walkthrough.rst
609

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

    
613
# Haskell programs to be installed in $PREFIX/bin
614
HS_BIN_PROGS=src/htools
615

    
616
# Haskell programs to be installed in the MYEXECLIB dir
617
if ENABLE_MOND
618
HS_MYEXECLIB_PROGS=src/mon-collector
619
else
620
HS_MYEXECLIB_PROGS=
621
endif
622

    
623
# Haskell programs to be compiled by "make really-all"
624
HS_COMPILE_PROGS = \
625
	src/ganeti-kvmd \
626
	src/ganeti-metad \
627
	src/ganeti-wconfd \
628
	src/hluxid \
629
	src/hs2py \
630
	src/rpc-test
631
if ENABLE_CONFD
632
HS_COMPILE_PROGS += src/hconfd
633
endif
634
if ENABLE_MOND
635
HS_COMPILE_PROGS += src/ganeti-mond
636
endif
637

    
638
# All Haskell non-test programs to be compiled but not automatically installed
639
HS_PROGS = $(HS_BIN_PROGS) $(HS_MYEXECLIB_PROGS)
640

    
641
HS_BIN_ROLES = harep hbal hscan hspace hinfo hcheck hroller hsqueeze
642
HS_HTOOLS_PROGS = $(HS_BIN_ROLES) hail
643

    
644
# Haskell programs that cannot be disabled at configure (e.g., unlike
645
# 'mon-collector')
646
HS_DEFAULT_PROGS = \
647
	$(HS_BIN_PROGS) \
648
	test/hs/hpc-htools \
649
	test/hs/hpc-mon-collector \
650
	test/hs/htest \
651
	$(HS_COMPILE_PROGS)
652

    
653
HS_ALL_PROGS = $(HS_DEFAULT_PROGS) $(HS_MYEXECLIB_PROGS)
654

    
655
HS_TEST_PROGS = $(filter test/%,$(HS_ALL_PROGS))
656
HS_SRC_PROGS = $(filter-out test/%,$(HS_ALL_PROGS))
657

    
658
HS_PROG_SRCS = $(patsubst %,%.hs,$(HS_DEFAULT_PROGS)) src/mon-collector.hs
659
HS_BUILT_TEST_HELPERS = $(HS_BIN_ROLES:%=test/hs/%) test/hs/hail
660

    
661
HFLAGS = \
662
	-O -Wall -Werror -isrc \
663
	-fwarn-monomorphism-restriction \
664
	-fwarn-tabs \
665
	$(GHC_BYVERSION_FLAGS)
666

    
667
if HPROFILE
668
HFLAGS += -prof -auto-all
669
endif
670
if HCOVERAGE
671
HFLAGS += -fhpc
672
endif
673
if HTEST
674
HFLAGS += -DTEST
675
endif
676

    
677
HTEST_SUFFIX = hpc
678

    
679
HTEST_FLAGS = $(HFLAGS) -fhpc -itest/hs \
680
	-osuf .$(HTEST_SUFFIX)_o \
681
	-hisuf .$(HTEST_SUFFIX)_hi
682

    
683
# extra flags that can be overriden on the command line (e.g. -Wwarn, etc.)
684
HEXTRA =
685
# internal extra flags (used for test/hs/htest mainly)
686
HEXTRA_INT =
687
# exclude options for coverage reports
688
HPCEXCL = --exclude Main \
689
	--exclude Ganeti.Constants \
690
	--exclude Ganeti.HTools.QC \
691
	--exclude Ganeti.THH \
692
	--exclude Ganeti.Version \
693
	--exclude Test.Ganeti.Attoparsec \
694
	--exclude Test.Ganeti.TestCommon \
695
	--exclude Test.Ganeti.TestHTools \
696
	--exclude Test.Ganeti.TestHelper \
697
	--exclude Test.Ganeti.TestImports \
698
	$(patsubst src.%,--exclude Test.%,$(subst /,.,$(patsubst %.hs,%, $(HS_LIB_SRCS))))
699

    
700
HS_LIB_SRCS = \
701
	src/Ganeti/BasicTypes.hs \
702
	src/Ganeti/Common.hs \
703
	src/Ganeti/Compat.hs \
704
	src/Ganeti/Confd/Client.hs \
705
	src/Ganeti/Confd/ClientFunctions.hs \
706
	src/Ganeti/Confd/Server.hs \
707
	src/Ganeti/Confd/Types.hs \
708
	src/Ganeti/Confd/Utils.hs \
709
	src/Ganeti/Config.hs \
710
	src/Ganeti/ConfigReader.hs \
711
	src/Ganeti/Constants.hs \
712
	src/Ganeti/ConstantUtils.hs \
713
	src/Ganeti/Cpu/LoadParser.hs \
714
	src/Ganeti/Cpu/Types.hs \
715
	src/Ganeti/Curl/Multi.hs \
716
	src/Ganeti/Daemon.hs \
717
	src/Ganeti/DataCollectors/CLI.hs \
718
	src/Ganeti/DataCollectors/CPUload.hs \
719
	src/Ganeti/DataCollectors/Diskstats.hs \
720
	src/Ganeti/DataCollectors/Drbd.hs \
721
	src/Ganeti/DataCollectors/InstStatus.hs \
722
	src/Ganeti/DataCollectors/InstStatusTypes.hs \
723
	src/Ganeti/DataCollectors/Lv.hs \
724
	src/Ganeti/DataCollectors/Program.hs \
725
	src/Ganeti/DataCollectors/Types.hs \
726
	src/Ganeti/Errors.hs \
727
	src/Ganeti/HTools/Backend/IAlloc.hs \
728
	src/Ganeti/HTools/Backend/Luxi.hs \
729
	src/Ganeti/HTools/Backend/Rapi.hs \
730
	src/Ganeti/HTools/Backend/Simu.hs \
731
	src/Ganeti/HTools/Backend/Text.hs \
732
	src/Ganeti/HTools/CLI.hs \
733
	src/Ganeti/HTools/Cluster.hs \
734
	src/Ganeti/HTools/Container.hs \
735
	src/Ganeti/HTools/ExtLoader.hs \
736
	src/Ganeti/HTools/Graph.hs \
737
	src/Ganeti/HTools/Group.hs \
738
	src/Ganeti/HTools/Instance.hs \
739
	src/Ganeti/HTools/Loader.hs \
740
	src/Ganeti/HTools/Nic.hs \
741
	src/Ganeti/HTools/Node.hs \
742
	src/Ganeti/HTools/PeerMap.hs \
743
	src/Ganeti/HTools/Program/Hail.hs \
744
	src/Ganeti/HTools/Program/Harep.hs \
745
	src/Ganeti/HTools/Program/Hbal.hs \
746
	src/Ganeti/HTools/Program/Hcheck.hs \
747
	src/Ganeti/HTools/Program/Hinfo.hs \
748
	src/Ganeti/HTools/Program/Hscan.hs \
749
	src/Ganeti/HTools/Program/Hspace.hs \
750
	src/Ganeti/HTools/Program/Hsqueeze.hs \
751
	src/Ganeti/HTools/Program/Hroller.hs \
752
	src/Ganeti/HTools/Program/Main.hs \
753
	src/Ganeti/HTools/Types.hs \
754
	src/Ganeti/Hypervisor/Xen.hs \
755
	src/Ganeti/Hypervisor/Xen/XmParser.hs \
756
	src/Ganeti/Hypervisor/Xen/Types.hs \
757
	src/Ganeti/Hash.hs \
758
	src/Ganeti/Hs2Py/GenConstants.hs \
759
	src/Ganeti/Hs2Py/GenOpCodes.hs \
760
	src/Ganeti/Hs2Py/OpDoc.hs \
761
	src/Ganeti/JQueue.hs \
762
	src/Ganeti/JQScheduler.hs \
763
	src/Ganeti/JSON.hs \
764
	src/Ganeti/Jobs.hs \
765
	src/Ganeti/Kvmd.hs \
766
	src/Ganeti/Lens.hs \
767
	src/Ganeti/Locking/Allocation.hs \
768
	src/Ganeti/Locking/Types.hs \
769
	src/Ganeti/Locking/Locks.hs \
770
	src/Ganeti/Logging.hs \
771
	src/Ganeti/Logging/Lifted.hs \
772
	src/Ganeti/Luxi.hs \
773
	src/Ganeti/Monitoring/Server.hs \
774
	src/Ganeti/Metad.hs \
775
	src/Ganeti/Network.hs \
776
	src/Ganeti/Objects.hs \
777
	src/Ganeti/Objects/Lens.hs \
778
	src/Ganeti/OpCodes.hs \
779
	src/Ganeti/OpParams.hs \
780
	src/Ganeti/Path.hs \
781
	src/Ganeti/Parsers.hs \
782
	src/Ganeti/PyValue.hs \
783
	src/Ganeti/Query/Cluster.hs \
784
	src/Ganeti/Query/Common.hs \
785
	src/Ganeti/Query/Export.hs \
786
	src/Ganeti/Query/Filter.hs \
787
	src/Ganeti/Query/Group.hs \
788
	src/Ganeti/Query/Instance.hs \
789
	src/Ganeti/Query/Job.hs \
790
	src/Ganeti/Query/Language.hs \
791
	src/Ganeti/Query/Locks.hs \
792
	src/Ganeti/Query/Network.hs \
793
	src/Ganeti/Query/Node.hs \
794
	src/Ganeti/Query/Query.hs \
795
	src/Ganeti/Query/Server.hs \
796
	src/Ganeti/Query/Types.hs \
797
	src/Ganeti/Rpc.hs \
798
	src/Ganeti/Runtime.hs \
799
	src/Ganeti/Ssconf.hs \
800
	src/Ganeti/Storage/Diskstats/Parser.hs \
801
	src/Ganeti/Storage/Diskstats/Types.hs \
802
	src/Ganeti/Storage/Drbd/Parser.hs \
803
	src/Ganeti/Storage/Drbd/Types.hs \
804
	src/Ganeti/Storage/Lvm/LVParser.hs \
805
	src/Ganeti/Storage/Lvm/Types.hs \
806
	src/Ganeti/Storage/Utils.hs \
807
	src/Ganeti/THH.hs \
808
	src/Ganeti/THH/Field.hs \
809
	src/Ganeti/THH/PyRPC.hs \
810
	src/Ganeti/THH/PyType.hs \
811
	src/Ganeti/THH/Types.hs \
812
	src/Ganeti/THH/RPC.hs \
813
	src/Ganeti/Types.hs \
814
	src/Ganeti/UDSServer.hs \
815
	src/Ganeti/Utils.hs \
816
	src/Ganeti/Utils/Atomic.hs \
817
	src/Ganeti/Utils/AsyncWorker.hs \
818
	src/Ganeti/VCluster.hs \
819
	src/Ganeti/WConfd/ConfigState.hs \
820
	src/Ganeti/WConfd/ConfigWriter.hs \
821
	src/Ganeti/WConfd/Core.hs \
822
	src/Ganeti/WConfd/DeathDetection.hs \
823
	src/Ganeti/WConfd/Language.hs \
824
	src/Ganeti/WConfd/Monad.hs \
825
	src/Ganeti/WConfd/Server.hs
826

    
827
HS_TEST_SRCS = \
828
	test/hs/Test/AutoConf.hs \
829
	test/hs/Test/Ganeti/Attoparsec.hs \
830
	test/hs/Test/Ganeti/BasicTypes.hs \
831
	test/hs/Test/Ganeti/Common.hs \
832
	test/hs/Test/Ganeti/Confd/Types.hs \
833
	test/hs/Test/Ganeti/Confd/Utils.hs \
834
	test/hs/Test/Ganeti/Constants.hs \
835
	test/hs/Test/Ganeti/Daemon.hs \
836
	test/hs/Test/Ganeti/Errors.hs \
837
	test/hs/Test/Ganeti/HTools/Backend/Simu.hs \
838
	test/hs/Test/Ganeti/HTools/Backend/Text.hs \
839
	test/hs/Test/Ganeti/HTools/CLI.hs \
840
	test/hs/Test/Ganeti/HTools/Cluster.hs \
841
	test/hs/Test/Ganeti/HTools/Container.hs \
842
	test/hs/Test/Ganeti/HTools/ExtLoader.hs \
843
	test/hs/Test/Ganeti/HTools/Graph.hs \
844
	test/hs/Test/Ganeti/HTools/Instance.hs \
845
	test/hs/Test/Ganeti/HTools/Loader.hs \
846
	test/hs/Test/Ganeti/HTools/Node.hs \
847
	test/hs/Test/Ganeti/HTools/PeerMap.hs \
848
	test/hs/Test/Ganeti/HTools/Types.hs \
849
	test/hs/Test/Ganeti/Hypervisor/Xen/XmParser.hs \
850
	test/hs/Test/Ganeti/JSON.hs \
851
	test/hs/Test/Ganeti/Jobs.hs \
852
	test/hs/Test/Ganeti/JQueue.hs \
853
	test/hs/Test/Ganeti/Kvmd.hs \
854
	test/hs/Test/Ganeti/Luxi.hs \
855
	test/hs/Test/Ganeti/Locking/Allocation.hs \
856
	test/hs/Test/Ganeti/Locking/Locks.hs \
857
	test/hs/Test/Ganeti/Network.hs \
858
	test/hs/Test/Ganeti/Objects.hs \
859
	test/hs/Test/Ganeti/OpCodes.hs \
860
	test/hs/Test/Ganeti/Query/Aliases.hs \
861
	test/hs/Test/Ganeti/Query/Filter.hs \
862
	test/hs/Test/Ganeti/Query/Instance.hs \
863
	test/hs/Test/Ganeti/Query/Language.hs \
864
	test/hs/Test/Ganeti/Query/Network.hs \
865
	test/hs/Test/Ganeti/Query/Query.hs \
866
	test/hs/Test/Ganeti/Rpc.hs \
867
	test/hs/Test/Ganeti/Runtime.hs \
868
	test/hs/Test/Ganeti/Ssconf.hs \
869
	test/hs/Test/Ganeti/Storage/Diskstats/Parser.hs \
870
	test/hs/Test/Ganeti/Storage/Drbd/Parser.hs \
871
	test/hs/Test/Ganeti/Storage/Drbd/Types.hs \
872
	test/hs/Test/Ganeti/Storage/Lvm/LVParser.hs \
873
	test/hs/Test/Ganeti/THH.hs \
874
	test/hs/Test/Ganeti/THH/Types.hs \
875
	test/hs/Test/Ganeti/TestCommon.hs \
876
	test/hs/Test/Ganeti/TestHTools.hs \
877
	test/hs/Test/Ganeti/TestHelper.hs \
878
	test/hs/Test/Ganeti/Types.hs \
879
	test/hs/Test/Ganeti/Utils.hs
880

    
881
HS_LIBTEST_SRCS = $(HS_LIB_SRCS) $(HS_TEST_SRCS)
882

    
883
HS_BUILT_SRCS = \
884
	test/hs/Test/Ganeti/TestImports.hs \
885
	src/AutoConf.hs \
886
	src/Ganeti/Hs2Py/ListConstants.hs \
887
	src/Ganeti/Curl/Internal.hs \
888
	src/Ganeti/Version.hs
889
HS_BUILT_SRCS_IN = \
890
	$(patsubst %,%.in,$(filter-out src/Ganeti/Curl/Internal.hs,$(HS_BUILT_SRCS))) \
891
	src/Ganeti/Curl/Internal.hsc \
892
	lib/_constants.py.in \
893
	lib/opcodes.py.in_after \
894
	lib/opcodes.py.in_before
895

    
896
HS_LIBTESTBUILT_SRCS = $(HS_LIBTEST_SRCS) $(HS_BUILT_SRCS)
897

    
898
$(RUN_IN_TEMPDIR): | stamp-directories
899

    
900
doc/html/index.html: ENABLE_MANPAGES =
901
doc/man-html/index.html: ENABLE_MANPAGES = 1
902
doc/man-html/index.html: doc/manpages-enabled.rst $(mandocrst)
903

    
904
# Note: we use here an order-only prerequisite, as the contents of
905
# _constants.py are not actually influencing the html build output: it
906
# has to exist in order for the sphinx module to be loaded
907
# successfully, but we certainly don't want the docs to be rebuilt if
908
# it changes
909
doc/html/index.html doc/man-html/index.html: $(docinput) doc/conf.py \
910
	configure.ac $(RUN_IN_TEMPDIR) lib/build/sphinx_ext.py \
911
	lib/build/shell_example_lexer.py lib/ht.py \
912
	doc/css/style.css lib/rapi/connector.py lib/rapi/rlib2.py \
913
	autotools/sphinx-wrapper | $(built_python_sources)
914
	@test -n "$(SPHINX)" || \
915
	    { echo 'sphinx-build' not found during configure; exit 1; }
916
if !MANPAGES_IN_DOC
917
	if test -n '$(ENABLE_MANPAGES)'; then \
918
	  echo 'Man pages in documentation were disabled at configure time' >&2; \
919
	  exit 1; \
920
	fi
921
endif
922
## Sphinx provides little control over what content should be included. Some
923
## mechanisms exist, but they all have drawbacks or actual issues. Since we
924
## build two different versions of the documentation--once without man pages and
925
## once, if enabled, with them--some control is necessary. xmpp-wrapper provides
926
## us with this, but requires running in a temporary directory. It moves the
927
## correct files into place depending on environment variables.
928
	dir=$(dir $@) && \
929
	@mkdir_p@ $$dir && \
930
	PYTHONPATH=. ENABLE_MANPAGES=$(ENABLE_MANPAGES) COPY_DOC=1 \
931
	$(RUN_IN_TEMPDIR) autotools/sphinx-wrapper $(SPHINX) -q -W -b html \
932
	    -d . \
933
	    -D version="$(VERSION_MAJOR).$(VERSION_MINOR)" \
934
	    -D release="$(PACKAGE_VERSION)" \
935
	    -D graphviz_dot="$(DOT)" \
936
	    -D enable_manpages="$(ENABLE_MANPAGES)" \
937
	    doc $(CURDIR)/$$dir && \
938
	rm -f $$dir/.buildinfo $$dir/objects.inv
939
	touch $@
940

    
941
doc/html: doc/html/index.html
942

    
943
doc/man-html: doc/man-html/index.html
944

    
945
doc/install-quick.rst: INSTALL
946
doc/news.rst: NEWS
947
doc/upgrade.rst: UPGRADE
948

    
949
doc/install-quick.rst doc/news.rst doc/upgrade.rst:
950
	set -e; \
951
	{ echo '.. This file is automatically updated at build time from $<.'; \
952
	  echo '.. Do not edit.'; \
953
	  echo; \
954
	  cat $<; \
955
	} > $@
956

    
957
doc/manpages-enabled.rst: Makefile | $(built_base_sources)
958
	{ echo '.. This file is automatically generated, do not edit!'; \
959
	  echo ''; \
960
	  echo 'Man pages'; \
961
	  echo '========='; \
962
	  echo; \
963
	  echo '.. toctree::'; \
964
	  echo '   :maxdepth: 1'; \
965
	  echo; \
966
	  for i in $(notdir $(mandocrst)); do \
967
	    echo "   $$i"; \
968
	  done | LC_ALL=C sort; \
969
	} > $@
970

    
971
doc/man-%.rst: man/%.gen Makefile $(REPLACE_VARS_SED) | $(built_base_sources)
972
if MANPAGES_IN_DOC
973
	{ echo '.. This file is automatically updated at build time from $<.'; \
974
	  echo '.. Do not edit.'; \
975
	  echo; \
976
	  echo "$*"; \
977
	  echo '=========================================='; \
978
	  tail -n +3 $< | sed -f $(REPLACE_VARS_SED); \
979
	} > $@
980
else
981
	echo 'Man pages in documentation were disabled at configure time' >&2; \
982
	exit 1;
983
endif
984

    
985
doc/users/%: doc/users/%.in Makefile $(REPLACE_VARS_SED)
986
	cat $< | sed -f $(REPLACE_VARS_SED) | LC_ALL=C sort | uniq | (grep -v '^root' || true) > $@
987

    
988
userspecs = \
989
	doc/users/users \
990
	doc/users/groups \
991
	doc/users/groupmemberships
992

    
993
# Things to build but not to install (add it to EXTRA_DIST if it should be
994
# distributed)
995
noinst_DATA = \
996
	$(BUILT_EXAMPLES) \
997
	doc/examples/bash_completion \
998
	doc/examples/bash_completion-debug \
999
	$(userspecs) \
1000
	$(manhtml)
1001

    
1002
if HAS_SPHINX
1003
if MANPAGES_IN_DOC
1004
noinst_DATA += doc/man-html
1005
else
1006
noinst_DATA += doc/html
1007
endif
1008
endif
1009

    
1010
gnt_scripts = \
1011
	scripts/gnt-backup \
1012
	scripts/gnt-cluster \
1013
	scripts/gnt-debug \
1014
	scripts/gnt-group \
1015
	scripts/gnt-instance \
1016
	scripts/gnt-job \
1017
	scripts/gnt-network \
1018
	scripts/gnt-node \
1019
	scripts/gnt-os \
1020
	scripts/gnt-storage
1021

    
1022
gnt_scripts_basenames = \
1023
	$(patsubst scripts/%,%,$(patsubst daemons/%,%,$(gnt_scripts) $(gnt_python_sbin_SCRIPTS)))
1024

    
1025
gnt_python_sbin_SCRIPTS = \
1026
	$(PYTHON_BOOTSTRAP_SBIN)
1027

    
1028
gntpython_SCRIPTS = $(gnt_scripts)
1029

    
1030
PYTHON_BOOTSTRAP_SBIN = \
1031
	daemons/ganeti-masterd \
1032
	daemons/ganeti-noded \
1033
	daemons/ganeti-rapi \
1034
	daemons/ganeti-watcher
1035

    
1036
PYTHON_BOOTSTRAP = \
1037
	tools/burnin \
1038
	tools/ensure-dirs \
1039
	tools/node-cleanup \
1040
	tools/node-daemon-setup \
1041
	tools/prepare-node-join
1042

    
1043
qa_scripts = \
1044
	qa/__init__.py \
1045
	qa/ganeti-qa.py \
1046
	qa/qa_cluster.py \
1047
	qa/qa_config.py \
1048
	qa/qa_daemon.py \
1049
	qa/qa_env.py \
1050
	qa/qa_error.py \
1051
	qa/qa_group.py \
1052
	qa/qa_instance.py \
1053
	qa/qa_instance_utils.py \
1054
	qa/qa_job.py \
1055
	qa/qa_job_utils.py \
1056
	qa/qa_monitoring.py \
1057
	qa/qa_node.py \
1058
	qa/qa_os.py \
1059
	qa/qa_rapi.py \
1060
	qa/qa_tags.py \
1061
	qa/qa_utils.py \
1062
	qa/rapi-workload.py
1063

    
1064
bin_SCRIPTS = $(HS_BIN_PROGS)
1065
install-exec-hook:
1066
	@mkdir_p@ $(DESTDIR)$(iallocatorsdir)
1067
# FIXME: this is a hardcoded logic, instead of auto-resolving
1068
	$(LN_S) -f ../../../bin/htools \
1069
	  $(DESTDIR)$(iallocatorsdir)/hail
1070
	for role in $(HS_BIN_ROLES); do \
1071
	  $(LN_S) -f htools $(DESTDIR)$(bindir)/$$role ; \
1072
	done
1073

    
1074
HS_SRCS = $(HS_LIBTESTBUILT_SRCS)
1075

    
1076
HS_MAKEFILE_GHC_SRCS = $(HS_SRC_PROGS:%=%.hs)
1077
if WANT_HSTESTS
1078
HS_MAKEFILE_GHC_SRCS += $(HS_TEST_PROGS:%=%.hs)
1079
endif
1080
Makefile.ghc: $(HS_MAKEFILE_GHC_SRCS) Makefile \
1081
              | $(built_base_sources) $(HS_BUILT_SRCS)
1082
	$(GHC) -M -dep-makefile $@ -dep-suffix $(HTEST_SUFFIX) $(HFLAGS) -itest/hs \
1083
		$(HS_PARALLEL3) $(HS_REGEX_PCRE) $(HEXTRA) $(HS_MAKEFILE_GHC_SRCS)
1084

    
1085
@include_makefile_ghc@
1086

    
1087
%.o:
1088
	@echo '[GHC]: $@ <- $^'
1089
	@$(GHC) -c $(HFLAGS) \
1090
		$(HS_PARALLEL3) $(HS_REGEX_PCRE) $(HEXTRA) $(@:%.o=%.hs)
1091

    
1092
%.$(HTEST_SUFFIX)_o:
1093
	@echo '[GHC]: $@ <- $^'
1094
	@$(GHC) -c $(HTEST_FLAGS) \
1095
		$(HS_PARALLEL3) $(HS_REGEX_PCRE) $(HEXTRA) $(@:%.$(HTEST_SUFFIX)_o=%.hs)
1096

    
1097
%.hi: %.o ;
1098
%.$(HTEST_SUFFIX)_hi: %.$(HTEST_SUFFIX)_o ;
1099

    
1100
$(HS_SRC_PROGS): %: %.o | stamp-directories
1101
	$(GHC) $(HFLAGS) \
1102
		$(HS_PARALLEL3) $(HS_REGEX_PCRE) $(HEXTRA) --make $(@:%=%.hs)
1103
	@rm -f $(notdir $@).tix
1104
	@touch "$@"
1105

    
1106
$(HS_TEST_PROGS): %: %.$(HTEST_SUFFIX)_o \
1107
	                   | stamp-directories $(built_python_sources)
1108
	@if [ "$(HS_NODEV)" ]; then \
1109
	  echo "Error: cannot run unittests without the development" \
1110
	       " libraries (see devnotes.rst)" 1>&2; \
1111
	  exit 1; \
1112
	fi
1113
	$(GHC) $(HTEST_FLAGS) \
1114
		$(HS_PARALLEL3) $(HS_REGEX_PCRE) $(HEXTRA) --make $(@:%=%.hs)
1115
	@rm -f $(notdir $@).tix
1116
	@touch "$@"
1117

    
1118
dist_sbin_SCRIPTS = \
1119
	tools/ganeti-listrunner
1120

    
1121
nodist_sbin_SCRIPTS = \
1122
	daemons/ganeti-cleaner
1123

    
1124
# strip path prefixes off the sbin scripts
1125
all_sbin_scripts = \
1126
	$(patsubst tools/%,%,$(patsubst daemons/%,%,$(patsubst scripts/%,%,\
1127
	$(patsubst src/%,%,$(dist_sbin_SCRIPTS) $(nodist_sbin_SCRIPTS)))))
1128

    
1129
if ENABLE_CONFD
1130
src/ganeti-confd: src/hconfd
1131
	cp -f $< $@
1132

    
1133
src/ganeti-luxid: src/hluxid
1134
	cp -f $< $@
1135

    
1136
nodist_sbin_SCRIPTS += src/ganeti-confd
1137
nodist_sbin_SCRIPTS += src/ganeti-wconfd
1138
nodist_sbin_SCRIPTS += src/ganeti-luxid
1139
nodist_sbin_SCRIPTS += src/ganeti-kvmd
1140
nodist_sbin_SCRIPTS += src/ganeti-metad
1141
endif
1142

    
1143
if ENABLE_MOND
1144
nodist_sbin_SCRIPTS += src/ganeti-mond
1145
endif
1146

    
1147
python_scripts = \
1148
	tools/cfgshell \
1149
	tools/cfgupgrade \
1150
	tools/cfgupgrade12 \
1151
	tools/cluster-merge \
1152
	tools/confd-client \
1153
	tools/fmtjson \
1154
	tools/lvmstrap \
1155
	tools/move-instance \
1156
	tools/ovfconverter \
1157
	tools/post-upgrade \
1158
	tools/sanitize-config
1159

    
1160
dist_tools_SCRIPTS = \
1161
	tools/kvm-console-wrapper \
1162
	tools/master-ip-setup \
1163
	tools/xen-console-wrapper
1164

    
1165
dist_tools_python_SCRIPTS = \
1166
	$(python_scripts) \
1167
	tools/burnin
1168

    
1169
nodist_tools_python_SCRIPTS = \
1170
	tools/node-cleanup
1171

    
1172
tools_python_basenames = $(patsubst tools/%,%,\
1173
	$(dist_tools_python_SCRIPTS) $(nodist_tools_python_SCRIPTS))
1174

    
1175
nodist_tools_SCRIPTS = \
1176
	tools/users-setup \
1177
	tools/vcluster-setup
1178

    
1179
tools_basenames = $(patsubst tools/%,%,$(nodist_tools_SCRIPTS) $(dist_tools_SCRIPTS))
1180

    
1181
pkglib_python_scripts = \
1182
	daemons/import-export \
1183
	tools/check-cert-expired
1184

    
1185
nodist_pkglib_python_scripts = \
1186
	tools/ensure-dirs \
1187
	tools/node-daemon-setup \
1188
	tools/prepare-node-join
1189

    
1190
pkglib_python_basenames = \
1191
	$(patsubst daemons/%,%,$(patsubst tools/%,%,\
1192
	$(pkglib_python_scripts) $(nodist_pkglib_python_scripts)))
1193

    
1194
myexeclib_SCRIPTS = \
1195
	daemons/daemon-util \
1196
	tools/kvm-ifup \
1197
	tools/kvm-ifup-os \
1198
	tools/vif-ganeti \
1199
	tools/net-common \
1200
	$(HS_MYEXECLIB_PROGS)
1201

    
1202
# compute the basenames of the myexeclib_scripts
1203
myexeclib_scripts_basenames = \
1204
	$(patsubst tools/%,%,$(patsubst daemons/%,%,$(patsubst src/%,%,$(myexeclib_SCRIPTS))))
1205

    
1206
EXTRA_DIST = \
1207
	NEWS \
1208
	UPGRADE \
1209
	epydoc.conf.in \
1210
	pylintrc \
1211
	pylintrc-test \
1212
	autotools/build-bash-completion \
1213
	autotools/build-rpc \
1214
	autotools/check-header \
1215
	autotools/check-imports \
1216
	autotools/check-man-dashes \
1217
	autotools/check-man-references \
1218
	autotools/check-man-warnings \
1219
	autotools/check-news \
1220
	autotools/check-python-code \
1221
	autotools/check-tar \
1222
	autotools/check-version \
1223
	autotools/docpp \
1224
	autotools/gen-py-coverage \
1225
	autotools/print-py-constants \
1226
	autotools/sphinx-wrapper \
1227
	autotools/testrunner \
1228
	autotools/wrong-hardcoded-paths \
1229
	$(RUN_IN_TEMPDIR) \
1230
	daemons/daemon-util.in \
1231
	daemons/ganeti-cleaner.in \
1232
	$(pkglib_python_scripts) \
1233
	devel/upload \
1234
	devel/webserver \
1235
	tools/kvm-ifup.in \
1236
	tools/kvm-ifup-os.in \
1237
	tools/vif-ganeti.in \
1238
	tools/net-common.in \
1239
	tools/vcluster-setup.in \
1240
	$(docinput) \
1241
	doc/html \
1242
	$(BUILT_EXAMPLES:%=%.in) \
1243
	doc/examples/ganeti.default \
1244
	doc/examples/ganeti.default-debug \
1245
	doc/examples/hooks/ethers \
1246
	doc/examples/gnt-debug/README \
1247
	doc/examples/gnt-debug/delay0.json \
1248
	doc/examples/gnt-debug/delay50.json \
1249
	doc/users/groupmemberships.in \
1250
	doc/users/groups.in \
1251
	doc/users/users.in \
1252
	$(dist_TESTS) \
1253
	$(TEST_FILES) \
1254
	$(python_test_support) \
1255
	man/footer.rst \
1256
	$(manrst) \
1257
	$(maninput) \
1258
	qa/qa-sample.json \
1259
	$(qa_scripts) \
1260
	$(HS_LIBTEST_SRCS) $(HS_BUILT_SRCS_IN) \
1261
	$(HS_PROG_SRCS) \
1262
	src/lint-hints.hs \
1263
	test/hs/cli-tests-defs.sh \
1264
	test/hs/offline-test.sh \
1265
	.ghci
1266

    
1267
man_MANS = \
1268
	man/ganeti-cleaner.8 \
1269
	man/ganeti-confd.8 \
1270
	man/ganeti-luxid.8 \
1271
	man/ganeti-listrunner.8 \
1272
	man/ganeti-kvmd.8 \
1273
	man/ganeti-masterd.8 \
1274
	man/ganeti-mond.8 \
1275
	man/ganeti-noded.8 \
1276
	man/ganeti-os-interface.7 \
1277
	man/ganeti-extstorage-interface.7 \
1278
	man/ganeti-rapi.8 \
1279
	man/ganeti-watcher.8 \
1280
	man/ganeti.7 \
1281
	man/gnt-backup.8 \
1282
	man/gnt-cluster.8 \
1283
	man/gnt-debug.8 \
1284
	man/gnt-group.8 \
1285
	man/gnt-network.8 \
1286
	man/gnt-instance.8 \
1287
	man/gnt-job.8 \
1288
	man/gnt-node.8 \
1289
	man/gnt-os.8 \
1290
	man/gnt-storage.8 \
1291
	man/hail.1 \
1292
	man/harep.1 \
1293
	man/hbal.1 \
1294
	man/hcheck.1 \
1295
	man/hinfo.1 \
1296
	man/hscan.1 \
1297
	man/hspace.1 \
1298
	man/hsqueeze.1 \
1299
	man/hroller.1 \
1300
	man/htools.1 \
1301
	man/mon-collector.7
1302

    
1303
# Remove extensions from all filenames in man_MANS
1304
mannoext = $(patsubst %.1,%,$(patsubst %.7,%,$(patsubst %.8,%,$(man_MANS))))
1305

    
1306
manrst = $(patsubst %,%.rst,$(mannoext))
1307
manhtml = $(patsubst %.rst,%.html,$(manrst))
1308
mangen = $(patsubst %.rst,%.gen,$(manrst))
1309
maninput = \
1310
	$(patsubst %.1,%.1.in,$(patsubst %.7,%.7.in,$(patsubst %.8,%.8.in,$(man_MANS)))) \
1311
	$(patsubst %.html,%.html.in,$(manhtml)) \
1312
	$(mangen)
1313

    
1314
manfullpath = $(patsubst man/%.1,man1/%.1,\
1315
	$(patsubst man/%.7,man7/%.7,\
1316
	$(patsubst man/%.8,man8/%.8,$(man_MANS))))
1317

    
1318
TEST_FILES = \
1319
	test/autotools/autotools-check-news.test \
1320
	test/data/htools/clean-nonzero-score.data \
1321
	test/data/htools/common-suffix.data \
1322
	test/data/htools/empty-cluster.data \
1323
	test/data/htools/hail-alloc-drbd.json \
1324
	test/data/htools/hail-alloc-invalid-network.json \
1325
	test/data/htools/hail-alloc-invalid-twodisks.json \
1326
	test/data/htools/hail-alloc-restricted-network.json \
1327
	test/data/htools/hail-alloc-spindles.json \
1328
	test/data/htools/hail-alloc-twodisks.json \
1329
	test/data/htools/hail-change-group.json \
1330
	test/data/htools/hail-invalid-reloc.json \
1331
	test/data/htools/hail-node-evac.json \
1332
	test/data/htools/hail-reloc-drbd.json \
1333
	test/data/htools/hbal-dyn.data \
1334
	test/data/htools/hbal-excl-tags.data \
1335
	test/data/htools/hbal-split-insts.data \
1336
	test/data/htools/hspace-tiered-dualspec-exclusive.data \
1337
	test/data/htools/hspace-tiered-dualspec.data \
1338
	test/data/htools/hspace-tiered-exclusive.data \
1339
	test/data/htools/hspace-tiered-ipolicy.data \
1340
	test/data/htools/hspace-tiered-mixed.data \
1341
	test/data/htools/hspace-tiered-resourcetypes.data \
1342
	test/data/htools/hspace-tiered-vcpu.data \
1343
	test/data/htools/hspace-tiered.data \
1344
	test/data/htools/invalid-node.data \
1345
	test/data/htools/missing-resources.data \
1346
	test/data/htools/multiple-master.data \
1347
	test/data/htools/multiple-tags.data \
1348
	test/data/htools/n1-failure.data \
1349
	test/data/htools/rapi/groups.json \
1350
	test/data/htools/rapi/info.json \
1351
	test/data/htools/rapi/instances.json \
1352
	test/data/htools/rapi/nodes.json \
1353
	test/data/htools/hroller-full.data \
1354
	test/data/htools/hroller-nodegroups.data \
1355
	test/data/htools/hroller-nonredundant.data \
1356
	test/data/htools/hroller-online.data \
1357
	test/data/htools/hsqueeze-mixed-instances.data \
1358
	test/data/htools/hsqueeze-overutilized.data \
1359
	test/data/htools/hsqueeze-underutilized.data \
1360
	test/data/htools/unique-reboot-order.data \
1361
	test/hs/shelltests/htools-balancing.test \
1362
	test/hs/shelltests/htools-basic.test \
1363
	test/hs/shelltests/htools-dynutil.test \
1364
	test/hs/shelltests/htools-excl.test \
1365
	test/hs/shelltests/htools-hail.test \
1366
	test/hs/shelltests/htools-hroller.test \
1367
	test/hs/shelltests/htools-hspace.test \
1368
	test/hs/shelltests/htools-hsqueeze.test \
1369
	test/hs/shelltests/htools-invalid.test \
1370
	test/hs/shelltests/htools-multi-group.test \
1371
	test/hs/shelltests/htools-no-backend.test \
1372
	test/hs/shelltests/htools-rapi.test \
1373
	test/hs/shelltests/htools-single-group.test \
1374
	test/hs/shelltests/htools-text-backend.test \
1375
	test/hs/shelltests/htools-mon-collector.test \
1376
	test/data/bdev-drbd-8.0.txt \
1377
	test/data/bdev-drbd-8.3.txt \
1378
	test/data/bdev-drbd-8.4.txt \
1379
	test/data/bdev-drbd-8.4-no-disk-params.txt \
1380
	test/data/bdev-drbd-disk.txt \
1381
	test/data/bdev-drbd-net-ip4.txt \
1382
	test/data/bdev-drbd-net-ip6.txt \
1383
	test/data/bdev-rbd/json_output_empty.txt \
1384
	test/data/bdev-rbd/json_output_extra_matches.txt \
1385
	test/data/bdev-rbd/json_output_no_matches.txt \
1386
	test/data/bdev-rbd/json_output_ok.txt \
1387
	test/data/bdev-rbd/plain_output_new_extra_matches.txt \
1388
	test/data/bdev-rbd/plain_output_new_no_matches.txt \
1389
	test/data/bdev-rbd/plain_output_new_ok.txt \
1390
	test/data/bdev-rbd/plain_output_old_empty.txt \
1391
	test/data/bdev-rbd/plain_output_old_extra_matches.txt \
1392
	test/data/bdev-rbd/plain_output_old_no_matches.txt \
1393
	test/data/bdev-rbd/plain_output_old_ok.txt \
1394
	test/data/bdev-rbd/output_invalid.txt \
1395
	test/data/cert1.pem \
1396
	test/data/cert2.pem \
1397
	test/data/cluster_config_2.7.json \
1398
	test/data/cluster_config_2.8.json \
1399
	test/data/cluster_config_2.9.json \
1400
	test/data/cluster_config_2.10.json \
1401
	test/data/cluster_config_2.11.json \
1402
	test/data/instance-minor-pairing.txt \
1403
	test/data/instance-prim-sec.txt \
1404
	test/data/ip-addr-show-dummy0.txt \
1405
	test/data/ip-addr-show-lo-ipv4.txt \
1406
	test/data/ip-addr-show-lo-ipv6.txt \
1407
	test/data/ip-addr-show-lo-oneline-ipv4.txt \
1408
	test/data/ip-addr-show-lo-oneline-ipv6.txt \
1409
	test/data/ip-addr-show-lo-oneline.txt \
1410
	test/data/ip-addr-show-lo.txt \
1411
	test/data/kvm_0.12.5_help.txt \
1412
	test/data/kvm_0.15.90_help.txt \
1413
	test/data/kvm_0.9.1_help.txt \
1414
	test/data/kvm_0.9.1_help_boot_test.txt \
1415
	test/data/kvm_1.0_help.txt \
1416
	test/data/kvm_1.1.2_help.txt \
1417
	test/data/kvm_runtime.json \
1418
	test/data/lvs_lv.txt \
1419
	test/data/NEWS_OK.txt \
1420
	test/data/NEWS_previous_unreleased.txt \
1421
	test/data/ovfdata/compr_disk.vmdk.gz \
1422
	test/data/ovfdata/config.ini \
1423
	test/data/ovfdata/corrupted_resources.ovf \
1424
	test/data/ovfdata/empty.ini \
1425
	test/data/ovfdata/empty.ovf \
1426
	test/data/ovfdata/ganeti.mf \
1427
	test/data/ovfdata/ganeti.ovf \
1428
	test/data/ovfdata/gzip_disk.ovf \
1429
	test/data/ovfdata/new_disk.vmdk \
1430
	test/data/ovfdata/no_disk.ini \
1431
	test/data/ovfdata/no_disk_in_ref.ovf \
1432
	test/data/ovfdata/no_os.ini \
1433
	test/data/ovfdata/no_ovf.ova \
1434
	test/data/ovfdata/other/rawdisk.raw \
1435
	test/data/ovfdata/ova.ova \
1436
	test/data/ovfdata/rawdisk.raw \
1437
	test/data/ovfdata/second_disk.vmdk \
1438
	test/data/ovfdata/unsafe_path.ini \
1439
	test/data/ovfdata/virtualbox.ovf \
1440
	test/data/ovfdata/wrong_config.ini \
1441
	test/data/ovfdata/wrong_extension.ovd \
1442
	test/data/ovfdata/wrong_manifest.mf \
1443
	test/data/ovfdata/wrong_manifest.ovf \
1444
	test/data/ovfdata/wrong_ova.ova \
1445
	test/data/ovfdata/wrong_xml.ovf \
1446
	test/data/proc_diskstats.txt \
1447
	test/data/proc_drbd8.txt \
1448
	test/data/proc_drbd80-emptyline.txt \
1449
	test/data/proc_drbd80-emptyversion.txt \
1450
	test/data/proc_drbd83.txt \
1451
	test/data/proc_drbd83_sync.txt \
1452
	test/data/proc_drbd83_sync_want.txt \
1453
	test/data/proc_drbd83_sync_krnl2.6.39.txt \
1454
	test/data/proc_drbd84.txt \
1455
	test/data/proc_drbd84_sync.txt \
1456
	test/data/proc_meminfo.txt \
1457
	test/data/proc_cpuinfo.txt \
1458
	test/data/qa-minimal-nodes-instances-only.json \
1459
	test/data/sys_drbd_usermode_helper.txt \
1460
	test/data/vgreduce-removemissing-2.02.02.txt \
1461
	test/data/vgreduce-removemissing-2.02.66-fail.txt \
1462
	test/data/vgreduce-removemissing-2.02.66-ok.txt \
1463
	test/data/vgs-missing-pvs-2.02.02.txt \
1464
	test/data/vgs-missing-pvs-2.02.66.txt \
1465
	test/data/xen-xm-info-4.0.1.txt \
1466
	test/data/xen-xm-list-4.0.1-dom0-only.txt \
1467
	test/data/xen-xm-list-4.0.1-four-instances.txt \
1468
	test/data/xen-xm-list-long-4.0.1.txt \
1469
	test/data/xen-xm-uptime-4.0.1.txt \
1470
	test/py/ganeti-cli.test \
1471
	test/py/gnt-cli.test \
1472
	test/py/import-export_unittest-helper
1473

    
1474

    
1475
python_tests = \
1476
	doc/examples/rapi_testutils.py \
1477
	test/py/cmdlib/backup_unittest.py \
1478
	test/py/cmdlib/cluster_unittest.py \
1479
	test/py/cmdlib/cmdlib_unittest.py \
1480
	test/py/cmdlib/group_unittest.py \
1481
	test/py/cmdlib/instance_unittest.py \
1482
	test/py/cmdlib/instance_migration_unittest.py \
1483
	test/py/cmdlib/instance_query_unittest.py \
1484
	test/py/cmdlib/instance_storage_unittest.py \
1485
	test/py/cmdlib/node_unittest.py \
1486
	test/py/cmdlib/test_unittest.py \
1487
	test/py/cfgupgrade_unittest.py \
1488
	test/py/docs_unittest.py \
1489
	test/py/ganeti.asyncnotifier_unittest.py \
1490
	test/py/ganeti.backend_unittest-runasroot.py \
1491
	test/py/ganeti.backend_unittest.py \
1492
	test/py/ganeti.bootstrap_unittest.py \
1493
	test/py/ganeti.cli_unittest.py \
1494
	test/py/ganeti.client.gnt_cluster_unittest.py \
1495
	test/py/ganeti.client.gnt_instance_unittest.py \
1496
	test/py/ganeti.client.gnt_job_unittest.py \
1497
	test/py/ganeti.compat_unittest.py \
1498
	test/py/ganeti.confd.client_unittest.py \
1499
	test/py/ganeti.config_unittest.py \
1500
	test/py/ganeti.constants_unittest.py \
1501
	test/py/ganeti.daemon_unittest.py \
1502
	test/py/ganeti.errors_unittest.py \
1503
	test/py/ganeti.hooks_unittest.py \
1504
	test/py/ganeti.ht_unittest.py \
1505
	test/py/ganeti.http_unittest.py \
1506
	test/py/ganeti.hypervisor.hv_chroot_unittest.py \
1507
	test/py/ganeti.hypervisor.hv_fake_unittest.py \
1508
	test/py/ganeti.hypervisor.hv_kvm_unittest.py \
1509
	test/py/ganeti.hypervisor.hv_lxc_unittest.py \
1510
	test/py/ganeti.hypervisor.hv_xen_unittest.py \
1511
	test/py/ganeti.hypervisor_unittest.py \
1512
	test/py/ganeti.impexpd_unittest.py \
1513
	test/py/ganeti.jqueue_unittest.py \
1514
	test/py/ganeti.jstore_unittest.py \
1515
	test/py/ganeti.locking_unittest.py \
1516
	test/py/ganeti.luxi_unittest.py \
1517
	test/py/ganeti.masterd.iallocator_unittest.py \
1518
	test/py/ganeti.masterd.instance_unittest.py \
1519
	test/py/ganeti.mcpu_unittest.py \
1520
	test/py/ganeti.netutils_unittest.py \
1521
	test/py/ganeti.objects_unittest.py \
1522
	test/py/ganeti.opcodes_unittest.py \
1523
	test/py/ganeti.outils_unittest.py \
1524
	test/py/ganeti.ovf_unittest.py \
1525
	test/py/ganeti.qlang_unittest.py \
1526
	test/py/ganeti.query_unittest.py \
1527
	test/py/ganeti.rapi.baserlib_unittest.py \
1528
	test/py/ganeti.rapi.client_unittest.py \
1529
	test/py/ganeti.rapi.resources_unittest.py \
1530
	test/py/ganeti.rapi.rlib2_unittest.py \
1531
	test/py/ganeti.rapi.testutils_unittest.py \
1532
	test/py/ganeti.rpc_unittest.py \
1533
	test/py/ganeti.rpc.client_unittest.py \
1534
	test/py/ganeti.runtime_unittest.py \
1535
	test/py/ganeti.serializer_unittest.py \
1536
	test/py/ganeti.server.rapi_unittest.py \
1537
	test/py/ganeti.ssconf_unittest.py \
1538
	test/py/ganeti.ssh_unittest.py \
1539
	test/py/ganeti.storage.bdev_unittest.py \
1540
	test/py/ganeti.storage.container_unittest.py \
1541
	test/py/ganeti.storage.drbd_unittest.py \
1542
	test/py/ganeti.storage.filestorage_unittest.py \
1543
	test/py/ganeti.storage.gluster_unittest.py \
1544
	test/py/ganeti.tools.burnin_unittest.py \
1545
	test/py/ganeti.tools.ensure_dirs_unittest.py \
1546
	test/py/ganeti.tools.node_daemon_setup_unittest.py \
1547
	test/py/ganeti.tools.prepare_node_join_unittest.py \
1548
	test/py/ganeti.uidpool_unittest.py \
1549
	test/py/ganeti.utils.algo_unittest.py \
1550
	test/py/ganeti.utils.filelock_unittest.py \
1551
	test/py/ganeti.utils.hash_unittest.py \
1552
	test/py/ganeti.utils.io_unittest-runasroot.py \
1553
	test/py/ganeti.utils.io_unittest.py \
1554
	test/py/ganeti.utils.log_unittest.py \
1555
	test/py/ganeti.utils.lvm_unittest.py \
1556
	test/py/ganeti.utils.mlock_unittest.py \
1557
	test/py/ganeti.utils.nodesetup_unittest.py \
1558
	test/py/ganeti.utils.process_unittest.py \
1559
	test/py/ganeti.utils.retry_unittest.py \
1560
	test/py/ganeti.utils.security_unittest.py \
1561
	test/py/ganeti.utils.storage_unittest.py \
1562
	test/py/ganeti.utils.text_unittest.py \
1563
	test/py/ganeti.utils.version_unittest.py \
1564
	test/py/ganeti.utils.wrapper_unittest.py \
1565
	test/py/ganeti.utils.x509_unittest.py \
1566
	test/py/ganeti.utils_unittest.py \
1567
	test/py/ganeti.vcluster_unittest.py \
1568
	test/py/ganeti.workerpool_unittest.py \
1569
	test/py/pycurl_reset_unittest.py \
1570
	test/py/qa.qa_config_unittest.py \
1571
	test/py/tempfile_fork_unittest.py
1572

    
1573
python_test_support = \
1574
	test/py/__init__.py \
1575
	test/py/lockperf.py \
1576
	test/py/testutils.py \
1577
	test/py/mocks.py \
1578
	test/py/cmdlib/__init__.py \
1579
	test/py/cmdlib/testsupport/__init__.py \
1580
	test/py/cmdlib/testsupport/cmdlib_testcase.py \
1581
	test/py/cmdlib/testsupport/config_mock.py \
1582
	test/py/cmdlib/testsupport/iallocator_mock.py \
1583
	test/py/cmdlib/testsupport/lock_manager_mock.py \
1584
	test/py/cmdlib/testsupport/netutils_mock.py \
1585
	test/py/cmdlib/testsupport/processor_mock.py \
1586
	test/py/cmdlib/testsupport/rpc_runner_mock.py \
1587
	test/py/cmdlib/testsupport/ssh_mock.py \
1588
	test/py/cmdlib/testsupport/utils_mock.py \
1589
	test/py/cmdlib/testsupport/util.py
1590

    
1591
haskell_tests = test/hs/htest
1592

    
1593
dist_TESTS = \
1594
	test/py/check-cert-expired_unittest.bash \
1595
	test/py/daemon-util_unittest.bash \
1596
	test/py/ganeti-cleaner_unittest.bash \
1597
	test/py/import-export_unittest.bash \
1598
	test/py/cli-test.bash \
1599
	test/py/bash_completion.bash
1600

    
1601
if PY_UNIT
1602
dist_TESTS += $(python_tests)
1603
endif
1604

    
1605
nodist_TESTS =
1606
check_SCRIPTS =
1607

    
1608
if WANT_HSTESTS
1609
nodist_TESTS += $(haskell_tests)
1610
# test dependency
1611
test/hs/offline-test.sh: test/hs/hpc-htools test/hs/hpc-mon-collector
1612
dist_TESTS += test/hs/offline-test.sh
1613
check_SCRIPTS += \
1614
	test/hs/hpc-htools \
1615
	test/hs/hpc-mon-collector \
1616
	$(HS_BUILT_TEST_HELPERS)
1617
endif
1618

    
1619
TESTS = $(dist_TESTS) $(nodist_TESTS)
1620

    
1621
# Environment for all tests
1622
PLAIN_TESTS_ENVIRONMENT = \
1623
	PYTHONPATH=.:./test/py \
1624
	TOP_SRCDIR=$(abs_top_srcdir) TOP_BUILDDIR=$(abs_top_builddir) \
1625
	PYTHON=$(PYTHON) FAKEROOT=$(FAKEROOT_PATH) \
1626
	$(RUN_IN_TEMPDIR)
1627

    
1628
# Environment for tests run by automake
1629
TESTS_ENVIRONMENT = \
1630
	$(PLAIN_TESTS_ENVIRONMENT) $(abs_top_srcdir)/autotools/testrunner
1631

    
1632
all_python_code = \
1633
	$(dist_sbin_SCRIPTS) \
1634
	$(python_scripts) \
1635
	$(pkglib_python_scripts) \
1636
	$(nodist_pkglib_python_scripts) \
1637
	$(nodist_tools_python_scripts) \
1638
	$(pkgpython_PYTHON) \
1639
	$(client_PYTHON) \
1640
	$(cmdlib_PYTHON) \
1641
	$(hypervisor_PYTHON) \
1642
	$(storage_PYTHON) \
1643
	$(rapi_PYTHON) \
1644
	$(server_PYTHON) \
1645
	$(rpc_PYTHON) \
1646
	$(rpc_stub_PYTHON) \
1647
	$(pytools_PYTHON) \
1648
	$(http_PYTHON) \
1649
	$(confd_PYTHON) \
1650
	$(masterd_PYTHON) \
1651
	$(impexpd_PYTHON) \
1652
	$(utils_PYTHON) \
1653
	$(watcher_PYTHON) \
1654
	$(noinst_PYTHON) \
1655
	$(qa_scripts)
1656

    
1657
if PY_UNIT
1658
all_python_code += $(python_tests)
1659
all_python_code += $(python_test_support)
1660
endif
1661

    
1662
srclink_files = \
1663
	man/footer.rst \
1664
	test/py/check-cert-expired_unittest.bash \
1665
	test/py/daemon-util_unittest.bash \
1666
	test/py/ganeti-cleaner_unittest.bash \
1667
	test/py/import-export_unittest.bash \
1668
	test/py/cli-test.bash \
1669
	test/py/bash_completion.bash \
1670
	test/hs/offline-test.sh \
1671
	test/hs/cli-tests-defs.sh \
1672
	$(all_python_code) \
1673
	$(HS_LIBTEST_SRCS) $(HS_PROG_SRCS) \
1674
	$(docinput)
1675

    
1676
check_python_code = \
1677
	$(BUILD_BASH_COMPLETION) \
1678
	$(CHECK_IMPORTS) \
1679
	$(CHECK_HEADER) \
1680
	$(DOCPP) \
1681
	$(all_python_code)
1682

    
1683
lint_python_code = \
1684
	ganeti \
1685
	ganeti/http/server.py \
1686
	$(dist_sbin_SCRIPTS) \
1687
	$(python_scripts) \
1688
	$(pkglib_python_scripts) \
1689
	$(BUILD_BASH_COMPLETION) \
1690
	$(CHECK_IMPORTS) \
1691
	$(CHECK_HEADER) \
1692
	$(DOCPP) \
1693
	$(gnt_python_sbin_SCRIPTS) \
1694
	$(PYTHON_BOOTSTRAP)
1695

    
1696
standalone_python_modules = \
1697
	lib/rapi/client.py \
1698
	tools/ganeti-listrunner
1699

    
1700
pep8_python_code = \
1701
	ganeti \
1702
	ganeti/http/server.py \
1703
	$(dist_sbin_SCRIPTS) \
1704
	$(python_scripts) \
1705
	$(pkglib_python_scripts) \
1706
	$(BUILD_BASH_COMPLETION) \
1707
	$(CHECK_HEADER) \
1708
	$(DOCPP) \
1709
	$(PYTHON_BOOTSTRAP) \
1710
	$(gnt_python_sbin_SCRIPTS) \
1711
	qa \
1712
	$(python_test_support)
1713

    
1714
test/py/daemon-util_unittest.bash: daemons/daemon-util
1715

    
1716
test/py/ganeti-cleaner_unittest.bash: daemons/ganeti-cleaner
1717

    
1718
test/py/bash_completion.bash: doc/examples/bash_completion-debug
1719

    
1720
tools/kvm-ifup: tools/kvm-ifup.in $(REPLACE_VARS_SED)
1721
	sed -f $(REPLACE_VARS_SED) < $< > $@
1722
	chmod +x $@
1723

    
1724
tools/kvm-ifup-os: tools/kvm-ifup-os.in $(REPLACE_VARS_SED)
1725
	sed -f $(REPLACE_VARS_SED) < $< > $@
1726
	chmod +x $@
1727

    
1728
tools/vif-ganeti: tools/vif-ganeti.in $(REPLACE_VARS_SED)
1729
	sed -f $(REPLACE_VARS_SED) < $< > $@
1730
	chmod +x $@
1731

    
1732
tools/net-common: tools/net-common.in $(REPLACE_VARS_SED)
1733
	sed -f $(REPLACE_VARS_SED) < $< > $@
1734
	chmod +x $@
1735

    
1736
tools/users-setup: Makefile $(userspecs)
1737
	set -e; \
1738
	{ echo '#!/bin/sh'; \
1739
	  echo 'if [ "x$$1" != "x--yes-do-it" ];'; \
1740
	  echo 'then echo "This will do the following changes"'; \
1741
	  $(AWK) -- '{print "echo + Will add group ",$$1; count++}\
1742
	             END {if (count == 0) {print "echo + No groups to add"}}' doc/users/groups; \
1743
	  $(AWK) -- '{if (NF > 1) {print "echo + Will add user",$$1,"with primary group",$$2} \
1744
	                          else {print "echo + Will add user",$$1}; count++}\
1745
	             END {if (count == 0) {print "echo + No users to add"}}' doc/users/users; \
1746
	  $(AWK) -- '{print "echo + Will add user",$$1,"to group",$$2}' doc/users/groupmemberships; \
1747
	  echo 'echo'; \
1748
	  echo 'echo "OK? (y/n)"'; \
1749
	  echo 'read confirm'; \
1750
	  echo 'if [ "x$$confirm" != "xy" ]; then exit 0; fi'; \
1751
	  echo 'fi'; \
1752
	  $(AWK) -- '{print "addgroup --system",$$1}' doc/users/groups; \
1753
	  $(AWK) -- '{if (NF > 1) {print "adduser --system --ingroup",$$2,$$1} else {print "adduser --system",$$1}}' doc/users/users; \
1754
	  $(AWK) -- '{print "adduser",$$1,$$2}' doc/users/groupmemberships; \
1755
	} > $@
1756
	chmod +x $@
1757

    
1758
tools/vcluster-setup: tools/vcluster-setup.in $(REPLACE_VARS_SED)
1759
	sed -f $(REPLACE_VARS_SED) < $< > $@
1760
	chmod +x $@
1761

    
1762
daemons/%:: daemons/%.in $(REPLACE_VARS_SED)
1763
	sed -f $(REPLACE_VARS_SED) < $< > $@
1764
	chmod +x $@
1765

    
1766
doc/examples/%:: doc/examples/%.in $(REPLACE_VARS_SED)
1767
	sed -f $(REPLACE_VARS_SED) < $< > $@
1768

    
1769
doc/examples/bash_completion: BC_ARGS = --compact
1770
doc/examples/bash_completion-debug: BC_ARGS =
1771

    
1772
doc/examples/bash_completion doc/examples/bash_completion-debug: \
1773
	$(BUILD_BASH_COMPLETION) $(RUN_IN_TEMPDIR) \
1774
	lib/cli.py $(gnt_scripts) $(client_PYTHON) tools/burnin \
1775
	daemons/ganeti-cleaner \
1776
	$(GENERATED_FILES) $(HS_GENERATED_FILES)
1777
	PYTHONPATH=. $(RUN_IN_TEMPDIR) \
1778
	  $(CURDIR)/$(BUILD_BASH_COMPLETION) $(BC_ARGS) > $@
1779

    
1780
man/%.gen: man/%.rst lib/query.py lib/build/sphinx_ext.py \
1781
	lib/build/shell_example_lexer.py \
1782
	| $(RUN_IN_TEMPDIR) $(built_python_sources)
1783
	@echo "Checking $< for hardcoded paths..."
1784
	@if grep -nEf autotools/wrong-hardcoded-paths $<; then \
1785
	  echo "Man page $< has hardcoded paths (see above)!" 1>&2 ; \
1786
	  exit 1; \
1787
	fi
1788
	set -e ; \
1789
	trap 'echo auto-removing $@; rm $@' EXIT; \
1790
	PYTHONPATH=. $(RUN_IN_TEMPDIR) $(CURDIR)/$(DOCPP) < $< > $@ ;\
1791
	$(CHECK_MAN_REFERENCES) $@; \
1792
	trap - EXIT
1793

    
1794
man/%.7.in man/%.8.in man/%.1.in: man/%.gen man/footer.rst
1795
	@test -n "$(PANDOC)" || \
1796
	  { echo 'pandoc' not found during configure; exit 1; }
1797
	set -o pipefail -e; \
1798
	trap 'echo auto-removing $@; rm $@' EXIT; \
1799
	$(PANDOC) -s -f rst -t man $< man/footer.rst | \
1800
	  sed -e 's/\\@/@/g' > $@; \
1801
	if test -n "$(MAN_HAS_WARNINGS)"; then $(CHECK_MAN_WARNINGS) $@; fi; \
1802
	$(CHECK_MAN_DASHES) $@; \
1803
	trap - EXIT
1804

    
1805
man/%.html.in: man/%.gen man/footer.rst
1806
	@test -n "$(PANDOC)" || \
1807
	  { echo 'pandoc' not found during configure; exit 1; }
1808
	set -o pipefail ; \
1809
	$(PANDOC) --toc -s -f rst -t html $< man/footer.rst | \
1810
	  sed -e 's/\\@/@/g' > $@
1811

    
1812
man/%: man/%.in  $(REPLACE_VARS_SED)
1813
	sed -f $(REPLACE_VARS_SED) < $< > $@
1814

    
1815
epydoc.conf: epydoc.conf.in $(REPLACE_VARS_SED)
1816
	sed -f $(REPLACE_VARS_SED) < $< > $@
1817

    
1818
vcs-version:
1819
	if test -d .git; then \
1820
	  git describe > $@; \
1821
	elif test ! -f $@ ; then \
1822
	  echo "Cannot auto-generate $@ file"; exit 1; \
1823
	fi
1824

    
1825
.PHONY: clean-vcs-version
1826
clean-vcs-version:
1827
	rm -f vcs-version
1828

    
1829
.PHONY: regen-vcs-version
1830
regen-vcs-version:
1831
	@set -e; \
1832
	cd $(srcdir); \
1833
	if test -d .git; then \
1834
	  T=`mktemp` ; trap 'rm -f $$T' EXIT; \
1835
	  git describe > $$T; \
1836
	  if ! cmp --quiet $$T vcs-version; then \
1837
	    mv $$T vcs-version; \
1838
	  fi; \
1839
	fi
1840

    
1841
src/Ganeti/Version.hs: src/Ganeti/Version.hs.in \
1842
	vcs-version $(built_base_sources)
1843
	set -e; \
1844
	VCSVER=`cat $(abs_top_srcdir)/vcs-version`; \
1845
	sed -e "s/%ver%/$$VCSVER/" < $< > $@
1846

    
1847
src/Ganeti/Hs2Py/ListConstants.hs: src/Ganeti/Hs2Py/ListConstants.hs.in \
1848
				   src/Ganeti/Constants.hs \
1849
			         | stamp-directories
1850
	@echo Generating $@
1851
	@set -e; \
1852
## Extract constant names from 'Constants.hs' by extracting the left
1853
## side of all lines containing an equal sign (i.e., '=') and
1854
## prepending the apostrophe sign (i.e., "'").
1855
##
1856
## For example, the constant
1857
##   adminstDown = ...
1858
## becomes
1859
##   'adminstDown
1860
	NAMES=$$(sed -e "/^--/ d" $(abs_top_srcdir)/src/Ganeti/Constants.hs |\
1861
		 sed -n -e "/=/ s/\(.*\) =.*/    '\1:/g p"); \
1862
	m4 -DPY_CONSTANT_NAMES="$$NAMES" \
1863
		$(abs_top_srcdir)/src/Ganeti/Hs2Py/ListConstants.hs.in > $@
1864

    
1865
src/Ganeti/Curl/Internal.hs: src/Ganeti/Curl/Internal.hsc | stamp-directories
1866
	hsc2hs -o $@ $<
1867

    
1868
test/hs/Test/Ganeti/TestImports.hs: test/hs/Test/Ganeti/TestImports.hs.in \
1869
	$(built_base_sources)
1870
	set -e; \
1871
	{ cat $< ; \
1872
	  echo ; \
1873
	  for name in $(filter-out Ganeti.THH,$(subst /,.,$(patsubst %.hs,%,$(patsubst src/%,%,$(HS_LIB_SRCS))))) ; do \
1874
	    echo "import $$name ()" ; \
1875
	  done ; \
1876
	} > $@
1877

    
1878
lib/_constants.py: Makefile src/hs2py lib/_constants.py.in | stamp-directories
1879
	cat $(abs_top_srcdir)/lib/_constants.py.in > $@
1880
	src/hs2py --constants >> $@
1881

    
1882
lib/constants.py: lib/_constants.py
1883

    
1884
src/AutoConf.hs: Makefile src/AutoConf.hs.in $(PRINT_PY_CONSTANTS) \
1885
	       | $(built_base_sources)
1886
	@echo "m4 ... >" $@
1887
	@m4 -DPACKAGE_VERSION="$(PACKAGE_VERSION)" \
1888
	    -DVERSION_MAJOR="$(VERSION_MAJOR)" \
1889
	    -DVERSION_MINOR="$(VERSION_MINOR)" \
1890
	    -DVERSION_REVISION="$(VERSION_REVISION)" \
1891
	    -DVERSION_SUFFIX="$(VERSION_SUFFIX)" \
1892
	    -DVERSION_FULL="$(VERSION_FULL)" \
1893
	    -DDIRVERSION="$(DIRVERSION)" \
1894
	    -DLOCALSTATEDIR="$(localstatedir)" \
1895
	    -DSYSCONFDIR="$(sysconfdir)" \
1896
	    -DSSH_CONFIG_DIR="$(SSH_CONFIG_DIR)" \
1897
	    -DSSH_LOGIN_USER="$(SSH_LOGIN_USER)" \
1898
	    -DSSH_CONSOLE_USER="$(SSH_CONSOLE_USER)" \
1899
	    -DEXPORT_DIR="$(EXPORT_DIR)" \
1900
	    -DOS_SEARCH_PATH="\"$(OS_SEARCH_PATH)\"" \
1901
	    -DES_SEARCH_PATH="\"$(ES_SEARCH_PATH)\"" \
1902
	    -DXEN_BOOTLOADER="$(XEN_BOOTLOADER)" \
1903
	    -DXEN_CONFIG_DIR="$(XEN_CONFIG_DIR)" \
1904
	    -DXEN_KERNEL="$(XEN_KERNEL)" \
1905
	    -DXEN_INITRD="$(XEN_INITRD)" \
1906
	    -DKVM_KERNEL="$(KVM_KERNEL)" \
1907
	    -DSHARED_FILE_STORAGE_DIR="$(SHARED_FILE_STORAGE_DIR)" \
1908
	    -DIALLOCATOR_SEARCH_PATH="\"$(IALLOCATOR_SEARCH_PATH)\"" \
1909
	    -DKVM_PATH="$(KVM_PATH)" \
1910
	    -DIP_PATH="$(IP_PATH)" \
1911
	    -DSOCAT_PATH="$(SOCAT)" \
1912
	    -DSOCAT_USE_ESCAPE="$(SOCAT_USE_ESCAPE)" \
1913
	    -DSOCAT_USE_COMPRESS="$(SOCAT_USE_COMPRESS)" \
1914
	    -DLVM_STRIPECOUNT="$(LVM_STRIPECOUNT)" \
1915
	    -DTOOLSDIR="$(libdir)/ganeti/tools" \
1916
	    -DGNT_SCRIPTS="$(foreach i,$(notdir $(gnt_scripts)),\"$(i)\":)" \
1917
	    -DHS_HTOOLS_PROGS="$(foreach i,$(HS_HTOOLS_PROGS),\"$(i)\":)" \
1918
	    -DPKGLIBDIR="$(libdir)/ganeti" \
1919
	    -DSHAREDIR="$(prefix)/share/ganeti" \
1920
	    -DVERSIONEDSHAREDIR="$(versionedsharedir)" \
1921
	    -DDRBD_BARRIERS="$(DRBD_BARRIERS)" \
1922
	    -DDRBD_NO_META_FLUSH="$(DRBD_NO_META_FLUSH)" \
1923
	    -DSYSLOG_USAGE="$(SYSLOG_USAGE)" \
1924
	    -DDAEMONS_GROUP="$(DAEMONS_GROUP)" \
1925
	    -DADMIN_GROUP="$(ADMIN_GROUP)" \
1926
	    -DMASTERD_USER="$(MASTERD_USER)" \
1927
	    -DMASTERD_GROUP="$(MASTERD_GROUP)" \
1928
	    -DMETAD_USER="$(METAD_USER)" \
1929
	    -DMETAD_GROUP="$(METAD_GROUP)" \
1930
	    -DRAPI_USER="$(RAPI_USER)" \
1931
	    -DRAPI_GROUP="$(RAPI_GROUP)" \
1932
	    -DCONFD_USER="$(CONFD_USER)" \
1933
	    -DCONFD_GROUP="$(CONFD_GROUP)" \
1934
	    -DWCONFD_USER="$(WCONFD_USER)" \
1935
	    -DWCONFD_GROUP="$(WCONFD_GROUP)" \
1936
	    -DKVMD_USER="$(KVMD_USER)" \
1937
	    -DKVMD_GROUP="$(KVMD_GROUP)" \
1938
	    -DLUXID_USER="$(LUXID_USER)" \
1939
	    -DLUXID_GROUP="$(LUXID_GROUP)" \
1940
	    -DNODED_USER="$(NODED_USER)" \
1941
	    -DNODED_GROUP="$(NODED_GROUP)" \
1942
	    -DMOND_USER="$(MOND_USER)" \
1943
	    -DMOND_GROUP="$(MOND_GROUP)" \
1944
	    -DDISK_SEPARATOR="$(DISK_SEPARATOR)" \
1945
	    -DQEMUIMG_PATH="$(QEMUIMG_PATH)" \
1946
	    -DENABLE_CONFD="$(ENABLE_CONFD)" \
1947
	    -DXEN_CMD="$(XEN_CMD)" \
1948
	    -DENABLE_RESTRICTED_COMMANDS="$(ENABLE_RESTRICTED_COMMANDS)" \
1949
	    -DENABLE_MOND="$(ENABLE_MOND)" \
1950
	    -DHAS_GNU_LN="$(HAS_GNU_LN)" \
1951
	    -DMAN_PAGES="$$(for i in $(notdir $(man_MANS)); do \
1952
	                    echo -n "$$i" | sed -re 's/^(.*)\.([0-9]+)$$/("\1",\2):/g'; \
1953
	                    done)" \
1954
	    -DAF_INET4="$$(PYTHONPATH=. python $(PRINT_PY_CONSTANTS) AF_INET4)" \
1955
	    -DAF_INET6="$$(PYTHONPATH=. python $(PRINT_PY_CONSTANTS) AF_INET6)" \
1956
	$(abs_top_srcdir)/src/AutoConf.hs.in > $@
1957

    
1958
lib/_vcsversion.py: Makefile vcs-version | stamp-directories
1959
	set -e; \
1960
	VCSVER=`cat $(abs_top_srcdir)/vcs-version`; \
1961
	{ echo '# This file is automatically generated, do not edit!'; \
1962
	  echo '#'; \
1963
	  echo ''; \
1964
	  echo '"""Build-time VCS version number for Ganeti.'; \
1965
	  echo '';\
1966
	  echo 'This file is autogenerated by the build process.'; \
1967
	  echo 'For any changes you need to re-run ./configure (and'; \
1968
	  echo 'not edit by hand).'; \
1969
	  echo ''; \
1970
	  echo '"""'; \
1971
	  echo ''; \
1972
	  echo '# pylint: disable=C0301,C0324'; \
1973
	  echo '# because this is autogenerated, we do not want'; \
1974
	  echo '# style warnings' ; \
1975
	  echo ''; \
1976
	  echo "VCS_VERSION = '$$VCSVER'"; \
1977
	} > $@
1978

    
1979
lib/opcodes.py: Makefile src/hs2py lib/opcodes.py.in_before \
1980
		lib/opcodes.py.in_after | stamp-directories
1981
	cat $(abs_top_srcdir)/lib/opcodes.py.in_before > $@
1982
	src/hs2py --opcodes >> $@
1983
	cat $(abs_top_srcdir)/lib/opcodes.py.in_after >> $@
1984

    
1985
lib/_generated_rpc.py: lib/rpc_defs.py $(BUILD_RPC)
1986
	PYTHONPATH=. $(RUN_IN_TEMPDIR) $(CURDIR)/$(BUILD_RPC) lib/rpc_defs.py > $@
1987

    
1988
lib/rpc/stub/wconfd.py: Makefile src/hs2py | stamp-directories
1989
	src/hs2py --wconfd-rpc > $@
1990

    
1991
$(SHELL_ENV_INIT): Makefile stamp-directories
1992
	set -e; \
1993
	{ echo '# Allow overriding for tests'; \
1994
	  echo 'readonly LOCALSTATEDIR=$${LOCALSTATEDIR:-$${GANETI_ROOTDIR:-}$(localstatedir)}'; \
1995
	  echo 'readonly SYSCONFDIR=$${SYSCONFDIR:-$${GANETI_ROOTDIR:-}$(sysconfdir)}'; \
1996
	  echo; \
1997
	  echo 'readonly PKGLIBDIR=$(libdir)/ganeti'; \
1998
	  echo 'readonly LOG_DIR="$$LOCALSTATEDIR/log/ganeti"'; \
1999
	  echo 'readonly RUN_DIR="$$LOCALSTATEDIR/run/ganeti"'; \
2000
	  echo 'readonly DATA_DIR="$$LOCALSTATEDIR/lib/ganeti"'; \
2001
	  echo 'readonly CONF_DIR="$$SYSCONFDIR/ganeti"'; \
2002
	} > $@
2003

    
2004
## Writes sed script to replace placeholders with build-time values. The
2005
## additional quotes after the first @ sign are necessary to stop configure
2006
## from replacing those values as well.
2007
$(REPLACE_VARS_SED): $(SHELL_ENV_INIT) Makefile stamp-directories
2008
	set -e; \
2009
	{ echo 's#@''PREFIX@#$(prefix)#g'; \
2010
	  echo 's#@''SYSCONFDIR@#$(sysconfdir)#g'; \
2011
	  echo 's#@''LOCALSTATEDIR@#$(localstatedir)#g'; \
2012
	  echo 's#@''BINDIR@#$(BINDIR)#g'; \
2013
	  echo 's#@''SBINDIR@#$(SBINDIR)#g'; \
2014
	  echo 's#@''LIBDIR@#$(libdir)#g'; \
2015
	  echo 's#@''GANETI_VERSION@#$(PACKAGE_VERSION)#g'; \
2016
	  echo 's#@''CUSTOM_XEN_BOOTLOADER@#$(XEN_BOOTLOADER)#g'; \
2017
	  echo 's#@''CUSTOM_XEN_KERNEL@#$(XEN_KERNEL)#g'; \
2018
	  echo 's#@''CUSTOM_XEN_INITRD@#$(XEN_INITRD)#g'; \
2019
	  echo 's#@''CUSTOM_IALLOCATOR_SEARCH_PATH@#$(IALLOCATOR_SEARCH_PATH)#g'; \
2020
	  echo 's#@''CUSTOM_EXPORT_DIR@#$(EXPORT_DIR)#g'; \
2021
	  echo 's#@''RPL_SSH_INITD_SCRIPT@#$(SSH_INITD_SCRIPT)#g'; \
2022
	  echo 's#@''PKGLIBDIR@#$(libdir)/ganeti#g'; \
2023
	  echo 's#@''GNTMASTERUSER@#$(MASTERD_USER)#g'; \
2024
	  echo 's#@''GNTRAPIUSER@#$(RAPI_USER)#g'; \
2025
	  echo 's#@''GNTCONFDUSER@#$(CONFD_USER)#g'; \
2026
	  echo 's#@''GNTWCONFDUSER@#$(WCONFD_USER)#g'; \
2027
	  echo 's#@''GNTLUXIDUSER@#$(LUXID_USER)#g'; \
2028
	  echo 's#@''GNTNODEDUSER@#$(NODED_USER)#g'; \
2029
	  echo 's#@''GNTMONDUSER@#$(MOND_USER)#g'; \
2030
	  echo 's#@''GNTRAPIGROUP@#$(RAPI_GROUP)#g'; \
2031
	  echo 's#@''GNTADMINGROUP@#$(ADMIN_GROUP)#g'; \
2032
	  echo 's#@''GNTCONFDGROUP@#$(CONFD_GROUP)#g'; \
2033
	  echo 's#@''GNTNODEDGROUP@#$(NODED_GROUP)#g'; \
2034
	  echo 's#@''GNTWCONFDGROUP@#$(CONFD_GROUP)#g'; \
2035
	  echo 's#@''GNTLUXIDGROUP@#$(LUXID_GROUP)#g'; \
2036
	  echo 's#@''GNTMASTERDGROUP@#$(MASTERD_GROUP)#g'; \
2037
	  echo 's#@''GNTMONDGROUP@#$(MOND_GROUP)#g'; \
2038
	  echo 's#@''GNTDAEMONSGROUP@#$(DAEMONS_GROUP)#g'; \
2039
	  echo 's#@''CUSTOM_ENABLE_CONFD@#$(ENABLE_CONFD)#g'; \
2040
	  echo 's#@''CUSTOM_ENABLE_MOND@#$(ENABLE_MOND)#g'; \
2041
	  echo 's#@''MODULES@#$(strip $(lint_python_code))#g'; \
2042
	  echo 's#@''XEN_CONFIG_DIR@#$(XEN_CONFIG_DIR)#g'; \
2043
	  echo; \
2044
	  echo '/^@SHELL_ENV_INIT@$$/ {'; \
2045
	  echo '  r $(SHELL_ENV_INIT)'; \
2046
	  echo '  d'; \
2047
	  echo '}'; \
2048
	} > $@
2049

    
2050
# Using deferred evaluation
2051
daemons/ganeti-%: MODULE = ganeti.server.$(patsubst ganeti-%,%,$(notdir $@))
2052
daemons/ganeti-watcher: MODULE = ganeti.watcher
2053
scripts/%: MODULE = ganeti.client.$(subst -,_,$(notdir $@))
2054
tools/burnin: MODULE = ganeti.tools.burnin
2055
tools/ensure-dirs: MODULE = ganeti.tools.ensure_dirs
2056
tools/node-daemon-setup: MODULE = ganeti.tools.node_daemon_setup
2057
tools/prepare-node-join: MODULE = ganeti.tools.prepare_node_join
2058
tools/node-cleanup: MODULE = ganeti.tools.node_cleanup
2059
$(HS_BUILT_TEST_HELPERS): TESTROLE = $(patsubst test/hs/%,%,$@)
2060

    
2061
$(PYTHON_BOOTSTRAP) $(gnt_scripts) $(gnt_python_sbin_SCRIPTS): Makefile | stamp-directories
2062
	test -n "$(MODULE)" || { echo Missing module; exit 1; }
2063
	set -e; \
2064
	{ echo '#!/usr/bin/python'; \
2065
	  echo '# This file is automatically generated, do not edit!'; \
2066
	  echo "# Edit $(MODULE) instead."; \
2067
	  echo; \
2068
	  echo '"""Bootstrap script for L{$(MODULE)}"""'; \
2069
	  echo; \
2070
	  echo '# pylint: disable=C0103'; \
2071
	  echo '# C0103: Invalid name'; \
2072
	  echo; \
2073
	  echo 'import sys'; \
2074
	  echo 'import $(MODULE) as main'; \
2075
	  echo; \
2076
	  echo '# Temporarily alias commands until bash completion'; \
2077
	  echo '# generator is changed'; \
2078
	  echo 'if hasattr(main, "commands"):'; \
2079
	  echo '  commands = main.commands # pylint: disable=E1101'; \
2080
	  echo 'if hasattr(main, "aliases"):'; \
2081
	  echo '  aliases = main.aliases # pylint: disable=E1101'; \
2082
	  echo; \
2083
	  echo 'if __name__ == "__main__":'; \
2084
	  echo '  sys.exit(main.Main())'; \
2085
	} > $@
2086
	chmod u+x $@
2087

    
2088
$(HS_BUILT_TEST_HELPERS): Makefile
2089
	@test -n "$(TESTROLE)" || { echo Missing TESTROLE; exit 1; }
2090
	set -e; \
2091
	{ echo '#!/bin/sh'; \
2092
	  echo '# This file is automatically generated, do not edit!'; \
2093
	  echo "# Edit Makefile.am instead."; \
2094
	  echo; \
2095
	  echo "HTOOLS=$(TESTROLE) exec ./test/hs/hpc-htools \"\$$@\""; \
2096
	} > $@
2097
	chmod u+x $@
2098

    
2099
stamp-directories: Makefile
2100
	$(MAKE) $(AM_MAKEFLAGS) ganeti
2101
	@mkdir_p@ $(DIRS) $(BUILDTIME_DIR_AUTOCREATE)
2102
	touch $@
2103

    
2104
# We need to create symlinks because "make distcheck" will not install Python
2105
# files when building.
2106
stamp-srclinks: Makefile | stamp-directories
2107
	set -e; \
2108
	for i in $(srclink_files); do \
2109
	  if test ! -f $$i -a -f $(abs_top_srcdir)/$$i; then \
2110
	    $(LN_S) $(abs_top_srcdir)/$$i $$i; \
2111
	  fi; \
2112
	done
2113
	touch $@
2114

    
2115
.PHONY: ganeti
2116
ganeti:
2117
	cd $(top_builddir) && test -h "$@" || { rm -f $@ && $(LN_S) lib $@; }
2118

    
2119
.PHONY: check-dirs
2120
check-dirs: $(GENERATED_FILES)
2121
	@set -e; \
2122
	find . -type d \( -name . -o -name .git -prune -o -print \) | { \
2123
	  error=; \
2124
	  while read dir; do \
2125
	    case "$$dir" in \
2126
	      $(strip $(patsubst %,(./%) ;;,$(DIRCHECK_EXCLUDE) $(DIRS))) \
2127
	      *) error=1; echo "Directory $$dir not listed in Makefile" >&2 ;; \
2128
	    esac; \
2129
	  done; \
2130
	  for dir in $(DIRS); do \
2131
	    if ! test -d "$$dir"; then \
2132
	      echo "Directory $$dir listed in DIRS does not exist" >&2; \
2133
	      error=1; \
2134
	    fi \
2135
	  done; \
2136
	  test -z "$$error"; \
2137
	}
2138

    
2139
.PHONY: check-news
2140
check-news:
2141
	RELEASE=$(PACKAGE_VERSION) $(CHECK_NEWS) < $(top_srcdir)/NEWS
2142

    
2143
.PHONY: check-local
2144
check-local: check-dirs check-news $(GENERATED_FILES)
2145
	$(CHECK_PYTHON_CODE) $(check_python_code)
2146
	PYTHONPATH=. $(CHECK_HEADER) $(check_python_code)
2147
	$(CHECK_VERSION) $(VERSION) $(top_srcdir)/NEWS
2148
	PYTHONPATH=. $(RUN_IN_TEMPDIR) $(CURDIR)/$(CHECK_IMPORTS) . $(standalone_python_modules)
2149
	error= ; \
2150
	if [ "x`echo $(VERSION_SUFFIX)|grep 'alpha'`" == "x" ]; then \
2151
	  expver=$(VERSION_MAJOR).$(VERSION_MINOR); \
2152
	  if test "`head -n 1 $(top_srcdir)/README`" != "Ganeti $$expver"; then \
2153
	    echo "Incorrect version in README, expected $$expver" >&2; \
2154
	    error=1; \
2155
	  fi; \
2156
	  for file in doc/iallocator.rst doc/hooks.rst doc/virtual-cluster.rst \
2157
	      doc/security.rst; do \
2158
	    if test "`sed -ne '4 p' $(top_srcdir)/$$file`" != \
2159
	      "Documents Ganeti version $$expver"; then \
2160
	      echo "Incorrect version in $$file, expected $$expver" >&2; \
2161
	      error=1; \
2162
	    fi; \
2163
	  done; \
2164
	  if ! test -f $(top_srcdir)/doc/design-$$expver.rst; then \
2165
	    echo "File $(top_srcdir)/doc/design-$$expver.rst not found" >&2; \
2166
	    error=1; \
2167
	  fi; \
2168
	  if test "`sed -ne '5 p' $(top_srcdir)/doc/design-draft.rst`" != \
2169
	    ".. Last updated for Ganeti $$expver"; then \
2170
	    echo "doc/design-draft.rst was not updated for version $$expver" >&2; \
2171
	    error=1; \
2172
	  fi; \
2173
	fi; \
2174
	for file in configure.ac $(HS_LIBTEST_SRCS) $(HS_PROG_SRCS); do \
2175
	  if test $$(wc --max-line-length < $(top_srcdir)/$$file) -gt 80; then \
2176
	    echo "Longest line in $$file is longer than 80 characters" >&2; \
2177
	    error=1; \
2178
	  fi; \
2179
	done; \
2180
	test -z "$$error"
2181

    
2182
.PHONY: hs-test-%
2183
hs-test-%: test/hs/htest
2184
	@rm -f htest.tix
2185
	test/hs/htest -t $*
2186

    
2187
.PHONY: hs-tests
2188
hs-tests: test/hs/htest
2189
	@rm -f htest.tix
2190
	./test/hs/htest
2191

    
2192
.PHONY: hs-shell-%
2193
hs-shell-%: test/hs/hpc-htools test/hs/hpc-mon-collector \
2194
            $(HS_BUILT_TEST_HELPERS)
2195
	@rm -f hpc-htools.tix hpc-mon-collector.tix
2196
	HBINARY="./test/hs/hpc-htools" \
2197
	SHELLTESTARGS=$(SHELLTESTARGS) \
2198
	./test/hs/offline-test.sh $*
2199

    
2200
.PHONY: hs-shell
2201
hs-shell: test/hs/hpc-htools test/hs/hpc-mon-collector $(HS_BUILT_TEST_HELPERS)
2202
	@rm -f hpc-htools.tix hpc-mon-collector.tix
2203
	HBINARY="./test/hs/hpc-htools" \
2204
	SHELLTESTARGS=$(SHELLTESTARGS) \
2205
	./test/hs/offline-test.sh
2206

    
2207
.PHONY: hs-check
2208
hs-check: hs-tests hs-shell
2209

    
2210
# E111: indentation is not a multiple of four
2211
# E121: continuation line indentation is not a multiple of four
2212
#       (since our indent level is not 4)
2213
# E125: continuation line does not distinguish itself from next logical line
2214
#       (since our indent level is not 4)
2215
# E123: closing bracket does not match indentation of opening bracket's line
2216
# E127: continuation line over-indented for visual indent
2217
#       (since our indent level is not 4)
2218
# note: do NOT add E128 here; it's a valid style error in most cases!
2219
# I've seen real errors, but also some cases were we indent wrongly
2220
# due to line length; try to rework the cases where it is triggered,
2221
# instead of silencing it
2222
# E261: at least two spaces before inline comment
2223
# E501: line too long (80 characters)
2224
PEP8_IGNORE = E111,E121,E123,E125,E127,E261,E501
2225

    
2226
# For excluding pep8 expects filenames only, not whole paths
2227
PEP8_EXCLUDE = $(subst $(space),$(comma),$(strip $(notdir $(built_python_sources))))
2228

    
2229
# A space-separated list of pylint warnings to completely ignore:
2230
# I0013 = disable warnings for ignoring whole files
2231
LINT_DISABLE = I0013
2232
# Additional pylint options
2233
LINT_OPTS =
2234
# The combined set of pylint options
2235
LINT_OPTS_ALL = $(LINT_OPTS) \
2236
  $(addprefix --disable=,$(LINT_DISABLE))
2237

    
2238
LINT_TARGETS = pylint pylint-qa pylint-test
2239
if HAS_PEP8
2240
LINT_TARGETS += pep8
2241
endif
2242
if HAS_HLINT
2243
LINT_TARGETS += hlint
2244
endif
2245

    
2246
.PHONY: lint
2247
lint: $(LINT_TARGETS)
2248

    
2249
.PHONY: pylint
2250
pylint: $(GENERATED_FILES)
2251
	@test -n "$(PYLINT)" || { echo 'pylint' not found during configure; exit 1; }
2252
	$(PYLINT) $(LINT_OPTS_ALL) $(lint_python_code)
2253

    
2254
.PHONY: pylint-qa
2255
pylint-qa: $(GENERATED_FILES)
2256
	@test -n "$(PYLINT)" || { echo 'pylint' not found during configure; exit 1; }
2257
	cd $(top_srcdir)/qa && \
2258
	  PYTHONPATH=$(abs_top_srcdir) $(PYLINT) $(LINT_OPTS_ALL) \
2259
		--rcfile  ../pylintrc $(patsubst qa/%.py,%,$(qa_scripts))
2260
# FIXME: lint all test code, not just the newly added test support
2261
pylint-test: $(GENERATED_FILES)
2262
	@test -n "$(PYLINT)" || { echo 'pylint' not found during configure; exit 1; }
2263
	cd $(top_srcdir) && \
2264
		PYTHONPATH=.:./test/py $(PYLINT) $(LINT_OPTS_ALL) \
2265
		--rcfile=pylintrc-test  $(python_test_support)
2266

    
2267
.PHONY: pep8
2268
pep8: $(GENERATED_FILES)
2269
	@test -n "$(PEP8)" || { echo 'pep8' not found during configure; exit 1; }
2270
	$(PEP8) --ignore='$(PEP8_IGNORE)' --exclude='$(PEP8_EXCLUDE)' \
2271
	  --repeat $(pep8_python_code)
2272

    
2273
# FIXME: remove ignore "Use void" when GHC 6.x is deprecated
2274
HLINT_EXCLUDES = src/Ganeti/THH.hs test/hs/hpc-htools.hs
2275
.PHONY: hlint
2276
hlint: $(HS_BUILT_SRCS) src/lint-hints.hs
2277
	@test -n "$(HLINT)" || { echo 'hlint' not found during configure; exit 1; }
2278
	@rm -f doc/hs-lint.html
2279
	if tty -s; then C="-c"; else C=""; fi; \
2280
	$(HLINT) --utf8 --report=doc/hs-lint.html --cross $$C \
2281
	  --ignore "Use first" \
2282
	  --ignore "Use &&&" \
2283
	  --ignore "Use void" \
2284
	  --ignore "Reduce duplication" \
2285
	  --hint src/lint-hints \
2286
	  $(filter-out $(HLINT_EXCLUDES),$(HS_LIBTEST_SRCS) $(HS_PROG_SRCS))
2287
	@if [ ! -f doc/hs-lint.html ]; then \
2288
	  echo "All good" > doc/hs-lint.html; \
2289
	fi
2290

    
2291
# a dist hook rule for updating the vcs-version file; this is
2292
# hardcoded due to where it needs to build the file...
2293
dist-hook:
2294
	$(MAKE) $(AM_MAKEFLAGS) regen-vcs-version
2295
	rm -f $(top_distdir)/vcs-version
2296
	cp -p $(srcdir)/vcs-version $(top_distdir)
2297

    
2298
# a distcheck hook rule for catching revision control directories
2299
distcheck-hook:
2300
	if find $(top_distdir) -name .svn -or -name .git | grep .; then \
2301
	  echo "Found revision control files in final archive." 1>&2; \
2302
	  exit 1; \
2303
	fi
2304
	if find $(top_distdir) -name '*.py[co]' | grep .; then \
2305
	  echo "Found Python byte code in final archive." 1>&2; \
2306
	  exit 1; \
2307
	fi
2308
	if find $(top_distdir) -name '*~' | grep .; then \
2309
	  echo "Found backup files in final archive." 1>&2; \
2310
	  exit 1; \
2311
	fi
2312
# Empty files or directories should not be distributed. They can cause
2313
# unnecessary warnings for packagers. Directories used by automake during
2314
# distcheck must be excluded.
2315
	if find $(top_distdir) -empty -and -not \( \
2316
	    -path $(top_distdir)/_build -or \
2317
	    -path $(top_distdir)/_inst \) | grep .; then \
2318
	  echo "Found empty files or directories in final archive." 1>&2; \
2319
	  exit 1; \
2320
	fi
2321
	if test -e $(top_distdir)/doc/man-html; then \
2322
	  echo "Found documentation including man pages in final archive" >&2; \
2323
	  exit 1; \
2324
	fi
2325

    
2326
# Backwards compatible distcheck-release target
2327
distcheck-release: distcheck
2328

    
2329
distrebuildcheck: dist
2330
	set -e; \
2331
	builddir=$$(mktemp -d $(abs_srcdir)/distrebuildcheck.XXXXXXX); \
2332
	trap "echo Removing $$builddir; cd $(abs_srcdir); rm -rf $$builddir" EXIT; \
2333
	cd $$builddir; \
2334
	tar xzf $(abs_srcdir)/$(distdir).tar.gz; \
2335
	cd $(distdir); \
2336
	./configure; \
2337
	$(MAKE) maintainer-clean; \
2338
	cp $(abs_srcdir)/vcs-version .; \
2339
	./configure; \
2340
	$(MAKE) $(AM_MAKEFLAGS)
2341

    
2342
dist-release: dist
2343
	set -e; \
2344
	for i in $(DIST_ARCHIVES); do \
2345
	  echo -n "Checking $$i ... "; \
2346
	  autotools/check-tar < $$i; \
2347
	  echo OK; \
2348
	done
2349

    
2350
install-exec-local:
2351
	@mkdir_p@ "$(DESTDIR)${localstatedir}/lib/ganeti" \
2352
	  "$(DESTDIR)${localstatedir}/log/ganeti" \
2353
	  "$(DESTDIR)${localstatedir}/run/ganeti"
2354
	for dir in $(SYMLINK_TARGET_DIRS); do \
2355
	  @mkdir_p@  $(DESTDIR)$$dir; \
2356
	done
2357
	$(LN_S) -f $(sysconfdir)/ganeti/lib $(DESTDIR)$(defaultversiondir)
2358
	$(LN_S) -f $(sysconfdir)/ganeti/share $(DESTDIR)$(defaultversionedsharedir)
2359
	for prog in $(HS_BIN_ROLES); do \
2360
	  $(LN_S) -f $(defaultversiondir)$(BINDIR)/$$prog $(DESTDIR)$(BINDIR)/$$prog; \
2361
	done
2362
	$(LN_S) -f $(defaultversiondir)$(libdir)/ganeti/iallocators/hail $(DESTDIR)$(libdir)/ganeti/iallocators/hail
2363
	for prog in $(all_sbin_scripts); do \
2364
	  $(LN_S) -f $(defaultversiondir)$(SBINDIR)/$$prog $(DESTDIR)$(SBINDIR)/$$prog; \
2365
	done
2366
	for prog in $(gnt_scripts_basenames); do \
2367
	  $(LN_S) -f $(defaultversionedsharedir)/$$prog $(DESTDIR)$(SBINDIR)/$$prog; \
2368
	done
2369
	for prog in $(pkglib_python_basenames); do \
2370
	  $(LN_S) -f $(defaultversionedsharedir)/$$prog $(DESTDIR)$(libdir)/ganeti/$$prog; \
2371
	done
2372
	for prog in $(tools_python_basenames); do \
2373
	  $(LN_S) -f $(defaultversionedsharedir)/$$prog $(DESTDIR)$(libdir)/ganeti/tools/$$prog; \
2374
	done
2375
	for prog in $(tools_basenames); do \
2376
	  $(LN_S) -f $(defaultversiondir)/$(libdir)/ganeti/tools/$$prog $(DESTDIR)$(libdir)/ganeti/tools/$$prog; \
2377
	done
2378
	if ! test -n '$(ENABLE_MANPAGES)'; then \
2379
	  for man in $(manfullpath); do \
2380
	    $(LN_S) -f $(defaultversionedsharedir)/root$(MANDIR)/$$man $(DESTDIR)$(MANDIR)/$$man; \
2381
	  done; \
2382
	fi
2383
	for prog in $(myexeclib_scripts_basenames); do \
2384
	  $(LN_S) -f $(defaultversiondir)$(libdir)/ganeti/$$prog $(DESTDIR)$(libdir)/ganeti/$$prog; \
2385
	done
2386
if INSTALL_SYMLINKS
2387
	$(LN_S) -f $(versionedsharedir) $(DESTDIR)$(sysconfdir)/ganeti/share
2388
	$(LN_S) -f $(versiondir) $(DESTDIR)$(sysconfdir)/ganeti/lib
2389
endif
2390

    
2391
.PHONY: apidoc
2392
if WANT_HSAPIDOC
2393
apidoc: py-apidoc hs-apidoc
2394
else
2395
apidoc: py-apidoc
2396
endif
2397

    
2398
.PHONY: py-apidoc
2399
py-apidoc: epydoc.conf $(RUN_IN_TEMPDIR) $(GENERATED_FILES)
2400
	env - PATH="$$PATH" PYTHONPATH="$$PYTHONPATH" \
2401
	$(RUN_IN_TEMPDIR) epydoc -v \
2402
	  --conf $(CURDIR)/epydoc.conf \
2403
	  --output $(CURDIR)/$(APIDOC_PY_DIR)
2404

    
2405
.PHONY: hs-apidoc
2406
hs-apidoc: $(APIDOC_HS_DIR)/index.html
2407

    
2408
$(APIDOC_HS_DIR)/index.html: $(HS_LIBTESTBUILT_SRCS) Makefile
2409
	@test -n "$(HSCOLOUR)" || \
2410
	    { echo 'HsColour' not found during configure; exit 1; }
2411
	@test -n "$(HADDOCK)" || \
2412
	    { echo 'haddock' not found during configure; exit 1; }
2413
	rm -rf $(APIDOC_HS_DIR)/*
2414
	for i in $(ALL_APIDOC_HS_DIRS); do \
2415
	  @mkdir_p@ $$i; \
2416
	  $(HSCOLOUR) -print-css > $$i/hscolour.css; \
2417
	done
2418
	set -e ; \
2419
	export LC_ALL=en_US.UTF-8; \
2420
	OPTGHC="--optghc=-isrc --optghc=-itest/hs"; \
2421
	if [ "$(HS_PARALLEL3)" ]; \
2422
	then OPTGHC="$$OPTGHC --optghc=$(HS_PARALLEL3)"; \
2423
	fi; \
2424
	if [ "$(HS_REGEX_PCRE)" ]; \
2425
	then OPTGHC="$$OPTGHC --optghc=$(HS_REGEX_PCRE)"; \
2426
	fi; \
2427
	for file in $(HS_LIBTESTBUILT_SRCS); do \
2428
	  f_nosrc=$${file##src/}; \
2429
	  f_notst=$${f_nosrc##test/hs/}; \
2430
	  f_html=$${f_notst%%.hs}.html; \
2431
	  $(HSCOLOUR) -css -anchor $$file > $(APIDOC_HS_DIR)/$$f_html ; \
2432
	done ; \
2433
	$(HADDOCK) --odir $(APIDOC_HS_DIR) --html --hoogle --ignore-all-exports -w \
2434
	  -t ganeti -p src/haddock-prologue \
2435
	  --source-module="%{MODULE/.//}.html" \
2436
	  --source-entity="%{MODULE/.//}.html#%{NAME}" \
2437
	  $$OPTGHC \
2438
	  $(HS_LIBTESTBUILT_SRCS)
2439

    
2440
.PHONY: TAGS
2441
TAGS: $(GENERATED_FILES)
2442
	rm -f TAGS
2443
	$(GHC) -e ":etags TAGS_hs" -v0 \
2444
	  $(filter-out -O -Werror,$(HFLAGS)) \
2445
		-osuf tags.o \
2446
		-hisuf tags.hi \
2447
    -lcurl \
2448
	  $(HS_PARALLEL3) $(HS_REGEX_PCRE) \
2449
	  $(HS_LIBTEST_SRCS)
2450
	find . -path './lib/*.py' -o -path './scripts/gnt-*' -o \
2451
	  -path './daemons/ganeti-*' -o -path './tools/*' -o \
2452
	  -path './qa/*.py' | \
2453
	  etags --etags-include=TAGS_hs -L -
2454

    
2455
.PHONY: coverage
2456

    
2457
COVERAGE_TESTS=
2458
if HS_UNIT
2459
COVERAGE_TESTS += hs-coverage
2460
endif
2461
if PY_UNIT
2462
COVERAGE_TESTS += py-coverage
2463
endif
2464

    
2465
coverage: $(COVERAGE_TESTS)
2466

    
2467
test/py/docs_unittest.py: $(gnt_scripts)
2468

    
2469
.PHONY: py-coverage
2470
py-coverage: $(GENERATED_FILES) $(python_tests)
2471
	@test -n "$(PYCOVERAGE)" || \
2472
	    { echo 'python-coverage' not found during configure; exit 1; }
2473
	set -e; \
2474
	COVERAGE=$(PYCOVERAGE) \
2475
	COVERAGE_FILE=$(CURDIR)/$(COVERAGE_PY_DIR)/data \
2476
	TEXT_COVERAGE=$(CURDIR)/$(COVERAGE_PY_DIR)/report.txt \
2477
	HTML_COVERAGE=$(CURDIR)/$(COVERAGE_PY_DIR) \
2478
	$(PLAIN_TESTS_ENVIRONMENT) \
2479
	$(abs_top_srcdir)/autotools/gen-py-coverage \
2480
	$(python_tests)
2481

    
2482
.PHONY: hs-coverage
2483
hs-coverage: $(haskell_tests) test/hs/hpc-htools test/hs/hpc-mon-collector
2484
	rm -f *.tix
2485
	$(MAKE) $(AM_MAKEFLAGS) hs-check
2486
	@mkdir_p@ $(COVERAGE_HS_DIR)
2487
	hpc sum --union $(HPCEXCL) \
2488
	  htest.tix hpc-htools.tix hpc-mon-collector.tix > coverage-hs.tix
2489
	hpc markup --destdir=$(COVERAGE_HS_DIR) coverage-hs.tix
2490
	hpc report coverage-hs.tix | tee $(COVERAGE_HS_DIR)/report.txt
2491
	$(LN_S) -f hpc_index.html $(COVERAGE_HS_DIR)/index.html
2492

    
2493
# Special "kind-of-QA" target for htools, needs special setup (all
2494
# tools compiled with -fhpc)
2495
.PHONY: live-test
2496
live-test: all
2497
	set -e ; \
2498
	cd src; \
2499
	rm -f .hpc; $(LN_S) ../.hpc .hpc; \
2500
	rm -f *.tix *.mix; \
2501
	./live-test.sh; \
2502
	hpc sum --union $(HPCEXCL) $(addsuffix .tix,$(HS_PROGS:src/%=%)) \
2503
	  --output=live-test.tix ; \
2504
	@mkdir_p@ ../$(COVERAGE_HS_DIR) ; \
2505
	hpc markup --destdir=../$(COVERAGE_HS_DIR) live-test \
2506
	  --srcdir=.. $(HPCEXCL) ; \
2507
	hpc report --srcdir=.. live-test $(HPCEXCL)
2508

    
2509
commit-check: autotools-check distcheck lint apidoc
2510

    
2511
autotools-check:
2512
	TESTDATA_DIR=./test/data shelltest $(SHELLTESTARGS) \
2513
  $(abs_top_srcdir)/test/autotools/*-*.test \
2514
  -- --hide-successes
2515

    
2516
.PHONY: gitignore-check
2517
gitignore-check:
2518
	@if [ -n "`git status --short`" ]; then \
2519
	  echo "Git status is not clean!" 1>&2 ; \
2520
	  git status --short; \
2521
	  exit 1; \
2522
	fi
2523

    
2524
# target to rebuild all man pages (both groff and html output)
2525
.PHONY: man
2526
man: $(man_MANS) $(manhtml)
2527

    
2528
# Target that builds all binaries (including those that are not
2529
# rebuilt except when running the tests)
2530
.PHONY: really-all
2531
really-all: all $(check_SCRIPTS) $(haskell_tests) $(HS_ALL_PROGS)
2532

    
2533
# we don't need the ancient implicit rules:
2534
%: %,v
2535
%: RCS/%,v
2536
%: RCS/%
2537
%: s.%
2538
%: SCCS/s.%
2539

    
2540
-include ./Makefile.local
2541

    
2542
# vim: set noet :