Statistics
| Branch: | Tag: | Revision:

root / Makefile.am @ 1a2eb2dc

History | View | Annotate | Download (49.2 kB)

1
# Ganeti makefile
2
# - Indent with tabs only.
3
# - Keep files sorted; one line per file.
4
# - Directories in lib/ must have their own *dir variable (see hypervisor).
5
# - All directories must be listed DIRS.
6
# - Use autogen.sh to generate Makefile.in and configure script.
7

    
8
# Automake doesn't export these variables before version 1.10.
9
abs_top_builddir = @abs_top_builddir@
10
abs_top_srcdir = @abs_top_srcdir@
11

    
12
# Helper values for calling builtin functions
13
empty :=
14
space := $(empty) $(empty)
15
comma := ,
16

    
17
# 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/Confd \
61
	htools/Ganeti/HTools \
62
	htools/Ganeti/HTools/Backend \
63
	htools/Ganeti/HTools/Program \
64
	htools/Ganeti/Query \
65
	htest \
66
	htest/Test \
67
	htest/Test/Ganeti \
68
	htest/Test/Ganeti/Confd \
69
	htest/Test/Ganeti/HTools \
70
	htest/Test/Ganeti/HTools/Backend \
71
	htest/Test/Ganeti/Query
72

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

    
106
BUILDTIME_DIR_AUTOCREATE = \
107
	scripts \
108
	$(APIDOC_DIR) \
109
	$(APIDOC_HS_DIR) \
110
	$(APIDOC_HS_DIR)/Ganeti \
111
	$(APIDOC_HS_DIR)/Ganeti/Confd \
112
	$(APIDOC_HS_DIR)/Ganeti/HTools \
113
	$(APIDOC_HS_DIR)/Ganeti/HTools/Backend \
114
	$(APIDOC_HS_DIR)/Ganeti/HTools/Program \
115
	$(APIDOC_HS_DIR)/Ganeti/Query \
116
	$(APIDOC_PY_DIR) \
117
	$(COVERAGE_DIR) \
118
	$(COVERAGE_HS_DIR) \
119
	$(COVERAGE_PY_DIR) \
120
	.hpc
121

    
122
BUILDTIME_DIRS = \
123
	$(BUILDTIME_DIR_AUTOCREATE) \
124
	doc/html
125

    
126
DIRCHECK_EXCLUDE = \
127
	$(BUILDTIME_DIRS) \
128
	ganeti-[0-9]*.[0-9]*.[0-9]* \
129
	doc/html/_*
130

    
131
# some helper vars
132
COVERAGE_DIR = doc/coverage
133
COVERAGE_PY_DIR = $(COVERAGE_DIR)/py
134
COVERAGE_HS_DIR = $(COVERAGE_DIR)/hs
135
APIDOC_DIR = doc/api
136
APIDOC_PY_DIR = $(APIDOC_DIR)/py
137
APIDOC_HS_DIR = $(APIDOC_DIR)/hs
138

    
139
MAINTAINERCLEANFILES = \
140
	$(docpng) \
141
	$(maninput) \
142
	doc/install-quick.rst \
143
	doc/news.rst \
144
	doc/upgrade.rst \
145
	vcs-version
146

    
147
maintainer-clean-local:
148
	rm -rf $(BUILDTIME_DIRS)
