Statistics
| Branch: | Tag: | Revision:

root / Makefile.am @ 0c37d1e4

History | View | Annotate | Download (37.7 kB)

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

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

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

    
17
# Use bash in order to be able to use pipefail
18
SHELL=/bin/bash
19

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

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

    
51
# Delete output file if an error occurred while building it
52
.DELETE_ON_ERROR:
53

    
54
HTOOLS_DIRS = \
55
	htools \
56
	htools/Ganeti \
57
	htools/Ganeti/HTools \
58
	htools/Ganeti/HTools/Program
59

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

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

    
102
BUILDTIME_DIRS = \
103
	$(BUILDTIME_DIR_AUTOCREATE) \
104
	doc/html
105

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

    
111
all_dirfiles = $(addsuffix /.dir,$(DIRS) $(BUILDTIME_DIR_AUTOCREATE))
112

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

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

    
129
maintainer-clean-local:
130
	rm -rf $(BUILDTIME_DIRS)
131

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

    
155
# BUILT_SOURCES should only be used as a dependency on phony targets. Otherwise
156
# it'll cause the target to rebuild every time.
157
BUILT_SOURCES = \
158
  $(built_base_sources) \
159
	$(BUILT_PYTHON_SOURCES) \
160
	$(PYTHON_BOOTSTRAP)
161

    
162
built_base_sources = \
163
	ganeti \
164
	stamp-srclinks \
165
	$(all_dirfiles)
166

    
167
built_python_base_sources = \
168
	lib/_autoconf.py \
169
	lib/_vcsversion.py
170

    
171
BUILT_PYTHON_SOURCES = \
172
	$(built_python_base_sources) \
173
	lib/_generated_rpc.py
174

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

    
179
# these are all built from the underlying %.in sources
180
BUILT_EXAMPLES = \
181
	doc/examples/ganeti-kvm-poweroff.initd \
182
	doc/examples/ganeti.cron \
183
	doc/examples/ganeti.initd \
184
	doc/examples/gnt-config-backup \
185
	doc/examples/hooks/ipsec
186

    
187
nodist_pkgpython_PYTHON = \
188
	$(BUILT_PYTHON_SOURCES)
189

    
190
noinst_PYTHON = \
191
	lib/build/__init__.py \
192
	lib/build/sphinx_ext.py
193

    
194
pkgpython_PYTHON = \
195
	lib/__init__.py \
196
	lib/asyncnotifier.py \
197
	lib/backend.py \
198
	lib/bdev.py \
199
	lib/bootstrap.py \
200
	lib/cli.py \
201
	lib/cmdlib.py \
202
	lib/compat.py \
203
	lib/config.py \
204
	lib/constants.py \
205
	lib/daemon.py \
206
	lib/errors.py \
207
	lib/ht.py \
208
	lib/jqueue.py \
209
	lib/jstore.py \
210
	lib/locking.py \
211
	lib/luxi.py \
212
	lib/mcpu.py \
213
	lib/netutils.py \
214
	lib/objects.py \
215
	lib/opcodes.py \
216
	lib/ovf.py \
217
	lib/qlang.py \
218
	lib/query.py \
219
	lib/rpc.py \
220
	lib/rpc_defs.py \
221
	lib/runtime.py \
222
	lib/serializer.py \
223
	lib/ssconf.py \
224
	lib/ssh.py \
225
	lib/storage.py \
226
	lib/uidpool.py \
227
	lib/workerpool.py
228

    
229
client_PYTHON = \
230
	lib/client/__init__.py \
231
	lib/client/gnt_backup.py \
232
	lib/client/gnt_cluster.py \
233
	lib/client/gnt_debug.py \
234
	lib/client/gnt_group.py \
235
	lib/client/gnt_instance.py \
236
	lib/client/gnt_job.py \
237
	lib/client/gnt_node.py \
238
	lib/client/gnt_os.py
239

    
240
hypervisor_PYTHON = \
241
	lib/hypervisor/__init__.py \
242
	lib/hypervisor/hv_base.py \
243
	lib/hypervisor/hv_chroot.py \
244
	lib/hypervisor/hv_fake.py \
245
	lib/hypervisor/hv_kvm.py \
246
	lib/hypervisor/hv_lxc.py \
247
	lib/hypervisor/hv_xen.py
248

    
249
rapi_PYTHON = \
250
	lib/rapi/__init__.py \
251
	lib/rapi/baserlib.py \
252
	lib/rapi/client.py \
253
	lib/rapi/client_utils.py \
254
	lib/rapi/connector.py \
255
	lib/rapi/rlib2.py
256

    
257
http_PYTHON = \
258
	lib/http/__init__.py \
259
	lib/http/auth.py \
260
	lib/http/client.py \
261
	lib/http/server.py
262

    
263
confd_PYTHON = \
264
	lib/confd/__init__.py \
265
	lib/confd/client.py \
266
	lib/confd/querylib.py \
267
	lib/confd/server.py
268

    
269
masterd_PYTHON = \
270
	lib/masterd/__init__.py \
271
	lib/masterd/instance.py
272

    
273
impexpd_PYTHON = \
274
	lib/impexpd/__init__.py
275

    
276
watcher_PYTHON = \
277
	lib/watcher/__init__.py \
278
	lib/watcher/nodemaint.py \
279
	lib/watcher/state.py
280

    
281
server_PYTHON = \
282
	lib/server/__init__.py \
283
	lib/server/confd.py \
284
	lib/server/masterd.py \
285
	lib/server/noded.py \
286
	lib/server/rapi.py
287

    
288
pytools_PYTHON = \
289
	lib/tools/__init__.py \
290
	lib/tools/ensure_dirs.py
291

    
292
utils_PYTHON = \
293
	lib/utils/__init__.py \
294
	lib/utils/algo.py \
295
	lib/utils/filelock.py \
296
	lib/utils/hash.py \
297
	lib/utils/io.py \
298
	lib/utils/log.py \
299
	lib/utils/mlock.py \
300
	lib/utils/nodesetup.py \
301
	lib/utils/process.py \
302
	lib/utils/retry.py \
303
	lib/utils/text.py \
304
	lib/utils/wrapper.py \
305
	lib/utils/x509.py
306

    
307
docrst = \
308
	doc/admin.rst \
309
	doc/design-2.0.rst \
310
	doc/design-2.1.rst \
311
	doc/design-2.2.rst \
312
	doc/design-2.3.rst \
313
	doc/design-htools-2.3.rst \
314
	doc/design-2.4.rst \
315
	doc/design-2.5.rst \
316
	doc/design-draft.rst \
317
	doc/design-oob.rst \
318
	doc/design-cpu-pinning.rst \
319
	doc/design-query2.rst \
320
	doc/design-x509-ca.rst \
321
	doc/design-http-server.rst \
322
	doc/design-impexp2.rst \
323
	doc/design-lu-generated-jobs.rst \
324
	doc/design-multi-reloc.rst \
325
	doc/design-network.rst \
326
	doc/design-chained-jobs.rst \
327
	doc/design-ovf-support.rst \
328
	doc/design-resource-model.rst \
329
	doc/cluster-merge.rst \
330
	doc/design-shared-storage.rst \
331
	doc/design-node-state-cache.rst \
332
	doc/design-virtual-clusters.rst \
333
	doc/devnotes.rst \
334
	doc/glossary.rst \
335
	doc/hooks.rst \
336
	doc/iallocator.rst \
337
	doc/index.rst \
338
	doc/install-quick.rst \
339
	doc/install.rst \
340
	doc/locking.rst \
341
	doc/move-instance.rst \
