Statistics
| Branch: | Tag: | Revision:

root / Makefile.am @ ba40281b

History | View | Annotate | Download (75.7 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/Query \
133
	src/Ganeti/Storage \
134
	src/Ganeti/Storage/Diskstats \
135
	src/Ganeti/Storage/Drbd \
136
	src/Ganeti/Storage/Lvm \
137
	src/Ganeti/THH \
138
	src/Ganeti/Utils \
139
	src/Ganeti/WConfd \
140
	test/hs \
141
	test/hs/Test \
142
	test/hs/Test/Ganeti \
143
	test/hs/Test/Ganeti/Storage \
144
	test/hs/Test/Ganeti/Storage/Diskstats \
145
	test/hs/Test/Ganeti/Storage/Drbd \
146
	test/hs/Test/Ganeti/Storage/Lvm \
147
	test/hs/Test/Ganeti/Confd \
148
	test/hs/Test/Ganeti/HTools \
149
	test/hs/Test/Ganeti/HTools/Backend \
150
	test/hs/Test/Ganeti/Hypervisor \
151
	test/hs/Test/Ganeti/Hypervisor/Xen \
152
	test/hs/Test/Ganeti/Locking \
153
	test/hs/Test/Ganeti/Query \
154
	test/hs/Test/Ganeti/THH
155

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
347
nodist_pkgpython_bin_SCRIPTS = \
348
	$(nodist_pkglib_python_scripts)
349

    
350
pkgpython_bin_SCRIPTS = \
351
	$(pkglib_python_scripts)
352

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
676
HTEST_SUFFIX = hpc
677

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

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

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

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

    
879
HS_LIBTEST_SRCS = $(HS_LIB_SRCS) $(HS_TEST_SRCS)
880

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

    
894
HS_LIBTESTBUILT_SRCS = $(HS_LIBTEST_SRCS) $(HS_BUILT_SRCS)
895

    
896
$(RUN_IN_TEMPDIR): | stamp-directories
897

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

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

    
939
doc/html: doc/html/index.html
940

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

    
943
doc/install-quick.rst: INSTALL
944
doc/news.rst: NEWS
945
doc/upgrade.rst: UPGRADE
946

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

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

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

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

    
986
userspecs = \
987
	doc/users/users \
988
	doc/users/groups \
989
	doc/users/groupmemberships
990

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

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

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

    
1020
gnt_scripts_basenames = \
1021
	$(patsubst scripts/%,%,$(patsubst daemons/%,%,$(gnt_scripts) $(gnt_python_sbin_SCRIPTS)))
1022

    
1023
gnt_python_sbin_SCRIPTS = \
1024
	$(PYTHON_BOOTSTRAP_SBIN)
1025

    
1026
gntpython_SCRIPTS = $(gnt_scripts)
1027

    
1028
PYTHON_BOOTSTRAP_SBIN = \
1029
	daemons/ganeti-masterd \
1030
	daemons/ganeti-noded \
1031
	daemons/ganeti-rapi \
1032
	daemons/ganeti-watcher
1033

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

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

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

    
1072
HS_SRCS = $(HS_LIBTESTBUILT_SRCS)
1073

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

    
1083
@include_makefile_ghc@
1084

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

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

    
1095
%.hi: %.o ;
1096
%.$(HTEST_SUFFIX)_hi: %.$(HTEST_SUFFIX)_o ;
1097

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

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

    
1116
dist_sbin_SCRIPTS = \
1117
	tools/ganeti-listrunner
1118

    
1119
nodist_sbin_SCRIPTS = \
1120
	daemons/ganeti-cleaner
1121

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

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

    
1131
src/ganeti-luxid: src/hluxid
1132
	cp -f $< $@
1133

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

    
1141
if ENABLE_MOND
1142
nodist_sbin_SCRIPTS += src/ganeti-mond
1143
endif
1144

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

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

    
1163
dist_tools_python_SCRIPTS = \
1164
	$(python_scripts) \
1165
	tools/burnin
1166

    
1167
nodist_tools_python_SCRIPTS = \
1168
	tools/node-cleanup
1169

    
1170
tools_python_basenames = $(patsubst tools/%,%,\
1171
	$(dist_tools_python_SCRIPTS) $(nodist_tools_python_SCRIPTS))
1172

    
1173
nodist_tools_SCRIPTS = \
1174
	tools/users-setup \
1175
	tools/vcluster-setup
1176

    
1177
tools_basenames = $(patsubst tools/%,%,$(nodist_tools_SCRIPTS) $(dist_tools_SCRIPTS))
1178

    
1179
pkglib_python_scripts = \
1180
	daemons/import-export \
1181
	tools/check-cert-expired
1182

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

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

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

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

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

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

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

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

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

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

    
1472

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

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

    
1589
haskell_tests = test/hs/htest
1590

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

    
1599
if PY_UNIT
1600
dist_TESTS += $(python_tests)
1601
endif
1602

    
1603
nodist_TESTS =
1604
check_SCRIPTS =
1605

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

    
1617
TESTS = $(dist_TESTS) $(nodist_TESTS)
1618

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

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

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

    
1655
if PY_UNIT
1656
all_python_code += $(python_tests)
1657
all_python_code += $(python_test_support)
1658
endif
1659

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

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

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

    
1694
standalone_python_modules = \
1695
	lib/rapi/client.py \
1696
	tools/ganeti-listrunner
1697

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

    
1712
test/py/daemon-util_unittest.bash: daemons/daemon-util
1713

    
1714
test/py/ganeti-cleaner_unittest.bash: daemons/ganeti-cleaner
1715

    
1716
test/py/bash_completion.bash: doc/examples/bash_completion-debug
1717

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

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

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

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

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

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

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

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

    
1767
doc/examples/bash_completion: BC_ARGS = --compact
1768
doc/examples/bash_completion-debug: BC_ARGS =
1769

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

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

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

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

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

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

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

    
1823
.PHONY: clean-vcs-version
1824
clean-vcs-version:
1825
	rm -f vcs-version
1826

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

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

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

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

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

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

    
1880
lib/constants.py: lib/_constants.py
1881

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
2205
.PHONY: hs-check
2206
hs-check: hs-tests hs-shell
2207

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

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

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

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

    
2244
.PHONY: lint
2245
lint: $(LINT_TARGETS)
2246

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

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

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

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

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

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

    
2324
# Backwards compatible distcheck-release target
2325
distcheck-release: distcheck
2326

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

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

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

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

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

    
2403
.PHONY: hs-apidoc
2404
hs-apidoc: $(APIDOC_HS_DIR)/index.html
2405

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

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

    
2453
.PHONY: coverage
2454

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

    
2463
coverage: $(COVERAGE_TESTS)
2464

    
2465
test/py/docs_unittest.py: $(gnt_scripts)
2466

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

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

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

    
2507
commit-check: autotools-check distcheck lint apidoc
2508

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

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

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

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

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

    
2538
-include ./Makefile.local
2539

    
2540
# vim: set noet :