Statistics
| Branch: | Tag: | Revision:

root / Makefile.am @ 332b1340

History | View | Annotate | Download (51 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
HTOOLS_DIRS = \
58
	htools \
59
	htools/Ganeti \
60
	htools/Ganeti/Block \
61
	htools/Ganeti/Block/Drbd \
62
	htools/Ganeti/Confd \
63
	htools/Ganeti/DataCollectors \
64
	htools/Ganeti/HTools \
65
	htools/Ganeti/HTools/Backend \
66
	htools/Ganeti/HTools/Program \
67
	htools/Ganeti/Query \
68
	htest \
69
	htest/Test \
70
	htest/Test/Ganeti \
71
	htest/Test/Ganeti/Block \
72
	htest/Test/Ganeti/Block/Drbd \
73
	htest/Test/Ganeti/Confd \
74
	htest/Test/Ganeti/HTools \
75
	htest/Test/Ganeti/HTools/Backend \
76
	htest/Test/Ganeti/Query
77

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

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

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

    
133
BUILDTIME_DIRS = \
134
	$(BUILDTIME_DIR_AUTOCREATE) \
135
	doc/html
136

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

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

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

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

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

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

    
194
HTOOLS_GENERATED_FILES =
195
if WANT_HTOOLS
196
HTOOLS_GENERATED_FILES += $(HS_PROGS)
197
if ENABLE_CONFD
198
HTOOLS_GENERATED_FILES += htools/hconfd htools/ganeti-confd
199
endif
200
endif
201

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

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

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

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

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

    
228
nodist_pkgpython_PYTHON = \
229
	$(BUILT_PYTHON_SOURCES)
230

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

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

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

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

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

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

    
311
confd_PYTHON = \
312
	lib/confd/__init__.py \
313
	lib/confd/client.py
314

    
315
masterd_PYTHON = \
316
	lib/masterd/__init__.py \
317
	lib/masterd/iallocator.py \
318
	lib/masterd/instance.py
319

    
320
impexpd_PYTHON = \
321
	lib/impexpd/__init__.py
322

    
323
watcher_PYTHON = \
324
	lib/watcher/__init__.py \
325
	lib/watcher/nodemaint.py \
326
	lib/watcher/state.py
327

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

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

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

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

    
409
HS_PROGS = htools/htools htools/mon-collector
410
HS_BIN_ROLES = hbal hscan hspace hinfo hcheck
411
HS_HTOOLS_PROGS = $(HS_BIN_ROLES) hail
412

    
413
HS_ALL_PROGS = \
414
	$(HS_PROGS) \
415
	htest/hpc-htools \
416
	htest/test \
417
	htools/hconfd \
418
	htools/rpc-test
419

    
420
HS_PROG_SRCS = $(patsubst %,%.hs,$(HS_ALL_PROGS))
421
HS_BUILT_TEST_HELPERS = $(HS_BIN_ROLES:%=htest/%) htest/hail
422

    
423
HFLAGS = \
424
	-O -Wall -Werror -ihtools \
425
	-fwarn-monomorphism-restriction \
426
	-fwarn-tabs \
427
	$(GHC_BYVERSION_FLAGS)
428

    
429
# extra flags that can be overriden on the command line (e.g. -Wwarn, etc.)
430
HEXTRA =
431
# internal extra flags (used for htest/test mainly)
432
HEXTRA_INT =
433
# exclude options for coverage reports
434
HPCEXCL = --exclude Main \
435
	--exclude Ganeti.Constants \
436
	--exclude Ganeti.HTools.QC \
437
	--exclude Ganeti.THH \
438
	--exclude Ganeti.Version \
439
	--exclude Test.Ganeti.Attoparsec \
440
	--exclude Test.Ganeti.TestCommon \
441
	--exclude Test.Ganeti.TestHTools \
442
	--exclude Test.Ganeti.TestHelper \
443
	--exclude Test.Ganeti.TestImports \
444
	$(patsubst htools.%,--exclude Test.%,$(subst /,.,$(patsubst %.hs,%, $(HS_LIB_SRCS))))
445

    
446
HS_LIB_SRCS = \
447
	htools/Ganeti/Block/Drbd/Types.hs \
448
	htools/Ganeti/Block/Drbd/Parser.hs \
449
	htools/Ganeti/BasicTypes.hs \
450
	htools/Ganeti/Common.hs \
451
	htools/Ganeti/Compat.hs \
452
	htools/Ganeti/Confd/Server.hs \
453
	htools/Ganeti/Confd/Types.hs \
454
	htools/Ganeti/Confd/Utils.hs \
455
	htools/Ganeti/Config.hs \
456
	htools/Ganeti/Daemon.hs \
457
	htools/Ganeti/DataCollectors/Drbd.hs \
458
	htools/Ganeti/DataCollectors/Program.hs \
459
	htools/Ganeti/Errors.hs \
460
	htools/Ganeti/HTools/Backend/IAlloc.hs \
461
	htools/Ganeti/HTools/Backend/Luxi.hs \
462
	htools/Ganeti/HTools/Backend/Rapi.hs \
463
	htools/Ganeti/HTools/Backend/Simu.hs \
464
	htools/Ganeti/HTools/Backend/Text.hs \
465
	htools/Ganeti/HTools/CLI.hs \
466
	htools/Ganeti/HTools/Cluster.hs \
467
	htools/Ganeti/HTools/Container.hs \
468
	htools/Ganeti/HTools/ExtLoader.hs \
469
	htools/Ganeti/HTools/Graph.hs \
470
	htools/Ganeti/HTools/Group.hs \
471
	htools/Ganeti/HTools/Instance.hs \
472
	htools/Ganeti/HTools/Loader.hs \
473
	htools/Ganeti/HTools/Node.hs \
474
	htools/Ganeti/HTools/PeerMap.hs \
475
	htools/Ganeti/HTools/Program.hs \
476
	htools/Ganeti/HTools/Program/Hail.hs \
477
	htools/Ganeti/HTools/Program/Hbal.hs \
478
	htools/Ganeti/HTools/Program/Hcheck.hs \
479
	htools/Ganeti/HTools/Program/Hinfo.hs \
480
	htools/Ganeti/HTools/Program/Hscan.hs \
481
	htools/Ganeti/HTools/Program/Hspace.hs \
482
	htools/Ganeti/HTools/Types.hs \
483
	htools/Ganeti/Hash.hs \
484
	htools/Ganeti/JSON.hs \
485
	htools/Ganeti/Jobs.hs \
486
	htools/Ganeti/Logging.hs \
487
	htools/Ganeti/Luxi.hs \
488
	htools/Ganeti/Network.hs \
489
	htools/Ganeti/Objects.hs \
490
	htools/Ganeti/OpCodes.hs \
491
	htools/Ganeti/OpParams.hs \
492
	htools/Ganeti/Path.hs \
493
	htools/Ganeti/Query/Common.hs \
494
	htools/Ganeti/Query/Filter.hs \
495
	htools/Ganeti/Query/Group.hs \
496
	htools/Ganeti/Query/Language.hs \
497
	htools/Ganeti/Query/Node.hs \
498
	htools/Ganeti/Query/Query.hs \
499
	htools/Ganeti/Query/Server.hs \
500
	htools/Ganeti/Query/Types.hs \
501
	htools/Ganeti/Rpc.hs \
502
	htools/Ganeti/Runtime.hs \
503
	htools/Ganeti/Ssconf.hs \
504
	htools/Ganeti/THH.hs \
505
	htools/Ganeti/Types.hs \
506
	htools/Ganeti/Utils.hs
507

    
508
HS_TEST_SRCS = \
509
	htest/Test/Ganeti/Attoparsec.hs \
510
	htest/Test/Ganeti/BasicTypes.hs \
511
	htest/Test/Ganeti/Block/Drbd/Parser.hs \
512
	htest/Test/Ganeti/Block/Drbd/Types.hs \
513
	htest/Test/Ganeti/Common.hs \
514
	htest/Test/Ganeti/Confd/Utils.hs \
515
	htest/Test/Ganeti/Daemon.hs \
516
	htest/Test/Ganeti/Errors.hs \
517
	htest/Test/Ganeti/HTools/Backend/Simu.hs \
518
	htest/Test/Ganeti/HTools/Backend/Text.hs \
519
	htest/Test/Ganeti/HTools/CLI.hs \
520
	htest/Test/Ganeti/HTools/Cluster.hs \
521
	htest/Test/Ganeti/HTools/Container.hs \
522
	htest/Test/Ganeti/HTools/Graph.hs \
523
	htest/Test/Ganeti/HTools/Instance.hs \
524
	htest/Test/Ganeti/HTools/Loader.hs \
525
	htest/Test/Ganeti/HTools/Node.hs \
526
	htest/Test/Ganeti/HTools/PeerMap.hs \
527
	htest/Test/Ganeti/HTools/Types.hs \
528
	htest/Test/Ganeti/JSON.hs \
529
	htest/Test/Ganeti/Jobs.hs \
530
	htest/Test/Ganeti/Luxi.hs \
531
	htest/Test/Ganeti/Network.hs \
532
	htest/Test/Ganeti/Objects.hs \
533
	htest/Test/Ganeti/OpCodes.hs \
534
	htest/Test/Ganeti/Query/Filter.hs \
535
	htest/Test/Ganeti/Query/Language.hs \
536
	htest/Test/Ganeti/Query/Query.hs \
537
	htest/Test/Ganeti/Rpc.hs \
538
	htest/Test/Ganeti/Ssconf.hs \
539
	htest/Test/Ganeti/THH.hs \
540
	htest/Test/Ganeti/TestCommon.hs \
541
	htest/Test/Ganeti/TestHTools.hs \
542
	htest/Test/Ganeti/TestHelper.hs \
543
	htest/Test/Ganeti/Types.hs \
544
	htest/Test/Ganeti/Utils.hs
545

    
546
HS_LIBTEST_SRCS = $(HS_LIB_SRCS) $(HS_TEST_SRCS)
547

    
548
HS_BUILT_SRCS = \
549
	htest/Test/Ganeti/TestImports.hs \
550
	htools/Ganeti/Constants.hs \
551
	htools/Ganeti/Version.hs
552
HS_BUILT_SRCS_IN = $(patsubst %,%.in,$(HS_BUILT_SRCS))
553

    
554
$(RUN_IN_TEMPDIR): | stamp-directories
555

    
556
# Note: we use here an order-only prerequisite, as the contents of
557
# _autoconf.py are not actually influencing the html build output: it
558
# has to exist in order for the sphinx module to be loaded
559
# successfully, but we certainly don't want the docs to be rebuilt if
560
# it changes
561
doc/html/index.html: $(docrst) $(docpng) doc/conf.py configure.ac \
562
	$(RUN_IN_TEMPDIR) lib/build/sphinx_ext.py \
563
	lib/build/shell_example_lexer.py lib/opcodes.py lib/ht.py \
564
	| $(BUILT_PYTHON_SOURCES)
565
	@test -n "$(SPHINX)" || \
566
	    { echo 'sphinx-build' not found during configure; exit 1; }
567
	@mkdir_p@ $(dir $@)
568
	PYTHONPATH=. $(RUN_IN_TEMPDIR) $(SPHINX) -q -W -b html \
569
	    -d . \
570
	    -D version="$(VERSION_MAJOR).$(VERSION_MINOR)" \
571
	    -D release="$(PACKAGE_VERSION)" \
572
	    $(abs_top_srcdir)/doc $(CURDIR)/doc/html
573
	rm -f doc/html/.buildinfo doc/html/objects.inv
574
	touch $@
575

    
576
doc/html: doc/html/index.html
577

    
578
doc/install-quick.rst: INSTALL
579
doc/news.rst: NEWS
580
doc/upgrade.rst: UPGRADE
581

    
582
doc/install-quick.rst doc/news.rst doc/upgrade.rst:
583
	set -e; \
584
	{ echo '.. This file is automatically updated at build time from $<.'; \
585
	  echo '.. Do not edit.'; \
586
	  echo; \
587
	  cat $<; \
588
	} > $@
589

    
590
docdot = \
591
	doc/arch-2.0.dot \
592
	doc/design-2.1-lock-acquire.dot \
593
	doc/design-2.1-lock-release.dot
594

    
595
docpng = $(patsubst %.dot,%.png,$(docdot))
596

    
597
# Things to build but not to install (add it to EXTRA_DIST if it should be
598
# distributed)
599
noinst_DATA = \
600
	doc/html \
601
	$(BUILT_EXAMPLES) \
602
	doc/examples/bash_completion \
603
	doc/examples/bash_completion-debug \
604
	$(manhtml)
605

    
606
gnt_scripts = \
607
	scripts/gnt-backup \
608
	scripts/gnt-cluster \
609
	scripts/gnt-debug \
610
	scripts/gnt-group \
611
	scripts/gnt-instance \
612
	scripts/gnt-job \
613
	scripts/gnt-network \
614
	scripts/gnt-node \
615
	scripts/gnt-os
616

    
617
PYTHON_BOOTSTRAP_SBIN = \
618
	daemons/ganeti-masterd \
619
	daemons/ganeti-noded \
620
	daemons/ganeti-rapi \
621
	daemons/ganeti-watcher \
622
	$(gnt_scripts)
623

    
624
PYTHON_BOOTSTRAP = \
625
	$(PYTHON_BOOTSTRAP_SBIN) \
626
	tools/ensure-dirs \
627
	tools/node-cleanup \
628
	tools/node-daemon-setup \
629
	tools/prepare-node-join
630

    
631
qa_scripts = \
632
	qa/__init__.py \
633
	qa/ganeti-qa.py \
634
	qa/qa_cluster.py \
635
	qa/qa_config.py \
636
	qa/qa_daemon.py \
637
	qa/qa_env.py \
638
	qa/qa_error.py \
639
	qa/qa_group.py \
640
	qa/qa_instance.py \
641
	qa/qa_job.py \
642
	qa/qa_node.py \
643
	qa/qa_os.py \
644
	qa/qa_rapi.py \
645
	qa/qa_tags.py \
646
	qa/qa_utils.py
647

    
648
bin_SCRIPTS =
649
if WANT_HTOOLS
650
bin_SCRIPTS += $(filter-out htools/hail,$(HS_PROGS))
651
install-exec-hook:
652
	@mkdir_p@ $(DESTDIR)$(iallocatorsdir)
653
# FIXME: this is a hardcoded logic, instead of auto-resolving
654
	$(LN_S) -f ../../../bin/htools \
655
	  $(DESTDIR)$(iallocatorsdir)/hail
656
	for role in $(HS_BIN_ROLES); do \
657
	  $(LN_S) -f htools $(DESTDIR)$(bindir)/$$role ; \
658
	done
659
endif
660

    
661
$(HS_ALL_PROGS): %: %.hs $(HS_LIBTEST_SRCS) $(HS_BUILT_SRCS) Makefile
662
	@if [ "$(notdir $@)" = "test" ] && [ "$(HTOOLS_NODEV)" ]; then \
663
	  echo "Error: cannot run unittests without the development" \
664
	       " libraries (see devnotes.rst)" 1>&2; \
665
	  exit 1; \
666
	fi
667
	@rm -f $(notdir $@).tix
668
	$(GHC) --make \
669
	  $(HFLAGS) \
670
	  $(HTOOLS_NOCURL) $(HTOOLS_PARALLEL3) $(HTOOLS_REGEX_PCRE) \
671
	  -osuf $(notdir $@).o -hisuf $(notdir $@).hi \
672
	  $(HEXTRA) $(HEXTRA_INT) $@
673
	@touch "$@"
674

    
675
# for the htest/test binary, we need to enable profiling/coverage
676
htest/test: HEXTRA_INT=-fhpc -ihtest
677

    
678
# we compile the hpc-htools binary with the program coverage
679
htest/hpc-htools: HEXTRA_INT=-fhpc
680

    
681
# test dependency
682
htest/offline-tests.sh: htest/hpc-htools
683

    
684
# rules for building profiling-enabled versions of the haskell
685
# programs: hs-prof does the full two-step build, whereas
686
# hs-prof-quick does only the final rebuild (hs-prof must have been
687
# run before)
688
.PHONY: hs-prof hs-prof-quick
689
hs-prof:
690
	$(MAKE) $(AM_MAKEFLAGS) clean
691
	$(MAKE) $(AM_MAKEFLAGS) $(HS_ALL_PROGS) HEXTRA="-osuf o"
692
	rm -f $(HS_ALL_PROGS)
693
	$(MAKE) $(AM_MAKEFLAGS) hs-prof-quick
694

    
695
hs-prof-quick:
696
	$(MAKE) $(AM_MAKEFLAGS) $(HS_ALL_PROGS) HEXTRA="-osuf prof_o -prof -auto-all"
697

    
698
dist_sbin_SCRIPTS = \
699
	tools/ganeti-listrunner
700

    
701
nodist_sbin_SCRIPTS = \
702
	$(PYTHON_BOOTSTRAP_SBIN) \
703
	daemons/ganeti-cleaner
704

    
705
if ENABLE_CONFD
706
htools/ganeti-confd: htools/hconfd
707
	cp -f $< $@
708

    
709
nodist_sbin_SCRIPTS += htools/ganeti-confd
710
endif
711

    
712
python_scripts = \
713
	tools/burnin \
714
	tools/cfgshell \
715
	tools/cfgupgrade \
716
	tools/cfgupgrade12 \
717
	tools/cluster-merge \
718
	tools/confd-client \
719
	tools/fmtjson \
720
	tools/lvmstrap \
721
	tools/move-instance \
722
	tools/ovfconverter \
723
	tools/sanitize-config
724

    
725
dist_tools_SCRIPTS = \
726
	$(python_scripts) \
727
	tools/kvm-console-wrapper \
728
	tools/master-ip-setup \
729
	tools/xen-console-wrapper
730

    
731
nodist_tools_python_scripts = \
732
	tools/node-cleanup
733

    
734
nodist_tools_SCRIPTS = \
735
	$(nodist_tools_python_scripts) \
736
	tools/vcluster-setup
737

    
738
pkglib_python_scripts = \
739
	daemons/import-export \
740
	tools/check-cert-expired
741

    
742
nodist_pkglib_python_scripts = \
743
	tools/ensure-dirs \
744
	tools/node-daemon-setup \
745
	tools/prepare-node-join
746

    
747
myexeclib_SCRIPTS = \
748
	daemons/daemon-util \
749
	tools/kvm-ifup \
750
	$(pkglib_python_scripts) \
751
	htools/mon-collector
752

    
753
nodist_myexeclib_SCRIPTS = \
754
	$(nodist_pkglib_python_scripts)
755

    
756
EXTRA_DIST = \
757
	NEWS \
758
	UPGRADE \
759
	epydoc.conf.in \
760
	pylintrc \
761
	autotools/build-bash-completion \
762
	autotools/build-rpc \
763
	autotools/check-header \
764
	autotools/check-imports \
765
	autotools/check-man-dashes \
766
	autotools/check-man-warnings \
767
	autotools/check-news \
768
	autotools/check-python-code \
769
	autotools/check-tar \
770
	autotools/check-version \
771
	autotools/convert-constants \
772
	autotools/docpp \
773
	autotools/gen-coverage \
774
	autotools/testrunner \
775
	autotools/wrong-hardcoded-paths \
776
	$(RUN_IN_TEMPDIR) \
777
	daemons/daemon-util.in \
778
	daemons/ganeti-cleaner.in \
779
	$(pkglib_python_scripts) \
780
	devel/upload \
781
	tools/kvm-ifup.in \
782
	tools/vcluster-setup.in \
783
	$(docdot) \
784
	$(docpng) \
785
	$(docrst) \
786
	doc/conf.py \
787
	doc/html \
788
	$(BUILT_EXAMPLES:%=%.in) \
789
	doc/examples/ganeti.default \
790
	doc/examples/ganeti.default-debug \
791
	doc/examples/hooks/ethers \
792
	doc/examples/gnt-debug/README \
793
	doc/examples/gnt-debug/delay0.json \
794
	doc/examples/gnt-debug/delay50.json \
795
	test/lockperf.py \
796
	test/testutils.py \
797
	test/mocks.py \
798
	$(dist_TESTS) \
799
	$(TEST_FILES) \
800
	man/footer.rst \
801
	$(manrst) \
802
	$(maninput) \
803
	qa/qa-sample.json \
804
	$(qa_scripts) \
805
	$(HS_LIBTEST_SRCS) $(HS_BUILT_SRCS_IN) \
806
	$(HS_PROG_SRCS) \
807
	htools/lint-hints.hs \
808
	htest/cli-tests-defs.sh \
809
	htest/offline-test.sh \
810
	.ghci
811

    
812
man_MANS = \
813
	man/ganeti-cleaner.8 \
814
	man/ganeti-confd.8 \
815
	man/ganeti-listrunner.8 \
816
	man/ganeti-masterd.8 \
817
	man/ganeti-noded.8 \
818
	man/ganeti-os-interface.7 \
819
	man/ganeti-rapi.8 \
820
	man/ganeti-watcher.8 \
821
	man/ganeti.7 \
822
	man/gnt-backup.8 \
823
	man/gnt-cluster.8 \
824
	man/gnt-debug.8 \
825
	man/gnt-group.8 \
826
	man/gnt-network.8 \
827
	man/gnt-instance.8 \
828
	man/gnt-job.8 \
829
	man/gnt-node.8 \
830
	man/gnt-os.8 \
831
	man/hail.1 \
832
	man/hbal.1 \
833
	man/hcheck.1 \
834
	man/hinfo.1 \
835
	man/hscan.1 \
836
	man/hspace.1 \
837
	man/htools.1 \
838
	man/mon-collector.7
839

    
840
manrst = $(patsubst %.1,%.rst,$(patsubst %.7,%.rst,$(patsubst %.8,%.rst,$(man_MANS))))
841
manhtml = $(patsubst %.rst,%.html,$(manrst))
842
mangen = $(patsubst %.rst,%.gen,$(manrst))
843
maninput = \
844
	$(patsubst %.1,%.1.in,$(patsubst %.7,%.7.in,$(patsubst %.8,%.8.in,$(man_MANS)))) \
845
	$(patsubst %.html,%.html.in,$(manhtml)) \
846
	man/footer.man man/footer.html $(mangen)
847

    
848
TEST_FILES = \
849
	htest/data/common-suffix.data \
850
	htest/data/hail-alloc-drbd.json \
851
	htest/data/hail-change-group.json \
852
	htest/data/hail-invalid-reloc.json \
853
	htest/data/hail-node-evac.json \
854
	htest/data/hail-reloc-drbd.json \
855
	htest/data/hbal-excl-tags.data \
856
	htest/data/hbal-split-insts.data \
857
	htest/data/invalid-node.data \
858
	htest/data/missing-resources.data \
859
	htest/data/rapi/groups.json \
860
	htest/data/rapi/info.json \
861
	htest/data/rapi/instances.json \
862
	htest/data/rapi/nodes.json \
863
	htest/shelltests/htools-balancing.test \
864
	htest/shelltests/htools-basic.test \
865
	htest/shelltests/htools-dynutil.test \
866
	htest/shelltests/htools-excl.test \
867
	htest/shelltests/htools-hail.test \
868
	htest/shelltests/htools-hspace.test \
869
	htest/shelltests/htools-invalid.test \
870
	htest/shelltests/htools-multi-group.test \
871
	htest/shelltests/htools-no-backend.test \
872
	htest/shelltests/htools-rapi.test \
873
	htest/shelltests/htools-single-group.test \
874
	htest/shelltests/htools-text-backend.test \
875
	test/data/bdev-drbd-8.0.txt \
876
	test/data/bdev-drbd-8.3.txt \
877
	test/data/bdev-drbd-disk.txt \
878
	test/data/bdev-drbd-net-ip4.txt \
879
	test/data/bdev-drbd-net-ip6.txt \
880
	test/data/cert1.pem \
881
	test/data/cert2.pem \
882
	test/data/ip-addr-show-dummy0.txt \
883
	test/data/ip-addr-show-lo-ipv4.txt \
884
	test/data/ip-addr-show-lo-ipv6.txt \
885
	test/data/ip-addr-show-lo-oneline-ipv4.txt \
886
	test/data/ip-addr-show-lo-oneline-ipv6.txt \
887
	test/data/ip-addr-show-lo-oneline.txt \
888
	test/data/ip-addr-show-lo.txt \
889
	test/data/kvm_0.12.5_help.txt \
890
	test/data/kvm_0.15.90_help.txt \
891
	test/data/kvm_0.9.1_help.txt \
892
	test/data/kvm_1.0_help.txt \
893
	test/data/ovfdata/compr_disk.vmdk.gz \
894
	test/data/ovfdata/config.ini \
895
	test/data/ovfdata/corrupted_resources.ovf \
896
	test/data/ovfdata/empty.ini \
897
	test/data/ovfdata/empty.ovf \
898
	test/data/ovfdata/ganeti.mf \
899
	test/data/ovfdata/ganeti.ovf \
900
	test/data/ovfdata/gzip_disk.ovf \
901
	test/data/ovfdata/new_disk.vmdk \
902
	test/data/ovfdata/no_disk.ini \
903
	test/data/ovfdata/no_disk_in_ref.ovf \
904
	test/data/ovfdata/no_os.ini \
905
	test/data/ovfdata/no_ovf.ova \
906
	test/data/ovfdata/other/rawdisk.raw \
907
	test/data/ovfdata/ova.ova \
908
	test/data/ovfdata/rawdisk.raw \
909
	test/data/ovfdata/second_disk.vmdk \
910
	test/data/ovfdata/unsafe_path.ini \
911
	test/data/ovfdata/virtualbox.ovf \
912
	test/data/ovfdata/wrong_config.ini \
913
	test/data/ovfdata/wrong_extension.ovd \
914
	test/data/ovfdata/wrong_manifest.mf \
915
	test/data/ovfdata/wrong_manifest.ovf \
916
	test/data/ovfdata/wrong_ova.ova \
917
	test/data/ovfdata/wrong_xml.ovf \
918
	test/data/proc_drbd8.txt \
919
	test/data/proc_drbd80-emptyline.txt \
920
	test/data/proc_drbd83.txt \
921
	test/data/proc_drbd83_sync.txt \
922
	test/data/proc_drbd83_sync_want.txt \
923
	test/data/proc_drbd83_sync_krnl2.6.39.txt \
924
	test/data/sys_drbd_usermode_helper.txt \
925
	test/data/vgreduce-removemissing-2.02.02.txt \
926
	test/data/vgreduce-removemissing-2.02.66-fail.txt \
927
	test/data/vgreduce-removemissing-2.02.66-ok.txt \
928
	test/data/vgs-missing-pvs-2.02.02.txt \
929
	test/data/vgs-missing-pvs-2.02.66.txt \
930
	test/ganeti-cli.test \
931
	test/gnt-cli.test \
932
	test/import-export_unittest-helper
933

    
934
python_tests = \
935
	doc/examples/rapi_testutils.py \
936
	test/cfgupgrade_unittest.py \
937
	test/docs_unittest.py \
938
	test/ganeti.asyncnotifier_unittest.py \
939
	test/ganeti.backend_unittest-runasroot.py \
940
	test/ganeti.backend_unittest.py \
941
	test/ganeti.bdev_unittest.py \
942
	test/ganeti.cli_unittest.py \
943
	test/ganeti.client.gnt_cluster_unittest.py \
944
	test/ganeti.client.gnt_instance_unittest.py \
945
	test/ganeti.client.gnt_job_unittest.py \
946
	test/ganeti.cmdlib_unittest.py \
947
	test/ganeti.compat_unittest.py \
948
	test/ganeti.confd.client_unittest.py \
949
	test/ganeti.config_unittest.py \
950
	test/ganeti.constants_unittest.py \
951
	test/ganeti.daemon_unittest.py \
952
	test/ganeti.errors_unittest.py \
953
	test/ganeti.hooks_unittest.py \
954
	test/ganeti.ht_unittest.py \
955
	test/ganeti.http_unittest.py \
956
	test/ganeti.hypervisor.hv_chroot_unittest.py \
957
	test/ganeti.hypervisor.hv_fake_unittest.py \
958
	test/ganeti.hypervisor.hv_kvm_unittest.py \
959
	test/ganeti.hypervisor.hv_lxc_unittest.py \
960
	test/ganeti.hypervisor.hv_xen_unittest.py \
961
	test/ganeti.hypervisor_unittest.py \
962
	test/ganeti.impexpd_unittest.py \
963
	test/ganeti.jqueue_unittest.py \
964
	test/ganeti.jstore_unittest.py \
965
	test/ganeti.locking_unittest.py \
966
	test/ganeti.luxi_unittest.py \
967
	test/ganeti.masterd.iallocator_unittest.py \
968
	test/ganeti.masterd.instance_unittest.py \
969
	test/ganeti.mcpu_unittest.py \
970
	test/ganeti.netutils_unittest.py \
971
	test/ganeti.objects_unittest.py \
972
	test/ganeti.objectutils_unittest.py \
973
	test/ganeti.opcodes_unittest.py \
974
	test/ganeti.ovf_unittest.py \
975
	test/ganeti.qlang_unittest.py \
976
	test/ganeti.query_unittest.py \
977
	test/ganeti.rapi.baserlib_unittest.py \
978
	test/ganeti.rapi.client_unittest.py \
979
	test/ganeti.rapi.resources_unittest.py \
980
	test/ganeti.rapi.rlib2_unittest.py \
981
	test/ganeti.rapi.testutils_unittest.py \
982
	test/ganeti.rpc_unittest.py \
983
	test/ganeti.runtime_unittest.py \
984
	test/ganeti.serializer_unittest.py \
985
	test/ganeti.server.rapi_unittest.py \
986
	test/ganeti.ssconf_unittest.py \
987
	test/ganeti.ssh_unittest.py \
988
	test/ganeti.storage_unittest.py \
989
	test/ganeti.tools.ensure_dirs_unittest.py \
990
	test/ganeti.tools.node_daemon_setup_unittest.py \
991
	test/ganeti.tools.prepare_node_join_unittest.py \
992
	test/ganeti.uidpool_unittest.py \
993
	test/ganeti.utils.algo_unittest.py \
994
	test/ganeti.utils.filelock_unittest.py \
995
	test/ganeti.utils.hash_unittest.py \
996
	test/ganeti.utils.io_unittest-runasroot.py \
997
	test/ganeti.utils.io_unittest.py \
998
	test/ganeti.utils.log_unittest.py \
999
	test/ganeti.utils.mlock_unittest.py \
1000
	test/ganeti.utils.nodesetup_unittest.py \
1001
	test/ganeti.utils.process_unittest.py \
1002
	test/ganeti.utils.retry_unittest.py \
1003
	test/ganeti.utils.text_unittest.py \
1004
	test/ganeti.utils.wrapper_unittest.py \
1005
	test/ganeti.utils.x509_unittest.py \
1006
	test/ganeti.utils_unittest.py \
1007
	test/ganeti.vcluster_unittest.py \
1008
	test/ganeti.workerpool_unittest.py \
1009
	test/pycurl_reset_unittest.py \
1010
	test/qa.qa_config_unittest.py \
1011
	test/tempfile_fork_unittest.py
1012

    
1013
haskell_tests = htest/test
1014

    
1015
dist_TESTS = \
1016
	test/check-cert-expired_unittest.bash \
1017
	test/daemon-util_unittest.bash \
1018
	test/ganeti-cleaner_unittest.bash \
1019
	test/import-export_unittest.bash \
1020
	test/cli-test.bash \
1021
	test/bash_completion.bash \
1022
	$(python_tests)
1023

    
1024
nodist_TESTS =
1025
check_SCRIPTS =
1026

    
1027
if WANT_HTOOLSTESTS
1028
nodist_TESTS += $(haskell_tests)
1029
dist_TESTS += htest/offline-test.sh
1030
check_SCRIPTS += htest/hpc-htools $(HS_BUILT_TEST_HELPERS)
1031
endif
1032

    
1033
TESTS = $(dist_TESTS) $(nodist_TESTS)
1034

    
1035
# Environment for all tests
1036
PLAIN_TESTS_ENVIRONMENT = \
1037
	PYTHONPATH=. \
1038
	TOP_SRCDIR=$(abs_top_srcdir) TOP_BUILDDIR=$(abs_top_builddir) \
1039
	PYTHON=$(PYTHON) FAKEROOT=$(FAKEROOT_PATH) \
1040
	$(RUN_IN_TEMPDIR)
1041

    
1042
# Environment for tests run by automake
1043
TESTS_ENVIRONMENT = \
1044
	$(PLAIN_TESTS_ENVIRONMENT) $(abs_top_srcdir)/autotools/testrunner
1045

    
1046
all_python_code = \
1047
	$(dist_sbin_SCRIPTS) \
1048
	$(python_scripts) \
1049
	$(pkglib_python_scripts) \
1050
	$(nodist_pkglib_python_scripts) \
1051
	$(nodist_tools_python_scripts) \
1052
	$(python_tests) \
1053
	$(pkgpython_PYTHON) \
1054
	$(client_PYTHON) \
1055
	$(hypervisor_PYTHON) \
1056
	$(rapi_PYTHON) \
1057
	$(server_PYTHON) \
1058
	$(pytools_PYTHON) \
1059
	$(http_PYTHON) \
1060
	$(confd_PYTHON) \
1061
	$(masterd_PYTHON) \
1062
	$(impexpd_PYTHON) \
1063
	$(utils_PYTHON) \
1064
	$(watcher_PYTHON) \
1065
	$(noinst_PYTHON) \
1066
	$(qa_scripts)
1067

    
1068
srclink_files = \
1069
	man/footer.rst \
1070
	test/check-cert-expired_unittest.bash \
1071
	test/daemon-util_unittest.bash \
1072
	test/ganeti-cleaner_unittest.bash \
1073
	test/import-export_unittest.bash \
1074
	test/cli-test.bash \
1075
	test/bash_completion.bash \
1076
	htest/offline-test.sh \
1077
	htest/cli-tests-defs.sh \
1078
	$(all_python_code) \
1079
	$(HS_LIBTEST_SRCS) $(HS_PROG_SRCS)
1080

    
1081
check_python_code = \
1082
	$(BUILD_BASH_COMPLETION) \
1083
	$(CHECK_IMPORTS) \
1084
	$(CHECK_HEADER) \
1085
	$(DOCPP) \
1086
	$(all_python_code)
1087

    
1088
lint_python_code = \
1089
	ganeti \
1090
	ganeti/http/server.py \
1091
	$(dist_sbin_SCRIPTS) \
1092
	$(python_scripts) \
1093
	$(pkglib_python_scripts) \
1094
	$(BUILD_BASH_COMPLETION) \
1095
	$(CHECK_IMPORTS) \
1096
	$(CHECK_HEADER) \
1097
	$(DOCPP) \
1098
	$(PYTHON_BOOTSTRAP)
1099

    
1100
standalone_python_modules = \
1101
	lib/rapi/client.py \
1102
	tools/ganeti-listrunner
1103

    
1104
pep8_python_code = \
1105
	ganeti \
1106
	ganeti/http/server.py \
1107
	$(dist_sbin_SCRIPTS) \
1108
	$(python_scripts) \
1109
	$(pkglib_python_scripts) \
1110
	$(BUILD_BASH_COMPLETION) \
1111
	$(CHECK_HEADER) \
1112
	$(DOCPP) \
1113
	$(PYTHON_BOOTSTRAP) \
1114
	qa
1115

    
1116
test/daemon-util_unittest.bash: daemons/daemon-util
1117

    
1118
test/ganeti-cleaner_unittest.bash: daemons/ganeti-cleaner
1119

    
1120
test/bash_completion.bash: doc/examples/bash_completion-debug
1121

    
1122
tools/kvm-ifup: tools/kvm-ifup.in $(REPLACE_VARS_SED)
1123
	sed -f $(REPLACE_VARS_SED) < $< > $@
1124
	chmod +x $@
1125

    
1126
tools/vcluster-setup: tools/vcluster-setup.in $(REPLACE_VARS_SED)
1127
	sed -f $(REPLACE_VARS_SED) < $< > $@
1128
	chmod +x $@
1129

    
1130
daemons/%:: daemons/%.in $(REPLACE_VARS_SED)
1131
	sed -f $(REPLACE_VARS_SED) < $< > $@
1132
	chmod +x $@
1133

    
1134
doc/examples/%:: doc/examples/%.in $(REPLACE_VARS_SED)
1135
	sed -f $(REPLACE_VARS_SED) < $< > $@
1136

    
1137
doc/examples/bash_completion: BC_ARGS = --compact
1138
doc/examples/bash_completion-debug: BC_ARGS =
1139

    
1140
doc/examples/bash_completion doc/examples/bash_completion-debug: \
1141
	$(BUILD_BASH_COMPLETION) $(RUN_IN_TEMPDIR) \
1142
	lib/cli.py $(gnt_scripts) $(client_PYTHON) tools/burnin \
1143
	daemons/ganeti-cleaner \
1144
	$(GENERATED_FILES) $(HTOOLS_GENERATED_FILES)
1145
	PYTHONPATH=. $(RUN_IN_TEMPDIR) \
1146
	  $(CURDIR)/$(BUILD_BASH_COMPLETION) $(BC_ARGS) > $@
1147

    
1148
doc/%.png: doc/%.dot
1149
	@test -n "$(DOT)" || { echo 'dot' not found during configure; exit 1; }
1150
	$(DOT) -Tpng -o $@ $<
1151

    
1152
man/footer.man: man/footer.rst
1153
	@test -n "$(PANDOC)" || \
1154
	  { echo 'pandoc' not found during configure; exit 1; }
1155
	$(PANDOC) -f rst -t man -o $@ $<
1156

    
1157
man/footer.html: man/footer.rst
1158
	@test -n "$(PANDOC)" || \
1159
	  { echo 'pandoc' not found during configure; exit 1; }
1160
	$(PANDOC) -f rst -t html -o $@ $<
1161

    
1162
man/%.gen: man/%.rst lib/query.py lib/build/sphinx_ext.py \
1163
	lib/build/shell_example_lexer.py \
1164
	| $(RUN_IN_TEMPDIR) $(BUILT_PYTHON_SOURCES)
1165
	@echo "Checking $< for hardcoded paths..."
1166
	@if grep -nEf autotools/wrong-hardcoded-paths $<; then \
1167
	  echo "Man page $< has harcoded paths (see above)!" 1>&2 ; \
1168
	  exit 1; \
1169
	fi
1170
	set -e ; \
1171
	trap 'echo auto-removing $@; rm $@' EXIT; \
1172
	PYTHONPATH=. $(RUN_IN_TEMPDIR) $(CURDIR)/$(DOCPP) < $< > $@ ;\
1173
	trap - EXIT
1174

    
1175
man/%.7.in man/%.8.in man/%.1.in: man/%.gen man/footer.man
1176
	@test -n "$(PANDOC)" || \
1177
	  { echo 'pandoc' not found during configure; exit 1; }
1178
	set -o pipefail ; \
1179
	trap 'echo auto-removing $@; rm $@' EXIT; \
1180
	$(PANDOC) -s -f rst -t man -A man/footer.man $< | \
1181
	  sed -e 's/\\@/@/g' > $@; \
1182
	if test -n "$(MAN_HAS_WARNINGS)"; then $(CHECK_MAN_WARNINGS) $@; fi; \
1183
	$(CHECK_MAN_DASHES) $@; \
1184
	trap - EXIT
1185

    
1186

    
1187
man/%.html.in: man/%.gen man/footer.html
1188
	@test -n "$(PANDOC)" || \
1189
	  { echo 'pandoc' not found during configure; exit 1; }
1190
	set -o pipefail ; \
1191
	$(PANDOC) -s -f rst -t html -A man/footer.html $< | \
1192
	  sed -e 's/\\@/@/g' > $@
1193

    
1194
man/%: man/%.in  $(REPLACE_VARS_SED)
1195
	sed -f $(REPLACE_VARS_SED) < $< > $@
1196

    
1197
epydoc.conf: epydoc.conf.in $(REPLACE_VARS_SED)
1198
	sed -f $(REPLACE_VARS_SED) < $< > $@
1199

    
1200
vcs-version:
1201
	if test -d .git; then \
1202
	  git describe > $@; \
1203
	elif test ! -f $@ ; then \
1204
	  echo "Cannot auto-generate $@ file"; exit 1; \
1205
	fi
1206

    
1207
.PHONY: clean-vcs-version
1208
clean-vcs-version:
1209
	rm -f vcs-version
1210

    
1211
.PHONY: regen-vcs-version
1212
regen-vcs-version:
1213
	@set -e; \
1214
	cd $(srcdir); \
1215
	if test -d .git; then \
1216
	  T=`mktemp` ; trap 'rm -f $$T' EXIT; \
1217
	  git describe > $$T; \
1218
	  if ! cmp --quiet $$T vcs-version; then \
1219
	    mv $$T vcs-version; \
1220
	  fi; \
1221
	fi
1222

    
1223
htools/Ganeti/Version.hs: htools/Ganeti/Version.hs.in \
1224
	vcs-version $(built_base_sources)
1225
	set -e; \
1226
	VCSVER=`cat $(abs_top_srcdir)/vcs-version`; \
1227
	sed -e "s/%ver%/$$VCSVER/" < $< > $@
1228

    
1229
htools/Ganeti/Constants.hs: htools/Ganeti/Constants.hs.in \
1230
	lib/constants.py lib/_autoconf.py lib/luxi.py lib/errors.py \
1231
	$(CONVERT_CONSTANTS) $(built_base_sources) \
1232
	| lib/_vcsversion.py
1233
	set -e; \
1234
	{ cat $< ; PYTHONPATH=. $(CONVERT_CONSTANTS); } > $@
1235

    
1236
htest/Test/Ganeti/TestImports.hs: htest/Test/Ganeti/TestImports.hs.in \
1237
	$(built_base_sources)
1238
	set -e; \
1239
	{ cat $< ; \
1240
	  echo ; \
1241
	  for name in $(filter-out Ganeti.THH,$(subst /,.,$(patsubst %.hs,%,$(patsubst htools/%,%,$(HS_LIB_SRCS))))) ; do \
1242
	    echo "import $$name ()" ; \
1243
	  done ; \
1244
	} > $@
1245

    
1246
lib/_autoconf.py: Makefile | stamp-directories
1247
	set -e; \
1248
	{ echo '# This file is automatically generated, do not edit!'; \
1249
	  echo '#'; \
1250
	  echo ''; \
1251
	  echo '"""Build-time configuration for Ganeti.'; \
1252
	  echo '';\
1253
	  echo 'This file is autogenerated by the build process.'; \
1254
	  echo 'For any changes you need to re-run ./configure (and'; \
1255
	  echo 'not edit by hand).'; \
1256
	  echo ''; \
1257
	  echo '"""'; \
1258
	  echo ''; \
1259
	  echo '# pylint: disable=C0301,C0324'; \
1260
	  echo '# because this is autogenerated, we do not want'; \
1261
	  echo '# style warnings' ; \
1262
	  echo ''; \
1263
	  echo "PACKAGE_VERSION = '$(PACKAGE_VERSION)'"; \
1264
	  echo "VERSION_MAJOR = '$(VERSION_MAJOR)'"; \
1265
	  echo "VERSION_MINOR = '$(VERSION_MINOR)'"; \
1266
	  echo "VERSION_REVISION = '$(VERSION_REVISION)'"; \
1267
	  echo "VERSION_SUFFIX = '$(VERSION_SUFFIX)'"; \
1268
	  echo "VERSION_FULL = '$(VERSION_FULL)'"; \
1269
	  echo "LOCALSTATEDIR = '$(localstatedir)'"; \
1270
	  echo "SYSCONFDIR = '$(sysconfdir)'"; \
1271
	  echo "SSH_CONFIG_DIR = '$(SSH_CONFIG_DIR)'"; \
1272
	  echo "SSH_LOGIN_USER = '$(SSH_LOGIN_USER)'"; \
1273
	  echo "SSH_CONSOLE_USER = '$(SSH_CONSOLE_USER)'"; \
1274
	  echo "EXPORT_DIR = '$(EXPORT_DIR)'"; \
1275
	  echo "OS_SEARCH_PATH = [$(OS_SEARCH_PATH)]"; \
1276
	  echo "XEN_BOOTLOADER = '$(XEN_BOOTLOADER)'"; \
1277
	  echo "XEN_KERNEL = '$(XEN_KERNEL)'"; \
1278
	  echo "XEN_INITRD = '$(XEN_INITRD)'"; \
1279
	  echo "KVM_KERNEL = '$(KVM_KERNEL)'"; \
1280
	  echo "FILE_STORAGE_DIR = '$(FILE_STORAGE_DIR)'"; \
1281
	  echo "ENABLE_FILE_STORAGE = $(ENABLE_FILE_STORAGE)"; \
1282
	  echo "SHARED_FILE_STORAGE_DIR = '$(SHARED_FILE_STORAGE_DIR)'"; \
1283
	  echo "ENABLE_SHARED_FILE_STORAGE = $(ENABLE_SHARED_FILE_STORAGE)"; \
1284
	  echo "IALLOCATOR_SEARCH_PATH = [$(IALLOCATOR_SEARCH_PATH)]"; \
1285
	  echo "KVM_PATH = '$(KVM_PATH)'"; \
1286
	  echo "IP_PATH = '$(IP_PATH)'"; \
1287
	  echo "SOCAT_PATH = '$(SOCAT)'"; \
1288
	  echo "SOCAT_USE_ESCAPE = $(SOCAT_USE_ESCAPE)"; \
1289
	  echo "SOCAT_USE_COMPRESS = $(SOCAT_USE_COMPRESS)"; \
1290
	  echo "LVM_STRIPECOUNT = $(LVM_STRIPECOUNT)"; \
1291
	  echo "TOOLSDIR = '$(toolsdir)'"; \
1292
	  echo "GNT_SCRIPTS = [$(foreach i,$(notdir $(gnt_scripts)),'$(i)',)]"; \
1293
	  echo "HTOOLS_PROGS = [$(foreach i,$(HS_HTOOLS_PROGS),'$(i)',)]"; \
1294
	  echo "PKGLIBDIR = '$(pkglibdir)'"; \
1295
	  echo "DRBD_BARRIERS = '$(DRBD_BARRIERS)'"; \
1296
	  echo "DRBD_NO_META_FLUSH = $(DRBD_NO_META_FLUSH)"; \
1297
	  echo "SYSLOG_USAGE = '$(SYSLOG_USAGE)'"; \
1298
	  echo "DAEMONS_GROUP = '$(DAEMONS_GROUP)'"; \
1299
	  echo "ADMIN_GROUP = '$(ADMIN_GROUP)'"; \
1300
	  echo "MASTERD_USER = '$(MASTERD_USER)'"; \
1301
	  echo "MASTERD_GROUP = '$(MASTERD_GROUP)'"; \
1302
	  echo "RAPI_USER = '$(RAPI_USER)'"; \
1303
	  echo "RAPI_GROUP = '$(RAPI_GROUP)'"; \
1304
	  echo "CONFD_USER = '$(CONFD_USER)'"; \
1305
	  echo "CONFD_GROUP = '$(CONFD_GROUP)'"; \
1306
	  echo "NODED_USER = '$(NODED_USER)'"; \
1307
	  echo "NODED_GROUP = '$(NODED_GROUP)'"; \
1308
	  echo "DISK_SEPARATOR = '$(DISK_SEPARATOR)'"; \
1309
	  echo "QEMUIMG_PATH = '$(QEMUIMG_PATH)'"; \
1310
	  echo "HTOOLS = True"; \
1311
	  echo "ENABLE_CONFD = $(ENABLE_CONFD)"; \
1312
	  echo "XEN_CMD = '$(XEN_CMD)'"; \
1313
	  echo "ENABLE_SPLIT_QUERY = $(ENABLE_SPLIT_QUERY)"; \
1314
	  echo "ENABLE_RESTRICTED_COMMANDS = $(ENABLE_RESTRICTED_COMMANDS)"; \
1315
	} > $@
1316

    
1317
lib/_vcsversion.py: Makefile vcs-version | stamp-directories
1318
	set -e; \
1319
	VCSVER=`cat $(abs_top_srcdir)/vcs-version`; \
1320
	{ echo '# This file is automatically generated, do not edit!'; \
1321
	  echo '#'; \
1322
	  echo ''; \
1323
	  echo '"""Build-time VCS version number for Ganeti.'; \
1324
	  echo '';\
1325
	  echo 'This file is autogenerated by the build process.'; \
1326
	  echo 'For any changes you need to re-run ./configure (and'; \
1327
	  echo 'not edit by hand).'; \
1328
	  echo ''; \
1329
	  echo '"""'; \
1330
	  echo ''; \
1331
	  echo '# pylint: disable=C0301,C0324'; \
1332
	  echo '# because this is autogenerated, we do not want'; \
1333
	  echo '# style warnings' ; \
1334
	  echo ''; \
1335
	  echo "VCS_VERSION = '$$VCSVER'"; \
1336
	} > $@
1337

    
1338
lib/_generated_rpc.py: lib/rpc_defs.py $(BUILD_RPC)
1339
	PYTHONPATH=. $(RUN_IN_TEMPDIR) $(CURDIR)/$(BUILD_RPC) lib/rpc_defs.py > $@
1340

    
1341
$(SHELL_ENV_INIT): Makefile stamp-directories
1342
	set -e; \
1343
	{ echo '# Allow overriding for tests'; \
1344
	  echo 'readonly LOCALSTATEDIR=$${LOCALSTATEDIR:-$${GANETI_ROOTDIR:-}$(localstatedir)}'; \
1345
	  echo 'readonly SYSCONFDIR=$${SYSCONFDIR:-$${GANETI_ROOTDIR:-}$(sysconfdir)}'; \
1346
	  echo; \
1347
	  echo 'readonly PKGLIBDIR=$(pkglibdir)'; \
1348
	  echo 'readonly LOG_DIR="$$LOCALSTATEDIR/log/ganeti"'; \
1349
	  echo 'readonly RUN_DIR="$$LOCALSTATEDIR/run/ganeti"'; \
1350
	  echo 'readonly DATA_DIR="$$LOCALSTATEDIR/lib/ganeti"'; \
1351
	  echo 'readonly CONF_DIR="$$SYSCONFDIR/ganeti"'; \
1352
	} > $@
1353

    
1354
$(REPLACE_VARS_SED): $(SHELL_ENV_INIT) Makefile stamp-directories
1355
	set -e; \
1356
	{ echo 's#@PREFIX@#$(prefix)#g'; \
1357
	  echo 's#@SYSCONFDIR@#$(sysconfdir)#g'; \
1358
	  echo 's#@LOCALSTATEDIR@#$(localstatedir)#g'; \
1359
	  echo 's#@BINDIR@#$(bindir)#g'; \
1360
	  echo 's#@SBINDIR@#$(sbindir)#g'; \
1361
	  echo 's#@LIBDIR@#$(libdir)#g'; \
1362
	  echo 's#@GANETI_VERSION@#$(PACKAGE_VERSION)#g'; \
1363
	  echo 's#@CUSTOM_XEN_BOOTLOADER@#$(XEN_BOOTLOADER)#g'; \
1364
	  echo 's#@CUSTOM_XEN_KERNEL@#$(XEN_KERNEL)#g'; \
1365
	  echo 's#@CUSTOM_XEN_INITRD@#$(XEN_INITRD)#g'; \
1366
	  echo 's#@CUSTOM_IALLOCATOR_SEARCH_PATH@#$(IALLOCATOR_SEARCH_PATH)#g'; \
1367
	  echo 's#@CUSTOM_EXPORT_DIR@#$(EXPORT_DIR)#g'; \
1368
	  echo 's#@RPL_FILE_STORAGE_DIR@#$(FILE_STORAGE_DIR)#g'; \
1369
	  echo 's#@RPL_SSH_INITD_SCRIPT@#$(SSH_INITD_SCRIPT)#g'; \
1370
	  echo 's#@PKGLIBDIR@#$(pkglibdir)#g'; \
1371
	  echo 's#@GNTMASTERUSER@#$(MASTERD_USER)#g'; \
1372
	  echo 's#@GNTRAPIUSER@#$(RAPI_USER)#g'; \
1373
	  echo 's#@GNTCONFDUSER@#$(CONFD_USER)#g'; \
1374
	  echo 's#@GNTNODEDUSER@#$(NODED_USER)#g'; \
1375
	  echo 's#@GNTRAPIGROUP@#$(RAPI_GROUP)#g'; \
1376
	  echo 's#@GNTADMINGROUP@#$(ADMIN_GROUP)#g'; \
1377
	  echo 's#@GNTCONFDGROUP@#$(CONFD_GROUP)#g'; \
1378
	  echo 's#@GNTMASTERDGROUP@#$(MASTERD_GROUP)#g'; \
1379
	  echo 's#@GNTDAEMONSGROUP@#$(DAEMONS_GROUP)#g'; \
1380
	  echo 's#@CUSTOM_ENABLE_CONFD@#$(ENABLE_CONFD)#g'; \
1381
	  echo 's#@MODULES@#$(strip $(lint_python_code))#g'; \
1382
	  echo 's#@ENABLE_SPLIT_QUERY@#$(ENABLE_SPLIT_QUERY)#g'; \
1383
	  echo; \
1384
	  echo '/^@SHELL_ENV_INIT@$$/ {'; \
1385
	  echo '  r $(SHELL_ENV_INIT)'; \
1386
	  echo '  d'; \
1387
	  echo '}'; \
1388
	} > $@
1389

    
1390
# Using deferred evaluation
1391
daemons/ganeti-%: MODULE = ganeti.server.$(patsubst ganeti-%,%,$(notdir $@))
1392
daemons/ganeti-watcher: MODULE = ganeti.watcher
1393
scripts/%: MODULE = ganeti.client.$(subst -,_,$(notdir $@))
1394
tools/ensure-dirs: MODULE = ganeti.tools.ensure_dirs
1395
tools/node-daemon-setup: MODULE = ganeti.tools.node_daemon_setup
1396
tools/prepare-node-join: MODULE = ganeti.tools.prepare_node_join
1397
tools/node-cleanup: MODULE = ganeti.tools.node_cleanup
1398
$(HS_BUILT_TEST_HELPERS): TESTROLE = $(patsubst htest/%,%,$@)
1399

    
1400
$(PYTHON_BOOTSTRAP): Makefile | stamp-directories
1401
	test -n "$(MODULE)" || { echo Missing module; exit 1; }
1402
	set -e; \
1403
	{ echo '#!/usr/bin/python'; \
1404
	  echo '# This file is automatically generated, do not edit!'; \
1405
	  echo "# Edit $(MODULE) instead."; \
1406
	  echo; \
1407
	  echo '"""Bootstrap script for L{$(MODULE)}"""'; \
1408
	  echo; \
1409
	  echo '# pylint: disable=C0103'; \
1410
	  echo '# C0103: Invalid name'; \
1411
	  echo; \
1412
	  echo 'import sys'; \
1413
	  echo 'import $(MODULE) as main'; \
1414
	  echo; \
1415
	  echo '# Temporarily alias commands until bash completion'; \
1416
	  echo '# generator is changed'; \
1417
	  echo 'if hasattr(main, "commands"):'; \
1418
	  echo '  commands = main.commands # pylint: disable=E1101'; \
1419
	  echo 'if hasattr(main, "aliases"):'; \
1420
	  echo '  aliases = main.aliases # pylint: disable=E1101'; \
1421
	  echo; \
1422
	  echo 'if __name__ == "__main__":'; \
1423
	  echo '  sys.exit(main.Main())'; \
1424
	} > $@
1425
	chmod u+x $@
1426

    
1427
$(HS_BUILT_TEST_HELPERS): Makefile
1428
	@test -n "$(TESTROLE)" || { echo Missing TESTROLE; exit 1; }
1429
	set -e; \
1430
	{ echo '#!/bin/sh'; \
1431
	  echo '# This file is automatically generated, do not edit!'; \
1432
	  echo "# Edit Makefile.am instead."; \
1433
	  echo; \
1434
	  echo "HTOOLS=$(TESTROLE) exec ./htest/hpc-htools \"\$$@\""; \
1435
	} > $@
1436
	chmod u+x $@
1437

    
1438
stamp-directories: Makefile
1439
	$(MAKE) $(AM_MAKEFLAGS) ganeti
1440
	@mkdir_p@ $(DIRS) $(BUILDTIME_DIR_AUTOCREATE)
1441
	touch $@
1442

    
1443
# We need to create symlinks because "make distcheck" will not install Python
1444
# files when building.
1445
stamp-srclinks: Makefile | stamp-directories
1446
	set -e; \
1447
	for i in $(srclink_files); do \
1448
	  if test ! -f $$i -a -f $(abs_top_srcdir)/$$i; then \
1449
	    $(LN_S) $(abs_top_srcdir)/$$i $$i; \
1450
	  fi; \
1451
	done
1452
	touch $@
1453

    
1454
.PHONY: ganeti
1455
ganeti:
1456
	cd $(top_builddir) && test -h "$@" || { rm -f $@ && $(LN_S) lib $@; }
1457

    
1458
.PHONY: check-dirs
1459
check-dirs: $(GENERATED_FILES)
1460
	@set -e; \
1461
	find . -type d \( -name . -o -name .git -prune -o -print \) | { \
1462
	  error=; \
1463
	  while read dir; do \
1464
	    case "$$dir" in \
1465
	      $(strip $(patsubst %,(./%) ;;,$(DIRCHECK_EXCLUDE) $(DIRS))) \
1466
	      *) error=1; echo "Directory $$dir not listed in Makefile" >&2 ;; \
1467
	    esac; \
1468
	  done; \
1469
	  for dir in $(DIRS); do \
1470
	    if ! test -d "$$dir"; then \
1471
	      echo "Directory $$dir listed in DIRS does not exist" >&2; \
1472
	      error=1; \
1473
	    fi \
1474
	  done; \
1475
	  test -z "$$error"; \
1476
	}