342
	doc/news.rst \
343
	doc/rapi.rst \
344
	doc/security.rst \
345
	doc/upgrade.rst \
346
	doc/walkthrough.rst
347

    
348
HS_PROGS = htools/htools
349
HS_BIN_ROLES = hbal hscan hspace
350

    
351
HS_ALL_PROGS = $(HS_PROGS) htools/test
352
HS_PROG_SRCS = $(patsubst %,%.hs,$(HS_ALL_PROGS))
353
# we don't add -Werror by default
354
HFLAGS = -O -Wall -fwarn-monomorphism-restriction -fwarn-tabs -ihtools
355
# extra flags that can be overriden on the command line
356
HEXTRA =
357
# exclude options for coverage reports
358
HPCEXCL = --exclude Main \
359
	--exclude Ganeti.Constants \
360
	--exclude Ganeti.THH \
361
	--exclude Ganeti.HTools.QC \
362
	--exclude Ganeti.HTools.QCHelper \
363
	--exclude Ganeti.HTools.Version
364

    
365
HS_LIB_SRCS = \
366
	htools/Ganeti/HTools/CLI.hs \
367
	htools/Ganeti/HTools/Cluster.hs \
368
	htools/Ganeti/HTools/Compat.hs \
369
	htools/Ganeti/HTools/Container.hs \
370
	htools/Ganeti/HTools/ExtLoader.hs \
371
	htools/Ganeti/HTools/Group.hs \
372
	htools/Ganeti/HTools/IAlloc.hs \
373
	htools/Ganeti/HTools/Instance.hs \
374
	htools/Ganeti/HTools/JSON.hs \
375
	htools/Ganeti/HTools/Loader.hs \
376
	htools/Ganeti/HTools/Luxi.hs \
377
	htools/Ganeti/HTools/Node.hs \
378
	htools/Ganeti/HTools/PeerMap.hs \
379
	htools/Ganeti/HTools/QC.hs \
380
	htools/Ganeti/HTools/QCHelper.hs \
381
	htools/Ganeti/HTools/Rapi.hs \
382
	htools/Ganeti/HTools/Simu.hs \
383
	htools/Ganeti/HTools/Text.hs \
384
	htools/Ganeti/HTools/Types.hs \
385
	htools/Ganeti/HTools/Utils.hs \
386
	htools/Ganeti/HTools/Program/Hail.hs \
387
	htools/Ganeti/HTools/Program/Hbal.hs \
388
	htools/Ganeti/HTools/Program/Hscan.hs \
389
	htools/Ganeti/HTools/Program/Hspace.hs \
390
	htools/Ganeti/BasicTypes.hs \
391
	htools/Ganeti/Jobs.hs \
392
	htools/Ganeti/Luxi.hs \
393
	htools/Ganeti/OpCodes.hs \
394
	htools/Ganeti/THH.hs
395

    
396
HS_BUILT_SRCS = htools/Ganeti/HTools/Version.hs htools/Ganeti/Constants.hs
397
HS_BUILT_SRCS_IN = $(patsubst %,%.in,$(HS_BUILT_SRCS))
398

    
399
$(RUN_IN_TEMPDIR): | $(all_dirfiles)
400

    
401
# Note: we use here an order-only prerequisite, as the contents of
402
# _autoconf.py are not actually influencing the html build output: it
403
# has to exist in order for the sphinx module to be loaded
404
# successfully, but we certainly don't want the docs to be rebuilt if
405
# it changes
406
doc/html/index.html: $(docrst) $(docpng) doc/conf.py configure.ac \
407
	$(RUN_IN_TEMPDIR) lib/build/sphinx_ext.py lib/opcodes.py lib/ht.py \
408
	| $(BUILT_PYTHON_SOURCES)
409
	@test -n "$(SPHINX)" || \
410
	    { echo 'sphinx-build' not found during configure; exit 1; }
411
	@mkdir_p@ $(dir $@)
412
	PYTHONPATH=. $(RUN_IN_TEMPDIR) $(SPHINX) -q -W -b html \
413
	    -d . \
414
	    -D version="$(VERSION_MAJOR).$(VERSION_MINOR)" \
415
	    -D release="$(PACKAGE_VERSION)" \
416
	    $(abs_top_srcdir)/doc $(CURDIR)/doc/html
417
	rm -f doc/html/.buildinfo doc/html/objects.inv
418
	touch $@
419

    
420
doc/html: doc/html/index.html
421

    
422
doc/install-quick.rst: INSTALL
423
doc/news.rst: NEWS
424
doc/upgrade.rst: UPGRADE
425

    
426
doc/install-quick.rst doc/news.rst doc/upgrade.rst:
427
	set -e; \
428
	{ echo '.. This file is automatically updated at build time from $<.'; \
429
	  echo '.. Do not edit.'; \
430
	  echo; \
431
	  cat $<; \
432
	} > $@
433

    
434
docdot = \
435
	doc/arch-2.0.dot \
436
	doc/design-2.1-lock-acquire.dot \
437
	doc/design-2.1-lock-release.dot
438

    
439
docpng = $(patsubst %.dot,%.png,$(docdot))
440

    
441
# Things to build but not to install (add it to EXTRA_DIST if it should be
442
# distributed)
443
noinst_DATA = \
444
	devel/upload \
445
	doc/html \
446
	$(BUILT_EXAMPLES) \
447
	doc/examples/bash_completion \
448
	$(manhtml)
449

    
450
gnt_scripts = \
451
	scripts/gnt-backup \
452
	scripts/gnt-cluster \
453
	scripts/gnt-debug \
454
	scripts/gnt-group \
455
	scripts/gnt-instance \
456
	scripts/gnt-job \
457
	scripts/gnt-node \
458
	scripts/gnt-os
459

    
460
PYTHON_BOOTSTRAP_SBIN = \
461
	daemons/ganeti-confd \
462
	daemons/ganeti-masterd \
463
	daemons/ganeti-noded \
464
	daemons/ganeti-watcher \
465
	daemons/ganeti-rapi \
466
	$(gnt_scripts)
467

    
468
PYTHON_BOOTSTRAP = \
469
	$(PYTHON_BOOTSTRAP_SBIN) \
470
	tools/ensure-dirs
471

    
472
qa_scripts = \
473
	qa/ganeti-qa.py \
474
	qa/qa_cluster.py \
475
	qa/qa_config.py \
476
	qa/qa_daemon.py \
477
	qa/qa_env.py \
478
	qa/qa_error.py \
479
	qa/qa_group.py \
480
	qa/qa_instance.py \
481
	qa/qa_node.py \
482
	qa/qa_os.py \
483
	qa/qa_rapi.py \
484
	qa/qa_tags.py \
485
	qa/qa_utils.py
486

    
487
bin_SCRIPTS =
488
if WANT_HTOOLS
489
bin_SCRIPTS += $(filter-out htools/hail,$(HS_PROGS))
490
install-exec-hook:
491
	@mkdir_p@ $(DESTDIR)$(iallocatorsdir)
492
# FIXME: this is a hardcoded logic, instead of auto-resolving
493
	$(LN_S) -f ../../../bin/htools \
494
		   $(DESTDIR)$(iallocatorsdir)/hail
495
	for role in $(HS_BIN_ROLES); do \
496
		$(LN_S) -f htools \
497
			   $(DESTDIR)$(bindir)/$$role ; \
498
	done
499
endif
500

    
501
$(HS_ALL_PROGS): %: %.hs $(HS_LIB_SRCS) $(HS_BUILT_SRCS) Makefile
502
	@if [ -z "$(HTOOLS)" ]; then \
