Statistics
| Branch: | Tag: | Revision:

root / Makefile.am @ f2b6e7d4

History | View | Annotate | Download (68.2 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
	src/hs2py-constants \
244
	.hpc/*.mix src/*.tix test/hs/*.tix \
245
	doc/hs-lint.html
246

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

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

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

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

    
268
built_python_base_sources = \
269
	lib/_autoconf.py \
270
	lib/_constants.py \
271
	lib/_vcsversion.py \
272
	lib/opcodes.py
273

    
274
BUILT_PYTHON_SOURCES = \
275
	$(built_python_base_sources) \
276
	lib/_generated_rpc.py
277

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

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

    
293
nodist_pkgpython_PYTHON = \
294
	$(BUILT_PYTHON_SOURCES)
295

    
296
noinst_PYTHON = \
297
	lib/build/__init__.py \
298
	lib/build/shell_example_lexer.py \
299
	lib/build/sphinx_ext.py
300

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

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

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

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

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

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

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

    
406
confd_PYTHON = \
407
	lib/confd/__init__.py \
408
	lib/confd/client.py
409

    
410
masterd_PYTHON = \
411
	lib/masterd/__init__.py \
412
	lib/masterd/iallocator.py \
413
	lib/masterd/instance.py
414

    
415
impexpd_PYTHON = \
416
	lib/impexpd/__init__.py
417

    
418
watcher_PYTHON = \
419
	lib/watcher/__init__.py \
420
	lib/watcher/nodemaint.py \
421
	lib/watcher/state.py
422

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

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

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

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

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

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

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

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

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

    
544
HS_BIN_ROLES = harep hbal hscan hspace hinfo hcheck hroller
545
HS_HTOOLS_PROGS = $(HS_BIN_ROLES) hail
546

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

    
554
HS_PROG_SRCS = $(patsubst %,%.hs,$(HS_ALL_PROGS)) src/hs2py-constants.hs
555
HS_BUILT_TEST_HELPERS = $(HS_BIN_ROLES:%=test/hs/%) test/hs/hail
556

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

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

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

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

    
725
HS_LIBTEST_SRCS = $(HS_LIB_SRCS) $(HS_TEST_SRCS)
726

    
727
HS_BUILT_SRCS = \
728
	test/hs/Test/Ganeti/TestImports.hs \
729
	src/Ganeti/Hs2Py/ListConstants.hs \
730
	src/Ganeti/PyConstants.hs \
731
	src/Ganeti/Curl/Internal.hs \
732
	src/Ganeti/Version.hs
733
HS_BUILT_SRCS_IN = \
734
	$(patsubst %,%.in,$(filter-out src/Ganeti/Curl/Internal.hs,$(HS_BUILT_SRCS))) \
735
	src/Ganeti/Curl/Internal.hsc \
736
	lib/_constants.py.in \
737
	lib/opcodes.py.in_after \
738
	lib/opcodes.py.in_before
739

    
740
HS_LIBTESTBUILT_SRCS = $(HS_LIBTEST_SRCS) $(HS_BUILT_SRCS)
741

    
742
$(RUN_IN_TEMPDIR): | stamp-directories
743

    
744
doc/html/index.html: ENABLE_MANPAGES =
745
doc/man-html/index.html: ENABLE_MANPAGES = 1
746
doc/man-html/index.html: doc/manpages-enabled.rst $(mandocrst)
747

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

    
785
doc/html: doc/html/index.html
786

    
787
doc/man-html: doc/man-html/index.html
788

    
789
doc/install-quick.rst: INSTALL
790
doc/news.rst: NEWS
791
doc/upgrade.rst: UPGRADE
792

    
793
doc/install-quick.rst doc/news.rst doc/upgrade.rst:
794
	set -e; \
795
	{ echo '.. This file is automatically updated at build time from $<.'; \
796
	  echo '.. Do not edit.'; \
797
	  echo; \
798
	  cat $<; \
799
	} > $@
800

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

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

    
829
# Things to build but not to install (add it to EXTRA_DIST if it should be
830
# distributed)
831
noinst_DATA = \
832
	$(BUILT_EXAMPLES) \
833
	doc/examples/bash_completion \
834
	doc/examples/bash_completion-debug \
835
	$(manhtml)
836

    
837
if HAS_SPHINX
838
if MANPAGES_IN_DOC
839
noinst_DATA += doc/man-html
840
else
841
noinst_DATA += doc/html
842
endif
843
endif
844

    
845
gnt_scripts = \
846
	scripts/gnt-backup \
847
	scripts/gnt-cluster \
848
	scripts/gnt-debug \
849
	scripts/gnt-group \
850
	scripts/gnt-instance \
851
	scripts/gnt-job \
852
	scripts/gnt-network \
853
	scripts/gnt-node \
854
	scripts/gnt-os \
855
	scripts/gnt-storage
856

    
857
PYTHON_BOOTSTRAP_SBIN = \
858
	daemons/ganeti-masterd \
859
	daemons/ganeti-noded \
860
	daemons/ganeti-rapi \
861
	daemons/ganeti-watcher \
862
	$(gnt_scripts)
863

    
864
PYTHON_BOOTSTRAP = \
865
	$(PYTHON_BOOTSTRAP_SBIN) \
866
	tools/burnin \
867
	tools/ensure-dirs \
868
	tools/node-cleanup \
869
	tools/node-daemon-setup \
870
	tools/prepare-node-join
871

    
872
qa_scripts = \
873
	qa/__init__.py \
874
	qa/ganeti-qa.py \
875
	qa/qa_cluster.py \
876
	qa/qa_config.py \
877
	qa/qa_daemon.py \
878
	qa/qa_env.py \
879
	qa/qa_error.py \
880
	qa/qa_group.py \
881
	qa/qa_instance.py \
882
	qa/qa_instance_utils.py \
883
	qa/qa_job.py \
884
	qa/qa_monitoring.py \
885
	qa/qa_node.py \
886
	qa/qa_os.py \
887
	qa/qa_rapi.py \
888
	qa/qa_tags.py \
889
	qa/qa_utils.py
890

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

    
904
# This target cannot be merged with the '$(HS_ALL_PROGS)' target
905
# because 'hs2py-constants' cannot depend on 'Ganeti.Constants'.  And
906
# the reason for this is because 'hs2py-constants' needs to generate
907
# Python code, and 'Ganeti.Constants' is generated by Python.
908
src/hs2py-constants: src/hs2py-constants.hs src/Ganeti/BasicTypes.hs \
909
		     src/Ganeti/JSON.hs src/Ganeti/THH.hs \
910
		     src/Ganeti/Hs2Py/GenConstants.hs \
911
		     src/Ganeti/Hs2Py/ListConstants.hs \
912
		     src/Ganeti/HsConstants.hs \
913
		     src/Ganeti/PyValueInstances.hs \
914
		   | stamp-srclinks
915
	$(GHC) --make \
916
	  $(HFLAGS) \
917
	  -osuf $(notdir $@).o -hisuf $(notdir $@).hi \
918
	  $(HEXTRA) $(HEXTRA_INT) src/hs2py-constants.hs
919

    
920
$(HS_ALL_PROGS): %: %.hs $(HS_LIBTESTBUILT_SRCS) Makefile
921
	@if [ "$(notdir $@)" = "test" ] && [ "$(HS_NODEV)" ]; then \
922
	  echo "Error: cannot run unittests without the development" \
923
	       " libraries (see devnotes.rst)" 1>&2; \
924
	  exit 1; \
925
	fi
926
	@rm -f $(notdir $@).tix
927
	$(GHC) --make \
928
	  $(HFLAGS) \
929
	  $(HS_PARALLEL3) $(HS_REGEX_PCRE) \
930
	  -osuf $(notdir $@).o -hisuf $(notdir $@).hi \
931
	  $(HEXTRA) $(HEXTRA_INT) $@
932
	@touch "$@"
933

    
934
# for the test/hs/htest binary, we need to enable profiling/coverage
935
test/hs/htest: HEXTRA_INT=-fhpc -itest/hs
936

    
937
# we compile the hpc-htools binary with the program coverage
938
test/hs/hpc-htools: HEXTRA_INT=-fhpc
939

    
940
# we compile the hpc-mon-collector binary with the program coverage
941
test/hs/hpc-mon-collector: HEXTRA_INT=-fhpc
942

    
943
# test dependency
944
test/hs/offline-test.sh: test/hs/hpc-htools test/hs/hpc-mon-collector
945

    
946
# rules for building profiling-enabled versions of the haskell
947
# programs: hs-prof does the full two-step build, whereas
948
# hs-prof-quick does only the final rebuild (hs-prof must have been
949
# run before)
950
.PHONY: hs-prof hs-prof-quick
951
hs-prof:
952
	@if [ -z "$(TARGET)" ]; then \
953
	  echo "You need to define TARGET when running this rule" 1>&2; \
954
	  exit 1; \
955
	fi
956
	$(MAKE) $(AM_MAKEFLAGS) clean
957
	$(MAKE) $(AM_MAKEFLAGS) $(TARGET) HEXTRA="-osuf o"
958
	rm -f $(HS_ALL_PROGS)
959
	$(MAKE) $(AM_MAKEFLAGS) hs-prof-quick
960

    
961
hs-prof-quick:
962
	@if [ -z "$(TARGET)" ]; then \
963
	  echo "You need to define TARGET when running this rule" 1>&2; \
964
	  exit 1; \
965
	fi
966
	$(MAKE) $(AM_MAKEFLAGS) $(TARGET) HEXTRA="-osuf prof_o -prof -auto-all"
967

    
968
dist_sbin_SCRIPTS = \
969
	tools/ganeti-listrunner
970

    
971
nodist_sbin_SCRIPTS = \
972
	$(PYTHON_BOOTSTRAP_SBIN) \
973
	daemons/ganeti-cleaner
974

    
975
# strip path prefixes off the sbin scripts
976
all_sbin_scripts = \
977
	$(patsubst tools/%,%,$(patsubst daemons/%,%,$(patsubst scripts/%,%,\
978
	$(patsubst src/%,%,$(dist_sbin_SCRIPTS) $(nodist_sbin_SCRIPTS)))))
979

    
980
if ENABLE_CONFD
981
src/ganeti-confd: src/hconfd
982
	cp -f $< $@
983

    
984
src/ganeti-luxid: src/hluxid
985
	cp -f $< $@
986

    
987
nodist_sbin_SCRIPTS += src/ganeti-confd
988
nodist_sbin_SCRIPTS += src/ganeti-luxid
989
endif
990

    
991
if ENABLE_MOND
992
nodist_sbin_SCRIPTS += src/ganeti-mond
993
endif
994

    
995
python_scripts = \
996
	tools/cfgshell \
997
	tools/cfgupgrade \
998
	tools/cfgupgrade12 \
999
	tools/cluster-merge \
1000
	tools/confd-client \
1001
	tools/fmtjson \
1002
	tools/lvmstrap \
1003
	tools/move-instance \
1004
	tools/ovfconverter \
1005
	tools/sanitize-config
1006

    
1007
dist_tools_SCRIPTS = \
1008
	$(python_scripts) \
1009
	tools/burnin \
1010
	tools/kvm-console-wrapper \
1011
	tools/master-ip-setup \
1012
	tools/xen-console-wrapper
1013

    
1014
nodist_tools_python_scripts = \
1015
	tools/node-cleanup
1016

    
1017
nodist_tools_SCRIPTS = \
1018
	$(nodist_tools_python_scripts) \
1019
	tools/users-setup \
1020
	tools/vcluster-setup
1021

    
1022
pkglib_python_scripts = \
1023
	daemons/import-export \
1024
	tools/check-cert-expired
1025

    
1026
nodist_pkglib_python_scripts = \
1027
	tools/ensure-dirs \
1028
	tools/node-daemon-setup \
1029
	tools/prepare-node-join
1030

    
1031
myexeclib_SCRIPTS = \
1032
	daemons/daemon-util \
1033
	tools/kvm-ifup \
1034
	tools/vif-ganeti \
1035
	tools/net-common \
1036
	$(pkglib_python_scripts) \
1037
	$(HS_MYEXECLIB_PROGS)
1038

    
1039
nodist_myexeclib_SCRIPTS = \
1040
	$(nodist_pkglib_python_scripts)
1041

    
1042
# strip path prefixes off the lib python scripts
1043
all_myexeclib_scripts = \
1044
	$(patsubst tools/%,%,$(patsubst daemons/%,%,\
1045
	$(patsubst src/%,%,$(myexeclib_SCRIPTS) $(nodist_myexeclib_SCRIPTS))))
1046

    
1047
EXTRA_DIST = \
1048
	NEWS \
1049
	UPGRADE \
1050
	epydoc.conf.in \
1051
	pylintrc \
1052
	pylintrc-test \
1053
	autotools/build-bash-completion \
1054
	autotools/build-rpc \
1055
	autotools/check-header \
1056
	autotools/check-imports \
1057
	autotools/check-man-dashes \
1058
	autotools/check-man-references \
1059
	autotools/check-man-warnings \
1060
	autotools/check-news \
1061
	autotools/check-python-code \
1062
	autotools/check-tar \
1063
	autotools/check-version \
1064
	autotools/convert-constants \
1065
	autotools/docpp \
1066
	autotools/gen-py-coverage \
1067
	autotools/sphinx-wrapper \
1068
	autotools/testrunner \
1069
	autotools/wrong-hardcoded-paths \
1070
	$(RUN_IN_TEMPDIR) \
1071
	daemons/daemon-util.in \
1072
	daemons/ganeti-cleaner.in \
1073
	$(pkglib_python_scripts) \
1074
	devel/upload \
1075
	devel/webserver \
1076
	tools/kvm-ifup.in \
1077
	tools/vif-ganeti.in \
1078
	tools/net-common.in \
1079
	tools/users-setup.in \
1080
	tools/vcluster-setup.in \
1081
	$(docinput) \
1082
	doc/html \
1083
	$(BUILT_EXAMPLES:%=%.in) \
1084
	doc/examples/ganeti.default \
1085
	doc/examples/ganeti.default-debug \
1086
	doc/examples/hooks/ethers \
1087
	doc/examples/gnt-debug/README \
1088
	doc/examples/gnt-debug/delay0.json \
1089
	doc/examples/gnt-debug/delay50.json \
1090
	$(dist_TESTS) \
1091
	$(TEST_FILES) \
1092
	$(python_test_support) \
1093
	man/footer.rst \
1094
	$(manrst) \
1095
	$(maninput) \
1096
	qa/qa-sample.json \
1097
	$(qa_scripts) \
1098
	$(HS_LIBTEST_SRCS) $(HS_BUILT_SRCS_IN) \
1099
	$(HS_PROG_SRCS) \
1100
	src/lint-hints.hs \
1101
	test/hs/cli-tests-defs.sh \
1102
	test/hs/offline-test.sh \
1103
	.ghci
1104

    
1105
man_MANS = \
1106
	man/ganeti-cleaner.8 \
1107
	man/ganeti-confd.8 \
1108
	man/ganeti-luxid.8 \
1109
	man/ganeti-listrunner.8 \
1110
	man/ganeti-masterd.8 \
1111
	man/ganeti-mond.8 \
1112
	man/ganeti-noded.8 \
1113
	man/ganeti-os-interface.7 \
1114
	man/ganeti-extstorage-interface.7 \
1115
	man/ganeti-rapi.8 \
1116
	man/ganeti-watcher.8 \
1117
	man/ganeti.7 \
1118
	man/gnt-backup.8 \
1119
	man/gnt-cluster.8 \
1120
	man/gnt-debug.8 \
1121
	man/gnt-group.8 \
1122
	man/gnt-network.8 \
1123
	man/gnt-instance.8 \
1124
	man/gnt-job.8 \
1125
	man/gnt-node.8 \
1126
	man/gnt-os.8 \
1127
	man/gnt-storage.8 \
1128
	man/hail.1 \
1129
	man/harep.1 \
1130
	man/hbal.1 \
1131
	man/hcheck.1 \
1132
	man/hinfo.1 \
1133
	man/hscan.1 \
1134
	man/hspace.1 \
1135
	man/hroller.1 \
1136
	man/htools.1 \
1137
	man/mon-collector.7
1138

    
1139
# Remove extensions from all filenames in man_MANS
1140
mannoext = $(patsubst %.1,%,$(patsubst %.7,%,$(patsubst %.8,%,$(man_MANS))))
1141

    
1142
manrst = $(patsubst %,%.rst,$(mannoext))
1143
manhtml = $(patsubst %.rst,%.html,$(manrst))
1144
mangen = $(patsubst %.rst,%.gen,$(manrst))
1145
maninput = \
1146
	$(patsubst %.1,%.1.in,$(patsubst %.7,%.7.in,$(patsubst %.8,%.8.in,$(man_MANS)))) \
1147
	$(patsubst %.html,%.html.in,$(manhtml)) \
1148
	$(mangen)
1149

    
1150
manfullpath = $(patsubst man/%.1,man1/%.1,\
1151
	$(patsubst man/%.7,man7/%.7,\
1152
	$(patsubst man/%.8,man8/%.8,$(man_MANS))))
1153

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

    
1300

    
1301
python_tests = \
1302
	doc/examples/rapi_testutils.py \
1303
	test/py/cmdlib/cluster_unittest.py \
1304
	test/py/cmdlib/cmdlib_unittest.py \
1305
	test/py/cmdlib/group_unittest.py \
1306
	test/py/cmdlib/instance_unittest.py \
1307
	test/py/cmdlib/instance_storage_unittest.py \
1308
	test/py/cmdlib/test_unittest.py \
1309
	test/py/cfgupgrade_unittest.py \
1310
	test/py/docs_unittest.py \
1311
	test/py/ganeti.asyncnotifier_unittest.py \
1312
	test/py/ganeti.backend_unittest-runasroot.py \
1313
	test/py/ganeti.backend_unittest.py \
1314
	test/py/ganeti.bootstrap_unittest.py \
1315
	test/py/ganeti.cli_unittest.py \
1316
	test/py/ganeti.client.gnt_cluster_unittest.py \
1317
	test/py/ganeti.client.gnt_instance_unittest.py \
1318
	test/py/ganeti.client.gnt_job_unittest.py \
1319
	test/py/ganeti.compat_unittest.py \
1320
	test/py/ganeti.confd.client_unittest.py \
1321
	test/py/ganeti.config_unittest.py \
1322
	test/py/ganeti.constants_unittest.py \
1323
	test/py/ganeti.daemon_unittest.py \
1324
	test/py/ganeti.errors_unittest.py \
1325
	test/py/ganeti.hooks_unittest.py \
1326
	test/py/ganeti.ht_unittest.py \
1327
	test/py/ganeti.http_unittest.py \
1328
	test/py/ganeti.hypervisor.hv_chroot_unittest.py \
1329
	test/py/ganeti.hypervisor.hv_fake_unittest.py \
1330
	test/py/ganeti.hypervisor.hv_kvm_unittest.py \
1331
	test/py/ganeti.hypervisor.hv_lxc_unittest.py \
1332
	test/py/ganeti.hypervisor.hv_xen_unittest.py \
1333
	test/py/ganeti.hypervisor_unittest.py \
1334
	test/py/ganeti.impexpd_unittest.py \
1335
	test/py/ganeti.jqueue_unittest.py \
1336
	test/py/ganeti.jstore_unittest.py \
1337
	test/py/ganeti.locking_unittest.py \
1338
	test/py/ganeti.luxi_unittest.py \
1339
	test/py/ganeti.masterd.iallocator_unittest.py \
1340
	test/py/ganeti.masterd.instance_unittest.py \
1341
	test/py/ganeti.mcpu_unittest.py \
1342
	test/py/ganeti.netutils_unittest.py \
1343
	test/py/ganeti.objects_unittest.py \
1344
	test/py/ganeti.opcodes_unittest.py \
1345
	test/py/ganeti.outils_unittest.py \
1346
	test/py/ganeti.ovf_unittest.py \
1347
	test/py/ganeti.qlang_unittest.py \
1348
	test/py/ganeti.query_unittest.py \
1349
	test/py/ganeti.rapi.baserlib_unittest.py \
1350
	test/py/ganeti.rapi.client_unittest.py \
1351
	test/py/ganeti.rapi.resources_unittest.py \
1352
	test/py/ganeti.rapi.rlib2_unittest.py \
1353
	test/py/ganeti.rapi.testutils_unittest.py \
1354
	test/py/ganeti.rpc_unittest.py \
1355
	test/py/ganeti.runtime_unittest.py \
1356
	test/py/ganeti.serializer_unittest.py \
1357
	test/py/ganeti.server.rapi_unittest.py \
1358
	test/py/ganeti.ssconf_unittest.py \
1359
	test/py/ganeti.ssh_unittest.py \
1360
	test/py/ganeti.storage.bdev_unittest.py \
1361
	test/py/ganeti.storage.container_unittest.py \
1362
	test/py/ganeti.storage.drbd_unittest.py \
1363
	test/py/ganeti.storage.filestorage_unittest.py \
1364
	test/py/ganeti.tools.burnin_unittest.py \
1365
	test/py/ganeti.tools.ensure_dirs_unittest.py \
1366
	test/py/ganeti.tools.node_daemon_setup_unittest.py \
1367
	test/py/ganeti.tools.prepare_node_join_unittest.py \
1368
	test/py/ganeti.uidpool_unittest.py \
1369
	test/py/ganeti.utils.algo_unittest.py \
1370
	test/py/ganeti.utils.filelock_unittest.py \
1371
	test/py/ganeti.utils.hash_unittest.py \
1372
	test/py/ganeti.utils.io_unittest-runasroot.py \
1373
	test/py/ganeti.utils.io_unittest.py \
1374
	test/py/ganeti.utils.log_unittest.py \
1375
	test/py/ganeti.utils.lvm_unittest.py \
1376
	test/py/ganeti.utils.mlock_unittest.py \
1377
	test/py/ganeti.utils.nodesetup_unittest.py \
1378
	test/py/ganeti.utils.process_unittest.py \
1379
	test/py/ganeti.utils.retry_unittest.py \
1380
	test/py/ganeti.utils.storage_unittest.py \
1381
	test/py/ganeti.utils.text_unittest.py \
1382
	test/py/ganeti.utils.wrapper_unittest.py \
1383
	test/py/ganeti.utils.x509_unittest.py \
1384
	test/py/ganeti.utils_unittest.py \
1385
	test/py/ganeti.vcluster_unittest.py \
1386
	test/py/ganeti.workerpool_unittest.py \
1387
	test/py/pycurl_reset_unittest.py \
1388
	test/py/qa.qa_config_unittest.py \
1389
	test/py/tempfile_fork_unittest.py
1390

    
1391
python_test_support = \
1392
	test/py/__init__.py \
1393
	test/py/lockperf.py \
1394
	test/py/testutils.py \
1395
	test/py/mocks.py \
1396
	test/py/cmdlib/__init__.py \
1397
	test/py/cmdlib/testsupport/__init__.py \
1398
	test/py/cmdlib/testsupport/cmdlib_testcase.py \
1399
	test/py/cmdlib/testsupport/config_mock.py \
1400
	test/py/cmdlib/testsupport/iallocator_mock.py \
1401
	test/py/cmdlib/testsupport/lock_manager_mock.py \
1402
	test/py/cmdlib/testsupport/netutils_mock.py \
1403
	test/py/cmdlib/testsupport/processor_mock.py \
1404
	test/py/cmdlib/testsupport/rpc_runner_mock.py \
1405
	test/py/cmdlib/testsupport/ssh_mock.py \
1406
	test/py/cmdlib/testsupport/util.py
1407

    
1408
haskell_tests = test/hs/htest
1409

    
1410
dist_TESTS = \
1411
	test/py/check-cert-expired_unittest.bash \
1412
	test/py/daemon-util_unittest.bash \
1413
	test/py/ganeti-cleaner_unittest.bash \
1414
	test/py/import-export_unittest.bash \
1415
	test/py/cli-test.bash \
1416
	test/py/bash_completion.bash
1417

    
1418
if PY_UNIT
1419
dist_TESTS += $(python_tests)
1420
endif
1421

    
1422
nodist_TESTS =
1423
check_SCRIPTS =
1424

    
1425
if WANT_HSTESTS
1426
nodist_TESTS += $(haskell_tests)
1427
dist_TESTS += test/hs/offline-test.sh
1428
check_SCRIPTS += \
1429
	test/hs/hpc-htools \
1430
	test/hs/hpc-mon-collector \
1431
	$(HS_BUILT_TEST_HELPERS)
1432
endif
1433

    
1434
TESTS = $(dist_TESTS) $(nodist_TESTS)
1435

    
1436
# Environment for all tests
1437
PLAIN_TESTS_ENVIRONMENT = \
1438
	PYTHONPATH=.:./test/py \
1439
	TOP_SRCDIR=$(abs_top_srcdir) TOP_BUILDDIR=$(abs_top_builddir) \
1440
	PYTHON=$(PYTHON) FAKEROOT=$(FAKEROOT_PATH) \
1441
	$(RUN_IN_TEMPDIR)
1442

    
1443
# Environment for tests run by automake
1444
TESTS_ENVIRONMENT = \
1445
	$(PLAIN_TESTS_ENVIRONMENT) $(abs_top_srcdir)/autotools/testrunner
1446

    
1447
all_python_code = \
1448
	$(dist_sbin_SCRIPTS) \
1449
	$(python_scripts) \
1450
	$(pkglib_python_scripts) \
1451
	$(nodist_pkglib_python_scripts) \
1452
	$(nodist_tools_python_scripts) \
1453
	$(pkgpython_PYTHON) \
1454
	$(client_PYTHON) \
1455
	$(cmdlib_PYTHON) \
1456
	$(hypervisor_PYTHON) \
1457
	$(storage_PYTHON) \
1458
	$(rapi_PYTHON) \
1459
	$(server_PYTHON) \
1460
	$(pytools_PYTHON) \
1461
	$(http_PYTHON) \
1462
	$(confd_PYTHON) \
1463
	$(masterd_PYTHON) \
1464
	$(impexpd_PYTHON) \
1465
	$(utils_PYTHON) \
1466
	$(watcher_PYTHON) \
1467
	$(noinst_PYTHON) \
1468
	$(qa_scripts)
1469

    
1470
if PY_UNIT
1471
all_python_code += $(python_tests)
1472
all_python_code += $(python_test_support)
1473
endif
1474

    
1475
srclink_files = \
1476
	man/footer.rst \
1477
	test/py/check-cert-expired_unittest.bash \
1478
	test/py/daemon-util_unittest.bash \
1479
	test/py/ganeti-cleaner_unittest.bash \
1480
	test/py/import-export_unittest.bash \
1481
	test/py/cli-test.bash \
1482
	test/py/bash_completion.bash \
1483
	test/hs/offline-test.sh \
1484
	test/hs/cli-tests-defs.sh \
1485
	$(all_python_code) \
1486
	$(HS_LIBTEST_SRCS) $(HS_PROG_SRCS) \
1487
	$(docinput)
1488

    
1489
check_python_code = \
1490
	$(BUILD_BASH_COMPLETION) \
1491
	$(CHECK_IMPORTS) \
1492
	$(CHECK_HEADER) \
1493
	$(DOCPP) \
1494
	$(all_python_code)
1495

    
1496
lint_python_code = \
1497
	ganeti \
1498
	ganeti/http/server.py \
1499
	$(dist_sbin_SCRIPTS) \
1500
	$(python_scripts) \
1501
	$(pkglib_python_scripts) \
1502
	$(BUILD_BASH_COMPLETION) \
1503
	$(CHECK_IMPORTS) \
1504
	$(CHECK_HEADER) \
1505
	$(DOCPP) \
1506
	$(PYTHON_BOOTSTRAP)
1507

    
1508
standalone_python_modules = \
1509
	lib/rapi/client.py \
1510
	tools/ganeti-listrunner
1511

    
1512
pep8_python_code = \
1513
	ganeti \
1514
	ganeti/http/server.py \
1515
	$(dist_sbin_SCRIPTS) \
1516
	$(python_scripts) \
1517
	$(pkglib_python_scripts) \
1518
	$(BUILD_BASH_COMPLETION) \
1519
	$(CHECK_HEADER) \
1520
	$(DOCPP) \
1521
	$(PYTHON_BOOTSTRAP) \
1522
	qa \
1523
	$(python_test_support)
1524

    
1525
test/py/daemon-util_unittest.bash: daemons/daemon-util
1526

    
1527
test/py/ganeti-cleaner_unittest.bash: daemons/ganeti-cleaner
1528

    
1529
test/py/bash_completion.bash: doc/examples/bash_completion-debug
1530

    
1531
tools/kvm-ifup: tools/kvm-ifup.in $(REPLACE_VARS_SED)
1532
	sed -f $(REPLACE_VARS_SED) < $< > $@
1533
	chmod +x $@
1534

    
1535
tools/vif-ganeti: tools/vif-ganeti.in $(REPLACE_VARS_SED)
1536
	sed -f $(REPLACE_VARS_SED) < $< > $@
1537
	chmod +x $@
1538

    
1539
tools/net-common: tools/net-common.in $(REPLACE_VARS_SED)
1540
	sed -f $(REPLACE_VARS_SED) < $< > $@
1541
	chmod +x $@
1542

    
1543
tools/users-setup: tools/users-setup.in $(REPLACE_VARS_SED)
1544
	sed -f $(REPLACE_VARS_SED) < $< > $@
1545
	chmod +x $@
1546

    
1547
tools/vcluster-setup: tools/vcluster-setup.in $(REPLACE_VARS_SED)
1548
	sed -f $(REPLACE_VARS_SED) < $< > $@
1549
	chmod +x $@
1550

    
1551
daemons/%:: daemons/%.in $(REPLACE_VARS_SED)
1552
	sed -f $(REPLACE_VARS_SED) < $< > $@
1553
	chmod +x $@
1554

    
1555
doc/examples/%:: doc/examples/%.in $(REPLACE_VARS_SED)
1556
	sed -f $(REPLACE_VARS_SED) < $< > $@
1557

    
1558
doc/examples/bash_completion: BC_ARGS = --compact
1559
doc/examples/bash_completion-debug: BC_ARGS =
1560

    
1561
doc/examples/bash_completion doc/examples/bash_completion-debug: \
1562
	$(BUILD_BASH_COMPLETION) $(RUN_IN_TEMPDIR) \
1563
	lib/cli.py $(gnt_scripts) $(client_PYTHON) tools/burnin \
1564
	daemons/ganeti-cleaner \
1565
	$(GENERATED_FILES) $(HS_GENERATED_FILES)
1566
	PYTHONPATH=. $(RUN_IN_TEMPDIR) \
1567
	  $(CURDIR)/$(BUILD_BASH_COMPLETION) $(BC_ARGS) > $@
1568

    
1569
man/%.gen: man/%.rst lib/query.py lib/build/sphinx_ext.py \
1570
	lib/build/shell_example_lexer.py \
1571
	| $(RUN_IN_TEMPDIR) $(BUILT_PYTHON_SOURCES)
1572
	@echo "Checking $< for hardcoded paths..."
1573
	@if grep -nEf autotools/wrong-hardcoded-paths $<; then \
1574
	  echo "Man page $< has hardcoded paths (see above)!" 1>&2 ; \
1575
	  exit 1; \
1576
	fi
1577
	set -e ; \
1578
	trap 'echo auto-removing $@; rm $@' EXIT; \
1579
	PYTHONPATH=. $(RUN_IN_TEMPDIR) $(CURDIR)/$(DOCPP) < $< > $@ ;\
1580
	$(CHECK_MAN_REFERENCES) $@; \
1581
	trap - EXIT
1582

    
1583
man/%.7.in man/%.8.in man/%.1.in: man/%.gen man/footer.rst
1584
	@test -n "$(PANDOC)" || \
1585
	  { echo 'pandoc' not found during configure; exit 1; }
1586
	set -o pipefail -e; \
1587
	trap 'echo auto-removing $@; rm $@' EXIT; \
1588
	$(PANDOC) -s -f rst -t man $< man/footer.rst | \
1589
	  sed -e 's/\\@/@/g' > $@; \
1590
	if test -n "$(MAN_HAS_WARNINGS)"; then $(CHECK_MAN_WARNINGS) $@; fi; \
1591
	$(CHECK_MAN_DASHES) $@; \
1592
	trap - EXIT
1593

    
1594
man/%.html.in: man/%.gen man/footer.rst
1595
	@test -n "$(PANDOC)" || \
1596
	  { echo 'pandoc' not found during configure; exit 1; }
1597
	set -o pipefail ; \
1598
	$(PANDOC) --toc -s -f rst -t html $< man/footer.rst | \
1599
	  sed -e 's/\\@/@/g' > $@
1600

    
1601
man/%: man/%.in  $(REPLACE_VARS_SED)
1602
	sed -f $(REPLACE_VARS_SED) < $< > $@
1603

    
1604
epydoc.conf: epydoc.conf.in $(REPLACE_VARS_SED)
1605
	sed -f $(REPLACE_VARS_SED) < $< > $@
1606

    
1607
vcs-version:
1608
	if test -d .git; then \
1609
	  git describe > $@; \
1610
	elif test ! -f $@ ; then \
1611
	  echo "Cannot auto-generate $@ file"; exit 1; \
1612
	fi
1613

    
1614
.PHONY: clean-vcs-version
1615
clean-vcs-version:
1616
	rm -f vcs-version
1617

    
1618
.PHONY: regen-vcs-version
1619
regen-vcs-version:
1620
	@set -e; \
1621
	cd $(srcdir); \
1622
	if test -d .git; then \
1623
	  T=`mktemp` ; trap 'rm -f $$T' EXIT; \
1624
	  git describe > $$T; \
1625
	  if ! cmp --quiet $$T vcs-version; then \
1626
	    mv $$T vcs-version; \
1627
	  fi; \
1628
	fi
1629

    
1630
src/Ganeti/Version.hs: src/Ganeti/Version.hs.in \
1631
	vcs-version $(built_base_sources)
1632
	set -e; \
1633
	VCSVER=`cat $(abs_top_srcdir)/vcs-version`; \
1634
	sed -e "s/%ver%/$$VCSVER/" < $< > $@
1635

    
1636
src/Ganeti/Hs2Py/ListConstants.hs: src/Ganeti/Hs2Py/ListConstants.hs.in \
1637
				   src/Ganeti/HsConstants.hs \
1638
			         | stamp-directories
1639
	@echo Generating $@
1640
	@set -e; \
1641
## Extract constant names from 'HsConstants.hs' by extracting the left
1642
## side of all lines containing an equal sign (i.e., '=') and
1643
## prepending the apostrophe sign (i.e., "'").
1644
##
1645
## For example, the constant
1646
##   adminstDown = ...
1647
## becomes
1648
##   'adminstDown
1649
	NAMES=$$(sed -n -e "/=/ s/\(.*\) =.*/    '\1:/g p" \
1650
		 $(abs_top_srcdir)/src/Ganeti/HsConstants.hs); \