1477

    
1478
.PHONY: check-local
1479
check-local: check-dirs $(GENERATED_FILES)
1480
	$(CHECK_PYTHON_CODE) $(check_python_code)
1481
	PYTHONPATH=. $(CHECK_HEADER) $(check_python_code)
1482
	$(CHECK_VERSION) $(VERSION) $(top_srcdir)/NEWS
1483
	$(CHECK_NEWS) < $(top_srcdir)/NEWS
1484
	PYTHONPATH=. $(RUN_IN_TEMPDIR) $(CURDIR)/$(CHECK_IMPORTS) . $(standalone_python_modules)
1485
	@expver=$(VERSION_MAJOR).$(VERSION_MINOR); \
1486
	if test "`head -n 1 $(top_srcdir)/README`" != "Ganeti $$expver"; then \
1487
	  echo "Incorrect version in README, expected $$expver"; \
1488
	  exit 1; \
1489
	fi; \
1490
	for file in doc/iallocator.rst doc/hooks.rst doc/virtual-cluster.rst \
1491
	    doc/security.rst; do \
1492
	  if test "`sed -ne '4 p' $(top_srcdir)/$$file`" != \
1493
	    "Documents Ganeti version $$expver"; then \
1494
	    echo "Incorrect version in $$file, expected $$expver"; \
