Statistics
| Branch: | Tag: | Revision:

root / Makefile.am @ dbee5c92

History | View | Annotate | Download (52.7 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_WARNINGS = $(top_srcdir)/autotools/check-man-warnings
27
CHECK_VERSION = $(top_srcdir)/autotools/check-version
28
CHECK_NEWS = $(top_srcdir)/autotools/check-news
29
CHECK_IMPORTS = $(top_srcdir)/autotools/check-imports
30
DOCPP = $(top_srcdir)/autotools/docpp
31
REPLACE_VARS_SED = autotools/replace_vars.sed
32
CONVERT_CONSTANTS = $(top_srcdir)/autotools/convert-constants
33
BUILD_RPC = $(top_srcdir)/autotools/build-rpc
34
SHELL_ENV_INIT = autotools/shell-env-init
35

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
229
nodist_pkgpython_PYTHON = \
230
	$(BUILT_PYTHON_SOURCES)
231

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
412
# Haskell programs to be installed in $PREFIX/bin
413
HS_BIN_PROGS=src/htools
414

    
415
# Haskell programs to be installed in the MYEXECLIB dir
416
HS_MYEXECLIB_PROGS=src/mon-collector
417

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

    
424
# All Haskell non-test programs to be compiled but not automatically installed
425
HS_PROGS = $(HS_BIN_PROGS) $(HS_MYEXECLIB_PROGS)
426

    
427
HS_BIN_ROLES = hbal hscan hspace hinfo hcheck hroller
428
HS_HTOOLS_PROGS = $(HS_BIN_ROLES) hail
429

    
430
HS_ALL_PROGS = \
431
	$(HS_PROGS) \
432
	test/hs/hpc-htools \
433
	test/hs/hpc-mon-collector \
434
	test/hs/htest \
435
	$(HS_COMPILE_PROGS)
436

    
437
HS_PROG_SRCS = $(patsubst %,%.hs,$(HS_ALL_PROGS))
438
HS_BUILT_TEST_HELPERS = $(HS_BIN_ROLES:%=test/hs/%) test/hs/hail
439

    
440
HFLAGS = \
441
	-O -Wall -Werror -isrc \
442
	-fwarn-monomorphism-restriction \
443
	-fwarn-tabs \
444
	$(GHC_BYVERSION_FLAGS)
445

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

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

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

    
570
HS_LIBTEST_SRCS = $(HS_LIB_SRCS) $(HS_TEST_SRCS)
571

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

    
578
$(RUN_IN_TEMPDIR): | stamp-directories
579

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

    
602
doc/html: doc/html/index.html
603

    
604
doc/install-quick.rst: INSTALL
605
doc/news.rst: NEWS
606
doc/upgrade.rst: UPGRADE
607

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

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

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

    
637
PYTHON_BOOTSTRAP_SBIN = \
638
	daemons/ganeti-masterd \
639
	daemons/ganeti-noded \
640
	daemons/ganeti-rapi \
641
	daemons/ganeti-watcher \
642
	$(gnt_scripts)
643

    
644
PYTHON_BOOTSTRAP = \
645
	$(PYTHON_BOOTSTRAP_SBIN) \
646
	tools/ensure-dirs \
647
	tools/node-cleanup \
648
	tools/node-daemon-setup \
649
	tools/prepare-node-join
650

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

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

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

    
695
# for the test/hs/htest binary, we need to enable profiling/coverage
696
test/hs/htest: HEXTRA_INT=-fhpc -itest/hs
697

    
698
# we compile the hpc-htools binary with the program coverage
699
test/hs/hpc-htools: HEXTRA_INT=-fhpc
700

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

    
704
# test dependency
705
test/hs/offline-tests.sh: test/hs/hpc-htools test/hs/hpc-mon-collector
706

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

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

    
729
dist_sbin_SCRIPTS = \
730
	tools/ganeti-listrunner
731

    
732
nodist_sbin_SCRIPTS = \
733
	$(PYTHON_BOOTSTRAP_SBIN) \
734
	daemons/ganeti-cleaner
735

    
736
if ENABLE_CONFD
737
src/ganeti-confd: src/hconfd
738
	cp -f $< $@
739

    
740
nodist_sbin_SCRIPTS += src/ganeti-confd
741
endif
742

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

    
756
dist_tools_SCRIPTS = \
757
	$(python_scripts) \
758
	tools/kvm-console-wrapper \
759
	tools/master-ip-setup \
760
	tools/xen-console-wrapper
761

    
762
nodist_tools_python_scripts = \
763
	tools/node-cleanup
764

    
765
nodist_tools_SCRIPTS = \
766
	$(nodist_tools_python_scripts) \
767
	tools/vcluster-setup
768

    
769
pkglib_python_scripts = \
770
	daemons/import-export \
771
	tools/check-cert-expired
772

    
773
nodist_pkglib_python_scripts = \
774
	tools/ensure-dirs \
775
	tools/node-daemon-setup \
776
	tools/prepare-node-join
777

    
778
myexeclib_SCRIPTS = \
779
	daemons/daemon-util \
780
	tools/kvm-ifup \
781
	$(pkglib_python_scripts) \
782
	$(HS_MYEXECLIB_PROGS)
783

    
784
nodist_myexeclib_SCRIPTS = \
785
	$(nodist_pkglib_python_scripts)
786

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

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

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

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

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

    
1053
haskell_tests = test/hs/htest
1054

    
1055
dist_TESTS = \
1056
	test/py/check-cert-expired_unittest.bash \
1057
	test/py/daemon-util_unittest.bash \
1058
	test/py/ganeti-cleaner_unittest.bash \
1059
	test/py/import-export_unittest.bash \
1060
	test/py/cli-test.bash \
1061
	test/py/bash_completion.bash \
1062
	$(python_tests)
1063

    
1064
nodist_TESTS =
1065
check_SCRIPTS =
1066

    
1067
if WANT_HSTESTS
1068
nodist_TESTS += $(haskell_tests)
1069
dist_TESTS += test/hs/offline-test.sh
1070
check_SCRIPTS += \
1071
	test/hs/hpc-htools \
1072
	test/hs/hpc-mon-collector \
1073
	$(HS_BUILT_TEST_HELPERS)
1074
endif
1075

    
1076
TESTS = $(dist_TESTS) $(nodist_TESTS)
1077

    
1078
# Environment for all tests
1079
PLAIN_TESTS_ENVIRONMENT = \
1080
	PYTHONPATH=. \
1081
	TOP_SRCDIR=$(abs_top_srcdir) TOP_BUILDDIR=$(abs_top_builddir) \
1082
	PYTHON=$(PYTHON) FAKEROOT=$(FAKEROOT_PATH) \
1083
	$(RUN_IN_TEMPDIR)
1084

    
1085
# Environment for tests run by automake
1086
TESTS_ENVIRONMENT = \
1087
	$(PLAIN_TESTS_ENVIRONMENT) $(abs_top_srcdir)/autotools/testrunner
1088

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

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

    
1124
check_python_code = \
1125
	$(BUILD_BASH_COMPLETION) \
1126
	$(CHECK_IMPORTS) \
1127
	$(CHECK_HEADER) \
1128
	$(DOCPP) \
1129
	$(all_python_code)
1130

    
1131
lint_python_code = \
1132
	ganeti \
1133
	ganeti/http/server.py \
1134
	$(dist_sbin_SCRIPTS) \
1135
	$(python_scripts) \
1136
	$(pkglib_python_scripts) \
1137
	$(BUILD_BASH_COMPLETION) \
1138
	$(CHECK_IMPORTS) \
1139
	$(CHECK_HEADER) \
1140
	$(DOCPP) \
1141
	$(PYTHON_BOOTSTRAP)
1142

    
1143
standalone_python_modules = \
1144
	lib/rapi/client.py \
1145
	tools/ganeti-listrunner
1146

    
1147
pep8_python_code = \
1148
	ganeti \
1149
	ganeti/http/server.py \
1150
	$(dist_sbin_SCRIPTS) \
1151
	$(python_scripts) \
1152
	$(pkglib_python_scripts) \
1153
	$(BUILD_BASH_COMPLETION) \
1154
	$(CHECK_HEADER) \
1155
	$(DOCPP) \
1156
	$(PYTHON_BOOTSTRAP) \
1157
	qa
1158

    
1159
test/py/daemon-util_unittest.bash: daemons/daemon-util
1160

    
1161
test/py/ganeti-cleaner_unittest.bash: daemons/ganeti-cleaner
1162

    
1163
test/py/bash_completion.bash: doc/examples/bash_completion-debug
1164

    
1165
tools/kvm-ifup: tools/kvm-ifup.in $(REPLACE_VARS_SED)
1166
	sed -f $(REPLACE_VARS_SED) < $< > $@
1167
	chmod +x $@
1168

    
1169
tools/vcluster-setup: tools/vcluster-setup.in $(REPLACE_VARS_SED)
1170
	sed -f $(REPLACE_VARS_SED) < $< > $@
1171
	chmod +x $@
1172

    
1173
daemons/%:: daemons/%.in $(REPLACE_VARS_SED)
1174
	sed -f $(REPLACE_VARS_SED) < $< > $@
1175
	chmod +x $@
1176

    
1177
doc/examples/%:: doc/examples/%.in $(REPLACE_VARS_SED)
1178
	sed -f $(REPLACE_VARS_SED) < $< > $@
1179

    
1180
doc/examples/bash_completion: BC_ARGS = --compact
1181
doc/examples/bash_completion-debug: BC_ARGS =
1182

    
1183
doc/examples/bash_completion doc/examples/bash_completion-debug: \
1184
	$(BUILD_BASH_COMPLETION) $(RUN_IN_TEMPDIR) \
1185
	lib/cli.py $(gnt_scripts) $(client_PYTHON) tools/burnin \
1186
	daemons/ganeti-cleaner \
1187
	$(GENERATED_FILES) $(HS_GENERATED_FILES)
1188
	PYTHONPATH=. $(RUN_IN_TEMPDIR) \
1189
	  $(CURDIR)/$(BUILD_BASH_COMPLETION) $(BC_ARGS) > $@
1190

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

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

    
1215
man/%.html.in: man/%.gen man/footer.rst
1216
	@test -n "$(PANDOC)" || \
1217
	  { echo 'pandoc' not found during configure; exit 1; }
1218
	set -o pipefail ; \
1219
	$(PANDOC) --toc -s -f rst -t html $< man/footer.rst | \
1220
	  sed -e 's/\\@/@/g' > $@
1221

    
1222
man/%: man/%.in  $(REPLACE_VARS_SED)
1223
	sed -f $(REPLACE_VARS_SED) < $< > $@
1224

    
1225
epydoc.conf: epydoc.conf.in $(REPLACE_VARS_SED)
1226
	sed -f $(REPLACE_VARS_SED) < $< > $@
1227

    
1228
vcs-version:
1229
	if test -d .git; then \
1230
	  git describe > $@; \
1231
	elif test ! -f $@ ; then \
1232
	  echo "Cannot auto-generate $@ file"; exit 1; \
1233
	fi
1234

    
1235
.PHONY: clean-vcs-version
1236
clean-vcs-version:
1237
	rm -f vcs-version
1238

    
1239
.PHONY: regen-vcs-version
1240
regen-vcs-version:
1241
	@set -e; \
1242
	cd $(srcdir); \
1243
	if test -d .git; then \
1244
	  T=`mktemp` ; trap 'rm -f $$T' EXIT; \
1245
	  git describe > $$T; \
1246
	  if ! cmp --quiet $$T vcs-version; then \
1247
	    mv $$T vcs-version; \
1248
	  fi; \
1249
	fi
1250

    
1251
src/Ganeti/Version.hs: src/Ganeti/Version.hs.in \
1252
	vcs-version $(built_base_sources)
1253
	set -e; \
1254
	VCSVER=`cat $(abs_top_srcdir)/vcs-version`; \
1255
	sed -e "s/%ver%/$$VCSVER/" < $< > $@
1256

    
1257
src/Ganeti/Constants.hs: src/Ganeti/Constants.hs.in \
1258
	lib/constants.py lib/_autoconf.py lib/luxi.py lib/errors.py \
1259
	lib/jstore.py $(RUN_IN_TEMPDIR) \
1260
	$(CONVERT_CONSTANTS) $(built_base_sources) \
1261
	| lib/_vcsversion.py
1262
	set -e; \
1263
	{ cat $< ; \
1264
	  PYTHONPATH=. $(RUN_IN_TEMPDIR) $(CURDIR)/$(CONVERT_CONSTANTS); \
1265
	} > $@
1266

    
1267
test/hs/Test/Ganeti/TestImports.hs: test/hs/Test/Ganeti/TestImports.hs.in \
1268
	$(built_base_sources)
1269
	set -e; \
1270
	{ cat $< ; \
1271
	  echo ; \
1272
	  for name in $(filter-out Ganeti.THH,$(subst /,.,$(patsubst %.hs,%,$(patsubst src/%,%,$(HS_LIB_SRCS))))) ; do \
1273
	    echo "import $$name ()" ; \
1274
	  done ; \
1275
	} > $@
1276

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

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

    
1371
lib/_generated_rpc.py: lib/rpc_defs.py $(BUILD_RPC)
1372
	PYTHONPATH=. $(RUN_IN_TEMPDIR) $(CURDIR)/$(BUILD_RPC) lib/rpc_defs.py > $@
1373

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

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

    
1423
# Using deferred evaluation
1424
daemons/ganeti-%: MODULE = ganeti.server.$(patsubst ganeti-%,%,$(notdir $@))
1425
daemons/ganeti-watcher: MODULE = ganeti.watcher
1426
scripts/%: MODULE = ganeti.client.$(subst -,_,$(notdir $@))
1427
tools/ensure-dirs: MODULE = ganeti.tools.ensure_dirs
1428
tools/node-daemon-setup: MODULE = ganeti.tools.node_daemon_setup
1429
tools/prepare-node-join: MODULE = ganeti.tools.prepare_node_join
1430
tools/node-cleanup: MODULE = ganeti.tools.node_cleanup
1431
$(HS_BUILT_TEST_HELPERS): TESTROLE = $(patsubst test/hs/%,%,$@)
1432

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

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

    
1471
stamp-directories: Makefile
1472
	$(MAKE) $(AM_MAKEFLAGS) ganeti
1473
	@mkdir_p@ $(DIRS) $(BUILDTIME_DIR_AUTOCREATE)
1474
	touch $@
1475

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

    
1487
.PHONY: ganeti
1488
ganeti:
1489
	cd $(top_builddir) && test -h "$@" || { rm -f $@ && $(LN_S) lib $@; }
1490

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

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

    
1549
.PHONY: hs-tests
1550
hs-tests: test/hs/htest | $(BUILT_PYTHON_SOURCES)
1551
	@rm -f htest.tix
1552
	./test/hs/htest
1553

    
1554
.PHONY: hs-shell
1555
hs-shell: test/hs/hpc-htools test/hs/hpc-mon-collector $(HS_BUILT_TEST_HELPERS)
1556
	@rm -f hpc-htools.tix hpc-mon-collector.tix
1557
	HBINARY="./test/hs/hpc-htools" ./test/hs/offline-test.sh
1558

    
1559
.PHONY: hs-check
1560
hs-check: hs-tests hs-shell
1561

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

    
1577
# For excluding pep8 expects filenames only, not whole paths
1578
PEP8_EXCLUDE = $(subst $(space),$(comma),$(strip $(notdir $(BUILT_PYTHON_SOURCES))))
1579

    
1580
LINT_TARGETS = pylint pylint-qa
1581
if HAS_PEP8
1582
LINT_TARGETS += pep8
1583
endif
1584
if HAS_HLINT
1585
LINT_TARGETS += hlint
1586
endif
1587

    
1588
.PHONY: lint
1589
lint: $(LINT_TARGETS)
1590

    
1591
.PHONY: pylint
1592
pylint: $(GENERATED_FILES)
1593
	@test -n "$(PYLINT)" || { echo 'pylint' not found during configure; exit 1; }
1594
	$(PYLINT) $(LINT_OPTS) $(lint_python_code)
1595

    
1596
.PHONY: pylint-qa
1597
pylint-qa: $(GENERATED_FILES)
1598
	@test -n "$(PYLINT)" || { echo 'pylint' not found during configure; exit 1; }
1599
	cd $(top_srcdir)/qa && \
1600
	  PYTHONPATH=$(abs_top_srcdir) $(PYLINT) $(LINT_OPTS) \
1601
	  --rcfile  ../pylintrc $(patsubst qa/%.py,%,$(qa_scripts))
1602

    
1603
.PHONY: pep8
1604
pep8: $(GENERATED_FILES)
1605
	@test -n "$(PEP8)" || { echo 'pep8' not found during configure; exit 1; }
1606
	$(PEP8) --ignore='$(PEP8_IGNORE)' --exclude='$(PEP8_EXCLUDE)' \
1607
	  --repeat $(pep8_python_code)
1608

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

    
1623
# a dist hook rule for updating the vcs-version file; this is
1624
# hardcoded due to where it needs to build the file...
1625
dist-hook:
1626
	$(MAKE) $(AM_MAKEFLAGS) regen-vcs-version
1627
	rm -f $(top_distdir)/vcs-version
1628
	cp -p $(srcdir)/vcs-version $(top_distdir)
1629

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

    
1659
# When building a release, stricter checks should be used
1660
distcheck-release dist-release: export BUILD_RELEASE = 1
1661
distcheck-release: distcheck
1662

    
1663
distrebuildcheck: dist
1664
	set -e; \
1665
	builddir=$$(mktemp -d $(abs_srcdir)/distrebuildcheck.XXXXXXX); \
1666
	trap "echo Removing $$builddir; cd $(abs_srcdir); rm -rf $$builddir" EXIT; \
1667
	cd $$builddir; \
1668
	tar xzf $(abs_srcdir)/$(distdir).tar.gz; \
1669
	cd $(distdir); \
1670
	./configure; \
1671
	$(MAKE) maintainer-clean; \
1672
	cp $(abs_srcdir)/vcs-version .; \
1673
	./configure; \
1674
	$(MAKE) $(AM_MAKEFLAGS)
1675

    
1676
dist-release: dist
1677
	set -e; \
1678
	for i in $(DIST_ARCHIVES); do \
1679
	  echo -n "Checking $$i ... "; \
1680
	  autotools/check-tar < $$i; \
1681
	  echo OK; \
1682
	done
1683

    
1684
install-exec-local:
1685
	@mkdir_p@ "$(DESTDIR)${localstatedir}/lib/ganeti" \
1686
	  "$(DESTDIR)${localstatedir}/log/ganeti" \
1687
	  "$(DESTDIR)${localstatedir}/run/ganeti"
1688

    
1689
.PHONY: apidoc
1690
if WANT_HSAPIDOC
1691
apidoc: py-apidoc hs-apidoc
1692
else
1693
apidoc: py-apidoc
1694
endif
1695

    
1696
.PHONY: py-apidoc
1697
py-apidoc: epydoc.conf $(RUN_IN_TEMPDIR) $(GENERATED_FILES)
1698
	env - PATH="$$PATH" PYTHONPATH="$$PYTHONPATH" \
1699
	$(RUN_IN_TEMPDIR) epydoc -v \
1700
	  --conf $(CURDIR)/epydoc.conf \
1701
	  --output $(CURDIR)/$(APIDOC_PY_DIR)
1702

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

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

    
1752
.PHONY: coverage
1753
if WANT_HTOOLS
1754
coverage: py-coverage hs-coverage
1755
else
1756
coverage: py-coverage
1757
endif
1758

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

    
1772
.PHONY: hs-coverage
1773
hs-coverage: $(haskell_tests) test/hs/hpc-htools test/hs/hpc-mon-collector
1774
	rm -f *.tix
1775
	$(MAKE) $(AM_MAKEFLAGS) hs-check
1776
	@mkdir_p@ $(COVERAGE_HS_DIR)
1777
	hpc sum --union $(HPCEXCL) \
1778
	  htest.tix hpc-htools.tix hpc-mon-collector.tix > coverage-hs.tix
1779
	hpc markup --destdir=$(COVERAGE_HS_DIR) coverage-hs.tix
1780
	hpc report coverage-hs.tix
1781
	$(LN_S) -f hpc_index.html $(COVERAGE_HS_DIR)/index.html
1782

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

    
1799
commit-check: distcheck lint apidoc
1800

    
1801
.PHONY: gitignore-check
1802
gitignore-check:
1803
	@if [ -n "`git status --short`" ]; then \
1804
	  echo "Git status is not clean!" 1>&2 ; \
1805
	  git status --short; \
1806
	  exit 1; \
1807
	fi
1808

    
1809
# target to rebuild all man pages (both groff and html output)
1810
.PHONY: man
1811
man: $(man_MANS) $(manhtml)
1812

    
1813
# Target that builds all binaries (including those that are not
1814
# rebuilt except when running the tests)
1815
.PHONY: really-all
1816
really-all: all $(check_SCRIPTS) $(haskell_tests) $(HS_ALL_PROGS)
1817

    
1818
# we don't need the ancient implicit rules:
1819
%: %,v
1820
%: RCS/%,v
1821
%: RCS/%
1822
%: s.%
1823
%: SCCS/s.%
1824

    
1825
-include ./Makefile.local
1826

    
1827
# vim: set noet :