149

    
150
CLEANFILES = \
151
	$(addsuffix /*.py[co],$(DIRS)) \
152
	$(addsuffix /*.hi,$(HTOOLS_DIRS)) \
153
	$(addsuffix /*.o,$(HTOOLS_DIRS)) \
154
	$(PYTHON_BOOTSTRAP) \
155
	epydoc.conf \
156
	$(REPLACE_VARS_SED) \
157
	$(SHELL_ENV_INIT) \
158
	daemons/daemon-util \
159
	daemons/ganeti-cleaner \
160
	$(BUILT_EXAMPLES) \
161
	doc/examples/bash_completion \
162
	doc/examples/bash_completion-debug \
163
	lib/_generated_rpc.py \
164
	$(man_MANS) \
165
	$(manhtml) \
166
	tools/kvm-ifup \
167
	tools/vcluster-setup \
168
	stamp-directories \
169
	stamp-srclinks \
170
	$(nodist_pkgpython_PYTHON) \
171
	$(HS_ALL_PROGS) $(HS_BUILT_SRCS) \
172
	$(HS_BUILT_TEST_HELPERS) \
173
	htools/ganeti-confd \
174
	.hpc/*.mix htools/*.tix htest/*.tix \
175
	doc/hs-lint.html
176

    
177
GENERATED_FILES = \
178
	$(built_base_sources) \
179
	$(BUILT_PYTHON_SOURCES) \
180
	$(PYTHON_BOOTSTRAP)
181

    
182
HTOOLS_GENERATED_FILES =
183
if WANT_HTOOLS
184
HTOOLS_GENERATED_FILES += $(HS_PROGS)
185
if ENABLE_CONFD
186
HTOOLS_GENERATED_FILES += htools/hconfd htools/ganeti-confd
187
endif
188
endif
189

    
190
built_base_sources = \
191
	stamp-directories \
192
	stamp-srclinks
193

    
194
built_python_base_sources = \
195
	lib/_autoconf.py \
196
	lib/_vcsversion.py
197

    
198
BUILT_PYTHON_SOURCES = \
199
	$(built_python_base_sources) \
200
	lib/_generated_rpc.py
201

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

    
206
# these are all built from the underlying %.in sources
207
BUILT_EXAMPLES = \
208
	doc/examples/ganeti-kvm-poweroff.initd \
209
	doc/examples/ganeti.cron \
210
	doc/examples/ganeti.initd \
211
	doc/examples/ganeti-master-role.ocf \
212
	doc/examples/ganeti-node-role.ocf \
213
	doc/examples/gnt-config-backup \
214
	doc/examples/hooks/ipsec
215

    
216
nodist_pkgpython_PYTHON = \
217
	$(BUILT_PYTHON_SOURCES)
218

    
219
noinst_PYTHON = \
220
	lib/build/__init__.py \
221
	lib/build/shell_example_lexer.py \
222
	lib/build/sphinx_ext.py
223

    
224
pkgpython_PYTHON = \
225
	lib/__init__.py \
226
	lib/asyncnotifier.py \
227
	lib/backend.py \
228
	lib/bdev.py \
229
	lib/bootstrap.py \
230
	lib/cli.py \
231
	lib/cmdlib.py \
232
	lib/compat.py \
233
	lib/config.py \
234
	lib/constants.py \
235
	lib/daemon.py \
236
	lib/errors.py \
237
	lib/ht.py \
238
	lib/jqueue.py \
239
	lib/jstore.py \
240
	lib/locking.py \
241
	lib/luxi.py \
242
	lib/mcpu.py \
243
	lib/netutils.py \
244
	lib/objects.py \
245
	lib/objectutils.py \
246
	lib/opcodes.py \
247
	lib/ovf.py \
248
	lib/pathutils.py \
249
	lib/qlang.py \
250
	lib/query.py \
251
	lib/rpc.py \
252
	lib/rpc_defs.py \
253
	lib/runtime.py \
254
	lib/serializer.py \
255
	lib/ssconf.py \
256
	lib/ssh.py \
257
	lib/storage.py \
258
	lib/uidpool.py \
259
	lib/vcluster.py \
260
	lib/workerpool.py
261

    
262
client_PYTHON = \
263
	lib/client/__init__.py \
264
	lib/client/gnt_backup.py \
265
	lib/client/gnt_cluster.py \
266
	lib/client/gnt_debug.py \
267
	lib/client/gnt_group.py \
268
	lib/client/gnt_instance.py \
269
	lib/client/gnt_job.py \
270
	lib/client/gnt_node.py \
271
	lib/client/gnt_os.py
272

    
273
hypervisor_PYTHON = \
274
	lib/hypervisor/__init__.py \
275
	lib/hypervisor/hv_base.py \
276
	lib/hypervisor/hv_chroot.py \
277
	lib/hypervisor/hv_fake.py \
278
	lib/hypervisor/hv_kvm.py \
279
	lib/hypervisor/hv_lxc.py \
280
	lib/hypervisor/hv_xen.py
281

    
282
rapi_PYTHON = \
283
	lib/rapi/__init__.py \
284
	lib/rapi/baserlib.py \
285
	lib/rapi/client.py \
286
	lib/rapi/client_utils.py \
287
	lib/rapi/connector.py \
288
	lib/rapi/rlib2.py \
289
	lib/rapi/testutils.py
290

    
291
http_PYTHON = \
292
	lib/http/__init__.py \
293
	lib/http/auth.py \
294
	lib/http/client.py \
295
	lib/http/server.py
296

    
297
confd_PYTHON = \
298
	lib/confd/__init__.py \
299
	lib/confd/client.py
300

    
301
masterd_PYTHON = \
302
	lib/masterd/__init__.py \
303
	lib/masterd/iallocator.py \
304
	lib/masterd/instance.py
305

    
306
impexpd_PYTHON = \
307
	lib/impexpd/__init__.py
308

    
309
watcher_PYTHON = \
310
	lib/watcher/__init__.py \
311
	lib/watcher/nodemaint.py \
312
	lib/watcher/state.py
313

    
314
server_PYTHON = \
315
	lib/server/__init__.py \
316
	lib/server/masterd.py \
317
	lib/server/noded.py \
318
	lib/server/rapi.py
319

    
320
pytools_PYTHON = \
321
	lib/tools/__init__.py \
322
	lib/tools/ensure_dirs.py \
323
	lib/tools/prepare_node_join.py
324

    
325
utils_PYTHON = \
326
	lib/utils/__init__.py \
327
	lib/utils/algo.py \
328
	lib/utils/filelock.py \
329
	lib/utils/hash.py \
330
	lib/utils/io.py \
331
	lib/utils/log.py \
332
	lib/utils/mlock.py \
333
	lib/utils/nodesetup.py \
334
	lib/utils/process.py \
335
	lib/utils/retry.py \
336
	lib/utils/text.py \
337
	lib/utils/wrapper.py \
338
	lib/utils/x509.py
339

    
340
docrst = \
341
	doc/admin.rst \
342
	doc/cluster-merge.rst \
343
	doc/design-2.0.rst \
344
	doc/design-2.1.rst \
345
	doc/design-2.2.rst \
346
	doc/design-2.3.rst \
347
	doc/design-2.4.rst \
348
	doc/design-2.5.rst \
349
	doc/design-2.6.rst \
350
	doc/design-2.7.rst \
351
	doc/design-autorepair.rst \
352
	doc/design-bulk-create.rst \
353
	doc/design-chained-jobs.rst \
354
	doc/design-cpu-pinning.rst \
355
	doc/design-draft.rst \
356
	doc/design-htools-2.3.rst \
357
	doc/design-http-server.rst \
358
	doc/design-impexp2.rst \
359
	doc/design-lu-generated-jobs.rst \
360
	doc/design-linuxha.rst \
361
	doc/design-multi-reloc.rst \
362
	doc/design-network.rst \
363
	doc/design-oob.rst \
364
	doc/design-ovf-support.rst \
365
	doc/design-partitioned.rst \
366
	doc/design-query-splitting.rst \
367
	doc/design-query2.rst \
368
	doc/design-remote-commands.rst \
369
	doc/design-resource-model.rst \
370
	doc/design-shared-storage.rst \
371
	doc/design-ssh-setup.rst \
372
	doc/design-monitoring-agent.rst \
373
	doc/design-virtual-clusters.rst \
374
	doc/design-x509-ca.rst \
375
	doc/devnotes.rst \
376
	doc/glossary.rst \
377
	doc/hooks.rst \
378
	doc/iallocator.rst \
379
	doc/index.rst \
380
	doc/install-quick.rst \
381
	doc/install.rst \
382
	doc/locking.rst \
383
	doc/move-instance.rst \
384
	doc/news.rst \
385
	doc/ovfconverter.rst \
386
	doc/rapi.rst \
387
	doc/security.rst \
388
	doc/upgrade.rst \
389
	doc/virtual-cluster.rst \
390
	doc/walkthrough.rst
391

    
392
HS_PROGS = htools/htools
393
HS_BIN_ROLES = hbal hscan hspace hinfo hcheck
394
HS_HTOOLS_PROGS = $(HS_BIN_ROLES) hail
395

    
396
HS_ALL_PROGS = \
397
	$(HS_PROGS) \
398
	htest/hpc-htools \
399
	htest/test \
400
	htools/hconfd \
401
	htools/rpc-test
402

    
403
HS_PROG_SRCS = $(patsubst %,%.hs,$(HS_ALL_PROGS))
404
HS_BUILT_TEST_HELPERS = $(HS_BIN_ROLES:%=htest/%) htest/hail
405

    
406
HFLAGS = \
407
	-O -Wall -Werror -ihtools \
408
	-fwarn-monomorphism-restriction \
409
	-fwarn-tabs \
410
	$(GHC_BYVERSION_FLAGS)
411

    
412
# extra flags that can be overriden on the command line (e.g. -Wwarn, etc.)
413
HEXTRA =
414
# internal extra flags (used for htest/test mainly)
415
HEXTRA_INT =
416
# exclude options for coverage reports
417
HPCEXCL = --exclude Main \
418
	--exclude Ganeti.Constants \
419
	--exclude Ganeti.HTools.QC \
420
	--exclude Ganeti.THH \
421
	--exclude Ganeti.Version \
422
	--exclude Test.Ganeti.TestCommon \
423
	--exclude Test.Ganeti.TestHTools \
424
	--exclude Test.Ganeti.TestHelper \
425
	--exclude Test.Ganeti.TestImports \
426
	$(patsubst htools.%,--exclude Test.%,$(subst /,.,$(patsubst %.hs,%, $(HS_LIB_SRCS))))
427

    
428
HS_LIB_SRCS = \
429
	htools/Ganeti/BasicTypes.hs \
430
	htools/Ganeti/Common.hs \
431
	htools/Ganeti/Compat.hs \
432
	htools/Ganeti/Confd/Server.hs \
433
	htools/Ganeti/Confd/Types.hs \
434
	htools/Ganeti/Confd/Utils.hs \
435
	htools/Ganeti/Config.hs \
436
	htools/Ganeti/Daemon.hs \
437
	htools/Ganeti/Errors.hs \
438
	htools/Ganeti/HTools/Backend/IAlloc.hs \
439
	htools/Ganeti/HTools/Backend/Luxi.hs \
440
	htools/Ganeti/HTools/Backend/Rapi.hs \
441
	htools/Ganeti/HTools/Backend/Simu.hs \
442
	htools/Ganeti/HTools/Backend/Text.hs \
443
	htools/Ganeti/HTools/CLI.hs \
444
	htools/Ganeti/HTools/Cluster.hs \
445
	htools/Ganeti/HTools/Container.hs \
446
	htools/Ganeti/HTools/ExtLoader.hs \
447
	htools/Ganeti/HTools/Group.hs \
448
	htools/Ganeti/HTools/Instance.hs \
449
	htools/Ganeti/HTools/Loader.hs \
450
	htools/Ganeti/HTools/Node.hs \
451
	htools/Ganeti/HTools/PeerMap.hs \
452
	htools/Ganeti/HTools/Program.hs \
453
	htools/Ganeti/HTools/Program/Hail.hs \
454
	htools/Ganeti/HTools/Program/Hbal.hs \
455
	htools/Ganeti/HTools/Program/Hcheck.hs \
456
	htools/Ganeti/HTools/Program/Hinfo.hs \
457
	htools/Ganeti/HTools/Program/Hscan.hs \
458
	htools/Ganeti/HTools/Program/Hspace.hs \
459
	htools/Ganeti/HTools/Types.hs \
460
	htools/Ganeti/Hash.hs \
461
	htools/Ganeti/JSON.hs \
462
	htools/Ganeti/Jobs.hs \
463
	htools/Ganeti/Logging.hs \
464
	htools/Ganeti/Luxi.hs \
465
	htools/Ganeti/Objects.hs \
466
	htools/Ganeti/OpCodes.hs \
467
	htools/Ganeti/Path.hs \
468
	htools/Ganeti/Query/Common.hs \
469
	htools/Ganeti/Query/Filter.hs \
470
	htools/Ganeti/Query/Group.hs \
471
	htools/Ganeti/Query/Language.hs \
472
	htools/Ganeti/Query/Node.hs \
473
	htools/Ganeti/Query/Query.hs \
474
	htools/Ganeti/Query/Server.hs \
475
	htools/Ganeti/Query/Types.hs \
476
	htools/Ganeti/Rpc.hs \
477
	htools/Ganeti/Runtime.hs \
478
	htools/Ganeti/Ssconf.hs \
479
	htools/Ganeti/THH.hs \
480
	htools/Ganeti/Utils.hs
481

    
482
HS_TEST_SRCS = \
483
	htest/Test/Ganeti/Attoparsec.hs \
484
	htest/Test/Ganeti/BasicTypes.hs \
485
	htest/Test/Ganeti/Common.hs \
486
	htest/Test/Ganeti/Confd/Utils.hs \
487
	htest/Test/Ganeti/Daemon.hs \
488
	htest/Test/Ganeti/Errors.hs \
489
	htest/Test/Ganeti/HTools/Backend/Simu.hs \
490
	htest/Test/Ganeti/HTools/Backend/Text.hs \
491
	htest/Test/Ganeti/HTools/CLI.hs \
492
	htest/Test/Ganeti/HTools/Cluster.hs \
493
	htest/Test/Ganeti/HTools/Container.hs \
494
	htest/Test/Ganeti/HTools/Instance.hs \
495
	htest/Test/Ganeti/HTools/Loader.hs \
496
	htest/Test/Ganeti/HTools/Node.hs \
497
	htest/Test/Ganeti/HTools/PeerMap.hs \
498
	htest/Test/Ganeti/HTools/Types.hs \
499
	htest/Test/Ganeti/JSON.hs \
500
	htest/Test/Ganeti/Jobs.hs \
501
	htest/Test/Ganeti/Luxi.hs \
502
	htest/Test/Ganeti/Objects.hs \
503
	htest/Test/Ganeti/OpCodes.hs \
504
	htest/Test/Ganeti/Query/Filter.hs \
505
	htest/Test/Ganeti/Query/Language.hs \
506
	htest/Test/Ganeti/Query/Query.hs \
507
	htest/Test/Ganeti/Rpc.hs \
508
	htest/Test/Ganeti/Ssconf.hs \
509
	htest/Test/Ganeti/THH.hs \
510
	htest/Test/Ganeti/TestCommon.hs \
511
	htest/Test/Ganeti/TestHTools.hs \
512
	htest/Test/Ganeti/TestHelper.hs \
513
	htest/Test/Ganeti/Utils.hs
514

    
515
HS_LIBTEST_SRCS = $(HS_LIB_SRCS) $(HS_TEST_SRCS)
516

    
517
HS_BUILT_SRCS = \
518
	htest/Test/Ganeti/TestImports.hs \
519
	htools/Ganeti/Constants.hs \
520
	htools/Ganeti/Version.hs
521
HS_BUILT_SRCS_IN = $(patsubst %,%.in,$(HS_BUILT_SRCS))
522

    
523
$(RUN_IN_TEMPDIR): | stamp-directories
524

    
525
# Note: we use here an order-only prerequisite, as the contents of
526
# _autoconf.py are not actually influencing the html build output: it
527
# has to exist in order for the sphinx module to be loaded
528
# successfully, but we certainly don't want the docs to be rebuilt if
529
# it changes
530
doc/html/index.html: $(docrst) $(docpng) doc/conf.py configure.ac \
531
	$(RUN_IN_TEMPDIR) lib/build/sphinx_ext.py \
532
	lib/build/shell_example_lexer.py lib/opcodes.py lib/ht.py \
533
	| $(BUILT_PYTHON_SOURCES)
534
	@test -n "$(SPHINX)" || \
535
	    { echo 'sphinx-build' not found during configure; exit 1; }
536
	@mkdir_p@ $(dir $@)
537
	PYTHONPATH=. $(RUN_IN_TEMPDIR) $(SPHINX) -q -W -b html \
538
	    -d . \
539
	    -D version="$(VERSION_MAJOR).$(VERSION_MINOR)" \
540
	    -D release="$(PACKAGE_VERSION)" \
541
	    $(abs_top_srcdir)/doc $(CURDIR)/doc/html
542
	rm -f doc/html/.buildinfo doc/html/objects.inv
543
	touch $@
544

    
545
doc/html: doc/html/index.html
546

    
547
doc/install-quick.rst: INSTALL
548
doc/news.rst: NEWS
549
doc/upgrade.rst: UPGRADE
550

    
551
doc/install-quick.rst doc/news.rst doc/upgrade.rst:
552
	set -e; \
553
	{ echo '.. This file is automatically updated at build time from $<.'; \
554
	  echo '.. Do not edit.'; \
555
	  echo; \
556
	  cat $<; \
557
	} > $@
558

    
559
docdot = \
560
	doc/arch-2.0.dot \
561
	doc/design-2.1-lock-acquire.dot \
562
	doc/design-2.1-lock-release.dot
563

    
564
docpng = $(patsubst %.dot,%.png,$(docdot))
565

    
566
# Things to build but not to install (add it to EXTRA_DIST if it should be
567
# distributed)
568
noinst_DATA = \
569
	doc/html \
570
	$(BUILT_EXAMPLES) \
571
	doc/examples/bash_completion \
572
	doc/examples/bash_completion-debug \
573
	$(manhtml)
574

    
575
gnt_scripts = \
576
	scripts/gnt-backup \
577
	scripts/gnt-cluster \
578
	scripts/gnt-debug \
579
	scripts/gnt-group \
580
	scripts/gnt-instance \
581
	scripts/gnt-job \
582
	scripts/gnt-node \
583
	scripts/gnt-os
584

    
585
PYTHON_BOOTSTRAP_SBIN = \
586
	daemons/ganeti-masterd \
587
	daemons/ganeti-noded \
588
	daemons/ganeti-rapi \
589
	daemons/ganeti-watcher \
590
	$(gnt_scripts)
591

    
592
PYTHON_BOOTSTRAP = \
593
	$(PYTHON_BOOTSTRAP_SBIN) \
594
	tools/ensure-dirs \
595
	tools/prepare-node-join
596

    
597
qa_scripts = \
598
	qa/__init__.py \
599
	qa/ganeti-qa.py \
600
	qa/qa_cluster.py \
601
	qa/qa_config.py \
602
	qa/qa_daemon.py \
603
	qa/qa_env.py \
604
	qa/qa_error.py \
605
	qa/qa_group.py \
606
	qa/qa_instance.py \
607
	qa/qa_job.py \
608
	qa/qa_node.py \
609
	qa/qa_os.py \
610
	qa/qa_rapi.py \
611
	qa/qa_tags.py \
612
	qa/qa_utils.py
613

    
614
bin_SCRIPTS =
615
if WANT_HTOOLS
616
bin_SCRIPTS += $(filter-out htools/hail,$(HS_PROGS))
617
install-exec-hook:
618
	@mkdir_p@ $(DESTDIR)$(iallocatorsdir)
619
# FIXME: this is a hardcoded logic, instead of auto-resolving
620
	$(LN_S) -f ../../../bin/htools \
621
		   $(DESTDIR)$(iallocatorsdir)/hail
622
	for role in $(HS_BIN_ROLES); do \
623
		$(LN_S) -f htools \
624
			   $(DESTDIR)$(bindir)/$$role ; \
625
	done
626
endif
627

    
628
$(HS_ALL_PROGS): %: %.hs $(HS_LIBTEST_SRCS) $(HS_BUILT_SRCS) Makefile
629
	@if [ "$(notdir $@)" = "test" ] && [ "$(HTOOLS_NODEV)" ]; then \
630
	  echo "Error: cannot run unittests without the development" \
631
	       " libraries (see devnotes.rst)" 1>&2; \
632
	  exit 1; \
633
	fi
634
	@rm -f $(notdir $@).tix
635
	$(GHC) --make \
636
	  $(HFLAGS) \
637
	  $(HTOOLS_NOCURL) $(HTOOLS_PARALLEL3) $(HTOOLS_REGEX_PCRE) \
638
	  -osuf $(notdir $@).o -hisuf $(notdir $@).hi \
639
	  $(HEXTRA) $(HEXTRA_INT) $@
640
	@touch "$@"
641

    
642
# for the htest/test binary, we need to enable profiling/coverage
643
htest/test: HEXTRA_INT=-fhpc -ihtest
644

    
645
# we compile the hpc-htools binary with the program coverage
646
htest/hpc-htools: HEXTRA_INT=-fhpc
647

    
648
# test dependency
649
htest/offline-tests.sh: htest/hpc-htools
650

    
651
# rules for building profiling-enabled versions of the haskell
652
# programs: hs-prof does the full two-step build, whereas
653
# hs-prof-quick does only the final rebuild (hs-prof must have been
654
# run before)
655
.PHONY: hs-prof hs-prof-quick
656
hs-prof:
657
	$(MAKE) $(AM_MAKEFLAGS) clean
658
	$(MAKE) $(AM_MAKEFLAGS) $(HS_ALL_PROGS) HEXTRA="-osuf .o"
659
	rm -f $(HS_ALL_PROGS)
660
	$(MAKE) $(AM_MAKEFLAGS) hs-prof-quick
661

    
662
hs-prof-quick:
663
	$(MAKE) $(AM_MAKEFLAGS) $(HS_ALL_PROGS) HEXTRA="-osuf .prof_o -prof -auto-all"
664

    
665
dist_sbin_SCRIPTS = \
666
	tools/ganeti-listrunner
667

    
668
nodist_sbin_SCRIPTS = \
669
	$(PYTHON_BOOTSTRAP_SBIN) \
670
	daemons/ganeti-cleaner
671

    
672
if ENABLE_CONFD
673
htools/ganeti-confd: htools/hconfd
674
	cp -f $< $@
675

    
676
nodist_sbin_SCRIPTS += htools/ganeti-confd
677
endif
678

    
679
python_scripts = \
680
	tools/burnin \
681
	tools/cfgshell \
682
	tools/cfgupgrade \
683
	tools/cfgupgrade12 \
684
	tools/cluster-merge \
685
	tools/confd-client \
686
	tools/fmtjson \
687
	tools/lvmstrap \
688
	tools/move-instance \
689
	tools/ovfconverter \
690
	tools/sanitize-config
691

    
692
dist_tools_SCRIPTS = \
693
	$(python_scripts) \
694
	tools/kvm-console-wrapper \
695
	tools/master-ip-setup \
696
	tools/xen-console-wrapper
697

    
698
nodist_tools_SCRIPTS = \
699
	tools/vcluster-setup
700

    
701
pkglib_python_scripts = \
702
	daemons/import-export \
703
	tools/check-cert-expired
704

    
705
nodist_pkglib_python_scripts = \
706
	tools/ensure-dirs \
707
	tools/prepare-node-join
708

    
709
myexeclib_SCRIPTS = \
710
	daemons/daemon-util \
711
	tools/kvm-ifup \
712
	$(pkglib_python_scripts)
713

    
714
nodist_myexeclib_SCRIPTS = \
715
	$(nodist_pkglib_python_scripts)
716

    
717
EXTRA_DIST = \
718
	NEWS \
719
	UPGRADE \
720
	epydoc.conf.in \
721
	pylintrc \
722
	autotools/build-bash-completion \
723
	autotools/build-rpc \
724
	autotools/check-header \
725
	autotools/check-imports \
726
	autotools/check-man-dashes \
727
	autotools/check-man-warnings \
728
	autotools/check-news \
729
	autotools/check-python-code \
730
	autotools/check-tar \
731
	autotools/check-version \
732
	autotools/convert-constants \
733
	autotools/docpp \
734
	autotools/gen-coverage \
735
	autotools/testrunner \
736
	autotools/wrong-hardcoded-paths \
737
	$(RUN_IN_TEMPDIR) \
738
	daemons/daemon-util.in \
739
	daemons/ganeti-cleaner.in \
740
	$(pkglib_python_scripts) \
741
	devel/upload \
742
	tools/kvm-ifup.in \
743
	tools/vcluster-setup.in \
744
	$(docdot) \
745
	$(docpng) \
746
	$(docrst) \
747
	doc/conf.py \
748
	doc/html \
749
	$(BUILT_EXAMPLES:%=%.in) \
750
	doc/examples/ganeti.default \
751
	doc/examples/ganeti.default-debug \
752
	doc/examples/hooks/ethers \
753
	doc/examples/gnt-debug/README \
754
	doc/examples/gnt-debug/delay0.json \
755
	doc/examples/gnt-debug/delay50.json \
756
	test/lockperf.py \
757
	test/testutils.py \
758
	test/mocks.py \
759
	$(dist_TESTS) \
760
	$(TEST_FILES) \
761
	man/footer.rst \
762
	$(manrst) \
763
	$(maninput) \
764
	qa/qa-sample.json \
765
	$(qa_scripts) \
766
	$(HS_LIBTEST_SRCS) $(HS_BUILT_SRCS_IN) \
767
	$(HS_PROG_SRCS) \
768
	htools/lint-hints.hs \
769
	htest/cli-tests-defs.sh \
770
	htest/offline-test.sh \
771
	.ghci
772

    
773
man_MANS = \
774
	man/ganeti-cleaner.8 \
775
	man/ganeti-confd.8 \
776
	man/ganeti-listrunner.8 \
777
	man/ganeti-masterd.8 \
778
	man/ganeti-noded.8 \
779
	man/ganeti-os-interface.7 \
780
	man/ganeti-rapi.8 \
781
	man/ganeti-watcher.8 \
782
	man/ganeti.7 \
783
	man/gnt-backup.8 \
784
	man/gnt-cluster.8 \
785
	man/gnt-debug.8 \
786
	man/gnt-group.8 \
787
	man/gnt-instance.8 \
788
	man/gnt-job.8 \
789
	man/gnt-node.8 \
790
	man/gnt-os.8 \
791
	man/hail.1 \
792
	man/hbal.1 \
793
	man/hcheck.1 \
794
	man/hinfo.1 \
795
	man/hscan.1 \
796
	man/hspace.1 \
797
	man/htools.1
798

    
799
manrst = $(patsubst %.1,%.rst,$(patsubst %.7,%.rst,$(patsubst %.8,%.rst,$(man_MANS))))
800
manhtml = $(patsubst %.rst,%.html,$(manrst))
801
mangen = $(patsubst %.rst,%.gen,$(manrst))
802
maninput = \
803
	$(patsubst %.1,%.1.in,$(patsubst %.7,%.7.in,$(patsubst %.8,%.8.in,$(man_MANS)))) \
804
	$(patsubst %.html,%.html.in,$(manhtml)) \
805
	man/footer.man man/footer.html $(mangen)
806

    
807
TEST_FILES = \
808
	htest/data/common-suffix.data \
809
	htest/data/hail-alloc-drbd.json \
810
	htest/data/hail-change-group.json \
811
	htest/data/hail-invalid-reloc.json \
812
	htest/data/hail-node-evac.json \
813
	htest/data/hail-reloc-drbd.json \
814
	htest/data/hbal-excl-tags.data \
815
	htest/data/hbal-split-insts.data \
816
	htest/data/invalid-node.data \
817
	htest/data/missing-resources.data \
818
	htest/data/rapi/groups.json \
819
	htest/data/rapi/info.json \
820
	htest/data/rapi/instances.json \
821
	htest/data/rapi/nodes.json \
822
	htest/shelltests/htools-balancing.test \
823
	htest/shelltests/htools-basic.test \
824
	htest/shelltests/htools-dynutil.test \
825
	htest/shelltests/htools-excl.test \
826
	htest/shelltests/htools-hail.test \
827
	htest/shelltests/htools-hspace.test \
828
	htest/shelltests/htools-invalid.test \
829
	htest/shelltests/htools-multi-group.test \
830
	htest/shelltests/htools-no-backend.test \
831
	htest/shelltests/htools-rapi.test \
832
	htest/shelltests/htools-single-group.test \
833
	htest/shelltests/htools-text-backend.test \
834
	test/data/bdev-drbd-8.0.txt \
835
	test/data/bdev-drbd-8.3.txt \
836
	test/data/bdev-drbd-disk.txt \
837
	test/data/bdev-drbd-net-ip4.txt \
838
	test/data/bdev-drbd-net-ip6.txt \
839
	test/data/cert1.pem \
840
	test/data/cert2.pem \
841
	test/data/ip-addr-show-dummy0.txt \
842
	test/data/ip-addr-show-lo-ipv4.txt \
843
	test/data/ip-addr-show-lo-ipv6.txt \
844
	test/data/ip-addr-show-lo-oneline-ipv4.txt \
845
	test/data/ip-addr-show-lo-oneline-ipv6.txt \
846
	test/data/ip-addr-show-lo-oneline.txt \
847
	test/data/ip-addr-show-lo.txt \
848
	test/data/kvm_0.12.5_help.txt \
849
	test/data/kvm_0.15.90_help.txt \
850
	test/data/kvm_0.9.1_help.txt \
851
	test/data/kvm_1.0_help.txt \
852
	test/data/ovfdata/compr_disk.vmdk.gz \
853
	test/data/ovfdata/config.ini \
854
	test/data/ovfdata/corrupted_resources.ovf \
855
	test/data/ovfdata/empty.ini \
856
	test/data/ovfdata/empty.ovf \
857
	test/data/ovfdata/ganeti.mf \
858
	test/data/ovfdata/ganeti.ovf \
859
	test/data/ovfdata/gzip_disk.ovf \
860
	test/data/ovfdata/new_disk.vmdk \
861
	test/data/ovfdata/no_disk.ini \
862
	test/data/ovfdata/no_disk_in_ref.ovf \
863
	test/data/ovfdata/no_os.ini \
864
	test/data/ovfdata/no_ovf.ova \
865
	test/data/ovfdata/other/rawdisk.raw \
866
	test/data/ovfdata/ova.ova \
867
	test/data/ovfdata/rawdisk.raw \
868
	test/data/ovfdata/second_disk.vmdk \
869
	test/data/ovfdata/unsafe_path.ini \
870
	test/data/ovfdata/virtualbox.ovf \
871
	test/data/ovfdata/wrong_config.ini \
872
	test/data/ovfdata/wrong_extension.ovd \
873
	test/data/ovfdata/wrong_manifest.mf \
874
	test/data/ovfdata/wrong_manifest.ovf \
875
	test/data/ovfdata/wrong_ova.ova \
876
	test/data/ovfdata/wrong_xml.ovf \
877
	test/data/proc_drbd8.txt \
878
	test/data/proc_drbd80-emptyline.txt \
879
	test/data/proc_drbd83.txt \
880
	test/data/proc_drbd83_sync.txt \
881
	test/data/proc_drbd83_sync_krnl2.6.39.txt \
882
	test/data/sys_drbd_usermode_helper.txt \
883
	test/data/vgreduce-removemissing-2.02.02.txt \
884
	test/data/vgreduce-removemissing-2.02.66-fail.txt \
885
	test/data/vgreduce-removemissing-2.02.66-ok.txt \
886
	test/data/vgs-missing-pvs-2.02.02.txt \
887
	test/data/vgs-missing-pvs-2.02.66.txt \
888
	test/ganeti-cli.test \
889
	test/gnt-cli.test \
890
	test/import-export_unittest-helper
891

    
892
python_tests = \
893
	doc/examples/rapi_testutils.py \
894
	test/cfgupgrade_unittest.py \
895
	test/docs_unittest.py \
896
	test/ganeti.asyncnotifier_unittest.py \
897
	test/ganeti.backend_unittest-runasroot.py \
898
	test/ganeti.backend_unittest.py \
899
	test/ganeti.bdev_unittest.py \
900
	test/ganeti.cli_unittest.py \
901
	test/ganeti.client.gnt_cluster_unittest.py \
902
	test/ganeti.client.gnt_instance_unittest.py \
903
	test/ganeti.client.gnt_job_unittest.py \
904
	test/ganeti.cmdlib_unittest.py \
905
	test/ganeti.compat_unittest.py \
906
	test/ganeti.confd.client_unittest.py \
907
	test/ganeti.config_unittest.py \
908
	test/ganeti.constants_unittest.py \
909
	test/ganeti.daemon_unittest.py \
910
	test/ganeti.errors_unittest.py \
911
	test/ganeti.hooks_unittest.py \
912
	test/ganeti.ht_unittest.py \
913
	test/ganeti.http_unittest.py \
914
	test/ganeti.hypervisor.hv_chroot_unittest.py \
915
	test/ganeti.hypervisor.hv_fake_unittest.py \
916
	test/ganeti.hypervisor.hv_kvm_unittest.py \
917
	test/ganeti.hypervisor.hv_lxc_unittest.py \
918
	test/ganeti.hypervisor.hv_xen_unittest.py \
919
	test/ganeti.hypervisor_unittest.py \
920
	test/ganeti.impexpd_unittest.py \
921
	test/ganeti.jqueue_unittest.py \
922
	test/ganeti.jstore_unittest.py \
923
	test/ganeti.locking_unittest.py \
924
	test/ganeti.luxi_unittest.py \
925
	test/ganeti.masterd.iallocator_unittest.py \
926
	test/ganeti.masterd.instance_unittest.py \
927
	test/ganeti.mcpu_unittest.py \
928
	test/ganeti.netutils_unittest.py \
929
	test/ganeti.objects_unittest.py \
930
	test/ganeti.objectutils_unittest.py \
931
	test/ganeti.opcodes_unittest.py \
932
	test/ganeti.ovf_unittest.py \
933
	test/ganeti.qlang_unittest.py \
934
	test/ganeti.query_unittest.py \
935
	test/ganeti.rapi.baserlib_unittest.py \
936
	test/ganeti.rapi.client_unittest.py \
937
	test/ganeti.rapi.resources_unittest.py \
938
	test/ganeti.rapi.rlib2_unittest.py \
939
	test/ganeti.rapi.testutils_unittest.py \
940
	test/ganeti.rpc_unittest.py \
941
	test/ganeti.runtime_unittest.py \
942
	test/ganeti.serializer_unittest.py \
943
	test/ganeti.server.rapi_unittest.py \
944
	test/ganeti.ssh_unittest.py \
945
	test/ganeti.storage_unittest.py \
946
	test/ganeti.tools.ensure_dirs_unittest.py \
947
	test/ganeti.tools.prepare_node_join_unittest.py \
948
	test/ganeti.uidpool_unittest.py \
949
	test/ganeti.utils.algo_unittest.py \
950
	test/ganeti.utils.filelock_unittest.py \
951
	test/ganeti.utils.hash_unittest.py \
952
	test/ganeti.utils.io_unittest-runasroot.py \
953
	test/ganeti.utils.io_unittest.py \
954
	test/ganeti.utils.log_unittest.py \
955
	test/ganeti.utils.mlock_unittest.py \
956
	test/ganeti.utils.nodesetup_unittest.py \
957
	test/ganeti.utils.process_unittest.py \
958
	test/ganeti.utils.retry_unittest.py \
959
	test/ganeti.utils.text_unittest.py \
960
	test/ganeti.utils.wrapper_unittest.py \
961
	test/ganeti.utils.x509_unittest.py \
962
	test/ganeti.utils_unittest.py \
963
	test/ganeti.vcluster_unittest.py \
964
	test/ganeti.workerpool_unittest.py \
965
	test/pycurl_reset_unittest.py \
966
	test/qa.qa_config_unittest.py \
967
	test/tempfile_fork_unittest.py
968

    
969
haskell_tests = htest/test
970

    
971
dist_TESTS = \
972
	test/check-cert-expired_unittest.bash \
973
	test/daemon-util_unittest.bash \
974
	test/ganeti-cleaner_unittest.bash \
975
	test/import-export_unittest.bash \
976
	test/cli-test.bash \
977
	test/bash_completion.bash \
978
	$(python_tests)
979

    
980
nodist_TESTS =
981
check_SCRIPTS =
982

    
983
if WANT_HTOOLSTESTS
984
nodist_TESTS += $(haskell_tests)
985
dist_TESTS += htest/offline-test.sh
986
check_SCRIPTS += htest/hpc-htools $(HS_BUILT_TEST_HELPERS)
987
endif
988

    
989
TESTS = $(dist_TESTS) $(nodist_TESTS)
990

    
991
# Environment for all tests
992
PLAIN_TESTS_ENVIRONMENT = \
993
	PYTHONPATH=. \
994
	TOP_SRCDIR=$(abs_top_srcdir) TOP_BUILDDIR=$(abs_top_builddir) \
995
	PYTHON=$(PYTHON) FAKEROOT=$(FAKEROOT_PATH) \
996
	$(RUN_IN_TEMPDIR)
997

    
998
# Environment for tests run by automake
999
TESTS_ENVIRONMENT = \
1000
	$(PLAIN_TESTS_ENVIRONMENT) $(abs_top_srcdir)/autotools/testrunner
1001

    
1002
all_python_code = \
1003
	$(dist_sbin_SCRIPTS) \
1004
	$(python_scripts) \
1005
	$(pkglib_python_scripts) \
1006
	$(nodist_pkglib_python_scripts) \
1007
	$(python_tests) \
1008
	$(pkgpython_PYTHON) \
1009
	$(client_PYTHON) \
1010
	$(hypervisor_PYTHON) \
1011
	$(rapi_PYTHON) \
1012
	$(server_PYTHON) \
1013
	$(pytools_PYTHON) \
1014
	$(http_PYTHON) \
1015
	$(confd_PYTHON) \
1016
	$(masterd_PYTHON) \
1017
	$(impexpd_PYTHON) \
1018
	$(utils_PYTHON) \
1019
	$(watcher_PYTHON) \
1020
	$(noinst_PYTHON) \
1021
	$(qa_scripts)
1022

    
1023
srclink_files = \
1024
	man/footer.rst \
1025
	test/check-cert-expired_unittest.bash \
1026
	test/daemon-util_unittest.bash \
1027
	test/ganeti-cleaner_unittest.bash \
1028
	test/import-export_unittest.bash \
1029
	test/cli-test.bash \
1030
	test/bash_completion.bash \
1031
	htest/offline-test.sh \
1032
	htest/cli-tests-defs.sh \
1033
	$(all_python_code) \
1034
	$(HS_LIBTEST_SRCS) $(HS_PROG_SRCS)
1035

    
1036
check_python_code = \
1037
	$(BUILD_BASH_COMPLETION) \
1038
	$(CHECK_IMPORTS) \
1039
	$(CHECK_HEADER) \
1040
	$(DOCPP) \
1041
	$(all_python_code)
1042

    
1043
lint_python_code = \
1044
	ganeti \
1045
	ganeti/http/server.py \
1046
	$(dist_sbin_SCRIPTS) \
1047
	$(python_scripts) \
1048
	$(pkglib_python_scripts) \
1049
	$(BUILD_BASH_COMPLETION) \
1050
	$(CHECK_IMPORTS) \
1051
	$(CHECK_HEADER) \
1052
	$(DOCPP) \
1053
	$(PYTHON_BOOTSTRAP)
1054

    
1055
standalone_python_modules = \
1056
	lib/rapi/client.py \
1057
	tools/ganeti-listrunner
1058

    
1059
pep8_python_code = \
1060
	ganeti \
1061
	ganeti/http/server.py \
1062
	$(dist_sbin_SCRIPTS) \
1063
	$(python_scripts) \
1064
	$(pkglib_python_scripts) \
1065
	$(BUILD_BASH_COMPLETION) \
1066
	$(CHECK_HEADER) \
1067
	$(DOCPP) \
1068
	$(PYTHON_BOOTSTRAP) \
1069
	qa
1070

    
1071
test/daemon-util_unittest.bash: daemons/daemon-util
1072

    
1073
test/ganeti-cleaner_unittest.bash: daemons/ganeti-cleaner
1074

    
1075
test/bash_completion.bash: doc/examples/bash_completion-debug
1076

    
1077
tools/kvm-ifup: tools/kvm-ifup.in $(REPLACE_VARS_SED)
1078
	sed -f $(REPLACE_VARS_SED) < $< > $@
1079
	chmod +x $@
1080

    
1081
tools/vcluster-setup: tools/vcluster-setup.in $(REPLACE_VARS_SED)
1082
	sed -f $(REPLACE_VARS_SED) < $< > $@
1083
	chmod +x $@
1084

    
1085
daemons/%:: daemons/%.in $(REPLACE_VARS_SED)
1086
	sed -f $(REPLACE_VARS_SED) < $< > $@
1087
	chmod +x $@
1088

    
1089
doc/examples/%:: doc/examples/%.in $(REPLACE_VARS_SED)
1090
	sed -f $(REPLACE_VARS_SED) < $< > $@
1091

    
1092
doc/examples/bash_completion: BC_ARGS = --compact
1093
doc/examples/bash_completion-debug: BC_ARGS =
1094

    
1095
doc/examples/bash_completion doc/examples/bash_completion-debug: \
1096
	$(BUILD_BASH_COMPLETION) $(RUN_IN_TEMPDIR) \
1097
	lib/cli.py $(gnt_scripts) $(client_PYTHON) tools/burnin \
1098
	daemons/ganeti-cleaner \
1099
	$(GENERATED_FILES) $(HTOOLS_GENERATED_FILES)
1100
	PYTHONPATH=. $(RUN_IN_TEMPDIR) \
1101
	  $(CURDIR)/$(BUILD_BASH_COMPLETION) $(BC_ARGS) > $@
1102

    
1103
doc/%.png: doc/%.dot
1104
	@test -n "$(DOT)" || { echo 'dot' not found during configure; exit 1; }
1105
	$(DOT) -Tpng -o $@ $<
1106

    
1107
man/footer.man: man/footer.rst
1108
	@test -n "$(PANDOC)" || \
1109
	  { echo 'pandoc' not found during configure; exit 1; }
1110
	$(PANDOC) -f rst -t man -o $@ $<
1111

    
1112
man/footer.html: man/footer.rst
1113
	@test -n "$(PANDOC)" || \
1114
	  { echo 'pandoc' not found during configure; exit 1; }
1115
	$(PANDOC) -f rst -t html -o $@ $<
1116

    
1117
man/%.gen: man/%.rst lib/query.py lib/build/sphinx_ext.py \
1118
	lib/build/shell_example_lexer.py \
1119
	| $(RUN_IN_TEMPDIR) $(BUILT_PYTHON_SOURCES)
1120
	@echo "Checking $< for hardcoded paths..."
1121
	@if grep -nEf autotools/wrong-hardcoded-paths $<; then \
1122
	  echo "Man page $< has harcoded paths (see above)!" 1>&2 ; \
1123
	  exit 1; \
1124
	fi
1125
	set -e ; \
1126
	trap 'echo auto-removing $@; rm $@' EXIT; \
1127
	PYTHONPATH=. $(RUN_IN_TEMPDIR) $(CURDIR)/$(DOCPP) < $< > $@ ;\
1128
	trap - EXIT
1129

    
1130
man/%.7.in man/%.8.in man/%.1.in: man/%.gen man/footer.man
1131
	@test -n "$(PANDOC)" || \
1132
	  { echo 'pandoc' not found during configure; exit 1; }
1133
	set -o pipefail ; \
1134
	trap 'echo auto-removing $@; rm $@' EXIT; \
1135
	$(PANDOC) -s -f rst -t man -A man/footer.man $< | \
1136
	  sed -e 's/\\@/@/g' > $@; \
1137
	if test -n "$(MAN_HAS_WARNINGS)"; then $(CHECK_MAN_WARNINGS) $@; fi; \
1138
	$(CHECK_MAN_DASHES) $@; \
1139
	trap - EXIT
1140

    
1141

    
1142
man/%.html.in: man/%.gen man/footer.html
1143
	@test -n "$(PANDOC)" || \
1144
	  { echo 'pandoc' not found during configure; exit 1; }
1145
	set -o pipefail ; \
1146
	$(PANDOC) -s -f rst -t html -A man/footer.html $< | \
1147
	  sed -e 's/\\@/@/g' > $@
1148

    
1149
man/%: man/%.in  $(REPLACE_VARS_SED)
1150
	sed -f $(REPLACE_VARS_SED) < $< > $@
1151

    
1152
epydoc.conf: epydoc.conf.in $(REPLACE_VARS_SED)
1153
	sed -f $(REPLACE_VARS_SED) < $< > $@
1154

    
1155
vcs-version:
1156
	if test -d .git; then \
1157
	  git describe > $@; \
1158
	elif test ! -f $@ ; then \
1159
	  echo "Cannot auto-generate $@ file"; exit 1; \
1160
	fi
1161

    
1162
.PHONY: clean-vcs-version
1163
clean-vcs-version:
1164
	rm -f vcs-version
1165

    
1166
.PHONY: regen-vcs-version
1167
regen-vcs-version:
1168
	@set -e; \
1169
	cd $(srcdir); \
1170
	if test -d .git; then \
1171
	  T=`mktemp` ; trap 'rm -f $$T' EXIT; \
1172
	  git describe > $$T; \
1173
	  if ! cmp --quiet $$T vcs-version; then \
1174
	    mv $$T vcs-version; \
1175
	  fi; \
1176
	fi
1177

    
1178
htools/Ganeti/Version.hs: htools/Ganeti/Version.hs.in \
1179
	vcs-version $(built_base_sources)
1180
	set -e; \
1181
	VCSVER=`cat $(abs_top_srcdir)/vcs-version`; \
1182
	sed -e "s/%ver%/$$VCSVER/" < $< > $@
1183

    
1184
htools/Ganeti/Constants.hs: htools/Ganeti/Constants.hs.in \
1185
	lib/constants.py lib/_autoconf.py lib/luxi.py \
1186
	$(CONVERT_CONSTANTS) $(built_base_sources) \
1187
	| lib/_vcsversion.py
1188
	set -e; \
1189
	{ cat $< ; PYTHONPATH=. $(CONVERT_CONSTANTS); } > $@
1190

    
1191
htest/Test/Ganeti/TestImports.hs: htest/Test/Ganeti/TestImports.hs.in \
1192
	$(built_base_sources)
1193
	set -e; \
1194
	{ cat $< ; \
1195
	  echo ; \
1196
	  for name in $(filter-out Ganeti.THH,$(subst /,.,$(patsubst %.hs,%,$(patsubst htools/%,%,$(HS_LIB_SRCS))))) ; do \
1197
	    echo "import $$name ()" ; \
1198
	  done ; \
1199
	} > $@
1200

    
1201
lib/_autoconf.py: Makefile | stamp-directories
1202
	set -e; \
1203
	{ echo '# This file is automatically generated, do not edit!'; \
1204
	  echo '#'; \
1205
	  echo ''; \
1206
	  echo '"""Build-time configuration for Ganeti.'; \
1207
	  echo '';\
1208
	  echo 'This file is autogenerated by the build process.'; \
1209
	  echo 'For any changes you need to re-run ./configure (and'; \
1210
	  echo 'not edit by hand).'; \
1211
	  echo ''; \
1212
	  echo '"""'; \
1213
	  echo ''; \
1214
	  echo '# pylint: disable=C0301,C0324'; \
1215
	  echo '# because this is autogenerated, we do not want'; \
1216
	  echo '# style warnings' ; \
1217
	  echo ''; \
1218
	  echo "PACKAGE_VERSION = '$(PACKAGE_VERSION)'"; \
1219
	  echo "VERSION_MAJOR = '$(VERSION_MAJOR)'"; \
1220
	  echo "VERSION_MINOR = '$(VERSION_MINOR)'"; \
1221
	  echo "VERSION_REVISION = '$(VERSION_REVISION)'"; \
1222
	  echo "VERSION_SUFFIX = '$(VERSION_SUFFIX)'"; \
1223
	  echo "VERSION_FULL = '$(VERSION_FULL)'"; \
1224
	  echo "LOCALSTATEDIR = '$(localstatedir)'"; \
1225
	  echo "SYSCONFDIR = '$(sysconfdir)'"; \
1226
	  echo "SSH_CONFIG_DIR = '$(SSH_CONFIG_DIR)'"; \
1227
	  echo "SSH_LOGIN_USER = '$(SSH_LOGIN_USER)'"; \
1228
	  echo "SSH_CONSOLE_USER = '$(SSH_CONSOLE_USER)'"; \
1229
	  echo "EXPORT_DIR = '$(EXPORT_DIR)'"; \
1230
	  echo "OS_SEARCH_PATH = [$(OS_SEARCH_PATH)]"; \
1231
	  echo "XEN_BOOTLOADER = '$(XEN_BOOTLOADER)'"; \
1232
	  echo "XEN_KERNEL = '$(XEN_KERNEL)'"; \
1233
	  echo "XEN_INITRD = '$(XEN_INITRD)'"; \
1234
	  echo "KVM_KERNEL = '$(KVM_KERNEL)'"; \
1235
	  echo "FILE_STORAGE_DIR = '$(FILE_STORAGE_DIR)'"; \
1236
	  echo "ENABLE_FILE_STORAGE = $(ENABLE_FILE_STORAGE)"; \
1237
	  echo "SHARED_FILE_STORAGE_DIR = '$(SHARED_FILE_STORAGE_DIR)'"; \
1238
	  echo "ENABLE_SHARED_FILE_STORAGE = $(ENABLE_SHARED_FILE_STORAGE)"; \
1239
	  echo "IALLOCATOR_SEARCH_PATH = [$(IALLOCATOR_SEARCH_PATH)]"; \
1240
	  echo "KVM_PATH = '$(KVM_PATH)'"; \
1241
	  echo "IP_PATH = '$(IP_PATH)'"; \
1242
	  echo "SOCAT_PATH = '$(SOCAT)'"; \
1243
	  echo "SOCAT_USE_ESCAPE = $(SOCAT_USE_ESCAPE)"; \
1244
	  echo "SOCAT_USE_COMPRESS = $(SOCAT_USE_COMPRESS)"; \
1245
	  echo "LVM_STRIPECOUNT = $(LVM_STRIPECOUNT)"; \
1246
	  echo "TOOLSDIR = '$(toolsdir)'"; \
1247
	  echo "GNT_SCRIPTS = [$(foreach i,$(notdir $(gnt_scripts)),'$(i)',)]"; \
1248
	  echo "HTOOLS_PROGS = [$(foreach i,$(HS_HTOOLS_PROGS),'$(i)',)]"; \
1249
	  echo "PKGLIBDIR = '$(pkglibdir)'"; \
1250
	  echo "DRBD_BARRIERS = '$(DRBD_BARRIERS)'"; \
1251
	  echo "DRBD_NO_META_FLUSH = $(DRBD_NO_META_FLUSH)"; \
1252
	  echo "SYSLOG_USAGE = '$(SYSLOG_USAGE)'"; \
1253
	  echo "DAEMONS_GROUP = '$(DAEMONS_GROUP)'"; \
1254
	  echo "ADMIN_GROUP = '$(ADMIN_GROUP)'"; \
1255
	  echo "MASTERD_USER = '$(MASTERD_USER)'"; \
1256
	  echo "MASTERD_GROUP = '$(MASTERD_GROUP)'"; \
1257
	  echo "RAPI_USER = '$(RAPI_USER)'"; \
1258
	  echo "RAPI_GROUP = '$(RAPI_GROUP)'"; \
1259
	  echo "CONFD_USER = '$(CONFD_USER)'"; \
1260
	  echo "CONFD_GROUP = '$(CONFD_GROUP)'"; \
1261
	  echo "NODED_USER = '$(NODED_USER)'"; \
1262
	  echo "NODED_GROUP = '$(NODED_GROUP)'"; \
1263
	  echo "DISK_SEPARATOR = '$(DISK_SEPARATOR)'"; \
1264
	  echo "QEMUIMG_PATH = '$(QEMUIMG_PATH)'"; \
1265
	  echo "HTOOLS = True"; \
1266
	  echo "ENABLE_CONFD = $(ENABLE_CONFD)"; \
1267
	  echo "XEN_CMD = '$(XEN_CMD)'"; \
1268
	  echo "ENABLE_SPLIT_QUERY = $(ENABLE_SPLIT_QUERY)"; \
1269
	  echo "ENABLE_REMOTE_COMMANDS = $(ENABLE_REMOTE_COMMANDS)"; \
1270
	} > $@
1271

    
1272
lib/_vcsversion.py: Makefile vcs-version | stamp-directories
1273
	set -e; \
1274
	VCSVER=`cat $(abs_top_srcdir)/vcs-version`; \
1275
	{ echo '# This file is automatically generated, do not edit!'; \
1276
	  echo '#'; \
1277
	  echo ''; \
1278
	  echo '"""Build-time VCS version number for Ganeti.'; \
1279
	  echo '';\
1280
	  echo 'This file is autogenerated by the build process.'; \
1281
	  echo 'For any changes you need to re-run ./configure (and'; \
1282
	  echo 'not edit by hand).'; \
1283
	  echo ''; \
1284
	  echo '"""'; \
1285
	  echo ''; \
1286
	  echo '# pylint: disable=C0301,C0324'; \
1287
	  echo '# because this is autogenerated, we do not want'; \
1288
	  echo '# style warnings' ; \
1289
	  echo ''; \
1290
	  echo "VCS_VERSION = '$$VCSVER'"; \
1291
	} > $@
1292

    
1293
lib/_generated_rpc.py: lib/rpc_defs.py $(BUILD_RPC)
1294
	PYTHONPATH=. $(RUN_IN_TEMPDIR) $(CURDIR)/$(BUILD_RPC) lib/rpc_defs.py > $@
1295

    
1296
$(SHELL_ENV_INIT): Makefile stamp-directories
1297
	set -e; \
1298
	{ echo '# Allow overriding for tests'; \
1299
	  echo 'readonly LOCALSTATEDIR=$${LOCALSTATEDIR:-$${GANETI_ROOTDIR:-}$(localstatedir)}'; \
1300
	  echo 'readonly SYSCONFDIR=$${SYSCONFDIR:-$${GANETI_ROOTDIR:-}$(sysconfdir)}'; \
1301
	  echo; \
1302
	  echo 'readonly PKGLIBDIR=$(pkglibdir)'; \
1303
	  echo 'readonly LOG_DIR="$$LOCALSTATEDIR/log/ganeti"'; \
1304
	  echo 'readonly RUN_DIR="$$LOCALSTATEDIR/run/ganeti"'; \
1305
	  echo 'readonly DATA_DIR="$$LOCALSTATEDIR/lib/ganeti"'; \
1306
	  echo 'readonly CONF_DIR="$$SYSCONFDIR/ganeti"'; \
1307
	} > $@
1308

    
1309
$(REPLACE_VARS_SED): $(SHELL_ENV_INIT) Makefile stamp-directories
1310
	set -e; \
1311
	{ echo 's#@PREFIX@#$(prefix)#g'; \
1312
	  echo 's#@SYSCONFDIR@#$(sysconfdir)#g'; \
1313
	  echo 's#@LOCALSTATEDIR@#$(localstatedir)#g'; \
1314
	  echo 's#@BINDIR@#$(bindir)#g'; \
1315
	  echo 's#@SBINDIR@#$(sbindir)#g'; \
1316
	  echo 's#@LIBDIR@#$(libdir)#g'; \
1317
	  echo 's#@GANETI_VERSION@#$(PACKAGE_VERSION)#g'; \
1318
	  echo 's#@CUSTOM_XEN_BOOTLOADER@#$(XEN_BOOTLOADER)#g'; \
1319
	  echo 's#@CUSTOM_XEN_KERNEL@#$(XEN_KERNEL)#g'; \
1320
	  echo 's#@CUSTOM_XEN_INITRD@#$(XEN_INITRD)#g'; \
1321
	  echo 's#@CUSTOM_IALLOCATOR_SEARCH_PATH@#$(IALLOCATOR_SEARCH_PATH)#g'; \
1322
	  echo 's#@CUSTOM_EXPORT_DIR@#$(EXPORT_DIR)#g'; \
1323
	  echo 's#@RPL_FILE_STORAGE_DIR@#$(FILE_STORAGE_DIR)#g'; \
1324
	  echo 's#@RPL_SSH_INITD_SCRIPT@#$(SSH_INITD_SCRIPT)#g'; \
1325
	  echo 's#@PKGLIBDIR@#$(pkglibdir)#g'; \
1326
	  echo 's#@GNTMASTERUSER@#$(MASTERD_USER)#g'; \
1327
	  echo 's#@GNTRAPIUSER@#$(RAPI_USER)#g'; \
1328
	  echo 's#@GNTCONFDUSER@#$(CONFD_USER)#g'; \
1329
	  echo 's#@GNTNODEDUSER@#$(NODED_USER)#g'; \
1330
	  echo 's#@GNTRAPIGROUP@#$(RAPI_GROUP)#g'; \
1331
	  echo 's#@GNTADMINGROUP@#$(ADMIN_GROUP)#g'; \
1332
	  echo 's#@GNTCONFDGROUP@#$(CONFD_GROUP)#g'; \
1333
	  echo 's#@GNTMASTERDGROUP@#$(MASTERD_GROUP)#g'; \
1334
	  echo 's#@GNTDAEMONSGROUP@#$(DAEMONS_GROUP)#g'; \
1335
	  echo 's#@CUSTOM_ENABLE_CONFD@#$(ENABLE_CONFD)#g'; \
1336
	  echo 's#@MODULES@#$(strip $(lint_python_code))#g'; \
1337
	  echo 's#@ENABLE_SPLIT_QUERY@#$(ENABLE_SPLIT_QUERY)#g'; \
1338
	  echo; \
1339
	  echo '/^@SHELL_ENV_INIT@$$/ {'; \
1340
	  echo '  r $(SHELL_ENV_INIT)'; \
1341
	  echo '  d'; \
1342
	  echo '}'; \
1343
	} > $@
1344

    
1345
# Using deferred evaluation
1346
daemons/ganeti-%: MODULE = ganeti.server.$(patsubst ganeti-%,%,$(notdir $@))
1347
daemons/ganeti-watcher: MODULE = ganeti.watcher
1348
scripts/%: MODULE = ganeti.client.$(subst -,_,$(notdir $@))
1349
tools/ensure-dirs: MODULE = ganeti.tools.ensure_dirs
1350
tools/prepare-node-join: MODULE = ganeti.tools.prepare_node_join
1351
$(HS_BUILT_TEST_HELPERS): TESTROLE = $(patsubst htest/%,%,$@)
1352

    
1353
$(PYTHON_BOOTSTRAP): Makefile | stamp-directories
1354
	test -n "$(MODULE)" || { echo Missing module; exit 1; }
1355
	set -e; \
1356
	{ echo '#!/usr/bin/python'; \
1357
	  echo '# This file is automatically generated, do not edit!'; \
1358
	  echo "# Edit $(MODULE) instead."; \
1359
	  echo; \
1360
	  echo '"""Bootstrap script for L{$(MODULE)}"""'; \
1361
	  echo; \
1362
	  echo '# pylint: disable=C0103'; \
1363
	  echo '# C0103: Invalid name'; \
1364
	  echo; \
1365
	  echo 'import sys'; \
1366
	  echo 'import $(MODULE) as main'; \
1367
	  echo; \
1368
	  echo '# Temporarily alias commands until bash completion'; \
1369
	  echo '# generator is changed'; \
1370
	  echo 'if hasattr(main, "commands"):'; \
1371
	  echo '  commands = main.commands # pylint: disable=E1101'; \
1372
	  echo 'if hasattr(main, "aliases"):'; \
1373
	  echo '  aliases = main.aliases # pylint: disable=E1101'; \
1374
	  echo; \
1375
	  echo 'if __name__ == "__main__":'; \
1376
	  echo '  sys.exit(main.Main())'; \
1377
	} > $@
1378
	chmod u+x $@
1379

    
1380
$(HS_BUILT_TEST_HELPERS): Makefile
1381
	@test -n "$(TESTROLE)" || { echo Missing TESTROLE; exit 1; }
1382
	set -e; \
1383
	{ echo '#!/bin/sh'; \
1384
	  echo '# This file is automatically generated, do not edit!'; \
1385
	  echo "# Edit Makefile.am instead."; \
1386
	  echo; \
1387
	  echo "HTOOLS=$(TESTROLE) exec ./htest/hpc-htools \"\$$@\""; \
1388
	} > $@
1389
	chmod u+x $@
1390

    
1391
stamp-directories: Makefile
1392
	$(MAKE) $(AM_MAKEFLAGS) ganeti
1393
	@mkdir_p@ $(DIRS) $(BUILDTIME_DIR_AUTOCREATE)
1394
	touch $@
1395

    
1396
# We need to create symlinks because "make distcheck" will not install Python
1397
# files when building.
1398
stamp-srclinks: Makefile | stamp-directories
1399
	set -e; \
1400
	for i in $(srclink_files); do \
1401
		if test ! -f $$i -a -f $(abs_top_srcdir)/$$i; then \
1402
			$(LN_S) $(abs_top_srcdir)/$$i $$i; \
1403
		fi; \
1404
	done
1405
	touch $@
1406

    
1407
.PHONY: ganeti
1408
ganeti:
1409
	cd $(top_builddir) && test -h "$@" || { rm -f $@ && $(LN_S) lib $@; }
1410

    
1411
.PHONY: check-dirs
1412
check-dirs: $(GENERATED_FILES)
1413
	@set -e; \
1414
	find . -type d \( \( -name . \) -o \( \
1415
		-name .git -o \
1416
		-name autom4te.cache \
1417
		\) -prune -o -print \) | { \
1418
		error=; \
1419
		while read dir; do \
1420
			case "$$dir" in \
1421
				$(strip $(patsubst %,(./%) ;;,$(DIRCHECK_EXCLUDE) $(DIRS))) \
1422
				*) error=1; echo "Directory $$dir not listed in Makefile" >&2 ;; \
1423
			esac; \
1424
		done; \
1425
		for dir in $(DIRS); do \
1426
			if ! test -d "$$dir"; then \
1427
				echo "Directory $$dir listed in DIRS does not exist" >&2; \
1428
				error=1; \
1429
			fi \
1430
		done; \
1431
		if test -n "$$error"; then exit 1; else exit 0; fi; \
1432
	}
1433

    
1434
.PHONY: check-local
1435
check-local: check-dirs $(GENERATED_FILES)
1436
	$(CHECK_PYTHON_CODE) $(check_python_code)
1437
	PYTHONPATH=. $(CHECK_HEADER) $(check_python_code)
1438
	$(CHECK_VERSION) $(VERSION) $(top_srcdir)/NEWS
1439
	$(CHECK_NEWS) < $(top_srcdir)/NEWS
1440
	PYTHONPATH=. $(RUN_IN_TEMPDIR) $(CURDIR)/$(CHECK_IMPORTS) . $(standalone_python_modules)
1441
	@expver=$(VERSION_MAJOR).$(VERSION_MINOR); \
1442
	if test "`head -n 1 $(top_srcdir)/README`" != "Ganeti $$expver"; then \
1443
		echo "Incorrect version in README, expected $$expver"; \
1444
		exit 1; \
1445
	fi; \
1446
	for file in doc/iallocator.rst doc/hooks.rst doc/virtual-cluster.rst \
1447
			doc/security.rst; do \
1448
		if test "`sed -ne '4 p' $(top_srcdir)/$$file`" != \
1449
			"Documents Ganeti version $$expver"; then \
1450
			echo "Incorrect version in $$file, expected $$expver"; \
1451
			exit 1; \
1452
		fi; \
1453
	done; \
1454
	if ! test -f $(top_srcdir)/doc/design-$$expver.rst; then \
1455
		echo "File $(top_srcdir)/doc/design-$$expver.rst not found"; \
1456
		exit 1; \
1457
	fi
1458

    
1459
.PHONY: hs-check
1460
hs-check: htest/test htest/hpc-htools $(HS_BUILT_TEST_HELPERS)
1461
	@rm -f test.tix
1462
	./htest/test
1463
	HBINARY="./htest/hpc-htools" ./htest/offline-test.sh
1464

    
1465
# E111: indentation is not a multiple of four
1466
# E121: continuation line indentation is not a multiple of four
1467
#       (since our indent level is not 4)
1468
# E125: continuation line does not distinguish itself from next logical line
1469
#       (since our indent level is not 4)
1470
# E127: continuation line over-indented for visual indent
1471
#       (since our indent level is not 4)
1472
# note: do NOT add E128 here; it's a valid style error in most cases!
1473
# I've seen real errors, but also some cases were we indent wrongly
1474
# due to line length; try to rework the cases where it is triggered,
1475
# instead of silencing it
1476
# E261: at least two spaces before inline comment
1477
# E501: line too long (80 characters)
1478
PEP8_IGNORE = E111,E121,E125,E127,E261,E501
1479

    
1480
# For excluding pep8 expects filenames only, not whole paths
1481
PEP8_EXCLUDE = $(subst $(space),$(comma),$(strip $(notdir $(BUILT_PYTHON_SOURCES))))
1482

    
1483
LINT_TARGETS = pylint pylint-qa
1484
if HAS_PEP8
1485
LINT_TARGETS += pep8
1486
endif
1487
if HAS_HLINT
1488
LINT_TARGETS += hlint
1489
endif
1490

    
1491
.PHONY: lint
1492
lint: $(LINT_TARGETS)
1493

    
1494
.PHONY: pylint
1495
pylint: $(GENERATED_FILES)
1496
	@test -n "$(PYLINT)" || { echo 'pylint' not found during configure; exit 1; }
1497
	$(PYLINT) $(LINT_OPTS) $(lint_python_code)
1498

    
1499
.PHONY: pylint-qa
1500
pylint-qa: $(GENERATED_FILES)
1501
	@test -n "$(PYLINT)" || { echo 'pylint' not found during configure; exit 1; }
1502
	cd $(top_srcdir)/qa && \
1503
	  PYTHONPATH=$(abs_top_srcdir) $(PYLINT) $(LINT_OPTS) \
1504
	  --rcfile  ../pylintrc $(patsubst qa/%.py,%,$(qa_scripts))
1505

    
1506
.PHONY: pep8
1507
pep8: $(GENERATED_FILES)
1508
	@test -n "$(PEP8)" || { echo 'pep8' not found during configure; exit 1; }
1509
	$(PEP8) --ignore='$(PEP8_IGNORE)' --exclude='$(PEP8_EXCLUDE)' \
1510
		--repeat $(pep8_python_code)
1511

    
1512
# FIXME: remove ignore "Use void" when GHC 6.x is deprecated
1513
.PHONY: hlint
1514
hlint: $(HS_BUILT_SRCS) htools/lint-hints.hs
1515
	@test -n "$(HLINT)" || { echo 'hlint' not found during configure; exit 1; }
1516
	if tty -s; then C="-c"; else C=""; fi; \
1517
	$(HLINT) --report=doc/hs-lint.html --cross $$C \
1518
	  --ignore "Use first" \
1519
	  --ignore "Use comparing" \
1520
	  --ignore "Use on" \
1521
	  --ignore "Reduce duplication" \
1522
	  --ignore "Use &&&" \
1523
	  --ignore "Use void" \
1524
	  --hint htools/lint-hints \
1525
	  $(filter-out htools/Ganeti/THH.hs,$(HS_LIBTEST_SRCS) $(HS_PROG_SRCS))
1526

    
1527
# a dist hook rule for updating the vcs-version file; this is
1528
# hardcoded due to where it needs to build the file...
1529
dist-hook:
1530
	$(MAKE) $(AM_MAKEFLAGS) regen-vcs-version
1531
	rm -f $(top_distdir)/vcs-version
1532
	cp -p $(srcdir)/vcs-version $(top_distdir)
1533

    
1534
# a distcheck hook rule for catching revision control directories
1535
distcheck-hook:
1536
	if find $(top_distdir) -name .svn -or -name .git | grep .; then \
1537
		echo "Found revision control files in final archive." 1>&2; \
1538
		exit 1; \
1539
	fi
1540
	if find $(top_distdir) -name '*.py[co]' | grep .; then \
1541
		echo "Found Python byte code in final archive." 1>&2; \
1542
		exit 1; \
1543
	fi
1544
	if find $(top_distdir) -name '*~' | grep .; then \
1545
		echo "Found backup files in final archive." 1>&2; \
1546
		exit 1; \
1547
	fi
1548
# Empty files or directories should not be distributed. They can cause
1549
# unnecessary warnings for packagers. Directories used by automake during
1550
# distcheck must be excluded.
1551
	if find $(top_distdir) -empty -and -not \( \
1552
			-path $(top_distdir)/_build -or \
1553
			-path $(top_distdir)/_inst \) | grep .; then \
1554
		echo "Found empty files or directories in final archive." 1>&2; \
1555
		exit 1; \
1556
	fi
1557
	if test -n "$(BUILD_RELEASE)" && \
1558
	   grep -n -H -E '^\*.*unreleased' $(top_distdir)/NEWS; then \
1559
		echo "Found unreleased version in NEWS." >&2; \
1560
		exit 1; \
1561
	fi
1562

    
1563
# When building a release, stricter checks should be used
1564
distcheck-release dist-release: export BUILD_RELEASE = 1
1565
distcheck-release: distcheck
1566

    
1567
distrebuildcheck: dist
1568
	set -e; \
1569
	builddir=$$(mktemp -d $(abs_srcdir)/distrebuildcheck.XXXXXXX); \
1570
	trap "echo Removing $$builddir; cd $(abs_srcdir); rm -rf $$builddir" EXIT; \
1571
	cd $$builddir; \
1572
	tar xzf $(abs_srcdir)/$(distdir).tar.gz; \
1573
	cd $(distdir); \
1574
	./configure; \
1575
	$(MAKE) maintainer-clean; \
1576
	cp $(abs_srcdir)/vcs-version .; \
1577
	./configure; \
1578
	$(MAKE) $(AM_MAKEFLAGS)
1579

    
1580
dist-release: dist
1581
	set -e; \
1582
	for i in $(DIST_ARCHIVES); do \
1583
		echo -n "Checking $$i ... "; \
1584
		autotools/check-tar < $$i; \
1585
		echo OK; \
1586
	done
1587

    
1588
install-exec-local:
1589
	@mkdir_p@ "$(DESTDIR)${localstatedir}/lib/ganeti" \
1590
	  "$(DESTDIR)${localstatedir}/log/ganeti" \
1591
	  "$(DESTDIR)${localstatedir}/run/ganeti"
1592

    
1593
.PHONY: apidoc
1594
if WANT_HTOOLSAPIDOC
1595
apidoc: py-apidoc hs-apidoc
1596
else
1597
apidoc: py-apidoc
1598
endif
1599

    
1600
.PHONY: py-apidoc
1601
py-apidoc: epydoc.conf $(RUN_IN_TEMPDIR) $(GENERATED_FILES)
1602
	$(RUN_IN_TEMPDIR) epydoc -v \
1603
		--conf $(CURDIR)/epydoc.conf \
1604
		--output $(CURDIR)/$(APIDOC_PY_DIR)
1605

    
1606
.PHONY: hs-apidoc
1607
hs-apidoc: $(HS_BUILT_SRCS)
1608
	@test -n "$(HSCOLOUR)" || \
1609
	    { echo 'HsColour' not found during configure; exit 1; }
1610
	@test -n "$(HADDOCK)" || \
1611
	    { echo 'haddock' not found during configure; exit 1; }
1612
	rm -rf $(APIDOC_HS_DIR)/*
1613
	@mkdir_p@ $(APIDOC_HS_DIR)/Ganeti/HTools/Backend
1614
	@mkdir_p@ $(APIDOC_HS_DIR)/Ganeti/HTools/Program
1615
	@mkdir_p@ $(APIDOC_HS_DIR)/Ganeti/Confd
1616
	@mkdir_p@ $(APIDOC_HS_DIR)/Ganeti/Query
1617
	$(HSCOLOUR) -print-css > $(APIDOC_HS_DIR)/Ganeti/hscolour.css
1618
	$(LN_S) ../hscolour.css $(APIDOC_HS_DIR)/Ganeti/HTools/hscolour.css
1619
	$(LN_S) ../hscolour.css $(APIDOC_HS_DIR)/Ganeti/Confd/hscolour.css
1620
	set -e ; \
1621
	cd htools; \
1622
	if [ "$(HTOOLS_NOCURL)" ]; \
1623
	then OPTGHC="--optghc=$(HTOOLS_NOCURL)"; \
1624
	else OPTGHC=""; \
1625
	fi; \
1626
	if [ "$(HTOOLS_PARALLEL3)" ]; \
1627
	then OPTGHC="$$OPTGHC --optghc=$(HTOOLS_PARALLEL3)"; \
1628
	fi; \
1629
	if [ "$(HTOOLS_REGEX_PCRE)" ]; \
1630
	then OPTGHC="$$OPTGHC --optghc=$(HTOOLS_REGEX_PCRE)"; \
1631
	fi; \
1632
	RELSRCS="$(HS_LIB_SRCS:htools/%=%) $(patsubst htools/%,%,$(filter htools/%,$(HS_BUILT_SRCS)))"; \
1633
	for file in $$RELSRCS; do \
1634
		hfile=`echo $$file|sed 's/\\.hs$$//'`.html; \
1635
		$(HSCOLOUR) -css -anchor $$file > ../$(APIDOC_HS_DIR)/$$hfile ; \
1636
	done ; \
1637
	$(HADDOCK) --odir ../$(APIDOC_HS_DIR) --html --ignore-all-exports -w \
1638
		-t ganeti -p haddock-prologue \
1639
		--source-module="%{MODULE/.//}.html" \
1640
		--source-entity="%{MODULE/.//}.html#%{NAME}" \
1641
		$$OPTGHC \
1642
		$(filter-out Ganeti/HTools/ExtLoader.hs,$(HS_LIB_SRCS:htools/%=%))
1643

    
1644
.PHONY: TAGS
1645
TAGS: $(GENERATED_FILES)
1646
	rm -f TAGS
1647
	$(GHC) -e ":etags" -v0 \
1648
	  $(filter-out -O -Werror,$(HFLAGS)) \
1649
	  $(HTOOLS_NOCURL) $(HTOOLS_PARALLEL3) $(HTOOLS_REGEX_PCRE) \
1650
	  $(HS_LIBTEST_SRCS)
1651
	find . -path './lib/*.py' -o -path './scripts/gnt-*' -o \
1652
	  -path './daemons/ganeti-*' -o -path './tools/*' -o \
1653
	  -path './qa/*.py' | \
1654
	  etags -l python -a -
1655

    
1656
.PHONY: coverage
1657
if WANT_HTOOLS
1658
coverage: py-coverage hs-coverage
1659
else
1660
coverage: py-coverage
1661
endif
1662

    
1663
.PHONY: py-coverage
1664
py-coverage: $(GENERATED_FILES) $(python_tests)
1665
	@test -n "$(PYCOVERAGE)" || \
1666
	    { echo 'python-coverage' not found during configure; exit 1; }
1667
	set -e; \
1668
	COVERAGE=$(PYCOVERAGE) \
1669
	COVERAGE_FILE=$(CURDIR)/$(COVERAGE_PY_DIR)/data \
1670
	TEXT_COVERAGE=$(CURDIR)/$(COVERAGE_PY_DIR)/report.txt \
1671
	HTML_COVERAGE=$(CURDIR)/$(COVERAGE_PY_DIR) \
1672
	$(PLAIN_TESTS_ENVIRONMENT) $(abs_top_srcdir)/autotools/gen-coverage \
1673
	$(python_tests)
1674

    
1675
.PHONY: hs-coverage
1676
hs-coverage: $(haskell_tests) htest/hpc-htools
1677
	rm -f *.tix
1678
	$(MAKE) $(AM_MAKEFLAGS) hs-check
1679
	@mkdir_p@ $(COVERAGE_HS_DIR)
1680
	hpc combine --union $(HPCEXCL) \
1681
	  test.tix hpc-htools.tix > coverage-htools.tix
1682
	hpc markup --destdir=$(COVERAGE_HS_DIR) coverage-htools.tix
1683
	hpc report coverage-htools.tix
1684
	$(LN_S) -f hpc_index.html $(COVERAGE_HS_DIR)/index.html
1685

    
1686
# Special "kind-of-QA" target for htools, needs special setup (all
1687
# tools compiled with -fhpc)
1688
.PHONY: live-test
1689
live-test: all
1690
	set -e ; \
1691
	cd htools; \
1692
	rm -f .hpc; $(LN_S) ../.hpc .hpc; \
1693
	rm -f *.tix *.mix; \
1694
	./live-test.sh; \
1695
	hpc sum --union $(HPCEXCL) $(addsuffix .tix,$(HS_PROGS:htools/%=%)) \
1696
	  --output=live-test.tix ; \
1697
	@mkdir_p@ ../$(COVERAGE_HS_DIR) ; \
1698
	hpc markup --destdir=../$(COVERAGE_HS_DIR) live-test \
1699
		--srcdir=.. $(HPCEXCL) ; \
1700
	hpc report --srcdir=.. live-test $(HPCEXCL)
1701

    
1702
commit-check: distcheck lint apidoc
1703

    
1704
.PHONY: gitignore-check
1705
gitignore-check:
1706
	@if [ -n "`git status --short`" ]; then \
1707
	  echo "Git status is not clean!" 1>&2 ; \
1708
	  git status --short; \
1709
	  exit 1; \
1710
	fi
1711

    
1712
# Target that builds all binaries (including those that are not
1713
# rebuilt except when running the tests)
1714
.PHONY: really-all
1715
really-all: all $(check_SCRIPTS) $(haskell_tests)
1716

    
1717
# we don't need the ancient implicit rules:
1718
%: %,v
1719
%: RCS/%,v
1720
%: RCS/%
1721
%: s.%
1722
%: SCCS/s.%
1723

    
1724
-include ./Makefile.local
1725

    
1726
# vim: set noet :