Statistics
| Branch: | Tag: | Revision:

root / Makefile.am @ 62f1e053

History | View | Annotate | Download (75.6 kB)

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

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

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

    
17
# Helper function to strip src/ and test/hs/ from a list
18
strip_hsroot = $(patsubst src/%,%,$(patsubst test/hs/%,%,$(1)))
19

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

    
23
# 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/log.py \
513
	lib/utils/lvm.py \
514
	lib/utils/mlock.py \
515
	lib/utils/nodesetup.py \
516
	lib/utils/process.py \
517
	lib/utils/retry.py \
518
	lib/utils/security.py \
519
	lib/utils/storage.py \
520
	lib/utils/text.py \
521
	lib/utils/version.py \
522
	lib/utils/wrapper.py \
523
	lib/utils/x509.py
524

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

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

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

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

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

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

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

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

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

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

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

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

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

    
675
HTEST_SUFFIX = hpc
676

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

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

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

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

    
875
HS_LIBTEST_SRCS = $(HS_LIB_SRCS) $(HS_TEST_SRCS)
876

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

    
890
HS_LIBTESTBUILT_SRCS = $(HS_LIBTEST_SRCS) $(HS_BUILT_SRCS)
891

    
892
$(RUN_IN_TEMPDIR): | stamp-directories
893

    
894
doc/html/index.html: ENABLE_MANPAGES =
895
doc/man-html/index.html: ENABLE_MANPAGES = 1
896
doc/man-html/index.html: doc/manpages-enabled.rst $(mandocrst)
897

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

    
935
doc/html: doc/html/index.html
936

    
937
doc/man-html: doc/man-html/index.html
938

    
939
doc/install-quick.rst: INSTALL
940
doc/news.rst: NEWS
941
doc/upgrade.rst: UPGRADE
942

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

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

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

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

    
982
userspecs = \
983
	doc/users/users \
984
	doc/users/groups \
985
	doc/users/groupmemberships
986

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

    
996
if HAS_SPHINX
997
if MANPAGES_IN_DOC
998
noinst_DATA += doc/man-html
999
else
1000
noinst_DATA += doc/html
1001
endif
1002
endif
1003

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

    
1016
gnt_scripts_basenames = \
1017
	$(patsubst scripts/%,%,$(patsubst daemons/%,%,$(gnt_scripts) $(gnt_python_sbin_SCRIPTS)))
1018

    
1019
gnt_python_sbin_SCRIPTS = \
1020
	$(PYTHON_BOOTSTRAP_SBIN)
1021

    
1022
gntpython_SCRIPTS = $(gnt_scripts)
1023

    
1024
PYTHON_BOOTSTRAP_SBIN = \
1025
	daemons/ganeti-masterd \
1026
	daemons/ganeti-noded \
1027
	daemons/ganeti-rapi \
1028
	daemons/ganeti-watcher
1029

    
1030
PYTHON_BOOTSTRAP = \
1031
	tools/burnin \
1032
	tools/ensure-dirs \
1033
	tools/node-cleanup \
1034
	tools/node-daemon-setup \
1035
	tools/prepare-node-join
1036

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

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

    
1067
HS_SRCS = $(HS_LIBTESTBUILT_SRCS)
1068

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

    
1078
@include_makefile_ghc@
1079

    
1080
%.o:
1081
	@echo '[GHC]: $@ <- $^'
1082
	@$(GHC) -c $(HFLAGS) \
1083
		$(HS_PARALLEL3) $(HS_REGEX_PCRE) $(HEXTRA) $(@:%.o=%.hs)
1084

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

    
1090
%.hi: %.o ;
1091
%.$(HTEST_SUFFIX)_hi: %.$(HTEST_SUFFIX)_o ;
1092

    
1093
$(HS_SRC_PROGS): %: %.o | stamp-directories
1094
	$(GHC) $(HFLAGS) \
1095
		$(HS_PARALLEL3) $(HS_REGEX_PCRE) $(HEXTRA) --make $(@:%=%.hs)
1096
	@rm -f $(notdir $@).tix
1097
	@touch "$@"
1098

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

    
1111
dist_sbin_SCRIPTS = \
1112
	tools/ganeti-listrunner
1113

    
1114
nodist_sbin_SCRIPTS = \
1115
	daemons/ganeti-cleaner
1116

    
1117
# strip path prefixes off the sbin scripts
1118
all_sbin_scripts = \
1119
	$(patsubst tools/%,%,$(patsubst daemons/%,%,$(patsubst scripts/%,%,\
1120
	$(patsubst src/%,%,$(dist_sbin_SCRIPTS) $(nodist_sbin_SCRIPTS)))))
1121

    
1122
if ENABLE_CONFD
1123
src/ganeti-confd: src/hconfd
1124
	cp -f $< $@
