Statistics
| Branch: | Tag: | Revision:

root / Makefile.am @ bced76fd

History | View | Annotate | Download (71.8 kB)

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

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

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

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

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

    
23
# Enable colors in shelltest
24
SHELLTESTARGS = "-c"
25

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

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

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

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

    
98
SYMLINK_TARGET_DIRS = \
99
	$(sysconfdir)/ganeti \
100
	$(libdir)/ganeti/iallocators \
101
	$(libdir)/ganeti/tools \
102
	$(prefix)/share/ganeti \
103
	$(BINDIR) \
104
	$(SBINDIR) \
105
	$(MANDIR)/man1 \
106
	$(MANDIR)/man7 \
107
	$(MANDIR)/man8
108

    
109
# Delete output file if an error occurred while building it
110
.DELETE_ON_ERROR:
111

    
112
HS_DIRS = \
113
	src \
114
	src/Ganeti \
115
	src/Ganeti/Confd \
116
	src/Ganeti/Curl \
117
	src/Ganeti/Cpu \
118
	src/Ganeti/DataCollectors \
119
	src/Ganeti/Hs2Py \
120
	src/Ganeti/HTools \
121
	src/Ganeti/HTools/Backend \
122
	src/Ganeti/HTools/Program \
123
	src/Ganeti/Hypervisor \
124
	src/Ganeti/Hypervisor/Xen \
125
	src/Ganeti/Monitoring \
126
	src/Ganeti/Query \
127
	src/Ganeti/Storage \
128
	src/Ganeti/Storage/Diskstats \
129
	src/Ganeti/Storage/Drbd \
130
	src/Ganeti/Storage/Lvm \
131
	test/hs \
132
	test/hs/Test \
133
	test/hs/Test/Ganeti \
134
	test/hs/Test/Ganeti/Storage \
135
	test/hs/Test/Ganeti/Storage/Diskstats \
136
	test/hs/Test/Ganeti/Storage/Drbd \
137
	test/hs/Test/Ganeti/Storage/Lvm \
138
	test/hs/Test/Ganeti/Confd \
139
	test/hs/Test/Ganeti/HTools \
140
	test/hs/Test/Ganeti/HTools/Backend \
141
	test/hs/Test/Ganeti/Hypervisor \
142
	test/hs/Test/Ganeti/Hypervisor/Xen \
143
	test/hs/Test/Ganeti/Query
144

    
145
# Haskell directories without the roots (src, test/hs)
146
HS_DIRS_NOROOT = $(filter-out src,$(filter-out test/hs,$(HS_DIRS)))
147

    
148
DIRS = \
149
	$(HS_DIRS) \
150
	autotools \
151
	daemons \
152
	devel \
153
	devel/data \
154
	doc \
155
	doc/css \
156
	doc/examples \
157
	doc/examples/gnt-debug \
158
	doc/examples/hooks \
159
	doc/users \
160
	test/data/htools \
161
	test/data/htools/rapi \
162
	test/hs/shelltests \
163
	test/autotools \
164
	lib \
165
	lib/build \
166
	lib/client \
167
	lib/cmdlib \
168
	lib/confd \
169
	lib/http \
170
	lib/hypervisor \
171
	lib/impexpd \
172
	lib/masterd \
173
	lib/rapi \
174
	lib/server \
175
	lib/storage \
176
	lib/tools \
177
	lib/utils \
178
	lib/watcher \
179
	man \
180
	qa \
181
	test \
182
	test/data \
183
	test/data/bdev-rbd \
184
	test/data/ovfdata \
185
	test/data/ovfdata/other \
186
	test/py \
187
	test/py/cmdlib \
188
	test/py/cmdlib/testsupport \
189
	tools
190

    
191
ALL_APIDOC_HS_DIRS = \
192
	$(APIDOC_HS_DIR) \
193
	$(patsubst %,$(APIDOC_HS_DIR)/%,$(call strip_hsroot,$(HS_DIRS_NOROOT)))
194

    
195
BUILDTIME_DIR_AUTOCREATE = \
196
	scripts \
197
	$(APIDOC_DIR) \
198
	$(ALL_APIDOC_HS_DIRS) \
199
	$(APIDOC_PY_DIR) \
200
	$(COVERAGE_DIR) \
201
	$(COVERAGE_HS_DIR) \
202
	$(COVERAGE_PY_DIR) \
203
	.hpc
204

    
205
BUILDTIME_DIRS = \
206
	$(BUILDTIME_DIR_AUTOCREATE) \
207
	doc/html \
208
	doc/man-html
209

    
210
DIRCHECK_EXCLUDE = \
211
	$(BUILDTIME_DIRS) \
212
	ganeti-[0-9]*.[0-9]*.[0-9]* \
213
	doc/html/_* \
214
	doc/man-html/_* \
215
	autom4te.cache
216

    
217
# some helper vars
218
COVERAGE_DIR = doc/coverage
219
COVERAGE_PY_DIR = $(COVERAGE_DIR)/py
220
COVERAGE_HS_DIR = $(COVERAGE_DIR)/hs
221
APIDOC_DIR = doc/api
222
APIDOC_PY_DIR = $(APIDOC_DIR)/py
223
APIDOC_HS_DIR = $(APIDOC_DIR)/hs
224

    
225
MAINTAINERCLEANFILES = \
226
	$(maninput) \
227
	doc/install-quick.rst \
228
	doc/news.rst \
229
	doc/upgrade.rst \
230
	vcs-version
231

    
232
maintainer-clean-local:
233
	rm -rf $(BUILDTIME_DIRS)