1495
	    exit 1; \
1496
	  fi; \
1497
	done; \
1498
	if ! test -f $(top_srcdir)/doc/design-$$expver.rst; then \
1499
	  echo "File $(top_srcdir)/doc/design-$$expver.rst not found"; \
1500
	  exit 1; \
1501
	fi; \
1502
	error= ; \
1503
	for file in configure.ac $(HS_LIBTEST_SRCS) $(HS_PROG_SRCS); do \
1504
	  if test $$(wc --max-line-length < $(top_srcdir)/$$file) -gt 80; then \
1505
	    echo "Longest line in $$file is longer than 80 characters" >&2; \
1506
	    error=1; \
1507
	  fi; \
1508
	done; \
1509
	test -z "$$error"
1510

    
1511
.PHONY: hs-check
1512
hs-check: htest/test htest/hpc-htools $(HS_BUILT_TEST_HELPERS)
1513
	@rm -f test.tix
1514
	./htest/test
1515
	HBINARY="./htest/hpc-htools" ./htest/offline-test.sh
1516

    
1517
# E111: indentation is not a multiple of four
1518
# E121: continuation line indentation is not a multiple of four
1519
#       (since our indent level is not 4)
1520
# E125: continuation line does not distinguish itself from next logical line
1521
#       (since our indent level is not 4)
1522
# E127: continuation line over-indented for visual indent
1523
#       (since our indent level is not 4)
1524
# note: do NOT add E128 here; it's a valid style error in most cases!
1525
# I've seen real errors, but also some cases were we indent wrongly
1526
# due to line length; try to rework the cases where it is triggered,
1527
# instead of silencing it
1528
# E261: at least two spaces before inline comment
1529
# E501: line too long (80 characters)
1530
PEP8_IGNORE = E111,E121,E125,E127,E261,E501
1531

    
1532
# For excluding pep8 expects filenames only, not whole paths
1533
PEP8_EXCLUDE = $(subst $(space),$(comma),$(strip $(notdir $(BUILT_PYTHON_SOURCES))))
1534

    
1535
LINT_TARGETS = pylint pylint-qa
1536
if HAS_PEP8
1537
LINT_TARGETS += pep8
1538
endif
1539
if HAS_HLINT
1540
LINT_TARGETS += hlint
1541
endif
1542

    
1543
.PHONY: lint
1544
lint: $(LINT_TARGETS)
1545

    
1546
.PHONY: pylint
1547
pylint: $(GENERATED_FILES)
1548
	@test -n "$(PYLINT)" || { echo 'pylint' not found during configure; exit 1; }