1125

    
1126
src/ganeti-luxid: src/hluxid
1127
	cp -f $< $@
1128

    
1129
nodist_sbin_SCRIPTS += src/ganeti-confd
1130
nodist_sbin_SCRIPTS += src/ganeti-wconfd
1131
nodist_sbin_SCRIPTS += src/ganeti-luxid
1132
nodist_sbin_SCRIPTS += src/ganeti-kvmd
1133
nodist_sbin_SCRIPTS += src/ganeti-metad
1134
endif
1135

    
1136
if ENABLE_MOND
1137
nodist_sbin_SCRIPTS += src/ganeti-mond
1138
endif
1139

    
1140
python_scripts = \
1141
	tools/cfgshell \
1142
	tools/cfgupgrade \
1143
	tools/cfgupgrade12 \
1144
	tools/cluster-merge \
1145
	tools/confd-client \
1146
	tools/fmtjson \
1147
	tools/lvmstrap \
1148
	tools/move-instance \
1149
	tools/ovfconverter \
1150
	tools/post-upgrade \
1151
	tools/sanitize-config
1152

    
1153
dist_tools_SCRIPTS = \
1154
	tools/kvm-console-wrapper \
1155
	tools/master-ip-setup \
1156
	tools/xen-console-wrapper
1157

    
1158
dist_tools_python_SCRIPTS = \
1159
	$(python_scripts) \
1160
	tools/burnin
1161

    
1162
nodist_tools_python_SCRIPTS = \
1163
	tools/node-cleanup
1164

    
1165
tools_python_basenames = $(patsubst tools/%,%,\
1166
	$(dist_tools_python_SCRIPTS) $(nodist_tools_python_SCRIPTS))
1167

    
1168
nodist_tools_SCRIPTS = \
1169
	tools/users-setup \
1170
	tools/vcluster-setup
1171

    
1172
tools_basenames = $(patsubst tools/%,%,$(nodist_tools_SCRIPTS) $(dist_tools_SCRIPTS))
1173

    
1174
pkglib_python_scripts = \
1175
	daemons/import-export \
1176
	tools/check-cert-expired
1177

    
1178
nodist_pkglib_python_scripts = \
1179
	tools/ensure-dirs \
1180
	tools/node-daemon-setup \
1181
	tools/prepare-node-join
1182

    
1183
pkglib_python_basenames = \
1184
	$(patsubst daemons/%,%,$(patsubst tools/%,%,\
1185
	$(pkglib_python_scripts) $(nodist_pkglib_python_scripts)))
1186

    
1187
myexeclib_SCRIPTS = \
1188
	daemons/daemon-util \
1189
	tools/kvm-ifup \
1190
	tools/kvm-ifup-os \
1191
	tools/vif-ganeti \
1192
	tools/net-common \
1193
	$(HS_MYEXECLIB_PROGS)
1194

    
1195
# compute the basenames of the myexeclib_scripts
1196
myexeclib_scripts_basenames = \
1197
	$(patsubst tools/%,%,$(patsubst daemons/%,%,$(patsubst src/%,%,$(myexeclib_SCRIPTS))))
1198

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

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

    
1296
# Remove extensions from all filenames in man_MANS
1297
mannoext = $(patsubst %.1,%,$(patsubst %.7,%,$(patsubst %.8,%,$(man_MANS))))
1298

    
1299
manrst = $(patsubst %,%.rst,$(mannoext))
1300
manhtml = $(patsubst %.rst,%.html,$(manrst))
1301
mangen = $(patsubst %.rst,%.gen,$(manrst))
1302
maninput = \
1303
	$(patsubst %.1,%.1.in,$(patsubst %.7,%.7.in,$(patsubst %.8,%.8.in,$(man_MANS)))) \
1304
	$(patsubst %.html,%.html.in,$(manhtml)) \
1305
	$(mangen)
1306

    
1307
manfullpath = $(patsubst man/%.1,man1/%.1,\
1308
	$(patsubst man/%.7,man7/%.7,\
1309
	$(patsubst man/%.8,man8/%.8,$(man_MANS))))
1310

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

    
1467

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

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

    
1584
haskell_tests = test/hs/htest
1585

    
1586
dist_TESTS = \
1587
	test/py/check-cert-expired_unittest.bash \
1588
	test/py/daemon-util_unittest.bash \
1589
	test/py/ganeti-cleaner_unittest.bash \
1590
	test/py/import-export_unittest.bash \
1591
	test/py/cli-test.bash \
1592
	test/py/bash_completion.bash
