Statistics
| Branch: | Tag: | Revision:

root / Makefile.am @ 72375ff8

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/Locking/Allocation.hs \
766
	src/Ganeti/Locking/Types.hs \
767
	src/Ganeti/Locking/Locks.hs \
768
	src/Ganeti/Logging.hs \
769
	src/Ganeti/Logging/Lifted.hs \
770
	src/Ganeti/Luxi.hs \
771
	src/Ganeti/Monitoring/Server.hs \
772
	src/Ganeti/Metad.hs \
773
	src/Ganeti/Network.hs \
774
	src/Ganeti/Objects.hs \
775
	src/Ganeti/OpCodes.hs \
776
	src/Ganeti/OpParams.hs \
777
	src/Ganeti/Path.hs \
778
	src/Ganeti/Parsers.hs \
779
	src/Ganeti/PyValue.hs \
780
	src/Ganeti/Query/Cluster.hs \
781
	src/Ganeti/Query/Common.hs \
782
	src/Ganeti/Query/Export.hs \
783
	src/Ganeti/Query/Filter.hs \
784
	src/Ganeti/Query/Group.hs \
785
	src/Ganeti/Query/Instance.hs \
786
	src/Ganeti/Query/Job.hs \
787
	src/Ganeti/Query/Language.hs \
788
	src/Ganeti/Query/Locks.hs \
789
	src/Ganeti/Query/Network.hs \
790
	src/Ganeti/Query/Node.hs \
791
	src/Ganeti/Query/Query.hs \
792
	src/Ganeti/Query/Server.hs \
793
	src/Ganeti/Query/Types.hs \
794
	src/Ganeti/Rpc.hs \
795
	src/Ganeti/Runtime.hs \
796
	src/Ganeti/Ssconf.hs \
797
	src/Ganeti/Storage/Diskstats/Parser.hs \
798
	src/Ganeti/Storage/Diskstats/Types.hs \
799
	src/Ganeti/Storage/Drbd/Parser.hs \
800
	src/Ganeti/Storage/Drbd/Types.hs \
801
	src/Ganeti/Storage/Lvm/LVParser.hs \
802
	src/Ganeti/Storage/Lvm/Types.hs \
803
	src/Ganeti/Storage/Utils.hs \
804
	src/Ganeti/THH.hs \
805
	src/Ganeti/THH/Field.hs \
806
	src/Ganeti/THH/PyRPC.hs \
807
	src/Ganeti/THH/PyType.hs \
808
	src/Ganeti/THH/Types.hs \
809
	src/Ganeti/THH/RPC.hs \
810
	src/Ganeti/Types.hs \
811
	src/Ganeti/UDSServer.hs \
812
	src/Ganeti/Utils.hs \
813
	src/Ganeti/Utils/Atomic.hs \
814
	src/Ganeti/Utils/AsyncWorker.hs \
815
	src/Ganeti/VCluster.hs \
816
	src/Ganeti/WConfd/ConfigState.hs \
817
	src/Ganeti/WConfd/ConfigWriter.hs \
818
	src/Ganeti/WConfd/Core.hs \
819
	src/Ganeti/WConfd/DeathDetection.hs \
820
	src/Ganeti/WConfd/Language.hs \
821
	src/Ganeti/WConfd/Monad.hs \
822
	src/Ganeti/WConfd/Server.hs
823

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

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

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

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

    
895
$(RUN_IN_TEMPDIR): | stamp-directories
896

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

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

    
938
doc/html: doc/html/index.html
939

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

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

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

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

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

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

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

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

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

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

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

    
1022
gnt_python_sbin_SCRIPTS = \
1023
	$(PYTHON_BOOTSTRAP_SBIN)
1024

    
1025
gntpython_SCRIPTS = $(gnt_scripts)
1026

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

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

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

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

    
1071
HS_SRCS = $(HS_LIBTESTBUILT_SRCS)
1072

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

    
1082
@include_makefile_ghc@
1083

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

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

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

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

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

    
1115
dist_sbin_SCRIPTS = \
1116
	tools/ganeti-listrunner
1117

    
1118
nodist_sbin_SCRIPTS = \
1119
	daemons/ganeti-cleaner
1120

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

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

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

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

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

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

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

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

    
1166
nodist_tools_python_SCRIPTS = \
1167
	tools/node-cleanup
1168

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
1471

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

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

    
1588
haskell_tests = test/hs/htest
1589

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

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

    
1602
nodist_TESTS =
1603
check_SCRIPTS =
1604

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
2452
.PHONY: coverage
2453

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

    
2462
coverage: $(COVERAGE_TESTS)
2463

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

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

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

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

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

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

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

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

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

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

    
2537
-include ./Makefile.local
2538

    
2539
# vim: set noet :