Statistics
| Branch: | Tag: | Revision:

root / Makefile.am @ fec1fac1

History | View | Annotate | Download (66.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
CONVERT_CONSTANTS = $(top_srcdir)/autotools/convert-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 a single directory,
44
# with only symbolic links added at other places.
45
versiondir = $(libdir)/ganeti-$(VERSION)
46

    
47
# Note: these are automake-specific variables, and must be named after
48
# the directory + 'dir' suffix
49
pkglibdir = $(versiondir)$(libdir)/ganeti
50
myexeclibdir = $(pkglibdir)
51
bindir = $(versiondir)$(exec_prefix)/bin
52
sbindir = $(versiondir)$(exec_prefix)/sbin
53
mandir = $(versiondir)$(datarootdir)/man
54
pkgpythondir = $(versiondir)$(pythondir)/ganeti
55

    
56
clientdir = $(pkgpythondir)/client
57
cmdlibdir = $(pkgpythondir)/cmdlib
58
hypervisordir = $(pkgpythondir)/hypervisor
59
storagedir = $(pkgpythondir)/storage
60
httpdir = $(pkgpythondir)/http
61
masterddir = $(pkgpythondir)/masterd
62
confddir = $(pkgpythondir)/confd
63
rapidir = $(pkgpythondir)/rapi
64
serverdir = $(pkgpythondir)/server
65
watcherdir = $(pkgpythondir)/watcher
66
impexpddir = $(pkgpythondir)/impexpd
67
utilsdir = $(pkgpythondir)/utils
68
toolsdir = $(pkglibdir)/tools
69
iallocatorsdir = $(pkglibdir)/iallocators
70
pytoolsdir = $(pkgpythondir)/tools
71
docdir = $(versiondir)$(datadir)/doc/$(PACKAGE)
72

    
73
SYMLINK_TARGET_DIRS = \
74
	$(pythondir) \
75
	$(libdir)/ganeti/iallocators \
76
	$(exec_prefix)/bin \
77
	$(exec_prefix)/sbin \
78
	$(datarootdir)/man/man1 \
79
	$(datarootdir)/man/man7 \
80
	$(datarootdir)/man/man8
81
SYMLINK_DIRS = \
82
	$(pythondir)/ganeti \
83
	$(libdir)/ganeti/tools
84

    
85
# Delete output file if an error occurred while building it
86
.DELETE_ON_ERROR:
87

    
88
HS_DIRS = \
89
	src \
90
	src/Ganeti \
91
	src/Ganeti/Confd \
92
	src/Ganeti/Curl \
93
	src/Ganeti/Cpu \
94
	src/Ganeti/DataCollectors \
95
	src/Ganeti/Hs2Py \
96
	src/Ganeti/HTools \
97
	src/Ganeti/HTools/Backend \
98
	src/Ganeti/HTools/Program \
99
	src/Ganeti/Hypervisor \
100
	src/Ganeti/Hypervisor/Xen \
101
	src/Ganeti/Monitoring \
102
	src/Ganeti/Query \
103
	src/Ganeti/Storage \
104
	src/Ganeti/Storage/Diskstats \
105
	src/Ganeti/Storage/Drbd \
106
	src/Ganeti/Storage/Lvm \
107
	test/hs \
108
	test/hs/Test \
109
	test/hs/Test/Ganeti \
110
	test/hs/Test/Ganeti/Storage \
111
	test/hs/Test/Ganeti/Storage/Diskstats \
112
	test/hs/Test/Ganeti/Storage/Drbd \
113
	test/hs/Test/Ganeti/Storage/Lvm \
114
	test/hs/Test/Ganeti/Confd \
115
	test/hs/Test/Ganeti/HTools \
116
	test/hs/Test/Ganeti/HTools/Backend \
117
	test/hs/Test/Ganeti/Hypervisor \
118
	test/hs/Test/Ganeti/Hypervisor/Xen \
119
	test/hs/Test/Ganeti/Query
120

    
121
# Haskell directories without the roots (src, test/hs)
122
HS_DIRS_NOROOT = $(filter-out src,$(filter-out test/hs,$(HS_DIRS)))
123

    
124
DIRS = \
125
	$(HS_DIRS) \
126
	autotools \
127
	daemons \
128
	devel \
129
	devel/data \
130
	doc \
131
	doc/css \
132
	doc/examples \
133
	doc/examples/gnt-debug \
134
	doc/examples/hooks \
135
	test/data/htools \
136
	test/data/htools/rapi \
137
	test/hs/shelltests \
138
	test/autotools \
139
	lib \
140
	lib/build \
141
	lib/client \
142
	lib/cmdlib \
143
	lib/confd \
144
	lib/http \
145
	lib/hypervisor \
146
	lib/impexpd \
147
	lib/masterd \
148
	lib/rapi \
149
	lib/server \
150
	lib/storage \
151
	lib/tools \
152
	lib/utils \
153
	lib/watcher \
154
	man \
155
	qa \
156
	test \
157
	test/data \
158
	test/data/bdev-rbd \
159
	test/data/ovfdata \
160
	test/data/ovfdata/other \
161
	test/py \
162
	test/py/cmdlib \
163
	test/py/cmdlib/testsupport \
164
	tools
165

    
166
ALL_APIDOC_HS_DIRS = \
167
	$(APIDOC_HS_DIR) \
168
	$(patsubst %,$(APIDOC_HS_DIR)/%,$(call strip_hsroot,$(HS_DIRS_NOROOT)))
169

    
170
BUILDTIME_DIR_AUTOCREATE = \
171
	scripts \
172
	$(APIDOC_DIR) \
173
	$(ALL_APIDOC_HS_DIRS) \
174
	$(APIDOC_PY_DIR) \
175
	$(COVERAGE_DIR) \
176
	$(COVERAGE_HS_DIR) \
177
	$(COVERAGE_PY_DIR) \
178
	.hpc
179

    
180
BUILDTIME_DIRS = \
181
	$(BUILDTIME_DIR_AUTOCREATE) \
182
	doc/html \
183
	doc/man-html
184

    
185
DIRCHECK_EXCLUDE = \
186
	$(BUILDTIME_DIRS) \
187
	ganeti-[0-9]*.[0-9]*.[0-9]* \
188
	doc/html/_* \
189
	doc/man-html/_* \
190
	autom4te.cache
191

    
192
# some helper vars
193
COVERAGE_DIR = doc/coverage
194
COVERAGE_PY_DIR = $(COVERAGE_DIR)/py
195
COVERAGE_HS_DIR = $(COVERAGE_DIR)/hs
196
APIDOC_DIR = doc/api
197
APIDOC_PY_DIR = $(APIDOC_DIR)/py
198
APIDOC_HS_DIR = $(APIDOC_DIR)/hs
199

    
200
MAINTAINERCLEANFILES = \
201
	$(maninput) \
202
	doc/install-quick.rst \
203
	doc/news.rst \
204
	doc/upgrade.rst \
205
	vcs-version
206

    
207
maintainer-clean-local:
208
	rm -rf $(BUILDTIME_DIRS)
209

    
210
CLEANFILES = \
211
	$(addsuffix /*.py[co],$(DIRS)) \
212
	$(addsuffix /*.hi,$(HS_DIRS)) \
213
	$(addsuffix /*.o,$(HS_DIRS)) \
214
	$(PYTHON_BOOTSTRAP) \
215
	epydoc.conf \
216
	$(REPLACE_VARS_SED) \
217
	$(SHELL_ENV_INIT) \
218
	daemons/daemon-util \
219
	daemons/ganeti-cleaner \
220
	devel/squeeze-amd64.tar.gz \
221
	devel/squeeze-amd64.conf \
222
	$(mandocrst) \
223
	doc/manpages-enabled.rst \
224
	$(BUILT_EXAMPLES) \
225
	doc/examples/bash_completion \
226
	doc/examples/bash_completion-debug \
227
	lib/_generated_rpc.py \
228
	$(man_MANS) \
229
	$(manhtml) \
230
	tools/kvm-ifup \
231
	tools/vif-ganeti \
232
	tools/net-common \
233
	tools/users-setup \
234
	tools/vcluster-setup \
235
	stamp-directories \
236
	stamp-srclinks \
237
	$(nodist_pkgpython_PYTHON) \
238
	$(HS_ALL_PROGS) $(HS_BUILT_SRCS) \
239
	$(HS_BUILT_TEST_HELPERS) \
240
	src/ganeti-confd \
241
	src/ganeti-luxid \
242
	src/ganeti-mond \
243
	.hpc/*.mix src/*.tix test/hs/*.tix \
244
	doc/hs-lint.html
245

    
246
GENERATED_FILES = \
247
	$(built_base_sources) \
248
	$(BUILT_PYTHON_SOURCES) \
249
	$(PYTHON_BOOTSTRAP)
250

    
251
HS_GENERATED_FILES =
252
if WANT_HTOOLS
253
HS_GENERATED_FILES += $(HS_PROGS)
254
if ENABLE_CONFD
255
HS_GENERATED_FILES += src/hconfd src/ganeti-confd src/hluxid src/ganeti-luxid
256
endif
257

    
258
if ENABLE_MOND
259
HS_GENERATED_FILES += src/ganeti-mond
260
endif
261
endif
262

    
263
built_base_sources = \
264
	stamp-directories \
265
	stamp-srclinks
266

    
267
built_python_base_sources = \
268
	lib/_autoconf.py \
269
	lib/_vcsversion.py \
270
	lib/opcodes.py
271

    
272
BUILT_PYTHON_SOURCES = \
273
	$(built_python_base_sources) \
274
	lib/_generated_rpc.py
275

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

    
280
# these are all built from the underlying %.in sources
281
BUILT_EXAMPLES = \
282
	doc/examples/ganeti-kvm-poweroff.initd \
283
	doc/examples/ganeti.cron \
284
	doc/examples/ganeti.initd \
285
	doc/examples/ganeti.logrotate \
286
	doc/examples/ganeti-master-role.ocf \
287
	doc/examples/ganeti-node-role.ocf \
288
	doc/examples/gnt-config-backup \
289
	doc/examples/hooks/ipsec
290

    
291
nodist_pkgpython_PYTHON = \
292
	$(BUILT_PYTHON_SOURCES)
293

    
294
noinst_PYTHON = \
295
	lib/build/__init__.py \
296
	lib/build/shell_example_lexer.py \
297
	lib/build/sphinx_ext.py
298

    
299
pkgpython_PYTHON = \
300
	lib/__init__.py \
301
	lib/asyncnotifier.py \
302
	lib/backend.py \
303
	lib/bootstrap.py \
304
	lib/cli.py \
305
	lib/compat.py \
306
	lib/config.py \
307
	lib/constants.py \
308
	lib/daemon.py \
309
	lib/errors.py \
310
	lib/hooksmaster.py \
311
	lib/ht.py \
312
	lib/jqueue.py \
313
	lib/jstore.py \
314
	lib/locking.py \
315
	lib/luxi.py \
316
	lib/mcpu.py \
317
	lib/netutils.py \
318
	lib/objects.py \
319
	lib/opcodes_base.py \
320
	lib/outils.py \
321
	lib/ovf.py \
322
	lib/pathutils.py \
323
	lib/qlang.py \
324
	lib/query.py \
325
	lib/rpc.py \
326
	lib/rpc_defs.py \
327
	lib/runtime.py \
328
	lib/serializer.py \
329
	lib/ssconf.py \
330
	lib/ssh.py \
331
	lib/uidpool.py \
332
	lib/vcluster.py \
333
	lib/network.py \
334
	lib/workerpool.py
335

    
336
client_PYTHON = \
337
	lib/client/__init__.py \
338
	lib/client/gnt_backup.py \
339
	lib/client/gnt_cluster.py \
340
	lib/client/gnt_debug.py \
341
	lib/client/gnt_group.py \
342
	lib/client/gnt_instance.py \
343
	lib/client/gnt_job.py \
344
	lib/client/gnt_node.py \
345
	lib/client/gnt_network.py \
346
	lib/client/gnt_os.py \
347
	lib/client/gnt_storage.py
348

    
349
cmdlib_PYTHON = \
350
	lib/cmdlib/__init__.py \
351
	lib/cmdlib/backup.py \
352
	lib/cmdlib/base.py \
353
	lib/cmdlib/cluster.py \
354
	lib/cmdlib/common.py \
355
	lib/cmdlib/group.py \
356
	lib/cmdlib/instance.py \
357
	lib/cmdlib/instance_migration.py \
358
	lib/cmdlib/instance_operation.py \
359
	lib/cmdlib/instance_query.py \
360
	lib/cmdlib/instance_storage.py \
361
	lib/cmdlib/instance_utils.py \
362
	lib/cmdlib/misc.py \
363
	lib/cmdlib/network.py \
364
	lib/cmdlib/node.py \
365
	lib/cmdlib/operating_system.py \
366
	lib/cmdlib/query.py \
367
	lib/cmdlib/tags.py \
368
	lib/cmdlib/test.py
369

    
370
hypervisor_PYTHON = \
371
	lib/hypervisor/__init__.py \
372
	lib/hypervisor/hv_base.py \
373
	lib/hypervisor/hv_chroot.py \
374
	lib/hypervisor/hv_fake.py \
375
	lib/hypervisor/hv_kvm.py \
376
	lib/hypervisor/hv_lxc.py \
377
	lib/hypervisor/hv_xen.py
378

    
379
storage_PYTHON = \
380
	lib/storage/__init__.py \
381
	lib/storage/bdev.py \
382
	lib/storage/base.py \
383
	lib/storage/container.py \
384
	lib/storage/drbd.py \
385
	lib/storage/drbd_info.py \
386
	lib/storage/drbd_cmdgen.py \
387
	lib/storage/filestorage.py
388

    
389
rapi_PYTHON = \
390
	lib/rapi/__init__.py \
391
	lib/rapi/baserlib.py \
392
	lib/rapi/client.py \
393
	lib/rapi/client_utils.py \
394
	lib/rapi/connector.py \
395
	lib/rapi/rlib2.py \
396
	lib/rapi/testutils.py
397

    
398
http_PYTHON = \
399
	lib/http/__init__.py \
400
	lib/http/auth.py \
401
	lib/http/client.py \
402
	lib/http/server.py
403

    
404
confd_PYTHON = \
405
	lib/confd/__init__.py \
406
	lib/confd/client.py
407

    
408
masterd_PYTHON = \
409
	lib/masterd/__init__.py \
410
	lib/masterd/iallocator.py \
411
	lib/masterd/instance.py
412

    
413
impexpd_PYTHON = \
414
	lib/impexpd/__init__.py
415

    
416
watcher_PYTHON = \
417
	lib/watcher/__init__.py \
418
	lib/watcher/nodemaint.py \
419
	lib/watcher/state.py
420

    
421
server_PYTHON = \
422
	lib/server/__init__.py \
423
	lib/server/masterd.py \
424
	lib/server/noded.py \
425
	lib/server/rapi.py
426

    
427
pytools_PYTHON = \
428
	lib/tools/__init__.py \
429
	lib/tools/burnin.py \
430
	lib/tools/ensure_dirs.py \
431
	lib/tools/node_cleanup.py \
432
	lib/tools/node_daemon_setup.py \
433
	lib/tools/prepare_node_join.py
434

    
435
utils_PYTHON = \
436
	lib/utils/__init__.py \
437
	lib/utils/algo.py \
438
	lib/utils/filelock.py \
439
	lib/utils/hash.py \
440
	lib/utils/io.py \
441
	lib/utils/log.py \
442
	lib/utils/lvm.py \
443
	lib/utils/mlock.py \
444
	lib/utils/nodesetup.py \
445
	lib/utils/process.py \
446
	lib/utils/retry.py \
447
	lib/utils/storage.py \
448
	lib/utils/text.py \
449
	lib/utils/wrapper.py \
450
	lib/utils/x509.py
451

    
452
docinput = \
453
	doc/conf.py \
454
	doc/css/style.css \
455
	doc/admin.rst \
456
	doc/cluster-merge.rst \
457
	doc/design-2.0.rst \
458
	doc/design-2.1.rst \
459
	doc/design-2.2.rst \
460
	doc/design-2.3.rst \
461
	doc/design-2.4.rst \
462
	doc/design-2.5.rst \
463
	doc/design-2.6.rst \
464
	doc/design-2.7.rst \
465
	doc/design-2.8.rst \
466
	doc/design-autorepair.rst \
467
	doc/design-bulk-create.rst \
468
	doc/design-chained-jobs.rst \
469
	doc/design-cpu-pinning.rst \
470
	doc/design-device-uuid-name.rst \
471
	doc/design-draft.rst \
472
	doc/design-hotplug.rst \
473
	doc/design-htools-2.3.rst \
474
	doc/design-http-server.rst \
475
	doc/design-impexp2.rst \
476
	doc/design-internal-shutdown.rst \
477
	doc/design-lu-generated-jobs.rst \
478
	doc/design-linuxha.rst \
479
	doc/design-multi-reloc.rst \
480
	doc/design-network.rst \
481
	doc/design-node-add.rst \
482
	doc/design-oob.rst \
483
	doc/design-ovf-support.rst \
484
	doc/design-opportunistic-locking.rst \
485
	doc/design-optables.rst \
486
	doc/design-partitioned.rst \
487
	doc/design-query-splitting.rst \
488
	doc/design-query2.rst \
489
	doc/design-reason-trail.rst \
490
	doc/design-resource-model.rst \
491
	doc/design-restricted-commands.rst \
492
	doc/design-shared-storage.rst \
493
	doc/design-monitoring-agent.rst \
494
	doc/design-virtual-clusters.rst \
495
	doc/design-x509-ca.rst \
496
	doc/design-hroller.rst \
497
	doc/design-storagetypes.rst \
498
        doc/design-upgrade.rst \
499
	doc/devnotes.rst \
500
	doc/glossary.rst \
501
	doc/hooks.rst \
502
	doc/iallocator.rst \
503
	doc/index.rst \
504
	doc/install-quick.rst \
505
	doc/install.rst \
506
	doc/locking.rst \
507
	doc/manpages-disabled.rst \
508
	doc/monitoring-query-format.rst \
509
	doc/move-instance.rst \
510
	doc/news.rst \
511
	doc/ovfconverter.rst \
512
	doc/rapi.rst \
513
	doc/security.rst \
514
	doc/upgrade.rst \
515
	doc/virtual-cluster.rst \
516
	doc/walkthrough.rst
517

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

    
521
# Haskell programs to be installed in $PREFIX/bin
522
HS_BIN_PROGS=src/htools
523

    
524
# Haskell programs to be installed in the MYEXECLIB dir
525
if ENABLE_MOND
526
HS_MYEXECLIB_PROGS=src/mon-collector
527
else
528
HS_MYEXECLIB_PROGS=
529
endif
530

    
531
# Haskell programs to be compiled by "make really-all"
532
HS_COMPILE_PROGS= \
533
	src/ganeti-mond \
534
	src/hconfd \
535
	src/hluxid \
536
	src/hs2py \
537
	src/rpc-test
538

    
539
# All Haskell non-test programs to be compiled but not automatically installed
540
HS_PROGS = $(HS_BIN_PROGS) $(HS_MYEXECLIB_PROGS)
541

    
542
HS_BIN_ROLES = harep hbal hscan hspace hinfo hcheck hroller
543
HS_HTOOLS_PROGS = $(HS_BIN_ROLES) hail
544

    
545
HS_ALL_PROGS = \
546
	$(HS_PROGS) \
547
	test/hs/hpc-htools \
548
	test/hs/hpc-mon-collector \
549
	test/hs/htest \
550
	$(HS_COMPILE_PROGS)
551

    
552
HS_PROG_SRCS = $(patsubst %,%.hs,$(HS_ALL_PROGS))
553
HS_BUILT_TEST_HELPERS = $(HS_BIN_ROLES:%=test/hs/%) test/hs/hail
554

    
555
HFLAGS = \
556
	-O -Wall -Werror -isrc \
557
	-fwarn-monomorphism-restriction \
558
	-fwarn-tabs \
559
	$(GHC_BYVERSION_FLAGS)
560

    
561
# extra flags that can be overriden on the command line (e.g. -Wwarn, etc.)
562
HEXTRA =
563
# internal extra flags (used for test/hs/htest mainly)
564
HEXTRA_INT =
565
# exclude options for coverage reports
566
HPCEXCL = --exclude Main \
567
	--exclude Ganeti.Constants \
568
	--exclude Ganeti.HTools.QC \
569
	--exclude Ganeti.THH \
570
	--exclude Ganeti.Version \
571
	--exclude Test.Ganeti.Attoparsec \
572
	--exclude Test.Ganeti.TestCommon \
573
	--exclude Test.Ganeti.TestHTools \
574
	--exclude Test.Ganeti.TestHelper \
575
	--exclude Test.Ganeti.TestImports \
576
	$(patsubst src.%,--exclude Test.%,$(subst /,.,$(patsubst %.hs,%, $(HS_LIB_SRCS))))
577

    
578
HS_LIB_SRCS = \
579
	src/Ganeti/BasicTypes.hs \
580
	src/Ganeti/Common.hs \
581
	src/Ganeti/Compat.hs \
582
	src/Ganeti/Confd/Client.hs \
583
	src/Ganeti/Confd/ClientFunctions.hs \
584
	src/Ganeti/Confd/Server.hs \
585
	src/Ganeti/Confd/Types.hs \
586
	src/Ganeti/Confd/Utils.hs \
587
	src/Ganeti/Config.hs \
588
	src/Ganeti/ConfigReader.hs \
589
	src/Ganeti/Constants.hs \
590
	src/Ganeti/Cpu/LoadParser.hs \
591
	src/Ganeti/Cpu/Types.hs \
592
	src/Ganeti/Curl/Multi.hs \
593
	src/Ganeti/Daemon.hs \
594
	src/Ganeti/DataCollectors/CLI.hs \
595
	src/Ganeti/DataCollectors/CPUload.hs \
596
	src/Ganeti/DataCollectors/Diskstats.hs \
597
	src/Ganeti/DataCollectors/Drbd.hs \
598
	src/Ganeti/DataCollectors/InstStatus.hs \
599
	src/Ganeti/DataCollectors/InstStatusTypes.hs \
600
	src/Ganeti/DataCollectors/Lv.hs \
601
	src/Ganeti/DataCollectors/Program.hs \
602
	src/Ganeti/DataCollectors/Types.hs \
603
	src/Ganeti/Errors.hs \
604
	src/Ganeti/HTools/Backend/IAlloc.hs \
605
	src/Ganeti/HTools/Backend/Luxi.hs \
606
	src/Ganeti/HTools/Backend/Rapi.hs \
607
	src/Ganeti/HTools/Backend/Simu.hs \
608
	src/Ganeti/HTools/Backend/Text.hs \
609
	src/Ganeti/HTools/CLI.hs \
610
	src/Ganeti/HTools/Cluster.hs \
611
	src/Ganeti/HTools/Container.hs \
612
	src/Ganeti/HTools/ExtLoader.hs \
613
	src/Ganeti/HTools/Graph.hs \
614
	src/Ganeti/HTools/Group.hs \
615
	src/Ganeti/HTools/Instance.hs \
616
	src/Ganeti/HTools/Loader.hs \
617
	src/Ganeti/HTools/Nic.hs \
618
	src/Ganeti/HTools/Node.hs \
619
	src/Ganeti/HTools/PeerMap.hs \
620
	src/Ganeti/HTools/Program/Hail.hs \
621
	src/Ganeti/HTools/Program/Harep.hs \
622
	src/Ganeti/HTools/Program/Hbal.hs \
623
	src/Ganeti/HTools/Program/Hcheck.hs \
624
	src/Ganeti/HTools/Program/Hinfo.hs \
625
	src/Ganeti/HTools/Program/Hscan.hs \
626
	src/Ganeti/HTools/Program/Hspace.hs \
627
	src/Ganeti/HTools/Program/Hroller.hs \
628
	src/Ganeti/HTools/Program/Main.hs \
629
	src/Ganeti/HTools/Types.hs \
630
	src/Ganeti/Hypervisor/Xen.hs \
631
	src/Ganeti/Hypervisor/Xen/XmParser.hs \
632
	src/Ganeti/Hypervisor/Xen/Types.hs \
633
	src/Ganeti/Hash.hs \
634
	src/Ganeti/Hs2Py/GenConstants.hs \
635
	src/Ganeti/Hs2Py/GenOpCodes.hs \
636
	src/Ganeti/Hs2Py/OpDoc.hs \
637
	src/Ganeti/JQueue.hs \
638
	src/Ganeti/JSON.hs \
639
	src/Ganeti/Jobs.hs \
640
	src/Ganeti/Logging.hs \
641
	src/Ganeti/Luxi.hs \
642
	src/Ganeti/Monitoring/Server.hs \
643
	src/Ganeti/Network.hs \
644
	src/Ganeti/Objects.hs \
645
	src/Ganeti/OpCodes.hs \
646
	src/Ganeti/OpParams.hs \
647
	src/Ganeti/Path.hs \
648
	src/Ganeti/Parsers.hs \
649
	src/Ganeti/PyValueInstances.hs \
650
	src/Ganeti/Query/Cluster.hs \
651
	src/Ganeti/Query/Common.hs \
652
	src/Ganeti/Query/Export.hs \
653
	src/Ganeti/Query/Filter.hs \
654
	src/Ganeti/Query/Group.hs \
655
	src/Ganeti/Query/Job.hs \
656
	src/Ganeti/Query/Language.hs \
657
	src/Ganeti/Query/Network.hs \
658
	src/Ganeti/Query/Node.hs \
659
	src/Ganeti/Query/Query.hs \
660
	src/Ganeti/Query/Server.hs \
661
	src/Ganeti/Query/Types.hs \
662
	src/Ganeti/Rpc.hs \
663
	src/Ganeti/Runtime.hs \
664
	src/Ganeti/Ssconf.hs \
665
	src/Ganeti/Storage/Diskstats/Parser.hs \
666
	src/Ganeti/Storage/Diskstats/Types.hs \
667
	src/Ganeti/Storage/Drbd/Parser.hs \
668
	src/Ganeti/Storage/Drbd/Types.hs \
669
	src/Ganeti/Storage/Lvm/LVParser.hs \
670
	src/Ganeti/Storage/Lvm/Types.hs \
671
	src/Ganeti/Storage/Utils.hs \
672
	src/Ganeti/THH.hs \
673
	src/Ganeti/Types.hs \
674
	src/Ganeti/Utils.hs
675

    
676
HS_TEST_SRCS = \
677
	test/hs/Test/Ganeti/Attoparsec.hs \
678
	test/hs/Test/Ganeti/BasicTypes.hs \
679
	test/hs/Test/Ganeti/Common.hs \
680
	test/hs/Test/Ganeti/Confd/Types.hs \
681
	test/hs/Test/Ganeti/Confd/Utils.hs \
682
	test/hs/Test/Ganeti/Daemon.hs \
683
	test/hs/Test/Ganeti/Errors.hs \
684
	test/hs/Test/Ganeti/HTools/Backend/Simu.hs \
685
	test/hs/Test/Ganeti/HTools/Backend/Text.hs \
686
	test/hs/Test/Ganeti/HTools/CLI.hs \
687
	test/hs/Test/Ganeti/HTools/Cluster.hs \
688
	test/hs/Test/Ganeti/HTools/Container.hs \
689
	test/hs/Test/Ganeti/HTools/Graph.hs \
690
	test/hs/Test/Ganeti/HTools/Instance.hs \
691
	test/hs/Test/Ganeti/HTools/Loader.hs \
692
	test/hs/Test/Ganeti/HTools/Node.hs \
693
	test/hs/Test/Ganeti/HTools/PeerMap.hs \
694
	test/hs/Test/Ganeti/HTools/Types.hs \
695
	test/hs/Test/Ganeti/Hypervisor/Xen/XmParser.hs \
696
	test/hs/Test/Ganeti/JSON.hs \
697
	test/hs/Test/Ganeti/Jobs.hs \
698
	test/hs/Test/Ganeti/JQueue.hs \
699
	test/hs/Test/Ganeti/Luxi.hs \
700
	test/hs/Test/Ganeti/Network.hs \
701
	test/hs/Test/Ganeti/Objects.hs \
702
	test/hs/Test/Ganeti/OpCodes.hs \
703
	test/hs/Test/Ganeti/Query/Filter.hs \
704
	test/hs/Test/Ganeti/Query/Language.hs \
705
	test/hs/Test/Ganeti/Query/Network.hs \
706
	test/hs/Test/Ganeti/Query/Query.hs \
707
	test/hs/Test/Ganeti/Rpc.hs \
708
	test/hs/Test/Ganeti/Runtime.hs \
709
	test/hs/Test/Ganeti/Ssconf.hs \
710
	test/hs/Test/Ganeti/Storage/Diskstats/Parser.hs \
711
	test/hs/Test/Ganeti/Storage/Drbd/Parser.hs \
712
	test/hs/Test/Ganeti/Storage/Drbd/Types.hs \
713
	test/hs/Test/Ganeti/Storage/Lvm/LVParser.hs \
714
	test/hs/Test/Ganeti/THH.hs \
715
	test/hs/Test/Ganeti/TestCommon.hs \
716
	test/hs/Test/Ganeti/TestHTools.hs \
717
	test/hs/Test/Ganeti/TestHelper.hs \
718
	test/hs/Test/Ganeti/Types.hs \
719
	test/hs/Test/Ganeti/Utils.hs
720

    
721
HS_LIBTEST_SRCS = $(HS_LIB_SRCS) $(HS_TEST_SRCS)
722

    
723
HS_BUILT_SRCS = \
724
	test/hs/Test/Ganeti/TestImports.hs \
725
	src/Ganeti/PyConstants.hs \
726
	src/Ganeti/Curl/Internal.hs \
727
	src/Ganeti/Version.hs
728
HS_BUILT_SRCS_IN = \
729
	$(patsubst %,%.in,$(filter-out src/Ganeti/Curl/Internal.hs,$(HS_BUILT_SRCS))) \
730
	src/Ganeti/Curl/Internal.hsc \
731
	lib/opcodes.py.in_after \
732
	lib/opcodes.py.in_before
733

    
734
HS_LIBTESTBUILT_SRCS = $(HS_LIBTEST_SRCS) $(HS_BUILT_SRCS)
735

    
736
$(RUN_IN_TEMPDIR): | stamp-directories
737

    
738
doc/html/index.html: ENABLE_MANPAGES =
739
doc/man-html/index.html: ENABLE_MANPAGES = 1
740
doc/man-html/index.html: doc/manpages-enabled.rst $(mandocrst)
741

    
742
# Note: we use here an order-only prerequisite, as the contents of
743
# _autoconf.py are not actually influencing the html build output: it
744
# has to exist in order for the sphinx module to be loaded
745
# successfully, but we certainly don't want the docs to be rebuilt if
746
# it changes
747
doc/html/index.html doc/man-html/index.html: $(docinput) doc/conf.py \
748
	configure.ac $(RUN_IN_TEMPDIR) lib/build/sphinx_ext.py \
749
	lib/build/shell_example_lexer.py lib/ht.py \
750
	doc/css/style.css lib/rapi/connector.py lib/rapi/rlib2.py \
751
	autotools/sphinx-wrapper | $(BUILT_PYTHON_SOURCES)
752
	@test -n "$(SPHINX)" || \
753
	    { echo 'sphinx-build' not found during configure; exit 1; }
754
if !MANPAGES_IN_DOC
755
	if test -n '$(ENABLE_MANPAGES)'; then \
756
	  echo 'Man pages in documentation were disabled at configure time' >&2; \
757
	  exit 1; \
758
	fi
759
endif
760
## Sphinx provides little control over what content should be included. Some
761
## mechanisms exist, but they all have drawbacks or actual issues. Since we
762
## build two different versions of the documentation--once without man pages and
763
## once, if enabled, with them--some control is necessary. xmpp-wrapper provides
764
## us with this, but requires running in a temporary directory. It moves the
765
## correct files into place depending on environment variables.
766
	dir=$(dir $@) && \
767
	@mkdir_p@ $$dir && \
768
	PYTHONPATH=. ENABLE_MANPAGES=$(ENABLE_MANPAGES) COPY_DOC=1 \
769
	$(RUN_IN_TEMPDIR) autotools/sphinx-wrapper $(SPHINX) -q -W -b html \
770
	    -d . \
771
	    -D version="$(VERSION_MAJOR).$(VERSION_MINOR)" \
772
	    -D release="$(PACKAGE_VERSION)" \
773
	    -D graphviz_dot="$(DOT)" \
774
	    -D enable_manpages="$(ENABLE_MANPAGES)" \
775
	    doc $(CURDIR)/$$dir && \
776
	rm -f $$dir/.buildinfo $$dir/objects.inv
777
	touch $@
778

    
779
doc/html: doc/html/index.html
780

    
781
doc/man-html: doc/man-html/index.html
782

    
783
doc/install-quick.rst: INSTALL
784
doc/news.rst: NEWS
785
doc/upgrade.rst: UPGRADE
786

    
787
doc/install-quick.rst doc/news.rst doc/upgrade.rst:
788
	set -e; \
789
	{ echo '.. This file is automatically updated at build time from $<.'; \
790
	  echo '.. Do not edit.'; \
791
	  echo; \
792
	  cat $<; \
793
	} > $@
794

    
795
doc/manpages-enabled.rst: Makefile | $(built_base_sources)
796
	{ echo '.. This file is automatically generated, do not edit!'; \
797
	  echo ''; \
798
	  echo 'Man pages'; \
799
	  echo '========='; \
800
	  echo; \
801
	  echo '.. toctree::'; \
802
	  echo '   :maxdepth: 1'; \
803
	  echo; \
804
	  for i in $(notdir $(mandocrst)); do \
805
	    echo "   $$i"; \
806
	  done | LC_ALL=C sort; \
807
	} > $@
808

    
809
doc/man-%.rst: man/%.gen Makefile $(REPLACE_VARS_SED) | $(built_base_sources)
810
if MANPAGES_IN_DOC
811
	{ echo '.. This file is automatically updated at build time from $<.'; \
812
	  echo '.. Do not edit.'; \
813
	  echo; \
814
	  echo "$*"; \
815
	  echo '=========================================='; \
816
	  tail -n +3 $< | sed -f $(REPLACE_VARS_SED); \
817
	} > $@
818
else
819
	echo 'Man pages in documentation were disabled at configure time' >&2; \
820
	exit 1;
821
endif
822

    
823
# Things to build but not to install (add it to EXTRA_DIST if it should be
824
# distributed)
825
noinst_DATA = \
826
	$(BUILT_EXAMPLES) \
827
	doc/examples/bash_completion \
828
	doc/examples/bash_completion-debug \
829
	$(manhtml)
830

    
831
if HAS_SPHINX
832
if MANPAGES_IN_DOC
833
noinst_DATA += doc/man-html
834
else
835
noinst_DATA += doc/html
836
endif
837
endif
838

    
839
gnt_scripts = \
840
	scripts/gnt-backup \
841
	scripts/gnt-cluster \
842
	scripts/gnt-debug \
843
	scripts/gnt-group \
844
	scripts/gnt-instance \
845
	scripts/gnt-job \
846
	scripts/gnt-network \
847
	scripts/gnt-node \
848
	scripts/gnt-os \
849
	scripts/gnt-storage
850

    
851
PYTHON_BOOTSTRAP_SBIN = \
852
	daemons/ganeti-masterd \
853
	daemons/ganeti-noded \
854
	daemons/ganeti-rapi \
855
	daemons/ganeti-watcher \
856
	$(gnt_scripts)
857

    
858
PYTHON_BOOTSTRAP = \
859
	$(PYTHON_BOOTSTRAP_SBIN) \
860
	tools/burnin \
861
	tools/ensure-dirs \
862
	tools/node-cleanup \
863
	tools/node-daemon-setup \
864
	tools/prepare-node-join
865

    
866
qa_scripts = \
867
	qa/__init__.py \
868
	qa/ganeti-qa.py \
869
	qa/qa_cluster.py \
870
	qa/qa_config.py \
871
	qa/qa_daemon.py \
872
	qa/qa_env.py \
873
	qa/qa_error.py \
874
	qa/qa_group.py \
875
	qa/qa_instance.py \
876
	qa/qa_instance_utils.py \
877
	qa/qa_job.py \
878
	qa/qa_monitoring.py \
879
	qa/qa_node.py \
880
	qa/qa_os.py \
881
	qa/qa_rapi.py \
882
	qa/qa_tags.py \
883
	qa/qa_utils.py
884

    
885
bin_SCRIPTS =
886
if WANT_HTOOLS
887
bin_SCRIPTS += $(HS_BIN_PROGS)
888
install-exec-hook:
889
	@mkdir_p@ $(DESTDIR)$(iallocatorsdir)
890
# FIXME: this is a hardcoded logic, instead of auto-resolving
891
	$(LN_S) -f ../../../bin/htools \
892
	  $(DESTDIR)$(iallocatorsdir)/hail
893
	for role in $(HS_BIN_ROLES); do \
894
	  $(LN_S) -f htools $(DESTDIR)$(bindir)/$$role ; \
895
	done
896
endif
897

    
898
$(HS_ALL_PROGS): %: %.hs $(HS_LIBTESTBUILT_SRCS) Makefile
899
	@if [ "$(notdir $@)" = "test" ] && [ "$(HS_NODEV)" ]; then \
900
	  echo "Error: cannot run unittests without the development" \
901
	       " libraries (see devnotes.rst)" 1>&2; \
902
	  exit 1; \
903
	fi
904
	@rm -f $(notdir $@).tix
905
	$(GHC) --make \
906
	  $(HFLAGS) \
907
	  $(HS_PARALLEL3) $(HS_REGEX_PCRE) \
908
	  -osuf $(notdir $@).o -hisuf $(notdir $@).hi \
909
	  $(HEXTRA) $(HEXTRA_INT) $@
910
	@touch "$@"
911

    
912
# for the test/hs/htest binary, we need to enable profiling/coverage
913
test/hs/htest: HEXTRA_INT=-fhpc -itest/hs
914

    
915
# we compile the hpc-htools binary with the program coverage
916
test/hs/hpc-htools: HEXTRA_INT=-fhpc
917

    
918
# we compile the hpc-mon-collector binary with the program coverage
919
test/hs/hpc-mon-collector: HEXTRA_INT=-fhpc
920

    
921
# test dependency
922
test/hs/offline-test.sh: test/hs/hpc-htools test/hs/hpc-mon-collector
923

    
924
# rules for building profiling-enabled versions of the haskell
925
# programs: hs-prof does the full two-step build, whereas
926
# hs-prof-quick does only the final rebuild (hs-prof must have been
927
# run before)
928
.PHONY: hs-prof hs-prof-quick
929
hs-prof:
930
	@if [ -z "$(TARGET)" ]; then \
931
	  echo "You need to define TARGET when running this rule" 1>&2; \
932
	  exit 1; \
933
	fi
934
	$(MAKE) $(AM_MAKEFLAGS) clean
935
	$(MAKE) $(AM_MAKEFLAGS) $(TARGET) HEXTRA="-osuf o"
936
	rm -f $(HS_ALL_PROGS)
937
	$(MAKE) $(AM_MAKEFLAGS) hs-prof-quick
938

    
939
hs-prof-quick:
940
	@if [ -z "$(TARGET)" ]; then \
941
	  echo "You need to define TARGET when running this rule" 1>&2; \
942
	  exit 1; \
943
	fi
944
	$(MAKE) $(AM_MAKEFLAGS) $(TARGET) HEXTRA="-osuf prof_o -prof -auto-all"
945

    
946
dist_sbin_SCRIPTS = \
947
	tools/ganeti-listrunner
948

    
949
nodist_sbin_SCRIPTS = \
950
	$(PYTHON_BOOTSTRAP_SBIN) \
951
	daemons/ganeti-cleaner
952

    
953
# strip path prefixes off the sbin scripts
954
all_sbin_scripts = \
955
	$(patsubst tools/%,%,$(patsubst daemons/%,%,$(patsubst scripts/%,%,\
956
	$(patsubst src/%,%,$(dist_sbin_SCRIPTS) $(nodist_sbin_SCRIPTS)))))
957

    
958
if ENABLE_CONFD
959
src/ganeti-confd: src/hconfd
960
	cp -f $< $@
961

    
962
src/ganeti-luxid: src/hluxid
963
	cp -f $< $@
964

    
965
nodist_sbin_SCRIPTS += src/ganeti-confd
966
nodist_sbin_SCRIPTS += src/ganeti-luxid
967
endif
968

    
969
if ENABLE_MOND
970
nodist_sbin_SCRIPTS += src/ganeti-mond
971
endif
972

    
973
python_scripts = \
974
	tools/cfgshell \
975
	tools/cfgupgrade \
976
	tools/cfgupgrade12 \
977
	tools/cluster-merge \
978
	tools/confd-client \
979
	tools/fmtjson \
980
	tools/lvmstrap \
981
	tools/move-instance \
982
	tools/ovfconverter \
983
	tools/sanitize-config
984

    
985
dist_tools_SCRIPTS = \
986
	$(python_scripts) \
987
	tools/burnin \
988
	tools/kvm-console-wrapper \
989
	tools/master-ip-setup \
990
	tools/xen-console-wrapper
991

    
992
nodist_tools_python_scripts = \
993
	tools/node-cleanup
994

    
995
nodist_tools_SCRIPTS = \
996
	$(nodist_tools_python_scripts) \
997
	tools/users-setup \
998
	tools/vcluster-setup
999

    
1000
pkglib_python_scripts = \
1001
	daemons/import-export \
1002
	tools/check-cert-expired
1003

    
1004
nodist_pkglib_python_scripts = \
1005
	tools/ensure-dirs \
1006
	tools/node-daemon-setup \
1007
	tools/prepare-node-join
1008

    
1009
myexeclib_SCRIPTS = \
1010
	daemons/daemon-util \
1011
	tools/kvm-ifup \
1012
	tools/vif-ganeti \
1013
	tools/net-common \
1014
	$(pkglib_python_scripts) \
1015
	$(HS_MYEXECLIB_PROGS)
1016

    
1017
nodist_myexeclib_SCRIPTS = \
1018
	$(nodist_pkglib_python_scripts)
1019

    
1020
# strip path prefixes off the lib python scripts
1021
all_myexeclib_scripts = \
1022
	$(patsubst tools/%,%,$(patsubst daemons/%,%,\
1023
	$(patsubst src/%,%,$(myexeclib_SCRIPTS) $(nodist_myexeclib_SCRIPTS))))
1024

    
1025
EXTRA_DIST = \
1026
	NEWS \
1027
	UPGRADE \
1028
	epydoc.conf.in \
1029
	pylintrc \
1030
	pylintrc-test \
1031
	autotools/build-bash-completion \
1032
	autotools/build-rpc \
1033
	autotools/check-header \
1034
	autotools/check-imports \
1035
	autotools/check-man-dashes \
1036
	autotools/check-man-references \
1037
	autotools/check-man-warnings \
1038
	autotools/check-news \
1039
	autotools/check-python-code \
1040
	autotools/check-tar \
1041
	autotools/check-version \
1042
	autotools/convert-constants \
1043
	autotools/docpp \
1044
	autotools/gen-py-coverage \
1045
	autotools/sphinx-wrapper \
1046
	autotools/testrunner \
1047
	autotools/wrong-hardcoded-paths \
1048
	$(RUN_IN_TEMPDIR) \
1049
	daemons/daemon-util.in \
1050
	daemons/ganeti-cleaner.in \
1051
	$(pkglib_python_scripts) \
1052
	devel/upload \
1053
	devel/webserver \
1054
	tools/kvm-ifup.in \
1055
	tools/vif-ganeti.in \
1056
	tools/net-common.in \
1057
	tools/users-setup.in \
1058
	tools/vcluster-setup.in \
1059
	$(docinput) \
1060
	doc/html \
1061
	$(BUILT_EXAMPLES:%=%.in) \
1062
	doc/examples/ganeti.default \
1063
	doc/examples/ganeti.default-debug \
1064
	doc/examples/hooks/ethers \
1065
	doc/examples/gnt-debug/README \
1066
	doc/examples/gnt-debug/delay0.json \
1067
	doc/examples/gnt-debug/delay50.json \
1068
	$(dist_TESTS) \
1069
	$(TEST_FILES) \
1070
	$(python_test_support) \
1071
	man/footer.rst \
1072
	$(manrst) \
1073
	$(maninput) \
1074
	qa/qa-sample.json \
1075
	$(qa_scripts) \
1076
	$(HS_LIBTEST_SRCS) $(HS_BUILT_SRCS_IN) \
1077
	$(HS_PROG_SRCS) \
1078
	src/lint-hints.hs \
1079
	test/hs/cli-tests-defs.sh \
1080
	test/hs/offline-test.sh \
1081
	.ghci
1082

    
1083
man_MANS = \
1084
	man/ganeti-cleaner.8 \
1085
	man/ganeti-confd.8 \
1086
	man/ganeti-luxid.8 \
1087
	man/ganeti-listrunner.8 \
1088
	man/ganeti-masterd.8 \
1089
	man/ganeti-mond.8 \
1090
	man/ganeti-noded.8 \
1091
	man/ganeti-os-interface.7 \
1092
	man/ganeti-extstorage-interface.7 \
1093
	man/ganeti-rapi.8 \
1094
	man/ganeti-watcher.8 \
1095
	man/ganeti.7 \
1096
	man/gnt-backup.8 \
1097
	man/gnt-cluster.8 \
1098
	man/gnt-debug.8 \
1099
	man/gnt-group.8 \
1100
	man/gnt-network.8 \
1101
	man/gnt-instance.8 \
1102
	man/gnt-job.8 \
1103
	man/gnt-node.8 \
1104
	man/gnt-os.8 \
1105
	man/gnt-storage.8 \
1106
	man/hail.1 \
1107
	man/harep.1 \
1108
	man/hbal.1 \
1109
	man/hcheck.1 \
1110
	man/hinfo.1 \
1111
	man/hscan.1 \
1112
	man/hspace.1 \
1113
	man/hroller.1 \
1114
	man/htools.1 \
1115
	man/mon-collector.7
1116

    
1117
# Remove extensions from all filenames in man_MANS
1118
mannoext = $(patsubst %.1,%,$(patsubst %.7,%,$(patsubst %.8,%,$(man_MANS))))
1119

    
1120
manrst = $(patsubst %,%.rst,$(mannoext))
1121
manhtml = $(patsubst %.rst,%.html,$(manrst))
1122
mangen = $(patsubst %.rst,%.gen,$(manrst))
1123
maninput = \
1124
	$(patsubst %.1,%.1.in,$(patsubst %.7,%.7.in,$(patsubst %.8,%.8.in,$(man_MANS)))) \
1125
	$(patsubst %.html,%.html.in,$(manhtml)) \
1126
	$(mangen)
1127

    
1128
manfullpath = $(patsubst man/%.1,man1/%.1,\
1129
	$(patsubst man/%.7,man7/%.7,\
1130
	$(patsubst man/%.8,man8/%.8,$(man_MANS))))
1131

    
1132
TEST_FILES = \
1133
	test/autotools/autotools-check-news.test \
1134
	test/data/htools/clean-nonzero-score.data \
1135
	test/data/htools/common-suffix.data \
1136
	test/data/htools/empty-cluster.data \
1137
	test/data/htools/hail-alloc-drbd.json \
1138
	test/data/htools/hail-alloc-invalid-network.json \
1139
	test/data/htools/hail-alloc-invalid-twodisks.json \
1140
	test/data/htools/hail-alloc-restricted-network.json \
1141
	test/data/htools/hail-alloc-spindles.json \
1142
	test/data/htools/hail-alloc-twodisks.json \
1143
	test/data/htools/hail-change-group.json \
1144
	test/data/htools/hail-invalid-reloc.json \
1145
	test/data/htools/hail-node-evac.json \
1146
	test/data/htools/hail-reloc-drbd.json \
1147
	test/data/htools/hbal-excl-tags.data \
1148
	test/data/htools/hbal-split-insts.data \
1149
	test/data/htools/hspace-tiered-dualspec-exclusive.data \
1150
	test/data/htools/hspace-tiered-dualspec.data \
1151
	test/data/htools/hspace-tiered-exclusive.data \
1152
	test/data/htools/hspace-tiered-ipolicy.data \
1153
	test/data/htools/hspace-tiered-mixed.data \
1154
	test/data/htools/hspace-tiered-resourcetypes.data \
1155
	test/data/htools/hspace-tiered-vcpu.data \
1156
	test/data/htools/hspace-tiered.data \
1157
	test/data/htools/invalid-node.data \
1158
	test/data/htools/missing-resources.data \
1159
	test/data/htools/multiple-master.data \
1160
	test/data/htools/multiple-tags.data \
1161
	test/data/htools/n1-failure.data \
1162
	test/data/htools/rapi/groups.json \
1163
	test/data/htools/rapi/info.json \
1164
	test/data/htools/rapi/instances.json \
1165
	test/data/htools/rapi/nodes.json \
1166
	test/data/htools/hroller-full.data \
1167
	test/data/htools/hroller-nodegroups.data \
1168
	test/data/htools/hroller-nonredundant.data \
1169
	test/data/htools/hroller-online.data \
1170
	test/data/htools/unique-reboot-order.data \
1171
	test/hs/shelltests/htools-balancing.test \
1172
	test/hs/shelltests/htools-basic.test \
1173
	test/hs/shelltests/htools-dynutil.test \
1174
	test/hs/shelltests/htools-excl.test \
1175
	test/hs/shelltests/htools-hail.test \
1176
	test/hs/shelltests/htools-hroller.test \
1177
	test/hs/shelltests/htools-hspace.test \
1178
	test/hs/shelltests/htools-invalid.test \
1179
	test/hs/shelltests/htools-multi-group.test \
1180
	test/hs/shelltests/htools-no-backend.test \
1181
	test/hs/shelltests/htools-rapi.test \
1182
	test/hs/shelltests/htools-single-group.test \
1183
	test/hs/shelltests/htools-text-backend.test \
1184
	test/hs/shelltests/htools-mon-collector.test \
1185
	test/data/bdev-drbd-8.0.txt \
1186
	test/data/bdev-drbd-8.3.txt \
1187
	test/data/bdev-drbd-8.4.txt \
1188
	test/data/bdev-drbd-8.4-no-disk-params.txt \
1189
	test/data/bdev-drbd-disk.txt \
1190
	test/data/bdev-drbd-net-ip4.txt \
1191
	test/data/bdev-drbd-net-ip6.txt \
1192
	test/data/bdev-rbd/json_output_empty.txt \
1193
	test/data/bdev-rbd/json_output_extra_matches.txt \
1194
	test/data/bdev-rbd/json_output_no_matches.txt \
1195
	test/data/bdev-rbd/json_output_ok.txt \
1196
	test/data/bdev-rbd/plain_output_new_extra_matches.txt \
1197
	test/data/bdev-rbd/plain_output_new_no_matches.txt \
1198
	test/data/bdev-rbd/plain_output_new_ok.txt \
1199
	test/data/bdev-rbd/plain_output_old_empty.txt \
1200
	test/data/bdev-rbd/plain_output_old_extra_matches.txt \
1201
	test/data/bdev-rbd/plain_output_old_no_matches.txt \
1202
	test/data/bdev-rbd/plain_output_old_ok.txt \
1203
	test/data/bdev-rbd/output_invalid.txt \
1204
	test/data/cert1.pem \
1205
	test/data/cert2.pem \
1206
	test/data/cluster_config_2.7.json \
1207
	test/data/cluster_config_2.8.json \
1208
	test/data/cluster_config_2.9.json \
1209
	test/data/instance-minor-pairing.txt \
1210
	test/data/instance-prim-sec.txt \
1211
	test/data/ip-addr-show-dummy0.txt \
1212
	test/data/ip-addr-show-lo-ipv4.txt \
1213
	test/data/ip-addr-show-lo-ipv6.txt \
1214
	test/data/ip-addr-show-lo-oneline-ipv4.txt \
1215
	test/data/ip-addr-show-lo-oneline-ipv6.txt \
1216
	test/data/ip-addr-show-lo-oneline.txt \
1217
	test/data/ip-addr-show-lo.txt \
1218
	test/data/kvm_0.12.5_help.txt \
1219
	test/data/kvm_0.15.90_help.txt \
1220
	test/data/kvm_0.9.1_help.txt \
1221
	test/data/kvm_0.9.1_help_boot_test.txt \
1222
	test/data/kvm_1.0_help.txt \
1223
	test/data/kvm_1.1.2_help.txt \
1224
	test/data/lvs_lv.txt \
1225
	test/data/NEWS_OK.txt \
1226
	test/data/NEWS_previous_unreleased.txt \
1227
	test/data/ovfdata/compr_disk.vmdk.gz \
1228
	test/data/ovfdata/config.ini \
1229
	test/data/ovfdata/corrupted_resources.ovf \
1230
	test/data/ovfdata/empty.ini \
1231
	test/data/ovfdata/empty.ovf \
1232
	test/data/ovfdata/ganeti.mf \
1233
	test/data/ovfdata/ganeti.ovf \
1234
	test/data/ovfdata/gzip_disk.ovf \
1235
	test/data/ovfdata/new_disk.vmdk \
1236
	test/data/ovfdata/no_disk.ini \
1237
	test/data/ovfdata/no_disk_in_ref.ovf \
1238
	test/data/ovfdata/no_os.ini \
1239
	test/data/ovfdata/no_ovf.ova \
1240
	test/data/ovfdata/other/rawdisk.raw \
1241
	test/data/ovfdata/ova.ova \
1242
	test/data/ovfdata/rawdisk.raw \
1243
	test/data/ovfdata/second_disk.vmdk \
1244
	test/data/ovfdata/unsafe_path.ini \
1245
	test/data/ovfdata/virtualbox.ovf \
1246
	test/data/ovfdata/wrong_config.ini \
1247
	test/data/ovfdata/wrong_extension.ovd \
1248
	test/data/ovfdata/wrong_manifest.mf \
1249
	test/data/ovfdata/wrong_manifest.ovf \
1250
	test/data/ovfdata/wrong_ova.ova \
1251
	test/data/ovfdata/wrong_xml.ovf \
1252
	test/data/proc_diskstats.txt \
1253
	test/data/proc_drbd8.txt \
1254
	test/data/proc_drbd80-emptyline.txt \
1255
	test/data/proc_drbd80-emptyversion.txt \
1256
	test/data/proc_drbd83.txt \
1257
	test/data/proc_drbd83_sync.txt \
1258
	test/data/proc_drbd83_sync_want.txt \
1259
	test/data/proc_drbd83_sync_krnl2.6.39.txt \
1260
	test/data/proc_drbd84.txt \
1261
	test/data/proc_drbd84_sync.txt \
1262
	test/data/qa-minimal-nodes-instances-only.json \
1263
	test/data/sys_drbd_usermode_helper.txt \
1264
	test/data/vgreduce-removemissing-2.02.02.txt \
1265
	test/data/vgreduce-removemissing-2.02.66-fail.txt \
1266
	test/data/vgreduce-removemissing-2.02.66-ok.txt \
1267
	test/data/vgs-missing-pvs-2.02.02.txt \
1268
	test/data/vgs-missing-pvs-2.02.66.txt \
1269
	test/data/xen-xm-info-4.0.1.txt \
1270
	test/data/xen-xm-list-4.0.1-dom0-only.txt \
1271
	test/data/xen-xm-list-4.0.1-four-instances.txt \
1272
	test/data/xen-xm-list-long-4.0.1.txt \
1273
	test/data/xen-xm-uptime-4.0.1.txt \
1274
	test/py/ganeti-cli.test \
1275
	test/py/gnt-cli.test \
1276
	test/py/import-export_unittest-helper
1277

    
1278

    
1279
python_tests = \
1280
	doc/examples/rapi_testutils.py \
1281
	test/py/cmdlib/cluster_unittest.py \
1282
	test/py/cmdlib/cmdlib_unittest.py \
1283
	test/py/cmdlib/group_unittest.py \
1284
	test/py/cmdlib/instance_unittest.py \
1285
	test/py/cmdlib/instance_storage_unittest.py \
1286
	test/py/cmdlib/test_unittest.py \
1287
	test/py/cfgupgrade_unittest.py \
1288
	test/py/docs_unittest.py \
1289
	test/py/ganeti.asyncnotifier_unittest.py \
1290
	test/py/ganeti.backend_unittest-runasroot.py \
1291
	test/py/ganeti.backend_unittest.py \
1292
	test/py/ganeti.bootstrap_unittest.py \
1293
	test/py/ganeti.cli_unittest.py \
1294
	test/py/ganeti.client.gnt_cluster_unittest.py \
1295
	test/py/ganeti.client.gnt_instance_unittest.py \
1296
	test/py/ganeti.client.gnt_job_unittest.py \
1297
	test/py/ganeti.compat_unittest.py \
1298
	test/py/ganeti.confd.client_unittest.py \
1299
	test/py/ganeti.config_unittest.py \
1300
	test/py/ganeti.constants_unittest.py \
1301
	test/py/ganeti.daemon_unittest.py \
1302
	test/py/ganeti.errors_unittest.py \
1303
	test/py/ganeti.hooks_unittest.py \
1304
	test/py/ganeti.ht_unittest.py \
1305
	test/py/ganeti.http_unittest.py \
1306
	test/py/ganeti.hypervisor.hv_chroot_unittest.py \
1307
	test/py/ganeti.hypervisor.hv_fake_unittest.py \
1308
	test/py/ganeti.hypervisor.hv_kvm_unittest.py \
1309
	test/py/ganeti.hypervisor.hv_lxc_unittest.py \
1310
	test/py/ganeti.hypervisor.hv_xen_unittest.py \
1311
	test/py/ganeti.hypervisor_unittest.py \
1312
	test/py/ganeti.impexpd_unittest.py \
1313
	test/py/ganeti.jqueue_unittest.py \
1314
	test/py/ganeti.jstore_unittest.py \
1315
	test/py/ganeti.locking_unittest.py \
1316
	test/py/ganeti.luxi_unittest.py \
1317
	test/py/ganeti.masterd.iallocator_unittest.py \
1318
	test/py/ganeti.masterd.instance_unittest.py \
1319
	test/py/ganeti.mcpu_unittest.py \
1320
	test/py/ganeti.netutils_unittest.py \
1321
	test/py/ganeti.objects_unittest.py \
1322
	test/py/ganeti.opcodes_unittest.py \
1323
	test/py/ganeti.outils_unittest.py \
1324
	test/py/ganeti.ovf_unittest.py \
1325
	test/py/ganeti.qlang_unittest.py \
1326
	test/py/ganeti.query_unittest.py \
1327
	test/py/ganeti.rapi.baserlib_unittest.py \
1328
	test/py/ganeti.rapi.client_unittest.py \
1329
	test/py/ganeti.rapi.resources_unittest.py \
1330
	test/py/ganeti.rapi.rlib2_unittest.py \
1331
	test/py/ganeti.rapi.testutils_unittest.py \
1332
	test/py/ganeti.rpc_unittest.py \
1333
	test/py/ganeti.runtime_unittest.py \
1334
	test/py/ganeti.serializer_unittest.py \
1335
	test/py/ganeti.server.rapi_unittest.py \
1336
	test/py/ganeti.ssconf_unittest.py \
1337
	test/py/ganeti.ssh_unittest.py \
1338
	test/py/ganeti.storage.bdev_unittest.py \
1339
	test/py/ganeti.storage.container_unittest.py \
1340
	test/py/ganeti.storage.drbd_unittest.py \
1341
	test/py/ganeti.storage.filestorage_unittest.py \
1342
	test/py/ganeti.tools.burnin_unittest.py \
1343
	test/py/ganeti.tools.ensure_dirs_unittest.py \
1344
	test/py/ganeti.tools.node_daemon_setup_unittest.py \
1345
	test/py/ganeti.tools.prepare_node_join_unittest.py \
1346
	test/py/ganeti.uidpool_unittest.py \
1347
	test/py/ganeti.utils.algo_unittest.py \
1348
	test/py/ganeti.utils.filelock_unittest.py \
1349
	test/py/ganeti.utils.hash_unittest.py \
1350
	test/py/ganeti.utils.io_unittest-runasroot.py \
1351
	test/py/ganeti.utils.io_unittest.py \
1352
	test/py/ganeti.utils.log_unittest.py \
1353
	test/py/ganeti.utils.lvm_unittest.py \
1354
	test/py/ganeti.utils.mlock_unittest.py \
1355
	test/py/ganeti.utils.nodesetup_unittest.py \
1356
	test/py/ganeti.utils.process_unittest.py \
1357
	test/py/ganeti.utils.retry_unittest.py \
1358
	test/py/ganeti.utils.storage_unittest.py \
1359
	test/py/ganeti.utils.text_unittest.py \
1360
	test/py/ganeti.utils.wrapper_unittest.py \
1361
	test/py/ganeti.utils.x509_unittest.py \
1362
	test/py/ganeti.utils_unittest.py \
1363
	test/py/ganeti.vcluster_unittest.py \
1364
	test/py/ganeti.workerpool_unittest.py \
1365
	test/py/pycurl_reset_unittest.py \
1366
	test/py/qa.qa_config_unittest.py \
1367
	test/py/tempfile_fork_unittest.py
1368

    
1369
python_test_support = \
1370
	test/py/__init__.py \
1371
	test/py/lockperf.py \
1372
	test/py/testutils.py \
1373
	test/py/mocks.py \
1374
	test/py/cmdlib/__init__.py \
1375
	test/py/cmdlib/testsupport/__init__.py \
1376
	test/py/cmdlib/testsupport/cmdlib_testcase.py \
1377
	test/py/cmdlib/testsupport/config_mock.py \
1378
	test/py/cmdlib/testsupport/iallocator_mock.py \
1379
	test/py/cmdlib/testsupport/lock_manager_mock.py \
1380
	test/py/cmdlib/testsupport/netutils_mock.py \
1381
	test/py/cmdlib/testsupport/processor_mock.py \
1382
	test/py/cmdlib/testsupport/rpc_runner_mock.py \
1383
	test/py/cmdlib/testsupport/ssh_mock.py \
1384
	test/py/cmdlib/testsupport/util.py
1385

    
1386
haskell_tests = test/hs/htest
1387

    
1388
dist_TESTS = \
1389
	test/py/check-cert-expired_unittest.bash \
1390
	test/py/daemon-util_unittest.bash \
1391
	test/py/ganeti-cleaner_unittest.bash \
1392
	test/py/import-export_unittest.bash \
1393
	test/py/cli-test.bash \
1394
	test/py/bash_completion.bash
1395

    
1396
if PY_UNIT
1397
dist_TESTS += $(python_tests)
1398
endif
1399

    
1400
nodist_TESTS =
1401
check_SCRIPTS =
1402

    
1403
if WANT_HSTESTS
1404
nodist_TESTS += $(haskell_tests)
1405
dist_TESTS += test/hs/offline-test.sh
1406
check_SCRIPTS += \
1407
	test/hs/hpc-htools \
1408
	test/hs/hpc-mon-collector \
1409
	$(HS_BUILT_TEST_HELPERS)
1410
endif
1411

    
1412
TESTS = $(dist_TESTS) $(nodist_TESTS)
1413

    
1414
# Environment for all tests
1415
PLAIN_TESTS_ENVIRONMENT = \
1416
	PYTHONPATH=.:./test/py \
1417
	TOP_SRCDIR=$(abs_top_srcdir) TOP_BUILDDIR=$(abs_top_builddir) \
1418
	PYTHON=$(PYTHON) FAKEROOT=$(FAKEROOT_PATH) \
1419
	$(RUN_IN_TEMPDIR)
1420

    
1421
# Environment for tests run by automake
1422
TESTS_ENVIRONMENT = \
1423
	$(PLAIN_TESTS_ENVIRONMENT) $(abs_top_srcdir)/autotools/testrunner
1424

    
1425
all_python_code = \
1426
	$(dist_sbin_SCRIPTS) \
1427
	$(python_scripts) \
1428
	$(pkglib_python_scripts) \
1429
	$(nodist_pkglib_python_scripts) \
1430
	$(nodist_tools_python_scripts) \
1431
	$(pkgpython_PYTHON) \
1432
	$(client_PYTHON) \
1433
	$(cmdlib_PYTHON) \
1434
	$(hypervisor_PYTHON) \
1435
	$(storage_PYTHON) \
1436
	$(rapi_PYTHON) \
1437
	$(server_PYTHON) \
1438
	$(pytools_PYTHON) \
1439
	$(http_PYTHON) \
1440
	$(confd_PYTHON) \
1441
	$(masterd_PYTHON) \
1442
	$(impexpd_PYTHON) \
1443
	$(utils_PYTHON) \
1444
	$(watcher_PYTHON) \
1445
	$(noinst_PYTHON) \
1446
	$(qa_scripts)
1447

    
1448
if PY_UNIT
1449
all_python_code += $(python_tests)
1450
all_python_code += $(python_test_support)
1451
endif
1452

    
1453
srclink_files = \
1454
	man/footer.rst \
1455
	test/py/check-cert-expired_unittest.bash \
1456
	test/py/daemon-util_unittest.bash \
1457
	test/py/ganeti-cleaner_unittest.bash \
1458
	test/py/import-export_unittest.bash \
1459
	test/py/cli-test.bash \
1460
	test/py/bash_completion.bash \
1461
	test/hs/offline-test.sh \
1462
	test/hs/cli-tests-defs.sh \
1463
	$(all_python_code) \
1464
	$(HS_LIBTEST_SRCS) $(HS_PROG_SRCS) \
1465
	$(docinput)
1466

    
1467
check_python_code = \
1468
	$(BUILD_BASH_COMPLETION) \
1469
	$(CHECK_IMPORTS) \
1470
	$(CHECK_HEADER) \
1471
	$(DOCPP) \
1472
	$(all_python_code)
1473

    
1474
lint_python_code = \
1475
	ganeti \
1476
	ganeti/http/server.py \
1477
	$(dist_sbin_SCRIPTS) \
1478
	$(python_scripts) \
1479
	$(pkglib_python_scripts) \
1480
	$(BUILD_BASH_COMPLETION) \
1481
	$(CHECK_IMPORTS) \
1482
	$(CHECK_HEADER) \
1483
	$(DOCPP) \
1484
	$(PYTHON_BOOTSTRAP)
1485

    
1486
standalone_python_modules = \
1487
	lib/rapi/client.py \
1488
	tools/ganeti-listrunner
1489

    
1490
pep8_python_code = \
1491
	ganeti \
1492
	ganeti/http/server.py \
1493
	$(dist_sbin_SCRIPTS) \
1494
	$(python_scripts) \
1495
	$(pkglib_python_scripts) \
1496
	$(BUILD_BASH_COMPLETION) \
1497
	$(CHECK_HEADER) \
1498
	$(DOCPP) \
1499
	$(PYTHON_BOOTSTRAP) \
1500
	qa \
1501
	$(python_test_support)
1502

    
1503
test/py/daemon-util_unittest.bash: daemons/daemon-util
1504

    
1505
test/py/ganeti-cleaner_unittest.bash: daemons/ganeti-cleaner
1506

    
1507
test/py/bash_completion.bash: doc/examples/bash_completion-debug
1508

    
1509
tools/kvm-ifup: tools/kvm-ifup.in $(REPLACE_VARS_SED)
1510
	sed -f $(REPLACE_VARS_SED) < $< > $@
1511
	chmod +x $@
1512

    
1513
tools/vif-ganeti: tools/vif-ganeti.in $(REPLACE_VARS_SED)
1514
	sed -f $(REPLACE_VARS_SED) < $< > $@
1515
	chmod +x $@
1516

    
1517
tools/net-common: tools/net-common.in $(REPLACE_VARS_SED)
1518
	sed -f $(REPLACE_VARS_SED) < $< > $@
1519
	chmod +x $@
1520

    
1521
tools/users-setup: tools/users-setup.in $(REPLACE_VARS_SED)
1522
	sed -f $(REPLACE_VARS_SED) < $< > $@
1523
	chmod +x $@
1524

    
1525
tools/vcluster-setup: tools/vcluster-setup.in $(REPLACE_VARS_SED)
1526
	sed -f $(REPLACE_VARS_SED) < $< > $@
1527
	chmod +x $@
1528

    
1529
daemons/%:: daemons/%.in $(REPLACE_VARS_SED)
1530
	sed -f $(REPLACE_VARS_SED) < $< > $@
1531
	chmod +x $@
1532

    
1533
doc/examples/%:: doc/examples/%.in $(REPLACE_VARS_SED)
1534
	sed -f $(REPLACE_VARS_SED) < $< > $@
1535

    
1536
doc/examples/bash_completion: BC_ARGS = --compact
1537
doc/examples/bash_completion-debug: BC_ARGS =
1538

    
1539
doc/examples/bash_completion doc/examples/bash_completion-debug: \
1540
	$(BUILD_BASH_COMPLETION) $(RUN_IN_TEMPDIR) \
1541
	lib/cli.py $(gnt_scripts) $(client_PYTHON) tools/burnin \
1542
	daemons/ganeti-cleaner \
1543
	$(GENERATED_FILES) $(HS_GENERATED_FILES)
1544
	PYTHONPATH=. $(RUN_IN_TEMPDIR) \
1545
	  $(CURDIR)/$(BUILD_BASH_COMPLETION) $(BC_ARGS) > $@
1546

    
1547
man/%.gen: man/%.rst lib/query.py lib/build/sphinx_ext.py \
1548
	lib/build/shell_example_lexer.py \
1549
	| $(RUN_IN_TEMPDIR) $(BUILT_PYTHON_SOURCES)
1550
	@echo "Checking $< for hardcoded paths..."
1551
	@if grep -nEf autotools/wrong-hardcoded-paths $<; then \
1552
	  echo "Man page $< has hardcoded paths (see above)!" 1>&2 ; \
1553
	  exit 1; \
1554
	fi
1555
	set -e ; \
1556
	trap 'echo auto-removing $@; rm $@' EXIT; \
1557
	PYTHONPATH=. $(RUN_IN_TEMPDIR) $(CURDIR)/$(DOCPP) < $< > $@ ;\
1558
	$(CHECK_MAN_REFERENCES) $@; \
1559
	trap - EXIT
1560

    
1561
man/%.7.in man/%.8.in man/%.1.in: man/%.gen man/footer.rst
1562
	@test -n "$(PANDOC)" || \
1563
	  { echo 'pandoc' not found during configure; exit 1; }
1564
	set -o pipefail -e; \
1565
	trap 'echo auto-removing $@; rm $@' EXIT; \
1566
	$(PANDOC) -s -f rst -t man $< man/footer.rst | \
1567
	  sed -e 's/\\@/@/g' > $@; \
1568
	if test -n "$(MAN_HAS_WARNINGS)"; then $(CHECK_MAN_WARNINGS) $@; fi; \
1569
	$(CHECK_MAN_DASHES) $@; \
1570
	trap - EXIT
1571

    
1572
man/%.html.in: man/%.gen man/footer.rst
1573
	@test -n "$(PANDOC)" || \
1574
	  { echo 'pandoc' not found during configure; exit 1; }
1575
	set -o pipefail ; \
1576
	$(PANDOC) --toc -s -f rst -t html $< man/footer.rst | \
1577
	  sed -e 's/\\@/@/g' > $@
1578

    
1579
man/%: man/%.in  $(REPLACE_VARS_SED)
1580
	sed -f $(REPLACE_VARS_SED) < $< > $@
1581

    
1582
epydoc.conf: epydoc.conf.in $(REPLACE_VARS_SED)
1583
	sed -f $(REPLACE_VARS_SED) < $< > $@
1584

    
1585
vcs-version:
1586
	if test -d .git; then \
1587
	  git describe > $@; \
1588
	elif test ! -f $@ ; then \
1589
	  echo "Cannot auto-generate $@ file"; exit 1; \
1590
	fi
1591

    
1592
.PHONY: clean-vcs-version
1593
clean-vcs-version:
1594
	rm -f vcs-version
1595

    
1596
.PHONY: regen-vcs-version
1597
regen-vcs-version:
1598
	@set -e; \
1599
	cd $(srcdir); \
1600
	if test -d .git; then \
1601
	  T=`mktemp` ; trap 'rm -f $$T' EXIT; \
1602
	  git describe > $$T; \
1603
	  if ! cmp --quiet $$T vcs-version; then \
1604
	    mv $$T vcs-version; \
1605
	  fi; \
1606
	fi
1607

    
1608
src/Ganeti/Version.hs: src/Ganeti/Version.hs.in \
1609
	vcs-version $(built_base_sources)
1610
	set -e; \
1611
	VCSVER=`cat $(abs_top_srcdir)/vcs-version`; \
1612
	sed -e "s/%ver%/$$VCSVER/" < $< > $@
1613

    
1614
src/Ganeti/PyConstants.hs: src/Ganeti/PyConstants.hs.in \
1615
	lib/constants.py lib/_autoconf.py lib/luxi.py lib/errors.py \
1616
	lib/jstore.py $(RUN_IN_TEMPDIR) \
1617
	$(CONVERT_CONSTANTS) $(built_base_sources) \
1618
	| lib/_vcsversion.py
1619
	set -e; \
1620
	{ cat $< ; \
1621
	  PYTHONPATH=. $(RUN_IN_TEMPDIR) $(CURDIR)/$(CONVERT_CONSTANTS); \
1622
	} > $@
1623

    
1624
src/Ganeti/Curl/Internal.hs: src/Ganeti/Curl/Internal.hsc | stamp-directories
1625
	hsc2hs -o $@ $<
1626

    
1627
test/hs/Test/Ganeti/TestImports.hs: test/hs/Test/Ganeti/TestImports.hs.in \
1628
	$(built_base_sources)
1629
	set -e; \
1630
	{ cat $< ; \
1631
	  echo ; \
1632
	  for name in $(filter-out Ganeti.THH,$(subst /,.,$(patsubst %.hs,%,$(patsubst src/%,%,$(HS_LIB_SRCS))))) ; do \
1633
	    echo "import $$name ()" ; \
1634
	  done ; \
1635
	} > $@
1636

    
1637
lib/_autoconf.py: Makefile | stamp-directories
1638
	set -e; \
1639
	{ echo '# This file is automatically generated, do not edit!'; \
1640
	  echo '#'; \
1641
	  echo ''; \
1642
	  echo '"""Build-time configuration for Ganeti.'; \
1643
	  echo '';\
1644
	  echo 'This file is autogenerated by the build process.'; \
1645
	  echo 'For any changes you need to re-run ./configure (and'; \
1646
	  echo 'not edit by hand).'; \
1647
	  echo ''; \
1648
	  echo '"""'; \
1649
	  echo ''; \
1650
	  echo '# pylint: disable=C0301,C0324'; \
1651
	  echo '# because this is autogenerated, we do not want'; \
1652
	  echo '# style warnings' ; \
1653
	  echo ''; \
1654
	  echo "PACKAGE_VERSION = '$(PACKAGE_VERSION)'"; \
1655
	  echo "VERSION_MAJOR = '$(VERSION_MAJOR)'"; \
1656
	  echo "VERSION_MINOR = '$(VERSION_MINOR)'"; \
1657
	  echo "VERSION_REVISION = '$(VERSION_REVISION)'"; \
1658
	  echo "VERSION_SUFFIX = '$(VERSION_SUFFIX)'"; \
1659
	  echo "VERSION_FULL = '$(VERSION_FULL)'"; \
1660
	  echo "LOCALSTATEDIR = '$(localstatedir)'"; \
1661
	  echo "SYSCONFDIR = '$(sysconfdir)'"; \
1662
	  echo "SSH_CONFIG_DIR = '$(SSH_CONFIG_DIR)'"; \
1663
	  echo "SSH_LOGIN_USER = '$(SSH_LOGIN_USER)'"; \
1664
	  echo "SSH_CONSOLE_USER = '$(SSH_CONSOLE_USER)'"; \
1665
	  echo "EXPORT_DIR = '$(EXPORT_DIR)'"; \
1666
	  echo "OS_SEARCH_PATH = [$(OS_SEARCH_PATH)]"; \
1667
	  echo "ES_SEARCH_PATH = [$(ES_SEARCH_PATH)]"; \
1668
	  echo "XEN_BOOTLOADER = '$(XEN_BOOTLOADER)'"; \
1669
	  echo "XEN_CONFIG_DIR = '$(XEN_CONFIG_DIR)'"; \
1670
	  echo "XEN_KERNEL = '$(XEN_KERNEL)'"; \
1671
	  echo "XEN_INITRD = '$(XEN_INITRD)'"; \
1672
	  echo "KVM_KERNEL = '$(KVM_KERNEL)'"; \
1673
	  echo "SHARED_FILE_STORAGE_DIR = '$(SHARED_FILE_STORAGE_DIR)'"; \
1674
	  echo "IALLOCATOR_SEARCH_PATH = [$(IALLOCATOR_SEARCH_PATH)]"; \
1675
	  echo "KVM_PATH = '$(KVM_PATH)'"; \
1676
	  echo "IP_PATH = '$(IP_PATH)'"; \
1677
	  echo "SOCAT_PATH = '$(SOCAT)'"; \
1678
	  echo "SOCAT_USE_ESCAPE = $(SOCAT_USE_ESCAPE)"; \
1679
	  echo "SOCAT_USE_COMPRESS = $(SOCAT_USE_COMPRESS)"; \
1680
	  echo "LVM_STRIPECOUNT = $(LVM_STRIPECOUNT)"; \
1681
	  echo "TOOLSDIR = '$(toolsdir)'"; \
1682
	  echo "GNT_SCRIPTS = [$(foreach i,$(notdir $(gnt_scripts)),'$(i)',)]"; \
1683
	  echo "HTOOLS_PROGS = [$(foreach i,$(HS_HTOOLS_PROGS),'$(i)',)]"; \
1684
	  echo "PKGLIBDIR = '$(pkglibdir)'"; \
1685
	  echo "DRBD_BARRIERS = '$(DRBD_BARRIERS)'"; \
1686
	  echo "DRBD_NO_META_FLUSH = $(DRBD_NO_META_FLUSH)"; \
1687
	  echo "SYSLOG_USAGE = '$(SYSLOG_USAGE)'"; \
1688
	  echo "DAEMONS_GROUP = '$(DAEMONS_GROUP)'"; \
1689
	  echo "ADMIN_GROUP = '$(ADMIN_GROUP)'"; \
1690
	  echo "MASTERD_USER = '$(MASTERD_USER)'"; \
1691
	  echo "MASTERD_GROUP = '$(MASTERD_GROUP)'"; \
1692
	  echo "RAPI_USER = '$(RAPI_USER)'"; \
1693
	  echo "RAPI_GROUP = '$(RAPI_GROUP)'"; \
1694
	  echo "CONFD_USER = '$(CONFD_USER)'"; \
1695
	  echo "CONFD_GROUP = '$(CONFD_GROUP)'"; \
1696
	  echo "LUXID_USER = '$(LUXID_USER)'"; \
1697
	  echo "LUXID_GROUP = '$(LUXID_GROUP)'"; \
1698
	  echo "NODED_USER = '$(NODED_USER)'"; \
1699
	  echo "NODED_GROUP = '$(NODED_GROUP)'"; \
1700
	  echo "MOND_USER = '$(MOND_USER)'"; \
1701
	  echo "MOND_GROUP = '$(MOND_GROUP)'"; \
1702
	  echo "DISK_SEPARATOR = '$(DISK_SEPARATOR)'"; \
1703
	  echo "QEMUIMG_PATH = '$(QEMUIMG_PATH)'"; \
1704
	  echo "HTOOLS = True"; \
1705
	  echo "ENABLE_CONFD = $(ENABLE_CONFD)"; \
1706
	  echo "XEN_CMD = '$(XEN_CMD)'"; \
1707
	  echo "ENABLE_SPLIT_QUERY = $(ENABLE_SPLIT_QUERY)"; \
1708
	  echo "ENABLE_RESTRICTED_COMMANDS = $(ENABLE_RESTRICTED_COMMANDS)"; \
1709
	  echo "ENABLE_MOND = $(ENABLE_MOND)"; \
1710
## Write dictionary with man page name as the key and the section number as the
1711
## value
1712
	  echo "MAN_PAGES = {"; \
1713
	  for i in $(notdir $(man_MANS)); do \
1714
	    echo "$$i" | sed -re 's/^(.*)\.([0-9]+)$$/  "\1": \2,/g'; \
1715
	  done; \
1716
	  echo "}"; \
1717
	} > $@
1718

    
1719
lib/_vcsversion.py: Makefile vcs-version | stamp-directories
1720
	set -e; \
1721
	VCSVER=`cat $(abs_top_srcdir)/vcs-version`; \
1722
	{ echo '# This file is automatically generated, do not edit!'; \
1723
	  echo '#'; \
1724
	  echo ''; \
1725
	  echo '"""Build-time VCS version number for Ganeti.'; \
1726
	  echo '';\
1727
	  echo 'This file is autogenerated by the build process.'; \
1728
	  echo 'For any changes you need to re-run ./configure (and'; \
1729
	  echo 'not edit by hand).'; \
1730
	  echo ''; \
1731
	  echo '"""'; \
1732
	  echo ''; \
1733
	  echo '# pylint: disable=C0301,C0324'; \
1734
	  echo '# because this is autogenerated, we do not want'; \
1735
	  echo '# style warnings' ; \
1736
	  echo ''; \
1737
	  echo "VCS_VERSION = '$$VCSVER'"; \
1738
	} > $@
1739

    
1740
lib/opcodes.py: Makefile src/hs2py src/Ganeti/PyConstants.hs \
1741
		lib/opcodes.py.in_before lib/opcodes.py.in_after \
1742
		| stamp-directories
1743
	cat $(abs_top_srcdir)/lib/opcodes.py.in_before > $@
1744
	src/hs2py >> $@
1745
	cat $(abs_top_srcdir)/lib/opcodes.py.in_after >> $@
1746

    
1747
lib/_generated_rpc.py: lib/rpc_defs.py $(BUILD_RPC)
1748
	PYTHONPATH=. $(RUN_IN_TEMPDIR) $(CURDIR)/$(BUILD_RPC) lib/rpc_defs.py > $@
1749

    
1750
$(SHELL_ENV_INIT): Makefile stamp-directories
1751
	set -e; \
1752
	{ echo '# Allow overriding for tests'; \
1753
	  echo 'readonly LOCALSTATEDIR=$${LOCALSTATEDIR:-$${GANETI_ROOTDIR:-}$(localstatedir)}'; \
1754
	  echo 'readonly SYSCONFDIR=$${SYSCONFDIR:-$${GANETI_ROOTDIR:-}$(sysconfdir)}'; \
1755
	  echo; \
1756
	  echo 'readonly PKGLIBDIR=$(pkglibdir)'; \
1757
	  echo 'readonly LOG_DIR="$$LOCALSTATEDIR/log/ganeti"'; \
1758
	  echo 'readonly RUN_DIR="$$LOCALSTATEDIR/run/ganeti"'; \
1759
	  echo 'readonly DATA_DIR="$$LOCALSTATEDIR/lib/ganeti"'; \
1760
	  echo 'readonly CONF_DIR="$$SYSCONFDIR/ganeti"'; \
1761
	} > $@
1762

    
1763
## Writes sed script to replace placeholders with build-time values. The
1764
## additional quotes after the first @ sign are necessary to stop configure
1765
## from replacing those values as well.
1766
$(REPLACE_VARS_SED): $(SHELL_ENV_INIT) Makefile stamp-directories
1767
	set -e; \
1768
	{ echo 's#@''PREFIX@#$(prefix)#g'; \
1769
	  echo 's#@''SYSCONFDIR@#$(sysconfdir)#g'; \
1770
	  echo 's#@''LOCALSTATEDIR@#$(localstatedir)#g'; \
1771
	  echo 's#@''BINDIR@#$(execprefix)/bin#g'; \
1772
	  echo 's#@''SBINDIR@#$(execprefix)/sbin#g'; \
1773
	  echo 's#@''LIBDIR@#$(libdir)#g'; \
1774
	  echo 's#@''GANETI_VERSION@#$(PACKAGE_VERSION)#g'; \
1775
	  echo 's#@''CUSTOM_XEN_BOOTLOADER@#$(XEN_BOOTLOADER)#g'; \
1776
	  echo 's#@''CUSTOM_XEN_KERNEL@#$(XEN_KERNEL)#g'; \
1777
	  echo 's#@''CUSTOM_XEN_INITRD@#$(XEN_INITRD)#g'; \
1778
	  echo 's#@''CUSTOM_IALLOCATOR_SEARCH_PATH@#$(IALLOCATOR_SEARCH_PATH)#g'; \
1779
	  echo 's#@''CUSTOM_EXPORT_DIR@#$(EXPORT_DIR)#g'; \
1780
	  echo 's#@''RPL_SSH_INITD_SCRIPT@#$(SSH_INITD_SCRIPT)#g'; \
1781
	  echo 's#@''PKGLIBDIR@#$(libdir)/ganeti#g'; \
1782
	  echo 's#@''GNTMASTERUSER@#$(MASTERD_USER)#g'; \
1783
	  echo 's#@''GNTRAPIUSER@#$(RAPI_USER)#g'; \
1784
	  echo 's#@''GNTCONFDUSER@#$(CONFD_USER)#g'; \
1785
	  echo 's#@''GNTLUXIDUSER@#$(LUXID_USER)#g'; \
1786
	  echo 's#@''GNTNODEDUSER@#$(NODED_USER)#g'; \
1787
	  echo 's#@''GNTMONDUSER@#$(MOND_USER)#g'; \
1788
	  echo 's#@''GNTRAPIGROUP@#$(RAPI_GROUP)#g'; \
1789
	  echo 's#@''GNTADMINGROUP@#$(ADMIN_GROUP)#g'; \
1790
	  echo 's#@''GNTCONFDGROUP@#$(CONFD_GROUP)#g'; \
1791
	  echo 's#@''GNTLUXIDGROUP@#$(LUXID_GROUP)#g'; \
1792
	  echo 's#@''GNTMASTERDGROUP@#$(MASTERD_GROUP)#g'; \
1793
	  echo 's#@''GNTMONDGROUP@#$(MOND_GROUP)#g'; \
1794
	  echo 's#@''GNTDAEMONSGROUP@#$(DAEMONS_GROUP)#g'; \
1795
	  echo 's#@''CUSTOM_ENABLE_CONFD@#$(ENABLE_CONFD)#g'; \
1796
	  echo 's#@''CUSTOM_ENABLE_MOND@#$(ENABLE_MOND)#g'; \
1797
	  echo 's#@''MODULES@#$(strip $(lint_python_code))#g'; \
1798
	  echo 's#@''XEN_CONFIG_DIR@#$(XEN_CONFIG_DIR)#g'; \
1799
	  echo; \
1800
	  echo '/^@SHELL_ENV_INIT@$$/ {'; \
1801
	  echo '  r $(SHELL_ENV_INIT)'; \
1802
	  echo '  d'; \
1803
	  echo '}'; \
1804
	} > $@
1805

    
1806
# Using deferred evaluation
1807
daemons/ganeti-%: MODULE = ganeti.server.$(patsubst ganeti-%,%,$(notdir $@))
1808
daemons/ganeti-watcher: MODULE = ganeti.watcher
1809
scripts/%: MODULE = ganeti.client.$(subst -,_,$(notdir $@))
1810
tools/burnin: MODULE = ganeti.tools.burnin
1811
tools/ensure-dirs: MODULE = ganeti.tools.ensure_dirs
1812
tools/node-daemon-setup: MODULE = ganeti.tools.node_daemon_setup
1813
tools/prepare-node-join: MODULE = ganeti.tools.prepare_node_join
1814
tools/node-cleanup: MODULE = ganeti.tools.node_cleanup
1815
$(HS_BUILT_TEST_HELPERS): TESTROLE = $(patsubst test/hs/%,%,$@)
1816

    
1817
$(PYTHON_BOOTSTRAP): Makefile | stamp-directories
1818
	test -n "$(MODULE)" || { echo Missing module; exit 1; }
1819
	set -e; \
1820
	{ echo '#!/usr/bin/python'; \
1821
	  echo '# This file is automatically generated, do not edit!'; \
1822
	  echo "# Edit $(MODULE) instead."; \
1823
	  echo; \
1824
	  echo '"""Bootstrap script for L{$(MODULE)}"""'; \
1825
	  echo; \
1826
	  echo '# pylint: disable=C0103'; \
1827
	  echo '# C0103: Invalid name'; \
1828
	  echo; \
1829
	  echo 'import sys'; \
1830
	  echo 'import $(MODULE) as main'; \
1831
	  echo; \
1832
	  echo '# Temporarily alias commands until bash completion'; \
1833
	  echo '# generator is changed'; \
1834
	  echo 'if hasattr(main, "commands"):'; \
1835
	  echo '  commands = main.commands # pylint: disable=E1101'; \
1836
	  echo 'if hasattr(main, "aliases"):'; \
1837
	  echo '  aliases = main.aliases # pylint: disable=E1101'; \
1838
	  echo; \
1839
	  echo 'if __name__ == "__main__":'; \
1840
	  echo '  sys.exit(main.Main())'; \
1841
	} > $@
1842
	chmod u+x $@
1843

    
1844
$(HS_BUILT_TEST_HELPERS): Makefile
1845
	@test -n "$(TESTROLE)" || { echo Missing TESTROLE; exit 1; }
1846
	set -e; \
1847
	{ echo '#!/bin/sh'; \
1848
	  echo '# This file is automatically generated, do not edit!'; \
1849
	  echo "# Edit Makefile.am instead."; \
1850
	  echo; \
1851
	  echo "HTOOLS=$(TESTROLE) exec ./test/hs/hpc-htools \"\$$@\""; \
1852
	} > $@
1853
	chmod u+x $@
1854

    
1855
stamp-directories: Makefile
1856
	$(MAKE) $(AM_MAKEFLAGS) ganeti
1857
	@mkdir_p@ $(DIRS) $(BUILDTIME_DIR_AUTOCREATE)
1858
	touch $@
1859

    
1860
# We need to create symlinks because "make distcheck" will not install Python
1861
# files when building.
1862
stamp-srclinks: Makefile | stamp-directories
1863
	set -e; \
1864
	for i in $(srclink_files); do \
1865
	  if test ! -f $$i -a -f $(abs_top_srcdir)/$$i; then \
1866
	    $(LN_S) $(abs_top_srcdir)/$$i $$i; \
1867
	  fi; \
1868
	done
1869
	touch $@
1870

    
1871
.PHONY: ganeti
1872
ganeti:
1873
	cd $(top_builddir) && test -h "$@" || { rm -f $@ && $(LN_S) lib $@; }
1874

    
1875
.PHONY: check-dirs
1876
check-dirs: $(GENERATED_FILES)
1877
	@set -e; \
1878
	find . -type d \( -name . -o -name .git -prune -o -print \) | { \
1879
	  error=; \
1880
	  while read dir; do \
1881
	    case "$$dir" in \
1882
	      $(strip $(patsubst %,(./%) ;;,$(DIRCHECK_EXCLUDE) $(DIRS))) \
1883
	      *) error=1; echo "Directory $$dir not listed in Makefile" >&2 ;; \
1884
	    esac; \
1885
	  done; \
1886
	  for dir in $(DIRS); do \
1887
	    if ! test -d "$$dir"; then \
1888
	      echo "Directory $$dir listed in DIRS does not exist" >&2; \
1889
	      error=1; \
1890
	    fi \
1891
	  done; \
1892
	  test -z "$$error"; \
1893
	}
1894

    
1895
.PHONY: check-local
1896
check-local: check-dirs $(GENERATED_FILES)
1897
	$(CHECK_PYTHON_CODE) $(check_python_code)
1898
	PYTHONPATH=. $(CHECK_HEADER) $(check_python_code)
1899
	$(CHECK_VERSION) $(VERSION) $(top_srcdir)/NEWS
1900
	RELEASE=$(PACKAGE_VERSION) $(CHECK_NEWS) < $(top_srcdir)/NEWS
1901
	PYTHONPATH=. $(RUN_IN_TEMPDIR) $(CURDIR)/$(CHECK_IMPORTS) . $(standalone_python_modules)
1902
	error= ; \
1903
	if [ "x`echo $(VERSION_SUFFIX)|grep 'alpha'`" == "x" ]; then \
1904
	  expver=$(VERSION_MAJOR).$(VERSION_MINOR); \
1905
	  if test "`head -n 1 $(top_srcdir)/README`" != "Ganeti $$expver"; then \
1906
	    echo "Incorrect version in README, expected $$expver" >&2; \
1907
	    error=1; \
1908
	  fi; \
1909
	  for file in doc/iallocator.rst doc/hooks.rst doc/virtual-cluster.rst \
1910
	      doc/security.rst; do \
1911
	    if test "`sed -ne '4 p' $(top_srcdir)/$$file`" != \
1912
	      "Documents Ganeti version $$expver"; then \
1913
	      echo "Incorrect version in $$file, expected $$expver" >&2; \
1914
	      error=1; \
1915
	    fi; \
1916
	  done; \
1917
	  if ! test -f $(top_srcdir)/doc/design-$$expver.rst; then \
1918
	    echo "File $(top_srcdir)/doc/design-$$expver.rst not found" >&2; \
1919
	    error=1; \
1920
	  fi; \
1921
	  if test "`sed -ne '5 p' $(top_srcdir)/doc/design-draft.rst`" != \
1922
	    ".. Last updated for Ganeti $$expver"; then \
1923
	    echo "doc/design-draft.rst was not updated for version $$expver" >&2; \
1924
	    error=1; \
1925
	  fi; \
1926
	fi; \
1927
	for file in configure.ac $(HS_LIBTEST_SRCS) $(HS_PROG_SRCS); do \
1928
	  if test $$(wc --max-line-length < $(top_srcdir)/$$file) -gt 80; then \
1929
	    echo "Longest line in $$file is longer than 80 characters" >&2; \
1930
	    error=1; \
1931
	  fi; \
1932
	done; \
1933
	test -z "$$error"
1934

    
1935
.PHONY: hs-test-%
1936
hs-test-%: test/hs/htest | $(BUILT_PYTHON_SOURCES)
1937
	@rm -f htest.tix
1938
	test/hs/htest -t $*
1939

    
1940
.PHONY: hs-tests
1941
hs-tests: test/hs/htest | $(BUILT_PYTHON_SOURCES)
1942
	@rm -f htest.tix
1943
	./test/hs/htest
1944

    
1945
.PHONY: hs-shell-%
1946
hs-shell-%: test/hs/hpc-htools test/hs/hpc-mon-collector \
1947
            $(HS_BUILT_TEST_HELPERS)
1948
	@rm -f hpc-htools.tix hpc-mon-collector.tix
1949
	HBINARY="./test/hs/hpc-htools" \
1950
	SHELLTESTARGS=$(SHELLTESTARGS) \
1951
	./test/hs/offline-test.sh $*
1952

    
1953
.PHONY: hs-shell
1954
hs-shell: test/hs/hpc-htools test/hs/hpc-mon-collector $(HS_BUILT_TEST_HELPERS)
1955
	@rm -f hpc-htools.tix hpc-mon-collector.tix
1956
	HBINARY="./test/hs/hpc-htools" \
1957
	SHELLTESTARGS=$(SHELLTESTARGS) \
1958
	./test/hs/offline-test.sh
1959

    
1960
.PHONY: hs-check
1961
hs-check: hs-tests hs-shell
1962

    
1963
# E111: indentation is not a multiple of four
1964
# E121: continuation line indentation is not a multiple of four
1965
#       (since our indent level is not 4)
1966
# E125: continuation line does not distinguish itself from next logical line
1967
#       (since our indent level is not 4)
1968
# E127: continuation line over-indented for visual indent
1969
#       (since our indent level is not 4)
1970
# note: do NOT add E128 here; it's a valid style error in most cases!
1971
# I've seen real errors, but also some cases were we indent wrongly
1972
# due to line length; try to rework the cases where it is triggered,
1973
# instead of silencing it
1974
# E261: at least two spaces before inline comment
1975
# E501: line too long (80 characters)
1976
PEP8_IGNORE = E111,E121,E125,E127,E261,E501
1977

    
1978
# For excluding pep8 expects filenames only, not whole paths
1979
PEP8_EXCLUDE = $(subst $(space),$(comma),$(strip $(notdir $(BUILT_PYTHON_SOURCES))))
1980

    
1981
LINT_TARGETS = pylint pylint-qa pylint-test
1982
if HAS_PEP8
1983
LINT_TARGETS += pep8
1984
endif
1985
if HAS_HLINT
1986
LINT_TARGETS += hlint
1987
endif
1988

    
1989
.PHONY: lint
1990
lint: $(LINT_TARGETS)
1991

    
1992
.PHONY: pylint
1993
pylint: $(GENERATED_FILES)
1994
	@test -n "$(PYLINT)" || { echo 'pylint' not found during configure; exit 1; }
1995
	$(PYLINT) $(LINT_OPTS) $(lint_python_code)
1996

    
1997
.PHONY: pylint-qa
1998
pylint-qa: $(GENERATED_FILES)
1999
	@test -n "$(PYLINT)" || { echo 'pylint' not found during configure; exit 1; }
2000
	cd $(top_srcdir)/qa && \
2001
	  PYTHONPATH=$(abs_top_srcdir) $(PYLINT) $(LINT_OPTS) \
2002
	  --rcfile  ../pylintrc $(patsubst qa/%.py,%,$(qa_scripts))
2003
# FIXME: lint all test code, not just the newly added test support
2004
pylint-test: $(GENERATED_FILES)
2005
	@test -n "$(PYLINT)" || { echo 'pylint' not found during configure; exit 1; }
2006
	cd $(top_srcdir) && \
2007
		PYTHONPATH=.:./test/py $(PYLINT) $(LINT_OPTS) \
2008
		--rcfile=pylintrc-test  $(python_test_support)
2009

    
2010
.PHONY: pep8
2011
pep8: $(GENERATED_FILES)
2012
	@test -n "$(PEP8)" || { echo 'pep8' not found during configure; exit 1; }
2013
	$(PEP8) --ignore='$(PEP8_IGNORE)' --exclude='$(PEP8_EXCLUDE)' \
2014
	  --repeat $(pep8_python_code)
2015

    
2016
# FIXME: remove ignore "Use void" when GHC 6.x is deprecated
2017
HLINT_EXCLUDES = src/Ganeti/THH.hs test/hs/hpc-htools.hs
2018
.PHONY: hlint
2019
hlint: $(HS_BUILT_SRCS) src/lint-hints.hs
2020
	@test -n "$(HLINT)" || { echo 'hlint' not found during configure; exit 1; }
2021
	@rm -f doc/hs-lint.html
2022
	if tty -s; then C="-c"; else C=""; fi; \
2023
	$(HLINT) --utf8 --report=doc/hs-lint.html --cross $$C \
2024
	  --ignore "Use first" \
2025
	  --ignore "Use &&&" \
2026
	  --ignore "Use void" \
2027
	  --ignore "Reduce duplication" \
2028
	  --hint src/lint-hints \
2029
	  $(filter-out $(HLINT_EXCLUDES),$(HS_LIBTEST_SRCS) $(HS_PROG_SRCS))
2030
	@if [ ! -f doc/hs-lint.html ]; then \
2031
	  echo "All good" > doc/hs-lint.html; \
2032
	fi
2033

    
2034
# a dist hook rule for updating the vcs-version file; this is
2035
# hardcoded due to where it needs to build the file...
2036
dist-hook:
2037
	$(MAKE) $(AM_MAKEFLAGS) regen-vcs-version
2038
	rm -f $(top_distdir)/vcs-version
2039
	cp -p $(srcdir)/vcs-version $(top_distdir)
2040

    
2041
# a distcheck hook rule for catching revision control directories
2042
distcheck-hook:
2043
	if find $(top_distdir) -name .svn -or -name .git | grep .; then \
2044
	  echo "Found revision control files in final archive." 1>&2; \
2045
	  exit 1; \
2046
	fi
2047
	if find $(top_distdir) -name '*.py[co]' | grep .; then \
2048
	  echo "Found Python byte code in final archive." 1>&2; \
2049
	  exit 1; \
2050
	fi
2051
	if find $(top_distdir) -name '*~' | grep .; then \
2052
	  echo "Found backup files in final archive." 1>&2; \
2053
	  exit 1; \
2054
	fi
2055
# Empty files or directories should not be distributed. They can cause
2056
# unnecessary warnings for packagers. Directories used by automake during
2057
# distcheck must be excluded.
2058
	if find $(top_distdir) -empty -and -not \( \
2059
	    -path $(top_distdir)/_build -or \
2060
	    -path $(top_distdir)/_inst \) | grep .; then \
2061
	  echo "Found empty files or directories in final archive." 1>&2; \
2062
	  exit 1; \
2063
	fi
2064
	if test -e $(top_distdir)/doc/man-html; then \
2065
	  echo "Found documentation including man pages in final archive" >&2; \
2066
	  exit 1; \
2067
	fi
2068

    
2069
# Backwards compatible distcheck-release target
2070
distcheck-release: distcheck
2071

    
2072
distrebuildcheck: dist
2073
	set -e; \
2074
	builddir=$$(mktemp -d $(abs_srcdir)/distrebuildcheck.XXXXXXX); \
2075
	trap "echo Removing $$builddir; cd $(abs_srcdir); rm -rf $$builddir" EXIT; \
2076
	cd $$builddir; \
2077
	tar xzf $(abs_srcdir)/$(distdir).tar.gz; \
2078
	cd $(distdir); \
2079
	./configure; \
2080
	$(MAKE) maintainer-clean; \
2081
	cp $(abs_srcdir)/vcs-version .; \
2082
	./configure; \
2083
	$(MAKE) $(AM_MAKEFLAGS)
2084

    
2085
dist-release: dist
2086
	set -e; \
2087
	for i in $(DIST_ARCHIVES); do \
2088
	  echo -n "Checking $$i ... "; \
2089
	  autotools/check-tar < $$i; \
2090
	  echo OK; \
2091
	done
2092

    
2093
install-exec-local:
2094
	@mkdir_p@ "$(DESTDIR)${localstatedir}/lib/ganeti" \
2095
	  "$(DESTDIR)${localstatedir}/log/ganeti" \
2096
	  "$(DESTDIR)${localstatedir}/run/ganeti"
2097
if INSTALL_SYMLINKS
2098
	for dir in $(SYMLINK_TARGET_DIRS); do \
2099
	  @mkdir_p@  $(DESTDIR)$$dir; \
2100
	done
2101
	for prog in $(HS_HTOOLS_PROGS); do \
2102
	  $(LN_S) $(bindir)/$$prog $(DESTDIR)$(exec_prefix)/bin/$$prog; \
2103
	done
2104
	$(LN_S) $(bindir)/htools $(DESTDIR)$(libdir)/ganeti/iallocators/hail
2105
	for prog in $(all_sbin_scripts); do \
2106
	  $(LN_S) $(sbindir)/$$prog $(DESTDIR)$(exec_prefix)/sbin/$$prog; \
2107
	done
2108
	for link in $(SYMLINK_DIRS); do \
2109
	  $(LN_S) $(versiondir)$$link $(DESTDIR)$$link; \
2110
	done
2111
	for prog in $(all_myexeclib_scripts); do \
2112
	  $(LN_S) $(pkglibdir)/$$prog $(DESTDIR)$(libdir)/ganeti/$$prog; \
2113
	done
2114
	if ! test -n '$(ENABLE_MANPAGES)'; then \
2115
	  for man in $(manfullpath); do \
2116
	    $(LN_S) $(versiondir)$(datarootdir)/man/$$man $(DESTDIR)$(datarootdir)/man/$$man; \
2117
	  done; \
2118
	fi
2119
endif
2120

    
2121
.PHONY: apidoc
2122
if WANT_HSAPIDOC
2123
apidoc: py-apidoc hs-apidoc
2124
else
2125
apidoc: py-apidoc
2126
endif
2127

    
2128
.PHONY: py-apidoc
2129
py-apidoc: epydoc.conf $(RUN_IN_TEMPDIR) $(GENERATED_FILES)
2130
	env - PATH="$$PATH" PYTHONPATH="$$PYTHONPATH" \
2131
	$(RUN_IN_TEMPDIR) epydoc -v \
2132
	  --conf $(CURDIR)/epydoc.conf \
2133
	  --output $(CURDIR)/$(APIDOC_PY_DIR)
2134

    
2135
.PHONY: hs-apidoc
2136
hs-apidoc: $(APIDOC_HS_DIR)/index.html
2137

    
2138
$(APIDOC_HS_DIR)/index.html: $(HS_LIBTESTBUILT_SRCS) Makefile
2139
	@test -n "$(HSCOLOUR)" || \
2140
	    { echo 'HsColour' not found during configure; exit 1; }
2141
	@test -n "$(HADDOCK)" || \
2142
	    { echo 'haddock' not found during configure; exit 1; }
2143
	rm -rf $(APIDOC_HS_DIR)/*
2144
	for i in $(ALL_APIDOC_HS_DIRS); do \
2145
	  @mkdir_p@ $$i; \
2146
	  $(HSCOLOUR) -print-css > $$i/hscolour.css; \
2147
	done
2148
	set -e ; \
2149
	export LC_ALL=en_US.UTF-8; \
2150
	OPTGHC="--optghc=-isrc --optghc=-itest/hs"; \
2151
	if [ "$(HS_PARALLEL3)" ]; \
2152
	then OPTGHC="$$OPTGHC --optghc=$(HS_PARALLEL3)"; \
2153
	fi; \
2154
	if [ "$(HS_REGEX_PCRE)" ]; \
2155
	then OPTGHC="$$OPTGHC --optghc=$(HS_REGEX_PCRE)"; \
2156
	fi; \
2157
	for file in $(HS_LIBTESTBUILT_SRCS); do \
2158
	  f_nosrc=$${file##src/}; \
2159
	  f_notst=$${f_nosrc##test/hs/}; \
2160
	  f_html=$${f_notst%%.hs}.html; \
2161
	  $(HSCOLOUR) -css -anchor $$file > $(APIDOC_HS_DIR)/$$f_html ; \
2162
	done ; \
2163
	$(HADDOCK) --odir $(APIDOC_HS_DIR) --html --ignore-all-exports -w \
2164
	  -t ganeti -p src/haddock-prologue \
2165
	  --source-module="%{MODULE/.//}.html" \
2166
	  --source-entity="%{MODULE/.//}.html#%{NAME}" \
2167
	  $$OPTGHC \
2168
	  $(HS_LIBTESTBUILT_SRCS)
2169

    
2170
.PHONY: TAGS
2171
TAGS: $(GENERATED_FILES)
2172
	rm -f TAGS
2173
	$(GHC) -e ":etags" -v0 \
2174
	  $(filter-out -O -Werror,$(HFLAGS)) \
2175
	  $(HS_PARALLEL3) $(HS_REGEX_PCRE) \
2176
	  $(HS_LIBTEST_SRCS)
2177
	find . -path './lib/*.py' -o -path './scripts/gnt-*' -o \
2178
	  -path './daemons/ganeti-*' -o -path './tools/*' -o \
2179
	  -path './qa/*.py' | \
2180
	  etags -l python -a -
2181

    
2182
.PHONY: coverage
2183

    
2184
COVERAGE_TESTS=
2185
if WANT_HTOOLS
2186
COVERAGE_TESTS += hs-coverage
2187
endif
2188
if PY_UNIT
2189
COVERAGE_TESTS += py-coverage
2190
endif
2191

    
2192
coverage: $(COVERAGE_TESTS)
2193

    
2194
.PHONY: py-coverage
2195
py-coverage: $(GENERATED_FILES) $(python_tests)
2196
	@test -n "$(PYCOVERAGE)" || \
2197
	    { echo 'python-coverage' not found during configure; exit 1; }
2198
	set -e; \
2199
	COVERAGE=$(PYCOVERAGE) \
2200
	COVERAGE_FILE=$(CURDIR)/$(COVERAGE_PY_DIR)/data \
2201
	TEXT_COVERAGE=$(CURDIR)/$(COVERAGE_PY_DIR)/report.txt \
2202
	HTML_COVERAGE=$(CURDIR)/$(COVERAGE_PY_DIR) \
2203
	$(PLAIN_TESTS_ENVIRONMENT) \
2204
	$(abs_top_srcdir)/autotools/gen-py-coverage \
2205
	$(python_tests)
2206

    
2207
.PHONY: hs-coverage
2208
hs-coverage: $(haskell_tests) test/hs/hpc-htools test/hs/hpc-mon-collector
2209
	rm -f *.tix
2210
	$(MAKE) $(AM_MAKEFLAGS) hs-check
2211
	@mkdir_p@ $(COVERAGE_HS_DIR)
2212
	hpc sum --union $(HPCEXCL) \
2213
	  htest.tix hpc-htools.tix hpc-mon-collector.tix > coverage-hs.tix
2214
	hpc markup --destdir=$(COVERAGE_HS_DIR) coverage-hs.tix
2215
	hpc report coverage-hs.tix | tee $(COVERAGE_HS_DIR)/report.txt
2216
	$(LN_S) -f hpc_index.html $(COVERAGE_HS_DIR)/index.html
2217

    
2218
# Special "kind-of-QA" target for htools, needs special setup (all
2219
# tools compiled with -fhpc)
2220
.PHONY: live-test
2221
live-test: all
2222
	set -e ; \
2223
	cd src; \
2224
	rm -f .hpc; $(LN_S) ../.hpc .hpc; \
2225
	rm -f *.tix *.mix; \
2226
	./live-test.sh; \
2227
	hpc sum --union $(HPCEXCL) $(addsuffix .tix,$(HS_PROGS:src/%=%)) \
2228
	  --output=live-test.tix ; \
2229
	@mkdir_p@ ../$(COVERAGE_HS_DIR) ; \
2230
	hpc markup --destdir=../$(COVERAGE_HS_DIR) live-test \
2231
	  --srcdir=.. $(HPCEXCL) ; \
2232
	hpc report --srcdir=.. live-test $(HPCEXCL)
2233

    
2234
commit-check: autotools-check distcheck lint apidoc
2235

    
2236
autotools-check:
2237
	TESTDATA_DIR=./test/data shelltest $(SHELLTESTARGS) \
2238
  $(abs_top_srcdir)/test/autotools/*-*.test \
2239
  -- --hide-successes
2240

    
2241
.PHONY: gitignore-check
2242
gitignore-check:
2243
	@if [ -n "`git status --short`" ]; then \
2244
	  echo "Git status is not clean!" 1>&2 ; \
2245
	  git status --short; \
2246
	  exit 1; \
2247
	fi
2248

    
2249
# target to rebuild all man pages (both groff and html output)
2250
.PHONY: man
2251
man: $(man_MANS) $(manhtml)
2252

    
2253
# Target that builds all binaries (including those that are not
2254
# rebuilt except when running the tests)
2255
.PHONY: really-all
2256
really-all: all $(check_SCRIPTS) $(haskell_tests) $(HS_ALL_PROGS)
2257

    
2258
# we don't need the ancient implicit rules:
2259
%: %,v
2260
%: RCS/%,v
2261
%: RCS/%
2262
%: s.%
2263
%: SCCS/s.%
2264

    
2265
-include ./Makefile.local
2266

    
2267
# vim: set noet :