503
	  echo "Error: htools compilation disabled at configure time" 1>&2 ;\
504
	  exit 1; \
505
	fi
506
	@BINARY=$(@:htools/%=%); \
507
	if [ "$BINARY" = "test" ] && [ -z "$(GHC_PKG_QUICKCHECK)" ]; then \
508
	  echo "Error: cannot run unittests without the QuickCheck library (see devnotes.rst)" 1>&2; \
509
	  exit 1; \
510
	fi
511
	BINARY=$(@:htools/%=%); $(GHC) --make \
512
	  $(HFLAGS) \
513
	  $(HTOOLS_NOCURL) $(HTOOLS_PARALLEL3) \
514
	  -osuf $$BINARY.o -hisuf $$BINARY.hi \
515
	  $(HEXTRA) $@
516

    
517
# for the htools/test binary, we need to enable profiling/coverage
518
htools/test: HEXTRA=-fhpc -Wwarn -fno-warn-missing-signatures \
519
	-fno-warn-monomorphism-restriction -fno-warn-orphans \
520
	-fno-warn-missing-methods -fno-warn-unused-imports
521

    
522
dist_sbin_SCRIPTS = \
523
	tools/ganeti-listrunner
524

    
525
nodist_sbin_SCRIPTS = \
526
	$(PYTHON_BOOTSTRAP_SBIN) \
527
	daemons/ganeti-cleaner
528

    
529
python_scripts = \
530
	tools/burnin \
531
	tools/cfgshell \
532
	tools/cfgupgrade \
533
	tools/cfgupgrade12 \
534
	tools/cluster-merge \
535
	tools/confd-client \
536
	tools/lvmstrap \
537
	tools/move-instance \
538
	tools/ovfconverter \
539
	tools/setup-ssh \
540
	tools/sanitize-config
541

    
542
dist_tools_SCRIPTS = \
543
	$(python_scripts) \
544
	tools/kvm-console-wrapper \
545
	tools/xm-console-wrapper \
546
	tools/master-ip-setup
547

    
548
pkglib_python_scripts = \
549
	daemons/import-export \
550
	tools/check-cert-expired
551

    
552
nodist_pkglib_python_scripts = \
553
	tools/ensure-dirs
554

    
555
pkglib_SCRIPTS = \
556
	daemons/daemon-util \
557
	tools/kvm-ifup \
558
	$(pkglib_python_scripts)
559

    
560
nodist_pkglib_SCRIPTS = \
561
	$(nodist_pkglib_python_scripts)
562

    
563
EXTRA_DIST = \
564
	NEWS \
565
	UPGRADE \
566
	epydoc.conf.in \
567
	pylintrc \
568
	autotools/build-bash-completion \
569
	autotools/build-rpc \
570
	autotools/check-header \
571
	autotools/check-python-code \
572
	autotools/check-imports \
573
	autotools/check-man \
574
	autotools/check-news \
575
	autotools/check-tar \
576
	autotools/check-version \
577
	autotools/convert-constants \
578
	autotools/docpp \
579
	autotools/gen-coverage \
580
	autotools/testrunner \
581
	$(RUN_IN_TEMPDIR) \
582
	daemons/daemon-util.in \
583
	daemons/ganeti-cleaner.in \
584
	$(pkglib_python_scripts) \
585
	devel/upload.in \
586
	tools/kvm-ifup.in \
587
	$(docdot) \
588
	$(docpng) \
589
	$(docrst) \
590
	doc/conf.py \
591
	doc/html \
592
	$(BUILT_EXAMPLES:%=%.in) \
593
	doc/examples/ganeti.default \
594
	doc/examples/ganeti.default-debug \
595
	doc/examples/hooks/ethers \
596
	doc/examples/gnt-debug/README \
597
	doc/examples/gnt-debug/delay0.json \
598
	doc/examples/gnt-debug/delay50.json \
599
	test/lockperf.py \
600
	test/testutils.py \
601
	test/mocks.py \
602
	$(dist_TESTS) \
603
	$(TEST_FILES) \
604
	man/footer.rst \
605
	$(manrst) \
606
	$(maninput) \
607
	qa/qa-sample.json \
608
	$(qa_scripts) \
609
	$(HS_LIB_SRCS) $(HS_BUILT_SRCS_IN) \
610
	$(HS_PROG_SRCS) \
611
	htools/lint-hints.hs
612

    
613
man_MANS = \
614
	man/ganeti.7 \
615
	man/ganeti-cleaner.8 \
616
	man/ganeti-confd.8 \
617
	man/ganeti-listrunner.8 \
618
	man/ganeti-masterd.8 \
619
	man/ganeti-noded.8 \
620
	man/ganeti-os-interface.7 \
621
	man/ganeti-rapi.8 \
622
	man/ganeti-watcher.8 \
623
	man/gnt-backup.8 \
624
	man/gnt-cluster.8 \
625
	man/gnt-debug.8 \
626
	man/gnt-group.8 \
627
	man/gnt-instance.8 \
628
	man/gnt-job.8 \
629
	man/gnt-node.8 \
630
	man/gnt-os.8 \
631
	man/hail.1 \
632
	man/hbal.1 \
633
	man/hscan.1 \
634
	man/hspace.1 \
635
	man/htools.1
636

    
637
manrst = $(patsubst %.1,%.rst,$(patsubst %.7,%.rst,$(patsubst %.8,%.rst,$(man_MANS))))
638
manhtml = $(patsubst %.rst,%.html,$(manrst))
639
mangen = $(patsubst %.rst,%.gen,$(manrst))
640
maninput = \
641
	$(patsubst %.1,%.1.in,$(patsubst %.7,%.7.in,$(patsubst %.8,%.8.in,$(man_MANS)))) \
642
	$(patsubst %.html,%.html.in,$(manhtml)) \
643
	man/footer.man man/footer.html $(mangen)
644

    
645
TEST_FILES = \
646
	test/data/bdev-drbd-8.0.txt \
647
	test/data/bdev-drbd-8.3.txt \
648
	test/data/bdev-drbd-disk.txt \
649
	test/data/bdev-drbd-net-ip4.txt \
650
	test/data/bdev-drbd-net-ip6.txt \
651
	test/data/cert1.pem \
652
	test/data/ip-addr-show-dummy0.txt \
653
	test/data/ip-addr-show-lo-ipv4.txt \
654
	test/data/ip-addr-show-lo-ipv6.txt \
655
	test/data/ip-addr-show-lo-oneline-ipv4.txt \
656
	test/data/ip-addr-show-lo-oneline-ipv6.txt \
657
	test/data/ip-addr-show-lo-oneline.txt \
658
	test/data/ip-addr-show-lo.txt \
659
	test/data/proc_drbd8.txt \
660
	test/data/proc_drbd80-emptyline.txt \
661
	test/data/proc_drbd83.txt \
662
	test/data/proc_drbd83_sync.txt \
663
	test/data/proc_drbd83_sync_krnl2.6.39.txt \
664
	test/data/kvm_1.0_help.txt \
665
	test/data/kvm_0.15.90_help.txt \
666
	test/data/kvm_0.12.5_help.txt \
667
	test/data/kvm_0.9.1_help.txt \
668
	test/data/sys_drbd_usermode_helper.txt \
669
	test/data/ovfdata/compr_disk.vmdk.gz \
670
	test/data/ovfdata/config.ini \
671
	test/data/ovfdata/corrupted_resources.ovf \
672
	test/data/ovfdata/empty.ini \
673
	test/data/ovfdata/empty.ovf \
674
	test/data/ovfdata/ganeti.mf \