234

    
235
CLEANFILES = \
236
	$(addsuffix /*.py[co],$(DIRS)) \
237
	$(addsuffix /*.hi,$(HS_DIRS)) \
238
	$(addsuffix /*.o,$(HS_DIRS)) \
239
	$(PYTHON_BOOTSTRAP) \
240
	$(gnt_python_sbin_SCRIPTS) \
241
	epydoc.conf \
242
	$(REPLACE_VARS_SED) \
243
	$(SHELL_ENV_INIT) \
244
	daemons/daemon-util \
245
	daemons/ganeti-cleaner \
246
	devel/squeeze-amd64.tar.gz \
247
	devel/squeeze-amd64.conf \
248
	$(mandocrst) \
249
	doc/manpages-enabled.rst \
250
	$(BUILT_EXAMPLES) \
251
	doc/examples/bash_completion \
252
	doc/examples/bash_completion-debug \
253
	$(userspecs) \
254
	lib/_generated_rpc.py \
255
	$(man_MANS) \
256
	$(manhtml) \
257
	tools/kvm-ifup \
258
	tools/vif-ganeti \
259
	tools/net-common \
260
	tools/users-setup \
261
	tools/vcluster-setup \
262
	stamp-directories \
263
	stamp-srclinks \
264
	$(nodist_pkgpython_PYTHON) \
265
	$(gnt_scripts) \
266
	$(HS_ALL_PROGS) $(HS_BUILT_SRCS) \
267
	$(HS_BUILT_TEST_HELPERS) \
268
	src/ganeti-confd \
269
	src/ganeti-luxid \
270
	src/ganeti-mond \
271
	.hpc/*.mix src/*.tix test/hs/*.tix *.tix \
272
	doc/hs-lint.html
273

    
274
GENERATED_FILES = \
275
	$(built_base_sources) \
276
	$(BUILT_PYTHON_SOURCES) \
277
	$(PYTHON_BOOTSTRAP) \
278
	$(gnt_python_sbin_SCRIPTS)
279

    
280
HS_GENERATED_FILES =
281
if WANT_HTOOLS
282
HS_GENERATED_FILES += $(HS_PROGS)
283
if ENABLE_CONFD
284
HS_GENERATED_FILES += src/hconfd src/ganeti-confd src/hluxid src/ganeti-luxid
285
endif
286

    
287
if ENABLE_MOND
288
HS_GENERATED_FILES += src/ganeti-mond
289
endif
290
endif
291

    
292
built_base_sources = \
293
	stamp-directories \
294
	stamp-srclinks
295

    
296
built_python_base_sources = \
297
	lib/_constants.py \
298
	lib/_vcsversion.py \
299
	lib/opcodes.py
300

    
301
BUILT_PYTHON_SOURCES = \
302
	$(built_python_base_sources) \
303
	lib/_generated_rpc.py
304

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

    
309
# these are all built from the underlying %.in sources
310
BUILT_EXAMPLES = \
311
	doc/examples/ganeti-kvm-poweroff.initd \
312
	doc/examples/ganeti.cron \
313
	doc/examples/ganeti.initd \
314
	doc/examples/ganeti.logrotate \
315
	doc/examples/ganeti-master-role.ocf \
316
	doc/examples/ganeti-node-role.ocf \
317
	doc/examples/gnt-config-backup \
318
	doc/examples/hooks/ipsec
319

    
320
nodist_pkgpython_PYTHON = \
321
	$(BUILT_PYTHON_SOURCES)
322

    
323
nodist_pkgpython_bin_SCRIPTS = \
324
	$(nodist_pkglib_python_scripts)
325

    
326
pkgpython_bin_SCRIPTS = \
327
	$(pkglib_python_scripts)
328

    
329
noinst_PYTHON = \
330
	lib/build/__init__.py \
331
	lib/build/shell_example_lexer.py \
332
	lib/build/sphinx_ext.py
333

    
334
pkgpython_PYTHON = \
335
	lib/__init__.py \
336
	lib/asyncnotifier.py \
337
	lib/backend.py \
338
	lib/bootstrap.py \
339
	lib/cli.py \
340
	lib/compat.py \
341
	lib/config.py \
342
	lib/constants.py \
343
	lib/daemon.py \
344
	lib/errors.py \
345
	lib/hooksmaster.py \
346
	lib/ht.py \
347
	lib/jqueue.py \
348
	lib/jstore.py \
349
	lib/locking.py \
350
	lib/luxi.py \
351
	lib/mcpu.py \
352
	lib/netutils.py \
353
	lib/objects.py \
354
	lib/opcodes_base.py \
355
	lib/outils.py \
356
	lib/ovf.py \
357
	lib/pathutils.py \
358
	lib/qlang.py \
359
	lib/query.py \
360
	lib/rpc.py \
361
	lib/rpc_defs.py \
362
	lib/runtime.py \
363
	lib/serializer.py \
364
	lib/ssconf.py \
365
	lib/ssh.py \
366
	lib/uidpool.py \
367
	lib/vcluster.py \
368
	lib/network.py \
369
	lib/workerpool.py
370

    
371
client_PYTHON = \
372
	lib/client/__init__.py \
373
	lib/client/gnt_backup.py \
374
	lib/client/gnt_cluster.py \
375
	lib/client/gnt_debug.py \
376
	lib/client/gnt_group.py \
377
	lib/client/gnt_instance.py \
378
	lib/client/gnt_job.py \
379
	lib/client/gnt_node.py \
380
	lib/client/gnt_network.py \
381
	lib/client/gnt_os.py \
382
	lib/client/gnt_storage.py
383

    
384
cmdlib_PYTHON = \
385
	lib/cmdlib/__init__.py \
386
	lib/cmdlib/backup.py \
387
	lib/cmdlib/base.py \
388
	lib/cmdlib/cluster.py \
389
	lib/cmdlib/common.py \
390
	lib/cmdlib/group.py \
391
	lib/cmdlib/instance.py \
392
	lib/cmdlib/instance_migration.py \
393
	lib/cmdlib/instance_operation.py \
394
	lib/cmdlib/instance_query.py \
395
	lib/cmdlib/instance_storage.py \
396
	lib/cmdlib/instance_utils.py \
397
	lib/cmdlib/misc.py \
398
	lib/cmdlib/network.py \
399
	lib/cmdlib/node.py \
400
	lib/cmdlib/operating_system.py \
401
	lib/cmdlib/query.py \
402
	lib/cmdlib/tags.py \
403
	lib/cmdlib/test.py
404

    
405
hypervisor_PYTHON = \
406
	lib/hypervisor/__init__.py \
407
	lib/hypervisor/hv_base.py \
408
	lib/hypervisor/hv_chroot.py \
409
	lib/hypervisor/hv_fake.py \
410
	lib/hypervisor/hv_kvm.py \
411
	lib/hypervisor/hv_lxc.py \
412
	lib/hypervisor/hv_xen.py
413

    
414
storage_PYTHON = \
415
	lib/storage/__init__.py \
416
	lib/storage/bdev.py \
417
	lib/storage/base.py \
418
	lib/storage/container.py \
419
	lib/storage/drbd.py \
420
	lib/storage/drbd_info.py \
421
	lib/storage/drbd_cmdgen.py \
422
	lib/storage/filestorage.py
423

    
424
rapi_PYTHON = \
425
	lib/rapi/__init__.py \
426
	lib/rapi/baserlib.py \
427
	lib/rapi/client.py \
428
	lib/rapi/client_utils.py \
429
	lib/rapi/connector.py \
430
	lib/rapi/rlib2.py \
431
	lib/rapi/testutils.py
432

    
433
http_PYTHON = \
434
	lib/http/__init__.py \
435
	lib/http/auth.py \
436
	lib/http/client.py \
437
	lib/http/server.py
438

    
439
confd_PYTHON = \
440
	lib/confd/__init__.py \
441
	lib/confd/client.py
442

    
443
masterd_PYTHON = \
444
	lib/masterd/__init__.py \
445
	lib/masterd/iallocator.py \
446
	lib/masterd/instance.py
447

    
448
impexpd_PYTHON = \
449
	lib/impexpd/__init__.py
450

    
451
watcher_PYTHON = \
452
	lib/watcher/__init__.py \
453
	lib/watcher/nodemaint.py \
454
	lib/watcher/state.py
455

    
456
server_PYTHON = \
457
	lib/server/__init__.py \
458
	lib/server/masterd.py \
459
	lib/server/noded.py \
460
	lib/server/rapi.py
461

    
462
pytools_PYTHON = \
463
	lib/tools/__init__.py \
464
	lib/tools/burnin.py \
465
	lib/tools/ensure_dirs.py \
466
	lib/tools/node_cleanup.py \
467
	lib/tools/node_daemon_setup.py \
468
	lib/tools/prepare_node_join.py
469

    
470
utils_PYTHON = \
471
	lib/utils/__init__.py \
472
	lib/utils/algo.py \
473
	lib/utils/filelock.py \
474
	lib/utils/hash.py \
475
	lib/utils/io.py \
476
	lib/utils/log.py \
477
	lib/utils/lvm.py \
478
	lib/utils/mlock.py \
479
	lib/utils/nodesetup.py \
480
	lib/utils/process.py \
481
	lib/utils/retry.py \
482
	lib/utils/storage.py \
483
	lib/utils/text.py \
484
	lib/utils/version.py \
485
	lib/utils/wrapper.py \
486
	lib/utils/x509.py
487

    
488
docinput = \
489
	doc/admin.rst \
490
	doc/cluster-keys-replacement.rst \
491
	doc/cluster-merge.rst \
492
	doc/conf.py \
493
	doc/css/style.css \
494
	doc/design-2.0.rst \
495
	doc/design-2.1.rst \
496
	doc/design-2.2.rst \
497
	doc/design-2.3.rst \
498
	doc/design-2.4.rst \
499
	doc/design-2.5.rst \
500
	doc/design-2.6.rst \
501
	doc/design-2.7.rst \
502
	doc/design-2.8.rst \
503
	doc/design-2.9.rst \
504
	doc/design-2.10.rst \
505
	doc/design-autorepair.rst \
506
	doc/design-bulk-create.rst \
507
	doc/design-ceph-ganeti-support.rst \
508
	doc/design-chained-jobs.rst \
509
	doc/design-cmdlib-unittests.rst \
510
	doc/design-cpu-pinning.rst \
511
	doc/design-daemons.rst \
512
	doc/design-device-uuid-name.rst \
513
	doc/design-draft.rst \
514
	doc/design-file-based-storage.rst \
515
	doc/design-glusterfs-ganeti-support.rst \
516
	doc/design-hotplug.rst \
517
	doc/design-hroller.rst \
518
	doc/design-hsqueeze.rst \
519
	doc/design-htools-2.3.rst \
520
	doc/design-http-server.rst \
521
	doc/design-hugepages-support.rst \
522
	doc/design-impexp2.rst \
523
	doc/design-internal-shutdown.rst \
524
	doc/design-linuxha.rst \
525
	doc/design-lu-generated-jobs.rst \
526
	doc/design-monitoring-agent.rst \
527
	doc/design-multi-reloc.rst \
528
	doc/design-network.rst \
529
	doc/design-node-add.rst \
530
	doc/design-oob.rst \
531
	doc/design-openvswitch.rst \
532
	doc/design-opportunistic-locking.rst \
533
	doc/design-optables.rst \
534
	doc/design-ovf-support.rst \
535
	doc/design-partitioned.rst \
536
	doc/design-query-splitting.rst \
537
	doc/design-query2.rst \
538
	doc/design-reason-trail.rst \
539
	doc/design-resource-model.rst \
540
	doc/design-restricted-commands.rst \
541
	doc/design-shared-storage.rst \
542
	doc/design-storagetypes.rst \
543
	doc/design-upgrade.rst \
544
	doc/design-virtual-clusters.rst \
545
	doc/design-x509-ca.rst \
546
	doc/devnotes.rst \
547
	doc/glossary.rst \
548
	doc/hooks.rst \
549
	doc/iallocator.rst \
550
	doc/index.rst \
551
	doc/install-quick.rst \
552
	doc/install.rst \
553
	doc/locking.rst \
554
	doc/manpages-disabled.rst \
555
	doc/monitoring-query-format.rst \
556
	doc/move-instance.rst \
557
	doc/news.rst \
558
	doc/ovfconverter.rst \
559
	doc/rapi.rst \
560
	doc/security.rst \
561
	doc/upgrade.rst \
562
	doc/virtual-cluster.rst \
563
	doc/walkthrough.rst
564

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

    
568
# Haskell programs to be installed in $PREFIX/bin
569
HS_BIN_PROGS=src/htools
570

    
571
# Haskell programs to be installed in the MYEXECLIB dir
572
if ENABLE_MOND
573
HS_MYEXECLIB_PROGS=src/mon-collector
574
else
575
HS_MYEXECLIB_PROGS=
576
endif
577

    
578
# Haskell programs to be compiled by "make really-all"
579
HS_COMPILE_PROGS= \
580
	src/ganeti-mond \
581
	src/hconfd \
582
	src/hluxid \
583
	src/hs2py \
584
	src/rpc-test
585

    
586
# All Haskell non-test programs to be compiled but not automatically installed
587
HS_PROGS = $(HS_BIN_PROGS) $(HS_MYEXECLIB_PROGS)
588

    
589
HS_BIN_ROLES = harep hbal hscan hspace hinfo hcheck hroller
590
HS_HTOOLS_PROGS = $(HS_BIN_ROLES) hail
591

    
592
# Haskell programs that cannot be disabled at configure (e.g., unlike
593
# 'mon-collector')
594
HS_DEFAULT_PROGS = \
595
	$(HS_BIN_PROGS) \
596
	test/hs/hpc-htools \
597
	test/hs/hpc-mon-collector \
598
	test/hs/htest \
599
	$(HS_COMPILE_PROGS)
600

    
601
HS_ALL_PROGS = $(HS_DEFAULT_PROGS) $(HS_MYEXECLIB_PROGS)
602

    
603
HS_PROG_SRCS = $(patsubst %,%.hs,$(HS_DEFAULT_PROGS)) src/mon-collector.hs
604
HS_BUILT_TEST_HELPERS = $(HS_BIN_ROLES:%=test/hs/%) test/hs/hail
605

    
606
HFLAGS = \
607
	-O -Wall -Werror -isrc \
608
	-fwarn-monomorphism-restriction \
609
	-fwarn-tabs \
610
	$(GHC_BYVERSION_FLAGS)
611

    
612
# extra flags that can be overriden on the command line (e.g. -Wwarn, etc.)
613
HEXTRA =
614
# internal extra flags (used for test/hs/htest mainly)
615
HEXTRA_INT =
616
# exclude options for coverage reports
617
HPCEXCL = --exclude Main \
618
	--exclude Ganeti.Constants \
619
	--exclude Ganeti.HTools.QC \
620
	--exclude Ganeti.THH \
621
	--exclude Ganeti.Version \
622
	--exclude Test.Ganeti.Attoparsec \
623
	--exclude Test.Ganeti.TestCommon \
624
	--exclude Test.Ganeti.TestHTools \
625
	--exclude Test.Ganeti.TestHelper \
626
	--exclude Test.Ganeti.TestImports \
627
	$(patsubst src.%,--exclude Test.%,$(subst /,.,$(patsubst %.hs,%, $(HS_LIB_SRCS))))
628

    
629
HS_LIB_SRCS = \
630
	src/Ganeti/BasicTypes.hs \
631
	src/Ganeti/Common.hs \
632
	src/Ganeti/Compat.hs \
633
	src/Ganeti/Confd/Client.hs \
634
	src/Ganeti/Confd/ClientFunctions.hs \
635
	src/Ganeti/Confd/Server.hs \
636
	src/Ganeti/Confd/Types.hs \
637
	src/Ganeti/Confd/Utils.hs \
638
	src/Ganeti/Config.hs \
639
	src/Ganeti/ConfigReader.hs \
640
	src/Ganeti/Constants.hs \
641
	src/Ganeti/ConstantUtils.hs \
642
	src/Ganeti/Cpu/LoadParser.hs \
643
	src/Ganeti/Cpu/Types.hs \
644
	src/Ganeti/Curl/Multi.hs \
645
	src/Ganeti/Daemon.hs \
646
	src/Ganeti/DataCollectors/CLI.hs \
647
	src/Ganeti/DataCollectors/CPUload.hs \
648
	src/Ganeti/DataCollectors/Diskstats.hs \
649
	src/Ganeti/DataCollectors/Drbd.hs \
650
	src/Ganeti/DataCollectors/InstStatus.hs \
651
	src/Ganeti/DataCollectors/InstStatusTypes.hs \
652
	src/Ganeti/DataCollectors/Lv.hs \
653
	src/Ganeti/DataCollectors/Program.hs \
654
	src/Ganeti/DataCollectors/Types.hs \
655
	src/Ganeti/Errors.hs \
656
	src/Ganeti/HTools/Backend/IAlloc.hs \
657
	src/Ganeti/HTools/Backend/Luxi.hs \
658
	src/Ganeti/HTools/Backend/Rapi.hs \
659
	src/Ganeti/HTools/Backend/Simu.hs \
660
	src/Ganeti/HTools/Backend/Text.hs \
661
	src/Ganeti/HTools/CLI.hs \
662
	src/Ganeti/HTools/Cluster.hs \
663
	src/Ganeti/HTools/Container.hs \
664
	src/Ganeti/HTools/ExtLoader.hs \
665
	src/Ganeti/HTools/Graph.hs \
666
	src/Ganeti/HTools/Group.hs \
667
	src/Ganeti/HTools/Instance.hs \
668
	src/Ganeti/HTools/Loader.hs \
669
	src/Ganeti/HTools/Nic.hs \
670
	src/Ganeti/HTools/Node.hs \
671
	src/Ganeti/HTools/PeerMap.hs \
672
	src/Ganeti/HTools/Program/Hail.hs \
673
	src/Ganeti/HTools/Program/Harep.hs \
674
	src/Ganeti/HTools/Program/Hbal.hs \
675
	src/Ganeti/HTools/Program/Hcheck.hs \
676
	src/Ganeti/HTools/Program/Hinfo.hs \
677
	src/Ganeti/HTools/Program/Hscan.hs \
678
	src/Ganeti/HTools/Program/Hspace.hs \
679
	src/Ganeti/HTools/Program/Hroller.hs \
680
	src/Ganeti/HTools/Program/Main.hs \
681
	src/Ganeti/HTools/Types.hs \
682
	src/Ganeti/Hypervisor/Xen.hs \
683
	src/Ganeti/Hypervisor/Xen/XmParser.hs \
684
	src/Ganeti/Hypervisor/Xen/Types.hs \
685
	src/Ganeti/Hash.hs \
686
	src/Ganeti/Hs2Py/GenConstants.hs \
687
	src/Ganeti/Hs2Py/GenOpCodes.hs \
688
	src/Ganeti/Hs2Py/OpDoc.hs \
689
	src/Ganeti/JQueue.hs \
690
	src/Ganeti/JSON.hs \
691
	src/Ganeti/Jobs.hs \
692
	src/Ganeti/Logging.hs \
693
	src/Ganeti/Luxi.hs \
694
	src/Ganeti/Monitoring/Server.hs \
695
	src/Ganeti/Network.hs \
696
	src/Ganeti/Objects.hs \
697
	src/Ganeti/OpCodes.hs \
698
	src/Ganeti/OpParams.hs \
699
	src/Ganeti/Path.hs \
700
	src/Ganeti/Parsers.hs \
701
	src/Ganeti/PyValueInstances.hs \
702
	src/Ganeti/Query/Cluster.hs \
703
	src/Ganeti/Query/Common.hs \
704
	src/Ganeti/Query/Export.hs \
705
	src/Ganeti/Query/Filter.hs \
706
	src/Ganeti/Query/Group.hs \
707
	src/Ganeti/Query/Job.hs \
708
	src/Ganeti/Query/Language.hs \
709
	src/Ganeti/Query/Network.hs \
710
	src/Ganeti/Query/Node.hs \
711
	src/Ganeti/Query/Query.hs \
712
	src/Ganeti/Query/Server.hs \
713
	src/Ganeti/Query/Types.hs \
714
	src/Ganeti/Rpc.hs \
715
	src/Ganeti/Runtime.hs \
716
	src/Ganeti/Ssconf.hs \
717
	src/Ganeti/Storage/Diskstats/Parser.hs \
718
	src/Ganeti/Storage/Diskstats/Types.hs \
719
	src/Ganeti/Storage/Drbd/Parser.hs \
720
	src/Ganeti/Storage/Drbd/Types.hs \
721
	src/Ganeti/Storage/Lvm/LVParser.hs \
722
	src/Ganeti/Storage/Lvm/Types.hs \
723
	src/Ganeti/Storage/Utils.hs \
724
	src/Ganeti/THH.hs \
725
	src/Ganeti/Types.hs \
726
	src/Ganeti/Utils.hs
727

    
728
HS_TEST_SRCS = \
729
	test/hs/Test/AutoConf.hs \
730
	test/hs/Test/Ganeti/Attoparsec.hs \
731
	test/hs/Test/Ganeti/BasicTypes.hs \
732
	test/hs/Test/Ganeti/Common.hs \
733
	test/hs/Test/Ganeti/Confd/Types.hs \
734
	test/hs/Test/Ganeti/Confd/Utils.hs \
735
	test/hs/Test/Ganeti/Constants.hs \
736
	test/hs/Test/Ganeti/Daemon.hs \
737
	test/hs/Test/Ganeti/Errors.hs \
738
	test/hs/Test/Ganeti/HTools/Backend/Simu.hs \
739
	test/hs/Test/Ganeti/HTools/Backend/Text.hs \
740
	test/hs/Test/Ganeti/HTools/CLI.hs \
741
	test/hs/Test/Ganeti/HTools/Cluster.hs \
742
	test/hs/Test/Ganeti/HTools/Container.hs \
743
	test/hs/Test/Ganeti/HTools/ExtLoader.hs \
744
	test/hs/Test/Ganeti/HTools/Graph.hs \
745
	test/hs/Test/Ganeti/HTools/Instance.hs \
746
	test/hs/Test/Ganeti/HTools/Loader.hs \
747
	test/hs/Test/Ganeti/HTools/Node.hs \
748
	test/hs/Test/Ganeti/HTools/PeerMap.hs \
749
	test/hs/Test/Ganeti/HTools/Types.hs \
750
	test/hs/Test/Ganeti/Hypervisor/Xen/XmParser.hs \
751
	test/hs/Test/Ganeti/JSON.hs \
752
	test/hs/Test/Ganeti/Jobs.hs \
753
	test/hs/Test/Ganeti/JQueue.hs \
754
	test/hs/Test/Ganeti/Luxi.hs \
755
	test/hs/Test/Ganeti/Network.hs \
756
	test/hs/Test/Ganeti/Objects.hs \
757
	test/hs/Test/Ganeti/OpCodes.hs \
758
	test/hs/Test/Ganeti/Query/Filter.hs \
759
	test/hs/Test/Ganeti/Query/Language.hs \
760
	test/hs/Test/Ganeti/Query/Network.hs \
761
	test/hs/Test/Ganeti/Query/Query.hs \
762
	test/hs/Test/Ganeti/Rpc.hs \
763
	test/hs/Test/Ganeti/Runtime.hs \
764
	test/hs/Test/Ganeti/Ssconf.hs \
765
	test/hs/Test/Ganeti/Storage/Diskstats/Parser.hs \
766
	test/hs/Test/Ganeti/Storage/Drbd/Parser.hs \
767
	test/hs/Test/Ganeti/Storage/Drbd/Types.hs \
768
	test/hs/Test/Ganeti/Storage/Lvm/LVParser.hs \
769
	test/hs/Test/Ganeti/THH.hs \
770
	test/hs/Test/Ganeti/TestCommon.hs \
771
	test/hs/Test/Ganeti/TestHTools.hs \
772
	test/hs/Test/Ganeti/TestHelper.hs \
773
	test/hs/Test/Ganeti/Types.hs \
774
	test/hs/Test/Ganeti/Utils.hs
775

    
776
HS_LIBTEST_SRCS = $(HS_LIB_SRCS) $(HS_TEST_SRCS)
777

    
778
HS_BUILT_SRCS = \
779
	test/hs/Test/Ganeti/TestImports.hs \
780
	src/AutoConf.hs \
781
	src/Ganeti/Hs2Py/ListConstants.hs \
782
	src/Ganeti/Curl/Internal.hs \
783
	src/Ganeti/Version.hs
784
HS_BUILT_SRCS_IN = \
785
	$(patsubst %,%.in,$(filter-out src/Ganeti/Curl/Internal.hs,$(HS_BUILT_SRCS))) \
786
	src/Ganeti/Curl/Internal.hsc \
787
	lib/_constants.py.in \
788
	lib/opcodes.py.in_after \
789
	lib/opcodes.py.in_before
790

    
791
HS_LIBTESTBUILT_SRCS = $(HS_LIBTEST_SRCS) $(HS_BUILT_SRCS)
792

    
793
$(RUN_IN_TEMPDIR): | stamp-directories
794

    
795
doc/html/index.html: ENABLE_MANPAGES =
796
doc/man-html/index.html: ENABLE_MANPAGES = 1
797
doc/man-html/index.html: doc/manpages-enabled.rst $(mandocrst)
798

    
799
# Note: we use here an order-only prerequisite, as the contents of
800
# _constants.py are not actually influencing the html build output: it
801
# has to exist in order for the sphinx module to be loaded
802
# successfully, but we certainly don't want the docs to be rebuilt if
803
# it changes
804
doc/html/index.html doc/man-html/index.html: $(docinput) doc/conf.py \
805
	configure.ac $(RUN_IN_TEMPDIR) lib/build/sphinx_ext.py \
806
	lib/build/shell_example_lexer.py lib/ht.py \
807
	doc/css/style.css lib/rapi/connector.py lib/rapi/rlib2.py \
808
	autotools/sphinx-wrapper | $(BUILT_PYTHON_SOURCES)
809
	@test -n "$(SPHINX)" || \
810
	    { echo 'sphinx-build' not found during configure; exit 1; }
811
if !MANPAGES_IN_DOC
812
	if test -n '$(ENABLE_MANPAGES)'; then \
813
	  echo 'Man pages in documentation were disabled at configure time' >&2; \
814
	  exit 1; \
815
	fi
816
endif
817
## Sphinx provides little control over what content should be included. Some
818
## mechanisms exist, but they all have drawbacks or actual issues. Since we
819
## build two different versions of the documentation--once without man pages and
820
## once, if enabled, with them--some control is necessary. xmpp-wrapper provides
821
## us with this, but requires running in a temporary directory. It moves the
822
## correct files into place depending on environment variables.
823
	dir=$(dir $@) && \
824
	@mkdir_p@ $$dir && \
825
	PYTHONPATH=. ENABLE_MANPAGES=$(ENABLE_MANPAGES) COPY_DOC=1 \
826
	$(RUN_IN_TEMPDIR) autotools/sphinx-wrapper $(SPHINX) -q -W -b html \
827
	    -d . \
828
	    -D version="$(VERSION_MAJOR).$(VERSION_MINOR)" \
829
	    -D release="$(PACKAGE_VERSION)" \
830
	    -D graphviz_dot="$(DOT)" \
831
	    -D enable_manpages="$(ENABLE_MANPAGES)" \
832
	    doc $(CURDIR)/$$dir && \
833
	rm -f $$dir/.buildinfo $$dir/objects.inv
834
	touch $@
835

    
836
doc/html: doc/html/index.html
837

    
838
doc/man-html: doc/man-html/index.html
839

    
840
doc/install-quick.rst: INSTALL
841
doc/news.rst: NEWS
842
doc/upgrade.rst: UPGRADE
843

    
844
doc/install-quick.rst doc/news.rst doc/upgrade.rst:
845
	set -e; \
846
	{ echo '.. This file is automatically updated at build time from $<.'; \
847
	  echo '.. Do not edit.'; \
848
	  echo; \
849
	  cat $<; \
850
	} > $@
851

    
852
doc/manpages-enabled.rst: Makefile | $(built_base_sources)
853
	{ echo '.. This file is automatically generated, do not edit!'; \
854
	  echo ''; \
855
	  echo 'Man pages'; \
856
	  echo '========='; \
857
	  echo; \
858
	  echo '.. toctree::'; \
859
	  echo '   :maxdepth: 1'; \
860
	  echo; \
861
	  for i in $(notdir $(mandocrst)); do \
862
	    echo "   $$i"; \
863
	  done | LC_ALL=C sort; \
864
	} > $@
865

    
866
doc/man-%.rst: man/%.gen Makefile $(REPLACE_VARS_SED) | $(built_base_sources)
867
if MANPAGES_IN_DOC
868
	{ echo '.. This file is automatically updated at build time from $<.'; \
869
	  echo '.. Do not edit.'; \
870
	  echo; \
871
	  echo "$*"; \
872
	  echo '=========================================='; \
873
	  tail -n +3 $< | sed -f $(REPLACE_VARS_SED); \
874
	} > $@
875
else
876
	echo 'Man pages in documentation were disabled at configure time' >&2; \
877
	exit 1;
878
endif
879

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

    
883
userspecs = \
884
	doc/users/users \
885
	doc/users/groups \
886
	doc/users/groupmemberships
887

    
888
# Things to build but not to install (add it to EXTRA_DIST if it should be
889
# distributed)
890
noinst_DATA = \
891
	$(BUILT_EXAMPLES) \
892
	doc/examples/bash_completion \
893
	doc/examples/bash_completion-debug \
894
	$(userspecs) \
895
	$(manhtml)
896

    
897
if HAS_SPHINX
898
if MANPAGES_IN_DOC
899
noinst_DATA += doc/man-html
900
else
901
noinst_DATA += doc/html
902
endif
903
endif
904

    
905
gnt_scripts = \
906
	scripts/gnt-backup \
907
	scripts/gnt-cluster \
908
	scripts/gnt-debug \
909
	scripts/gnt-group \
910
	scripts/gnt-instance \
911
	scripts/gnt-job \
912
	scripts/gnt-network \
913
	scripts/gnt-node \
914
	scripts/gnt-os \
915
	scripts/gnt-storage
916

    
917
gnt_scripts_basenames = \
918
	$(patsubst scripts/%,%,$(patsubst daemons/%,%,$(gnt_scripts) $(gnt_python_sbin_SCRIPTS)))
919

    
920
gnt_python_sbin_SCRIPTS = \
921
	$(PYTHON_BOOTSTRAP_SBIN)
922

    
923
gntpython_SCRIPTS = $(gnt_scripts)
924

    
925
PYTHON_BOOTSTRAP_SBIN = \
926
	daemons/ganeti-masterd \
927
	daemons/ganeti-noded \
928
	daemons/ganeti-rapi \
929
	daemons/ganeti-watcher
930

    
931
PYTHON_BOOTSTRAP = \
932
	tools/burnin \
933
	tools/ensure-dirs \
934
	tools/node-cleanup \
935
	tools/node-daemon-setup \
936
	tools/prepare-node-join
937

    
938
qa_scripts = \
939
	qa/__init__.py \
940
	qa/ganeti-qa.py \
941
	qa/qa_cluster.py \
942
	qa/qa_config.py \
943
	qa/qa_daemon.py \
944
	qa/qa_env.py \
945
	qa/qa_error.py \
946
	qa/qa_group.py \
947
	qa/qa_instance.py \
948
	qa/qa_instance_utils.py \
949
	qa/qa_job.py \
950
	qa/qa_monitoring.py \
951
	qa/qa_node.py \
952
	qa/qa_os.py \
953
	qa/qa_rapi.py \
954
	qa/qa_tags.py \
955
	qa/qa_utils.py
956

    
957
bin_SCRIPTS =
958
if WANT_HTOOLS
959
bin_SCRIPTS += $(HS_BIN_PROGS)
960
install-exec-hook:
961
	@mkdir_p@ $(DESTDIR)$(iallocatorsdir)
962
# FIXME: this is a hardcoded logic, instead of auto-resolving
963
	$(LN_S) -f ../../../bin/htools \
964
	  $(DESTDIR)$(iallocatorsdir)/hail
965
	for role in $(HS_BIN_ROLES); do \
966
	  $(LN_S) -f htools $(DESTDIR)$(bindir)/$$role ; \
967
	done
968
endif
969

    
970
$(HS_ALL_PROGS): %: %.hs $(HS_LIBTESTBUILT_SRCS) Makefile
971
	@if [ "$(notdir $@)" = "test" ] && [ "$(HS_NODEV)" ]; then \
972
	  echo "Error: cannot run unittests without the development" \
973
	       " libraries (see devnotes.rst)" 1>&2; \
974
	  exit 1; \
975
	fi
976
	@rm -f $(notdir $@).tix
977
	$(GHC) --make \
978
	  $(HFLAGS) \
979
	  $(HS_PARALLEL3) $(HS_REGEX_PCRE) \
980
	  -osuf $(notdir $@).o -hisuf $(notdir $@).hi \
981
	  $(HEXTRA) $(HEXTRA_INT) $@
982
	@touch "$@"
983

    
984
# for the test/hs/htest binary, we need to enable profiling/coverage
985
test/hs/htest: HEXTRA_INT=-fhpc -itest/hs
986

    
987
# we compile the hpc-htools binary with the program coverage
988
test/hs/hpc-htools: HEXTRA_INT=-fhpc
989

    
990
# we compile the hpc-mon-collector binary with the program coverage
991
test/hs/hpc-mon-collector: HEXTRA_INT=-fhpc
992

    
993
# test dependency
994
test/hs/offline-test.sh: test/hs/hpc-htools test/hs/hpc-mon-collector
995

    
996
# rules for building profiling-enabled versions of the haskell
997
# programs: hs-prof does the full two-step build, whereas
998
# hs-prof-quick does only the final rebuild (hs-prof must have been
999
# run before)
1000
.PHONY: hs-prof hs-prof-quick
1001
hs-prof:
1002
	@if [ -z "$(TARGET)" ]; then \
1003
	  echo "You need to define TARGET when running this rule" 1>&2; \
1004
	  exit 1; \
1005
	fi
1006
	$(MAKE) $(AM_MAKEFLAGS) clean
1007
	$(MAKE) $(AM_MAKEFLAGS) $(TARGET) HEXTRA="-osuf o"
1008
	rm -f $(HS_ALL_PROGS)
1009
	$(MAKE) $(AM_MAKEFLAGS) hs-prof-quick
1010

    
1011
hs-prof-quick:
1012
	@if [ -z "$(TARGET)" ]; then \
1013
	  echo "You need to define TARGET when running this rule" 1>&2; \
1014
	  exit 1; \
1015
	fi
1016
	$(MAKE) $(AM_MAKEFLAGS) $(TARGET) HEXTRA="-osuf prof_o -prof -auto-all"
1017

    
1018
dist_sbin_SCRIPTS = \
1019
	tools/ganeti-listrunner
1020

    
1021
nodist_sbin_SCRIPTS = \
1022
	daemons/ganeti-cleaner
1023

    
1024
# strip path prefixes off the sbin scripts
1025
all_sbin_scripts = \
1026
	$(patsubst tools/%,%,$(patsubst daemons/%,%,$(patsubst scripts/%,%,\
1027
	$(patsubst src/%,%,$(dist_sbin_SCRIPTS) $(nodist_sbin_SCRIPTS)))))
1028

    
1029
if ENABLE_CONFD
1030
src/ganeti-confd: src/hconfd
1031
	cp -f $< $@
1032

    
1033
src/ganeti-luxid: src/hluxid
1034
	cp -f $< $@
1035

    
1036
nodist_sbin_SCRIPTS += src/ganeti-confd
1037
nodist_sbin_SCRIPTS += src/ganeti-luxid
1038
endif
1039

    
1040
if ENABLE_MOND
1041
nodist_sbin_SCRIPTS += src/ganeti-mond
1042
endif
1043

    
1044
python_scripts = \
1045
	tools/cfgshell \
1046
	tools/cfgupgrade \
1047
	tools/cfgupgrade12 \
1048
	tools/cluster-merge \
1049
	tools/confd-client \
1050
	tools/fmtjson \
1051
	tools/lvmstrap \
1052
	tools/move-instance \
1053
	tools/ovfconverter \
1054
	tools/post-upgrade \
1055
	tools/sanitize-config
1056

    
1057
dist_tools_SCRIPTS = \
1058
	tools/kvm-console-wrapper \
1059
	tools/master-ip-setup \
1060
	tools/xen-console-wrapper
1061

    
1062
dist_tools_python_SCRIPTS = \
1063
	$(python_scripts) \
1064
	tools/burnin
1065

    
1066
nodist_tools_python_SCRIPTS = \
1067
	tools/node-cleanup
1068

    
1069
tools_python_basenames = $(patsubst tools/%,%,\
1070
	$(dist_tools_python_SCRIPTS) $(nodist_tools_python_SCRIPTS))
1071

    
1072
nodist_tools_SCRIPTS = \
1073
	tools/users-setup \
1074
	tools/vcluster-setup
1075

    
1076
tools_basenames = $(patsubst tools/%,%,$(nodist_tools_SCRIPTS) $(dist_tools_SCRIPTS))
1077

    
1078
pkglib_python_scripts = \
1079
	daemons/import-export \
1080
	tools/check-cert-expired
1081

    
1082
nodist_pkglib_python_scripts = \
1083
	tools/ensure-dirs \
1084
	tools/node-daemon-setup \
1085
	tools/prepare-node-join
1086

    
1087
pkglib_python_basenames = \
1088
	$(patsubst daemons/%,%,$(patsubst tools/%,%,\
1089
	$(pkglib_python_scripts) $(nodist_pkglib_python_scripts)))
1090

    
1091
myexeclib_SCRIPTS = \
1092
	daemons/daemon-util \
1093
	tools/kvm-ifup \
1094
	tools/vif-ganeti \
1095
	tools/net-common \
1096
	$(HS_MYEXECLIB_PROGS)
1097

    
1098
# compute the basenames of the myexeclib_scripts
1099
myexeclib_scripts_basenames = \
1100
	$(patsubst tools/%,%,$(patsubst daemons/%,%,$(patsubst src/%,%,$(myexeclib_SCRIPTS))))
1101

    
1102
EXTRA_DIST = \
1103
	NEWS \
1104
	UPGRADE \
1105
	epydoc.conf.in \
1106
	pylintrc \
1107
	pylintrc-test \
1108
	autotools/build-bash-completion \
1109
	autotools/build-rpc \
1110
	autotools/check-header \
1111
	autotools/check-imports \
1112
	autotools/check-man-dashes \
1113
	autotools/check-man-references \
1114
	autotools/check-man-warnings \
1115
	autotools/check-news \
1116
	autotools/check-python-code \
1117
	autotools/check-tar \
1118
	autotools/check-version \
1119
	autotools/docpp \
1120
	autotools/gen-py-coverage \
1121
	autotools/print-py-constants \
1122
	autotools/sphinx-wrapper \
1123
	autotools/testrunner \
1124
	autotools/wrong-hardcoded-paths \
1125
	$(RUN_IN_TEMPDIR) \
1126
	daemons/daemon-util.in \
1127
	daemons/ganeti-cleaner.in \
1128
	$(pkglib_python_scripts) \
1129
	devel/upload \
1130
	devel/webserver \
1131
	tools/kvm-ifup.in \
1132
	tools/vif-ganeti.in \
1133
	tools/net-common.in \
1134
	tools/vcluster-setup.in \
1135
	$(docinput) \
1136
	doc/html \
1137
	$(BUILT_EXAMPLES:%=%.in) \
1138
	doc/examples/ganeti.default \
1139
	doc/examples/ganeti.default-debug \
1140
	doc/examples/hooks/ethers \
1141
	doc/examples/gnt-debug/README \
1142
	doc/examples/gnt-debug/delay0.json \
1143
	doc/examples/gnt-debug/delay50.json \
1144
	doc/users/groupmemberships.in \
1145
	doc/users/groups.in \
1146
	doc/users/users.in \
1147
	$(dist_TESTS) \
1148
	$(TEST_FILES) \
1149
	$(python_test_support) \
1150
	man/footer.rst \
1151
	$(manrst) \
1152
	$(maninput) \
1153
	qa/qa-sample.json \
1154
	$(qa_scripts) \
1155
	$(HS_LIBTEST_SRCS) $(HS_BUILT_SRCS_IN) \
1156
	$(HS_PROG_SRCS) \
1157
	src/lint-hints.hs \
1158
	test/hs/cli-tests-defs.sh \
1159
	test/hs/offline-test.sh \
1160
	.ghci
1161

    
1162
man_MANS = \
1163
	man/ganeti-cleaner.8 \
1164
	man/ganeti-confd.8 \
1165
	man/ganeti-luxid.8 \
1166
	man/ganeti-listrunner.8 \
1167
	man/ganeti-masterd.8 \
1168
	man/ganeti-mond.8 \
1169
	man/ganeti-noded.8 \
1170
	man/ganeti-os-interface.7 \
1171
	man/ganeti-extstorage-interface.7 \
1172
	man/ganeti-rapi.8 \
1173
	man/ganeti-watcher.8 \
1174
	man/ganeti.7 \
1175
	man/gnt-backup.8 \
1176
	man/gnt-cluster.8 \
1177
	man/gnt-debug.8 \
1178
	man/gnt-group.8 \
1179
	man/gnt-network.8 \
1180
	man/gnt-instance.8 \
1181
	man/gnt-job.8 \
1182
	man/gnt-node.8 \
1183
	man/gnt-os.8 \
1184
	man/gnt-storage.8 \
1185
	man/hail.1 \
1186
	man/harep.1 \
1187
	man/hbal.1 \
1188
	man/hcheck.1 \
1189
	man/hinfo.1 \
1190
	man/hscan.1 \
1191
	man/hspace.1 \
1192
	man/hroller.1 \
1193
	man/htools.1 \
1194
	man/mon-collector.7
1195

    
1196
# Remove extensions from all filenames in man_MANS
1197
mannoext = $(patsubst %.1,%,$(patsubst %.7,%,$(patsubst %.8,%,$(man_MANS))))
1198

    
1199
manrst = $(patsubst %,%.rst,$(mannoext))
1200
manhtml = $(patsubst %.rst,%.html,$(manrst))
1201
mangen = $(patsubst %.rst,%.gen,$(manrst))
1202
maninput = \
1203
	$(patsubst %.1,%.1.in,$(patsubst %.7,%.7.in,$(patsubst %.8,%.8.in,$(man_MANS)))) \
1204
	$(patsubst %.html,%.html.in,$(manhtml)) \
1205
	$(mangen)
1206

    
1207
manfullpath = $(patsubst man/%.1,man1/%.1,\
1208
	$(patsubst man/%.7,man7/%.7,\
1209
	$(patsubst man/%.8,man8/%.8,$(man_MANS))))
1210

    
1211
TEST_FILES = \
1212
	test/autotools/autotools-check-news.test \
1213
	test/data/htools/clean-nonzero-score.data \
1214
	test/data/htools/common-suffix.data \
1215
	test/data/htools/empty-cluster.data \
1216
	test/data/htools/hail-alloc-drbd.json \
1217
	test/data/htools/hail-alloc-invalid-network.json \
1218
	test/data/htools/hail-alloc-invalid-twodisks.json \
1219
	test/data/htools/hail-alloc-restricted-network.json \
1220
	test/data/htools/hail-alloc-spindles.json \
1221
	test/data/htools/hail-alloc-twodisks.json \
1222
	test/data/htools/hail-change-group.json \
1223
	test/data/htools/hail-invalid-reloc.json \
1224
	test/data/htools/hail-node-evac.json \
1225
	test/data/htools/hail-reloc-drbd.json \
1226
	test/data/htools/hbal-dyn.data \
1227
	test/data/htools/hbal-excl-tags.data \
1228
	test/data/htools/hbal-split-insts.data \
1229
	test/data/htools/hspace-tiered-dualspec-exclusive.data \
1230
	test/data/htools/hspace-tiered-dualspec.data \
1231
	test/data/htools/hspace-tiered-exclusive.data \
1232
	test/data/htools/hspace-tiered-ipolicy.data \
1233
	test/data/htools/hspace-tiered-mixed.data \
1234
	test/data/htools/hspace-tiered-resourcetypes.data \
1235
	test/data/htools/hspace-tiered-vcpu.data \
1236
	test/data/htools/hspace-tiered.data \
1237
	test/data/htools/invalid-node.data \
1238
	test/data/htools/missing-resources.data \
1239
	test/data/htools/multiple-master.data \
1240
	test/data/htools/multiple-tags.data \
1241
	test/data/htools/n1-failure.data \
1242
	test/data/htools/rapi/groups.json \
1243
	test/data/htools/rapi/info.json \
1244
	test/data/htools/rapi/instances.json \
1245
	test/data/htools/rapi/nodes.json \
1246
	test/data/htools/hroller-full.data \
1247
	test/data/htools/hroller-nodegroups.data \
1248
	test/data/htools/hroller-nonredundant.data \
1249
	test/data/htools/hroller-online.data \
1250
	test/data/htools/unique-reboot-order.data \
1251
	test/hs/shelltests/htools-balancing.test \
1252
	test/hs/shelltests/htools-basic.test \
1253
	test/hs/shelltests/htools-dynutil.test \
1254
	test/hs/shelltests/htools-excl.test \
1255
	test/hs/shelltests/htools-hail.test \
1256
	test/hs/shelltests/htools-hroller.test \
1257
	test/hs/shelltests/htools-hspace.test \
1258
	test/hs/shelltests/htools-invalid.test \
1259
	test/hs/shelltests/htools-multi-group.test \
1260
	test/hs/shelltests/htools-no-backend.test \
1261
	test/hs/shelltests/htools-rapi.test \
1262
	test/hs/shelltests/htools-single-group.test \
1263
	test/hs/shelltests/htools-text-backend.test \
1264
	test/hs/shelltests/htools-mon-collector.test \
1265
	test/data/bdev-drbd-8.0.txt \
1266
	test/data/bdev-drbd-8.3.txt \
1267
	test/data/bdev-drbd-8.4.txt \
1268
	test/data/bdev-drbd-8.4-no-disk-params.txt \
1269
	test/data/bdev-drbd-disk.txt \
1270
	test/data/bdev-drbd-net-ip4.txt \
1271
	test/data/bdev-drbd-net-ip6.txt \
1272
	test/data/bdev-rbd/json_output_empty.txt \
1273
	test/data/bdev-rbd/json_output_extra_matches.txt \
1274
	test/data/bdev-rbd/json_output_no_matches.txt \
1275
	test/data/bdev-rbd/json_output_ok.txt \
1276
	test/data/bdev-rbd/plain_output_new_extra_matches.txt \
1277
	test/data/bdev-rbd/plain_output_new_no_matches.txt \
1278
	test/data/bdev-rbd/plain_output_new_ok.txt \
1279
	test/data/bdev-rbd/plain_output_old_empty.txt \
1280
	test/data/bdev-rbd/plain_output_old_extra_matches.txt \
1281
	test/data/bdev-rbd/plain_output_old_no_matches.txt \
1282
	test/data/bdev-rbd/plain_output_old_ok.txt \
1283
	test/data/bdev-rbd/output_invalid.txt \
1284
	test/data/cert1.pem \
1285
	test/data/cert2.pem \
1286
	test/data/cluster_config_2.7.json \
1287
	test/data/cluster_config_2.8.json \
1288
	test/data/cluster_config_2.9.json \
1289
	test/data/instance-minor-pairing.txt \
1290
	test/data/instance-prim-sec.txt \
1291
	test/data/ip-addr-show-dummy0.txt \
1292
	test/data/ip-addr-show-lo-ipv4.txt \
1293
	test/data/ip-addr-show-lo-ipv6.txt \
1294
	test/data/ip-addr-show-lo-oneline-ipv4.txt \
1295
	test/data/ip-addr-show-lo-oneline-ipv6.txt \
1296
	test/data/ip-addr-show-lo-oneline.txt \
1297
	test/data/ip-addr-show-lo.txt \
1298
	test/data/kvm_0.12.5_help.txt \
1299
	test/data/kvm_0.15.90_help.txt \
1300
	test/data/kvm_0.9.1_help.txt \
1301
	test/data/kvm_0.9.1_help_boot_test.txt \
1302
	test/data/kvm_1.0_help.txt \
1303
	test/data/kvm_1.1.2_help.txt \
1304
	test/data/kvm_runtime.json \
1305
	test/data/lvs_lv.txt \
1306
	test/data/NEWS_OK.txt \
1307
	test/data/NEWS_previous_unreleased.txt \
1308
	test/data/ovfdata/compr_disk.vmdk.gz \
1309
	test/data/ovfdata/config.ini \
1310
	test/data/ovfdata/corrupted_resources.ovf \
1311
	test/data/ovfdata/empty.ini \
1312
	test/data/ovfdata/empty.ovf \
1313
	test/data/ovfdata/ganeti.mf \
1314
	test/data/ovfdata/ganeti.ovf \
1315
	test/data/ovfdata/gzip_disk.ovf \
1316
	test/data/ovfdata/new_disk.vmdk \
1317
	test/data/ovfdata/no_disk.ini \
1318
	test/data/ovfdata/no_disk_in_ref.ovf \
1319
	test/data/ovfdata/no_os.ini \
1320
	test/data/ovfdata/no_ovf.ova \
1321
	test/data/ovfdata/other/rawdisk.raw \
1322
	test/data/ovfdata/ova.ova \
1323
	test/data/ovfdata/rawdisk.raw \
1324
	test/data/ovfdata/second_disk.vmdk \
1325
	test/data/ovfdata/unsafe_path.ini \
1326
	test/data/ovfdata/virtualbox.ovf \
1327
	test/data/ovfdata/wrong_config.ini \
1328
	test/data/ovfdata/wrong_extension.ovd \
1329
	test/data/ovfdata/wrong_manifest.mf \
1330
	test/data/ovfdata/wrong_manifest.ovf \
1331
	test/data/ovfdata/wrong_ova.ova \
1332
	test/data/ovfdata/wrong_xml.ovf \
1333
	test/data/proc_diskstats.txt \
1334
	test/data/proc_drbd8.txt \
1335
	test/data/proc_drbd80-emptyline.txt \
1336
	test/data/proc_drbd80-emptyversion.txt \
1337
	test/data/proc_drbd83.txt \
1338
	test/data/proc_drbd83_sync.txt \
1339
	test/data/proc_drbd83_sync_want.txt \
1340
	test/data/proc_drbd83_sync_krnl2.6.39.txt \
1341
	test/data/proc_drbd84.txt \
1342
	test/data/proc_drbd84_sync.txt \
1343
	test/data/proc_meminfo.txt \
1344
	test/data/proc_cpuinfo.txt \
1345
	test/data/qa-minimal-nodes-instances-only.json \
1346
	test/data/sys_drbd_usermode_helper.txt \
1347
	test/data/vgreduce-removemissing-2.02.02.txt \
1348
	test/data/vgreduce-removemissing-2.02.66-fail.txt \
1349
	test/data/vgreduce-removemissing-2.02.66-ok.txt \
1350
	test/data/vgs-missing-pvs-2.02.02.txt \
1351
	test/data/vgs-missing-pvs-2.02.66.txt \
1352
	test/data/xen-xm-info-4.0.1.txt \
1353
	test/data/xen-xm-list-4.0.1-dom0-only.txt \
1354
	test/data/xen-xm-list-4.0.1-four-instances.txt \
1355
	test/data/xen-xm-list-long-4.0.1.txt \
1356
	test/data/xen-xm-uptime-4.0.1.txt \
1357
	test/py/ganeti-cli.test \
1358
	test/py/gnt-cli.test \
1359
	test/py/import-export_unittest-helper
1360

    
1361

    
1362
python_tests = \
1363
	doc/examples/rapi_testutils.py \
1364
	test/py/cmdlib/backup_unittest.py \
1365
	test/py/cmdlib/cluster_unittest.py \
1366
	test/py/cmdlib/cmdlib_unittest.py \
1367
	test/py/cmdlib/group_unittest.py \
1368
	test/py/cmdlib/instance_unittest.py \
1369
	test/py/cmdlib/instance_migration_unittest.py \
1370
	test/py/cmdlib/instance_query_unittest.py \
1371
	test/py/cmdlib/instance_storage_unittest.py \
1372
	test/py/cmdlib/node_unittest.py \
1373
	test/py/cmdlib/test_unittest.py \
1374
	test/py/cfgupgrade_unittest.py \
1375
	test/py/docs_unittest.py \
1376
	test/py/ganeti.asyncnotifier_unittest.py \
1377
	test/py/ganeti.backend_unittest-runasroot.py \
1378
	test/py/ganeti.backend_unittest.py \
1379
	test/py/ganeti.bootstrap_unittest.py \
1380
	test/py/ganeti.cli_unittest.py \
1381
	test/py/ganeti.client.gnt_cluster_unittest.py \
1382
	test/py/ganeti.client.gnt_instance_unittest.py \
1383
	test/py/ganeti.client.gnt_job_unittest.py \
1384
	test/py/ganeti.compat_unittest.py \
1385
	test/py/ganeti.confd.client_unittest.py \
1386
	test/py/ganeti.config_unittest.py \
1387
	test/py/ganeti.constants_unittest.py \
1388
	test/py/ganeti.daemon_unittest.py \
1389
	test/py/ganeti.errors_unittest.py \
1390
	test/py/ganeti.hooks_unittest.py \
1391
	test/py/ganeti.ht_unittest.py \
1392
	test/py/ganeti.http_unittest.py \
1393
	test/py/ganeti.hypervisor.hv_chroot_unittest.py \
1394
	test/py/ganeti.hypervisor.hv_fake_unittest.py \
1395
	test/py/ganeti.hypervisor.hv_kvm_unittest.py \
1396
	test/py/ganeti.hypervisor.hv_lxc_unittest.py \
1397
	test/py/ganeti.hypervisor.hv_xen_unittest.py \
1398
	test/py/ganeti.hypervisor_unittest.py \
1399
	test/py/ganeti.impexpd_unittest.py \
1400
	test/py/ganeti.jqueue_unittest.py \
1401
	test/py/ganeti.jstore_unittest.py \
1402
	test/py/ganeti.locking_unittest.py \
1403
	test/py/ganeti.luxi_unittest.py \
1404
	test/py/ganeti.masterd.iallocator_unittest.py \
1405
	test/py/ganeti.masterd.instance_unittest.py \
1406
	test/py/ganeti.mcpu_unittest.py \
1407
	test/py/ganeti.netutils_unittest.py \
1408
	test/py/ganeti.objects_unittest.py \
1409
	test/py/ganeti.opcodes_unittest.py \
1410
	test/py/ganeti.outils_unittest.py \
1411
	test/py/ganeti.ovf_unittest.py \
1412
	test/py/ganeti.qlang_unittest.py \
1413
	test/py/ganeti.query_unittest.py \
1414
	test/py/ganeti.rapi.baserlib_unittest.py \
1415
	test/py/ganeti.rapi.client_unittest.py \
1416
	test/py/ganeti.rapi.resources_unittest.py \
1417
	test/py/ganeti.rapi.rlib2_unittest.py \
1418
	test/py/ganeti.rapi.testutils_unittest.py \
1419
	test/py/ganeti.rpc_unittest.py \
1420
	test/py/ganeti.runtime_unittest.py \
1421
	test/py/ganeti.serializer_unittest.py \
1422
	test/py/ganeti.server.rapi_unittest.py \
1423
	test/py/ganeti.ssconf_unittest.py \
1424
	test/py/ganeti.ssh_unittest.py \
1425
	test/py/ganeti.storage.bdev_unittest.py \
1426
	test/py/ganeti.storage.container_unittest.py \
1427
	test/py/ganeti.storage.drbd_unittest.py \
1428
	test/py/ganeti.storage.filestorage_unittest.py \
1429
	test/py/ganeti.tools.burnin_unittest.py \
1430
	test/py/ganeti.tools.ensure_dirs_unittest.py \
1431
	test/py/ganeti.tools.node_daemon_setup_unittest.py \
1432
	test/py/ganeti.tools.prepare_node_join_unittest.py \
1433
	test/py/ganeti.uidpool_unittest.py \
1434
	test/py/ganeti.utils.algo_unittest.py \
1435
	test/py/ganeti.utils.filelock_unittest.py \
1436
	test/py/ganeti.utils.hash_unittest.py \
1437
	test/py/ganeti.utils.io_unittest-runasroot.py \
1438
	test/py/ganeti.utils.io_unittest.py \
1439
	test/py/ganeti.utils.log_unittest.py \
1440
	test/py/ganeti.utils.lvm_unittest.py \
1441
	test/py/ganeti.utils.mlock_unittest.py \
1442
	test/py/ganeti.utils.nodesetup_unittest.py \
1443
	test/py/ganeti.utils.process_unittest.py \
1444
	test/py/ganeti.utils.retry_unittest.py \
1445
	test/py/ganeti.utils.storage_unittest.py \
1446
	test/py/ganeti.utils.text_unittest.py \
1447
	test/py/ganeti.utils.version_unittest.py \
1448
	test/py/ganeti.utils.wrapper_unittest.py \
1449
	test/py/ganeti.utils.x509_unittest.py \
1450
	test/py/ganeti.utils_unittest.py \
1451
	test/py/ganeti.vcluster_unittest.py \
1452
	test/py/ganeti.workerpool_unittest.py \
1453
	test/py/pycurl_reset_unittest.py \
1454
	test/py/qa.qa_config_unittest.py \
1455
	test/py/tempfile_fork_unittest.py
1456

    
1457
python_test_support = \
1458
	test/py/__init__.py \
1459
	test/py/lockperf.py \
1460
	test/py/testutils.py \
1461
	test/py/mocks.py \
1462
	test/py/cmdlib/__init__.py \
1463
	test/py/cmdlib/testsupport/__init__.py \
1464
	test/py/cmdlib/testsupport/cmdlib_testcase.py \
1465
	test/py/cmdlib/testsupport/config_mock.py \
1466
	test/py/cmdlib/testsupport/iallocator_mock.py \
1467
	test/py/cmdlib/testsupport/lock_manager_mock.py \
1468
	test/py/cmdlib/testsupport/netutils_mock.py \
1469
	test/py/cmdlib/testsupport/processor_mock.py \
1470
	test/py/cmdlib/testsupport/rpc_runner_mock.py \
1471
	test/py/cmdlib/testsupport/ssh_mock.py \
1472
	test/py/cmdlib/testsupport/utils_mock.py \
1473
	test/py/cmdlib/testsupport/util.py
1474

    
1475
haskell_tests = test/hs/htest
1476

    
1477
dist_TESTS = \
1478
	test/py/check-cert-expired_unittest.bash \
1479
	test/py/daemon-util_unittest.bash \
1480
	test/py/ganeti-cleaner_unittest.bash \
1481
	test/py/import-export_unittest.bash \
1482
	test/py/cli-test.bash \
1483
	test/py/bash_completion.bash
1484

    
1485
if PY_UNIT
1486
dist_TESTS += $(python_tests)
1487
endif
1488

    
1489
nodist_TESTS =
1490
check_SCRIPTS =
1491

    
1492
if WANT_HSTESTS
1493
nodist_TESTS += $(haskell_tests)
1494
dist_TESTS += test/hs/offline-test.sh
1495
check_SCRIPTS += \
1496
	test/hs/hpc-htools \
1497
	test/hs/hpc-mon-collector \
1498
	$(HS_BUILT_TEST_HELPERS)
1499
endif
1500

    
1501
TESTS = $(dist_TESTS) $(nodist_TESTS)
1502

    
1503
# Environment for all tests
1504
PLAIN_TESTS_ENVIRONMENT = \
1505
	PYTHONPATH=.:./test/py \
1506
	TOP_SRCDIR=$(abs_top_srcdir) TOP_BUILDDIR=$(abs_top_builddir) \
1507
	PYTHON=$(PYTHON) FAKEROOT=$(FAKEROOT_PATH) \
1508
	$(RUN_IN_TEMPDIR)
1509

    
1510
# Environment for tests run by automake
1511
TESTS_ENVIRONMENT = \
1512
	$(PLAIN_TESTS_ENVIRONMENT) $(abs_top_srcdir)/autotools/testrunner
1513

    
1514
all_python_code = \
1515
	$(dist_sbin_SCRIPTS) \
1516
	$(python_scripts) \
1517
	$(pkglib_python_scripts) \
1518
	$(nodist_pkglib_python_scripts) \
1519
	$(nodist_tools_python_scripts) \
1520
	$(pkgpython_PYTHON) \
1521
	$(client_PYTHON) \
1522
	$(cmdlib_PYTHON) \
1523
	$(hypervisor_PYTHON) \
1524
	$(storage_PYTHON) \
1525
	$(rapi_PYTHON) \
1526
	$(server_PYTHON) \
1527
	$(pytools_PYTHON) \
1528
	$(http_PYTHON) \
1529
	$(confd_PYTHON) \
1530
	$(masterd_PYTHON) \
1531
	$(impexpd_PYTHON) \
1532
	$(utils_PYTHON) \
1533
	$(watcher_PYTHON) \
1534
	$(noinst_PYTHON) \
1535
	$(qa_scripts)
1536

    
1537
if PY_UNIT
1538
all_python_code += $(python_tests)
1539
all_python_code += $(python_test_support)
1540
endif
1541

    
1542
srclink_files = \
1543
	man/footer.rst \
1544
	test/py/check-cert-expired_unittest.bash \
1545
	test/py/daemon-util_unittest.bash \
1546
	test/py/ganeti-cleaner_unittest.bash \
1547
	test/py/import-export_unittest.bash \
1548
	test/py/cli-test.bash \
1549
	test/py/bash_completion.bash \
1550
	test/hs/offline-test.sh \
1551
	test/hs/cli-tests-defs.sh \
1552
	$(all_python_code) \
1553
	$(HS_LIBTEST_SRCS) $(HS_PROG_SRCS) \
1554
	$(docinput)
1555

    
1556
check_python_code = \
1557
	$(BUILD_BASH_COMPLETION) \
1558
	$(CHECK_IMPORTS) \
1559
	$(CHECK_HEADER) \
1560
	$(DOCPP) \
1561
	$(all_python_code)
1562

    
1563
lint_python_code = \
1564
	ganeti \
1565
	ganeti/http/server.py \
1566
	$(dist_sbin_SCRIPTS) \
1567
	$(python_scripts) \
1568
	$(pkglib_python_scripts) \
1569
	$(BUILD_BASH_COMPLETION) \
1570
	$(CHECK_IMPORTS) \
1571
	$(CHECK_HEADER) \
1572
	$(DOCPP) \
1573
	$(gnt_python_sbin_SCRIPTS) \
1574
	$(PYTHON_BOOTSTRAP)
1575

    
1576
standalone_python_modules = \
1577
	lib/rapi/client.py \
1578
	tools/ganeti-listrunner
1579

    
1580
pep8_python_code = \
1581
	ganeti \
1582
	ganeti/http/server.py \
1583
	$(dist_sbin_SCRIPTS) \
1584
	$(python_scripts) \
1585
	$(pkglib_python_scripts) \
1586
	$(BUILD_BASH_COMPLETION) \
1587
	$(CHECK_HEADER) \
1588
	$(DOCPP) \
1589
	$(PYTHON_BOOTSTRAP) \
1590
	$(gnt_python_sbin_SCRIPTS) \
1591
	qa \
1592
	$(python_test_support)
1593

    
1594
test/py/daemon-util_unittest.bash: daemons/daemon-util
1595

    
1596
test/py/ganeti-cleaner_unittest.bash: daemons/ganeti-cleaner
1597

    
1598
test/py/bash_completion.bash: doc/examples/bash_completion-debug
1599

    
1600
tools/kvm-ifup: tools/kvm-ifup.in $(REPLACE_VARS_SED)
1601
	sed -f $(REPLACE_VARS_SED) < $< > $@
1602
	chmod +x $@
1603

    
1604
tools/vif-ganeti: tools/vif-ganeti.in $(REPLACE_VARS_SED)
1605
	sed -f $(REPLACE_VARS_SED) < $< > $@
1606
	chmod +x $@
1607

    
1608
tools/net-common: tools/net-common.in $(REPLACE_VARS_SED)
1609
	sed -f $(REPLACE_VARS_SED) < $< > $@
1610
	chmod +x $@
1611

    
1612
tools/users-setup: Makefile $(userspecs)
1613
	set -e; \
1614
	{ echo '#!/bin/sh'; \
1615
	  echo 'if [ "x$$1" != "x--yes-do-it" ];'; \
1616
	  echo 'then echo "This will do the following changes"'; \
1617
	  $(AWK) -- '{print "echo + Will add group ",$$1; count++}\
1618
	             END {if (count == 0) {print "echo + No groups to add"}}' doc/users/groups; \
1619
	  $(AWK) -- '{if (NF > 1) {print "echo + Will add user",$$1,"with primary group",$$2} \
1620
	                          else {print "echo + Will add user",$$1}; count++}\
1621
	             END {if (count == 0) {print "echo + No users to add"}}' doc/users/users; \
1622
	  $(AWK) -- '{print "echo + Will add user",$$1,"to group",$$2}' doc/users/groupmemberships; \
1623
	  echo 'echo'; \
1624
	  echo 'echo "OK? (y/n)"'; \
1625
	  echo 'read confirm'; \
1626
	  echo 'if [ "x$$confirm" != "xy" ]; then exit 0; fi'; \
1627
	  echo 'fi'; \
1628
	  $(AWK) -- '{print "addgroup --system",$$1}' doc/users/groups; \
1629
	  $(AWK) -- '{if (NF > 1) {print "adduser --system --ingroup",$$2,$$1} else {print "adduser --system",$$1}}' doc/users/users; \
1630
	  $(AWK) -- '{print "adduser",$$1,$$2}' doc/users/groupmemberships; \
1631
	} > $@
1632
	chmod +x $@
1633

    
1634
tools/vcluster-setup: tools/vcluster-setup.in $(REPLACE_VARS_SED)
1635
	sed -f $(REPLACE_VARS_SED) < $< > $@
1636
	chmod +x $@
1637

    
1638
daemons/%:: daemons/%.in $(REPLACE_VARS_SED)
1639
	sed -f $(REPLACE_VARS_SED) < $< > $@
1640
	chmod +x $@
1641

    
1642
doc/examples/%:: doc/examples/%.in $(REPLACE_VARS_SED)
1643
	sed -f $(REPLACE_VARS_SED) < $< > $@
1644

    
1645
doc/examples/bash_completion: BC_ARGS = --compact
1646
doc/examples/bash_completion-debug: BC_ARGS =
1647

    
1648
doc/examples/bash_completion doc/examples/bash_completion-debug: \
1649
	$(BUILD_BASH_COMPLETION) $(RUN_IN_TEMPDIR) \
1650
	lib/cli.py $(gnt_scripts) $(client_PYTHON) tools/burnin \
1651
	daemons/ganeti-cleaner \
1652
	$(GENERATED_FILES) $(HS_GENERATED_FILES)
1653
	PYTHONPATH=. $(RUN_IN_TEMPDIR) \
1654
	  $(CURDIR)/$(BUILD_BASH_COMPLETION) $(BC_ARGS) > $@
1655

    
1656
man/%.gen: man/%.rst lib/query.py lib/build/sphinx_ext.py \
1657
	lib/build/shell_example_lexer.py \
1658
	| $(RUN_IN_TEMPDIR) $(BUILT_PYTHON_SOURCES)
1659
	@echo "Checking $< for hardcoded paths..."
1660
	@if grep -nEf autotools/wrong-hardcoded-paths $<; then \
1661
	  echo "Man page $< has hardcoded paths (see above)!" 1>&2 ; \
1662
	  exit 1; \
1663
	fi
1664
	set -e ; \
1665
	trap 'echo auto-removing $@; rm $@' EXIT; \
1666
	PYTHONPATH=. $(RUN_IN_TEMPDIR) $(CURDIR)/$(DOCPP) < $< > $@ ;\
1667
	$(CHECK_MAN_REFERENCES) $@; \
1668
	trap - EXIT
1669

    
1670
man/%.7.in man/%.8.in man/%.1.in: man/%.gen man/footer.rst
1671
	@test -n "$(PANDOC)" || \
1672
	  { echo 'pandoc' not found during configure; exit 1; }
1673
	set -o pipefail -e; \
1674
	trap 'echo auto-removing $@; rm $@' EXIT; \
1675
	$(PANDOC) -s -f rst -t man $< man/footer.rst | \
1676
	  sed -e 's/\\@/@/g' > $@; \
1677
	if test -n "$(MAN_HAS_WARNINGS)"; then $(CHECK_MAN_WARNINGS) $@; fi; \
1678
	$(CHECK_MAN_DASHES) $@; \
1679
	trap - EXIT
1680

    
1681
man/%.html.in: man/%.gen man/footer.rst
1682
	@test -n "$(PANDOC)" || \
1683
	  { echo 'pandoc' not found during configure; exit 1; }
1684
	set -o pipefail ; \
1685
	$(PANDOC) --toc -s -f rst -t html $< man/footer.rst | \
1686
	  sed -e 's/\\@/@/g' > $@
1687

    
1688
man/%: man/%.in  $(REPLACE_VARS_SED)
1689
	sed -f $(REPLACE_VARS_SED) < $< > $@
1690

    
1691
epydoc.conf: epydoc.conf.in $(REPLACE_VARS_SED)
1692
	sed -f $(REPLACE_VARS_SED) < $< > $@
1693

    
1694
vcs-version:
1695
	if test -d .git; then \
1696
	  git describe > $@; \
1697
	elif test ! -f $@ ; then \
1698
	  echo "Cannot auto-generate $@ file"; exit 1; \
1699
	fi
1700

    
1701
.PHONY: clean-vcs-version
1702
clean-vcs-version:
1703
	rm -f vcs-version
1704

    
1705
.PHONY: regen-vcs-version
1706
regen-vcs-version:
1707
	@set -e; \
1708
	cd $(srcdir); \
1709
	if test -d .git; then \
1710
	  T=`mktemp` ; trap 'rm -f $$T' EXIT; \
1711
	  git describe > $$T; \
1712
	  if ! cmp --quiet $$T vcs-version; then \
1713
	    mv $$T vcs-version; \
1714
	  fi; \
1715
	fi
1716

    
1717
src/Ganeti/Version.hs: src/Ganeti/Version.hs.in \
1718
	vcs-version $(built_base_sources)
1719
	set -e; \
1720
	VCSVER=`cat $(abs_top_srcdir)/vcs-version`; \
1721
	sed -e "s/%ver%/$$VCSVER/" < $< > $@
1722

    
1723
src/Ganeti/Hs2Py/ListConstants.hs: src/Ganeti/Hs2Py/ListConstants.hs.in \
1724
				   src/Ganeti/Constants.hs \
1725
			         | stamp-directories
1726
	@echo Generating $@
1727
	@set -e; \
1728
## Extract constant names from 'Constants.hs' by extracting the left
1729
## side of all lines containing an equal sign (i.e., '=') and
1730
## prepending the apostrophe sign (i.e., "'").
1731
##
1732
## For example, the constant
1733
##   adminstDown = ...
1734
## becomes
1735
##   'adminstDown
1736
	NAMES=$$(sed -e "/^--/ d" $(abs_top_srcdir)/src/Ganeti/Constants.hs |\
1737
		 sed -n -e "/=/ s/\(.*\) =.*/    '\1:/g p"); \
1738
	m4 -DPY_CONSTANT_NAMES="$$NAMES" $(abs_top_srcdir)/$< > $@
1739

    
1740
src/Ganeti/Curl/Internal.hs: src/Ganeti/Curl/Internal.hsc | stamp-directories
1741
	hsc2hs -o $@ $<
1742

    
1743
test/hs/Test/Ganeti/TestImports.hs: test/hs/Test/Ganeti/TestImports.hs.in \
1744
	$(built_base_sources)
1745
	set -e; \
1746
	{ cat $< ; \
1747
	  echo ; \
1748
	  for name in $(filter-out Ganeti.THH,$(subst /,.,$(patsubst %.hs,%,$(patsubst src/%,%,$(HS_LIB_SRCS))))) ; do \
1749
	    echo "import $$name ()" ; \
1750
	  done ; \
1751
	} > $@
1752

    
1753
lib/_constants.py: Makefile src/hs2py lib/_constants.py.in | stamp-directories
1754
	cat $(abs_top_srcdir)/lib/_constants.py.in > $@
1755
	src/hs2py --constants >> $@
1756

    
1757
lib/constants.py: lib/_constants.py
1758

    
1759
src/AutoConf.hs: Makefile src/AutoConf.hs.in $(PRINT_PY_CONSTANTS) \
1760
	       | $(built_base_sources)
1761
	@echo "m4 ... >" $@
1762
	@m4 -DPACKAGE_VERSION="$(PACKAGE_VERSION)" \
1763
	    -DVERSION_MAJOR="$(VERSION_MAJOR)" \
1764
	    -DVERSION_MINOR="$(VERSION_MINOR)" \
1765
	    -DVERSION_REVISION="$(VERSION_REVISION)" \
1766
	    -DVERSION_SUFFIX="$(VERSION_SUFFIX)" \
1767
	    -DVERSION_FULL="$(VERSION_FULL)" \
1768
	    -DDIRVERSION="$(DIRVERSION)" \
1769
	    -DLOCALSTATEDIR="$(localstatedir)" \
1770
	    -DSYSCONFDIR="$(sysconfdir)" \
1771
	    -DSSH_CONFIG_DIR="$(SSH_CONFIG_DIR)" \
1772
	    -DSSH_LOGIN_USER="$(SSH_LOGIN_USER)" \
1773
	    -DSSH_CONSOLE_USER="$(SSH_CONSOLE_USER)" \
1774
	    -DEXPORT_DIR="$(EXPORT_DIR)" \
1775
	    -DOS_SEARCH_PATH="\"$(OS_SEARCH_PATH)\"" \
1776
	    -DES_SEARCH_PATH="\"$(ES_SEARCH_PATH)\"" \
1777
	    -DXEN_BOOTLOADER="$(XEN_BOOTLOADER)" \
1778
	    -DXEN_CONFIG_DIR="$(XEN_CONFIG_DIR)" \
1779
	    -DXEN_KERNEL="$(XEN_KERNEL)" \
1780
	    -DXEN_INITRD="$(XEN_INITRD)" \
1781
	    -DKVM_KERNEL="$(KVM_KERNEL)" \
1782
	    -DSHARED_FILE_STORAGE_DIR="$(SHARED_FILE_STORAGE_DIR)" \
1783
	    -DIALLOCATOR_SEARCH_PATH="\"$(IALLOCATOR_SEARCH_PATH)\"" \
1784
	    -DKVM_PATH="$(KVM_PATH)" \
1785
	    -DIP_PATH="$(IP_PATH)" \
1786
	    -DSOCAT_PATH="$(SOCAT)" \
1787
	    -DSOCAT_USE_ESCAPE="$(SOCAT_USE_ESCAPE)" \
1788
	    -DSOCAT_USE_COMPRESS="$(SOCAT_USE_COMPRESS)" \
1789
	    -DLVM_STRIPECOUNT="$(LVM_STRIPECOUNT)" \
1790
	    -DTOOLSDIR="$(libdir)/ganeti/tools" \
1791
	    -DGNT_SCRIPTS="$(foreach i,$(notdir $(gnt_scripts)),\"$(i)\":)" \
1792
	    -DHS_HTOOLS_PROGS="$(foreach i,$(HS_HTOOLS_PROGS),\"$(i)\":)" \
1793
	    -DPKGLIBDIR="$(libdir)/ganeti" \
1794
	    -DSHAREDIR="$(prefix)/share/ganeti" \
1795
	    -DVERSIONEDSHAREDIR="$(versionedsharedir)" \
1796
	    -DDRBD_BARRIERS="$(DRBD_BARRIERS)" \
1797
	    -DDRBD_NO_META_FLUSH="$(DRBD_NO_META_FLUSH)" \
1798
	    -DSYSLOG_USAGE="$(SYSLOG_USAGE)" \
1799
	    -DDAEMONS_GROUP="$(DAEMONS_GROUP)" \
1800
	    -DADMIN_GROUP="$(ADMIN_GROUP)" \
1801
	    -DMASTERD_USER="$(MASTERD_USER)" \
1802
	    -DMASTERD_GROUP="$(MASTERD_GROUP)" \
1803
	    -DRAPI_USER="$(RAPI_USER)" \
1804
	    -DRAPI_GROUP="$(RAPI_GROUP)" \
1805
	    -DCONFD_USER="$(CONFD_USER)" \
1806
	    -DCONFD_GROUP="$(CONFD_GROUP)" \
1807
	    -DLUXID_USER="$(LUXID_USER)" \
1808
	    -DLUXID_GROUP="$(LUXID_GROUP)" \
1809
	    -DNODED_USER="$(NODED_USER)" \
1810
	    -DNODED_GROUP="$(NODED_GROUP)" \
1811
	    -DMOND_USER="$(MOND_USER)" \
1812
	    -DMOND_GROUP="$(MOND_GROUP)" \
1813
	    -DDISK_SEPARATOR="$(DISK_SEPARATOR)" \
1814
	    -DQEMUIMG_PATH="$(QEMUIMG_PATH)" \
1815
	    -DHTOOLS="True" \
1816
	    -DENABLE_CONFD="$(ENABLE_CONFD)" \
1817
	    -DXEN_CMD="$(XEN_CMD)" \
1818
	    -DENABLE_SPLIT_QUERY="$(ENABLE_SPLIT_QUERY)" \
1819
	    -DENABLE_RESTRICTED_COMMANDS="$(ENABLE_RESTRICTED_COMMANDS)" \
1820
	    -DENABLE_MOND="$(ENABLE_MOND)" \
1821
	    -DHAS_GNU_LN="$(HAS_GNU_LN)" \
1822
	    -DMAN_PAGES="$$(for i in $(notdir $(man_MANS)); do \
1823
	                    echo -n "$$i" | sed -re 's/^(.*)\.([0-9]+)$$/("\1",\2):/g'; \
1824
	                    done)" \
1825
	    -DAF_INET4="$$(PYTHONPATH=. python $(PRINT_PY_CONSTANTS) AF_INET4)" \