1549
	$(PYLINT) $(LINT_OPTS) $(lint_python_code)
1550

    
1551
.PHONY: pylint-qa
1552
pylint-qa: $(GENERATED_FILES)
1553
	@test -n "$(PYLINT)" || { echo 'pylint' not found during configure; exit 1; }
1554
	cd $(top_srcdir)/qa && \
1555
	  PYTHONPATH=$(abs_top_srcdir) $(PYLINT) $(LINT_OPTS) \
1556
	  --rcfile  ../pylintrc $(patsubst qa/%.py,%,$(qa_scripts))
1557

    
1558
.PHONY: pep8
1559
pep8: $(GENERATED_FILES)
1560
	@test -n "$(PEP8)" || { echo 'pep8' not found during configure; exit 1; }
1561
	$(PEP8) --ignore='$(PEP8_IGNORE)' --exclude='$(PEP8_EXCLUDE)' \
1562
	  --repeat $(pep8_python_code)
1563

    
1564
# FIXME: remove ignore "Use void" when GHC 6.x is deprecated
1565
HLINT_EXCLUDES = htools/Ganeti/THH.hs htest/hpc-htools.hs
1566
.PHONY: hlint
1567
hlint: $(HS_BUILT_SRCS) htools/lint-hints.hs
1568
	@test -n "$(HLINT)" || { echo 'hlint' not found during configure; exit 1; }