675
	test/data/ovfdata/ganeti.ovf \
676
	test/data/ovfdata/gzip_disk.ovf \
677
	test/data/ovfdata/new_disk.vmdk \
678
	test/data/ovfdata/no_disk.ini \
679
	test/data/ovfdata/no_disk_in_ref.ovf \
680
	test/data/ovfdata/no_os.ini \
681
	test/data/ovfdata/no_ovf.ova \
682
	test/data/ovfdata/ova.ova \
683
	test/data/ovfdata/second_disk.vmdk \
684
	test/data/ovfdata/rawdisk.raw \
685
	test/data/ovfdata/unsafe_path.ini \
686
	test/data/ovfdata/virtualbox.ovf \
687
	test/data/ovfdata/wrong_extension.ovd \
688
	test/data/ovfdata/wrong_config.ini \
689
	test/data/ovfdata/wrong_manifest.mf \
690
	test/data/ovfdata/wrong_manifest.ovf \
691
	test/data/ovfdata/wrong_ova.ova \
692
	test/data/ovfdata/wrong_xml.ovf \
693
	test/data/ovfdata/other/rawdisk.raw \
694
	test/import-export_unittest-helper
695

    
696
python_tests = \
697
	test/ganeti.asyncnotifier_unittest.py \
698
	test/ganeti.backend_unittest.py \
699
	test/ganeti.bdev_unittest.py \
700
	test/ganeti.cli_unittest.py \
701
	test/ganeti.client.gnt_cluster_unittest.py \
702
	test/ganeti.client.gnt_instance_unittest.py \
703
	test/ganeti.daemon_unittest.py \
704
	test/ganeti.cmdlib_unittest.py \
705
	test/ganeti.compat_unittest.py \
706
	test/ganeti.confd.client_unittest.py \
707
	test/ganeti.config_unittest.py \
708
	test/ganeti.constants_unittest.py \
709
	test/ganeti.errors_unittest.py \
710
	test/ganeti.hooks_unittest.py \
711
	test/ganeti.ht_unittest.py \
712
	test/ganeti.http_unittest.py \
713
	test/ganeti.hypervisor_unittest.py \
714
	test/ganeti.hypervisor.hv_chroot_unittest.py \
715
	test/ganeti.hypervisor.hv_fake_unittest.py \
716
	test/ganeti.hypervisor.hv_kvm_unittest.py \
717
	test/ganeti.hypervisor.hv_lxc_unittest.py \
718
	test/ganeti.hypervisor.hv_xen_unittest.py \
719
	test/ganeti.impexpd_unittest.py \
720
	test/ganeti.jqueue_unittest.py \
721
	test/ganeti.locking_unittest.py \
722
	test/ganeti.luxi_unittest.py \
723
	test/ganeti.masterd.instance_unittest.py \
724
	test/ganeti.mcpu_unittest.py \
725
	test/ganeti.netutils_unittest.py \
726
	test/ganeti.objects_unittest.py \
727
	test/ganeti.opcodes_unittest.py \
728
	test/ganeti.ovf_unittest.py \
729
	test/ganeti.qlang_unittest.py \
730
	test/ganeti.query_unittest.py \
731
	test/ganeti.rapi.baserlib_unittest.py \
732
	test/ganeti.rapi.client_unittest.py \
733
	test/ganeti.rapi.resources_unittest.py \
734
	test/ganeti.rapi.rlib2_unittest.py \
735
	test/ganeti.rpc_unittest.py \
736
	test/ganeti.runtime_unittest.py \
737
	test/ganeti.serializer_unittest.py \
738
	test/ganeti.ssh_unittest.py \
739
	test/ganeti.tools.ensure_dirs_unittest.py \
740
	test/ganeti.uidpool_unittest.py \
741
	test/ganeti.utils.algo_unittest.py \
742
	test/ganeti.utils.filelock_unittest.py \
743
	test/ganeti.utils.hash_unittest.py \
744
	test/ganeti.utils.io_unittest.py \
745
	test/ganeti.utils.log_unittest.py \
746
	test/ganeti.utils.mlock_unittest.py \
747
	test/ganeti.utils.nodesetup_unittest.py \
748
	test/ganeti.utils.process_unittest.py \
749
	test/ganeti.utils.retry_unittest.py \
750
	test/ganeti.utils.text_unittest.py \
751
	test/ganeti.utils.wrapper_unittest.py \
752
	test/ganeti.utils.x509_unittest.py \
753
	test/ganeti.utils_unittest.py \
754
	test/ganeti.workerpool_unittest.py \
755
	test/cfgupgrade_unittest.py \
756
	test/docs_unittest.py \
757
	test/pycurl_reset_unittest.py \
758
	test/tempfile_fork_unittest.py
759
if HAS_FAKEROOT
760
python_tests += test/ganeti.utils.io_unittest-runasroot.py
761
endif
762

    
763
haskell_tests = htools/test
764

    
765
dist_TESTS = \
766
	test/check-cert-expired_unittest.bash \
767
	test/daemon-util_unittest.bash \
768
	test/ganeti-cleaner_unittest.bash \
769
	test/import-export_unittest.bash \
770
	$(python_tests)
771

    
772
nodist_TESTS =
773
if WANT_HTOOLSTESTS
774
nodist_TESTS += $(haskell_tests)
775
endif
776

    
777
TESTS = $(dist_TESTS) $(nodist_TESTS)
778

    
779
# Environment for all tests
780
PLAIN_TESTS_ENVIRONMENT = \
781
	PYTHONPATH=. TOP_SRCDIR=$(abs_top_srcdir) PYTHON=$(PYTHON) \
782
	FAKEROOT=$(FAKEROOT_PATH) $(RUN_IN_TEMPDIR)
783

    
784
# Environment for tests run by automake
785
TESTS_ENVIRONMENT = \
786
	$(PLAIN_TESTS_ENVIRONMENT) $(abs_top_srcdir)/autotools/testrunner
787

    
788
all_python_code = \
789
	$(dist_sbin_SCRIPTS) \
790
	$(python_scripts) \
791
	$(pkglib_python_scripts) \
792
	$(nodist_pkglib_python_scripts) \
793
	$(python_tests) \
794
	$(pkgpython_PYTHON) \
795
	$(client_PYTHON) \
796
	$(hypervisor_PYTHON) \
797
	$(rapi_PYTHON) \
798
	$(server_PYTHON) \
799
	$(pytools_PYTHON) \
800
	$(http_PYTHON) \
801
	$(confd_PYTHON) \
802
	$(masterd_PYTHON) \
803
	$(impexpd_PYTHON) \
804
	$(utils_PYTHON) \
805
	$(watcher_PYTHON) \
806
	$(noinst_PYTHON) \
807
	$(qa_scripts)
808

    
809
srclink_files = \
810
	man/footer.rst \
811
	test/check-cert-expired_unittest.bash \
812
	test/daemon-util_unittest.bash \
813
	test/ganeti-cleaner_unittest.bash \
814
	test/import-export_unittest.bash \
815
	$(all_python_code) \
816
	$(HS_LIB_SRCS) $(HS_PROG_SRCS)
817

    
818
check_python_code = \
819
	$(BUILD_BASH_COMPLETION) \
820
	$(CHECK_IMPORTS) \
821
	$(CHECK_HEADER) \
822
	$(DOCPP) \
823
	$(all_python_code)
824

    
825
lint_python_code = \
826
	ganeti \
827
	ganeti/http/server.py \
828
	$(dist_sbin_SCRIPTS) \
829
	$(python_scripts) \
830
	$(pkglib_python_scripts) \