1826
	    -DAF_INET6="$$(PYTHONPATH=. python $(PRINT_PY_CONSTANTS) AF_INET6)" \
1827
	$(abs_top_srcdir)/src/AutoConf.hs.in > $@
1828

    
1829
lib/_vcsversion.py: Makefile vcs-version | stamp-directories
1830
	set -e; \
1831
	VCSVER=`cat $(abs_top_srcdir)/vcs-version`; \
1832
	{ echo '# This file is automatically generated, do not edit!'; \
1833
	  echo '#'; \
1834
	  echo ''; \
1835
	  echo '"""Build-time VCS version number for Ganeti.'; \
1836
	  echo '';\
1837
	  echo 'This file is autogenerated by the build process.'; \
1838
	  echo 'For any changes you need to re-run ./configure (and'; \
1839
	  echo 'not edit by hand).'; \
1840
	  echo ''; \
1841
	  echo '"""'; \
1842
	  echo ''; \
1843
	  echo '# pylint: disable=C0301,C0324'; \
1844
	  echo '# because this is autogenerated, we do not want'; \
1845
	  echo '# style warnings' ; \
1846
	  echo ''; \
1847
	  echo "VCS_VERSION = '$$VCSVER'"; \
1848
	} > $@
1849

    
1850
lib/opcodes.py: Makefile src/hs2py lib/opcodes.py.in_before \
1851
		lib/opcodes.py.in_after | stamp-directories