1651
	m4 -DPY_CONSTANT_NAMES="$$NAMES" $(abs_top_srcdir)/$< > $@
1652

    
1653
src/Ganeti/PyConstants.hs: src/Ganeti/PyConstants.hs.in \
1654
	lib/constants.py lib/_autoconf.py lib/luxi.py lib/errors.py \
1655
	lib/jstore.py $(RUN_IN_TEMPDIR) \
1656
	$(CONVERT_CONSTANTS) $(built_base_sources) \
1657
	| lib/_vcsversion.py
1658
	set -e; \
1659
	{ cat $< ; \
1660
	  PYTHONPATH=. $(RUN_IN_TEMPDIR) $(CURDIR)/$(CONVERT_CONSTANTS); \
1661
	} > $@
1662

    
1663
src/Ganeti/Curl/Internal.hs: src/Ganeti/Curl/Internal.hsc | stamp-directories
1664
	hsc2hs -o $@ $<
1665

    
1666
test/hs/Test/Ganeti/TestImports.hs: test/hs/Test/Ganeti/TestImports.hs.in \
1667
	$(built_base_sources)
1668
	set -e; \
1669
	{ cat $< ; \
1670
	  echo ; \
1671
	  for name in $(filter-out Ganeti.THH,$(subst /,.,$(patsubst %.hs,%,$(patsubst src/%,%,$(HS_LIB_SRCS))))) ; do \
1672
	    echo "import $$name ()" ; \
1673
	  done ; \
1674
	} > $@