1569
	if tty -s; then C="-c"; else C=""; fi; \
1570
	$(HLINT) --utf8 --report=doc/hs-lint.html --cross $$C \
1571
	  --ignore "Use first" \
1572
	  --ignore "Use comparing" \
1573
	  --ignore "Use on" \
1574
	  --ignore "Reduce duplication" \
1575
	  --ignore "Use &&&" \
1576
	  --ignore "Use void" \
1577
	  --hint htools/lint-hints \
1578
	  $(filter-out $(HLINT_EXCLUDES),$(HS_LIBTEST_SRCS) $(HS_PROG_SRCS))
1579

    
1580
# a dist hook rule for updating the vcs-version file; this is
1581
# hardcoded due to where it needs to build the file...
1582
dist-hook:
1583
	$(MAKE) $(AM_MAKEFLAGS) regen-vcs-version
1584
	rm -f $(top_distdir)/vcs-version
1585
	cp -p $(srcdir)/vcs-version $(top_distdir)
1586

    
1587
# a distcheck hook rule for catching revision control directories
1588
distcheck-hook:
1589
	if find $(top_distdir) -name .svn -or -name .git | grep .; then \
1590
	  echo "Found revision control files in final archive." 1>&2; \
1591
	  exit 1; \
1592
	fi
1593
	if find $(top_distdir) -name '*.py[co]' | grep .; then \