1852
	cat $(abs_top_srcdir)/lib/opcodes.py.in_before > $@
1853
	src/hs2py --opcodes >> $@
1854
	cat $(abs_top_srcdir)/lib/opcodes.py.in_after >> $@
1855

    
1856
lib/_generated_rpc.py: lib/rpc_defs.py $(BUILD_RPC)
1857
	PYTHONPATH=. $(RUN_IN_TEMPDIR) $(CURDIR)/$(BUILD_RPC) lib/rpc_defs.py > $@
1858

    
1859
$(SHELL_ENV_INIT): Makefile stamp-directories
1860
	set -e; \
1861
	{ echo '# Allow overriding for tests'; \
1862
	  echo 'readonly LOCALSTATEDIR=$${LOCALSTATEDIR:-$${GANETI_ROOTDIR:-}$(localstatedir)}'; \
1863
	  echo 'readonly SYSCONFDIR=$${SYSCONFDIR:-$${GANETI_ROOTDIR:-}$(sysconfdir)}'; \
1864
	  echo; \
1865
	  echo 'readonly PKGLIBDIR=$(libdir)/ganeti'; \
1866
	  echo 'readonly LOG_DIR="$$LOCALSTATEDIR/log/ganeti"'; \
1867
	  echo 'readonly RUN_DIR="$$LOCALSTATEDIR/run/ganeti"'; \
1868
	  echo 'readonly DATA_DIR="$$LOCALSTATEDIR/lib/ganeti"'; \
1869
	  echo 'readonly CONF_DIR="$$SYSCONFDIR/ganeti"'; \
1870
	} > $@