1675

    
1676
lib/_autoconf.py: Makefile | stamp-directories
1677
	set -e; \
1678
	{ echo '# This file is automatically generated, do not edit!'; \
1679
	  echo '#'; \
1680
	  echo ''; \
1681
	  echo '"""Build-time configuration for Ganeti.'; \
1682
	  echo '';\
1683
	  echo 'This file is autogenerated by the build process.'; \
1684
	  echo 'For any changes you need to re-run ./configure (and'; \
1685
	  echo 'not edit by hand).'; \
1686
	  echo ''; \
1687
	  echo '"""'; \
1688
	  echo ''; \
1689
	  echo '# pylint: disable=C0301,C0324'; \
1690
	  echo '# because this is autogenerated, we do not want'; \
1691
	  echo '# style warnings' ; \
1692
	  echo ''; \
1693
	  echo "PACKAGE_VERSION = '$(PACKAGE_VERSION)'"; \
1694
	  echo "VERSION_MAJOR = '$(VERSION_MAJOR)'"; \
1695
	  echo "VERSION_MINOR = '$(VERSION_MINOR)'"; \
1696
	  echo "VERSION_REVISION = '$(VERSION_REVISION)'"; \
1697
	  echo "VERSION_SUFFIX = '$(VERSION_SUFFIX)'"; \
1698
	  echo "VERSION_FULL = '$(VERSION_FULL)'"; \
1699
	  echo "LOCALSTATEDIR = '$(localstatedir)'"; \
1700
	  echo "SYSCONFDIR = '$(sysconfdir)'"; \
1701
	  echo "SSH_CONFIG_DIR = '$(SSH_CONFIG_DIR)'"; \
1702
	  echo "SSH_LOGIN_USER = '$(SSH_LOGIN_USER)'"; \
1703
	  echo "SSH_CONSOLE_USER = '$(SSH_CONSOLE_USER)'"; \
1704
	  echo "EXPORT_DIR = '$(EXPORT_DIR)'"; \
1705
	  echo "OS_SEARCH_PATH = [$(OS_SEARCH_PATH)]"; \
1706
	  echo "ES_SEARCH_PATH = [$(ES_SEARCH_PATH)]"; \
1707
	  echo "XEN_BOOTLOADER = '$(XEN_BOOTLOADER)'"; \
1708
	  echo "XEN_CONFIG_DIR = '$(XEN_CONFIG_DIR)'"; \
1709
	  echo "XEN_KERNEL = '$(XEN_KERNEL)'"; \
1710
	  echo "XEN_INITRD = '$(XEN_INITRD)'"; \
1711
	  echo "KVM_KERNEL = '$(KVM_KERNEL)'"; \
1712
	  echo "SHARED_FILE_STORAGE_DIR = '$(SHARED_FILE_STORAGE_DIR)'"; \
1713
	  echo "IALLOCATOR_SEARCH_PATH = [$(IALLOCATOR_SEARCH_PATH)]"; \
1714
	  echo "KVM_PATH = '$(KVM_PATH)'"; \
1715
	  echo "IP_PATH = '$(IP_PATH)'"; \
1716
	  echo "SOCAT_PATH = '$(SOCAT)'"; \
1717
	  echo "SOCAT_USE_ESCAPE = $(SOCAT_USE_ESCAPE)"; \
1718
	  echo "SOCAT_USE_COMPRESS = $(SOCAT_USE_COMPRESS)"; \
1719
	  echo "LVM_STRIPECOUNT = $(LVM_STRIPECOUNT)"; \
1720
	  echo "TOOLSDIR = '$(toolsdir)'"; \
1721
	  echo "GNT_SCRIPTS = [$(foreach i,$(notdir $(gnt_scripts)),'$(i)',)]"; \
1722
	  echo "HTOOLS_PROGS = [$(foreach i,$(HS_HTOOLS_PROGS),'$(i)',)]"; \
1723
	  echo "PKGLIBDIR = '$(pkglibdir)'"; \
1724
	  echo "DRBD_BARRIERS = '$(DRBD_BARRIERS)'"; \
1725
	  echo "DRBD_NO_META_FLUSH = $(DRBD_NO_META_FLUSH)"; \
1726
	  echo "SYSLOG_USAGE = '$(SYSLOG_USAGE)'"; \
1727
	  echo "DAEMONS_GROUP = '$(DAEMONS_GROUP)'"; \
1728
	  echo "ADMIN_GROUP = '$(ADMIN_GROUP)'"; \
1729
	  echo "MASTERD_USER = '$(MASTERD_USER)'"; \
1730
	  echo "MASTERD_GROUP = '$(MASTERD_GROUP)'"; \
1731
	  echo "RAPI_USER = '$(RAPI_USER)'"; \
1732
	  echo "RAPI_GROUP = '$(RAPI_GROUP)'"; \
1733
	  echo "CONFD_USER = '$(CONFD_USER)'"; \
1734
	  echo "CONFD_GROUP = '$(CONFD_GROUP)'"; \
1735
	  echo "LUXID_USER = '$(LUXID_USER)'"; \
1736
	  echo "LUXID_GROUP = '$(LUXID_GROUP)'"; \
1737
	  echo "NODED_USER = '$(NODED_USER)'"; \
1738
	  echo "NODED_GROUP = '$(NODED_GROUP)'"; \
1739
	  echo "MOND_USER = '$(MOND_USER)'"; \
1740
	  echo "MOND_GROUP = '$(MOND_GROUP)'"; \
1741
	  echo "DISK_SEPARATOR = '$(DISK_SEPARATOR)'"; \
1742
	  echo "QEMUIMG_PATH = '$(QEMUIMG_PATH)'"; \
1743
	  echo "HTOOLS = True"; \
1744
	  echo "ENABLE_CONFD = $(ENABLE_CONFD)"; \
1745
	  echo "XEN_CMD = '$(XEN_CMD)'"; \
1746
	  echo "ENABLE_SPLIT_QUERY = $(ENABLE_SPLIT_QUERY)"; \
1747
	  echo "ENABLE_RESTRICTED_COMMANDS = $(ENABLE_RESTRICTED_COMMANDS)"; \
1748
	  echo "ENABLE_MOND = $(ENABLE_MOND)"; \
1749
## Write dictionary with man page name as the key and the section number as the
1750
## value
1751
	  echo "MAN_PAGES = {"; \
1752
	  for i in $(notdir $(man_MANS)); do \
1753
	    echo "$$i" | sed -re 's/^(.*)\.([0-9]+)$$/  "\1": \2,/g'; \
1754
	  done; \
1755
	  echo "}"; \
1756
	} > $@