1594
	  echo "Found Python byte code in final archive." 1>&2; \
1595
	  exit 1; \
1596
	fi
1597
	if find $(top_distdir) -name '*~' | grep .; then \
1598
	  echo "Found backup files in final archive." 1>&2; \
1599
	  exit 1; \
1600
	fi
1601
# Empty files or directories should not be distributed. They can cause
1602
# unnecessary warnings for packagers. Directories used by automake during
1603
# distcheck must be excluded.
1604
	if find $(top_distdir) -empty -and -not \( \
1605
	    -path $(top_distdir)/_build -or \
1606
	    -path $(top_distdir)/_inst \) | grep .; then \
1607
	  echo "Found empty files or directories in final archive." 1>&2; \
1608
	  exit 1; \
1609
	fi
1610
	if test -n "$(BUILD_RELEASE)" && \
1611
	   grep -n -H -E '^\*.*unreleased' $(top_distdir)/NEWS; then \
1612
	   echo "Found unreleased version in NEWS." >&2; \
1613
	   exit 1; \
1614
	fi
1615

    
1616
# When building a release, stricter checks should be used
1617
distcheck-release dist-release: export BUILD_RELEASE = 1
1618
distcheck-release: distcheck
1619

    
1620
distrebuildcheck: dist
1621
	set -e; \