831
	$(BUILD_BASH_COMPLETION) \
832
	$(CHECK_IMPORTS) \
833
	$(CHECK_HEADER) \
834
	$(DOCPP) \
835
	$(PYTHON_BOOTSTRAP)
836

    
837
standalone_python_modules = \
838
	lib/rapi/client.py \
839
	tools/ganeti-listrunner
840

    
841
pep8_python_code = \
842
	ganeti \
843
	ganeti/http/server.py \
844
	$(dist_sbin_SCRIPTS) \
845
	$(python_scripts) \
846
	$(pkglib_python_scripts) \
847
	$(BUILD_BASH_COMPLETION) \
848
	$(CHECK_HEADER) \
849
	$(DOCPP) \
850
	$(PYTHON_BOOTSTRAP) \
851
	qa
852

    
853
test/daemon-util_unittest.bash: daemons/daemon-util
854

    
855
test/ganeti-cleaner_unittest.bash: daemons/ganeti-cleaner
856

    
857
tools/kvm-ifup: tools/kvm-ifup.in $(REPLACE_VARS_SED)
858
	sed -f $(REPLACE_VARS_SED) < $< > $@
859
	chmod +x $@
860

    
861
devel/upload: devel/upload.in $(REPLACE_VARS_SED)
862
	sed -f $(REPLACE_VARS_SED) < $< > $@
863
	chmod u+x $@
864

    
865
daemons/%: daemons/%.in $(REPLACE_VARS_SED)
866
	sed -f $(REPLACE_VARS_SED) < $< > $@
867
	chmod +x $@
868

    
869
doc/examples/%: doc/examples/%.in $(REPLACE_VARS_SED)
870
	sed -f $(REPLACE_VARS_SED) < $< > $@
871

    
872
doc/examples/hooks/%: doc/examples/hooks/%.in $(REPLACE_VARS_SED)
873
	sed -f $(REPLACE_VARS_SED) < $< > $@
874

    
875
doc/examples/bash_completion: $(BUILD_BASH_COMPLETION) $(RUN_IN_TEMPDIR) \
876
	lib/cli.py $(gnt_scripts) $(client_PYTHON) tools/burnin
877
	PYTHONPATH=. $(RUN_IN_TEMPDIR) $(CURDIR)/$(BUILD_BASH_COMPLETION) > $@
878

    
879
doc/%.png: doc/%.dot
880
	@test -n "$(DOT)" || { echo 'dot' not found during configure; exit 1; }
881
	$(DOT) -Tpng -o $@ $<
882

    
883
man/footer.man: man/footer.rst
884
	@test -n "$(PANDOC)" || \
885
	  { echo 'pandoc' not found during configure; exit 1; }
886
	$(PANDOC) -f rst -t man -o $@ $<
887

    
888
man/footer.html: man/footer.rst
889
	@test -n "$(PANDOC)" || \
890
	  { echo 'pandoc' not found during configure; exit 1; }
891
	$(PANDOC) -f rst -t html -o $@ $<
892

    
893
man/%.gen: man/%.rst lib/query.py lib/build/sphinx_ext.py
894
	PYTHONPATH=. $(RUN_IN_TEMPDIR) $(CURDIR)/$(DOCPP) < $< > $@
895

    
896
man/%.7.in man/%.8.in man/%.1.in: man/%.gen man/footer.man
897
	@test -n "$(PANDOC)" || \
898
	  { echo 'pandoc' not found during configure; exit 1; }
899
	set -o pipefail ; \
900
	$(PANDOC) -s -f rst -t man -A man/footer.man $< | \
901
	  sed -e 's/\\@/@/g' > $@
902
	if test -n "$(MAN_HAS_WARNINGS)"; then $(CHECK_MAN) $@; fi
903

    
904
man/%.html.in: man/%.gen man/footer.html
905
	@test -n "$(PANDOC)" || \
906
	  { echo 'pandoc' not found during configure; exit 1; }
907
	set -o pipefail ; \
908
	$(PANDOC) -s -f rst -t html -A man/footer.html $< | \
909
	  sed -e 's/\\@/@/g' > $@
910

    
911
man/%.1: man/%.1.in $(REPLACE_VARS_SED)
912
	sed -f $(REPLACE_VARS_SED) < $< > $@
913

    
914
man/%.7: man/%.7.in $(REPLACE_VARS_SED)
915
	sed -f $(REPLACE_VARS_SED) < $< > $@
916

    
917
man/%.8: man/%.8.in $(REPLACE_VARS_SED)
918
	sed -f $(REPLACE_VARS_SED) < $< > $@
919

    
920
man/%.html: man/%.html.in $(REPLACE_VARS_SED)
921
	sed -f $(REPLACE_VARS_SED) < $< > $@
922

    
923
epydoc.conf: epydoc.conf.in Makefile
924
	sed -e 's#@MODULES@#$(strip $(lint_python_code))#g' < $< > $@
925

    
926
vcs-version:
927
	if test -d .git; then \
928
	  git describe > $@; \
929
	elif test ! -f $@ ; then \
930
	  echo "Cannot auto-generate $@ file"; exit 1; \
931
	fi
932

    
933
.PHONY: regen-vcs-version
934
regen-vcs-version:
935
	set -e; \
936
	cd $(srcdir); \
937
	if test -d .git; then \
938
	  rm -f vcs-version; \
939
	  $(MAKE) vcs-version; \
940
	fi
941

    
942
htools/Ganeti/HTools/Version.hs: htools/Ganeti/HTools/Version.hs.in vcs-version
943
	set -e; \
944
	VCSVER=`cat $(abs_top_srcdir)/vcs-version`; \
945
	sed -e "s/%ver%/$$VCSVER/" < $< > $@
946

    
947
htools/Ganeti/Constants.hs: htools/Ganeti/Constants.hs.in \
948
	lib/constants.py lib/_autoconf.py $(CONVERT_CONSTANTS) \
949
	| lib/_vcsversion.py
950
	set -e; \
951
	{ cat $< ; PYTHONPATH=. $(CONVERT_CONSTANTS); } > $@
952

    
953
lib/_autoconf.py: Makefile | lib/.dir
954
	set -e; \