1757

    
1758
lib/_constants.py: Makefile lib/_constants.py.in src/hs2py-constants \
1759
		 | stamp-directories
1760
	cat $(abs_top_srcdir)/lib/_constants.py.in > $@
1761
	src/hs2py-constants >> $@
1762

    
1763
lib/constants.py: lib/_constants.py
1764

    
1765
lib/_vcsversion.py: Makefile vcs-version | stamp-directories
1766
	set -e; \
1767
	VCSVER=`cat $(abs_top_srcdir)/vcs-version`; \
1768
	{ echo '# This file is automatically generated, do not edit!'; \
1769
	  echo '#'; \
1770
	  echo ''; \
1771
	  echo '"""Build-time VCS version number for Ganeti.'; \
1772
	  echo '';\
1773
	  echo 'This file is autogenerated by the build process.'; \
1774
	  echo 'For any changes you need to re-run ./configure (and'; \
1775
	  echo 'not edit by hand).'; \
1776
	  echo ''; \
1777
	  echo '"""'; \
1778
	  echo ''; \
1779
	  echo '# pylint: disable=C0301,C0324'; \
1780
	  echo '# because this is autogenerated, we do not want'; \
1781
	  echo '# style warnings' ; \
1782
	  echo ''; \
1783
	  echo "VCS_VERSION = '$$VCSVER'"; \
1784
	} > $@