1622
	builddir=$$(mktemp -d $(abs_srcdir)/distrebuildcheck.XXXXXXX); \
1623
	trap "echo Removing $$builddir; cd $(abs_srcdir); rm -rf $$builddir" EXIT; \
1624
	cd $$builddir; \
1625
	tar xzf $(abs_srcdir)/$(distdir).tar.gz; \
1626
	cd $(distdir); \
1627
	./configure; \
1628
	$(MAKE) maintainer-clean; \
1629
	cp $(abs_srcdir)/vcs-version .; \
1630
	./configure; \
1631
	$(MAKE) $(AM_MAKEFLAGS)
1632

    
1633
dist-release: dist
1634
	set -e; \
1635
	for i in $(DIST_ARCHIVES); do \
1636
	  echo -n "Checking $$i ... "; \
1637
	  autotools/check-tar < $$i; \
1638
	  echo OK; \
1639
	done
1640

    
1641
install-exec-local:
1642
	@mkdir_p@ "$(DESTDIR)${localstatedir}/lib/ganeti" \
1643
	  "$(DESTDIR)${localstatedir}/log/ganeti" \
1644
	  "$(DESTDIR)${localstatedir}/run/ganeti"
1645

    
1646
.PHONY: apidoc
1647
if WANT_HTOOLSAPIDOC
1648
apidoc: py-apidoc hs-apidoc
1649
else
1650
apidoc: py-apidoc
1651
endif
1652

    
1653
.PHONY: py-apidoc
1654
py-apidoc: epydoc.conf $(RUN_IN_TEMPDIR) $(GENERATED_FILES)
1655
	env - PATH="$$PATH" PYTHONPATH="$$PYTHONPATH" \
