Statistics
| Branch: | Tag: | Revision:

root / Makefile.am @ eb7a6965

History | View | Annotate | Download (52.9 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
# Use bash in order to be able to use pipefail
18
SHELL=/bin/bash
19

    
20
ACLOCAL_AMFLAGS = -I autotools
21
BUILD_BASH_COMPLETION = $(top_srcdir)/autotools/build-bash-completion
22
RUN_IN_TEMPDIR = $(top_srcdir)/autotools/run-in-tempdir
23
CHECK_PYTHON_CODE = $(top_srcdir)/autotools/check-python-code
24
CHECK_HEADER = $(top_srcdir)/autotools/check-header
25
CHECK_MAN_DASHES = $(top_srcdir)/autotools/check-man-dashes
26
CHECK_MAN_REFERENCES = $(top_srcdir)/autotools/check-man-references
27
CHECK_MAN_WARNINGS = $(top_srcdir)/autotools/check-man-warnings
28
CHECK_VERSION = $(top_srcdir)/autotools/check-version
29
CHECK_NEWS = $(top_srcdir)/autotools/check-news
30
CHECK_IMPORTS = $(top_srcdir)/autotools/check-imports
31
DOCPP = $(top_srcdir)/autotools/docpp
32
REPLACE_VARS_SED = autotools/replace_vars.sed
33
CONVERT_CONSTANTS = $(top_srcdir)/autotools/convert-constants
34
BUILD_RPC = $(top_srcdir)/autotools/build-rpc
35
SHELL_ENV_INIT = autotools/shell-env-init
36

    
37
# Note: these are automake-specific variables, and must be named after
38
# the directory + 'dir' suffix
39
clientdir = $(pkgpythondir)/client
40
hypervisordir = $(pkgpythondir)/hypervisor
41
httpdir = $(pkgpythondir)/http
42
masterddir = $(pkgpythondir)/masterd
43
confddir = $(pkgpythondir)/confd
44
rapidir = $(pkgpythondir)/rapi
45
serverdir = $(pkgpythondir)/server
46
watcherdir = $(pkgpythondir)/watcher
47
impexpddir = $(pkgpythondir)/impexpd
48
utilsdir = $(pkgpythondir)/utils
49
toolsdir = $(pkglibdir)/tools
50
iallocatorsdir = $(pkglibdir)/iallocators
51
pytoolsdir = $(pkgpythondir)/tools
52
docdir = $(datadir)/doc/$(PACKAGE)
53
myexeclibdir = $(pkglibdir)
54

    
55
# Delete output file if an error occurred while building it
56
.DELETE_ON_ERROR:
57

    
58
HS_DIRS = \
59
	src \
60
	src/Ganeti \
61
	src/Ganeti/Block \
62
	src/Ganeti/Block/Drbd \
63
	src/Ganeti/Confd \
64
	src/Ganeti/DataCollectors \
65
	src/Ganeti/HTools \
66
	src/Ganeti/HTools/Backend \
67
	src/Ganeti/HTools/Program \
68
	src/Ganeti/Query \
69
	test/hs \
70
	test/hs/Test \
71
	test/hs/Test/Ganeti \
72
	test/hs/Test/Ganeti/Block \
73
	test/hs/Test/Ganeti/Block/Drbd \
74
	test/hs/Test/Ganeti/Confd \
75
	test/hs/Test/Ganeti/HTools \
76
	test/hs/Test/Ganeti/HTools/Backend \
77
	test/hs/Test/Ganeti/Query
78

    
79
DIRS = \
80
	$(HS_DIRS) \
81
	autotools \
82
	daemons \
83
	devel \
84
	doc \
85
	doc/css \
86
	doc/examples \
87
	doc/examples/gnt-debug \
88
	doc/examples/hooks \
89
	test/data/htools \
90
	test/data/htools/rapi \
91
	test/hs/shelltests \
92
	lib \
93
	lib/build \
94
	lib/client \
95
	lib/confd \
96
	lib/http \
97
	lib/hypervisor \
98
	lib/impexpd \
99
	lib/masterd \
100
	lib/rapi \
101
	lib/server \
102
	lib/tools \
103
	lib/utils \
104
	lib/watcher \
105
	man \
106
	qa \
107
	test \
108
	test/data \
109
	test/data/ovfdata \
110
	test/data/ovfdata/other \
111
	test/py \
112
	tools
113

    
114
ALL_APIDOC_HS_DIRS = \
115
	$(APIDOC_HS_DIR) \
116
	$(APIDOC_HS_DIR)/Ganeti \
117
	$(APIDOC_HS_DIR)/Ganeti/Block \
118
	$(APIDOC_HS_DIR)/Ganeti/Block/Drbd \
119
	$(APIDOC_HS_DIR)/Ganeti/Confd \
120
	$(APIDOC_HS_DIR)/Ganeti/DataCollectors \
121
	$(APIDOC_HS_DIR)/Ganeti/HTools \
122
	$(APIDOC_HS_DIR)/Ganeti/HTools/Backend \
123
	$(APIDOC_HS_DIR)/Ganeti/HTools/Program \
124
	$(APIDOC_HS_DIR)/Ganeti/Query
125

    
126
BUILDTIME_DIR_AUTOCREATE = \
127
	scripts \
128
	$(APIDOC_DIR) \
129
	$(ALL_APIDOC_HS_DIRS) \
130
	$(APIDOC_PY_DIR) \
131
	$(COVERAGE_DIR) \
132
	$(COVERAGE_HS_DIR) \
133
	$(COVERAGE_PY_DIR) \
134
	.hpc
135

    
136
BUILDTIME_DIRS = \
137
	$(BUILDTIME_DIR_AUTOCREATE) \
138
	doc/html
139

    
140
DIRCHECK_EXCLUDE = \
141
	$(BUILDTIME_DIRS) \
142
	ganeti-[0-9]*.[0-9]*.[0-9]* \
143
	doc/html/_* \
144
	autom4te.cache
145

    
146
# some helper vars
147
COVERAGE_DIR = doc/coverage
148
COVERAGE_PY_DIR = $(COVERAGE_DIR)/py
149
COVERAGE_HS_DIR = $(COVERAGE_DIR)/hs
150
APIDOC_DIR = doc/api
151
APIDOC_PY_DIR = $(APIDOC_DIR)/py
152
APIDOC_HS_DIR = $(APIDOC_DIR)/hs
153

    
154
MAINTAINERCLEANFILES = \
155
	$(maninput) \
156
	doc/install-quick.rst \
157
	doc/news.rst \
158
	doc/upgrade.rst \
159
	vcs-version
160

    
161
maintainer-clean-local:
162
	rm -rf $(BUILDTIME_DIRS)
163

    
164
CLEANFILES = \
165
	$(addsuffix /*.py[co],$(DIRS)) \
166
	$(addsuffix /*.hi,$(HS_DIRS)) \
167
	$(addsuffix /*.o,$(HS_DIRS)) \
168
	$(PYTHON_BOOTSTRAP) \
169
	epydoc.conf \
170
	$(REPLACE_VARS_SED) \
171
	$(SHELL_ENV_INIT) \
172
	daemons/daemon-util \
173
	daemons/ganeti-cleaner \
174
	$(BUILT_EXAMPLES) \
175
	doc/examples/bash_completion \
176
	doc/examples/bash_completion-debug \
177
	lib/_generated_rpc.py \
178
	$(man_MANS) \
179
	$(manhtml) \
180
	tools/kvm-ifup \
181
	tools/vcluster-setup \
182
	stamp-directories \
183
	stamp-srclinks \
184
	$(nodist_pkgpython_PYTHON) \
185
	$(HS_ALL_PROGS) $(HS_BUILT_SRCS) \
186
	$(HS_BUILT_TEST_HELPERS) \
187
	src/ganeti-confd \
188
	.hpc/*.mix src/*.tix test/hs/*.tix \
189
	doc/hs-lint.html
190

    
191
GENERATED_FILES = \
192
	$(built_base_sources) \
193
	$(BUILT_PYTHON_SOURCES) \
194
	$(PYTHON_BOOTSTRAP)
195

    
196
HS_GENERATED_FILES =
197
if WANT_HTOOLS
198
HS_GENERATED_FILES += $(HS_PROGS)
199
if ENABLE_CONFD
200
HS_GENERATED_FILES += src/hconfd src/ganeti-confd
201
endif
202
endif
203

    
204
built_base_sources = \
205
	stamp-directories \
206
	stamp-srclinks
207

    
208
built_python_base_sources = \
209
	lib/_autoconf.py \
210
	lib/_vcsversion.py
211

    
212
BUILT_PYTHON_SOURCES = \
213
	$(built_python_base_sources) \
214
	lib/_generated_rpc.py
215

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

    
220
# these are all built from the underlying %.in sources
221
BUILT_EXAMPLES = \
222
	doc/examples/ganeti-kvm-poweroff.initd \
223
	doc/examples/ganeti.cron \
224
	doc/examples/ganeti.initd \
225
	doc/examples/ganeti-master-role.ocf \
226
	doc/examples/ganeti-node-role.ocf \
227
	doc/examples/gnt-config-backup \
228
	doc/examples/hooks/ipsec
229

    
230
nodist_pkgpython_PYTHON = \
231
	$(BUILT_PYTHON_SOURCES)
232

    
233
noinst_PYTHON = \
234
	lib/build/__init__.py \
235
	lib/build/shell_example_lexer.py \
236
	lib/build/sphinx_ext.py
237

    
238
pkgpython_PYTHON = \
239
	lib/__init__.py \
240
	lib/asyncnotifier.py \
241
	lib/backend.py \
242
	lib/bdev.py \
243
	lib/bootstrap.py \
244
	lib/cli.py \
245
	lib/cmdlib.py \
246
	lib/compat.py \
247
	lib/config.py \
248
	lib/constants.py \
249
	lib/daemon.py \
250
	lib/errors.py \
251
	lib/ht.py \
252
	lib/jqueue.py \
253
	lib/jstore.py \
254
	lib/locking.py \
255
	lib/luxi.py \
256
	lib/mcpu.py \
257
	lib/netutils.py \
258
	lib/objects.py \
259
	lib/objectutils.py \
260
	lib/opcodes.py \
261
	lib/ovf.py \
262
	lib/pathutils.py \
263
	lib/qlang.py \
264
	lib/query.py \
265
	lib/rpc.py \
266
	lib/rpc_defs.py \
267
	lib/runtime.py \
268
	lib/serializer.py \
269
	lib/ssconf.py \
270
	lib/ssh.py \
271
	lib/storage.py \
272
	lib/uidpool.py \
273
	lib/vcluster.py \
274
	lib/network.py \
275
	lib/workerpool.py
276

    
277
client_PYTHON = \
278
	lib/client/__init__.py \
279
	lib/client/gnt_backup.py \
280
	lib/client/gnt_cluster.py \
281
	lib/client/gnt_debug.py \
282
	lib/client/gnt_group.py \
283
	lib/client/gnt_instance.py \
284
	lib/client/gnt_job.py \
285
	lib/client/gnt_node.py \
286
	lib/client/gnt_network.py \
287
	lib/client/gnt_os.py \
288
	lib/client/gnt_storage.py
289

    
290
hypervisor_PYTHON = \
291
	lib/hypervisor/__init__.py \
292
	lib/hypervisor/hv_base.py \
293
	lib/hypervisor/hv_chroot.py \
294
	lib/hypervisor/hv_fake.py \
295
	lib/hypervisor/hv_kvm.py \
296
	lib/hypervisor/hv_lxc.py \
297
	lib/hypervisor/hv_xen.py
298

    
299
rapi_PYTHON = \
300
	lib/rapi/__init__.py \
301
	lib/rapi/baserlib.py \
302
	lib/rapi/client.py \
303
	lib/rapi/client_utils.py \
304
	lib/rapi/connector.py \
305
	lib/rapi/rlib2.py \
306
	lib/rapi/testutils.py
307

    
308
http_PYTHON = \
309
	lib/http/__init__.py \
310
	lib/http/auth.py \
311
	lib/http/client.py \
312
	lib/http/server.py
313

    
314
confd_PYTHON = \
315
	lib/confd/__init__.py \
316
	lib/confd/client.py
317

    
318
masterd_PYTHON = \
319
	lib/masterd/__init__.py \
320
	lib/masterd/iallocator.py \
321
	lib/masterd/instance.py
322

    
323
impexpd_PYTHON = \
324
	lib/impexpd/__init__.py
325

    
326
watcher_PYTHON = \
327
	lib/watcher/__init__.py \
328
	lib/watcher/nodemaint.py \
329
	lib/watcher/state.py
330

    
331
server_PYTHON = \
332
	lib/server/__init__.py \
333
	lib/server/masterd.py \
334
	lib/server/noded.py \
335
	lib/server/rapi.py
336

    
337
pytools_PYTHON = \
338
	lib/tools/__init__.py \
339
	lib/tools/ensure_dirs.py \
340
	lib/tools/node_cleanup.py \
341
	lib/tools/node_daemon_setup.py \
342
	lib/tools/prepare_node_join.py
343

    
344
utils_PYTHON = \
345
	lib/utils/__init__.py \
346
	lib/utils/algo.py \
347
	lib/utils/filelock.py \
348
	lib/utils/hash.py \
349
	lib/utils/io.py \
350
	lib/utils/log.py \
351
	lib/utils/lvm.py \
352
	lib/utils/mlock.py \
353
	lib/utils/nodesetup.py \
354
	lib/utils/process.py \
355
	lib/utils/retry.py \
356
	lib/utils/text.py \
357
	lib/utils/wrapper.py \
358
	lib/utils/x509.py
359

    
360
docinput = \
361
	doc/conf.py \
362
	doc/css/style.css \
363
	doc/admin.rst \
364
	doc/cluster-merge.rst \
365
	doc/design-2.0.rst \
366
	doc/design-2.1.rst \
367
	doc/design-2.2.rst \
368
	doc/design-2.3.rst \
369
	doc/design-2.4.rst \
370
	doc/design-2.5.rst \
371
	doc/design-2.6.rst \
372
	doc/design-2.7.rst \
373
	doc/design-autorepair.rst \
374
	doc/design-bulk-create.rst \
375
	doc/design-chained-jobs.rst \
376
	doc/design-cpu-pinning.rst \
377
	doc/design-draft.rst \
378
	doc/design-htools-2.3.rst \
379
	doc/design-http-server.rst \
380
	doc/design-impexp2.rst \
381
	doc/design-lu-generated-jobs.rst \
382
	doc/design-linuxha.rst \
383
	doc/design-multi-reloc.rst \
384
	doc/design-network.rst \
385
	doc/design-node-add.rst \
386
	doc/design-oob.rst \
387
	doc/design-ovf-support.rst \
388
	doc/design-opportunistic-locking.rst \
389
	doc/design-partitioned.rst \
390
	doc/design-query-splitting.rst \
391
	doc/design-query2.rst \
392
	doc/design-remote-commands.rst \
393
	doc/design-resource-model.rst \
394
	doc/design-shared-storage.rst \
395
	doc/design-monitoring-agent.rst \
396
	doc/design-virtual-clusters.rst \
397
	doc/design-x509-ca.rst \
398
	doc/devnotes.rst \
399
	doc/glossary.rst \
400
	doc/hooks.rst \
401
	doc/iallocator.rst \
402
	doc/index.rst \
403
	doc/install-quick.rst \
404
	doc/install.rst \
405
	doc/locking.rst \
406
	doc/move-instance.rst \
407
	doc/news.rst \
408
	doc/ovfconverter.rst \
409
	doc/rapi.rst \
410
	doc/security.rst \
411
	doc/upgrade.rst \
412
	doc/virtual-cluster.rst \
413
	doc/walkthrough.rst
414

    
415
# Haskell programs to be installed in $PREFIX/bin
416
HS_BIN_PROGS=src/htools
417

    
418
# Haskell programs to be installed in the MYEXECLIB dir
419
HS_MYEXECLIB_PROGS=src/mon-collector
420

    
421
# Haskell programs to compiled but not installed automatically
422
# Usually they have their own specific installation rules
423
HS_COMPILE_PROGS= \
424
	src/hconfd \
425
	src/rpc-test
426

    
427
# All Haskell non-test programs to be compiled but not automatically installed
428
HS_PROGS = $(HS_BIN_PROGS) $(HS_MYEXECLIB_PROGS)
429

    
430
HS_BIN_ROLES = hbal hscan hspace hinfo hcheck hroller
431
HS_HTOOLS_PROGS = $(HS_BIN_ROLES) hail
432

    
433
HS_ALL_PROGS = \
434
	$(HS_PROGS) \
435
	test/hs/hpc-htools \
436
	test/hs/hpc-mon-collector \
437
	test/hs/htest \
438
	$(HS_COMPILE_PROGS)
439

    
440
HS_PROG_SRCS = $(patsubst %,%.hs,$(HS_ALL_PROGS))
441
HS_BUILT_TEST_HELPERS = $(HS_BIN_ROLES:%=test/hs/%) test/hs/hail
442

    
443
HFLAGS = \
444
	-O -Wall -Werror -isrc \
445
	-fwarn-monomorphism-restriction \
446
	-fwarn-tabs \
447
	$(GHC_BYVERSION_FLAGS)
448

    
449
# extra flags that can be overriden on the command line (e.g. -Wwarn, etc.)
450
HEXTRA =
451
# internal extra flags (used for test/hs/htest mainly)
452
HEXTRA_INT =
453
# exclude options for coverage reports
454
HPCEXCL = --exclude Main \
455
	--exclude Ganeti.Constants \
456
	--exclude Ganeti.HTools.QC \
457
	--exclude Ganeti.THH \
458
	--exclude Ganeti.Version \
459
	--exclude Test.Ganeti.Attoparsec \
460
	--exclude Test.Ganeti.TestCommon \
461
	--exclude Test.Ganeti.TestHTools \
462
	--exclude Test.Ganeti.TestHelper \
463
	--exclude Test.Ganeti.TestImports \
464
	$(patsubst src.%,--exclude Test.%,$(subst /,.,$(patsubst %.hs,%, $(HS_LIB_SRCS))))
465

    
466
HS_LIB_SRCS = \
467
	src/Ganeti/Block/Drbd/Types.hs \
468
	src/Ganeti/Block/Drbd/Parser.hs \
469
	src/Ganeti/BasicTypes.hs \
470
	src/Ganeti/Common.hs \
471
	src/Ganeti/Compat.hs \
472
	src/Ganeti/Confd/Client.hs \
473
	src/Ganeti/Confd/Server.hs \
474
	src/Ganeti/Confd/Types.hs \
475
	src/Ganeti/Confd/Utils.hs \
476
	src/Ganeti/Config.hs \
477
	src/Ganeti/Daemon.hs \
478
	src/Ganeti/DataCollectors/CLI.hs \
479
	src/Ganeti/DataCollectors/Drbd.hs \
480
	src/Ganeti/DataCollectors/Program.hs \
481
	src/Ganeti/Errors.hs \
482
	src/Ganeti/HTools/Backend/IAlloc.hs \
483
	src/Ganeti/HTools/Backend/Luxi.hs \
484
	src/Ganeti/HTools/Backend/Rapi.hs \
485
	src/Ganeti/HTools/Backend/Simu.hs \
486
	src/Ganeti/HTools/Backend/Text.hs \
487
	src/Ganeti/HTools/CLI.hs \
488
	src/Ganeti/HTools/Cluster.hs \
489
	src/Ganeti/HTools/Container.hs \
490
	src/Ganeti/HTools/ExtLoader.hs \
491
	src/Ganeti/HTools/Graph.hs \
492
	src/Ganeti/HTools/Group.hs \
493
	src/Ganeti/HTools/Instance.hs \
494
	src/Ganeti/HTools/Loader.hs \
495
	src/Ganeti/HTools/Node.hs \
496
	src/Ganeti/HTools/PeerMap.hs \
497
	src/Ganeti/HTools/Program/Hail.hs \
498
	src/Ganeti/HTools/Program/Hbal.hs \
499
	src/Ganeti/HTools/Program/Hcheck.hs \
500
	src/Ganeti/HTools/Program/Hinfo.hs \
501
	src/Ganeti/HTools/Program/Hscan.hs \
502
	src/Ganeti/HTools/Program/Hspace.hs \
503
	src/Ganeti/HTools/Program/Hroller.hs \
504
	src/Ganeti/HTools/Program/Main.hs \
505
	src/Ganeti/HTools/Types.hs \
506
	src/Ganeti/Hash.hs \
507
	src/Ganeti/JQueue.hs \
508
	src/Ganeti/JSON.hs \
509
	src/Ganeti/Jobs.hs \
510
	src/Ganeti/Logging.hs \
511
	src/Ganeti/Luxi.hs \
512
	src/Ganeti/Network.hs \
513
	src/Ganeti/Objects.hs \
514
	src/Ganeti/OpCodes.hs \
515
	src/Ganeti/OpParams.hs \
516
	src/Ganeti/Path.hs \
517
	src/Ganeti/Query/Common.hs \
518
	src/Ganeti/Query/Filter.hs \
519
	src/Ganeti/Query/Group.hs \
520
	src/Ganeti/Query/Job.hs \
521
	src/Ganeti/Query/Language.hs \
522
	src/Ganeti/Query/Node.hs \
523
	src/Ganeti/Query/Query.hs \
524
	src/Ganeti/Query/Server.hs \
525
	src/Ganeti/Query/Types.hs \
526
	src/Ganeti/Rpc.hs \
527
	src/Ganeti/Runtime.hs \
528
	src/Ganeti/Ssconf.hs \
529
	src/Ganeti/THH.hs \
530
	src/Ganeti/Types.hs \
531
	src/Ganeti/Utils.hs
532

    
533
HS_TEST_SRCS = \
534
	test/hs/Test/Ganeti/Attoparsec.hs \
535
	test/hs/Test/Ganeti/BasicTypes.hs \
536
	test/hs/Test/Ganeti/Block/Drbd/Parser.hs \
537
	test/hs/Test/Ganeti/Block/Drbd/Types.hs \
538
	test/hs/Test/Ganeti/Common.hs \
539
	test/hs/Test/Ganeti/Confd/Types.hs \
540
	test/hs/Test/Ganeti/Confd/Utils.hs \
541
	test/hs/Test/Ganeti/Daemon.hs \
542
	test/hs/Test/Ganeti/Errors.hs \
543
	test/hs/Test/Ganeti/HTools/Backend/Simu.hs \
544
	test/hs/Test/Ganeti/HTools/Backend/Text.hs \
545
	test/hs/Test/Ganeti/HTools/CLI.hs \
546
	test/hs/Test/Ganeti/HTools/Cluster.hs \
547
	test/hs/Test/Ganeti/HTools/Container.hs \
548
	test/hs/Test/Ganeti/HTools/Graph.hs \
549
	test/hs/Test/Ganeti/HTools/Instance.hs \
550
	test/hs/Test/Ganeti/HTools/Loader.hs \
551
	test/hs/Test/Ganeti/HTools/Node.hs \
552
	test/hs/Test/Ganeti/HTools/PeerMap.hs \
553
	test/hs/Test/Ganeti/HTools/Types.hs \
554
	test/hs/Test/Ganeti/JSON.hs \
555
	test/hs/Test/Ganeti/Jobs.hs \
556
	test/hs/Test/Ganeti/JQueue.hs \
557
	test/hs/Test/Ganeti/Luxi.hs \
558
	test/hs/Test/Ganeti/Network.hs \
559
	test/hs/Test/Ganeti/Objects.hs \
560
	test/hs/Test/Ganeti/OpCodes.hs \
561
	test/hs/Test/Ganeti/Query/Filter.hs \
562
	test/hs/Test/Ganeti/Query/Language.hs \
563
	test/hs/Test/Ganeti/Query/Query.hs \
564
	test/hs/Test/Ganeti/Rpc.hs \
565
	test/hs/Test/Ganeti/Ssconf.hs \
566
	test/hs/Test/Ganeti/THH.hs \
567
	test/hs/Test/Ganeti/TestCommon.hs \
568
	test/hs/Test/Ganeti/TestHTools.hs \
569
	test/hs/Test/Ganeti/TestHelper.hs \
570
	test/hs/Test/Ganeti/Types.hs \
571
	test/hs/Test/Ganeti/Utils.hs
572

    
573
HS_LIBTEST_SRCS = $(HS_LIB_SRCS) $(HS_TEST_SRCS)
574

    
575
HS_BUILT_SRCS = \
576
	test/hs/Test/Ganeti/TestImports.hs \
577
	src/Ganeti/Constants.hs \
578
	src/Ganeti/Version.hs
579
HS_BUILT_SRCS_IN = $(patsubst %,%.in,$(HS_BUILT_SRCS))
580

    
581
$(RUN_IN_TEMPDIR): | stamp-directories
582

    
583
# Note: we use here an order-only prerequisite, as the contents of
584
# _autoconf.py are not actually influencing the html build output: it
585
# has to exist in order for the sphinx module to be loaded
586
# successfully, but we certainly don't want the docs to be rebuilt if
587
# it changes
588
doc/html/index.html: $(docinput) doc/conf.py configure.ac \
589
	$(RUN_IN_TEMPDIR) lib/build/sphinx_ext.py \
590
	lib/build/shell_example_lexer.py lib/opcodes.py lib/ht.py \
591
	doc/css/style.css \
592
	| $(BUILT_PYTHON_SOURCES)
593
	@test -n "$(SPHINX)" || \
594
	    { echo 'sphinx-build' not found during configure; exit 1; }
595
	@mkdir_p@ $(dir $@)
596
	PYTHONPATH=. $(RUN_IN_TEMPDIR) $(SPHINX) -q -W -b html \
597
	    -d . \
598
	    -D version="$(VERSION_MAJOR).$(VERSION_MINOR)" \
599
	    -D release="$(PACKAGE_VERSION)" \
600
	    -D graphviz_dot="$(DOT)" \
601
	    $(abs_top_builddir)/doc $(CURDIR)/doc/html
602
	rm -f doc/html/.buildinfo doc/html/objects.inv
603
	touch $@
604

    
605
doc/html: doc/html/index.html
606

    
607
doc/install-quick.rst: INSTALL
608
doc/news.rst: NEWS
609
doc/upgrade.rst: UPGRADE
610

    
611
doc/install-quick.rst doc/news.rst doc/upgrade.rst:
612
	set -e; \
613
	{ echo '.. This file is automatically updated at build time from $<.'; \
614
	  echo '.. Do not edit.'; \
615
	  echo; \
616
	  cat $<; \
617
	} > $@
618

    
619
# Things to build but not to install (add it to EXTRA_DIST if it should be
620
# distributed)
621
noinst_DATA = \
622
	doc/html \
623
	$(BUILT_EXAMPLES) \
624
	doc/examples/bash_completion \
625
	doc/examples/bash_completion-debug \
626
	$(manhtml)
627

    
628
gnt_scripts = \
629
	scripts/gnt-backup \
630
	scripts/gnt-cluster \
631
	scripts/gnt-debug \
632
	scripts/gnt-group \
633
	scripts/gnt-instance \
634
	scripts/gnt-job \
635
	scripts/gnt-network \
636
	scripts/gnt-node \
637
	scripts/gnt-os \
638
	scripts/gnt-storage
639

    
640
PYTHON_BOOTSTRAP_SBIN = \
641
	daemons/ganeti-masterd \
642
	daemons/ganeti-noded \
643
	daemons/ganeti-rapi \
644
	daemons/ganeti-watcher \
645
	$(gnt_scripts)
646

    
647
PYTHON_BOOTSTRAP = \
648
	$(PYTHON_BOOTSTRAP_SBIN) \
649
	tools/ensure-dirs \
650
	tools/node-cleanup \
651
	tools/node-daemon-setup \
652
	tools/prepare-node-join
653

    
654
qa_scripts = \
655
	qa/__init__.py \
656
	qa/ganeti-qa.py \
657
	qa/qa_cluster.py \
658
	qa/qa_config.py \
659
	qa/qa_daemon.py \
660
	qa/qa_env.py \
661
	qa/qa_error.py \
662
	qa/qa_group.py \
663
	qa/qa_instance.py \
664
	qa/qa_job.py \
665
	qa/qa_node.py \
666
	qa/qa_os.py \
667
	qa/qa_rapi.py \
668
	qa/qa_tags.py \
669
	qa/qa_utils.py
670

    
671
bin_SCRIPTS =
672
if WANT_HTOOLS
673
bin_SCRIPTS += $(HS_BIN_PROGS)
674
install-exec-hook:
675
	@mkdir_p@ $(DESTDIR)$(iallocatorsdir)
676
# FIXME: this is a hardcoded logic, instead of auto-resolving
677
	$(LN_S) -f ../../../bin/htools \
678
	  $(DESTDIR)$(iallocatorsdir)/hail
679
	for role in $(HS_BIN_ROLES); do \
680
	  $(LN_S) -f htools $(DESTDIR)$(bindir)/$$role ; \
681
	done
682
endif
683

    
684
$(HS_ALL_PROGS): %: %.hs $(HS_LIBTEST_SRCS) $(HS_BUILT_SRCS) Makefile
685
	@if [ "$(notdir $@)" = "test" ] && [ "$(HS_NODEV)" ]; then \
686
	  echo "Error: cannot run unittests without the development" \
687
	       " libraries (see devnotes.rst)" 1>&2; \
688
	  exit 1; \
689
	fi
690
	@rm -f $(notdir $@).tix
691
	$(GHC) --make \
692
	  $(HFLAGS) \
693
	  $(HS_NOCURL) $(HS_PARALLEL3) $(HS_REGEX_PCRE) \
694
	  -osuf $(notdir $@).o -hisuf $(notdir $@).hi \
695
	  $(HEXTRA) $(HEXTRA_INT) $@
696
	@touch "$@"
697

    
698
# for the test/hs/htest binary, we need to enable profiling/coverage
699
test/hs/htest: HEXTRA_INT=-fhpc -itest/hs
700

    
701
# we compile the hpc-htools binary with the program coverage
702
test/hs/hpc-htools: HEXTRA_INT=-fhpc
703

    
704
# we compile the hpc-mon-collector binary with the program coverage
705
test/hs/hpc-mon-collector: HEXTRA_INT=-fhpc
706

    
707
# test dependency
708
test/hs/offline-tests.sh: test/hs/hpc-htools test/hs/hpc-mon-collector
709

    
710
# rules for building profiling-enabled versions of the haskell
711
# programs: hs-prof does the full two-step build, whereas
712
# hs-prof-quick does only the final rebuild (hs-prof must have been
713
# run before)
714
.PHONY: hs-prof hs-prof-quick
715
hs-prof:
716
	@if [ -z "$(TARGET)" ]; then \
717
	  echo "You need to define TARGET when running this rule" 1>&2; \
718
	  exit 1; \
719
	fi
720
	$(MAKE) $(AM_MAKEFLAGS) clean
721
	$(MAKE) $(AM_MAKEFLAGS) $(TARGET) HEXTRA="-osuf o"
722
	rm -f $(HS_ALL_PROGS)
723
	$(MAKE) $(AM_MAKEFLAGS) hs-prof-quick
724

    
725
hs-prof-quick:
726
	@if [ -z "$(TARGET)" ]; then \
727
	  echo "You need to define TARGET when running this rule" 1>&2; \
728
	  exit 1; \
729
	fi
730
	$(MAKE) $(AM_MAKEFLAGS) $(TARGET) HEXTRA="-osuf prof_o -prof -auto-all"
731

    
732
dist_sbin_SCRIPTS = \
733
	tools/ganeti-listrunner
734

    
735
nodist_sbin_SCRIPTS = \
736
	$(PYTHON_BOOTSTRAP_SBIN) \
737
	daemons/ganeti-cleaner
738

    
739
if ENABLE_CONFD
740
src/ganeti-confd: src/hconfd
741
	cp -f $< $@
742

    
743
nodist_sbin_SCRIPTS += src/ganeti-confd
744
endif
745

    
746
python_scripts = \
747
	tools/burnin \
748
	tools/cfgshell \
749
	tools/cfgupgrade \
750
	tools/cfgupgrade12 \
751
	tools/cluster-merge \
752
	tools/confd-client \
753
	tools/fmtjson \
754
	tools/lvmstrap \
755
	tools/move-instance \
756
	tools/ovfconverter \
757
	tools/sanitize-config
758

    
759
dist_tools_SCRIPTS = \
760
	$(python_scripts) \
761
	tools/kvm-console-wrapper \
762
	tools/master-ip-setup \
763
	tools/xen-console-wrapper
764

    
765
nodist_tools_python_scripts = \
766
	tools/node-cleanup
767

    
768
nodist_tools_SCRIPTS = \
769
	$(nodist_tools_python_scripts) \
770
	tools/vcluster-setup
771

    
772
pkglib_python_scripts = \
773
	daemons/import-export \
774
	tools/check-cert-expired
775

    
776
nodist_pkglib_python_scripts = \
777
	tools/ensure-dirs \
778
	tools/node-daemon-setup \
779
	tools/prepare-node-join
780

    
781
myexeclib_SCRIPTS = \
782
	daemons/daemon-util \
783
	tools/kvm-ifup \
784
	$(pkglib_python_scripts) \
785
	$(HS_MYEXECLIB_PROGS)
786

    
787
nodist_myexeclib_SCRIPTS = \
788
	$(nodist_pkglib_python_scripts)
789

    
790
EXTRA_DIST = \
791
	NEWS \
792
	UPGRADE \
793
	epydoc.conf.in \
794
	pylintrc \
795
	autotools/build-bash-completion \
796
	autotools/build-rpc \
797
	autotools/check-header \
798
	autotools/check-imports \
799
	autotools/check-man-dashes \
800
	autotools/check-man-references \
801
	autotools/check-man-warnings \
802
	autotools/check-news \
803
	autotools/check-python-code \
804
	autotools/check-tar \
805
	autotools/check-version \
806
	autotools/convert-constants \
807
	autotools/docpp \
808
	autotools/gen-py-coverage \
809
	autotools/testrunner \
810
	autotools/wrong-hardcoded-paths \
811
	$(RUN_IN_TEMPDIR) \
812
	daemons/daemon-util.in \
813
	daemons/ganeti-cleaner.in \
814
	$(pkglib_python_scripts) \
815
	devel/upload \
816
	devel/webserver \
817
	tools/kvm-ifup.in \
818
	tools/vcluster-setup.in \
819
	$(docinput) \
820
	doc/html \
821
	$(BUILT_EXAMPLES:%=%.in) \
822
	doc/examples/ganeti.default \
823
	doc/examples/ganeti.default-debug \
824
	doc/examples/hooks/ethers \
825
	doc/examples/gnt-debug/README \
826
	doc/examples/gnt-debug/delay0.json \
827
	doc/examples/gnt-debug/delay50.json \
828
	test/py/lockperf.py \
829
	test/py/testutils.py \
830
	test/py/mocks.py \
831
	$(dist_TESTS) \
832
	$(TEST_FILES) \
833
	man/footer.rst \
834
	$(manrst) \
835
	$(maninput) \
836
	qa/qa-sample.json \
837
	$(qa_scripts) \
838
	$(HS_LIBTEST_SRCS) $(HS_BUILT_SRCS_IN) \
839
	$(HS_PROG_SRCS) \
840
	src/lint-hints.hs \
841
	test/hs/cli-tests-defs.sh \
842
	test/hs/offline-test.sh \
843
	.ghci
844

    
845
man_MANS = \
846
	man/ganeti-cleaner.8 \
847
	man/ganeti-confd.8 \
848
	man/ganeti-listrunner.8 \
849
	man/ganeti-masterd.8 \
850
	man/ganeti-noded.8 \
851
	man/ganeti-os-interface.7 \
852
	man/ganeti-extstorage-interface.7 \
853
	man/ganeti-rapi.8 \
854
	man/ganeti-watcher.8 \
855
	man/ganeti.7 \
856
	man/gnt-backup.8 \
857
	man/gnt-cluster.8 \
858
	man/gnt-debug.8 \
859
	man/gnt-group.8 \
860
	man/gnt-network.8 \
861
	man/gnt-instance.8 \
862
	man/gnt-job.8 \
863
	man/gnt-node.8 \
864
	man/gnt-os.8 \
865
	man/gnt-storage.8 \
866
	man/hail.1 \
867
	man/hbal.1 \
868
	man/hcheck.1 \
869
	man/hinfo.1 \
870
	man/hscan.1 \
871
	man/hspace.1 \
872
	man/hroller.1 \
873
	man/htools.1 \
874
	man/mon-collector.7
875

    
876
manrst = $(patsubst %.1,%.rst,$(patsubst %.7,%.rst,$(patsubst %.8,%.rst,$(man_MANS))))
877
manhtml = $(patsubst %.rst,%.html,$(manrst))
878
mangen = $(patsubst %.rst,%.gen,$(manrst))
879
maninput = \
880
	$(patsubst %.1,%.1.in,$(patsubst %.7,%.7.in,$(patsubst %.8,%.8.in,$(man_MANS)))) \
881
	$(patsubst %.html,%.html.in,$(manhtml)) \
882
	$(mangen)
883

    
884
TEST_FILES = \
885
	test/data/htools/clean-nonzero-score.data \
886
	test/data/htools/common-suffix.data \
887
	test/data/htools/empty-cluster.data \
888
	test/data/htools/hail-alloc-drbd.json \
889
	test/data/htools/hail-change-group.json \
890
	test/data/htools/hail-invalid-reloc.json \
891
	test/data/htools/hail-node-evac.json \
892
	test/data/htools/hail-reloc-drbd.json \
893
	test/data/htools/hbal-excl-tags.data \
894
	test/data/htools/hbal-split-insts.data \
895
	test/data/htools/invalid-node.data \
896
	test/data/htools/missing-resources.data \
897
	test/data/htools/n1-failure.data \
898
	test/data/htools/rapi/groups.json \
899
	test/data/htools/rapi/info.json \
900
	test/data/htools/rapi/instances.json \
901
	test/data/htools/rapi/nodes.json \
902
	test/hs/shelltests/htools-balancing.test \
903
	test/hs/shelltests/htools-basic.test \
904
	test/hs/shelltests/htools-dynutil.test \
905
	test/hs/shelltests/htools-excl.test \
906
	test/hs/shelltests/htools-hail.test \
907
	test/hs/shelltests/htools-hspace.test \
908
	test/hs/shelltests/htools-invalid.test \
909
	test/hs/shelltests/htools-multi-group.test \
910
	test/hs/shelltests/htools-no-backend.test \
911
	test/hs/shelltests/htools-rapi.test \
912
	test/hs/shelltests/htools-single-group.test \
913
	test/hs/shelltests/htools-text-backend.test \
914
	test/hs/shelltests/htools-mon-collector.test \
915
	test/data/bdev-drbd-8.0.txt \
916
	test/data/bdev-drbd-8.3.txt \
917
	test/data/bdev-drbd-disk.txt \
918
	test/data/bdev-drbd-net-ip4.txt \
919
	test/data/bdev-drbd-net-ip6.txt \
920
	test/data/cert1.pem \
921
	test/data/cert2.pem \
922
	test/data/instance-minor-pairing.txt \
923
	test/data/ip-addr-show-dummy0.txt \
924
	test/data/ip-addr-show-lo-ipv4.txt \
925
	test/data/ip-addr-show-lo-ipv6.txt \
926
	test/data/ip-addr-show-lo-oneline-ipv4.txt \
927
	test/data/ip-addr-show-lo-oneline-ipv6.txt \
928
	test/data/ip-addr-show-lo-oneline.txt \
929
	test/data/ip-addr-show-lo.txt \
930
	test/data/kvm_0.12.5_help.txt \
931
	test/data/kvm_0.15.90_help.txt \
932
	test/data/kvm_0.9.1_help.txt \
933
	test/data/kvm_0.9.1_help_boot_test.txt \
934
	test/data/kvm_1.0_help.txt \
935
	test/data/kvm_1.1.2_help.txt \
936
	test/data/ovfdata/compr_disk.vmdk.gz \
937
	test/data/ovfdata/config.ini \
938
	test/data/ovfdata/corrupted_resources.ovf \
939
	test/data/ovfdata/empty.ini \
940
	test/data/ovfdata/empty.ovf \
941
	test/data/ovfdata/ganeti.mf \
942
	test/data/ovfdata/ganeti.ovf \
943
	test/data/ovfdata/gzip_disk.ovf \
944
	test/data/ovfdata/new_disk.vmdk \
945
	test/data/ovfdata/no_disk.ini \
946
	test/data/ovfdata/no_disk_in_ref.ovf \
947
	test/data/ovfdata/no_os.ini \
948
	test/data/ovfdata/no_ovf.ova \
949
	test/data/ovfdata/other/rawdisk.raw \
950
	test/data/ovfdata/ova.ova \
951
	test/data/ovfdata/rawdisk.raw \
952
	test/data/ovfdata/second_disk.vmdk \
953
	test/data/ovfdata/unsafe_path.ini \
954
	test/data/ovfdata/virtualbox.ovf \
955
	test/data/ovfdata/wrong_config.ini \
956
	test/data/ovfdata/wrong_extension.ovd \
957
	test/data/ovfdata/wrong_manifest.mf \
958
	test/data/ovfdata/wrong_manifest.ovf \
959
	test/data/ovfdata/wrong_ova.ova \
960
	test/data/ovfdata/wrong_xml.ovf \
961
	test/data/proc_drbd8.txt \
962
	test/data/proc_drbd80-emptyline.txt \
963
	test/data/proc_drbd83.txt \
964
	test/data/proc_drbd83_sync.txt \
965
	test/data/proc_drbd83_sync_want.txt \
966
	test/data/proc_drbd83_sync_krnl2.6.39.txt \
967
	test/data/sys_drbd_usermode_helper.txt \
968
	test/data/vgreduce-removemissing-2.02.02.txt \
969
	test/data/vgreduce-removemissing-2.02.66-fail.txt \
970
	test/data/vgreduce-removemissing-2.02.66-ok.txt \
971
	test/data/vgs-missing-pvs-2.02.02.txt \
972
	test/data/vgs-missing-pvs-2.02.66.txt \
973
	test/py/ganeti-cli.test \
974
	test/py/gnt-cli.test \
975
	test/py/import-export_unittest-helper
976

    
977
python_tests = \
978
	doc/examples/rapi_testutils.py \
979
	test/py/cfgupgrade_unittest.py \
980
	test/py/docs_unittest.py \
981
	test/py/ganeti.asyncnotifier_unittest.py \
982
	test/py/ganeti.backend_unittest-runasroot.py \
983
	test/py/ganeti.backend_unittest.py \
984
	test/py/ganeti.bdev_unittest.py \
985
	test/py/ganeti.cli_unittest.py \
986
	test/py/ganeti.client.gnt_cluster_unittest.py \
987
	test/py/ganeti.client.gnt_instance_unittest.py \
988
	test/py/ganeti.client.gnt_job_unittest.py \
989
	test/py/ganeti.cmdlib_unittest.py \
990
	test/py/ganeti.compat_unittest.py \
991
	test/py/ganeti.confd.client_unittest.py \
992
	test/py/ganeti.config_unittest.py \
993
	test/py/ganeti.constants_unittest.py \
994
	test/py/ganeti.daemon_unittest.py \
995
	test/py/ganeti.errors_unittest.py \
996
	test/py/ganeti.hooks_unittest.py \
997
	test/py/ganeti.ht_unittest.py \
998
	test/py/ganeti.http_unittest.py \
999
	test/py/ganeti.hypervisor.hv_chroot_unittest.py \
1000
	test/py/ganeti.hypervisor.hv_fake_unittest.py \
1001
	test/py/ganeti.hypervisor.hv_kvm_unittest.py \
1002
	test/py/ganeti.hypervisor.hv_lxc_unittest.py \
1003
	test/py/ganeti.hypervisor.hv_xen_unittest.py \
1004
	test/py/ganeti.hypervisor_unittest.py \
1005
	test/py/ganeti.impexpd_unittest.py \
1006
	test/py/ganeti.jqueue_unittest.py \
1007
	test/py/ganeti.jstore_unittest.py \
1008
	test/py/ganeti.locking_unittest.py \
1009
	test/py/ganeti.luxi_unittest.py \
1010
	test/py/ganeti.masterd.iallocator_unittest.py \
1011
	test/py/ganeti.masterd.instance_unittest.py \
1012
	test/py/ganeti.mcpu_unittest.py \
1013
	test/py/ganeti.netutils_unittest.py \
1014
	test/py/ganeti.objects_unittest.py \
1015
	test/py/ganeti.objectutils_unittest.py \
1016
	test/py/ganeti.opcodes_unittest.py \
1017
	test/py/ganeti.ovf_unittest.py \
1018
	test/py/ganeti.qlang_unittest.py \
1019
	test/py/ganeti.query_unittest.py \
1020
	test/py/ganeti.rapi.baserlib_unittest.py \
1021
	test/py/ganeti.rapi.client_unittest.py \
1022
	test/py/ganeti.rapi.resources_unittest.py \
1023
	test/py/ganeti.rapi.rlib2_unittest.py \
1024
	test/py/ganeti.rapi.testutils_unittest.py \
1025
	test/py/ganeti.rpc_unittest.py \
1026
	test/py/ganeti.runtime_unittest.py \
1027
	test/py/ganeti.serializer_unittest.py \
1028
	test/py/ganeti.server.rapi_unittest.py \
1029
	test/py/ganeti.ssconf_unittest.py \
1030
	test/py/ganeti.ssh_unittest.py \
1031
	test/py/ganeti.storage_unittest.py \
1032
	test/py/ganeti.tools.ensure_dirs_unittest.py \
1033
	test/py/ganeti.tools.node_daemon_setup_unittest.py \
1034
	test/py/ganeti.tools.prepare_node_join_unittest.py \
1035
	test/py/ganeti.uidpool_unittest.py \
1036
	test/py/ganeti.utils.algo_unittest.py \
1037
	test/py/ganeti.utils.filelock_unittest.py \
1038
	test/py/ganeti.utils.hash_unittest.py \
1039
	test/py/ganeti.utils.io_unittest-runasroot.py \
1040
	test/py/ganeti.utils.io_unittest.py \
1041
	test/py/ganeti.utils.log_unittest.py \
1042
	test/py/ganeti.utils.lvm_unittest.py \
1043
	test/py/ganeti.utils.mlock_unittest.py \
1044
	test/py/ganeti.utils.nodesetup_unittest.py \
1045
	test/py/ganeti.utils.process_unittest.py \
1046
	test/py/ganeti.utils.retry_unittest.py \
1047
	test/py/ganeti.utils.text_unittest.py \
1048
	test/py/ganeti.utils.wrapper_unittest.py \
1049
	test/py/ganeti.utils.x509_unittest.py \
1050
	test/py/ganeti.utils_unittest.py \
1051
	test/py/ganeti.vcluster_unittest.py \
1052
	test/py/ganeti.workerpool_unittest.py \
1053
	test/py/pycurl_reset_unittest.py \
1054
	test/py/qa.qa_config_unittest.py \
1055
	test/py/tempfile_fork_unittest.py
1056

    
1057
haskell_tests = test/hs/htest
1058

    
1059
dist_TESTS = \
1060
	test/py/check-cert-expired_unittest.bash \
1061
	test/py/daemon-util_unittest.bash \
1062
	test/py/ganeti-cleaner_unittest.bash \
1063
	test/py/import-export_unittest.bash \
1064
	test/py/cli-test.bash \
1065
	test/py/bash_completion.bash \
1066
	$(python_tests)
1067

    
1068
nodist_TESTS =
1069
check_SCRIPTS =
1070

    
1071
if WANT_HSTESTS
1072
nodist_TESTS += $(haskell_tests)
1073
dist_TESTS += test/hs/offline-test.sh
1074
check_SCRIPTS += \
1075
	test/hs/hpc-htools \
1076
	test/hs/hpc-mon-collector \
1077
	$(HS_BUILT_TEST_HELPERS)
1078
endif
1079

    
1080
TESTS = $(dist_TESTS) $(nodist_TESTS)
1081

    
1082
# Environment for all tests
1083
PLAIN_TESTS_ENVIRONMENT = \
1084
	PYTHONPATH=. \
1085
	TOP_SRCDIR=$(abs_top_srcdir) TOP_BUILDDIR=$(abs_top_builddir) \
1086
	PYTHON=$(PYTHON) FAKEROOT=$(FAKEROOT_PATH) \
1087
	$(RUN_IN_TEMPDIR)
1088

    
1089
# Environment for tests run by automake
1090
TESTS_ENVIRONMENT = \
1091
	$(PLAIN_TESTS_ENVIRONMENT) $(abs_top_srcdir)/autotools/testrunner
1092

    
1093
all_python_code = \
1094
	$(dist_sbin_SCRIPTS) \
1095
	$(python_scripts) \
1096
	$(pkglib_python_scripts) \
1097
	$(nodist_pkglib_python_scripts) \
1098
	$(nodist_tools_python_scripts) \
1099
	$(python_tests) \
1100
	$(pkgpython_PYTHON) \
1101
	$(client_PYTHON) \
1102
	$(hypervisor_PYTHON) \
1103
	$(rapi_PYTHON) \
1104
	$(server_PYTHON) \
1105
	$(pytools_PYTHON) \
1106
	$(http_PYTHON) \
1107
	$(confd_PYTHON) \
1108
	$(masterd_PYTHON) \
1109
	$(impexpd_PYTHON) \
1110
	$(utils_PYTHON) \
1111
	$(watcher_PYTHON) \
1112
	$(noinst_PYTHON) \
1113
	$(qa_scripts)
1114

    
1115
srclink_files = \
1116
	man/footer.rst \
1117
	test/py/check-cert-expired_unittest.bash \
1118
	test/py/daemon-util_unittest.bash \
1119
	test/py/ganeti-cleaner_unittest.bash \
1120
	test/py/import-export_unittest.bash \
1121
	test/py/cli-test.bash \
1122
	test/py/bash_completion.bash \
1123
	test/hs/offline-test.sh \
1124
	test/hs/cli-tests-defs.sh \
1125
	$(all_python_code) \
1126
	$(HS_LIBTEST_SRCS) $(HS_PROG_SRCS) \
1127
	$(docinput)
1128

    
1129
check_python_code = \
1130
	$(BUILD_BASH_COMPLETION) \
1131
	$(CHECK_IMPORTS) \
1132
	$(CHECK_HEADER) \
1133
	$(DOCPP) \
1134
	$(all_python_code)
1135

    
1136
lint_python_code = \
1137
	ganeti \
1138
	ganeti/http/server.py \
1139
	$(dist_sbin_SCRIPTS) \
1140
	$(python_scripts) \
1141
	$(pkglib_python_scripts) \
1142
	$(BUILD_BASH_COMPLETION) \
1143
	$(CHECK_IMPORTS) \
1144
	$(CHECK_HEADER) \
1145
	$(DOCPP) \
1146
	$(PYTHON_BOOTSTRAP)
1147

    
1148
standalone_python_modules = \
1149
	lib/rapi/client.py \
1150
	tools/ganeti-listrunner
1151

    
1152
pep8_python_code = \
1153
	ganeti \
1154
	ganeti/http/server.py \
1155
	$(dist_sbin_SCRIPTS) \
1156
	$(python_scripts) \
1157
	$(pkglib_python_scripts) \
1158
	$(BUILD_BASH_COMPLETION) \
1159
	$(CHECK_HEADER) \
1160
	$(DOCPP) \
1161
	$(PYTHON_BOOTSTRAP) \
1162
	qa
1163

    
1164
test/py/daemon-util_unittest.bash: daemons/daemon-util
1165

    
1166
test/py/ganeti-cleaner_unittest.bash: daemons/ganeti-cleaner
1167

    
1168
test/py/bash_completion.bash: doc/examples/bash_completion-debug
1169

    
1170
tools/kvm-ifup: tools/kvm-ifup.in $(REPLACE_VARS_SED)
1171
	sed -f $(REPLACE_VARS_SED) < $< > $@
1172
	chmod +x $@
1173

    
1174
tools/vcluster-setup: tools/vcluster-setup.in $(REPLACE_VARS_SED)
1175
	sed -f $(REPLACE_VARS_SED) < $< > $@
1176
	chmod +x $@
1177

    
1178
daemons/%:: daemons/%.in $(REPLACE_VARS_SED)
1179
	sed -f $(REPLACE_VARS_SED) < $< > $@
1180
	chmod +x $@
1181

    
1182
doc/examples/%:: doc/examples/%.in $(REPLACE_VARS_SED)
1183
	sed -f $(REPLACE_VARS_SED) < $< > $@
1184

    
1185
doc/examples/bash_completion: BC_ARGS = --compact
1186
doc/examples/bash_completion-debug: BC_ARGS =
1187

    
1188
doc/examples/bash_completion doc/examples/bash_completion-debug: \
1189
	$(BUILD_BASH_COMPLETION) $(RUN_IN_TEMPDIR) \
1190
	lib/cli.py $(gnt_scripts) $(client_PYTHON) tools/burnin \
1191
	daemons/ganeti-cleaner \
1192
	$(GENERATED_FILES) $(HS_GENERATED_FILES)
1193
	PYTHONPATH=. $(RUN_IN_TEMPDIR) \
1194
	  $(CURDIR)/$(BUILD_BASH_COMPLETION) $(BC_ARGS) > $@
1195

    
1196
man/%.gen: man/%.rst lib/query.py lib/build/sphinx_ext.py \
1197
	lib/build/shell_example_lexer.py \
1198
	| $(RUN_IN_TEMPDIR) $(BUILT_PYTHON_SOURCES)
1199
	@echo "Checking $< for hardcoded paths..."
1200
	@if grep -nEf autotools/wrong-hardcoded-paths $<; then \
1201
	  echo "Man page $< has hardcoded paths (see above)!" 1>&2 ; \
1202
	  exit 1; \
1203
	fi
1204
	set -e ; \
1205
	trap 'echo auto-removing $@; rm $@' EXIT; \
1206
	PYTHONPATH=. $(RUN_IN_TEMPDIR) $(CURDIR)/$(DOCPP) < $< > $@ ;\
1207
	$(CHECK_MAN_REFERENCES) $@; \
1208
	trap - EXIT
1209

    
1210
man/%.7.in man/%.8.in man/%.1.in: man/%.gen man/footer.rst
1211
	@test -n "$(PANDOC)" || \
1212
	  { echo 'pandoc' not found during configure; exit 1; }
1213
	set -o pipefail ; \
1214
	trap 'echo auto-removing $@; rm $@' EXIT; \
1215
	$(PANDOC) -s -f rst -t man $< man/footer.rst | \
1216
	  sed -e 's/\\@/@/g' > $@; \
1217
	if test -n "$(MAN_HAS_WARNINGS)"; then $(CHECK_MAN_WARNINGS) $@; fi; \
1218
	$(CHECK_MAN_DASHES) $@; \
1219
	trap - EXIT
1220

    
1221
man/%.html.in: man/%.gen man/footer.rst
1222
	@test -n "$(PANDOC)" || \
1223
	  { echo 'pandoc' not found during configure; exit 1; }
1224
	set -o pipefail ; \
1225
	$(PANDOC) --toc -s -f rst -t html $< man/footer.rst | \
1226
	  sed -e 's/\\@/@/g' > $@
1227

    
1228
man/%: man/%.in  $(REPLACE_VARS_SED)
1229
	sed -f $(REPLACE_VARS_SED) < $< > $@
1230

    
1231
epydoc.conf: epydoc.conf.in $(REPLACE_VARS_SED)
1232
	sed -f $(REPLACE_VARS_SED) < $< > $@
1233

    
1234
vcs-version:
1235
	if test -d .git; then \
1236
	  git describe > $@; \
1237
	elif test ! -f $@ ; then \
1238
	  echo "Cannot auto-generate $@ file"; exit 1; \
1239
	fi
1240

    
1241
.PHONY: clean-vcs-version
1242
clean-vcs-version:
1243
	rm -f vcs-version
1244

    
1245
.PHONY: regen-vcs-version
1246
regen-vcs-version:
1247
	@set -e; \
1248
	cd $(srcdir); \
1249
	if test -d .git; then \
1250
	  T=`mktemp` ; trap 'rm -f $$T' EXIT; \
1251
	  git describe > $$T; \
1252
	  if ! cmp --quiet $$T vcs-version; then \
1253
	    mv $$T vcs-version; \
1254
	  fi; \
1255
	fi
1256

    
1257
src/Ganeti/Version.hs: src/Ganeti/Version.hs.in \
1258
	vcs-version $(built_base_sources)
1259
	set -e; \
1260
	VCSVER=`cat $(abs_top_srcdir)/vcs-version`; \
1261
	sed -e "s/%ver%/$$VCSVER/" < $< > $@
1262

    
1263
src/Ganeti/Constants.hs: src/Ganeti/Constants.hs.in \
1264
	lib/constants.py lib/_autoconf.py lib/luxi.py lib/errors.py \
1265
	lib/jstore.py $(RUN_IN_TEMPDIR) \
1266
	$(CONVERT_CONSTANTS) $(built_base_sources) \
1267
	| lib/_vcsversion.py
1268
	set -e; \
1269
	{ cat $< ; \
1270
	  PYTHONPATH=. $(RUN_IN_TEMPDIR) $(CURDIR)/$(CONVERT_CONSTANTS); \
1271
	} > $@
1272

    
1273
test/hs/Test/Ganeti/TestImports.hs: test/hs/Test/Ganeti/TestImports.hs.in \
1274
	$(built_base_sources)
1275
	set -e; \
1276
	{ cat $< ; \
1277
	  echo ; \
1278
	  for name in $(filter-out Ganeti.THH,$(subst /,.,$(patsubst %.hs,%,$(patsubst src/%,%,$(HS_LIB_SRCS))))) ; do \
1279
	    echo "import $$name ()" ; \
1280
	  done ; \
1281
	} > $@
1282

    
1283
lib/_autoconf.py: Makefile | stamp-directories
1284
	set -e; \
1285
	{ echo '# This file is automatically generated, do not edit!'; \
1286
	  echo '#'; \
1287
	  echo ''; \
1288
	  echo '"""Build-time configuration for Ganeti.'; \
1289
	  echo '';\
1290
	  echo 'This file is autogenerated by the build process.'; \
1291
	  echo 'For any changes you need to re-run ./configure (and'; \
1292
	  echo 'not edit by hand).'; \
1293
	  echo ''; \
1294
	  echo '"""'; \
1295
	  echo ''; \
1296
	  echo '# pylint: disable=C0301,C0324'; \
1297
	  echo '# because this is autogenerated, we do not want'; \
1298
	  echo '# style warnings' ; \
1299
	  echo ''; \
1300
	  echo "PACKAGE_VERSION = '$(PACKAGE_VERSION)'"; \
1301
	  echo "VERSION_MAJOR = '$(VERSION_MAJOR)'"; \
1302
	  echo "VERSION_MINOR = '$(VERSION_MINOR)'"; \
1303
	  echo "VERSION_REVISION = '$(VERSION_REVISION)'"; \
1304
	  echo "VERSION_SUFFIX = '$(VERSION_SUFFIX)'"; \
1305
	  echo "VERSION_FULL = '$(VERSION_FULL)'"; \
1306
	  echo "LOCALSTATEDIR = '$(localstatedir)'"; \
1307
	  echo "SYSCONFDIR = '$(sysconfdir)'"; \
1308
	  echo "SSH_CONFIG_DIR = '$(SSH_CONFIG_DIR)'"; \
1309
	  echo "SSH_LOGIN_USER = '$(SSH_LOGIN_USER)'"; \
1310
	  echo "SSH_CONSOLE_USER = '$(SSH_CONSOLE_USER)'"; \
1311
	  echo "EXPORT_DIR = '$(EXPORT_DIR)'"; \
1312
	  echo "OS_SEARCH_PATH = [$(OS_SEARCH_PATH)]"; \
1313
	  echo "ES_SEARCH_PATH = [$(ES_SEARCH_PATH)]"; \
1314
	  echo "XEN_BOOTLOADER = '$(XEN_BOOTLOADER)'"; \
1315
	  echo "XEN_KERNEL = '$(XEN_KERNEL)'"; \
1316
	  echo "XEN_INITRD = '$(XEN_INITRD)'"; \
1317
	  echo "KVM_KERNEL = '$(KVM_KERNEL)'"; \
1318
	  echo "FILE_STORAGE_DIR = '$(FILE_STORAGE_DIR)'"; \
1319
	  echo "ENABLE_FILE_STORAGE = $(ENABLE_FILE_STORAGE)"; \
1320
	  echo "SHARED_FILE_STORAGE_DIR = '$(SHARED_FILE_STORAGE_DIR)'"; \
1321
	  echo "ENABLE_SHARED_FILE_STORAGE = $(ENABLE_SHARED_FILE_STORAGE)"; \
1322
	  echo "IALLOCATOR_SEARCH_PATH = [$(IALLOCATOR_SEARCH_PATH)]"; \
1323
	  echo "KVM_PATH = '$(KVM_PATH)'"; \
1324
	  echo "IP_PATH = '$(IP_PATH)'"; \
1325
	  echo "SOCAT_PATH = '$(SOCAT)'"; \
1326
	  echo "SOCAT_USE_ESCAPE = $(SOCAT_USE_ESCAPE)"; \
1327
	  echo "SOCAT_USE_COMPRESS = $(SOCAT_USE_COMPRESS)"; \
1328
	  echo "LVM_STRIPECOUNT = $(LVM_STRIPECOUNT)"; \
1329
	  echo "TOOLSDIR = '$(toolsdir)'"; \
1330
	  echo "GNT_SCRIPTS = [$(foreach i,$(notdir $(gnt_scripts)),'$(i)',)]"; \
1331
	  echo "HTOOLS_PROGS = [$(foreach i,$(HS_HTOOLS_PROGS),'$(i)',)]"; \
1332
	  echo "PKGLIBDIR = '$(pkglibdir)'"; \
1333
	  echo "DRBD_BARRIERS = '$(DRBD_BARRIERS)'"; \
1334
	  echo "DRBD_NO_META_FLUSH = $(DRBD_NO_META_FLUSH)"; \
1335
	  echo "SYSLOG_USAGE = '$(SYSLOG_USAGE)'"; \
1336
	  echo "DAEMONS_GROUP = '$(DAEMONS_GROUP)'"; \
1337
	  echo "ADMIN_GROUP = '$(ADMIN_GROUP)'"; \
1338
	  echo "MASTERD_USER = '$(MASTERD_USER)'"; \
1339
	  echo "MASTERD_GROUP = '$(MASTERD_GROUP)'"; \
1340
	  echo "RAPI_USER = '$(RAPI_USER)'"; \
1341
	  echo "RAPI_GROUP = '$(RAPI_GROUP)'"; \
1342
	  echo "CONFD_USER = '$(CONFD_USER)'"; \
1343
	  echo "CONFD_GROUP = '$(CONFD_GROUP)'"; \
1344
	  echo "NODED_USER = '$(NODED_USER)'"; \
1345
	  echo "NODED_GROUP = '$(NODED_GROUP)'"; \
1346
	  echo "DISK_SEPARATOR = '$(DISK_SEPARATOR)'"; \
1347
	  echo "QEMUIMG_PATH = '$(QEMUIMG_PATH)'"; \
1348
	  echo "HTOOLS = True"; \
1349
	  echo "ENABLE_CONFD = $(ENABLE_CONFD)"; \
1350
	  echo "XEN_CMD = '$(XEN_CMD)'"; \
1351
	  echo "ENABLE_SPLIT_QUERY = $(ENABLE_SPLIT_QUERY)"; \
1352
	  echo "ENABLE_RESTRICTED_COMMANDS = $(ENABLE_RESTRICTED_COMMANDS)"; \
1353
	  echo "ENABLE_MONITORING = $(ENABLE_MONITORING)"; \
1354
	} > $@
1355

    
1356
lib/_vcsversion.py: Makefile vcs-version | stamp-directories
1357
	set -e; \
1358
	VCSVER=`cat $(abs_top_srcdir)/vcs-version`; \
1359
	{ echo '# This file is automatically generated, do not edit!'; \
1360
	  echo '#'; \
1361
	  echo ''; \
1362
	  echo '"""Build-time VCS version number for Ganeti.'; \
1363
	  echo '';\
1364
	  echo 'This file is autogenerated by the build process.'; \
1365
	  echo 'For any changes you need to re-run ./configure (and'; \
1366
	  echo 'not edit by hand).'; \
1367
	  echo ''; \
1368
	  echo '"""'; \
1369
	  echo ''; \
1370
	  echo '# pylint: disable=C0301,C0324'; \
1371
	  echo '# because this is autogenerated, we do not want'; \
1372
	  echo '# style warnings' ; \
1373
	  echo ''; \
1374
	  echo "VCS_VERSION = '$$VCSVER'"; \
1375
	} > $@
1376

    
1377
lib/_generated_rpc.py: lib/rpc_defs.py $(BUILD_RPC)
1378
	PYTHONPATH=. $(RUN_IN_TEMPDIR) $(CURDIR)/$(BUILD_RPC) lib/rpc_defs.py > $@
1379

    
1380
$(SHELL_ENV_INIT): Makefile stamp-directories
1381
	set -e; \
1382
	{ echo '# Allow overriding for tests'; \
1383
	  echo 'readonly LOCALSTATEDIR=$${LOCALSTATEDIR:-$${GANETI_ROOTDIR:-}$(localstatedir)}'; \
1384
	  echo 'readonly SYSCONFDIR=$${SYSCONFDIR:-$${GANETI_ROOTDIR:-}$(sysconfdir)}'; \
1385
	  echo; \
1386
	  echo 'readonly PKGLIBDIR=$(pkglibdir)'; \
1387
	  echo 'readonly LOG_DIR="$$LOCALSTATEDIR/log/ganeti"'; \
1388
	  echo 'readonly RUN_DIR="$$LOCALSTATEDIR/run/ganeti"'; \
1389
	  echo 'readonly DATA_DIR="$$LOCALSTATEDIR/lib/ganeti"'; \
1390
	  echo 'readonly CONF_DIR="$$SYSCONFDIR/ganeti"'; \
1391
	} > $@
1392

    
1393
$(REPLACE_VARS_SED): $(SHELL_ENV_INIT) Makefile stamp-directories
1394
	set -e; \
1395
	{ echo 's#@PREFIX@#$(prefix)#g'; \
1396
	  echo 's#@SYSCONFDIR@#$(sysconfdir)#g'; \
1397
	  echo 's#@LOCALSTATEDIR@#$(localstatedir)#g'; \
1398
	  echo 's#@BINDIR@#$(bindir)#g'; \
1399
	  echo 's#@SBINDIR@#$(sbindir)#g'; \
1400
	  echo 's#@LIBDIR@#$(libdir)#g'; \
1401
	  echo 's#@GANETI_VERSION@#$(PACKAGE_VERSION)#g'; \
1402
	  echo 's#@CUSTOM_XEN_BOOTLOADER@#$(XEN_BOOTLOADER)#g'; \
1403
	  echo 's#@CUSTOM_XEN_KERNEL@#$(XEN_KERNEL)#g'; \
1404
	  echo 's#@CUSTOM_XEN_INITRD@#$(XEN_INITRD)#g'; \
1405
	  echo 's#@CUSTOM_IALLOCATOR_SEARCH_PATH@#$(IALLOCATOR_SEARCH_PATH)#g'; \
1406
	  echo 's#@CUSTOM_EXPORT_DIR@#$(EXPORT_DIR)#g'; \
1407
	  echo 's#@RPL_FILE_STORAGE_DIR@#$(FILE_STORAGE_DIR)#g'; \
1408
	  echo 's#@RPL_SSH_INITD_SCRIPT@#$(SSH_INITD_SCRIPT)#g'; \
1409
	  echo 's#@PKGLIBDIR@#$(pkglibdir)#g'; \
1410
	  echo 's#@GNTMASTERUSER@#$(MASTERD_USER)#g'; \
1411
	  echo 's#@GNTRAPIUSER@#$(RAPI_USER)#g'; \
1412
	  echo 's#@GNTCONFDUSER@#$(CONFD_USER)#g'; \
1413
	  echo 's#@GNTNODEDUSER@#$(NODED_USER)#g'; \
1414
	  echo 's#@GNTRAPIGROUP@#$(RAPI_GROUP)#g'; \
1415
	  echo 's#@GNTADMINGROUP@#$(ADMIN_GROUP)#g'; \
1416
	  echo 's#@GNTCONFDGROUP@#$(CONFD_GROUP)#g'; \
1417
	  echo 's#@GNTMASTERDGROUP@#$(MASTERD_GROUP)#g'; \
1418
	  echo 's#@GNTDAEMONSGROUP@#$(DAEMONS_GROUP)#g'; \
1419
	  echo 's#@CUSTOM_ENABLE_CONFD@#$(ENABLE_CONFD)#g'; \
1420
	  echo 's#@MODULES@#$(strip $(lint_python_code))#g'; \
1421
	  echo 's#@ENABLE_SPLIT_QUERY@#$(ENABLE_SPLIT_QUERY)#g'; \
1422
	  echo; \
1423
	  echo '/^@SHELL_ENV_INIT@$$/ {'; \
1424
	  echo '  r $(SHELL_ENV_INIT)'; \
1425
	  echo '  d'; \
1426
	  echo '}'; \
1427
	} > $@
1428

    
1429
# Using deferred evaluation
1430
daemons/ganeti-%: MODULE = ganeti.server.$(patsubst ganeti-%,%,$(notdir $@))
1431
daemons/ganeti-watcher: MODULE = ganeti.watcher
1432
scripts/%: MODULE = ganeti.client.$(subst -,_,$(notdir $@))
1433
tools/ensure-dirs: MODULE = ganeti.tools.ensure_dirs
1434
tools/node-daemon-setup: MODULE = ganeti.tools.node_daemon_setup
1435
tools/prepare-node-join: MODULE = ganeti.tools.prepare_node_join
1436
tools/node-cleanup: MODULE = ganeti.tools.node_cleanup
1437
$(HS_BUILT_TEST_HELPERS): TESTROLE = $(patsubst test/hs/%,%,$@)
1438

    
1439
$(PYTHON_BOOTSTRAP): Makefile | stamp-directories
1440
	test -n "$(MODULE)" || { echo Missing module; exit 1; }
1441
	set -e; \
1442
	{ echo '#!/usr/bin/python'; \
1443
	  echo '# This file is automatically generated, do not edit!'; \
1444
	  echo "# Edit $(MODULE) instead."; \
1445
	  echo; \
1446
	  echo '"""Bootstrap script for L{$(MODULE)}"""'; \
1447
	  echo; \
1448
	  echo '# pylint: disable=C0103'; \
1449
	  echo '# C0103: Invalid name'; \
1450
	  echo; \
1451
	  echo 'import sys'; \
1452
	  echo 'import $(MODULE) as main'; \
1453
	  echo; \
1454
	  echo '# Temporarily alias commands until bash completion'; \
1455
	  echo '# generator is changed'; \
1456
	  echo 'if hasattr(main, "commands"):'; \
1457
	  echo '  commands = main.commands # pylint: disable=E1101'; \
1458
	  echo 'if hasattr(main, "aliases"):'; \
1459
	  echo '  aliases = main.aliases # pylint: disable=E1101'; \
1460
	  echo; \
1461
	  echo 'if __name__ == "__main__":'; \
1462
	  echo '  sys.exit(main.Main())'; \
1463
	} > $@
1464
	chmod u+x $@
1465

    
1466
$(HS_BUILT_TEST_HELPERS): Makefile
1467
	@test -n "$(TESTROLE)" || { echo Missing TESTROLE; exit 1; }
1468
	set -e; \
1469
	{ echo '#!/bin/sh'; \
1470
	  echo '# This file is automatically generated, do not edit!'; \
1471
	  echo "# Edit Makefile.am instead."; \
1472
	  echo; \
1473
	  echo "HTOOLS=$(TESTROLE) exec ./test/hs/hpc-htools \"\$$@\""; \
1474
	} > $@
1475
	chmod u+x $@
1476

    
1477
stamp-directories: Makefile
1478
	$(MAKE) $(AM_MAKEFLAGS) ganeti
1479
	@mkdir_p@ $(DIRS) $(BUILDTIME_DIR_AUTOCREATE)
1480
	touch $@
1481

    
1482
# We need to create symlinks because "make distcheck" will not install Python
1483
# files when building.
1484
stamp-srclinks: Makefile | stamp-directories
1485
	set -e; \
1486
	for i in $(srclink_files); do \
1487
	  if test ! -f $$i -a -f $(abs_top_srcdir)/$$i; then \
1488
	    $(LN_S) $(abs_top_srcdir)/$$i $$i; \
1489
	  fi; \
1490
	done
1491
	touch $@
1492

    
1493
.PHONY: ganeti
1494
ganeti:
1495
	cd $(top_builddir) && test -h "$@" || { rm -f $@ && $(LN_S) lib $@; }
1496

    
1497
.PHONY: check-dirs
1498
check-dirs: $(GENERATED_FILES)
1499
	@set -e; \
1500
	find . -type d \( -name . -o -name .git -prune -o -print \) | { \
1501
	  error=; \
1502
	  while read dir; do \
1503
	    case "$$dir" in \
1504
	      $(strip $(patsubst %,(./%) ;;,$(DIRCHECK_EXCLUDE) $(DIRS))) \
1505
	      *) error=1; echo "Directory $$dir not listed in Makefile" >&2 ;; \
1506
	    esac; \
1507
	  done; \
1508
	  for dir in $(DIRS); do \
1509
	    if ! test -d "$$dir"; then \
1510
	      echo "Directory $$dir listed in DIRS does not exist" >&2; \
1511
	      error=1; \
1512
	    fi \
1513
	  done; \
1514
	  test -z "$$error"; \
1515
	}
1516

    
1517
.PHONY: check-local
1518
check-local: check-dirs $(GENERATED_FILES)
1519
	$(CHECK_PYTHON_CODE) $(check_python_code)
1520
	PYTHONPATH=. $(CHECK_HEADER) $(check_python_code)
1521
	$(CHECK_VERSION) $(VERSION) $(top_srcdir)/NEWS
1522
	$(CHECK_NEWS) < $(top_srcdir)/NEWS
1523
	PYTHONPATH=. $(RUN_IN_TEMPDIR) $(CURDIR)/$(CHECK_IMPORTS) . $(standalone_python_modules)
1524
	@expver=$(VERSION_MAJOR).$(VERSION_MINOR); \
1525
	error= ; \
1526
	if test "`head -n 1 $(top_srcdir)/README`" != "Ganeti $$expver"; then \
1527
	  echo "Incorrect version in README, expected $$expver" >&2; \
1528
	  error=1; \
1529
	fi; \
1530
	for file in doc/iallocator.rst doc/hooks.rst doc/virtual-cluster.rst \
1531
	    doc/security.rst; do \
1532
	  if test "`sed -ne '4 p' $(top_srcdir)/$$file`" != \
1533
	    "Documents Ganeti version $$expver"; then \
1534
	    echo "Incorrect version in $$file, expected $$expver" >&2; \
1535
	    error=1; \
1536
	  fi; \
1537
	done; \
1538
	if ! test -f $(top_srcdir)/doc/design-$$expver.rst; then \
1539
	  echo "File $(top_srcdir)/doc/design-$$expver.rst not found" >&2; \
1540
	  error=1; \
1541
	fi; \
1542
	if test "`sed -ne '5 p' $(top_srcdir)/doc/design-draft.rst`" != \
1543
	  ".. Last updated for Ganeti $$expver"; then \
1544
	  echo "doc/design-draft.rst was not updated for version $$expver" >&2; \
1545
	  error=1; \
1546
	fi; \
1547
	for file in configure.ac $(HS_LIBTEST_SRCS) $(HS_PROG_SRCS); do \
1548
	  if test $$(wc --max-line-length < $(top_srcdir)/$$file) -gt 80; then \
1549
	    echo "Longest line in $$file is longer than 80 characters" >&2; \
1550
	    error=1; \
1551
	  fi; \
1552
	done; \
1553
	test -z "$$error"
1554

    
1555
.PHONY: hs-tests
1556
hs-tests: test/hs/htest | $(BUILT_PYTHON_SOURCES)
1557
	@rm -f htest.tix
1558
	./test/hs/htest
1559

    
1560
.PHONY: hs-shell
1561
hs-shell: test/hs/hpc-htools test/hs/hpc-mon-collector $(HS_BUILT_TEST_HELPERS)
1562
	@rm -f hpc-htools.tix hpc-mon-collector.tix
1563
	HBINARY="./test/hs/hpc-htools" ./test/hs/offline-test.sh
1564

    
1565
.PHONY: hs-check
1566
hs-check: hs-tests hs-shell
1567

    
1568
# E111: indentation is not a multiple of four
1569
# E121: continuation line indentation is not a multiple of four
1570
#       (since our indent level is not 4)
1571
# E125: continuation line does not distinguish itself from next logical line
1572
#       (since our indent level is not 4)
1573
# E127: continuation line over-indented for visual indent
1574
#       (since our indent level is not 4)
1575
# note: do NOT add E128 here; it's a valid style error in most cases!
1576
# I've seen real errors, but also some cases were we indent wrongly
1577
# due to line length; try to rework the cases where it is triggered,
1578
# instead of silencing it
1579
# E261: at least two spaces before inline comment
1580
# E501: line too long (80 characters)
1581
PEP8_IGNORE = E111,E121,E125,E127,E261,E501
1582

    
1583
# For excluding pep8 expects filenames only, not whole paths
1584
PEP8_EXCLUDE = $(subst $(space),$(comma),$(strip $(notdir $(BUILT_PYTHON_SOURCES))))
1585

    
1586
LINT_TARGETS = pylint pylint-qa
1587
if HAS_PEP8
1588
LINT_TARGETS += pep8
1589
endif
1590
if HAS_HLINT
1591
LINT_TARGETS += hlint
1592
endif
1593

    
1594
.PHONY: lint
1595
lint: $(LINT_TARGETS)
1596

    
1597
.PHONY: pylint
1598
pylint: $(GENERATED_FILES)
1599
	@test -n "$(PYLINT)" || { echo 'pylint' not found during configure; exit 1; }
1600
	$(PYLINT) $(LINT_OPTS) $(lint_python_code)
1601

    
1602
.PHONY: pylint-qa
1603
pylint-qa: $(GENERATED_FILES)
1604
	@test -n "$(PYLINT)" || { echo 'pylint' not found during configure; exit 1; }
1605
	cd $(top_srcdir)/qa && \
1606
	  PYTHONPATH=$(abs_top_srcdir) $(PYLINT) $(LINT_OPTS) \
1607
	  --rcfile  ../pylintrc $(patsubst qa/%.py,%,$(qa_scripts))
1608

    
1609
.PHONY: pep8
1610
pep8: $(GENERATED_FILES)
1611
	@test -n "$(PEP8)" || { echo 'pep8' not found during configure; exit 1; }
1612
	$(PEP8) --ignore='$(PEP8_IGNORE)' --exclude='$(PEP8_EXCLUDE)' \
1613
	  --repeat $(pep8_python_code)
1614

    
1615
# FIXME: remove ignore "Use void" when GHC 6.x is deprecated
1616
HLINT_EXCLUDES = src/Ganeti/THH.hs test/hs/hpc-htools.hs
1617
.PHONY: hlint
1618
hlint: $(HS_BUILT_SRCS) src/lint-hints.hs
1619
	@test -n "$(HLINT)" || { echo 'hlint' not found during configure; exit 1; }
1620
	if tty -s; then C="-c"; else C=""; fi; \
1621
	$(HLINT) --utf8 --report=doc/hs-lint.html --cross $$C \
1622
	  --ignore "Use first" \
1623
	  --ignore "Use &&&" \
1624
	  --ignore "Use void" \
1625
	  --ignore "Reduce duplication" \
1626
	  --hint src/lint-hints \
1627
	  $(filter-out $(HLINT_EXCLUDES),$(HS_LIBTEST_SRCS) $(HS_PROG_SRCS))
1628

    
1629
# a dist hook rule for updating the vcs-version file; this is
1630
# hardcoded due to where it needs to build the file...
1631
dist-hook:
1632
	$(MAKE) $(AM_MAKEFLAGS) regen-vcs-version
1633
	rm -f $(top_distdir)/vcs-version
1634
	cp -p $(srcdir)/vcs-version $(top_distdir)
1635

    
1636
# a distcheck hook rule for catching revision control directories
1637
distcheck-hook:
1638
	if find $(top_distdir) -name .svn -or -name .git | grep .; then \
1639
	  echo "Found revision control files in final archive." 1>&2; \
1640
	  exit 1; \
1641
	fi
1642
	if find $(top_distdir) -name '*.py[co]' | grep .; then \
1643
	  echo "Found Python byte code in final archive." 1>&2; \
1644
	  exit 1; \
1645
	fi
1646
	if find $(top_distdir) -name '*~' | grep .; then \
1647
	  echo "Found backup files in final archive." 1>&2; \
1648
	  exit 1; \
1649
	fi
1650
# Empty files or directories should not be distributed. They can cause
1651
# unnecessary warnings for packagers. Directories used by automake during
1652
# distcheck must be excluded.
1653
	if find $(top_distdir) -empty -and -not \( \
1654
	    -path $(top_distdir)/_build -or \
1655
	    -path $(top_distdir)/_inst \) | grep .; then \
1656
	  echo "Found empty files or directories in final archive." 1>&2; \
1657
	  exit 1; \
1658
	fi
1659
	if test -n "$(BUILD_RELEASE)" && \
1660
	   grep -n -H -E '^\*.*unreleased' $(top_distdir)/NEWS; then \
1661
	   echo "Found unreleased version in NEWS." >&2; \
1662
	   exit 1; \
1663
	fi
1664

    
1665
# When building a release, stricter checks should be used
1666
distcheck-release dist-release: export BUILD_RELEASE = 1
1667
distcheck-release: distcheck
1668

    
1669
distrebuildcheck: dist
1670
	set -e; \
1671
	builddir=$$(mktemp -d $(abs_srcdir)/distrebuildcheck.XXXXXXX); \
1672
	trap "echo Removing $$builddir; cd $(abs_srcdir); rm -rf $$builddir" EXIT; \
1673
	cd $$builddir; \
1674
	tar xzf $(abs_srcdir)/$(distdir).tar.gz; \
1675
	cd $(distdir); \
1676
	./configure; \
1677
	$(MAKE) maintainer-clean; \
1678
	cp $(abs_srcdir)/vcs-version .; \
1679
	./configure; \
1680
	$(MAKE) $(AM_MAKEFLAGS)
1681

    
1682
dist-release: dist
1683
	set -e; \
1684
	for i in $(DIST_ARCHIVES); do \
1685
	  echo -n "Checking $$i ... "; \
1686
	  autotools/check-tar < $$i; \
1687
	  echo OK; \
1688
	done
1689

    
1690
install-exec-local:
1691
	@mkdir_p@ "$(DESTDIR)${localstatedir}/lib/ganeti" \
1692
	  "$(DESTDIR)${localstatedir}/log/ganeti" \
1693
	  "$(DESTDIR)${localstatedir}/run/ganeti"
1694

    
1695
.PHONY: apidoc
1696
if WANT_HSAPIDOC
1697
apidoc: py-apidoc hs-apidoc
1698
else
1699
apidoc: py-apidoc
1700
endif
1701

    
1702
.PHONY: py-apidoc
1703
py-apidoc: epydoc.conf $(RUN_IN_TEMPDIR) $(GENERATED_FILES)
1704
	env - PATH="$$PATH" PYTHONPATH="$$PYTHONPATH" \
1705
	$(RUN_IN_TEMPDIR) epydoc -v \
1706
	  --conf $(CURDIR)/epydoc.conf \
1707
	  --output $(CURDIR)/$(APIDOC_PY_DIR)
1708

    
1709
.PHONY: hs-apidoc
1710
hs-apidoc: $(HS_BUILT_SRCS)
1711
	@test -n "$(HSCOLOUR)" || \
1712
	    { echo 'HsColour' not found during configure; exit 1; }
1713
	@test -n "$(HADDOCK)" || \
1714
	    { echo 'haddock' not found during configure; exit 1; }
1715
	rm -rf $(APIDOC_HS_DIR)/*
1716
	for i in $(ALL_APIDOC_HS_DIRS); do \
1717
	  @mkdir_p@ $$i; \
1718
	done
1719
	$(HSCOLOUR) -print-css > $(APIDOC_HS_DIR)/Ganeti/hscolour.css
1720
	$(LN_S) ../hscolour.css $(APIDOC_HS_DIR)/Ganeti/HTools/hscolour.css
1721
	$(LN_S) ../hscolour.css $(APIDOC_HS_DIR)/Ganeti/Confd/hscolour.css
1722
	set -e ; \
1723
	cd src; \
1724
	if [ "$(HS_NOCURL)" ]; \
1725
	then OPTGHC="--optghc=$(HS_NOCURL)"; \
1726
	else OPTGHC=""; \
1727
	fi; \
1728
	if [ "$(HS_PARALLEL3)" ]; \
1729
	then OPTGHC="$$OPTGHC --optghc=$(HS_PARALLEL3)"; \
1730
	fi; \
1731
	if [ "$(HS_REGEX_PCRE)" ]; \
1732
	then OPTGHC="$$OPTGHC --optghc=$(HS_REGEX_PCRE)"; \
1733
	fi; \
1734
	RELSRCS="$(HS_LIB_SRCS:src/%=%) $(patsubst src/%,%,$(filter src/%,$(HS_BUILT_SRCS)))"; \
1735
	for file in $$RELSRCS; do \
1736
	  hfile=`echo $$file|sed 's/\\.hs$$//'`.html; \
1737
	  $(HSCOLOUR) -css -anchor $$file > ../$(APIDOC_HS_DIR)/$$hfile ; \
1738
	done ; \
1739
	$(HADDOCK) --odir ../$(APIDOC_HS_DIR) --html --ignore-all-exports -w \
1740
	  -t ganeti -p haddock-prologue \
1741
	  --source-module="%{MODULE/.//}.html" \
1742
	  --source-entity="%{MODULE/.//}.html#%{NAME}" \
1743
	  $$OPTGHC \
1744
	  $(filter-out Ganeti/HTools/ExtLoader.hs,$(HS_LIB_SRCS:src/%=%))
1745

    
1746
.PHONY: TAGS
1747
TAGS: $(GENERATED_FILES)
1748
	rm -f TAGS
1749
	$(GHC) -e ":etags" -v0 \
1750
	  $(filter-out -O -Werror,$(HFLAGS)) \
1751
	  $(HS_NOCURL) $(HS_PARALLEL3) $(HS_REGEX_PCRE) \
1752
	  $(HS_LIBTEST_SRCS)
1753
	find . -path './lib/*.py' -o -path './scripts/gnt-*' -o \
1754
	  -path './daemons/ganeti-*' -o -path './tools/*' -o \
1755
	  -path './qa/*.py' | \
1756
	  etags -l python -a -
1757

    
1758
.PHONY: coverage
1759
if WANT_HTOOLS
1760
coverage: py-coverage hs-coverage
1761
else
1762
coverage: py-coverage
1763
endif
1764

    
1765
.PHONY: py-coverage
1766
py-coverage: $(GENERATED_FILES) $(python_tests)
1767
	@test -n "$(PYCOVERAGE)" || \
1768
	    { echo 'python-coverage' not found during configure; exit 1; }
1769
	set -e; \
1770
	COVERAGE=$(PYCOVERAGE) \
1771
	COVERAGE_FILE=$(CURDIR)/$(COVERAGE_PY_DIR)/data \
1772
	TEXT_COVERAGE=$(CURDIR)/$(COVERAGE_PY_DIR)/report.txt \
1773
	HTML_COVERAGE=$(CURDIR)/$(COVERAGE_PY_DIR) \
1774
	$(PLAIN_TESTS_ENVIRONMENT) \
1775
	$(abs_top_srcdir)/autotools/gen-py-coverage \
1776
	$(python_tests)
1777

    
1778
.PHONY: hs-coverage
1779
hs-coverage: $(haskell_tests) test/hs/hpc-htools test/hs/hpc-mon-collector
1780
	rm -f *.tix
1781
	$(MAKE) $(AM_MAKEFLAGS) hs-check
1782
	@mkdir_p@ $(COVERAGE_HS_DIR)
1783
	hpc sum --union $(HPCEXCL) \
1784
	  htest.tix hpc-htools.tix hpc-mon-collector.tix > coverage-hs.tix
1785
	hpc markup --destdir=$(COVERAGE_HS_DIR) coverage-hs.tix
1786
	hpc report coverage-hs.tix
1787
	$(LN_S) -f hpc_index.html $(COVERAGE_HS_DIR)/index.html
1788

    
1789
# Special "kind-of-QA" target for htools, needs special setup (all
1790
# tools compiled with -fhpc)
1791
.PHONY: live-test
1792
live-test: all
1793
	set -e ; \
1794
	cd src; \
1795
	rm -f .hpc; $(LN_S) ../.hpc .hpc; \
1796
	rm -f *.tix *.mix; \
1797
	./live-test.sh; \
1798
	hpc sum --union $(HPCEXCL) $(addsuffix .tix,$(HS_PROGS:src/%=%)) \
1799
	  --output=live-test.tix ; \
1800
	@mkdir_p@ ../$(COVERAGE_HS_DIR) ; \
1801
	hpc markup --destdir=../$(COVERAGE_HS_DIR) live-test \
1802
	  --srcdir=.. $(HPCEXCL) ; \
1803
	hpc report --srcdir=.. live-test $(HPCEXCL)
1804

    
1805
commit-check: distcheck lint apidoc
1806

    
1807
.PHONY: gitignore-check
1808
gitignore-check:
1809
	@if [ -n "`git status --short`" ]; then \
1810
	  echo "Git status is not clean!" 1>&2 ; \
1811
	  git status --short; \
1812
	  exit 1; \
1813
	fi
1814

    
1815
# target to rebuild all man pages (both groff and html output)
1816
.PHONY: man
1817
man: $(man_MANS) $(manhtml)
1818

    
1819
# Target that builds all binaries (including those that are not
1820
# rebuilt except when running the tests)
1821
.PHONY: really-all
1822
really-all: all $(check_SCRIPTS) $(haskell_tests) $(HS_ALL_PROGS)
1823

    
1824
# we don't need the ancient implicit rules:
1825
%: %,v
1826
%: RCS/%,v
1827
%: RCS/%
1828
%: s.%
1829
%: SCCS/s.%
1830

    
1831
-include ./Makefile.local
1832

    
1833
# vim: set noet :