1785

    
1786
lib/opcodes.py: Makefile src/hs2py src/Ganeti/PyConstants.hs \
1787
		lib/opcodes.py.in_before lib/opcodes.py.in_after \
1788
		| stamp-directories
1789
	cat $(abs_top_srcdir)/lib/opcodes.py.in_before > $@
1790
	src/hs2py >> $@
1791
	cat $(abs_top_srcdir)/lib/opcodes.py.in_after >> $@
1792

    
1793
lib/_generated_rpc.py: lib/rpc_defs.py $(BUILD_RPC)
1794
	PYTHONPATH=. $(RUN_IN_TEMPDIR) $(CURDIR)/$(BUILD_RPC) lib/rpc_defs.py > $@
1795

    
1796
$(SHELL_ENV_INIT): Makefile stamp-directories
1797
	set -e; \
1798
	{ echo '# Allow overriding for tests'; \
1799
	  echo 'readonly LOCALSTATEDIR=$${LOCALSTATEDIR:-$${GANETI_ROOTDIR:-}$(localstatedir)}'; \
1800
	  echo 'readonly SYSCONFDIR=$${SYSCONFDIR:-$${GANETI_ROOTDIR:-}$(sysconfdir)}'; \
1801
	  echo; \
1802
	  echo 'readonly PKGLIBDIR=$(pkglibdir)'; \
1803
	  echo 'readonly LOG_DIR="$$LOCALSTATEDIR/log/ganeti"'; \
1804
	  echo 'readonly RUN_DIR="$$LOCALSTATEDIR/run/ganeti"'; \
1805
	  echo 'readonly DATA_DIR="$$LOCALSTATEDIR/lib/ganeti"'; \
1806
	  echo 'readonly CONF_DIR="$$SYSCONFDIR/ganeti"'; \
1807
	} > $@
1808

    
1809
## Writes sed script to replace placeholders with build-time values. The
1810
## additional quotes after the first @ sign are necessary to stop configure
1811
## from replacing those values as well.
1812
$(REPLACE_VARS_SED): $(SHELL_ENV_INIT) Makefile stamp-directories
1813
	set -e; \