1593

    
1594
if PY_UNIT
1595
dist_TESTS += $(python_tests)
1596
endif
1597

    
1598
nodist_TESTS =
1599
check_SCRIPTS =
1600

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

    
1612
TESTS = $(dist_TESTS) $(nodist_TESTS)
1613

    
1614
# Environment for all tests
1615
PLAIN_TESTS_ENVIRONMENT = \
1616
	PYTHONPATH=.:./test/py \
1617
	TOP_SRCDIR=$(abs_top_srcdir) TOP_BUILDDIR=$(abs_top_builddir) \
1618
	PYTHON=$(PYTHON) FAKEROOT=$(FAKEROOT_PATH) \
1619
	$(RUN_IN_TEMPDIR)
1620

    
1621
# Environment for tests run by automake
1622
TESTS_ENVIRONMENT = \
1623
	$(PLAIN_TESTS_ENVIRONMENT) $(abs_top_srcdir)/autotools/testrunner
1624

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

    
1650
if PY_UNIT
1651
all_python_code += $(python_tests)
1652
all_python_code += $(python_test_support)
1653
endif
1654

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

    
1669
check_python_code = \
1670
	$(BUILD_BASH_COMPLETION) \
1671
	$(CHECK_IMPORTS) \
1672
	$(CHECK_HEADER) \
1673
	$(DOCPP) \
1674
	$(all_python_code)
1675

    
1676
lint_python_code = \
1677
	ganeti \
1678
	ganeti/http/server.py \
1679
	$(dist_sbin_SCRIPTS) \
1680
	$(python_scripts) \
1681
	$(pkglib_python_scripts) \
1682
	$(BUILD_BASH_COMPLETION) \
1683
	$(CHECK_IMPORTS) \
1684
	$(CHECK_HEADER) \
1685
	$(DOCPP) \
1686
	$(gnt_python_sbin_SCRIPTS) \
1687
	$(PYTHON_BOOTSTRAP)
1688

    
1689
standalone_python_modules = \
1690
	lib/rapi/client.py \
1691
	tools/ganeti-listrunner
1692

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

    
1707
test/py/daemon-util_unittest.bash: daemons/daemon-util
1708

    
1709
test/py/ganeti-cleaner_unittest.bash: daemons/ganeti-cleaner
1710

    
1711
test/py/bash_completion.bash: doc/examples/bash_completion-debug
1712

    
1713
tools/kvm-ifup: tools/kvm-ifup.in $(REPLACE_VARS_SED)
1714
	sed -f $(REPLACE_VARS_SED) < $< > $@
1715
	chmod +x $@
1716

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

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

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

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

    
1751
tools/vcluster-setup: tools/vcluster-setup.in $(REPLACE_VARS_SED)
1752
	sed -f $(REPLACE_VARS_SED) < $< > $@
1753
	chmod +x $@
1754

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

    
1759
doc/examples/%:: doc/examples/%.in $(REPLACE_VARS_SED)
1760
	sed -f $(REPLACE_VARS_SED) < $< > $@
1761

    
1762
doc/examples/bash_completion: BC_ARGS = --compact
1763
doc/examples/bash_completion-debug: BC_ARGS =
1764

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

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

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

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

    
1805
man/%: man/%.in  $(REPLACE_VARS_SED)
1806
	sed -f $(REPLACE_VARS_SED) < $< > $@
1807

    
1808
epydoc.conf: epydoc.conf.in $(REPLACE_VARS_SED)
1809
	sed -f $(REPLACE_VARS_SED) < $< > $@
1810

    
1811
vcs-version:
1812
	if test -d .git; then \
1813
	  git describe > $@; \
1814
	elif test ! -f $@ ; then \
1815
	  echo "Cannot auto-generate $@ file"; exit 1; \
1816
	fi
1817

    
1818
.PHONY: clean-vcs-version
1819
clean-vcs-version:
1820
	rm -f vcs-version
1821

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

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

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

    
1858
src/Ganeti/Curl/Internal.hs: src/Ganeti/Curl/Internal.hsc | stamp-directories
1859
	hsc2hs -o $@ $<
1860

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

    
1871
lib/_constants.py: Makefile src/hs2py lib/_constants.py.in | stamp-directories
1872
	cat $(abs_top_srcdir)/lib/_constants.py.in > $@
1873
	src/hs2py --constants >> $@
1874

    
1875
lib/constants.py: lib/_constants.py
1876

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

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

    
1972
lib/opcodes.py: Makefile src/hs2py lib/opcodes.py.in_before \
1973
		lib/opcodes.py.in_after | stamp-directories
1974
	cat $(abs_top_srcdir)/lib/opcodes.py.in_before > $@
1975
	src/hs2py --opcodes >> $@
1976
	cat $(abs_top_srcdir)/lib/opcodes.py.in_after >> $@