1871

    
1872
## Writes sed script to replace placeholders with build-time values. The
1873
## additional quotes after the first @ sign are necessary to stop configure
1874
## from replacing those values as well.
1875
$(REPLACE_VARS_SED): $(SHELL_ENV_INIT) Makefile stamp-directories
1876
	set -e; \
1877
	{ echo 's#@''PREFIX@#$(prefix)#g'; \
1878
	  echo 's#@''SYSCONFDIR@#$(sysconfdir)#g'; \
1879
	  echo 's#@''LOCALSTATEDIR@#$(localstatedir)#g'; \
1880
	  echo 's#@''BINDIR@#$(BINDIR)#g'; \
1881
	  echo 's#@''SBINDIR@#$(SBINDIR)#g'; \
1882
	  echo 's#@''LIBDIR@#$(libdir)#g'; \
1883
	  echo 's#@''GANETI_VERSION@#$(PACKAGE_VERSION)#g'; \
1884
	  echo 's#@''CUSTOM_XEN_BOOTLOADER@#$(XEN_BOOTLOADER)#g'; \
1885
	  echo 's#@''CUSTOM_XEN_KERNEL@#$(XEN_KERNEL)#g'; \
1886
	  echo 's#@''CUSTOM_XEN_INITRD@#$(XEN_INITRD)#g'; \
1887
	  echo 's#@''CUSTOM_IALLOCATOR_SEARCH_PATH@#$(IALLOCATOR_SEARCH_PATH)#g'; \
1888
	  echo 's#@''CUSTOM_EXPORT_DIR@#$(EXPORT_DIR)#g'; \
1889
	  echo 's#@''RPL_SSH_INITD_SCRIPT@#$(SSH_INITD_SCRIPT)#g'; \
1890
	  echo 's#@''PKGLIBDIR@#$(libdir)/ganeti#g'; \
1891
	  echo 's#@''GNTMASTERUSER@#$(MASTERD_USER)#g'; \
1892
	  echo 's#@''GNTRAPIUSER@#$(RAPI_USER)#g'; \
1893
	  echo 's#@''GNTCONFDUSER@#$(CONFD_USER)#g'; \
1894
	  echo 's#@''GNTLUXIDUSER@#$(LUXID_USER)#g'; \
1895
	  echo 's#@''GNTNODEDUSER@#$(NODED_USER)#g'; \
1896
	  echo 's#@''GNTMONDUSER@#$(MOND_USER)#g'; \
1897
	  echo 's#@''GNTRAPIGROUP@#$(RAPI_GROUP)#g'; \
1898
	  echo 's#@''GNTADMINGROUP@#$(ADMIN_GROUP)#g'; \
1899
	  echo 's#@''GNTCONFDGROUP@#$(CONFD_GROUP)#g'; \
1900
	  echo 's#@''GNTLUXIDGROUP@#$(LUXID_GROUP)#g'; \
1901
	  echo 's#@''GNTMASTERDGROUP@#$(MASTERD_GROUP)#g'; \
1902
	  echo 's#@''GNTMONDGROUP@#$(MOND_GROUP)#g'; \
1903
	  echo 's#@''GNTDAEMONSGROUP@#$(DAEMONS_GROUP)#g'; \
1904
	  echo 's#@''CUSTOM_ENABLE_CONFD@#$(ENABLE_CONFD)#g'; \
1905
	  echo 's#@''CUSTOM_ENABLE_MOND@#$(ENABLE_MOND)#g'; \
1906
	  echo 's#@''MODULES@#$(strip $(lint_python_code))#g'; \
1907
	  echo 's#@''XEN_CONFIG_DIR@#$(XEN_CONFIG_DIR)#g'; \
1908
	  echo; \
1909
	  echo '/^@SHELL_ENV_INIT@$$/ {'; \
1910
	  echo '  r $(SHELL_ENV_INIT)'; \
1911
	  echo '  d'; \
1912
	  echo '}'; \
1913
	} > $@