955
	{ echo '# This file is automatically generated, do not edit!'; \
956
	  echo '#'; \
957
	  echo ''; \
958
	  echo '"""Build-time configuration for Ganeti.'; \
959
	  echo '';\
960
	  echo 'This file is autogenerated by the build process.'; \
961
	  echo 'For any changes you need to re-run ./configure (and'; \
962
	  echo 'not edit by hand).'; \
963
	  echo ''; \
964
	  echo '"""'; \
965
	  echo ''; \
966
	  echo '# pylint: disable=C0301,C0324'; \
967
	  echo '# because this is autogenerated, we do not want'; \
968
	  echo '# style warnings' ; \
969
	  echo ''; \
970
	  echo "PACKAGE_VERSION = '$(PACKAGE_VERSION)'"; \
971
	  echo "VERSION_MAJOR = '$(VERSION_MAJOR)'"; \
972
	  echo "VERSION_MINOR = '$(VERSION_MINOR)'"; \
973
	  echo "VERSION_REVISION = '$(VERSION_REVISION)'"; \
974
	  echo "VERSION_SUFFIX = '$(VERSION_SUFFIX)'"; \
975
	  echo "VERSION_FULL = '$(VERSION_FULL)'"; \
976
	  echo "LOCALSTATEDIR = '$(localstatedir)'"; \
977
	  echo "SYSCONFDIR = '$(sysconfdir)'"; \
978
	  echo "SSH_CONFIG_DIR = '$(SSH_CONFIG_DIR)'"; \
979
	  echo "EXPORT_DIR = '$(EXPORT_DIR)'"; \
980
	  echo "OS_SEARCH_PATH = [$(OS_SEARCH_PATH)]"; \
981
	  echo "XEN_BOOTLOADER = '$(XEN_BOOTLOADER)'"; \
982
	  echo "XEN_KERNEL = '$(XEN_KERNEL)'"; \
983
	  echo "XEN_INITRD = '$(XEN_INITRD)'"; \
984
	  echo "FILE_STORAGE_DIR = '$(FILE_STORAGE_DIR)'"; \
985
	  echo "ENABLE_FILE_STORAGE = $(ENABLE_FILE_STORAGE)"; \
986
	  echo "SHARED_FILE_STORAGE_DIR = '$(SHARED_FILE_STORAGE_DIR)'"; \
987
	  echo "ENABLE_SHARED_FILE_STORAGE = $(ENABLE_SHARED_FILE_STORAGE)"; \
988
	  echo "IALLOCATOR_SEARCH_PATH = [$(IALLOCATOR_SEARCH_PATH)]"; \
989
	  echo "KVM_PATH = '$(KVM_PATH)'"; \
990
	  echo "IP_PATH = '$(IP_PATH)'"; \
991
	  echo "SOCAT_PATH = '$(SOCAT)'"; \
992
	  echo "SOCAT_USE_ESCAPE = $(SOCAT_USE_ESCAPE)"; \
993
	  echo "SOCAT_USE_COMPRESS = $(SOCAT_USE_COMPRESS)"; \
994
	  echo "LVM_STRIPECOUNT = $(LVM_STRIPECOUNT)"; \
995
	  echo "TOOLSDIR = '$(toolsdir)'"; \
996
	  echo "GNT_SCRIPTS = [$(foreach i,$(notdir $(gnt_scripts)),'$(i)',)]"; \
997
	  echo "PKGLIBDIR = '$(pkglibdir)'"; \
998
	  echo "DRBD_BARRIERS = '$(DRBD_BARRIERS)'"; \
999
	  echo "DRBD_NO_META_FLUSH = $(DRBD_NO_META_FLUSH)"; \
1000
	  echo "SYSLOG_USAGE = '$(SYSLOG_USAGE)'"; \
1001
	  echo "DAEMONS_GROUP = '$(DAEMONS_GROUP)'"; \
1002
	  echo "ADMIN_GROUP = '$(ADMIN_GROUP)'"; \
1003
	  echo "MASTERD_USER = '$(MASTERD_USER)'"; \
1004
	  echo "MASTERD_GROUP = '$(MASTERD_GROUP)'"; \
1005
	  echo "RAPI_USER = '$(RAPI_USER)'"; \
1006
	  echo "RAPI_GROUP = '$(RAPI_GROUP)'"; \
1007
	  echo "CONFD_USER = '$(CONFD_USER)'"; \
1008
	  echo "CONFD_GROUP = '$(CONFD_GROUP)'"; \
1009
	  echo "NODED_USER = '$(NODED_USER)'"; \
1010
	  echo "NODED_GROUP = '$(NODED_GROUP)'"; \
1011
	  echo "DISK_SEPARATOR = '$(DISK_SEPARATOR)'"; \
1012
	  echo "QEMUIMG_PATH = '$(QEMUIMG_PATH)'"; \
1013
	  if [ "$(HTOOLS)" ]; then \
1014
	    echo "HTOOLS = True"; \
1015
	  else \
1016
	    echo "HTOOLS = False"; \
1017
	  fi; \
1018
	  echo "ENABLE_CONFD = $(ENABLE_CONFD)"; \
1019
	} > $@
1020

    
1021
lib/_vcsversion.py: Makefile vcs-version | lib/.dir
1022
	set -e; \
1023
	VCSVER=`cat $(abs_top_srcdir)/vcs-version`; \
1024
	{ echo '# This file is automatically generated, do not edit!'; \
1025
	  echo '#'; \
1026
	  echo ''; \
1027
	  echo '"""Build-time VCS version number for Ganeti.'; \
1028
	  echo '';\
1029
	  echo 'This file is autogenerated by the build process.'; \
1030
	  echo 'For any changes you need to re-run ./configure (and'; \
1031
	  echo 'not edit by hand).'; \
1032
	  echo ''; \
1033
	  echo '"""'; \
1034
	  echo ''; \
1035
	  echo '# pylint: disable=C0301,C0324'; \
1036
	  echo '# because this is autogenerated, we do not want'; \
1037
	  echo '# style warnings' ; \
1038
	  echo ''; \
1039
	  echo "VCS_VERSION = '$$VCSVER'"; \
1040
	} > $@
1041

    
1042
lib/_generated_rpc.py: lib/rpc_defs.py $(BUILD_RPC)
1043
	PYTHONPATH=. $(RUN_IN_TEMPDIR) $(CURDIR)/$(BUILD_RPC) lib/rpc_defs.py > $@
1044

    
1045
$(REPLACE_VARS_SED): Makefile
1046
	set -e; \
1047
	{ echo 's#@PREFIX@#$(prefix)#g'; \
1048
	  echo 's#@SYSCONFDIR@#$(sysconfdir)#g'; \
1049
	  echo 's#@LOCALSTATEDIR@#$(localstatedir)#g'; \
1050
	  echo 's#@BINDIR@#$(bindir)#g'; \
1051
	  echo 's#@SBINDIR@#$(sbindir)#g'; \
1052
	  echo 's#@GANETI_VERSION@#$(PACKAGE_VERSION)#g'; \
1053
	  echo 's#@CUSTOM_XEN_BOOTLOADER@#$(XEN_BOOTLOADER)#g'; \
1054
	  echo 's#@CUSTOM_XEN_KERNEL@#$(XEN_KERNEL)#g'; \
1055
	  echo 's#@CUSTOM_XEN_INITRD@#$(XEN_INITRD)#g'; \
1056
	  echo 's#@CUSTOM_IALLOCATOR_SEARCH_PATH@#$(IALLOCATOR_SEARCH_PATH)#g'; \
1057
	  echo 's#@CUSTOM_EXPORT_DIR@#$(EXPORT_DIR)#g'; \
1058
	  echo 's#@RPL_FILE_STORAGE_DIR@#$(FILE_STORAGE_DIR)#g'; \
1059
	  echo 's#@RPL_SSH_INITD_SCRIPT@#$(SSH_INITD_SCRIPT)#g'; \
1060
	  echo 's#@PKGLIBDIR@#$(pkglibdir)#g'; \
1061
	  echo 's#@GNTMASTERUSER@#$(MASTERD_USER)#g'; \
1062
	  echo 's#@GNTRAPIUSER@#$(RAPI_USER)#g'; \
1063
	  echo 's#@GNTCONFDUSER@#$(CONFD_USER)#g'; \
1064
	  echo 's#@GNTNODEDUSER@#$(NODED_USER)#g'; \
1065
	  echo 's#@GNTRAPIGROUP@#$(RAPI_GROUP)#g'; \
1066
	  echo 's#@GNTADMINGROUP@#$(ADMIN_GROUP)#g'; \
1067
	  echo 's#@GNTCONFDGROUP@#$(CONFD_GROUP)#g'; \
1068
	  echo 's#@GNTMASTERDGROUP@#$(MASTERD_GROUP)#g'; \
1069
	  echo 's#@GNTDAEMONSGROUP@#$(DAEMONS_GROUP)#g'; \
1070
	  echo 's#@CUSTOM_ENABLE_CONFD@#$(ENABLE_CONFD)#g'; \
1071
	} > $@