1814
	{ echo 's#@''PREFIX@#$(prefix)#g'; \
1815
	  echo 's#@''SYSCONFDIR@#$(sysconfdir)#g'; \
1816
	  echo 's#@''LOCALSTATEDIR@#$(localstatedir)#g'; \
1817
	  echo 's#@''BINDIR@#$(execprefix)/bin#g'; \
1818
	  echo 's#@''SBINDIR@#$(execprefix)/sbin#g'; \
1819
	  echo 's#@''LIBDIR@#$(libdir)#g'; \
1820
	  echo 's#@''GANETI_VERSION@#$(PACKAGE_VERSION)#g'; \
1821
	  echo 's#@''CUSTOM_XEN_BOOTLOADER@#$(XEN_BOOTLOADER)#g'; \
1822
	  echo 's#@''CUSTOM_XEN_KERNEL@#$(XEN_KERNEL)#g'; \
1823
	  echo 's#@''CUSTOM_XEN_INITRD@#$(XEN_INITRD)#g'; \
1824
	  echo 's#@''CUSTOM_IALLOCATOR_SEARCH_PATH@#$(IALLOCATOR_SEARCH_PATH)#g'; \
1825
	  echo 's#@''CUSTOM_EXPORT_DIR@#$(EXPORT_DIR)#g'; \
1826
	  echo 's#@''RPL_SSH_INITD_SCRIPT@#$(SSH_INITD_SCRIPT)#g'; \
1827
	  echo 's#@''PKGLIBDIR@#$(libdir)/ganeti#g'; \
1828
	  echo 's#@''GNTMASTERUSER@#$(MASTERD_USER)#g'; \
1829
	  echo 's#@''GNTRAPIUSER@#$(RAPI_USER)#g'; \
1830
	  echo 's#@''GNTCONFDUSER@#$(CONFD_USER)#g'; \
1831
	  echo 's#@''GNTLUXIDUSER@#$(LUXID_USER)#g'; \
1832
	  echo 's#@''GNTNODEDUSER@#$(NODED_USER)#g'; \
1833
	  echo 's#@''GNTMONDUSER@#$(MOND_USER)#g'; \
1834
	  echo 's#@''GNTRAPIGROUP@#$(RAPI_GROUP)#g'; \
1835
	  echo 's#@''GNTADMINGROUP@#$(ADMIN_GROUP)#g'; \
1836
	  echo 's#@''GNTCONFDGROUP@#$(CONFD_GROUP)#g'; \
1837
	  echo 's#@''GNTLUXIDGROUP@#$(LUXID_GROUP)#g'; \
1838
	  echo 's#@''GNTMASTERDGROUP@#$(MASTERD_GROUP)#g'; \
1839
	  echo 's#@''GNTMONDGROUP@#$(MOND_GROUP)#g'; \
1840
	  echo 's#@''GNTDAEMONSGROUP@#$(DAEMONS_GROUP)#g'; \
1841
	  echo 's#@''CUSTOM_ENABLE_CONFD@#$(ENABLE_CONFD)#g'; \
1842
	  echo 's#@''CUSTOM_ENABLE_MOND@#$(ENABLE_MOND)#g'; \
1843
	  echo 's#@''MODULES@#$(strip $(lint_python_code))#g'; \
1844
	  echo 's#@''XEN_CONFIG_DIR@#$(XEN_CONFIG_DIR)#g'; \
1845
	  echo; \
1846
	  echo '/^@SHELL_ENV_INIT@$$/ {'; \
1847
	  echo '  r $(SHELL_ENV_INIT)'; \
1848
	  echo '  d'; \
1849
	  echo '}'; \
1850
	} > $@
1851

    
1852
# Using deferred evaluation
1853
daemons/ganeti-%: MODULE = ganeti.server.$(patsubst ganeti-%,%,$(notdir $@))
1854
daemons/ganeti-watcher: MODULE = ganeti.watcher
1855
scripts/%: MODULE = ganeti.client.$(subst -,_,$(notdir $@))
1856
tools/burnin: MODULE = ganeti.tools.burnin
1857
tools/ensure-dirs: MODULE = ganeti.tools.ensure_dirs
1858
tools/node-daemon-setup: MODULE = ganeti.tools.node_daemon_setup
1859
tools/prepare-node-join: MODULE = ganeti.tools.prepare_node_join
1860
tools/node-cleanup: MODULE = ganeti.tools.node_cleanup
1861
$(HS_BUILT_TEST_HELPERS): TESTROLE = $(patsubst test/hs/%,%,$@)
1862

    
1863
$(PYTHON_BOOTSTRAP): Makefile | stamp-directories
1864
	test -n "$(MODULE)" || { echo Missing module; exit 1; }
1865
	set -e; \
1866
	{ echo '#!/usr/bin/python'; \
1867
	  echo '# This file is automatically generated, do not edit!'; \
1868
	  echo "# Edit $(MODULE) instead."; \
1869
	  echo; \
1870
	  echo '"""Bootstrap script for L{$(MODULE)}"""'; \
1871
	  echo; \
1872
	  echo '# pylint: disable=C0103'; \
1873
	  echo '# C0103: Invalid name'; \
1874
	  echo; \
1875
	  echo 'import sys'; \
1876
	  echo 'import $(MODULE) as main'; \
1877
	  echo; \
1878
	  echo '# Temporarily alias commands until bash completion'; \
1879
	  echo '# generator is changed'; \
1880
	  echo 'if hasattr(main, "commands"):'; \
1881
	  echo '  commands = main.commands # pylint: disable=E1101'; \
1882
	  echo 'if hasattr(main, "aliases"):'; \
1883
	  echo '  aliases = main.aliases # pylint: disable=E1101'; \
1884
	  echo; \
1885
	  echo 'if __name__ == "__main__":'; \
1886
	  echo '  sys.exit(main.Main())'; \
1887
	} > $@
1888
	chmod u+x $@
1889

    
1890
$(HS_BUILT_TEST_HELPERS): Makefile
1891
	@test -n "$(TESTROLE)" || { echo Missing TESTROLE; exit 1; }
1892
	set -e; \
1893
	{ echo '#!/bin/sh'; \
1894
	  echo '# This file is automatically generated, do not edit!'; \
1895
	  echo "# Edit Makefile.am instead."; \
1896
	  echo; \
1897
	  echo "HTOOLS=$(TESTROLE) exec ./test/hs/hpc-htools \"\$$@\""; \
1898
	} > $@
1899
	chmod u+x $@
1900

    
1901
stamp-directories: Makefile
1902
	$(MAKE) $(AM_MAKEFLAGS) ganeti
1903
	@mkdir_p@ $(DIRS) $(BUILDTIME_DIR_AUTOCREATE)
1904
	touch $@
1905

    
1906
# We need to create symlinks because "make distcheck" will not install Python
1907
# files when building.
1908
stamp-srclinks: Makefile | stamp-directories
1909
	set -e; \
1910
	for i in $(srclink_files); do \
1911
	  if test ! -f $$i -a -f $(abs_top_srcdir)/$$i; then \
1912
	    $(LN_S) $(abs_top_srcdir)/$$i $$i; \
1913
	  fi; \
1914
	done
1915
	touch $@
1916

    
1917
.PHONY: ganeti
1918
ganeti:
1919
	cd $(top_builddir) && test -h "$@" || { rm -f $@ && $(LN_S) lib $@; }
1920

    
1921
.PHONY: check-dirs
1922
check-dirs: $(GENERATED_FILES)
1923
	@set -e; \
1924
	find . -type d \( -name . -o -name .git -prune -o -print \) | { \
1925
	  error=; \
1926
	  while read dir; do \
1927
	    case "$$dir" in \
1928
	      $(strip $(patsubst %,(./%) ;;,$(DIRCHECK_EXCLUDE) $(DIRS))) \
1929
	      *) error=1; echo "Directory $$dir not listed in Makefile" >&2 ;; \
1930
	    esac; \
1931
	  done; \
1932
	  for dir in $(DIRS); do \
1933
	    if ! test -d "$$dir"; then \
1934
	      echo "Directory $$dir listed in DIRS does not exist" >&2; \
1935
	      error=1; \
1936
	    fi \
1937
	  done; \
1938
	  test -z "$$error"; \
1939
	}
1940

    
1941
.PHONY: check-local
1942
check-local: check-dirs $(GENERATED_FILES)
1943
	$(CHECK_PYTHON_CODE) $(check_python_code)
1944
	PYTHONPATH=. $(CHECK_HEADER) $(check_python_code)
1945
	$(CHECK_VERSION) $(VERSION) $(top_srcdir)/NEWS
1946
	RELEASE=$(PACKAGE_VERSION) $(CHECK_NEWS) < $(top_srcdir)/NEWS
1947
	PYTHONPATH=. $(RUN_IN_TEMPDIR) $(CURDIR)/$(CHECK_IMPORTS) . $(standalone_python_modules)
1948
	error= ; \
1949
	if [ "x`echo $(VERSION_SUFFIX)|grep 'alpha'`" == "x" ]; then \
1950
	  expver=$(VERSION_MAJOR).$(VERSION_MINOR); \
1951
	  if test "`head -n 1 $(top_srcdir)/README`" != "Ganeti $$expver"; then \
1952
	    echo "Incorrect version in README, expected $$expver" >&2; \
1953
	    error=1; \
1954
	  fi; \
1955
	  for file in doc/iallocator.rst doc/hooks.rst doc/virtual-cluster.rst \
1956
	      doc/security.rst; do \
1957
	    if test "`sed -ne '4 p' $(top_srcdir)/$$file`" != \