1914

    
1915
# Using deferred evaluation
1916
daemons/ganeti-%: MODULE = ganeti.server.$(patsubst ganeti-%,%,$(notdir $@))
1917
daemons/ganeti-watcher: MODULE = ganeti.watcher
1918
scripts/%: MODULE = ganeti.client.$(subst -,_,$(notdir $@))
1919
tools/burnin: MODULE = ganeti.tools.burnin
1920
tools/ensure-dirs: MODULE = ganeti.tools.ensure_dirs
1921
tools/node-daemon-setup: MODULE = ganeti.tools.node_daemon_setup
1922
tools/prepare-node-join: MODULE = ganeti.tools.prepare_node_join
1923
tools/node-cleanup: MODULE = ganeti.tools.node_cleanup
1924
$(HS_BUILT_TEST_HELPERS): TESTROLE = $(patsubst test/hs/%,%,$@)
1925

    
1926
$(PYTHON_BOOTSTRAP) $(gnt_scripts) $(gnt_python_sbin_SCRIPTS): Makefile | stamp-directories
1927
	test -n "$(MODULE)" || { echo Missing module; exit 1; }
1928
	set -e; \
1929
	{ echo '#!/usr/bin/python'; \
1930
	  echo '# This file is automatically generated, do not edit!'; \
1931
	  echo "# Edit $(MODULE) instead."; \
1932
	  echo; \
1933
	  echo '"""Bootstrap script for L{$(MODULE)}"""'; \
1934
	  echo; \
1935
	  echo '# pylint: disable=C0103'; \
1936
	  echo '# C0103: Invalid name'; \
1937
	  echo; \
1938
	  echo 'import sys'; \
1939
	  echo 'import $(MODULE) as main'; \
1940
	  echo; \
1941
	  echo '# Temporarily alias commands until bash completion'; \
1942
	  echo '# generator is changed'; \
1943
	  echo 'if hasattr(main, "commands"):'; \
1944
	  echo '  commands = main.commands # pylint: disable=E1101'; \
1945
	  echo 'if hasattr(main, "aliases"):'; \
1946
	  echo '  aliases = main.aliases # pylint: disable=E1101'; \
1947
	  echo; \
1948
	  echo 'if __name__ == "__main__":'; \
1949
	  echo '  sys.exit(main.Main())'; \
1950
	} > $@
