Statistics
| Branch: | Tag: | Revision:

root / Makefile.am @ d85f01e7

History | View | Annotate | Download (36.4 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_MAN = $(top_srcdir)/autotools/check-man
25
CHECK_VERSION = $(top_srcdir)/autotools/check-version
26
CHECK_NEWS = $(top_srcdir)/autotools/check-news
27
CHECK_IMPORTS = $(top_srcdir)/autotools/check-imports
28
DOCPP = $(top_srcdir)/autotools/docpp
29
REPLACE_VARS_SED = autotools/replace_vars.sed
30
CONVERT_CONSTANTS = $(top_srcdir)/autotools/convert-constants
31

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

    
49
# Delete output file if an error occurred while building it
50
.DELETE_ON_ERROR:
51

    
52
HTOOLS_DIRS = \
53
	htools \
54
	htools/Ganeti \
55
	htools/Ganeti/HTools \
56
	htools/Ganeti/HTools/Program
57

    
58
DIRS = \
59
	autotools \
60
	daemons \
61
	devel \
62
	doc \
63
	doc/examples \
64
	doc/examples/hooks \
65
	doc/examples/gnt-debug \
66
	$(HTOOLS_DIRS) \
67
	lib \
68
	lib/client \
69
	lib/build \
70
	lib/confd \
71
	lib/http \
72
	lib/hypervisor \
73
	lib/impexpd \
74
	lib/masterd \
75
	lib/rapi \
76
	lib/server \
77
	lib/tools \
78
	lib/utils \
79
	lib/watcher \
80
	man \
81
	qa \
82
	test \
83
	test/data \
84
	test/data/ovfdata \
85
	test/data/ovfdata/other \
86
	tools
87

    
88
BUILDTIME_DIR_AUTOCREATE = \
89
	scripts \
90
	$(APIDOC_DIR) \
91
	$(APIDOC_PY_DIR) \
92
	$(APIDOC_HS_DIR) \
93
	$(APIDOC_HS_DIR)/Ganeti $(APIDOC_HS_DIR)/Ganeti/HTools \
94
	$(APIDOC_HS_DIR)/Ganeti/HTools/Program \
95
	$(COVERAGE_DIR) \
96
	$(COVERAGE_PY_DIR) \
97
	$(COVERAGE_HS_DIR) \
98
	.hpc
99

    
100
BUILDTIME_DIRS = \
101
	$(BUILDTIME_DIR_AUTOCREATE) \
102
	doc/html
103

    
104
DIRCHECK_EXCLUDE = \
105
	$(BUILDTIME_DIRS) \
106
	ganeti-[0-9]*.[0-9]*.[0-9]* \
107
	doc/html/_*
108

    
109
all_dirfiles = $(addsuffix /.dir,$(DIRS) $(BUILDTIME_DIR_AUTOCREATE))
110

    
111
# some helper vars
112
COVERAGE_DIR = doc/coverage
113
COVERAGE_PY_DIR = $(COVERAGE_DIR)/py
114
COVERAGE_HS_DIR = $(COVERAGE_DIR)/hs
115
APIDOC_DIR = doc/api
116
APIDOC_PY_DIR = $(APIDOC_DIR)/py
117
APIDOC_HS_DIR = $(APIDOC_DIR)/hs
118

    
119
MAINTAINERCLEANFILES = \
120
	$(docpng) \
121
	$(maninput) \
122
	doc/install-quick.rst \
123
	doc/news.rst \
124
	doc/upgrade.rst \
125
	vcs-version
126

    
127
maintainer-clean-local:
128
	rm -rf $(BUILDTIME_DIRS)
129

    
130
CLEANFILES = \
131
	$(addsuffix /*.py[co],$(DIRS)) \
132
	$(addsuffix /*.hi,$(HTOOLS_DIRS)) \
133
	$(addsuffix /*.o,$(HTOOLS_DIRS)) \
134
	$(all_dirfiles) \
135
	$(PYTHON_BOOTSTRAP) \
136
	epydoc.conf \
137
	autotools/replace_vars.sed \
138
	daemons/daemon-util \
139
	daemons/ganeti-cleaner \
140
	devel/upload \
141
	doc/examples/bash_completion \
142
	doc/examples/ganeti.initd \
143
	doc/examples/ganeti-kvm-poweroff.initd \
144
	doc/examples/ganeti.cron \
145
	doc/examples/gnt-config-backup \
146
	doc/examples/hooks/ipsec \
147
	$(man_MANS) \
148
	$(manhtml) \
149
	tools/kvm-ifup \
150
	stamp-srclinks \
151
	$(nodist_pkgpython_PYTHON) \
152
	$(HS_ALL_PROGS) $(HS_BUILT_SRCS) \
153
	.hpc/*.mix htools/*.tix \
154
	doc/hs-lint.html
155

    
156
# BUILT_SOURCES should only be used as a dependency on phony targets. Otherwise
157
# it'll cause the target to rebuild every time.
158
BUILT_SOURCES = \
159
	ganeti \
160
	stamp-srclinks \
161
	$(all_dirfiles) \
162
	$(PYTHON_BOOTSTRAP) \
163
	$(BUILT_PYTHON_SOURCES)
164

    
165
BUILT_PYTHON_SOURCES = \
166
	lib/_autoconf.py \
167
	lib/_vcsversion.py
168

    
169
nodist_pkgpython_PYTHON = \
170
	$(BUILT_PYTHON_SOURCES)
171

    
172
noinst_PYTHON = \
173
	lib/build/__init__.py \
174
	lib/build/sphinx_ext.py
175

    
176
pkgpython_PYTHON = \
177
	lib/__init__.py \
178
	lib/asyncnotifier.py \
179
	lib/backend.py \
180
	lib/bdev.py \
181
	lib/bootstrap.py \
182
	lib/cli.py \
183
	lib/cmdlib.py \
184
	lib/compat.py \
185
	lib/config.py \
186
	lib/constants.py \
187
	lib/daemon.py \
188
	lib/errors.py \
189
	lib/ht.py \
190
	lib/jqueue.py \
191
	lib/jstore.py \
192
	lib/locking.py \
193
	lib/luxi.py \
194
	lib/mcpu.py \
195
	lib/netutils.py \
196
	lib/objects.py \
197
	lib/opcodes.py \
198
	lib/ovf.py \
199
	lib/qlang.py \
200
	lib/query.py \
201
	lib/rpc.py \
202
	lib/runtime.py \
203
	lib/serializer.py \
204
	lib/ssconf.py \
205
	lib/ssh.py \
206
	lib/storage.py \
207
	lib/uidpool.py \
208
	lib/workerpool.py
209

    
210
client_PYTHON = \
211
	lib/client/__init__.py \
212
	lib/client/gnt_backup.py \
213
	lib/client/gnt_cluster.py \
214
	lib/client/gnt_debug.py \
215
	lib/client/gnt_group.py \
216
	lib/client/gnt_instance.py \
217
	lib/client/gnt_job.py \
218
	lib/client/gnt_node.py \
219
	lib/client/gnt_os.py
220

    
221
hypervisor_PYTHON = \
222
	lib/hypervisor/__init__.py \
223
	lib/hypervisor/hv_base.py \
224
	lib/hypervisor/hv_chroot.py \
225
	lib/hypervisor/hv_fake.py \
226
	lib/hypervisor/hv_kvm.py \
227
	lib/hypervisor/hv_lxc.py \
228
	lib/hypervisor/hv_xen.py
229

    
230
rapi_PYTHON = \
231
	lib/rapi/__init__.py \
232
	lib/rapi/baserlib.py \
233
	lib/rapi/client.py \
234
	lib/rapi/client_utils.py \
235
	lib/rapi/connector.py \
236
	lib/rapi/rlib2.py
237

    
238
http_PYTHON = \
239
	lib/http/__init__.py \
240
	lib/http/auth.py \
241
	lib/http/client.py \
242
	lib/http/server.py
243

    
244
confd_PYTHON = \
245
	lib/confd/__init__.py \
246
	lib/confd/client.py \
247
	lib/confd/querylib.py \
248
	lib/confd/server.py
249

    
250
masterd_PYTHON = \
251
	lib/masterd/__init__.py \
252
	lib/masterd/instance.py
253

    
254
impexpd_PYTHON = \
255
	lib/impexpd/__init__.py
256

    
257
watcher_PYTHON = \
258
	lib/watcher/__init__.py \
259
	lib/watcher/nodemaint.py \
260
	lib/watcher/state.py
261

    
262
server_PYTHON = \
263
	lib/server/__init__.py \
264
	lib/server/confd.py \
265
	lib/server/masterd.py \
266
	lib/server/noded.py \
267
	lib/server/rapi.py
268

    
269
pytools_PYTHON = \
270
	lib/tools/__init__.py \
271
	lib/tools/ensure_dirs.py
272

    
273
utils_PYTHON = \
274
	lib/utils/__init__.py \
275
	lib/utils/algo.py \
276
	lib/utils/filelock.py \
277
	lib/utils/hash.py \
278
	lib/utils/io.py \
279
	lib/utils/log.py \
280
	lib/utils/mlock.py \
281
	lib/utils/nodesetup.py \
282
	lib/utils/process.py \
283
	lib/utils/retry.py \
284
	lib/utils/text.py \
285
	lib/utils/wrapper.py \
286
	lib/utils/x509.py
287

    
288
docrst = \
289
	doc/admin.rst \
290
	doc/design-2.0.rst \
291
	doc/design-2.1.rst \
292
	doc/design-2.2.rst \
293
	doc/design-2.3.rst \
294
	doc/design-htools-2.3.rst \
295
	doc/design-2.4.rst \
296
	doc/design-2.5.rst \
297
	doc/design-draft.rst \
298
	doc/design-oob.rst \
299
	doc/design-cpu-pinning.rst \
300
	doc/design-query2.rst \
301
	doc/design-x509-ca.rst \
302
	doc/design-http-server.rst \
303
	doc/design-impexp2.rst \
304
	doc/design-lu-generated-jobs.rst \
305
	doc/design-multi-reloc.rst \
306
	doc/design-network.rst \
307
	doc/design-chained-jobs.rst \
308
	doc/design-ovf-support.rst \
309
	doc/design-resource-model.rst \
310
	doc/cluster-merge.rst \
311
	doc/design-shared-storage.rst \
312
	doc/design-node-state-cache.rst \
313
	doc/devnotes.rst \
314
	doc/glossary.rst \
315
	doc/hooks.rst \
316
	doc/iallocator.rst \
317
	doc/index.rst \
318
	doc/install-quick.rst \
319
	doc/install.rst \
320
	doc/locking.rst \
321
	doc/move-instance.rst \
322
	doc/news.rst \
323
	doc/rapi.rst \
324
	doc/security.rst \
325
	doc/upgrade.rst \
326
	doc/walkthrough.rst
327

    
328
HS_PROGS = htools/htools
329
HS_BIN_ROLES = hbal hscan hspace
330

    
331
HS_ALL_PROGS = $(HS_PROGS) htools/test
332
HS_PROG_SRCS = $(patsubst %,%.hs,$(HS_ALL_PROGS))
333
# we don't add -Werror by default
334
HFLAGS = -O -Wall -fwarn-monomorphism-restriction -fwarn-tabs -ihtools
335
# extra flags that can be overriden on the command line
336
HEXTRA =
337
# exclude options for coverage reports
338
HPCEXCL = --exclude Main \
339
	--exclude Ganeti.Constants \
340
	--exclude Ganeti.THH \
341
	--exclude Ganeti.HTools.QC \
342
	--exclude Ganeti.HTools.QCHelper \
343
	--exclude Ganeti.HTools.Version
344

    
345
HS_LIB_SRCS = \
346
	htools/Ganeti/HTools/CLI.hs \
347
	htools/Ganeti/HTools/Cluster.hs \
348
	htools/Ganeti/HTools/Compat.hs \
349
	htools/Ganeti/HTools/Container.hs \
350
	htools/Ganeti/HTools/ExtLoader.hs \
351
	htools/Ganeti/HTools/Group.hs \
352
	htools/Ganeti/HTools/IAlloc.hs \
353
	htools/Ganeti/HTools/Instance.hs \
354
	htools/Ganeti/HTools/JSON.hs \
355
	htools/Ganeti/HTools/Loader.hs \
356
	htools/Ganeti/HTools/Luxi.hs \
357
	htools/Ganeti/HTools/Node.hs \
358
	htools/Ganeti/HTools/PeerMap.hs \
359
	htools/Ganeti/HTools/QC.hs \
360
	htools/Ganeti/HTools/QCHelper.hs \
361
	htools/Ganeti/HTools/Rapi.hs \
362
	htools/Ganeti/HTools/Simu.hs \
363
	htools/Ganeti/HTools/Text.hs \
364
	htools/Ganeti/HTools/Types.hs \
365
	htools/Ganeti/HTools/Utils.hs \
366
	htools/Ganeti/HTools/Program/Hail.hs \
367
	htools/Ganeti/HTools/Program/Hbal.hs \
368
	htools/Ganeti/HTools/Program/Hscan.hs \
369
	htools/Ganeti/HTools/Program/Hspace.hs \
370
	htools/Ganeti/Jobs.hs \
371
	htools/Ganeti/Luxi.hs \
372
	htools/Ganeti/OpCodes.hs \
373
	htools/Ganeti/THH.hs
374

    
375
HS_BUILT_SRCS = htools/Ganeti/HTools/Version.hs htools/Ganeti/Constants.hs
376
HS_BUILT_SRCS_IN = $(patsubst %,%.in,$(HS_BUILT_SRCS))
377

    
378
$(RUN_IN_TEMPDIR): | $(all_dirfiles)
379

    
380
# Note: we use here an order-only prerequisite, as the contents of
381
# _autoconf.py are not actually influencing the html build output: it
382
# has to exist in order for the sphinx module to be loaded
383
# successfully, but we certainly don't want the docs to be rebuilt if
384
# it changes
385
doc/html/index.html: $(docrst) $(docpng) doc/conf.py configure.ac \
386
	$(RUN_IN_TEMPDIR) lib/build/sphinx_ext.py lib/opcodes.py lib/ht.py \
387
	| $(BUILT_PYTHON_SOURCES)
388
	@test -n "$(SPHINX)" || \
389
	    { echo 'sphinx-build' not found during configure; exit 1; }
390
	@mkdir_p@ $(dir $@)
391
	PYTHONPATH=. $(RUN_IN_TEMPDIR) $(SPHINX) -q -W -b html \
392
	    -d . \
393
	    -D version="$(VERSION_MAJOR).$(VERSION_MINOR)" \
394
	    -D release="$(PACKAGE_VERSION)" \
395
	    $(abs_top_srcdir)/doc $(CURDIR)/doc/html
396
	rm -f doc/html/.buildinfo doc/html/objects.inv
397
	touch $@
398

    
399
doc/html: doc/html/index.html
400

    
401
doc/install-quick.rst: INSTALL
402
doc/news.rst: NEWS
403
doc/upgrade.rst: UPGRADE
404

    
405
doc/install-quick.rst doc/news.rst doc/upgrade.rst:
406
	set -e; \
407
	{ echo '.. This file is automatically updated at build time from $<.'; \
408
	  echo '.. Do not edit.'; \
409
	  echo; \
410
	  cat $<; \
411
	} > $@
412

    
413
docdot = \
414
	doc/arch-2.0.dot \
415
	doc/design-2.1-lock-acquire.dot \
416
	doc/design-2.1-lock-release.dot
417

    
418
docpng = $(patsubst %.dot,%.png,$(docdot))
419

    
420
# Things to build but not to install (add it to EXTRA_DIST if it should be
421
# distributed)
422
noinst_DATA = \
423
	devel/upload \
424
	doc/html \
425
	doc/examples/bash_completion \
426
	doc/examples/ganeti.cron \
427
	doc/examples/ganeti.initd \
428
	doc/examples/ganeti-kvm-poweroff.initd \
429
	doc/examples/gnt-config-backup \
430
	doc/examples/hooks/ipsec \
431
	$(manhtml)
432

    
433
gnt_scripts = \
434
	scripts/gnt-backup \
435
	scripts/gnt-cluster \
436
	scripts/gnt-debug \
437
	scripts/gnt-group \
438
	scripts/gnt-instance \
439
	scripts/gnt-job \
440
	scripts/gnt-node \
441
	scripts/gnt-os
442

    
443
PYTHON_BOOTSTRAP_SBIN = \
444
	daemons/ganeti-confd \
445
	daemons/ganeti-masterd \
446
	daemons/ganeti-noded \
447
	daemons/ganeti-watcher \
448
	daemons/ganeti-rapi \
449
	scripts/gnt-backup \
450
	scripts/gnt-cluster \
451
	scripts/gnt-debug \
452
	scripts/gnt-group \
453
	scripts/gnt-instance \
454
	scripts/gnt-job \
455
	scripts/gnt-node \
456
	scripts/gnt-os
457

    
458
PYTHON_BOOTSTRAP = \
459
	$(PYTHON_BOOTSTRAP_SBIN) \
460
	tools/ensure-dirs
461

    
462
qa_scripts = \
463
	qa/ganeti-qa.py \
464
	qa/qa_cluster.py \
465
	qa/qa_config.py \
466
	qa/qa_daemon.py \
467
	qa/qa_env.py \
468
	qa/qa_error.py \
469
	qa/qa_group.py \
470
	qa/qa_instance.py \
471
	qa/qa_node.py \
472
	qa/qa_os.py \
473
	qa/qa_rapi.py \
474
	qa/qa_tags.py \
475
	qa/qa_utils.py
476

    
477
bin_SCRIPTS =
478
if WANT_HTOOLS
479
bin_SCRIPTS += $(filter-out htools/hail,$(HS_PROGS))
480
install-exec-hook:
481
	@mkdir_p@ $(DESTDIR)$(iallocatorsdir)
482
# FIXME: this is a hardcoded logic, instead of auto-resolving
483
	$(LN_S) -f ../../../bin/htools \
484
		   $(DESTDIR)$(iallocatorsdir)/hail
485
	for role in $(HS_BIN_ROLES); do \
486
		$(LN_S) -f htools \
487
			   $(DESTDIR)$(bindir)/$$role ; \
488
	done
489
endif
490

    
491
$(HS_ALL_PROGS): %: %.hs $(HS_LIB_SRCS) $(HS_BUILT_SRCS) Makefile
492
	@if [ -z "$(HTOOLS)" ]; then \
493
	  echo "Error: htools compilation disabled at configure time" 1>&2 ;\
494
	  exit 1; \
495
	fi
496
	@BINARY=$(@:htools/%=%); \
497
	if [ "$BINARY" = "test" ] && [ -z "$(GHC_PKG_QUICKCHECK)" ]; then \
498
	  echo "Error: cannot run unittests without the QuickCheck library (see devnotes.rst)" 1>&2; \
499
	  exit 1; \
500
	fi
501
	BINARY=$(@:htools/%=%); $(GHC) --make \
502
	  $(HFLAGS) $(HEXTRA) \
503
	  $(HTOOLS_NOCURL) $(HTOOLS_PARALLEL3) \
504
	  -osuf $$BINARY.o -hisuf $$BINARY.hi $@
505

    
506
# for the htools/test binary, we need to enable profiling/coverage
507
htools/test: HEXTRA=-fhpc -Wwarn -fno-warn-missing-signatures \
508
	-fno-warn-monomorphism-restriction -fno-warn-orphans \
509
	-fno-warn-missing-methods -fno-warn-unused-imports
510

    
511
dist_sbin_SCRIPTS = \
512
	tools/ganeti-listrunner
513

    
514
nodist_sbin_SCRIPTS = \
515
	$(PYTHON_BOOTSTRAP_SBIN) \
516
	daemons/ganeti-cleaner
517

    
518
dist_tools_PYTHON = \
519
	tools/burnin \
520
	tools/cfgshell \
521
	tools/cfgupgrade \
522
	tools/cfgupgrade12 \
523
	tools/cluster-merge \
524
	tools/lvmstrap \
525
	tools/move-instance \
526
	tools/ovfconverter \
527
	tools/setup-ssh \
528
	tools/sanitize-config
529

    
530
dist_tools_SCRIPTS = \
531
	$(dist_tools_PYTHON) \
532
	tools/kvm-console-wrapper \
533
	tools/xm-console-wrapper
534

    
535
pkglib_python_scripts = \
536
	daemons/import-export \
537
	tools/check-cert-expired
538

    
539
nodist_pkglib_python_scripts = \
540
	tools/ensure-dirs
541

    
542
pkglib_SCRIPTS = \
543
	daemons/daemon-util \
544
	tools/kvm-ifup \
545
	$(pkglib_python_scripts)
546

    
547
nodist_pkglib_SCRIPTS = \
548
	$(nodist_pkglib_python_scripts)
549

    
550
EXTRA_DIST = \
551
	NEWS \
552
	UPGRADE \
553
	epydoc.conf.in \
554
	pylintrc \
555
	autotools/build-bash-completion \
556
	autotools/check-python-code \
557
	autotools/check-imports \
558
	autotools/check-man \
559
	autotools/check-news \
560
	autotools/check-tar \
561
	autotools/check-version \
562
	autotools/convert-constants \
563
	autotools/docpp \
564
	autotools/gen-coverage \
565
	autotools/testrunner \
566
	$(RUN_IN_TEMPDIR) \
567
	daemons/daemon-util.in \
568
	daemons/ganeti-cleaner.in \
569
	$(pkglib_python_scripts) \
570
	devel/upload.in \
571
	tools/kvm-ifup.in \
572
	$(docdot) \
573
	$(docpng) \
574
	$(docrst) \
575
	doc/conf.py \
576
	doc/html \
577
	doc/examples/ganeti.initd.in \
578
	doc/examples/ganeti-kvm-poweroff.initd.in \
579
	doc/examples/ganeti.cron.in \
580
	doc/examples/gnt-config-backup.in \
581
	doc/examples/ganeti.default \
582
	doc/examples/ganeti.default-debug \
583
	doc/examples/hooks/ethers \
584
	doc/examples/hooks/ipsec.in \
585
	doc/examples/gnt-debug/README \
586
	doc/examples/gnt-debug/delay0.json \
587
	doc/examples/gnt-debug/delay50.json \
588
	test/testutils.py \
589
	test/mocks.py \
590
	$(dist_TESTS) \
591
	$(TEST_FILES) \
592
	man/footer.rst \
593
	$(manrst) \
594
	$(maninput) \
595
	qa/qa-sample.json \
596
	$(qa_scripts) \
597
	$(HS_LIB_SRCS) $(HS_BUILT_SRCS_IN) \
598
	$(HS_PROG_SRCS)
599

    
600
man_MANS = \
601
	man/ganeti.7 \
602
	man/ganeti-cleaner.8 \
603
	man/ganeti-confd.8 \
604
	man/ganeti-listrunner.8 \
605
	man/ganeti-masterd.8 \
606
	man/ganeti-noded.8 \
607
	man/ganeti-os-interface.7 \
608
	man/ganeti-rapi.8 \
609
	man/ganeti-watcher.8 \
610
	man/gnt-backup.8 \
611
	man/gnt-cluster.8 \
612
	man/gnt-debug.8 \
613
	man/gnt-group.8 \
614
	man/gnt-instance.8 \
615
	man/gnt-job.8 \
616
	man/gnt-node.8 \
617
	man/gnt-os.8 \
618
	man/hail.1 \
619
	man/hbal.1 \
620
	man/hscan.1 \
621
	man/hspace.1 \
622
	man/htools.1
623

    
624
manrst = $(patsubst %.1,%.rst,$(patsubst %.7,%.rst,$(patsubst %.8,%.rst,$(man_MANS))))
625
manhtml = $(patsubst %.rst,%.html,$(manrst))
626
mangen = $(patsubst %.rst,%.gen,$(manrst))
627
maninput = \
628
	$(patsubst %.1,%.1.in,$(patsubst %.7,%.7.in,$(patsubst %.8,%.8.in,$(man_MANS)))) \
629
	$(patsubst %.html,%.html.in,$(manhtml)) \
630
	man/footer.man man/footer.html $(mangen)
631

    
632
TEST_FILES = \
633
	test/data/bdev-drbd-8.0.txt \
634
	test/data/bdev-drbd-8.3.txt \
635
	test/data/bdev-drbd-disk.txt \
636
	test/data/bdev-drbd-net-ip4.txt \
637
	test/data/bdev-drbd-net-ip6.txt \
638
	test/data/cert1.pem \
639
	test/data/ip-addr-show-dummy0.txt \
640
	test/data/ip-addr-show-lo-ipv4.txt \
641
	test/data/ip-addr-show-lo-ipv6.txt \
642
	test/data/ip-addr-show-lo-oneline-ipv4.txt \
643
	test/data/ip-addr-show-lo-oneline-ipv6.txt \
644
	test/data/ip-addr-show-lo-oneline.txt \
645
	test/data/ip-addr-show-lo.txt \
646
	test/data/proc_drbd8.txt \
647
	test/data/proc_drbd80-emptyline.txt \
648
	test/data/proc_drbd83.txt \
649
	test/data/proc_drbd83_sync.txt \
650
	test/data/proc_drbd83_sync_krnl2.6.39.txt \
651
	test/data/sys_drbd_usermode_helper.txt \
652
	test/data/ovfdata/compr_disk.vmdk.gz \
653
	test/data/ovfdata/config.ini \
654
	test/data/ovfdata/corrupted_resources.ovf \
655
	test/data/ovfdata/empty.ini \
656
	test/data/ovfdata/empty.ovf \
657
	test/data/ovfdata/ganeti.mf \
658
	test/data/ovfdata/ganeti.ovf \
659
	test/data/ovfdata/gzip_disk.ovf \
660
	test/data/ovfdata/new_disk.vmdk \
661
	test/data/ovfdata/no_disk.ini \
662
	test/data/ovfdata/no_disk_in_ref.ovf \
663
	test/data/ovfdata/no_os.ini \
664
	test/data/ovfdata/no_ovf.ova \
665
	test/data/ovfdata/ova.ova \
666
	test/data/ovfdata/second_disk.vmdk \
667
	test/data/ovfdata/rawdisk.raw \
668
	test/data/ovfdata/unsafe_path.ini \
669
	test/data/ovfdata/virtualbox.ovf \
670
	test/data/ovfdata/wrong_extension.ovd \
671
	test/data/ovfdata/wrong_config.ini \
672
	test/data/ovfdata/wrong_manifest.mf \
673
	test/data/ovfdata/wrong_manifest.ovf \
674
	test/data/ovfdata/wrong_ova.ova \
675
	test/data/ovfdata/wrong_xml.ovf \
676
	test/data/ovfdata/other/rawdisk.raw \
677
	test/import-export_unittest-helper
678

    
679
python_tests = \
680
	test/ganeti.asyncnotifier_unittest.py \
681
	test/ganeti.backend_unittest.py \
682
	test/ganeti.bdev_unittest.py \
683
	test/ganeti.cli_unittest.py \
684
	test/ganeti.client.gnt_cluster_unittest.py \
685
	test/ganeti.client.gnt_instance_unittest.py \
686
	test/ganeti.daemon_unittest.py \
687
	test/ganeti.cmdlib_unittest.py \
688
	test/ganeti.compat_unittest.py \
689
	test/ganeti.confd.client_unittest.py \
690
	test/ganeti.config_unittest.py \
691
	test/ganeti.constants_unittest.py \
692
	test/ganeti.errors_unittest.py \
693
	test/ganeti.hooks_unittest.py \
694
	test/ganeti.ht_unittest.py \
695
	test/ganeti.http_unittest.py \
696
	test/ganeti.hypervisor_unittest.py \
697
	test/ganeti.hypervisor.hv_chroot_unittest.py \
698
	test/ganeti.hypervisor.hv_fake_unittest.py \
699
	test/ganeti.hypervisor.hv_kvm_unittest.py \
700
	test/ganeti.hypervisor.hv_lxc_unittest.py \
701
	test/ganeti.hypervisor.hv_xen_unittest.py \
702
	test/ganeti.impexpd_unittest.py \
703
	test/ganeti.jqueue_unittest.py \
704
	test/ganeti.locking_unittest.py \
705
	test/ganeti.luxi_unittest.py \
706
	test/ganeti.masterd.instance_unittest.py \
707
	test/ganeti.mcpu_unittest.py \
708
	test/ganeti.netutils_unittest.py \
709
	test/ganeti.objects_unittest.py \
710
	test/ganeti.opcodes_unittest.py \
711
	test/ganeti.ovf_unittest.py \
712
	test/ganeti.qlang_unittest.py \
713
	test/ganeti.query_unittest.py \
714
	test/ganeti.rapi.baserlib_unittest.py \
715
	test/ganeti.rapi.client_unittest.py \
716
	test/ganeti.rapi.resources_unittest.py \
717
	test/ganeti.rapi.rlib2_unittest.py \
718
	test/ganeti.rpc_unittest.py \
719
	test/ganeti.runtime_unittest.py \
720
	test/ganeti.serializer_unittest.py \
721
	test/ganeti.ssh_unittest.py \
722
	test/ganeti.tools.ensure_dirs_unittest.py \
723
	test/ganeti.uidpool_unittest.py \
724
	test/ganeti.utils.algo_unittest.py \
725
	test/ganeti.utils.filelock_unittest.py \
726
	test/ganeti.utils.hash_unittest.py \
727
	test/ganeti.utils.io_unittest.py \
728
	test/ganeti.utils.log_unittest.py \
729
	test/ganeti.utils.mlock_unittest.py \
730
	test/ganeti.utils.nodesetup_unittest.py \
731
	test/ganeti.utils.process_unittest.py \
732
	test/ganeti.utils.retry_unittest.py \
733
	test/ganeti.utils.text_unittest.py \
734
	test/ganeti.utils.wrapper_unittest.py \
735
	test/ganeti.utils.x509_unittest.py \
736
	test/ganeti.utils_unittest.py \
737
	test/ganeti.workerpool_unittest.py \
738
	test/cfgupgrade_unittest.py \
739
	test/docs_unittest.py \
740
	test/tempfile_fork_unittest.py
741

    
742
haskell_tests = htools/test
743

    
744
dist_TESTS = \
745
	test/check-cert-expired_unittest.bash \
746
	test/daemon-util_unittest.bash \
747
	test/ganeti-cleaner_unittest.bash \
748
	test/import-export_unittest.bash \
749
	$(python_tests)
750

    
751
nodist_TESTS =
752
if WANT_HTOOLSTESTS
753
nodist_TESTS += $(haskell_tests)
754
endif
755

    
756
TESTS = $(dist_TESTS) $(nodist_TESTS)
757

    
758
# Environment for all tests
759
PLAIN_TESTS_ENVIRONMENT = \
760
	PYTHONPATH=. TOP_SRCDIR=$(abs_top_srcdir) PYTHON=$(PYTHON) $(RUN_IN_TEMPDIR)
761

    
762
# Environment for tests run by automake
763
TESTS_ENVIRONMENT = \
764
	$(PLAIN_TESTS_ENVIRONMENT) $(abs_top_srcdir)/autotools/testrunner
765

    
766
all_python_code = \
767
	$(dist_sbin_SCRIPTS) \
768
	$(dist_tools_PYTHON) \
769
	$(pkglib_python_scripts) \
770
	$(nodist_pkglib_python_scripts) \
771
	$(python_tests) \
772
	$(pkgpython_PYTHON) \
773
	$(client_PYTHON) \
774
	$(hypervisor_PYTHON) \
775
	$(rapi_PYTHON) \
776
	$(server_PYTHON) \
777
	$(pytools_PYTHON) \
778
	$(http_PYTHON) \
779
	$(confd_PYTHON) \
780
	$(masterd_PYTHON) \
781
	$(impexpd_PYTHON) \
782
	$(utils_PYTHON) \
783
	$(watcher_PYTHON) \
784
	$(noinst_PYTHON) \
785
	$(qa_scripts)
786

    
787
srclink_files = \
788
	man/footer.rst \
789
	test/check-cert-expired_unittest.bash \
790
	test/daemon-util_unittest.bash \
791
	test/ganeti-cleaner_unittest.bash \
792
	test/import-export_unittest.bash \
793
	$(all_python_code) \
794
	$(HS_LIB_SRCS) $(HS_PROG_SRCS)
795

    
796
check_python_code = \
797
	$(BUILD_BASH_COMPLETION) \
798
	$(CHECK_IMPORTS) \
799
	$(DOCPP) \
800
	$(all_python_code)
801

    
802
lint_python_code = \
803
	ganeti \
804
	ganeti/http/server.py \
805
	$(dist_sbin_SCRIPTS) \
806
	$(dist_tools_PYTHON) \
807
	$(pkglib_python_scripts) \
808
	$(BUILD_BASH_COMPLETION) \
809
	$(CHECK_IMPORTS) \
810
	$(DOCPP) \
811
	$(PYTHON_BOOTSTRAP)
812

    
813
standalone_python_modules = \
814
	lib/rapi/client.py \
815
	tools/ganeti-listrunner
816

    
817
pep8_python_code = \
818
	ganeti \
819
	ganeti/http/server.py \
820
	$(dist_sbin_SCRIPTS) \
821
	$(dist_tools_PYTHON) \
822
	$(pkglib_python_scripts) \
823
	$(BUILD_BASH_COMPLETION) \
824
	$(DOCPP) \
825
	$(PYTHON_BOOTSTRAP) \
826
	qa
827

    
828
test/daemon-util_unittest.bash: daemons/daemon-util
829

    
830
test/ganeti-cleaner_unittest.bash: daemons/ganeti-cleaner
831

    
832
tools/kvm-ifup: tools/kvm-ifup.in $(REPLACE_VARS_SED)
833
	sed -f $(REPLACE_VARS_SED) < $< > $@
834
	chmod +x $@
835

    
836
devel/upload: devel/upload.in $(REPLACE_VARS_SED)
837
	sed -f $(REPLACE_VARS_SED) < $< > $@
838
	chmod u+x $@
839

    
840
daemons/%: daemons/%.in $(REPLACE_VARS_SED)
841
	sed -f $(REPLACE_VARS_SED) < $< > $@
842
	chmod +x $@
843

    
844
doc/examples/%: doc/examples/%.in $(REPLACE_VARS_SED)
845
	sed -f $(REPLACE_VARS_SED) < $< > $@
846

    
847
doc/examples/hooks/%: doc/examples/hooks/%.in $(REPLACE_VARS_SED)
848
	sed -f $(REPLACE_VARS_SED) < $< > $@
849

    
850
doc/examples/bash_completion: $(BUILD_BASH_COMPLETION) $(RUN_IN_TEMPDIR) \
851
	lib/cli.py $(gnt_scripts) $(client_PYTHON) tools/burnin
852
	PYTHONPATH=. $(RUN_IN_TEMPDIR) $(CURDIR)/$(BUILD_BASH_COMPLETION) > $@
853

    
854
doc/%.png: doc/%.dot
855
	@test -n "$(DOT)" || { echo 'dot' not found during configure; exit 1; }
856
	$(DOT) -Tpng -o $@ $<
857

    
858
man/footer.man: man/footer.rst
859
	@test -n "$(PANDOC)" || \
860
	  { echo 'pandoc' not found during configure; exit 1; }
861
	$(PANDOC) -f rst -t man -o $@ $<
862

    
863
man/footer.html: man/footer.rst
864
	@test -n "$(PANDOC)" || \
865
	  { echo 'pandoc' not found during configure; exit 1; }
866
	$(PANDOC) -f rst -t html -o $@ $<
867

    
868
man/%.gen: man/%.rst lib/query.py lib/build/sphinx_ext.py
869
	PYTHONPATH=. $(RUN_IN_TEMPDIR) $(CURDIR)/$(DOCPP) < $< > $@
870

    
871
man/%.7.in man/%.8.in man/%.1.in: man/%.gen man/footer.man
872
	@test -n "$(PANDOC)" || \
873
	  { echo 'pandoc' not found during configure; exit 1; }
874
	set -o pipefail ; \
875
	$(PANDOC) -s -f rst -t man -A man/footer.man $< | \
876
	  sed -e 's/\\@/@/g' > $@
877
	if test -n "$(MAN_HAS_WARNINGS)"; then $(CHECK_MAN) $@; fi
878

    
879
man/%.html.in: man/%.gen man/footer.html
880
	@test -n "$(PANDOC)" || \
881
	  { echo 'pandoc' not found during configure; exit 1; }
882
	set -o pipefail ; \
883
	$(PANDOC) -s -f rst -t html -A man/footer.html $< | \
884
	  sed -e 's/\\@/@/g' > $@
885

    
886
man/%.1: man/%.1.in $(REPLACE_VARS_SED)
887
	sed -f $(REPLACE_VARS_SED) < $< > $@
888

    
889
man/%.7: man/%.7.in $(REPLACE_VARS_SED)
890
	sed -f $(REPLACE_VARS_SED) < $< > $@
891

    
892
man/%.8: man/%.8.in $(REPLACE_VARS_SED)
893
	sed -f $(REPLACE_VARS_SED) < $< > $@
894

    
895
man/%.html: man/%.html.in $(REPLACE_VARS_SED)
896
	sed -f $(REPLACE_VARS_SED) < $< > $@
897

    
898
epydoc.conf: epydoc.conf.in Makefile
899
	sed -e 's#@MODULES@#$(strip $(lint_python_code))#g' < $< > $@
900

    
901
vcs-version:
902
	if test -d .git; then \
903
	  git describe > $@; \
904
	elif test ! -f $@ ; then \
905
	  echo "Cannot auto-generate $@ file"; exit 1; \
906
	fi
907

    
908
.PHONY: regen-vcs-version
909
regen-vcs-version:
910
	set -e; \
911
	cd $(srcdir); \
912
	if test -d .git; then \
913
	  rm -f vcs-version; \
914
	  $(MAKE) vcs-version; \
915
	fi
916

    
917
htools/Ganeti/HTools/Version.hs: htools/Ganeti/HTools/Version.hs.in vcs-version
918
	set -e; \
919
	VCSVER=`cat $(abs_top_srcdir)/vcs-version`; \
920
	sed -e "s/%ver%/$$VCSVER/" < $< > $@
921

    
922
htools/Ganeti/Constants.hs: htools/Ganeti/Constants.hs.in \
923
	lib/constants.py lib/_autoconf.py $(CONVERT_CONSTANTS)
924
	set -e; \
925
	{ cat $< ; PYTHONPATH=. $(CONVERT_CONSTANTS); } > $@
926

    
927
lib/_autoconf.py: Makefile | lib/.dir
928
	set -e; \
929
	{ echo '# This file is automatically generated, do not edit!'; \
930
	  echo '#'; \
931
	  echo ''; \
932
	  echo '"""Build-time configuration for Ganeti.'; \
933
	  echo '';\
934
	  echo 'This file is autogenerated by the build process.'; \
935
	  echo 'For any changes you need to re-run ./configure (and'; \
936
	  echo 'not edit by hand).'; \
937
	  echo ''; \
938
	  echo '"""'; \
939
	  echo ''; \
940
	  echo '# pylint: disable=C0301,C0324'; \
941
	  echo '# because this is autogenerated, we do not want'; \
942
	  echo '# style warnings' ; \
943
	  echo ''; \
944
	  echo "PACKAGE_VERSION = '$(PACKAGE_VERSION)'"; \
945
	  echo "VERSION_MAJOR = '$(VERSION_MAJOR)'"; \
946
	  echo "VERSION_MINOR = '$(VERSION_MINOR)'"; \
947
	  echo "VERSION_REVISION = '$(VERSION_REVISION)'"; \
948
	  echo "VERSION_SUFFIX = '$(VERSION_SUFFIX)'"; \
949
	  echo "VERSION_FULL = '$(VERSION_FULL)'"; \
950
	  echo "LOCALSTATEDIR = '$(localstatedir)'"; \
951
	  echo "SYSCONFDIR = '$(sysconfdir)'"; \
952
	  echo "SSH_CONFIG_DIR = '$(SSH_CONFIG_DIR)'"; \
953
	  echo "EXPORT_DIR = '$(EXPORT_DIR)'"; \
954
	  echo "OS_SEARCH_PATH = [$(OS_SEARCH_PATH)]"; \
955
	  echo "XEN_BOOTLOADER = '$(XEN_BOOTLOADER)'"; \
956
	  echo "XEN_KERNEL = '$(XEN_KERNEL)'"; \
957
	  echo "XEN_INITRD = '$(XEN_INITRD)'"; \
958
	  echo "FILE_STORAGE_DIR = '$(FILE_STORAGE_DIR)'"; \
959
	  echo "ENABLE_FILE_STORAGE = $(ENABLE_FILE_STORAGE)"; \
960
	  echo "SHARED_FILE_STORAGE_DIR = '$(SHARED_FILE_STORAGE_DIR)'"; \
961
	  echo "ENABLE_SHARED_FILE_STORAGE = $(ENABLE_SHARED_FILE_STORAGE)"; \
962
	  echo "IALLOCATOR_SEARCH_PATH = [$(IALLOCATOR_SEARCH_PATH)]"; \
963
	  echo "KVM_PATH = '$(KVM_PATH)'"; \
964
	  echo "IP_PATH = '$(IP_PATH)'"; \
965
	  echo "SOCAT_PATH = '$(SOCAT)'"; \
966
	  echo "SOCAT_USE_ESCAPE = $(SOCAT_USE_ESCAPE)"; \
967
	  echo "SOCAT_USE_COMPRESS = $(SOCAT_USE_COMPRESS)"; \
968
	  echo "LVM_STRIPECOUNT = $(LVM_STRIPECOUNT)"; \
969
	  echo "TOOLSDIR = '$(toolsdir)'"; \
970
	  echo "GNT_SCRIPTS = [$(foreach i,$(notdir $(gnt_scripts)),'$(i)',)]"; \
971
	  echo "PKGLIBDIR = '$(pkglibdir)'"; \
972
	  echo "DRBD_BARRIERS = $(DRBD_BARRIERS)"; \
973
	  echo "SYSLOG_USAGE = '$(SYSLOG_USAGE)'"; \
974
	  echo "DAEMONS_GROUP = '$(DAEMONS_GROUP)'"; \
975
	  echo "ADMIN_GROUP = '$(ADMIN_GROUP)'"; \
976
	  echo "MASTERD_USER = '$(MASTERD_USER)'"; \
977
	  echo "MASTERD_GROUP = '$(MASTERD_GROUP)'"; \
978
	  echo "RAPI_USER = '$(RAPI_USER)'"; \
979
	  echo "RAPI_GROUP = '$(RAPI_GROUP)'"; \
980
	  echo "CONFD_USER = '$(CONFD_USER)'"; \
981
	  echo "CONFD_GROUP = '$(CONFD_GROUP)'"; \
982
	  echo "NODED_USER = '$(NODED_USER)'"; \
983
	  echo "NODED_GROUP = '$(NODED_GROUP)'"; \
984
	  echo "DISK_SEPARATOR = '$(DISK_SEPARATOR)'"; \
985
	  if [ "$(HTOOLS)" ]; then \
986
	    echo "HTOOLS = True"; \
987
	  else \
988
	    echo "HTOOLS = False"; \
989
	  fi; \
990
	} > $@
991

    
992
lib/_vcsversion.py: Makefile vcs-version | lib/.dir
993
	set -e; \
994
	VCSVER=`cat $(abs_top_srcdir)/vcs-version`; \
995
	{ echo '# This file is automatically generated, do not edit!'; \
996
	  echo '#'; \
997
	  echo ''; \
998
	  echo '"""Build-time VCS version number for Ganeti.'; \
999
	  echo '';\
1000
	  echo 'This file is autogenerated by the build process.'; \
1001
	  echo 'For any changes you need to re-run ./configure (and'; \
1002
	  echo 'not edit by hand).'; \
1003
	  echo ''; \
1004
	  echo '"""'; \
1005
	  echo ''; \
1006
	  echo '# pylint: disable=C0301,C0324'; \
1007
	  echo '# because this is autogenerated, we do not want'; \
1008
	  echo '# style warnings' ; \
1009
	  echo ''; \
1010
	  echo "VCS_VERSION = '$$VCSVER'"; \
1011
	} > $@
1012

    
1013
$(REPLACE_VARS_SED): Makefile
1014
	set -e; \
1015
	{ echo 's#@PREFIX@#$(prefix)#g'; \
1016
	  echo 's#@SYSCONFDIR@#$(sysconfdir)#g'; \
1017
	  echo 's#@LOCALSTATEDIR@#$(localstatedir)#g'; \
1018
	  echo 's#@BINDIR@#$(bindir)#g'; \
1019
	  echo 's#@SBINDIR@#$(sbindir)#g'; \
1020
	  echo 's#@GANETI_VERSION@#$(PACKAGE_VERSION)#g'; \
1021
	  echo 's#@CUSTOM_XEN_BOOTLOADER@#$(XEN_BOOTLOADER)#g'; \
1022
	  echo 's#@CUSTOM_XEN_KERNEL@#$(XEN_KERNEL)#g'; \
1023
	  echo 's#@CUSTOM_XEN_INITRD@#$(XEN_INITRD)#g'; \
1024
	  echo 's#@CUSTOM_IALLOCATOR_SEARCH_PATH@#$(IALLOCATOR_SEARCH_PATH)#g'; \
1025
	  echo 's#@CUSTOM_EXPORT_DIR@#$(EXPORT_DIR)#g'; \
1026
	  echo 's#@RPL_FILE_STORAGE_DIR@#$(FILE_STORAGE_DIR)#g'; \
1027
	  echo 's#@RPL_SSH_INITD_SCRIPT@#$(SSH_INITD_SCRIPT)#g'; \
1028
	  echo 's#@PKGLIBDIR@#$(pkglibdir)#g'; \
1029
	  echo 's#@GNTMASTERUSER@#$(MASTERD_USER)#g'; \
1030
	  echo 's#@GNTRAPIUSER@#$(RAPI_USER)#g'; \
1031
	  echo 's#@GNTCONFDUSER@#$(CONFD_USER)#g'; \
1032
	  echo 's#@GNTNODEDUSER@#$(NODED_USER)#g'; \
1033
	  echo 's#@GNTRAPIGROUP@#$(RAPI_GROUP)#g'; \
1034
	  echo 's#@GNTADMINGROUP@#$(ADMIN_GROUP)#g'; \
1035
	  echo 's#@GNTCONFDGROUP@#$(CONFD_GROUP)#g'; \
1036
	  echo 's#@GNTMASTERDGROUP@#$(MASTERD_GROUP)#g'; \
1037
	  echo 's#@GNTDAEMONSGROUP@#$(DAEMONS_GROUP)#g'; \
1038
	} > $@
1039

    
1040
# Using deferred evaluation
1041
daemons/ganeti-%: MODULE = ganeti.server.$(patsubst ganeti-%,%,$(notdir $@))
1042
daemons/ganeti-watcher: MODULE = ganeti.watcher
1043
scripts/%: MODULE = ganeti.client.$(subst -,_,$(notdir $@))
1044
tools/ensure-dirs: MODULE = ganeti.tools.ensure_dirs
1045

    
1046
$(PYTHON_BOOTSTRAP): Makefile | $(all_dirfiles)
1047
	test -n "$(MODULE)" || { echo Missing module; exit 1; }
1048
	set -e; \
1049
	{ echo '#!/usr/bin/python'; \
1050
	  echo '# This file is automatically generated, do not edit!'; \
1051
	  echo "# Edit $(MODULE) instead."; \
1052
	  echo; \
1053
	  echo '"""Bootstrap script for L{$(MODULE)}"""'; \
1054
	  echo; \
1055
	  echo '# pylint: disable=C0103'; \
1056
	  echo '# C0103: Invalid name'; \
1057
	  echo; \
1058
	  echo 'import sys'; \
1059
	  echo 'import $(MODULE) as main'; \
1060
	  echo; \
1061
	  echo '# Temporarily alias commands until bash completion'; \
1062
	  echo '# generator is changed'; \
1063
	  echo 'if hasattr(main, "commands"):'; \
1064
	  echo '  commands = main.commands # pylint: disable=E1101'; \
1065
	  echo 'if hasattr(main, "aliases"):'; \
1066
	  echo '  aliases = main.aliases # pylint: disable=E1101'; \
1067
	  echo; \
1068
	  echo 'if __name__ == "__main__":'; \
1069
	  echo '  sys.exit(main.Main())'; \
1070
	} > $@
1071
	chmod u+x $@
1072

    
1073
# We need to create symlinks because "make distcheck" will not install Python
1074
# files when building.
1075
stamp-srclinks: Makefile | $(all_dirfiles)
1076
	set -e; \
1077
	for i in $(srclink_files); do \
1078
		if test ! -f $$i -a -f $(abs_top_srcdir)/$$i; then \
1079
			$(LN_S) $(abs_top_srcdir)/$$i $$i; \
1080
		fi; \
1081
	done
1082
	touch $@
1083

    
1084
.PHONY: ganeti
1085
ganeti:
1086
	cd $(top_builddir) && test -h "$@" || { rm -f $@ && $(LN_S) lib $@; }
1087

    
1088
.PHONY: check-dirs
1089
check-dirs: $(BUILT_SOURCES)
1090
	@set -e; \
1091
	find . -type d \( \( -name . \) -o \( \
1092
		-name .git -o \
1093
		-name autom4te.cache \
1094
		\) -prune -o -print \) | { \
1095
		error=; \
1096
		while read dir; do \
1097
			case "$$dir" in \
1098
				$(strip $(patsubst %,(./%) ;;,$(DIRCHECK_EXCLUDE) $(DIRS))) \
1099
				*) error=1; echo "Directory $$dir not listed in Makefile" >&2 ;; \
1100
			esac; \
1101
		done; \
1102
		for dir in $(DIRS); do \
1103
			if ! test -d "$$dir"; then \
1104
				echo "Directory $$dir listed in DIRS does not exist" >&2; \
1105
				error=1; \
1106
			fi \
1107
		done; \
1108
		if test -n "$$error"; then exit 1; else exit 0; fi; \
1109
	}
1110

    
1111
.PHONY: check-local
1112
check-local: check-dirs $(BUILT_SOURCES)
1113
	$(CHECK_PYTHON_CODE) $(check_python_code)
1114
	$(CHECK_VERSION) $(VERSION) $(top_srcdir)/NEWS
1115
	$(CHECK_NEWS) < $(top_srcdir)/NEWS
1116
	PYTHONPATH=. $(RUN_IN_TEMPDIR) $(CURDIR)/$(CHECK_IMPORTS) . $(standalone_python_modules)
1117
	expver=$(VERSION_MAJOR).$(VERSION_MINOR); \
1118
	if test "`head -n 1 $(top_srcdir)/README`" != "Ganeti $$expver"; then \
1119
		echo "Incorrect version in README, expected $$expver"; \
1120
		exit 1; \
1121
	fi; \
1122
	for file in doc/iallocator.rst doc/hooks.rst; do \
1123
		if test "`sed -ne '4 p' $(top_srcdir)/$$file`" != \
1124
			"Documents Ganeti version $$expver"; then \
1125
			echo "Incorrect version in $$file, expected $$expver"; \
1126
			exit 1; \
1127
		fi; \
1128
	done
1129

    
1130
.PHONY: hs-check
1131
hs-check: htools/test
1132
	@rm -f test.tix
1133
	./htools/test
1134

    
1135
# E111: indentation is not a multiple of four
1136
# E261: at least two spaces before inline comment
1137
# E501: line too long (80 characters)
1138
PEP8_IGNORE = E111,E261,E501
1139

    
1140
# For excluding pep8 expects filenames only, not whole paths
1141
PEP8_EXCLUDE = $(subst $(space),$(comma),$(strip $(notdir $(BUILT_PYTHON_SOURCES))))
1142

    
1143
.PHONY: lint
1144
lint: $(BUILT_SOURCES)
1145
	@test -n "$(PYLINT)" || { echo 'pylint' not found during configure; exit 1; }
1146
	if test -z "$(PEP8)"; then \
1147
		echo '"pep8" not found during configure' >&2; \
1148
	else \
1149
		$(PEP8) --repeat --ignore='$(PEP8_IGNORE)' --exclude='$(PEP8_EXCLUDE)' \
1150
			$(pep8_python_code); \
1151
	fi
1152
	$(PYLINT) $(LINT_OPTS) $(lint_python_code)
1153
	cd $(top_srcdir)/qa && \
1154
	  PYTHONPATH=$(abs_top_srcdir) $(PYLINT) $(LINT_OPTS) \
1155
	  --rcfile  ../pylintrc $(patsubst qa/%.py,%,$(qa_scripts))
1156

    
1157
.PHONY: hlint
1158
hlint: $(HS_BUILT_SRCS)
1159
	if tty -s; then C="-c"; else C=""; fi; \
1160
	hlint --report=doc/hs-lint.html $$C htools
1161

    
1162
# a dist hook rule for updating the vcs-version file; this is
1163
# hardcoded due to where it needs to build the file...
1164
dist-hook:
1165
	$(MAKE) regen-vcs-version && \
1166
	rm -f $(top_distdir)/vcs-version && \
1167
	cp -p $(srcdir)/vcs-version $(top_distdir)
1168

    
1169
# a distcheck hook rule for catching revision control directories
1170
distcheck-hook:
1171
	if find $(top_distdir) -name .svn -or -name .git | grep .; then \
1172
		echo "Found revision control files in final archive." 1>&2; \
1173
		exit 1; \
1174
	fi
1175
	if find $(top_distdir) -name '*.py[co]' | grep .; then \
1176
		echo "Found Python byte code in final archive." 1>&2; \
1177
		exit 1; \
1178
	fi
1179
	if find $(top_distdir) -name '*~' | grep .; then \
1180
		echo "Found backup files in final archive." 1>&2; \
1181
		exit 1; \
1182
	fi
1183
# Empty files or directories should not be distributed. They can cause
1184
# unnecessary warnings for packagers. Directories used by automake during
1185
# distcheck must be excluded.
1186
	if find $(top_distdir) -empty -and -not \( \
1187
			-path $(top_distdir)/_build -or \
1188
			-path $(top_distdir)/_inst \) | grep .; then \
1189
		echo "Found empty files or directories in final archive." 1>&2; \
1190
		exit 1; \
1191
	fi
1192
	if test -n "$(BUILD_RELEASE)" && \
1193
	   grep -n -H -E '^\*.*unreleased' $(top_distdir)/NEWS; then \
1194
		echo "Found unreleased version in NEWS." >&2; \
1195
		exit 1; \
1196
	fi
1197

    
1198
# When building a release, stricter checks should be used
1199
distcheck-release dist-release: export BUILD_RELEASE = 1
1200
distcheck-release: distcheck
1201

    
1202
dist-release: dist
1203
	set -e; \
1204
	for i in $(DIST_ARCHIVES); do \
1205
		echo -n "Checking $$i ... "; \
1206
		autotools/check-tar < $$i; \
1207
		echo OK; \
1208
	done
1209

    
1210
install-exec-local:
1211
	@mkdir_p@ "$(DESTDIR)${localstatedir}/lib/ganeti" \
1212
	  "$(DESTDIR)${localstatedir}/log/ganeti" \
1213
	  "$(DESTDIR)${localstatedir}/run/ganeti"
1214

    
1215
# To avoid conflicts between directory names and other targets, a file inside
1216
# the directory is used to ensure its existence.
1217
%.dir:
1218
	@mkdir_p@ $* && touch $@
1219

    
1220
.PHONY: apidoc
1221
if WANT_HTOOLSAPIDOC
1222
apidoc: py-apidoc hs-apidoc
1223
else
1224
apidoc: py-apidoc
1225
endif
1226

    
1227
.PHONY: py-apidoc
1228
py-apidoc: epydoc.conf $(RUN_IN_TEMPDIR) $(BUILT_SOURCES)
1229
	$(RUN_IN_TEMPDIR) epydoc -v \
1230
		--conf $(CURDIR)/epydoc.conf \
1231
		--output $(CURDIR)/$(APIDOC_PY_DIR)
1232

    
1233
.PHONY: hs-apidoc
1234
hs-apidoc: $(HS_BUILT_SRCS)
1235
	@test -n "$(HSCOLOUR)" || \
1236
	    { echo 'HsColour' not found during configure; exit 1; }
1237
	@test -n "$(HADDOCK)" || \
1238
	    { echo 'haddock' not found during configure; exit 1; }
1239
	rm -rf $(APIDOC_HS_DIR)/*
1240
	@mkdir_p@ $(APIDOC_HS_DIR)/Ganeti/HTools/Program
1241
	$(HSCOLOUR) -print-css > $(APIDOC_HS_DIR)/Ganeti/hscolour.css
1242
	$(LN_S) ../hscolour.css $(APIDOC_HS_DIR)/Ganeti/HTools/hscolour.css
1243
	set -e ; \
1244
	cd htools; \
1245
	if [ "$(HTOOLS_NOCURL)" ]; \
1246
	then OPTGHC="--optghc=$(HTOOLS_NOCURL)"; \
1247
	else OPTGHC=""; \
1248
	fi; \
1249
	if [ "$(HTOOLS_PARALLEL3)" ]; \
1250
	then OPTGHC="$$OPTGHC --optghc=$(HTOOLS_PARALLEL3)"; \
1251
	fi; \
1252
	RELSRCS="$(HS_LIB_SRCS:htools/%=%)  $(HS_BUILT_SRCS:htools/%=%)"; \
1253
	for file in $$RELSRCS; do \
1254
		hfile=`echo $$file|sed 's/\\.hs$$//'`.html; \
1255
		$(HSCOLOUR) -css -anchor $$file > ../$(APIDOC_HS_DIR)/$$hfile ; \
1256
	done ; \
1257
	$(HADDOCK) --odir ../$(APIDOC_HS_DIR) --html --ignore-all-exports -w \
1258
		-t ganeti-htools -p haddock-prologue \
1259
		--source-module="%{MODULE/.//}.html" \
1260
		--source-entity="%{MODULE/.//}.html#%{NAME}" \
1261
		$$OPTGHC \
1262
		$(filter-out Ganeti/HTools/ExtLoader.hs,$(HS_LIB_SRCS:htools/%=%))
1263

    
1264
.PHONY: TAGS
1265
TAGS: $(BUILT_SOURCES)
1266
	rm -f TAGS
1267
	find . -path './lib/*.py' -o -path './scripts/gnt-*' -o \
1268
	  -path './daemons/ganeti-*' -o -path './tools/*' -o \
1269
	  -path './qa/*.py' | \
1270
	  etags -l python -
1271

    
1272
.PHONY: coverage
1273
if WANT_HTOOLS
1274
coverage: py-coverage hs-coverage
1275
else
1276
coverage: py-coverage
1277
endif
1278

    
1279
.PHONY: py-coverage
1280
py-coverage: $(BUILT_SOURCES) $(python_tests)
1281
	set -e; \
1282
	COVERAGE_FILE=$(CURDIR)/$(COVERAGE_PY_DIR)/data \
1283
	TEXT_COVERAGE=$(CURDIR)/$(COVERAGE_PY_DIR)/report.txt \
1284
	HTML_COVERAGE=$(CURDIR)/$(COVERAGE_PY_DIR) \
1285
	$(PLAIN_TESTS_ENVIRONMENT) $(abs_top_srcdir)/autotools/gen-coverage \
1286
	$(python_tests)
1287

    
1288
.PHONY: hs-coverage
1289
hs-coverage: $(haskell_tests)
1290
	cd htools && rm -f *.tix *.mix && ./test
1291
	@mkdir_p@ $(COVERAGE_HS_DIR)
1292
	hpc markup --destdir=$(COVERAGE_HS_DIR) htools/test $(HPCEXCL)
1293
	hpc report htools/test $(HPCEXCL)
1294
	$(LN_S) -f hpc_index.html $(COVERAGE_HS_DIR)/index.html
1295

    
1296
# Special "kind-of-QA" target for htools, needs special setup (all
1297
# tools compiled with -fhpc)
1298
.PHONY: live-test
1299
live-test: all
1300
	set -e ; \
1301
	cd htools; \
1302
	rm -f .hpc; $(LN_S) ../.hpc .hpc; \
1303
	rm -f *.tix *.mix; \
1304
	./live-test.sh; \
1305
	hpc sum --union $(HPCEXCL) $(addsuffix .tix,$(HS_PROGS:htools/%=%)) \
1306
	  --output=live-test.tix ; \
1307
	@mkdir_p@ ../$(COVERAGE_HS_DIR) ; \
1308
	hpc markup --destdir=../$(COVERAGE_HS_DIR) live-test \
1309
		--srcdir=.. $(HPCEXCL) ; \
1310
	hpc report --srcdir=.. live-test $(HPCEXCL)
1311

    
1312
commit-check: distcheck lint apidoc
1313

    
1314
-include ./Makefile.local
1315

    
1316
# vim: set noet :