Statistics
| Branch: | Tag: | Revision:

root / Makefile.am @ 9f13be88

History | View | Annotate | Download (38.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 = $(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
# internal extra flags (used for htools/test mainly)
358
HEXTRA_INT =
359
# exclude options for coverage reports
360
HPCEXCL = --exclude Main \
361
	--exclude Ganeti.Constants \
362
	--exclude Ganeti.THH \
363
	--exclude Ganeti.HTools.QC \
364
	--exclude Ganeti.HTools.QCHelper \
365
	--exclude Ganeti.HTools.Version
366

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

    
399
HS_BUILT_SRCS = htools/Ganeti/HTools/Version.hs htools/Ganeti/Constants.hs
400
HS_BUILT_SRCS_IN = $(patsubst %,%.in,$(HS_BUILT_SRCS))
401

    
402
$(RUN_IN_TEMPDIR): | $(all_dirfiles)
403

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

    
423
doc/html: doc/html/index.html
424

    
425
doc/install-quick.rst: INSTALL
426
doc/news.rst: NEWS
427
doc/upgrade.rst: UPGRADE
428

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

    
437
docdot = \
438
	doc/arch-2.0.dot \
439
	doc/design-2.1-lock-acquire.dot \
440
	doc/design-2.1-lock-release.dot
441

    
442
docpng = $(patsubst %.dot,%.png,$(docdot))
443

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

    
453
gnt_scripts = \
454
	scripts/gnt-backup \
455
	scripts/gnt-cluster \
456
	scripts/gnt-debug \
457
	scripts/gnt-group \
458
	scripts/gnt-instance \
459
	scripts/gnt-job \
460
	scripts/gnt-node \
461
	scripts/gnt-os
462

    
463
PYTHON_BOOTSTRAP_SBIN = \
464
	daemons/ganeti-confd \
465
	daemons/ganeti-masterd \
466
	daemons/ganeti-noded \
467
	daemons/ganeti-watcher \
468
	daemons/ganeti-rapi \
469
	$(gnt_scripts)
470

    
471
PYTHON_BOOTSTRAP = \
472
	$(PYTHON_BOOTSTRAP_SBIN) \
473
	tools/ensure-dirs
474

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

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

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

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

    
525
# rules for building profiling-enabled versions of the haskell
526
# programs: hs-prof does the full two-step build, whereas
527
# hs-prof-quick does only the final rebuild (hs-prof must have been
528
# run before)
529
.PHONY: hs-prof hs-prof-quick
530
hs-prof:
531
	$(MAKE) clean
532
	$(MAKE) $(HS_ALL_PROGS) HEXTRA="-osuf .o"
533
	rm -f $(HS_ALL_PROGS)
534
	$(MAKE) hs-prof-quick
535

    
536
hs-prof-quick:
537
	$(MAKE) $(HS_ALL_PROGS) HEXTRA="-osuf .prof_o -prof -auto-all"
538

    
539
dist_sbin_SCRIPTS = \
540
	tools/ganeti-listrunner
541

    
542
nodist_sbin_SCRIPTS = \
543
	$(PYTHON_BOOTSTRAP_SBIN) \
544
	daemons/ganeti-cleaner
545

    
546
python_scripts = \
547
	tools/burnin \
548
	tools/cfgshell \
549
	tools/cfgupgrade \
550
	tools/cfgupgrade12 \
551
	tools/cluster-merge \
552
	tools/confd-client \
553
	tools/lvmstrap \
554
	tools/move-instance \
555
	tools/ovfconverter \
556
	tools/setup-ssh \
557
	tools/sanitize-config
558

    
559
dist_tools_SCRIPTS = \
560
	$(python_scripts) \
561
	tools/kvm-console-wrapper \
562
	tools/xm-console-wrapper \
563
	tools/master-ip-setup
564

    
565
pkglib_python_scripts = \
566
	daemons/import-export \
567
	tools/check-cert-expired
568

    
569
nodist_pkglib_python_scripts = \
570
	tools/ensure-dirs
571

    
572
pkglib_SCRIPTS = \
573
	daemons/daemon-util \
574
	tools/kvm-ifup \
575
	$(pkglib_python_scripts)
576

    
577
nodist_pkglib_SCRIPTS = \
578
	$(nodist_pkglib_python_scripts)
579

    
580
EXTRA_DIST = \
581
	NEWS \
582
	UPGRADE \
583
	epydoc.conf.in \
584
	pylintrc \
585
	autotools/build-bash-completion \
586
	autotools/build-rpc \
587
	autotools/check-header \
588
	autotools/check-python-code \
589
	autotools/check-imports \
590
	autotools/check-man \
591
	autotools/check-news \
592
	autotools/check-tar \
593
	autotools/check-version \
594
	autotools/convert-constants \
595
	autotools/docpp \
596
	autotools/gen-coverage \
597
	autotools/testrunner \
598
	$(RUN_IN_TEMPDIR) \
599
	daemons/daemon-util.in \
600
	daemons/ganeti-cleaner.in \
601
	$(pkglib_python_scripts) \
602
	devel/upload.in \
603
	tools/kvm-ifup.in \
604
	$(docdot) \
605
	$(docpng) \
606
	$(docrst) \
607
	doc/conf.py \
608
	doc/html \
609
	$(BUILT_EXAMPLES:%=%.in) \
610
	doc/examples/ganeti.default \
611
	doc/examples/ganeti.default-debug \
612
	doc/examples/hooks/ethers \
613
	doc/examples/gnt-debug/README \
614
	doc/examples/gnt-debug/delay0.json \
615
	doc/examples/gnt-debug/delay50.json \
616
	test/lockperf.py \
617
	test/testutils.py \
618
	test/mocks.py \
619
	$(dist_TESTS) \
620
	$(TEST_FILES) \
621
	man/footer.rst \
622
	$(manrst) \
623
	$(maninput) \
624
	qa/qa-sample.json \
625
	$(qa_scripts) \
626
	$(HS_LIB_SRCS) $(HS_BUILT_SRCS_IN) \
627
	$(HS_PROG_SRCS) \
628
	htools/lint-hints.hs
629

    
630
man_MANS = \
631
	man/ganeti.7 \
632
	man/ganeti-cleaner.8 \
633
	man/ganeti-confd.8 \
634
	man/ganeti-listrunner.8 \
635
	man/ganeti-masterd.8 \
636
	man/ganeti-noded.8 \
637
	man/ganeti-os-interface.7 \
638
	man/ganeti-rapi.8 \
639
	man/ganeti-watcher.8 \
640
	man/gnt-backup.8 \
641
	man/gnt-cluster.8 \
642
	man/gnt-debug.8 \
643
	man/gnt-group.8 \
644
	man/gnt-instance.8 \
645
	man/gnt-job.8 \
646
	man/gnt-node.8 \
647
	man/gnt-os.8 \
648
	man/hail.1 \
649
	man/hbal.1 \
650
	man/hscan.1 \
651
	man/hspace.1 \
652
	man/htools.1
653

    
654
manrst = $(patsubst %.1,%.rst,$(patsubst %.7,%.rst,$(patsubst %.8,%.rst,$(man_MANS))))
655
manhtml = $(patsubst %.rst,%.html,$(manrst))
656
mangen = $(patsubst %.rst,%.gen,$(manrst))
657
maninput = \
658
	$(patsubst %.1,%.1.in,$(patsubst %.7,%.7.in,$(patsubst %.8,%.8.in,$(man_MANS)))) \
659
	$(patsubst %.html,%.html.in,$(manhtml)) \
660
	man/footer.man man/footer.html $(mangen)
661

    
662
TEST_FILES = \
663
	test/data/bdev-drbd-8.0.txt \
664
	test/data/bdev-drbd-8.3.txt \
665
	test/data/bdev-drbd-disk.txt \
666
	test/data/bdev-drbd-net-ip4.txt \
667
	test/data/bdev-drbd-net-ip6.txt \
668
	test/data/cert1.pem \
669
	test/data/ip-addr-show-dummy0.txt \
670
	test/data/ip-addr-show-lo-ipv4.txt \
671
	test/data/ip-addr-show-lo-ipv6.txt \
672
	test/data/ip-addr-show-lo-oneline-ipv4.txt \
673
	test/data/ip-addr-show-lo-oneline-ipv6.txt \
674
	test/data/ip-addr-show-lo-oneline.txt \
675
	test/data/ip-addr-show-lo.txt \
676
	test/data/proc_drbd8.txt \
677
	test/data/proc_drbd80-emptyline.txt \
678
	test/data/proc_drbd83.txt \
679
	test/data/proc_drbd83_sync.txt \
680
	test/data/proc_drbd83_sync_krnl2.6.39.txt \
681
	test/data/kvm_1.0_help.txt \
682
	test/data/kvm_0.15.90_help.txt \
683
	test/data/kvm_0.12.5_help.txt \
684
	test/data/kvm_0.9.1_help.txt \
685
	test/data/sys_drbd_usermode_helper.txt \
686
	test/data/ovfdata/compr_disk.vmdk.gz \
687
	test/data/ovfdata/config.ini \
688
	test/data/ovfdata/corrupted_resources.ovf \
689
	test/data/ovfdata/empty.ini \
690
	test/data/ovfdata/empty.ovf \
691
	test/data/ovfdata/ganeti.mf \
692
	test/data/ovfdata/ganeti.ovf \
693
	test/data/ovfdata/gzip_disk.ovf \
694
	test/data/ovfdata/new_disk.vmdk \
695
	test/data/ovfdata/no_disk.ini \
696
	test/data/ovfdata/no_disk_in_ref.ovf \
697
	test/data/ovfdata/no_os.ini \
698
	test/data/ovfdata/no_ovf.ova \
699
	test/data/ovfdata/ova.ova \
700
	test/data/ovfdata/second_disk.vmdk \
701
	test/data/ovfdata/rawdisk.raw \
702
	test/data/ovfdata/unsafe_path.ini \
703
	test/data/ovfdata/virtualbox.ovf \
704
	test/data/ovfdata/wrong_extension.ovd \
705
	test/data/ovfdata/wrong_config.ini \
706
	test/data/ovfdata/wrong_manifest.mf \
707
	test/data/ovfdata/wrong_manifest.ovf \
708
	test/data/ovfdata/wrong_ova.ova \
709
	test/data/ovfdata/wrong_xml.ovf \
710
	test/data/ovfdata/other/rawdisk.raw \
711
	test/import-export_unittest-helper
712

    
713
python_tests = \
714
	test/ganeti.asyncnotifier_unittest.py \
715
	test/ganeti.backend_unittest.py \
716
	test/ganeti.bdev_unittest.py \
717
	test/ganeti.cli_unittest.py \
718
	test/ganeti.client.gnt_cluster_unittest.py \
719
	test/ganeti.client.gnt_instance_unittest.py \
720
	test/ganeti.daemon_unittest.py \
721
	test/ganeti.cmdlib_unittest.py \
722
	test/ganeti.compat_unittest.py \
723
	test/ganeti.confd.client_unittest.py \
724
	test/ganeti.config_unittest.py \
725
	test/ganeti.constants_unittest.py \
726
	test/ganeti.errors_unittest.py \
727
	test/ganeti.hooks_unittest.py \
728
	test/ganeti.ht_unittest.py \
729
	test/ganeti.http_unittest.py \
730
	test/ganeti.hypervisor_unittest.py \
731
	test/ganeti.hypervisor.hv_chroot_unittest.py \
732
	test/ganeti.hypervisor.hv_fake_unittest.py \
733
	test/ganeti.hypervisor.hv_kvm_unittest.py \
734
	test/ganeti.hypervisor.hv_lxc_unittest.py \
735
	test/ganeti.hypervisor.hv_xen_unittest.py \
736
	test/ganeti.impexpd_unittest.py \
737
	test/ganeti.jqueue_unittest.py \
738
	test/ganeti.locking_unittest.py \
739
	test/ganeti.luxi_unittest.py \
740
	test/ganeti.masterd.instance_unittest.py \
741
	test/ganeti.mcpu_unittest.py \
742
	test/ganeti.netutils_unittest.py \
743
	test/ganeti.objects_unittest.py \
744
	test/ganeti.opcodes_unittest.py \
745
	test/ganeti.ovf_unittest.py \
746
	test/ganeti.qlang_unittest.py \
747
	test/ganeti.query_unittest.py \
748
	test/ganeti.rapi.baserlib_unittest.py \
749
	test/ganeti.rapi.client_unittest.py \
750
	test/ganeti.rapi.resources_unittest.py \
751
	test/ganeti.rapi.rlib2_unittest.py \
752
	test/ganeti.rpc_unittest.py \
753
	test/ganeti.runtime_unittest.py \
754
	test/ganeti.serializer_unittest.py \
755
	test/ganeti.ssh_unittest.py \
756
	test/ganeti.tools.ensure_dirs_unittest.py \
757
	test/ganeti.uidpool_unittest.py \
758
	test/ganeti.utils.algo_unittest.py \
759
	test/ganeti.utils.filelock_unittest.py \
760
	test/ganeti.utils.hash_unittest.py \
761
	test/ganeti.utils.io_unittest.py \
762
	test/ganeti.utils.log_unittest.py \
763
	test/ganeti.utils.mlock_unittest.py \
764
	test/ganeti.utils.nodesetup_unittest.py \
765
	test/ganeti.utils.process_unittest.py \
766
	test/ganeti.utils.retry_unittest.py \
767
	test/ganeti.utils.text_unittest.py \
768
	test/ganeti.utils.wrapper_unittest.py \
769
	test/ganeti.utils.x509_unittest.py \
770
	test/ganeti.utils_unittest.py \
771
	test/ganeti.workerpool_unittest.py \
772
	test/cfgupgrade_unittest.py \
773
	test/docs_unittest.py \
774
	test/pycurl_reset_unittest.py \
775
	test/tempfile_fork_unittest.py
776
if HAS_FAKEROOT
777
python_tests += test/ganeti.utils.io_unittest-runasroot.py
778
endif
779

    
780
haskell_tests = htools/test
781

    
782
dist_TESTS = \
783
	test/check-cert-expired_unittest.bash \
784
	test/daemon-util_unittest.bash \
785
	test/ganeti-cleaner_unittest.bash \
786
	test/import-export_unittest.bash \
787
	$(python_tests)
788

    
789
nodist_TESTS =
790
if WANT_HTOOLSTESTS
791
nodist_TESTS += $(haskell_tests)
792
endif
793

    
794
TESTS = $(dist_TESTS) $(nodist_TESTS)
795

    
796
# Environment for all tests
797
PLAIN_TESTS_ENVIRONMENT = \
798
	PYTHONPATH=. TOP_SRCDIR=$(abs_top_srcdir) PYTHON=$(PYTHON) \
799
	FAKEROOT=$(FAKEROOT_PATH) $(RUN_IN_TEMPDIR)
800

    
801
# Environment for tests run by automake
802
TESTS_ENVIRONMENT = \
803
	$(PLAIN_TESTS_ENVIRONMENT) $(abs_top_srcdir)/autotools/testrunner
804

    
805
all_python_code = \
806
	$(dist_sbin_SCRIPTS) \
807
	$(python_scripts) \
808
	$(pkglib_python_scripts) \
809
	$(nodist_pkglib_python_scripts) \
810
	$(python_tests) \
811
	$(pkgpython_PYTHON) \
812
	$(client_PYTHON) \
813
	$(hypervisor_PYTHON) \
814
	$(rapi_PYTHON) \
815
	$(server_PYTHON) \
816
	$(pytools_PYTHON) \
817
	$(http_PYTHON) \
818
	$(confd_PYTHON) \
819
	$(masterd_PYTHON) \
820
	$(impexpd_PYTHON) \
821
	$(utils_PYTHON) \
822
	$(watcher_PYTHON) \
823
	$(noinst_PYTHON) \
824
	$(qa_scripts)
825

    
826
srclink_files = \
827
	man/footer.rst \
828
	test/check-cert-expired_unittest.bash \
829
	test/daemon-util_unittest.bash \
830
	test/ganeti-cleaner_unittest.bash \
831
	test/import-export_unittest.bash \
832
	$(all_python_code) \
833
	$(HS_LIB_SRCS) $(HS_PROG_SRCS)
834

    
835
check_python_code = \
836
	$(BUILD_BASH_COMPLETION) \
837
	$(CHECK_IMPORTS) \
838
	$(CHECK_HEADER) \
839
	$(DOCPP) \
840
	$(all_python_code)
841

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

    
854
standalone_python_modules = \
855
	lib/rapi/client.py \
856
	tools/ganeti-listrunner
857

    
858
pep8_python_code = \
859
	ganeti \
860
	ganeti/http/server.py \
861
	$(dist_sbin_SCRIPTS) \
862
	$(python_scripts) \
863
	$(pkglib_python_scripts) \
864
	$(BUILD_BASH_COMPLETION) \
865
	$(CHECK_HEADER) \
866
	$(DOCPP) \
867
	$(PYTHON_BOOTSTRAP) \
868
	qa
869

    
870
test/daemon-util_unittest.bash: daemons/daemon-util
871

    
872
test/ganeti-cleaner_unittest.bash: daemons/ganeti-cleaner
873

    
874
tools/kvm-ifup: tools/kvm-ifup.in $(REPLACE_VARS_SED)
875
	sed -f $(REPLACE_VARS_SED) < $< > $@
876
	chmod +x $@
877

    
878
devel/upload: devel/upload.in $(REPLACE_VARS_SED)
879
	sed -f $(REPLACE_VARS_SED) < $< > $@
880
	chmod u+x $@
881

    
882
daemons/%: daemons/%.in $(REPLACE_VARS_SED)
883
	sed -f $(REPLACE_VARS_SED) < $< > $@
884
	chmod +x $@
885

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

    
889
doc/examples/hooks/%: doc/examples/hooks/%.in $(REPLACE_VARS_SED)
890
	sed -f $(REPLACE_VARS_SED) < $< > $@
891

    
892
doc/examples/bash_completion: $(BUILD_BASH_COMPLETION) $(RUN_IN_TEMPDIR) \
893
	lib/cli.py $(gnt_scripts) $(client_PYTHON) tools/burnin
894
	PYTHONPATH=. $(RUN_IN_TEMPDIR) $(CURDIR)/$(BUILD_BASH_COMPLETION) > $@
895

    
896
doc/%.png: doc/%.dot
897
	@test -n "$(DOT)" || { echo 'dot' not found during configure; exit 1; }
898
	$(DOT) -Tpng -o $@ $<
899

    
900
man/footer.man: man/footer.rst
901
	@test -n "$(PANDOC)" || \
902
	  { echo 'pandoc' not found during configure; exit 1; }
903
	$(PANDOC) -f rst -t man -o $@ $<
904

    
905
man/footer.html: man/footer.rst
906
	@test -n "$(PANDOC)" || \
907
	  { echo 'pandoc' not found during configure; exit 1; }
908
	$(PANDOC) -f rst -t html -o $@ $<
909

    
910
man/%.gen: man/%.rst lib/query.py lib/build/sphinx_ext.py
911
	PYTHONPATH=. $(RUN_IN_TEMPDIR) $(CURDIR)/$(DOCPP) < $< > $@
912

    
913
man/%.7.in man/%.8.in man/%.1.in: man/%.gen man/footer.man
914
	@test -n "$(PANDOC)" || \
915
	  { echo 'pandoc' not found during configure; exit 1; }
916
	set -o pipefail ; \
917
	$(PANDOC) -s -f rst -t man -A man/footer.man $< | \
918
	  sed -e 's/\\@/@/g' > $@
919
	if test -n "$(MAN_HAS_WARNINGS)"; then $(CHECK_MAN) $@; fi
920

    
921
man/%.html.in: man/%.gen man/footer.html
922
	@test -n "$(PANDOC)" || \
923
	  { echo 'pandoc' not found during configure; exit 1; }
924
	set -o pipefail ; \
925
	$(PANDOC) -s -f rst -t html -A man/footer.html $< | \
926
	  sed -e 's/\\@/@/g' > $@
927

    
928
man/%.1: man/%.1.in $(REPLACE_VARS_SED)
929
	sed -f $(REPLACE_VARS_SED) < $< > $@
930

    
931
man/%.7: man/%.7.in $(REPLACE_VARS_SED)
932
	sed -f $(REPLACE_VARS_SED) < $< > $@
933

    
934
man/%.8: man/%.8.in $(REPLACE_VARS_SED)
935
	sed -f $(REPLACE_VARS_SED) < $< > $@
936

    
937
man/%.html: man/%.html.in $(REPLACE_VARS_SED)
938
	sed -f $(REPLACE_VARS_SED) < $< > $@
939

    
940
epydoc.conf: epydoc.conf.in Makefile
941
	sed -e 's#@MODULES@#$(strip $(lint_python_code))#g' < $< > $@
942

    
943
vcs-version:
944
	if test -d .git; then \
945
	  git describe > $@; \
946
	elif test ! -f $@ ; then \
947
	  echo "Cannot auto-generate $@ file"; exit 1; \
948
	fi
949

    
950
.PHONY: regen-vcs-version
951
regen-vcs-version:
952
	set -e; \
953
	cd $(srcdir); \
954
	if test -d .git; then \
955
	  rm -f vcs-version; \
956
	  $(MAKE) vcs-version; \
957
	fi
958

    
959
htools/Ganeti/HTools/Version.hs: htools/Ganeti/HTools/Version.hs.in vcs-version
960
	set -e; \
961
	VCSVER=`cat $(abs_top_srcdir)/vcs-version`; \
962
	sed -e "s/%ver%/$$VCSVER/" < $< > $@
963

    
964
htools/Ganeti/Constants.hs: htools/Ganeti/Constants.hs.in \
965
	lib/constants.py lib/_autoconf.py $(CONVERT_CONSTANTS) \
966
	| lib/_vcsversion.py
967
	set -e; \
968
	{ cat $< ; PYTHONPATH=. $(CONVERT_CONSTANTS); } > $@
969

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

    
1038
lib/_vcsversion.py: Makefile vcs-version | lib/.dir
1039
	set -e; \
1040
	VCSVER=`cat $(abs_top_srcdir)/vcs-version`; \
1041
	{ echo '# This file is automatically generated, do not edit!'; \
1042
	  echo '#'; \
1043
	  echo ''; \
1044
	  echo '"""Build-time VCS version number for Ganeti.'; \
1045
	  echo '';\
1046
	  echo 'This file is autogenerated by the build process.'; \
1047
	  echo 'For any changes you need to re-run ./configure (and'; \
1048
	  echo 'not edit by hand).'; \
1049
	  echo ''; \
1050
	  echo '"""'; \
1051
	  echo ''; \
1052
	  echo '# pylint: disable=C0301,C0324'; \
1053
	  echo '# because this is autogenerated, we do not want'; \
1054
	  echo '# style warnings' ; \
1055
	  echo ''; \
1056
	  echo "VCS_VERSION = '$$VCSVER'"; \
1057
	} > $@
1058

    
1059
lib/_generated_rpc.py: lib/rpc_defs.py $(BUILD_RPC)
1060
	PYTHONPATH=. $(RUN_IN_TEMPDIR) $(CURDIR)/$(BUILD_RPC) lib/rpc_defs.py > $@
1061

    
1062
$(REPLACE_VARS_SED): Makefile
1063
	set -e; \
1064
	{ echo 's#@PREFIX@#$(prefix)#g'; \
1065
	  echo 's#@SYSCONFDIR@#$(sysconfdir)#g'; \
1066
	  echo 's#@LOCALSTATEDIR@#$(localstatedir)#g'; \
1067
	  echo 's#@BINDIR@#$(bindir)#g'; \
1068
	  echo 's#@SBINDIR@#$(sbindir)#g'; \
1069
	  echo 's#@GANETI_VERSION@#$(PACKAGE_VERSION)#g'; \
1070
	  echo 's#@CUSTOM_XEN_BOOTLOADER@#$(XEN_BOOTLOADER)#g'; \
1071
	  echo 's#@CUSTOM_XEN_KERNEL@#$(XEN_KERNEL)#g'; \
1072
	  echo 's#@CUSTOM_XEN_INITRD@#$(XEN_INITRD)#g'; \
1073
	  echo 's#@CUSTOM_IALLOCATOR_SEARCH_PATH@#$(IALLOCATOR_SEARCH_PATH)#g'; \
1074
	  echo 's#@CUSTOM_EXPORT_DIR@#$(EXPORT_DIR)#g'; \
1075
	  echo 's#@RPL_FILE_STORAGE_DIR@#$(FILE_STORAGE_DIR)#g'; \
1076
	  echo 's#@RPL_SSH_INITD_SCRIPT@#$(SSH_INITD_SCRIPT)#g'; \
1077
	  echo 's#@PKGLIBDIR@#$(pkglibdir)#g'; \
1078
	  echo 's#@GNTMASTERUSER@#$(MASTERD_USER)#g'; \
1079
	  echo 's#@GNTRAPIUSER@#$(RAPI_USER)#g'; \
1080
	  echo 's#@GNTCONFDUSER@#$(CONFD_USER)#g'; \
1081
	  echo 's#@GNTNODEDUSER@#$(NODED_USER)#g'; \
1082
	  echo 's#@GNTRAPIGROUP@#$(RAPI_GROUP)#g'; \
1083
	  echo 's#@GNTADMINGROUP@#$(ADMIN_GROUP)#g'; \
1084
	  echo 's#@GNTCONFDGROUP@#$(CONFD_GROUP)#g'; \
1085
	  echo 's#@GNTMASTERDGROUP@#$(MASTERD_GROUP)#g'; \
1086
	  echo 's#@GNTDAEMONSGROUP@#$(DAEMONS_GROUP)#g'; \
1087
	  echo 's#@CUSTOM_ENABLE_CONFD@#$(ENABLE_CONFD)#g'; \
1088
	} > $@
1089

    
1090
# Using deferred evaluation
1091
daemons/ganeti-%: MODULE = ganeti.server.$(patsubst ganeti-%,%,$(notdir $@))
1092
daemons/ganeti-watcher: MODULE = ganeti.watcher
1093
scripts/%: MODULE = ganeti.client.$(subst -,_,$(notdir $@))
1094
tools/ensure-dirs: MODULE = ganeti.tools.ensure_dirs
1095

    
1096
$(PYTHON_BOOTSTRAP): Makefile | $(all_dirfiles)
1097
	test -n "$(MODULE)" || { echo Missing module; exit 1; }
1098
	set -e; \
1099
	{ echo '#!/usr/bin/python'; \
1100
	  echo '# This file is automatically generated, do not edit!'; \
1101
	  echo "# Edit $(MODULE) instead."; \
1102
	  echo; \
1103
	  echo '"""Bootstrap script for L{$(MODULE)}"""'; \
1104
	  echo; \
1105
	  echo '# pylint: disable=C0103'; \
1106
	  echo '# C0103: Invalid name'; \
1107
	  echo; \
1108
	  echo 'import sys'; \
1109
	  echo 'import $(MODULE) as main'; \
1110
	  echo; \
1111
	  echo '# Temporarily alias commands until bash completion'; \
1112
	  echo '# generator is changed'; \
1113
	  echo 'if hasattr(main, "commands"):'; \
1114
	  echo '  commands = main.commands # pylint: disable=E1101'; \
1115
	  echo 'if hasattr(main, "aliases"):'; \
1116
	  echo '  aliases = main.aliases # pylint: disable=E1101'; \
1117
	  echo; \
1118
	  echo 'if __name__ == "__main__":'; \
1119
	  echo '  sys.exit(main.Main())'; \
1120
	} > $@
1121
	chmod u+x $@
1122

    
1123
# We need to create symlinks because "make distcheck" will not install Python
1124
# files when building.
1125
stamp-srclinks: Makefile | $(all_dirfiles)
1126
	set -e; \
1127
	for i in $(srclink_files); do \
1128
		if test ! -f $$i -a -f $(abs_top_srcdir)/$$i; then \
1129
			$(LN_S) $(abs_top_srcdir)/$$i $$i; \
1130
		fi; \
1131
	done
1132
	touch $@
1133

    
1134
.PHONY: ganeti
1135
ganeti:
1136
	cd $(top_builddir) && test -h "$@" || { rm -f $@ && $(LN_S) lib $@; }
1137

    
1138
.PHONY: check-dirs
1139
check-dirs: $(BUILT_SOURCES)
1140
	@set -e; \
1141
	find . -type d \( \( -name . \) -o \( \
1142
		-name .git -o \
1143
		-name autom4te.cache \
1144
		\) -prune -o -print \) | { \
1145
		error=; \
1146
		while read dir; do \
1147
			case "$$dir" in \
1148
				$(strip $(patsubst %,(./%) ;;,$(DIRCHECK_EXCLUDE) $(DIRS))) \
1149
				*) error=1; echo "Directory $$dir not listed in Makefile" >&2 ;; \
1150
			esac; \
1151
		done; \
1152
		for dir in $(DIRS); do \
1153
			if ! test -d "$$dir"; then \
1154
				echo "Directory $$dir listed in DIRS does not exist" >&2; \
1155
				error=1; \
1156
			fi \
1157
		done; \
1158
		if test -n "$$error"; then exit 1; else exit 0; fi; \
1159
	}
1160

    
1161
.PHONY: check-local
1162
check-local: check-dirs $(BUILT_SOURCES)
1163
	$(CHECK_PYTHON_CODE) $(check_python_code)
1164
	PYTHONPATH=. $(CHECK_HEADER) $(check_python_code)
1165
	$(CHECK_VERSION) $(VERSION) $(top_srcdir)/NEWS
1166
	$(CHECK_NEWS) < $(top_srcdir)/NEWS
1167
	PYTHONPATH=. $(RUN_IN_TEMPDIR) $(CURDIR)/$(CHECK_IMPORTS) . $(standalone_python_modules)
1168
	expver=$(VERSION_MAJOR).$(VERSION_MINOR); \
1169
	if test "`head -n 1 $(top_srcdir)/README`" != "Ganeti $$expver"; then \
1170
		echo "Incorrect version in README, expected $$expver"; \
1171
		exit 1; \
1172
	fi; \
1173
	for file in doc/iallocator.rst doc/hooks.rst; do \
1174
		if test "`sed -ne '4 p' $(top_srcdir)/$$file`" != \
1175
			"Documents Ganeti version $$expver"; then \
1176
			echo "Incorrect version in $$file, expected $$expver"; \
1177
			exit 1; \
1178
		fi; \
1179
	done
1180

    
1181
.PHONY: hs-check
1182
hs-check: htools/test
1183
	@rm -f test.tix
1184
	./htools/test
1185

    
1186
# E111: indentation is not a multiple of four
1187
# E261: at least two spaces before inline comment
1188
# E501: line too long (80 characters)
1189
PEP8_IGNORE = E111,E261,E501
1190

    
1191
# For excluding pep8 expects filenames only, not whole paths
1192
PEP8_EXCLUDE = $(subst $(space),$(comma),$(strip $(notdir $(BUILT_PYTHON_SOURCES))))
1193

    
1194
.PHONY: lint
1195
lint: $(BUILT_SOURCES)
1196
	@test -n "$(PYLINT)" || { echo 'pylint' not found during configure; exit 1; }
1197
	if test -z "$(PEP8)"; then \
1198
		echo '"pep8" not found during configure' >&2; \
1199
	else \
1200
		$(PEP8) --repeat --ignore='$(PEP8_IGNORE)' --exclude='$(PEP8_EXCLUDE)' \
1201
			$(pep8_python_code); \
1202
	fi
1203
	$(PYLINT) $(LINT_OPTS) $(lint_python_code)
1204
	cd $(top_srcdir)/qa && \
1205
	  PYTHONPATH=$(abs_top_srcdir) $(PYLINT) $(LINT_OPTS) \
1206
	  --rcfile  ../pylintrc $(patsubst qa/%.py,%,$(qa_scripts))
1207

    
1208
.PHONY: hlint
1209
hlint: $(HS_BUILT_SRCS) htools/lint-hints.hs
1210
	if tty -s; then C="-c"; else C=""; fi; \
1211
	hlint --report=doc/hs-lint.html --cross $$C \
1212
	  --ignore "Use first" \
1213
	  --ignore "Use comparing" \
1214
	  --ignore "Use on" \
1215
	  --ignore "Use Control.Exception.catch" \
1216
	  --ignore "Reduce duplication" \
1217
	  --hint htools/lint-hints \
1218
	  $(filter-out htools/Ganeti/THH.hs,$(HS_LIB_SRCS))
1219

    
1220
# a dist hook rule for updating the vcs-version file; this is
1221
# hardcoded due to where it needs to build the file...
1222
dist-hook:
1223
	$(MAKE) regen-vcs-version && \
1224
	rm -f $(top_distdir)/vcs-version && \
1225
	cp -p $(srcdir)/vcs-version $(top_distdir)
1226

    
1227
# a distcheck hook rule for catching revision control directories
1228
distcheck-hook:
1229
	if find $(top_distdir) -name .svn -or -name .git | grep .; then \
1230
		echo "Found revision control files in final archive." 1>&2; \
1231
		exit 1; \
1232
	fi
1233
	if find $(top_distdir) -name '*.py[co]' | grep .; then \
1234
		echo "Found Python byte code in final archive." 1>&2; \
1235
		exit 1; \
1236
	fi
1237
	if find $(top_distdir) -name '*~' | grep .; then \
1238
		echo "Found backup files in final archive." 1>&2; \
1239
		exit 1; \
1240
	fi
1241
# Empty files or directories should not be distributed. They can cause
1242
# unnecessary warnings for packagers. Directories used by automake during
1243
# distcheck must be excluded.
1244
	if find $(top_distdir) -empty -and -not \( \
1245
			-path $(top_distdir)/_build -or \
1246
			-path $(top_distdir)/_inst \) | grep .; then \
1247
		echo "Found empty files or directories in final archive." 1>&2; \
1248
		exit 1; \
1249
	fi
1250
	if test -n "$(BUILD_RELEASE)" && \
1251
	   grep -n -H -E '^\*.*unreleased' $(top_distdir)/NEWS; then \
1252
		echo "Found unreleased version in NEWS." >&2; \
1253
		exit 1; \
1254
	fi
1255

    
1256
# When building a release, stricter checks should be used
1257
distcheck-release dist-release: export BUILD_RELEASE = 1
1258
distcheck-release: distcheck
1259

    
1260
dist-release: dist
1261
	set -e; \
1262
	for i in $(DIST_ARCHIVES); do \
1263
		echo -n "Checking $$i ... "; \
1264
		autotools/check-tar < $$i; \
1265
		echo OK; \
1266
	done
1267

    
1268
install-exec-local:
1269
	@mkdir_p@ "$(DESTDIR)${localstatedir}/lib/ganeti" \
1270
	  "$(DESTDIR)${localstatedir}/log/ganeti" \
1271
	  "$(DESTDIR)${localstatedir}/run/ganeti"
1272

    
1273
# To avoid conflicts between directory names and other targets, a file inside
1274
# the directory is used to ensure its existence.
1275
%.dir:
1276
	@mkdir_p@ $* && touch $@
1277

    
1278
.PHONY: apidoc
1279
if WANT_HTOOLSAPIDOC
1280
apidoc: py-apidoc hs-apidoc
1281
else
1282
apidoc: py-apidoc
1283
endif
1284

    
1285
.PHONY: py-apidoc
1286
py-apidoc: epydoc.conf $(RUN_IN_TEMPDIR) $(BUILT_SOURCES)
1287
	$(RUN_IN_TEMPDIR) epydoc -v \
1288
		--conf $(CURDIR)/epydoc.conf \
1289
		--output $(CURDIR)/$(APIDOC_PY_DIR)
1290

    
1291
.PHONY: hs-apidoc
1292
hs-apidoc: $(HS_BUILT_SRCS)
1293
	@test -n "$(HSCOLOUR)" || \
1294
	    { echo 'HsColour' not found during configure; exit 1; }
1295
	@test -n "$(HADDOCK)" || \
1296
	    { echo 'haddock' not found during configure; exit 1; }
1297
	rm -rf $(APIDOC_HS_DIR)/*
1298
	@mkdir_p@ $(APIDOC_HS_DIR)/Ganeti/HTools/Program
1299
	$(HSCOLOUR) -print-css > $(APIDOC_HS_DIR)/Ganeti/hscolour.css
1300
	$(LN_S) ../hscolour.css $(APIDOC_HS_DIR)/Ganeti/HTools/hscolour.css
1301
	set -e ; \
1302
	cd htools; \
1303
	if [ "$(HTOOLS_NOCURL)" ]; \
1304
	then OPTGHC="--optghc=$(HTOOLS_NOCURL)"; \
1305
	else OPTGHC=""; \
1306
	fi; \
1307
	if [ "$(HTOOLS_PARALLEL3)" ]; \
1308
	then OPTGHC="$$OPTGHC --optghc=$(HTOOLS_PARALLEL3)"; \
1309
	fi; \
1310
	RELSRCS="$(HS_LIB_SRCS:htools/%=%)  $(HS_BUILT_SRCS:htools/%=%)"; \
1311
	for file in $$RELSRCS; do \
1312
		hfile=`echo $$file|sed 's/\\.hs$$//'`.html; \
1313
		$(HSCOLOUR) -css -anchor $$file > ../$(APIDOC_HS_DIR)/$$hfile ; \
1314
	done ; \
1315
	$(HADDOCK) --odir ../$(APIDOC_HS_DIR) --html --ignore-all-exports -w \
1316
		-t ganeti-htools -p haddock-prologue \
1317
		--source-module="%{MODULE/.//}.html" \
1318
		--source-entity="%{MODULE/.//}.html#%{NAME}" \
1319
		$$OPTGHC \
1320
		$(filter-out Ganeti/HTools/ExtLoader.hs,$(HS_LIB_SRCS:htools/%=%))
1321

    
1322
.PHONY: TAGS
1323
TAGS: $(BUILT_SOURCES)
1324
	rm -f TAGS
1325
	find . -path './lib/*.py' -o -path './scripts/gnt-*' -o \
1326
	  -path './daemons/ganeti-*' -o -path './tools/*' -o \
1327
	  -path './qa/*.py' | \
1328
	  etags -l python -
1329

    
1330
.PHONY: coverage
1331
if WANT_HTOOLS
1332
coverage: py-coverage hs-coverage
1333
else
1334
coverage: py-coverage
1335
endif
1336

    
1337
.PHONY: py-coverage
1338
py-coverage: $(BUILT_SOURCES) $(python_tests)
1339
	set -e; \
1340
	COVERAGE_FILE=$(CURDIR)/$(COVERAGE_PY_DIR)/data \
1341
	TEXT_COVERAGE=$(CURDIR)/$(COVERAGE_PY_DIR)/report.txt \
1342
	HTML_COVERAGE=$(CURDIR)/$(COVERAGE_PY_DIR) \
1343
	$(PLAIN_TESTS_ENVIRONMENT) $(abs_top_srcdir)/autotools/gen-coverage \
1344
	$(python_tests)
1345

    
1346
.PHONY: hs-coverage
1347
hs-coverage: $(haskell_tests)
1348
	cd htools && rm -f *.tix *.mix && ./test
1349
	@mkdir_p@ $(COVERAGE_HS_DIR)
1350
	hpc markup --destdir=$(COVERAGE_HS_DIR) htools/test $(HPCEXCL)
1351
	hpc report htools/test $(HPCEXCL)
1352
	$(LN_S) -f hpc_index.html $(COVERAGE_HS_DIR)/index.html
1353

    
1354
# Special "kind-of-QA" target for htools, needs special setup (all
1355
# tools compiled with -fhpc)
1356
.PHONY: live-test
1357
live-test: all
1358
	set -e ; \
1359
	cd htools; \
1360
	rm -f .hpc; $(LN_S) ../.hpc .hpc; \
1361
	rm -f *.tix *.mix; \
1362
	./live-test.sh; \
1363
	hpc sum --union $(HPCEXCL) $(addsuffix .tix,$(HS_PROGS:htools/%=%)) \
1364
	  --output=live-test.tix ; \
1365
	@mkdir_p@ ../$(COVERAGE_HS_DIR) ; \
1366
	hpc markup --destdir=../$(COVERAGE_HS_DIR) live-test \
1367
		--srcdir=.. $(HPCEXCL) ; \
1368
	hpc report --srcdir=.. live-test $(HPCEXCL)
1369

    
1370
commit-check: distcheck lint apidoc
1371

    
1372
-include ./Makefile.local
1373

    
1374
# vim: set noet :