1951
	chmod u+x $@
1952

    
1953
$(HS_BUILT_TEST_HELPERS): Makefile
1954
	@test -n "$(TESTROLE)" || { echo Missing TESTROLE; exit 1; }
1955
	set -e; \
1956
	{ echo '#!/bin/sh'; \
1957
	  echo '# This file is automatically generated, do not edit!'; \
1958
	  echo "# Edit Makefile.am instead."; \
1959
	  echo; \
1960
	  echo "HTOOLS=$(TESTROLE) exec ./test/hs/hpc-htools \"\$$@\""; \
1961
	} > $@
1962
	chmod u+x $@
1963

    
1964
stamp-directories: Makefile
1965
	$(MAKE) $(AM_MAKEFLAGS) ganeti
1966
	@mkdir_p@ $(DIRS) $(BUILDTIME_DIR_AUTOCREATE)
1967
	touch $@
1968

    
1969
# We need to create symlinks because "make distcheck" will not install Python
1970
# files when building.
1971
stamp-srclinks: Makefile | stamp-directories
1972
	set -e; \
1973
	for i in $(srclink_files); do \
1974
	  if test ! -f $$i -a -f $(abs_top_srcdir)/$$i; then \
1975
	    $(LN_S) $(abs_top_srcdir)/$$i $$i; \
1976
	  fi; \
1977
	done
1978
	touch $@
1979

    
1980
.PHONY: ganeti
1981
ganeti:
1982
	cd $(top_builddir) && test -h "$@" || { rm -f $@ && $(LN_S) lib $@; }
1983

    
1984
.PHONY: check-dirs
1985
check-dirs: $(GENERATED_FILES)
1986
	@set -e; \
1987
	find . -type d \( -name . -o -name .git -prune -o -print \) | { \
1988
	  error=; \
1989
	  while read dir; do \
1990
	    case "$$dir" in \
1991
	      $(strip $(patsubst %,(./%) ;;,$(DIRCHECK_EXCLUDE) $(DIRS))) \
1992
	      *) error=1; echo "Directory $$dir not listed in Makefile" >&2 ;; \
1993
	    esac; \
1994
	  done; \
1995
	  for dir in $(DIRS); do \
1996
	    if ! test -d "$$dir"; then \
1997
	      echo "Directory $$dir listed in DIRS does not exist" >&2; \
1998
	      error=1; \
1999
	    fi \
2000
	  done; \
2001
	  test -z "$$error"; \
2002
	}
2003

    
2004
.PHONY: check-news
2005
check-news:
2006
	RELEASE=$(PACKAGE_VERSION) $(CHECK_NEWS) < $(top_srcdir)/NEWS
2007

    
2008
.PHONY: check-local
2009
check-local: check-dirs check-news $(GENERATED_FILES)
2010
	$(CHECK_PYTHON_CODE) $(check_python_code)
2011
	PYTHONPATH=. $(CHECK_HEADER) $(check_python_code)
2012
	$(CHECK_VERSION) $(VERSION) $(top_srcdir)/NEWS
2013
	PYTHONPATH=. $(RUN_IN_TEMPDIR) $(CURDIR)/$(CHECK_IMPORTS) . $(standalone_python_modules)
2014
	error= ; \
2015
	if [ "x`echo $(VERSION_SUFFIX)|grep 'alpha'`" == "x" ]; then \
2016
	  expver=$(VERSION_MAJOR).$(VERSION_MINOR); \
2017
	  if test "`head -n 1 $(top_srcdir)/README`" != "Ganeti $$expver"; then \
2018
	    echo "Incorrect version in README, expected $$expver" >&2; \
2019
	    error=1; \
2020
	  fi; \
2021
	  for file in doc/iallocator.rst doc/hooks.rst doc/virtual-cluster.rst \
2022
	      doc/security.rst; do \
2023
	    if test "`sed -ne '4 p' $(top_srcdir)/$$file`" != \
2024
	      "Documents Ganeti version $$expver"; then \
2025
	      echo "Incorrect version in $$file, expected $$expver" >&2; \
2026
	      error=1; \
2027
	    fi; \
2028
	  done; \
2029
	  if ! test -f $(top_srcdir)/doc/design-$$expver.rst; then \
2030
	    echo "File $(top_srcdir)/doc/design-$$expver.rst not found" >&2; \
2031
	    error=1; \
2032
	  fi; \
2033
	  if test "`sed -ne '5 p' $(top_srcdir)/doc/design-draft.rst`" != \
2034
	    ".. Last updated for Ganeti $$expver"; then \
2035
	    echo "doc/design-draft.rst was not updated for version $$expver" >&2; \
2036
	    error=1; \
2037
	  fi; \
2038
	fi; \
2039
	for file in configure.ac $(HS_LIBTEST_SRCS) $(HS_PROG_SRCS); do \
2040
	  if test $$(wc --max-line-length < $(top_srcdir)/$$file) -gt 80; then \
2041
	    echo "Longest line in $$file is longer than 80 characters" >&2; \
2042
	    error=1; \
2043
	  fi; \
2044
	done; \
2045
	test -z "$$error"
2046

    
2047
.PHONY: hs-test-%
2048
hs-test-%: test/hs/htest | $(BUILT_PYTHON_SOURCES)
2049
	@rm -f htest.tix
2050
	test/hs/htest -t $*
2051

    
2052
.PHONY: hs-tests
2053
hs-tests: test/hs/htest | $(BUILT_PYTHON_SOURCES)
2054
	@rm -f htest.tix
2055
	./test/hs/htest
2056

    
2057
.PHONY: hs-shell-%
2058
hs-shell-%: test/hs/hpc-htools test/hs/hpc-mon-collector \
2059
            $(HS_BUILT_TEST_HELPERS)
2060
	@rm -f hpc-htools.tix hpc-mon-collector.tix
2061
	HBINARY="./test/hs/hpc-htools" \
2062
	SHELLTESTARGS=$(SHELLTESTARGS) \
2063
	./test/hs/offline-test.sh $*
2064

    
2065
.PHONY: hs-shell
2066
hs-shell: test/hs/hpc-htools test/hs/hpc-mon-collector $(HS_BUILT_TEST_HELPERS)
2067
	@rm -f hpc-htools.tix hpc-mon-collector.tix
2068
	HBINARY="./test/hs/hpc-htools" \
2069
	SHELLTESTARGS=$(SHELLTESTARGS) \
2070
	./test/hs/offline-test.sh
2071

    
2072
.PHONY: hs-check
2073
hs-check: hs-tests hs-shell
2074

    
2075
# E111: indentation is not a multiple of four
2076
# E121: continuation line indentation is not a multiple of four
2077
#       (since our indent level is not 4)
2078
# E125: continuation line does not distinguish itself from next logical line
2079
#       (since our indent level is not 4)
2080
# E123: closing bracket does not match indentation of opening bracket's line
2081
# E127: continuation line over-indented for visual indent
2082
#       (since our indent level is not 4)
2083
# note: do NOT add E128 here; it's a valid style error in most cases!
2084
# I've seen real errors, but also some cases were we indent wrongly
2085
# due to line length; try to rework the cases where it is triggered,
2086
# instead of silencing it
2087
# E261: at least two spaces before inline comment
2088
# E501: line too long (80 characters)
2089
PEP8_IGNORE = E111,E121,E123,E125,E127,E261,E501
2090

    
2091
# For excluding pep8 expects filenames only, not whole paths
2092
PEP8_EXCLUDE = $(subst $(space),$(comma),$(strip $(notdir $(BUILT_PYTHON_SOURCES))))
2093

    
2094
LINT_TARGETS = pylint pylint-qa pylint-test
2095
if HAS_PEP8
2096
LINT_TARGETS += pep8
2097
endif
2098
if HAS_HLINT
2099
LINT_TARGETS += hlint
2100
endif
2101

    
2102
.PHONY: lint
2103
lint: $(LINT_TARGETS)
2104

    
2105
.PHONY: pylint
2106
pylint: $(GENERATED_FILES)
2107
	@test -n "$(PYLINT)" || { echo 'pylint' not found during configure; exit 1; }
2108
	$(PYLINT) $(LINT_OPTS) $(lint_python_code)
2109

    
2110
.PHONY: pylint-qa
2111
pylint-qa: $(GENERATED_FILES)
2112
	@test -n "$(PYLINT)" || { echo 'pylint' not found during configure; exit 1; }
2113
	cd $(top_srcdir)/qa && \
2114
	  PYTHONPATH=$(abs_top_srcdir) $(PYLINT) $(LINT_OPTS) \
2115
	  --rcfile  ../pylintrc $(patsubst qa/%.py,%,$(qa_scripts))
2116
# FIXME: lint all test code, not just the newly added test support
2117
pylint-test: $(GENERATED_FILES)
2118
	@test -n "$(PYLINT)" || { echo 'pylint' not found during configure; exit 1; }
2119
	cd $(top_srcdir) && \
2120
		PYTHONPATH=.:./test/py $(PYLINT) $(LINT_OPTS) \
2121
		--rcfile=pylintrc-test  $(python_test_support)
2122

    
2123
.PHONY: pep8
2124
pep8: $(GENERATED_FILES)
2125
	@test -n "$(PEP8)" || { echo 'pep8' not found during configure; exit 1; }
2126
	$(PEP8) --ignore='$(PEP8_IGNORE)' --exclude='$(PEP8_EXCLUDE)' \