1072

    
1073
# Using deferred evaluation
1074
daemons/ganeti-%: MODULE = ganeti.server.$(patsubst ganeti-%,%,$(notdir $@))
1075
daemons/ganeti-watcher: MODULE = ganeti.watcher
1076
scripts/%: MODULE = ganeti.client.$(subst -,_,$(notdir $@))
1077
tools/ensure-dirs: MODULE = ganeti.tools.ensure_dirs
1078

    
1079
$(PYTHON_BOOTSTRAP): Makefile | $(all_dirfiles)
1080
	test -n "$(MODULE)" || { echo Missing module; exit 1; }
1081
	set -e; \
1082
	{ echo '#!/usr/bin/python'; \
1083
	  echo '# This file is automatically generated, do not edit!'; \
1084
	  echo "# Edit $(MODULE) instead."; \
1085
	  echo; \
1086
	  echo '"""Bootstrap script for L{$(MODULE)}"""'; \
1087
	  echo; \
1088
	  echo '# pylint: disable=C0103'; \
1089
	  echo '# C0103: Invalid name'; \
1090
	  echo; \
1091
	  echo 'import sys'; \
1092
	  echo 'import $(MODULE) as main'; \
1093
	  echo; \
1094
	  echo '# Temporarily alias commands until bash completion'; \
1095
	  echo '# generator is changed'; \
1096
	  echo 'if hasattr(main, "commands"):'; \
1097
	  echo '  commands = main.commands # pylint: disable=E1101'; \
1098
	  echo 'if hasattr(main, "aliases"):'; \
1099
	  echo '  aliases = main.aliases # pylint: disable=E1101'; \
1100
	  echo; \
1101
	  echo 'if __name__ == "__main__":'; \
1102
	  echo '  sys.exit(main.Main())'; \
1103
	} > $@
1104
	chmod u+x $@
1105

    
1106
# We need to create symlinks because "make distcheck" will not install Python
1107
# files when building.
1108
stamp-srclinks: Makefile | $(all_dirfiles)
1109
	set -e; \
1110
	for i in $(srclink_files); do \
1111
		if test ! -f $$i -a -f $(abs_top_srcdir)/$$i; then \
1112
			$(LN_S) $(abs_top_srcdir)/$$i $$i; \
1113
		fi; \
1114
	done
1115
	touch $@
1116

    
1117
.PHONY: ganeti
1118
ganeti:
1119
	cd $(top_builddir) && test -h "$@" || { rm -f $@ && $(LN_S) lib $@; }
1120

    
1121
.PHONY: check-dirs
1122
check-dirs: $(BUILT_SOURCES)
1123
	@set -e; \
1124
	find . -type d \( \( -name . \) -o \( \
1125
		-name .git -o \
1126
		-name autom4te.cache \
1127
		\) -prune -o -print \) | { \
1128
		error=; \
1129
		while read dir; do \
1130
			case "$$dir" in \
1131
				$(strip $(patsubst %,(./%) ;;,$(DIRCHECK_EXCLUDE) $(DIRS))) \
1132
				*) error=1; echo "Directory $$dir not listed in Makefile" >&2 ;; \
1133
			esac; \
1134
		done; \
1135
		for dir in $(DIRS); do \
1136
			if ! test -d "$$dir"; then \
1137
				echo "Directory $$dir listed in DIRS does not exist" >&2; \
1138
				error=1; \
1139
			fi \
1140
		done; \
1141
		if test -n "$$error"; then exit 1; else exit 0; fi; \
1142
	}
1143

    
1144
.PHONY: check-local
1145
check-local: check-dirs $(BUILT_SOURCES)
1146
	$(CHECK_PYTHON_CODE) $(check_python_code)
1147
	PYTHONPATH=. $(CHECK_HEADER) $(check_python_code)
1148
	$(CHECK_VERSION) $(VERSION) $(top_srcdir)/NEWS
1149
	$(CHECK_NEWS) < $(top_srcdir)/NEWS
1150
	PYTHONPATH=. $(RUN_IN_TEMPDIR) $(CURDIR)/$(CHECK_IMPORTS) . $(standalone_python_modules)
1151
	expver=$(VERSION_MAJOR).$(VERSION_MINOR); \
1152
	if test "`head -n 1 $(top_srcdir)/README`" != "Ganeti $$expver"; then \
1153
		echo "Incorrect version in README, expected $$expver"; \
1154
		exit 1; \
1155
	fi; \
1156
	for file in doc/iallocator.rst doc/hooks.rst; do \
1157
		if test "`sed -ne '4 p' $(top_srcdir)/$$file`" != \
1158
			"Documents Ganeti version $$expver"; then \
1159
			echo "Incorrect version in $$file, expected $$expver"; \
1160
			exit 1; \
1161
		fi; \
1162
	done
1163

    
1164
.PHONY: hs-check
1165
hs-check: htools/test
1166
	@rm -f test.tix
1167
	./htools/test
1168

    
1169
# E111: indentation is not a multiple of four
1170
# E261: at least two spaces before inline comment
1171
# E501: line too long (80 characters)
1172
PEP8_IGNORE = E111,E261,E501
1173

    
1174
# For excluding pep8 expects filenames only, not whole paths
1175
PEP8_EXCLUDE = $(subst $(space),$(comma),$(strip $(notdir $(BUILT_PYTHON_SOURCES))))
1176

    
1177
.PHONY: lint
1178
lint: $(BUILT_SOURCES)
1179
	@test -n "$(PYLINT)" || { echo 'pylint' not found during configure; exit 1; }
1180
	if test -z "$(PEP8)"; then \
1181
		echo '"pep8" not found during configure' >&2; \
1182
	else \
1183
		$(PEP8) --repeat --ignore='$(PEP8_IGNORE)' --exclude='$(PEP8_EXCLUDE)' \
1184
			$(pep8_python_code); \
1185
	fi
1186
	$(PYLINT) $(LINT_OPTS) $(lint_python_code)
1187
	cd $(top_srcdir)/qa && \
1188
	  PYTHONPATH=$(abs_top_srcdir) $(PYLINT) $(LINT_OPTS) \
1189
	  --rcfile  ../pylintrc $(patsubst qa/%.py,%,$(qa_scripts))
1190

    
1191
.PHONY: hlint
1192
hlint: $(HS_BUILT_SRCS) htools/lint-hints.hs
1193
	if tty -s; then C="-c"; else C=""; fi; \
1194
	hlint --report=doc/hs-lint.html --cross $$C \
1195
	  --ignore "Use first" \
1196
	  --ignore "Use comparing" \
1197
	  --ignore "Use on" \
1198
	  --ignore "Use Control.Exception.catch" \
1199
	  --ignore "Reduce duplication" \
1200
	  --hint htools/lint-hints \
1201
	  $(filter-out htools/Ganeti/THH.hs,$(HS_LIB_SRCS))
1202

    
1203
# a dist hook rule for updating the vcs-version file; this is
1204
# hardcoded due to where it needs to build the file...
1205
dist-hook:
1206
	$(MAKE) regen-vcs-version && \
1207
	rm -f $(top_distdir)/vcs-version && \
1208
	cp -p $(srcdir)/vcs-version $(top_distdir)
1209

    
1210
# a distcheck hook rule for catching revision control directories
1211
distcheck-hook:
1212
	if find $(top_distdir) -name .svn -or -name .git | grep .; then \
1213
		echo "Found revision control files in final archive." 1>&2; \
1214
		exit 1; \
1215
	fi