1958
	      "Documents Ganeti version $$expver"; then \
1959
	      echo "Incorrect version in $$file, expected $$expver" >&2; \
1960
	      error=1; \
1961
	    fi; \
1962
	  done; \
1963
	  if ! test -f $(top_srcdir)/doc/design-$$expver.rst; then \
1964
	    echo "File $(top_srcdir)/doc/design-$$expver.rst not found" >&2; \
1965
	    error=1; \
1966
	  fi; \
1967
	  if test "`sed -ne '5 p' $(top_srcdir)/doc/design-draft.rst`" != \
1968
	    ".. Last updated for Ganeti $$expver"; then \
1969
	    echo "doc/design-draft.rst was not updated for version $$expver" >&2; \
1970
	    error=1; \
1971
	  fi; \
1972
	fi; \
1973
	for file in configure.ac $(HS_LIBTEST_SRCS) $(HS_PROG_SRCS); do \
1974
	  if test $$(wc --max-line-length < $(top_srcdir)/$$file) -gt 80; then \
1975
	    echo "Longest line in $$file is longer than 80 characters" >&2; \
1976
	    error=1; \
1977
	  fi; \
1978
	done; \
1979
	test -z "$$error"
1980

    
1981
.PHONY: hs-test-%
1982
hs-test-%: test/hs/htest | $(BUILT_PYTHON_SOURCES)
1983
	@rm -f htest.tix
1984
	test/hs/htest -t $*
1985

    
1986
.PHONY: hs-tests
1987
hs-tests: test/hs/htest | $(BUILT_PYTHON_SOURCES)
1988
	@rm -f htest.tix
1989
	./test/hs/htest
1990

    
1991
.PHONY: hs-shell-%
1992
hs-shell-%: test/hs/hpc-htools test/hs/hpc-mon-collector \
1993
            $(HS_BUILT_TEST_HELPERS)
1994
	@rm -f hpc-htools.tix hpc-mon-collector.tix
1995
	HBINARY="./test/hs/hpc-htools" \
1996
	SHELLTESTARGS=$(SHELLTESTARGS) \
1997
	./test/hs/offline-test.sh $*
1998

    
1999
.PHONY: hs-shell
2000
hs-shell: test/hs/hpc-htools test/hs/hpc-mon-collector $(HS_BUILT_TEST_HELPERS)
2001
	@rm -f hpc-htools.tix hpc-mon-collector.tix
2002
	HBINARY="./test/hs/hpc-htools" \
2003
	SHELLTESTARGS=$(SHELLTESTARGS) \
2004
	./test/hs/offline-test.sh
2005

    
2006
.PHONY: hs-check
2007
hs-check: hs-tests hs-shell
2008

    
2009
# E111: indentation is not a multiple of four
2010
# E121: continuation line indentation is not a multiple of four
2011
#       (since our indent level is not 4)
2012
# E125: continuation line does not distinguish itself from next logical line
2013
#       (since our indent level is not 4)
2014
# E127: continuation line over-indented for visual indent
2015
#       (since our indent level is not 4)
2016
# note: do NOT add E128 here; it's a valid style error in most cases!
2017
# I've seen real errors, but also some cases were we indent wrongly
2018
# due to line length; try to rework the cases where it is triggered,
2019
# instead of silencing it
2020
# E261: at least two spaces before inline comment
2021
# E501: line too long (80 characters)
2022
PEP8_IGNORE = E111,E121,E125,E127,E261,E501
2023

    
2024
# For excluding pep8 expects filenames only, not whole paths
2025
PEP8_EXCLUDE = $(subst $(space),$(comma),$(strip $(notdir $(BUILT_PYTHON_SOURCES))))
2026

    
2027
LINT_TARGETS = pylint pylint-qa pylint-test
2028
if HAS_PEP8
2029
LINT_TARGETS += pep8
2030
endif
2031
if HAS_HLINT
2032
LINT_TARGETS += hlint
2033
endif
2034

    
2035
.PHONY: lint
2036
lint: $(LINT_TARGETS)
2037

    
2038
.PHONY: pylint
2039
pylint: $(GENERATED_FILES)
2040
	@test -n "$(PYLINT)" || { echo 'pylint' not found during configure; exit 1; }
2041
	$(PYLINT) $(LINT_OPTS) $(lint_python_code)
2042

    
2043
.PHONY: pylint-qa
2044
pylint-qa: $(GENERATED_FILES)
2045
	@test -n "$(PYLINT)" || { echo 'pylint' not found during configure; exit 1; }
2046
	cd $(top_srcdir)/qa && \
2047
	  PYTHONPATH=$(abs_top_srcdir) $(PYLINT) $(LINT_OPTS) \
2048
	  --rcfile  ../pylintrc $(patsubst qa/%.py,%,$(qa_scripts))
2049
# FIXME: lint all test code, not just the newly added test support
2050
pylint-test: $(GENERATED_FILES)
2051
	@test -n "$(PYLINT)" || { echo 'pylint' not found during configure; exit 1; }
2052
	cd $(top_srcdir) && \
2053
		PYTHONPATH=.:./test/py $(PYLINT) $(LINT_OPTS) \
2054
		--rcfile=pylintrc-test  $(python_test_support)
2055

    
2056
.PHONY: pep8
2057
pep8: $(GENERATED_FILES)
2058
	@test -n "$(PEP8)" || { echo 'pep8' not found during configure; exit 1; }
2059
	$(PEP8) --ignore='$(PEP8_IGNORE)' --exclude='$(PEP8_EXCLUDE)' \
2060
	  --repeat $(pep8_python_code)
2061

    
2062
# FIXME: remove ignore "Use void" when GHC 6.x is deprecated
2063
HLINT_EXCLUDES = src/Ganeti/THH.hs test/hs/hpc-htools.hs
2064
.PHONY: hlint
2065
hlint: $(HS_BUILT_SRCS) src/lint-hints.hs
2066
	@test -n "$(HLINT)" || { echo 'hlint' not found during configure; exit 1; }
2067
	@rm -f doc/hs-lint.html
2068
	if tty -s; then C="-c"; else C=""; fi; \
2069
	$(HLINT) --utf8 --report=doc/hs-lint.html --cross $$C \
2070
	  --ignore "Use first" \
2071
	  --ignore "Use &&&" \
2072
	  --ignore "Use void" \
2073
	  --ignore "Reduce duplication" \
2074
	  --hint src/lint-hints \
2075
	  $(filter-out $(HLINT_EXCLUDES),$(HS_LIBTEST_SRCS) $(HS_PROG_SRCS))
2076
	@if [ ! -f doc/hs-lint.html ]; then \
2077
	  echo "All good" > doc/hs-lint.html; \
2078
	fi
2079

    
2080
# a dist hook rule for updating the vcs-version file; this is
2081
# hardcoded due to where it needs to build the file...
2082
dist-hook:
2083
	$(MAKE) $(AM_MAKEFLAGS) regen-vcs-version
2084
	rm -f $(top_distdir)/vcs-version
2085
	cp -p $(srcdir)/vcs-version $(top_distdir)
2086

    
2087
# a distcheck hook rule for catching revision control directories
2088
distcheck-hook:
2089
	if find $(top_distdir) -name .svn -or -name .git | grep .; then \
2090
	  echo "Found revision control files in final archive." 1>&2; \
2091
	  exit 1; \
2092
	fi
2093
	if find $(top_distdir) -name '*.py[co]' | grep .; then \
2094
	  echo "Found Python byte code in final archive." 1>&2; \
2095
	  exit 1; \
2096
	fi
2097
	if find $(top_distdir) -name '*~' | grep .; then \
2098
	  echo "Found backup files in final archive." 1>&2; \
2099
	  exit 1; \
2100
	fi
2101
# Empty files or directories should not be distributed. They can cause
2102
# unnecessary warnings for packagers. Directories used by automake during
2103
# distcheck must be excluded.
2104
	if find $(top_distdir) -empty -and -not \( \
2105
	    -path $(top_distdir)/_build -or \
2106
	    -path $(top_distdir)/_inst \) | grep .; then \
2107
	  echo "Found empty files or directories in final archive." 1>&2; \
2108
	  exit 1; \
2109
	fi
2110
	if test -e $(top_distdir)/doc/man-html; then \
2111
	  echo "Found documentation including man pages in final archive" >&2; \
2112
	  exit 1; \
2113
	fi
2114

    
2115
# Backwards compatible distcheck-release target
2116
distcheck-release: distcheck
2117

    
2118
distrebuildcheck: dist
2119
	set -e; \
2120
	builddir=$$(mktemp -d $(abs_srcdir)/distrebuildcheck.XXXXXXX); \
2121
	trap "echo Removing $$builddir; cd $(abs_srcdir); rm -rf $$builddir" EXIT; \
2122
	cd $$builddir; \
2123
	tar xzf $(abs_srcdir)/$(distdir).tar.gz; \
2124
	cd $(distdir); \
2125
	./configure; \
2126
	$(MAKE) maintainer-clean; \
2127
	cp $(abs_srcdir)/vcs-version .; \
2128
	./configure; \
2129
	$(MAKE) $(AM_MAKEFLAGS)
2130

    
2131
dist-release: dist
2132
	set -e; \
2133
	for i in $(DIST_ARCHIVES); do \
2134
	  echo -n "Checking $$i ... "; \
2135
	  autotools/check-tar < $$i; \
2136
	  echo OK; \
2137
	done