2127
	  --repeat $(pep8_python_code)
2128

    
2129
# FIXME: remove ignore "Use void" when GHC 6.x is deprecated
2130
HLINT_EXCLUDES = src/Ganeti/THH.hs test/hs/hpc-htools.hs
2131
.PHONY: hlint
2132
hlint: $(HS_BUILT_SRCS) src/lint-hints.hs
2133
	@test -n "$(HLINT)" || { echo 'hlint' not found during configure; exit 1; }
2134
	@rm -f doc/hs-lint.html
2135
	if tty -s; then C="-c"; else C=""; fi; \
2136
	$(HLINT) --utf8 --report=doc/hs-lint.html --cross $$C \
2137
	  --ignore "Use first" \
2138
	  --ignore "Use &&&" \
2139
	  --ignore "Use void" \
2140
	  --ignore "Reduce duplication" \
2141
	  --hint src/lint-hints \
2142
	  $(filter-out $(HLINT_EXCLUDES),$(HS_LIBTEST_SRCS) $(HS_PROG_SRCS))
2143
	@if [ ! -f doc/hs-lint.html ]; then \
2144
	  echo "All good" > doc/hs-lint.html; \
2145
	fi
2146

    
2147
# a dist hook rule for updating the vcs-version file; this is
2148
# hardcoded due to where it needs to build the file...
2149
dist-hook:
2150
	$(MAKE) $(AM_MAKEFLAGS) regen-vcs-version
2151
	rm -f $(top_distdir)/vcs-version
2152
	cp -p $(srcdir)/vcs-version $(top_distdir)
2153

    
2154
# a distcheck hook rule for catching revision control directories
2155
distcheck-hook:
2156
	if find $(top_distdir) -name .svn -or -name .git | grep .; then \
2157
	  echo "Found revision control files in final archive." 1>&2; \
2158
	  exit 1; \
2159
	fi
2160
	if find $(top_distdir) -name '*.py[co]' | grep .; then \
2161
	  echo "Found Python byte code in final archive." 1>&2; \
2162
	  exit 1; \
2163
	fi
2164
	if find $(top_distdir) -name '*~' | grep .; then \
2165
	  echo "Found backup files in final archive." 1>&2; \
2166
	  exit 1; \
2167
	fi
2168
# Empty files or directories should not be distributed. They can cause
2169
# unnecessary warnings for packagers. Directories used by automake during
2170
# distcheck must be excluded.
2171
	if find $(top_distdir) -empty -and -not \( \
2172
	    -path $(top_distdir)/_build -or \
2173
	    -path $(top_distdir)/_inst \) | grep .; then \
2174
	  echo "Found empty files or directories in final archive." 1>&2; \
2175
	  exit 1; \
2176
	fi
2177
	if test -e $(top_distdir)/doc/man-html; then \
2178
	  echo "Found documentation including man pages in final archive" >&2; \
2179
	  exit 1; \
2180
	fi
2181

    
2182
# Backwards compatible distcheck-release target
2183
distcheck-release: distcheck
2184

    
2185
distrebuildcheck: dist
2186
	set -e; \
2187
	builddir=$$(mktemp -d $(abs_srcdir)/distrebuildcheck.XXXXXXX); \
2188
	trap "echo Removing $$builddir; cd $(abs_srcdir); rm -rf $$builddir" EXIT; \
2189
	cd $$builddir; \
2190
	tar xzf $(abs_srcdir)/$(distdir).tar.gz; \
2191
	cd $(distdir); \
2192
	./configure; \
2193
	$(MAKE) maintainer-clean; \
2194
	cp $(abs_srcdir)/vcs-version .; \
2195
	./configure; \
2196
	$(MAKE) $(AM_MAKEFLAGS)
2197

    
2198
dist-release: dist
2199
	set -e; \
2200
	for i in $(DIST_ARCHIVES); do \
2201
	  echo -n "Checking $$i ... "; \
2202
	  autotools/check-tar < $$i; \
2203
	  echo OK; \
2204
	done
2205

    
2206
install-exec-local:
2207
	@mkdir_p@ "$(DESTDIR)${localstatedir}/lib/ganeti" \
2208
	  "$(DESTDIR)${localstatedir}/log/ganeti" \
2209
	  "$(DESTDIR)${localstatedir}/run/ganeti"
2210
	for dir in $(SYMLINK_TARGET_DIRS); do \
2211
	  @mkdir_p@  $(DESTDIR)$$dir; \
2212
	done
2213
	$(LN_S) -f $(sysconfdir)/ganeti/lib $(DESTDIR)$(defaultversiondir)
2214
	$(LN_S) -f $(sysconfdir)/ganeti/share $(DESTDIR)$(defaultversionedsharedir)
2215
	for prog in $(HS_BIN_ROLES); do \
2216
	  $(LN_S) -f $(defaultversiondir)$(BINDIR)/$$prog $(DESTDIR)$(BINDIR)/$$prog; \
2217
	done
2218
	$(LN_S) -f $(defaultversiondir)$(libdir)/ganeti/iallocators/hail $(DESTDIR)$(libdir)/ganeti/iallocators/hail
2219
	for prog in $(all_sbin_scripts); do \
2220
	  $(LN_S) -f $(defaultversiondir)$(SBINDIR)/$$prog $(DESTDIR)$(SBINDIR)/$$prog; \
2221
	done
2222
	for prog in $(gnt_scripts_basenames); do \
2223
	  $(LN_S) -f $(defaultversionedsharedir)/$$prog $(DESTDIR)$(SBINDIR)/$$prog; \
2224
	done
2225
	for prog in $(pkglib_python_basenames); do \
2226
	  $(LN_S) -f $(defaultversionedsharedir)/$$prog $(DESTDIR)$(libdir)/ganeti/$$prog; \
2227
	done
2228
	for prog in $(tools_python_basenames); do \
2229
	  $(LN_S) -f $(defaultversionedsharedir)/$$prog $(DESTDIR)$(libdir)/ganeti/tools/$$prog; \
2230
	done
2231
	for prog in $(tools_basenames); do \
2232
	  $(LN_S) -f $(defaultversiondir)/$(libdir)/ganeti/tools/$$prog $(DESTDIR)$(libdir)/ganeti/tools/$$prog; \
2233
	done
2234
	if ! test -n '$(ENABLE_MANPAGES)'; then \
2235
	  for man in $(manfullpath); do \
2236
	    $(LN_S) -f $(defaultversionedsharedir)/root$(MANDIR)/$$man $(DESTDIR)$(MANDIR)/$$man; \
2237
	  done; \
2238
	fi
2239
	for prog in $(myexeclib_scripts_basenames); do \
2240
	  $(LN_S) -f $(defaultversiondir)$(libdir)/ganeti/$$prog $(DESTDIR)$(libdir)/ganeti/$$prog; \
2241
	done
2242
if INSTALL_SYMLINKS
2243
	$(LN_S) -f $(versionedsharedir) $(DESTDIR)$(sysconfdir)/ganeti/share
2244
	$(LN_S) -f $(versiondir) $(DESTDIR)$(sysconfdir)/ganeti/lib
2245
endif
2246

    
2247
.PHONY: apidoc
2248
if WANT_HSAPIDOC
2249
apidoc: py-apidoc hs-apidoc
2250
else
2251
apidoc: py-apidoc
2252
endif
2253

    
2254
.PHONY: py-apidoc
2255
py-apidoc: epydoc.conf $(RUN_IN_TEMPDIR) $(GENERATED_FILES)
2256
	env - PATH="$$PATH" PYTHONPATH="$$PYTHONPATH" \
2257
	$(RUN_IN_TEMPDIR) epydoc -v \
2258
	  --conf $(CURDIR)/epydoc.conf \
2259
	  --output $(CURDIR)/$(APIDOC_PY_DIR)
2260

    
2261
.PHONY: hs-apidoc
2262
hs-apidoc: $(APIDOC_HS_DIR)/index.html
2263

    
2264
$(APIDOC_HS_DIR)/index.html: $(HS_LIBTESTBUILT_SRCS) Makefile
2265
	@test -n "$(HSCOLOUR)" || \
2266
	    { echo 'HsColour' not found during configure; exit 1; }
2267
	@test -n "$(HADDOCK)" || \
2268
	    { echo 'haddock' not found during configure; exit 1; }
2269
	rm -rf $(APIDOC_HS_DIR)/*
2270
	for i in $(ALL_APIDOC_HS_DIRS); do \
2271
	  @mkdir_p@ $$i; \
2272
	  $(HSCOLOUR) -print-css > $$i/hscolour.css; \
2273
	done
2274
	set -e ; \
2275
	export LC_ALL=en_US.UTF-8; \
2276
	OPTGHC="--optghc=-isrc --optghc=-itest/hs"; \
2277
	if [ "$(HS_PARALLEL3)" ]; \
2278
	then OPTGHC="$$OPTGHC --optghc=$(HS_PARALLEL3)"; \
2279
	fi; \
2280
	if [ "$(HS_REGEX_PCRE)" ]; \
2281
	then OPTGHC="$$OPTGHC --optghc=$(HS_REGEX_PCRE)"; \
2282
	fi; \
2283
	for file in $(HS_LIBTESTBUILT_SRCS); do \
2284
	  f_nosrc=$${file##src/}; \
2285
	  f_notst=$${f_nosrc##test/hs/}; \
2286
	  f_html=$${f_notst%%.hs}.html; \
2287
	  $(HSCOLOUR) -css -anchor $$file > $(APIDOC_HS_DIR)/$$f_html ; \
2288
	done ; \
2289
	$(HADDOCK) --odir $(APIDOC_HS_DIR) --html --ignore-all-exports -w \
2290
	  -t ganeti -p src/haddock-prologue \
2291
	  --source-module="%{MODULE/.//}.html" \
2292
	  --source-entity="%{MODULE/.//}.html#%{NAME}" \
2293
	  $$OPTGHC \
2294
	  $(HS_LIBTESTBUILT_SRCS)
2295

    
2296
.PHONY: TAGS
2297
TAGS: $(GENERATED_FILES)
2298
	rm -f TAGS
2299
	$(GHC) -e ":etags" -v0 \
2300
	  $(filter-out -O -Werror,$(HFLAGS)) \
2301
	  $(HS_PARALLEL3) $(HS_REGEX_PCRE) \
2302
	  $(HS_LIBTEST_SRCS)
2303
	find . -path './lib/*.py' -o -path './scripts/gnt-*' -o \
2304
	  -path './daemons/ganeti-*' -o -path './tools/*' -o \
2305
	  -path './qa/*.py' | \
2306
	  etags -l python -a -
2307

    
2308
.PHONY: coverage
2309

    
2310
COVERAGE_TESTS=
2311
if WANT_HTOOLS
2312
COVERAGE_TESTS += hs-coverage
2313
endif
2314
if PY_UNIT
2315
COVERAGE_TESTS += py-coverage
2316
endif
2317

    
2318
coverage: $(COVERAGE_TESTS)
2319

    
2320
.PHONY: py-coverage
2321
py-coverage: $(GENERATED_FILES) $(python_tests)
2322
	@test -n "$(PYCOVERAGE)" || \
2323
	    { echo 'python-coverage' not found during configure; exit 1; }
2324
	set -e; \
2325
	COVERAGE=$(PYCOVERAGE) \
2326
	COVERAGE_FILE=$(CURDIR)/$(COVERAGE_PY_DIR)/data \
2327
	TEXT_COVERAGE=$(CURDIR)/$(COVERAGE_PY_DIR)/report.txt \
2328
	HTML_COVERAGE=$(CURDIR)/$(COVERAGE_PY_DIR) \
2329
	$(PLAIN_TESTS_ENVIRONMENT) \
2330
	$(abs_top_srcdir)/autotools/gen-py-coverage \
2331
	$(python_tests)
2332

    
2333
.PHONY: hs-coverage
2334
hs-coverage: $(haskell_tests) test/hs/hpc-htools test/hs/hpc-mon-collector
2335
	rm -f *.tix
2336
	$(MAKE) $(AM_MAKEFLAGS) hs-check
2337
	@mkdir_p@ $(COVERAGE_HS_DIR)
2338
	hpc sum --union $(HPCEXCL) \
2339
	  htest.tix hpc-htools.tix hpc-mon-collector.tix > coverage-hs.tix
2340
	hpc markup --destdir=$(COVERAGE_HS_DIR) coverage-hs.tix
2341
	hpc report coverage-hs.tix | tee $(COVERAGE_HS_DIR)/report.txt
2342
	$(LN_S) -f hpc_index.html $(COVERAGE_HS_DIR)/index.html
2343

    
2344
# Special "kind-of-QA" target for htools, needs special setup (all
2345
# tools compiled with -fhpc)
2346
.PHONY: live-test
2347
live-test: all
2348
	set -e ; \
2349
	cd src; \
2350
	rm -f .hpc; $(LN_S) ../.hpc .hpc; \
2351
	rm -f *.tix *.mix; \
2352
	./live-test.sh; \
2353
	hpc sum --union $(HPCEXCL) $(addsuffix .tix,$(HS_PROGS:src/%=%)) \
2354
	  --output=live-test.tix ; \
2355
	@mkdir_p@ ../$(COVERAGE_HS_DIR) ; \
2356
	hpc markup --destdir=../$(COVERAGE_HS_DIR) live-test \
2357
	  --srcdir=.. $(HPCEXCL) ; \
2358
	hpc report --srcdir=.. live-test $(HPCEXCL)
2359

    
2360
commit-check: autotools-check distcheck lint apidoc
2361

    
2362
autotools-check:
2363
	TESTDATA_DIR=./test/data shelltest $(SHELLTESTARGS) \
2364
  $(abs_top_srcdir)/test/autotools/*-*.test \
2365
  -- --hide-successes
2366

    
2367
.PHONY: gitignore-check
2368
gitignore-check:
2369
	@if [ -n "`git status --short`" ]; then \
2370
	  echo "Git status is not clean!" 1>&2 ; \
2371
	  git status --short; \
2372
	  exit 1; \
2373
	fi
2374

    
2375
# target to rebuild all man pages (both groff and html output)
2376
.PHONY: man
2377
man: $(man_MANS) $(manhtml)
2378

    
2379
# Target that builds all binaries (including those that are not
2380
# rebuilt except when running the tests)
2381
.PHONY: really-all
2382
really-all: all $(check_SCRIPTS) $(haskell_tests) $(HS_ALL_PROGS)
2383

    
2384
# we don't need the ancient implicit rules:
2385
%: %,v
2386
%: RCS/%,v
2387
%: RCS/%
2388
%: s.%
2389
%: SCCS/s.%
2390

    
2391
-include ./Makefile.local
2392

    
2393
# vim: set noet :