1216
	if find $(top_distdir) -name '*.py[co]' | grep .; then \
1217
		echo "Found Python byte code in final archive." 1>&2; \
1218
		exit 1; \
1219
	fi
1220
	if find $(top_distdir) -name '*~' | grep .; then \
1221
		echo "Found backup files in final archive." 1>&2; \
1222
		exit 1; \
1223
	fi
1224
# Empty files or directories should not be distributed. They can cause
1225
# unnecessary warnings for packagers. Directories used by automake during
1226
# distcheck must be excluded.
1227
	if find $(top_distdir) -empty -and -not \( \
1228
			-path $(top_distdir)/_build -or \
1229
			-path $(top_distdir)/_inst \) | grep .; then \
1230
		echo "Found empty files or directories in final archive." 1>&2; \
1231
		exit 1; \
1232
	fi
1233
	if test -n "$(BUILD_RELEASE)" && \
1234
	   grep -n -H -E '^\*.*unreleased' $(top_distdir)/NEWS; then \
1235
		echo "Found unreleased version in NEWS." >&2; \
1236
		exit 1; \
1237
	fi
1238

    
1239
# When building a release, stricter checks should be used
1240
distcheck-release dist-release: export BUILD_RELEASE = 1
1241
distcheck-release: distcheck
1242

    
1243
dist-release: dist
1244
	set -e; \
1245
	for i in $(DIST_ARCHIVES); do \
1246
		echo -n "Checking $$i ... "; \
1247
		autotools/check-tar < $$i; \
1248
		echo OK; \
1249
	done
1250

    
1251
install-exec-local:
1252
	@mkdir_p@ "$(DESTDIR)${localstatedir}/lib/ganeti" \
1253
	  "$(DESTDIR)${localstatedir}/log/ganeti" \
1254
	  "$(DESTDIR)${localstatedir}/run/ganeti"
1255

    
1256
# To avoid conflicts between directory names and other targets, a file inside
1257
# the directory is used to ensure its existence.
1258
%.dir:
1259
	@mkdir_p@ $* && touch $@
1260

    
1261
.PHONY: apidoc
1262
if WANT_HTOOLSAPIDOC
1263
apidoc: py-apidoc hs-apidoc
1264
else
1265
apidoc: py-apidoc
1266
endif
1267

    
1268
.PHONY: py-apidoc
1269
py-apidoc: epydoc.conf $(RUN_IN_TEMPDIR) $(BUILT_SOURCES)
1270
	$(RUN_IN_TEMPDIR) epydoc -v \
1271
		--conf $(CURDIR)/epydoc.conf \
1272
		--output $(CURDIR)/$(APIDOC_PY_DIR)
1273

    
1274
.PHONY: hs-apidoc
1275
hs-apidoc: $(HS_BUILT_SRCS)
1276
	@test -n "$(HSCOLOUR)" || \
1277
	    { echo 'HsColour' not found during configure; exit 1; }
1278
	@test -n "$(HADDOCK)" || \
1279
	    { echo 'haddock' not found during configure; exit 1; }
1280
	rm -rf $(APIDOC_HS_DIR)/*
1281
	@mkdir_p@ $(APIDOC_HS_DIR)/Ganeti/HTools/Program
1282
	$(HSCOLOUR) -print-css > $(APIDOC_HS_DIR)/Ganeti/hscolour.css
1283
	$(LN_S) ../hscolour.css $(APIDOC_HS_DIR)/Ganeti/HTools/hscolour.css
1284
	set -e ; \
1285
	cd htools; \
1286
	if [ "$(HTOOLS_NOCURL)" ]; \
1287
	then OPTGHC="--optghc=$(HTOOLS_NOCURL)"; \
1288
	else OPTGHC=""; \
1289
	fi; \
1290
	if [ "$(HTOOLS_PARALLEL3)" ]; \
1291
	then OPTGHC="$$OPTGHC --optghc=$(HTOOLS_PARALLEL3)"; \
1292
	fi; \
1293
	RELSRCS="$(HS_LIB_SRCS:htools/%=%)  $(HS_BUILT_SRCS:htools/%=%)"; \
1294
	for file in $$RELSRCS; do \
1295
		hfile=`echo $$file|sed 's/\\.hs$$//'`.html; \
1296
		$(HSCOLOUR) -css -anchor $$file > ../$(APIDOC_HS_DIR)/$$hfile ; \
1297
	done ; \
1298
	$(HADDOCK) --odir ../$(APIDOC_HS_DIR) --html --ignore-all-exports -w \
1299
		-t ganeti-htools -p haddock-prologue \
1300
		--source-module="%{MODULE/.//}.html" \
1301
		--source-entity="%{MODULE/.//}.html#%{NAME}" \
1302
		$$OPTGHC \
1303
		$(filter-out Ganeti/HTools/ExtLoader.hs,$(HS_LIB_SRCS:htools/%=%))
1304

    
1305
.PHONY: TAGS
1306
TAGS: $(BUILT_SOURCES)
1307
	rm -f TAGS
1308
	find . -path './lib/*.py' -o -path './scripts/gnt-*' -o \
1309
	  -path './daemons/ganeti-*' -o -path './tools/*' -o \
1310
	  -path './qa/*.py' | \
1311
	  etags -l python -
1312

    
1313
.PHONY: coverage
1314
if WANT_HTOOLS
1315
coverage: py-coverage hs-coverage
1316
else
1317
coverage: py-coverage
1318
endif
1319

    
1320
.PHONY: py-coverage
1321
py-coverage: $(BUILT_SOURCES) $(python_tests)
1322
	set -e; \
1323
	COVERAGE_FILE=$(CURDIR)/$(COVERAGE_PY_DIR)/data \
1324
	TEXT_COVERAGE=$(CURDIR)/$(COVERAGE_PY_DIR)/report.txt \
1325
	HTML_COVERAGE=$(CURDIR)/$(COVERAGE_PY_DIR) \
1326
	$(PLAIN_TESTS_ENVIRONMENT) $(abs_top_srcdir)/autotools/gen-coverage \
1327
	$(python_tests)
1328

    
1329
.PHONY: hs-coverage
1330
hs-coverage: $(haskell_tests)
1331
	cd htools && rm -f *.tix *.mix && ./test
1332
	@mkdir_p@ $(COVERAGE_HS_DIR)
1333
	hpc markup --destdir=$(COVERAGE_HS_DIR) htools/test $(HPCEXCL)
1334
	hpc report htools/test $(HPCEXCL)
1335
	$(LN_S) -f hpc_index.html $(COVERAGE_HS_DIR)/index.html
1336

    
1337
# Special "kind-of-QA" target for htools, needs special setup (all
1338
# tools compiled with -fhpc)
1339
.PHONY: live-test
1340
live-test: all
1341
	set -e ; \
1342
	cd htools; \
1343
	rm -f .hpc; $(LN_S) ../.hpc .hpc; \
1344
	rm -f *.tix *.mix; \
1345
	./live-test.sh; \
1346
	hpc sum --union $(HPCEXCL) $(addsuffix .tix,$(HS_PROGS:htools/%=%)) \
1347
	  --output=live-test.tix ; \
1348
	@mkdir_p@ ../$(COVERAGE_HS_DIR) ; \
1349
	hpc markup --destdir=../$(COVERAGE_HS_DIR) live-test \
1350
		--srcdir=.. $(HPCEXCL) ; \
1351
	hpc report --srcdir=.. live-test $(HPCEXCL)
1352

    
1353
commit-check: distcheck lint apidoc
1354

    
1355
-include ./Makefile.local
1356

    
1357
# vim: set noet :