1977

    
1978
lib/_generated_rpc.py: lib/rpc_defs.py $(BUILD_RPC)
1979
	PYTHONPATH=. $(RUN_IN_TEMPDIR) $(CURDIR)/$(BUILD_RPC) lib/rpc_defs.py > $@
1980

    
1981
lib/rpc/stub/wconfd.py: Makefile src/hs2py | stamp-directories
1982
	src/hs2py --wconfd-rpc > $@
1983

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

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

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

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

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

    
2092
stamp-directories: Makefile
2093
	$(MAKE) $(AM_MAKEFLAGS) ganeti
2094
	@mkdir_p@ $(DIRS) $(BUILDTIME_DIR_AUTOCREATE)
2095
	touch $@
2096

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

    
2108
.PHONY: ganeti
2109
ganeti:
2110
	cd $(top_builddir) && test -h "$@" || { rm -f $@ && $(LN_S) lib $@; }
2111

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

    
2132
.PHONY: check-news
2133
check-news:
2134
	RELEASE=$(PACKAGE_VERSION) $(CHECK_NEWS) < $(top_srcdir)/NEWS
2135

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

    
2175
.PHONY: hs-test-%
2176
hs-test-%: test/hs/htest
2177
	@rm -f htest.tix
2178
	test/hs/htest -t $*
2179

    
2180
.PHONY: hs-tests
2181
hs-tests: test/hs/htest
2182
	@rm -f htest.tix
2183
	./test/hs/htest
2184

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

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

    
2200
.PHONY: hs-check
2201
hs-check: hs-tests hs-shell
2202

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

    
2219
# For excluding pep8 expects filenames only, not whole paths
2220
PEP8_EXCLUDE = $(subst $(space),$(comma),$(strip $(notdir $(built_python_sources))))
2221

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

    
2231
LINT_TARGETS = pylint pylint-qa pylint-test
2232
if HAS_PEP8
2233
LINT_TARGETS += pep8
2234
endif
2235
if HAS_HLINT
2236
LINT_TARGETS += hlint
2237
endif
2238

    
2239
.PHONY: lint
2240
lint: $(LINT_TARGETS)
2241

    
2242
.PHONY: pylint
2243
pylint: $(GENERATED_FILES)
2244
	@test -n "$(PYLINT)" || { echo 'pylint' not found during configure; exit 1; }
2245
	$(PYLINT) $(LINT_OPTS_ALL) $(lint_python_code)
2246

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

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

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

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

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

    
2319
# Backwards compatible distcheck-release target
2320
distcheck-release: distcheck
2321

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

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

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

    
2384
.PHONY: apidoc
2385
if WANT_HSAPIDOC
2386
apidoc: py-apidoc hs-apidoc
2387
else
2388
apidoc: py-apidoc
2389
endif
2390

    
2391
.PHONY: py-apidoc
2392
py-apidoc: epydoc.conf $(RUN_IN_TEMPDIR) $(GENERATED_FILES)
2393
	env - PATH="$$PATH" PYTHONPATH="$$PYTHONPATH" \
2394
	$(RUN_IN_TEMPDIR) epydoc -v \
2395
	  --conf $(CURDIR)/epydoc.conf \
2396
	  --output $(CURDIR)/$(APIDOC_PY_DIR)
2397

    
2398
.PHONY: hs-apidoc
2399
hs-apidoc: $(APIDOC_HS_DIR)/index.html
2400

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

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

    
2448
.PHONY: coverage
2449

    
2450
COVERAGE_TESTS=
2451
if HS_UNIT
2452
COVERAGE_TESTS += hs-coverage
2453
endif
2454
if PY_UNIT
2455
COVERAGE_TESTS += py-coverage
2456
endif
2457

    
2458
coverage: $(COVERAGE_TESTS)
2459

    
2460
test/py/docs_unittest.py: $(gnt_scripts)
2461

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

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

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

    
2502
commit-check: autotools-check distcheck lint apidoc
2503

    
2504
autotools-check:
2505
	TESTDATA_DIR=./test/data shelltest $(SHELLTESTARGS) \
2506
  $(abs_top_srcdir)/test/autotools/*-*.test \
2507
  -- --hide-successes
2508

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

    
2517
# target to rebuild all man pages (both groff and html output)
2518
.PHONY: man
2519
man: $(man_MANS) $(manhtml)
2520

    
2521
# Target that builds all binaries (including those that are not
2522
# rebuilt except when running the tests)
2523
.PHONY: really-all
2524
really-all: all $(check_SCRIPTS) $(haskell_tests) $(HS_ALL_PROGS)
2525

    
2526
# we don't need the ancient implicit rules:
2527
%: %,v
2528
%: RCS/%,v
2529
%: RCS/%
2530
%: s.%
2531
%: SCCS/s.%
2532

    
2533
-include ./Makefile.local
2534

    
2535
# vim: set noet :