1656
	$(RUN_IN_TEMPDIR) epydoc -v \
1657
	  --conf $(CURDIR)/epydoc.conf \
1658
	  --output $(CURDIR)/$(APIDOC_PY_DIR)
1659

    
1660
.PHONY: hs-apidoc
1661
hs-apidoc: $(HS_BUILT_SRCS)
1662
	@test -n "$(HSCOLOUR)" || \
1663
	    { echo 'HsColour' not found during configure; exit 1; }
1664
	@test -n "$(HADDOCK)" || \
1665
	    { echo 'haddock' not found during configure; exit 1; }
1666
	rm -rf $(APIDOC_HS_DIR)/*
1667
	for i in $(ALL_APIDOC_HS_DIRS); do \
1668
	  @mkdir_p@ $$i; \
1669
	done
1670
	$(HSCOLOUR) -print-css > $(APIDOC_HS_DIR)/Ganeti/hscolour.css
1671
	$(LN_S) ../hscolour.css $(APIDOC_HS_DIR)/Ganeti/HTools/hscolour.css
1672
	$(LN_S) ../hscolour.css $(APIDOC_HS_DIR)/Ganeti/Confd/hscolour.css
1673
	set -e ; \
1674
	cd htools; \
1675
	if [ "$(HTOOLS_NOCURL)" ]; \
1676
	then OPTGHC="--optghc=$(HTOOLS_NOCURL)"; \
1677
	else OPTGHC=""; \
1678
	fi; \
1679
	if [ "$(HTOOLS_PARALLEL3)" ]; \
1680
	then OPTGHC="$$OPTGHC --optghc=$(HTOOLS_PARALLEL3)"; \
1681
	fi; \
1682
	if [ "$(HTOOLS_REGEX_PCRE)" ]; \
1683
	then OPTGHC="$$OPTGHC --optghc=$(HTOOLS_REGEX_PCRE)"; \
1684
	fi; \
1685
	RELSRCS="$(HS_LIB_SRCS:htools/%=%) $(patsubst htools/%,%,$(filter htools/%,$(HS_BUILT_SRCS)))"; \
1686
	for file in $$RELSRCS; do \
1687
	  hfile=`echo $$file|sed 's/\\.hs$$//'`.html; \
1688
	  $(HSCOLOUR) -css -anchor $$file > ../$(APIDOC_HS_DIR)/$$hfile ; \
1689
	done ; \
1690
	$(HADDOCK) --odir ../$(APIDOC_HS_DIR) --html --ignore-all-exports -w \
1691
	  -t ganeti -p haddock-prologue \
1692
	  --source-module="%{MODULE/.//}.html" \
1693
	  --source-entity="%{MODULE/.//}.html#%{NAME}" \
1694
	  $$OPTGHC \
1695
	  $(filter-out Ganeti/HTools/ExtLoader.hs,$(HS_LIB_SRCS:htools/%=%))
1696

    
1697
.PHONY: TAGS
1698
TAGS: $(GENERATED_FILES)
1699
	rm -f TAGS
1700
	$(GHC) -e ":etags" -v0 \
1701
	  $(filter-out -O -Werror,$(HFLAGS)) \
1702
	  $(HTOOLS_NOCURL) $(HTOOLS_PARALLEL3) $(HTOOLS_REGEX_PCRE) \
1703
	  $(HS_LIBTEST_SRCS)
1704
	find . -path './lib/*.py' -o -path './scripts/gnt-*' -o \
1705
	  -path './daemons/ganeti-*' -o -path './tools/*' -o \
1706
	  -path './qa/*.py' | \
1707
	  etags -l python -a -
1708

    
1709
.PHONY: coverage
1710
if WANT_HTOOLS
1711
coverage: py-coverage hs-coverage
1712
else
1713
coverage: py-coverage
1714
endif
1715

    
1716
.PHONY: py-coverage
1717
py-coverage: $(GENERATED_FILES) $(python_tests)
1718
	@test -n "$(PYCOVERAGE)" || \
1719
	    { echo 'python-coverage' not found during configure; exit 1; }
1720
	set -e; \
1721
	COVERAGE=$(PYCOVERAGE) \
1722
	COVERAGE_FILE=$(CURDIR)/$(COVERAGE_PY_DIR)/data \
1723
	TEXT_COVERAGE=$(CURDIR)/$(COVERAGE_PY_DIR)/report.txt \
1724
	HTML_COVERAGE=$(CURDIR)/$(COVERAGE_PY_DIR) \
1725
	$(PLAIN_TESTS_ENVIRONMENT) $(abs_top_srcdir)/autotools/gen-coverage \
1726
	$(python_tests)
1727

    
1728
.PHONY: hs-coverage
1729
hs-coverage: $(haskell_tests) htest/hpc-htools
1730
	rm -f *.tix
1731
	$(MAKE) $(AM_MAKEFLAGS) hs-check
1732
	@mkdir_p@ $(COVERAGE_HS_DIR)
1733
	hpc combine --union $(HPCEXCL) \
1734
	  test.tix hpc-htools.tix > coverage-htools.tix
1735
	hpc markup --destdir=$(COVERAGE_HS_DIR) coverage-htools.tix
1736
	hpc report coverage-htools.tix
1737
	$(LN_S) -f hpc_index.html $(COVERAGE_HS_DIR)/index.html
1738

    
1739
# Special "kind-of-QA" target for htools, needs special setup (all
1740
# tools compiled with -fhpc)
1741
.PHONY: live-test
1742
live-test: all
1743
	set -e ; \
1744
	cd htools; \
1745
	rm -f .hpc; $(LN_S) ../.hpc .hpc; \
1746
	rm -f *.tix *.mix; \
1747
	./live-test.sh; \
1748
	hpc sum --union $(HPCEXCL) $(addsuffix .tix,$(HS_PROGS:htools/%=%)) \
1749
	  --output=live-test.tix ; \
1750
	@mkdir_p@ ../$(COVERAGE_HS_DIR) ; \
1751
	hpc markup --destdir=../$(COVERAGE_HS_DIR) live-test \
1752
	  --srcdir=.. $(HPCEXCL) ; \
1753
	hpc report --srcdir=.. live-test $(HPCEXCL)
1754

    
1755
commit-check: distcheck lint apidoc
1756

    
1757
.PHONY: gitignore-check
1758
gitignore-check:
1759
	@if [ -n "`git status --short`" ]; then \
1760
	  echo "Git status is not clean!" 1>&2 ; \
1761
	  git status --short; \
1762
	  exit 1; \
1763
	fi
1764

    
1765
# Target that builds all binaries (including those that are not
1766
# rebuilt except when running the tests)
1767
.PHONY: really-all
1768
really-all: all $(check_SCRIPTS) $(haskell_tests) $(HS_ALL_PROGS)
1769

    
1770
# we don't need the ancient implicit rules:
1771
%: %,v
1772
%: RCS/%,v
1773
%: RCS/%
1774
%: s.%
1775
%: SCCS/s.%
1776

    
1777
-include ./Makefile.local
1778

    
1779
# vim: set noet :