2138

    
2139
install-exec-local:
2140
	@mkdir_p@ "$(DESTDIR)${localstatedir}/lib/ganeti" \
2141
	  "$(DESTDIR)${localstatedir}/log/ganeti" \
2142
	  "$(DESTDIR)${localstatedir}/run/ganeti"
2143
if INSTALL_SYMLINKS
2144
	for dir in $(SYMLINK_TARGET_DIRS); do \
2145
	  @mkdir_p@  $(DESTDIR)$$dir; \
2146
	done
2147
	for prog in $(HS_BIN_ROLES); do \
2148
	  $(LN_S) $(bindir)/$$prog $(DESTDIR)$(exec_prefix)/bin/$$prog; \
2149
	done
2150
	$(LN_S) $(bindir)/htools $(DESTDIR)$(libdir)/ganeti/iallocators/hail
2151
	for prog in $(all_sbin_scripts); do \
2152
	  $(LN_S) $(sbindir)/$$prog $(DESTDIR)$(exec_prefix)/sbin/$$prog; \
2153
	done
2154
	for link in $(SYMLINK_DIRS); do \
2155
	  $(LN_S) $(versiondir)$$link $(DESTDIR)$$link; \
2156
	done
2157
	for prog in $(all_myexeclib_scripts); do \
2158
	  $(LN_S) $(pkglibdir)/$$prog $(DESTDIR)$(libdir)/ganeti/$$prog; \
2159
	done
2160
	if ! test -n '$(ENABLE_MANPAGES)'; then \
2161
	  for man in $(manfullpath); do \
2162
	    $(LN_S) $(versiondir)$(datarootdir)/man/$$man $(DESTDIR)$(datarootdir)/man/$$man; \
2163
	  done; \
2164
	fi
2165
endif
2166

    
2167
.PHONY: apidoc
2168
if WANT_HSAPIDOC
2169
apidoc: py-apidoc hs-apidoc
2170
else
2171
apidoc: py-apidoc
2172
endif
2173

    
2174
.PHONY: py-apidoc
2175
py-apidoc: epydoc.conf $(RUN_IN_TEMPDIR) $(GENERATED_FILES)
2176
	env - PATH="$$PATH" PYTHONPATH="$$PYTHONPATH" \
2177
	$(RUN_IN_TEMPDIR) epydoc -v \
2178
	  --conf $(CURDIR)/epydoc.conf \
2179
	  --output $(CURDIR)/$(APIDOC_PY_DIR)
2180

    
2181
.PHONY: hs-apidoc
2182
hs-apidoc: $(APIDOC_HS_DIR)/index.html
2183

    
2184
$(APIDOC_HS_DIR)/index.html: $(HS_LIBTESTBUILT_SRCS) Makefile
2185
	@test -n "$(HSCOLOUR)" || \
2186
	    { echo 'HsColour' not found during configure; exit 1; }
2187
	@test -n "$(HADDOCK)" || \
2188
	    { echo 'haddock' not found during configure; exit 1; }
2189
	rm -rf $(APIDOC_HS_DIR)/*
2190
	for i in $(ALL_APIDOC_HS_DIRS); do \
2191
	  @mkdir_p@ $$i; \
2192
	  $(HSCOLOUR) -print-css > $$i/hscolour.css; \
2193
	done
2194
	set -e ; \
2195
	export LC_ALL=en_US.UTF-8; \
2196
	OPTGHC="--optghc=-isrc --optghc=-itest/hs"; \
2197
	if [ "$(HS_PARALLEL3)" ]; \
2198
	then OPTGHC="$$OPTGHC --optghc=$(HS_PARALLEL3)"; \
2199
	fi; \
2200
	if [ "$(HS_REGEX_PCRE)" ]; \
2201
	then OPTGHC="$$OPTGHC --optghc=$(HS_REGEX_PCRE)"; \
2202
	fi; \
2203
	for file in $(HS_LIBTESTBUILT_SRCS); do \
2204
	  f_nosrc=$${file##src/}; \
2205
	  f_notst=$${f_nosrc##test/hs/}; \
2206
	  f_html=$${f_notst%%.hs}.html; \
2207
	  $(HSCOLOUR) -css -anchor $$file > $(APIDOC_HS_DIR)/$$f_html ; \
2208
	done ; \
2209
	$(HADDOCK) --odir $(APIDOC_HS_DIR) --html --ignore-all-exports -w \
2210
	  -t ganeti -p src/haddock-prologue \
2211
	  --source-module="%{MODULE/.//}.html" \
2212
	  --source-entity="%{MODULE/.//}.html#%{NAME}" \
2213
	  $$OPTGHC \
2214
	  $(HS_LIBTESTBUILT_SRCS)
2215

    
2216
.PHONY: TAGS
2217
TAGS: $(GENERATED_FILES)
2218
	rm -f TAGS
2219
	$(GHC) -e ":etags" -v0 \
2220
	  $(filter-out -O -Werror,$(HFLAGS)) \
2221
	  $(HS_PARALLEL3) $(HS_REGEX_PCRE) \
2222
	  $(HS_LIBTEST_SRCS)
2223
	find . -path './lib/*.py' -o -path './scripts/gnt-*' -o \
2224
	  -path './daemons/ganeti-*' -o -path './tools/*' -o \
2225
	  -path './qa/*.py' | \
2226
	  etags -l python -a -
2227

    
2228
.PHONY: coverage
2229

    
2230
COVERAGE_TESTS=
2231
if WANT_HTOOLS
2232
COVERAGE_TESTS += hs-coverage
2233
endif
2234
if PY_UNIT
2235
COVERAGE_TESTS += py-coverage
2236
endif
2237

    
2238
coverage: $(COVERAGE_TESTS)
2239

    
2240
.PHONY: py-coverage
2241
py-coverage: $(GENERATED_FILES) $(python_tests)
2242
	@test -n "$(PYCOVERAGE)" || \
2243
	    { echo 'python-coverage' not found during configure; exit 1; }
2244
	set -e; \
2245
	COVERAGE=$(PYCOVERAGE) \
2246
	COVERAGE_FILE=$(CURDIR)/$(COVERAGE_PY_DIR)/data \
2247
	TEXT_COVERAGE=$(CURDIR)/$(COVERAGE_PY_DIR)/report.txt \
2248
	HTML_COVERAGE=$(CURDIR)/$(COVERAGE_PY_DIR) \
2249
	$(PLAIN_TESTS_ENVIRONMENT) \
2250
	$(abs_top_srcdir)/autotools/gen-py-coverage \
2251
	$(python_tests)
2252

    
2253
.PHONY: hs-coverage
2254
hs-coverage: $(haskell_tests) test/hs/hpc-htools test/hs/hpc-mon-collector
2255
	rm -f *.tix
2256
	$(MAKE) $(AM_MAKEFLAGS) hs-check
2257
	@mkdir_p@ $(COVERAGE_HS_DIR)
2258
	hpc sum --union $(HPCEXCL) \
2259
	  htest.tix hpc-htools.tix hpc-mon-collector.tix > coverage-hs.tix
2260
	hpc markup --destdir=$(COVERAGE_HS_DIR) coverage-hs.tix
2261
	hpc report coverage-hs.tix | tee $(COVERAGE_HS_DIR)/report.txt
2262
	$(LN_S) -f hpc_index.html $(COVERAGE_HS_DIR)/index.html
2263

    
2264
# Special "kind-of-QA" target for htools, needs special setup (all
2265
# tools compiled with -fhpc)
2266
.PHONY: live-test
2267
live-test: all
2268
	set -e ; \
2269
	cd src; \
2270
	rm -f .hpc; $(LN_S) ../.hpc .hpc; \
2271
	rm -f *.tix *.mix; \
2272
	./live-test.sh; \
2273
	hpc sum --union $(HPCEXCL) $(addsuffix .tix,$(HS_PROGS:src/%=%)) \
2274
	  --output=live-test.tix ; \
2275
	@mkdir_p@ ../$(COVERAGE_HS_DIR) ; \
2276
	hpc markup --destdir=../$(COVERAGE_HS_DIR) live-test \
2277
	  --srcdir=.. $(HPCEXCL) ; \
2278
	hpc report --srcdir=.. live-test $(HPCEXCL)
2279

    
2280
commit-check: autotools-check distcheck lint apidoc
2281

    
2282
autotools-check:
2283
	TESTDATA_DIR=./test/data shelltest $(SHELLTESTARGS) \
2284
  $(abs_top_srcdir)/test/autotools/*-*.test \
2285
  -- --hide-successes
2286

    
2287
.PHONY: gitignore-check
2288
gitignore-check:
2289
	@if [ -n "`git status --short`" ]; then \
2290
	  echo "Git status is not clean!" 1>&2 ; \
2291
	  git status --short; \
2292
	  exit 1; \
2293
	fi
2294

    
2295
# target to rebuild all man pages (both groff and html output)
2296
.PHONY: man
2297
man: $(man_MANS) $(manhtml)
2298

    
2299
# Target that builds all binaries (including those that are not
2300
# rebuilt except when running the tests)
2301
.PHONY: really-all
2302
really-all: all $(check_SCRIPTS) $(haskell_tests) $(HS_ALL_PROGS)
2303

    
2304
# we don't need the ancient implicit rules:
2305
%: %,v
2306
%: RCS/%,v
2307
%: RCS/%
2308
%: s.%
2309
%: SCCS/s.%
2310

    
2311
-include ./Makefile.local
2312

    
2313
# vim: set noet :