Statistics
| Branch: | Tag: | Revision:

root / Makefile.am @ a593113c

History | View | Annotate | Download (38.9 kB)

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

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

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

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

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

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

    
53
# Delete output file if an error occurred while building it
54
.DELETE_ON_ERROR:
55

    
56
HTOOLS_DIRS = \
57
	htools \
58
	htools/Ganeti \
59
	htools/Ganeti/HTools \
60
	htools/Ganeti/HTools/Program
61

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

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

    
104
BUILDTIME_DIRS = \
105
	$(BUILDTIME_DIR_AUTOCREATE) \
106
	doc/html
107

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

    
113
all_dirfiles = $(addsuffix /.dir,$(DIRS) $(BUILDTIME_DIR_AUTOCREATE))
114

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

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

    
131
maintainer-clean-local:
132
	rm -rf $(BUILDTIME_DIRS)
133

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

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

    
164
built_base_sources = \
165
	ganeti \
166
	stamp-srclinks \
167
	$(all_dirfiles)
168

    
169
built_python_base_sources = \
170
	lib/_autoconf.py \
171
	lib/_vcsversion.py
172

    
173
BUILT_PYTHON_SOURCES = \
174
	$(built_python_base_sources) \
175
	lib/_generated_rpc.py
176

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

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

    
189
nodist_pkgpython_PYTHON = \
190
	$(BUILT_PYTHON_SOURCES)
191

    
192
noinst_PYTHON = \
193
	lib/build/__init__.py \
194
	lib/build/sphinx_ext.py
195

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

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

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

    
251
rapi_PYTHON = \
252
	lib/rapi/__init__.py \
253
	lib/rapi/baserlib.py \
254
	lib/rapi/client.py \
255
	lib/rapi/client_utils.py \
256
	lib/rapi/connector.py \
257
	lib/rapi/rlib2.py \
258
	lib/rapi/testutils.py
259

    
260
http_PYTHON = \
261
	lib/http/__init__.py \
262
	lib/http/auth.py \
263
	lib/http/client.py \
264
	lib/http/server.py
265

    
266
confd_PYTHON = \
267
	lib/confd/__init__.py \
268
	lib/confd/client.py \
269
	lib/confd/querylib.py \
270
	lib/confd/server.py
271

    
272
masterd_PYTHON = \
273
	lib/masterd/__init__.py \
274
	lib/masterd/instance.py
275

    
276
impexpd_PYTHON = \
277
	lib/impexpd/__init__.py
278

    
279
watcher_PYTHON = \
280
	lib/watcher/__init__.py \
281
	lib/watcher/nodemaint.py \
282
	lib/watcher/state.py
283

    
284
server_PYTHON = \
285
	lib/server/__init__.py \
286
	lib/server/confd.py \
287
	lib/server/masterd.py \
288
	lib/server/noded.py \
289
	lib/server/rapi.py
290

    
291
pytools_PYTHON = \
292
	lib/tools/__init__.py \
293
	lib/tools/ensure_dirs.py
294

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

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

    
351
HS_PROGS = htools/htools
352
HS_BIN_ROLES = hbal hscan hspace hinfo
353

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

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

    
403
HS_BUILT_SRCS = htools/Ganeti/HTools/Version.hs htools/Ganeti/Constants.hs
404
HS_BUILT_SRCS_IN = $(patsubst %,%.in,$(HS_BUILT_SRCS))
405

    
406
$(RUN_IN_TEMPDIR): | $(all_dirfiles)
407

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

    
427
doc/html: doc/html/index.html
428

    
429
doc/install-quick.rst: INSTALL
430
doc/news.rst: NEWS
431
doc/upgrade.rst: UPGRADE
432

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

    
441
docdot = \
442
	doc/arch-2.0.dot \
443
	doc/design-2.1-lock-acquire.dot \
444
	doc/design-2.1-lock-release.dot
445

    
446
docpng = $(patsubst %.dot,%.png,$(docdot))
447

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

    
457
gnt_scripts = \
458
	scripts/gnt-backup \
459
	scripts/gnt-cluster \
460
	scripts/gnt-debug \
461
	scripts/gnt-group \
462
	scripts/gnt-instance \
463
	scripts/gnt-job \
464
	scripts/gnt-node \
465
	scripts/gnt-os
466

    
467
PYTHON_BOOTSTRAP_SBIN = \
468
	daemons/ganeti-confd \
469
	daemons/ganeti-masterd \
470
	daemons/ganeti-noded \
471
	daemons/ganeti-watcher \
472
	daemons/ganeti-rapi \
473
	$(gnt_scripts)
474

    
475
PYTHON_BOOTSTRAP = \
476
	$(PYTHON_BOOTSTRAP_SBIN) \
477
	tools/ensure-dirs
478

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

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

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

    
525
# for the htools/test binary, we need to enable profiling/coverage
526
htools/test: HEXTRA_INT=-fhpc -Wwarn -fno-warn-missing-signatures \
527
	-fno-warn-monomorphism-restriction -fno-warn-orphans \
528
	-fno-warn-missing-methods -fno-warn-unused-imports
529

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

    
541
hs-prof-quick:
542
	$(MAKE) $(HS_ALL_PROGS) HEXTRA="-osuf .prof_o -prof -auto-all"
543

    
544
dist_sbin_SCRIPTS = \
545
	tools/ganeti-listrunner
546

    
547
nodist_sbin_SCRIPTS = \
548
	$(PYTHON_BOOTSTRAP_SBIN) \
549
	daemons/ganeti-cleaner
550

    
551
python_scripts = \
552
	tools/burnin \
553
	tools/cfgshell \
554
	tools/cfgupgrade \
555
	tools/cfgupgrade12 \
556
	tools/cluster-merge \
557
	tools/confd-client \
558
	tools/fmtjson \
559
	tools/lvmstrap \
560
	tools/move-instance \
561
	tools/ovfconverter \
562
	tools/setup-ssh \
563
	tools/sanitize-config
564

    
565
dist_tools_SCRIPTS = \
566
	$(python_scripts) \
567
	tools/kvm-console-wrapper \
568
	tools/xm-console-wrapper \
569
	tools/master-ip-setup
570

    
571
pkglib_python_scripts = \
572
	daemons/import-export \
573
	tools/check-cert-expired
574

    
575
nodist_pkglib_python_scripts = \
576
	tools/ensure-dirs
577

    
578
myexeclib_SCRIPTS = \
579
	daemons/daemon-util \
580
	tools/kvm-ifup \
581
	$(pkglib_python_scripts)
582

    
583
nodist_myexeclib_SCRIPTS = \
584
	$(nodist_pkglib_python_scripts)
585

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

    
637
man_MANS = \
638
	man/ganeti.7 \
639
	man/ganeti-cleaner.8 \
640
	man/ganeti-confd.8 \
641
	man/ganeti-listrunner.8 \
642
	man/ganeti-masterd.8 \
643
	man/ganeti-noded.8 \
644
	man/ganeti-os-interface.7 \
645
	man/ganeti-rapi.8 \
646
	man/ganeti-watcher.8 \
647
	man/gnt-backup.8 \
648
	man/gnt-cluster.8 \
649
	man/gnt-debug.8 \
650
	man/gnt-group.8 \
651
	man/gnt-instance.8 \
652
	man/gnt-job.8 \
653
	man/gnt-node.8 \
654
	man/gnt-os.8 \
655
	man/hail.1 \
656
	man/hbal.1 \
657
	man/hinfo.1 \
658
	man/hscan.1 \
659
	man/hspace.1 \
660
	man/htools.1
661

    
662
manrst = $(patsubst %.1,%.rst,$(patsubst %.7,%.rst,$(patsubst %.8,%.rst,$(man_MANS))))
663
manhtml = $(patsubst %.rst,%.html,$(manrst))
664
mangen = $(patsubst %.rst,%.gen,$(manrst))
665
maninput = \
666
	$(patsubst %.1,%.1.in,$(patsubst %.7,%.7.in,$(patsubst %.8,%.8.in,$(man_MANS)))) \
667
	$(patsubst %.html,%.html.in,$(manhtml)) \
668
	man/footer.man man/footer.html $(mangen)
669

    
670
TEST_FILES = \
671
	test/data/bdev-drbd-8.0.txt \
672
	test/data/bdev-drbd-8.3.txt \
673
	test/data/bdev-drbd-disk.txt \
674
	test/data/bdev-drbd-net-ip4.txt \
675
	test/data/bdev-drbd-net-ip6.txt \
676
	test/data/cert1.pem \
677
	test/data/ip-addr-show-dummy0.txt \
678
	test/data/ip-addr-show-lo-ipv4.txt \
679
	test/data/ip-addr-show-lo-ipv6.txt \
680
	test/data/ip-addr-show-lo-oneline-ipv4.txt \
681
	test/data/ip-addr-show-lo-oneline-ipv6.txt \
682
	test/data/ip-addr-show-lo-oneline.txt \
683
	test/data/ip-addr-show-lo.txt \
684
	test/data/proc_drbd8.txt \
685
	test/data/proc_drbd80-emptyline.txt \
686
	test/data/proc_drbd83.txt \
687
	test/data/proc_drbd83_sync.txt \
688
	test/data/proc_drbd83_sync_krnl2.6.39.txt \
689
	test/data/kvm_1.0_help.txt \
690
	test/data/kvm_0.15.90_help.txt \
691
	test/data/kvm_0.12.5_help.txt \
692
	test/data/kvm_0.9.1_help.txt \
693
	test/data/sys_drbd_usermode_helper.txt \
694
	test/data/ovfdata/compr_disk.vmdk.gz \
695
	test/data/ovfdata/config.ini \
696
	test/data/ovfdata/corrupted_resources.ovf \
697
	test/data/ovfdata/empty.ini \
698
	test/data/ovfdata/empty.ovf \
699
	test/data/ovfdata/ganeti.mf \
700
	test/data/ovfdata/ganeti.ovf \
701
	test/data/ovfdata/gzip_disk.ovf \
702
	test/data/ovfdata/new_disk.vmdk \
703
	test/data/ovfdata/no_disk.ini \
704
	test/data/ovfdata/no_disk_in_ref.ovf \
705
	test/data/ovfdata/no_os.ini \
706
	test/data/ovfdata/no_ovf.ova \
707
	test/data/ovfdata/ova.ova \
708
	test/data/ovfdata/second_disk.vmdk \
709
	test/data/ovfdata/rawdisk.raw \
710
	test/data/ovfdata/unsafe_path.ini \
711
	test/data/ovfdata/virtualbox.ovf \
712
	test/data/ovfdata/wrong_extension.ovd \
713
	test/data/ovfdata/wrong_config.ini \
714
	test/data/ovfdata/wrong_manifest.mf \
715
	test/data/ovfdata/wrong_manifest.ovf \
716
	test/data/ovfdata/wrong_ova.ova \
717
	test/data/ovfdata/wrong_xml.ovf \
718
	test/data/ovfdata/other/rawdisk.raw \
719
	test/data/vgreduce-removemissing-2.02.02.txt \
720
	test/data/vgreduce-removemissing-2.02.66-fail.txt \
721
	test/data/vgreduce-removemissing-2.02.66-ok.txt \
722
	test/data/vgs-missing-pvs-2.02.02.txt \
723
	test/data/vgs-missing-pvs-2.02.66.txt \
724
	test/import-export_unittest-helper
725

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

    
795
haskell_tests = htools/test
796

    
797
dist_TESTS = \
798
	test/check-cert-expired_unittest.bash \
799
	test/daemon-util_unittest.bash \
800
	test/ganeti-cleaner_unittest.bash \
801
	test/import-export_unittest.bash \
802
	$(python_tests)
803

    
804
nodist_TESTS =
805
if WANT_HTOOLSTESTS
806
nodist_TESTS += $(haskell_tests)
807
endif
808

    
809
TESTS = $(dist_TESTS) $(nodist_TESTS)
810

    
811
# Environment for all tests
812
PLAIN_TESTS_ENVIRONMENT = \
813
	PYTHONPATH=. TOP_SRCDIR=$(abs_top_srcdir) PYTHON=$(PYTHON) \
814
	FAKEROOT=$(FAKEROOT_PATH) $(RUN_IN_TEMPDIR)
815

    
816
# Environment for tests run by automake
817
TESTS_ENVIRONMENT = \
818
	$(PLAIN_TESTS_ENVIRONMENT) $(abs_top_srcdir)/autotools/testrunner
819

    
820
all_python_code = \
821
	$(dist_sbin_SCRIPTS) \
822
	$(python_scripts) \
823
	$(pkglib_python_scripts) \
824
	$(nodist_pkglib_python_scripts) \
825
	$(python_tests) \
826
	$(pkgpython_PYTHON) \
827
	$(client_PYTHON) \
828
	$(hypervisor_PYTHON) \
829
	$(rapi_PYTHON) \
830
	$(server_PYTHON) \
831
	$(pytools_PYTHON) \
832
	$(http_PYTHON) \
833
	$(confd_PYTHON) \
834
	$(masterd_PYTHON) \
835
	$(impexpd_PYTHON) \
836
	$(utils_PYTHON) \
837
	$(watcher_PYTHON) \
838
	$(noinst_PYTHON) \
839
	$(qa_scripts)
840

    
841
srclink_files = \
842
	man/footer.rst \
843
	test/check-cert-expired_unittest.bash \
844
	test/daemon-util_unittest.bash \
845
	test/ganeti-cleaner_unittest.bash \
846
	test/import-export_unittest.bash \
847
	$(all_python_code) \
848
	$(HS_LIB_SRCS) $(HS_PROG_SRCS)
849

    
850
check_python_code = \
851
	$(BUILD_BASH_COMPLETION) \
852
	$(CHECK_IMPORTS) \
853
	$(CHECK_HEADER) \
854
	$(DOCPP) \
855
	$(all_python_code)
856

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

    
869
standalone_python_modules = \
870
	lib/rapi/client.py \
871
	tools/ganeti-listrunner
872

    
873
pep8_python_code = \
874
	ganeti \
875
	ganeti/http/server.py \
876
	$(dist_sbin_SCRIPTS) \
877
	$(python_scripts) \
878
	$(pkglib_python_scripts) \
879
	$(BUILD_BASH_COMPLETION) \
880
	$(CHECK_HEADER) \
881
	$(DOCPP) \
882
	$(PYTHON_BOOTSTRAP) \
883
	qa
884

    
885
test/daemon-util_unittest.bash: daemons/daemon-util
886

    
887
test/ganeti-cleaner_unittest.bash: daemons/ganeti-cleaner
888

    
889
tools/kvm-ifup: tools/kvm-ifup.in $(REPLACE_VARS_SED)
890
	sed -f $(REPLACE_VARS_SED) < $< > $@
891
	chmod +x $@
892

    
893
devel/upload: devel/upload.in $(REPLACE_VARS_SED)
894
	sed -f $(REPLACE_VARS_SED) < $< > $@
895
	chmod u+x $@
896

    
897
daemons/%: daemons/%.in $(REPLACE_VARS_SED)
898
	sed -f $(REPLACE_VARS_SED) < $< > $@
899
	chmod +x $@
900

    
901
doc/examples/%: doc/examples/%.in $(REPLACE_VARS_SED)
902
	sed -f $(REPLACE_VARS_SED) < $< > $@
903

    
904
doc/examples/hooks/%: doc/examples/hooks/%.in $(REPLACE_VARS_SED)
905
	sed -f $(REPLACE_VARS_SED) < $< > $@
906

    
907
doc/examples/bash_completion: $(BUILD_BASH_COMPLETION) $(RUN_IN_TEMPDIR) \
908
	lib/cli.py $(gnt_scripts) $(client_PYTHON) tools/burnin
909
	PYTHONPATH=. $(RUN_IN_TEMPDIR) $(CURDIR)/$(BUILD_BASH_COMPLETION) > $@
910

    
911
doc/%.png: doc/%.dot
912
	@test -n "$(DOT)" || { echo 'dot' not found during configure; exit 1; }
913
	$(DOT) -Tpng -o $@ $<
914

    
915
man/footer.man: man/footer.rst
916
	@test -n "$(PANDOC)" || \
917
	  { echo 'pandoc' not found during configure; exit 1; }
918
	$(PANDOC) -f rst -t man -o $@ $<
919

    
920
man/footer.html: man/footer.rst
921
	@test -n "$(PANDOC)" || \
922
	  { echo 'pandoc' not found during configure; exit 1; }
923
	$(PANDOC) -f rst -t html -o $@ $<
924

    
925
man/%.gen: man/%.rst lib/query.py lib/build/sphinx_ext.py
926
	PYTHONPATH=. $(RUN_IN_TEMPDIR) $(CURDIR)/$(DOCPP) < $< > $@
927

    
928
man/%.7.in man/%.8.in man/%.1.in: man/%.gen man/footer.man
929
	@test -n "$(PANDOC)" || \
930
	  { echo 'pandoc' not found during configure; exit 1; }
931
	set -o pipefail ; \
932
	trap 'echo auto-removing $@; rm $@' EXIT; \
933
	$(PANDOC) -s -f rst -t man -A man/footer.man $< | \
934
	  sed -e 's/\\@/@/g' > $@; \
935
	if test -n "$(MAN_HAS_WARNINGS)"; then $(CHECK_MAN_WARNINGS) $@; fi; \
936
	$(CHECK_MAN_DASHES) $@; \
937
	trap - EXIT
938

    
939

    
940
man/%.html.in: man/%.gen man/footer.html
941
	@test -n "$(PANDOC)" || \
942
	  { echo 'pandoc' not found during configure; exit 1; }
943
	set -o pipefail ; \
944
	$(PANDOC) -s -f rst -t html -A man/footer.html $< | \
945
	  sed -e 's/\\@/@/g' > $@
946

    
947
man/%.1: man/%.1.in $(REPLACE_VARS_SED)
948
	sed -f $(REPLACE_VARS_SED) < $< > $@
949

    
950
man/%.7: man/%.7.in $(REPLACE_VARS_SED)
951
	sed -f $(REPLACE_VARS_SED) < $< > $@
952

    
953
man/%.8: man/%.8.in $(REPLACE_VARS_SED)
954
	sed -f $(REPLACE_VARS_SED) < $< > $@
955

    
956
man/%.html: man/%.html.in $(REPLACE_VARS_SED)
957
	sed -f $(REPLACE_VARS_SED) < $< > $@
958

    
959
epydoc.conf: epydoc.conf.in Makefile
960
	sed -e 's#@MODULES@#$(strip $(lint_python_code))#g' < $< > $@
961

    
962
vcs-version:
963
	if test -d .git; then \
964
	  git describe > $@; \
965
	elif test ! -f $@ ; then \
966
	  echo "Cannot auto-generate $@ file"; exit 1; \
967
	fi
968

    
969
.PHONY: regen-vcs-version
970
regen-vcs-version:
971
	set -e; \
972
	cd $(srcdir); \
973
	if test -d .git; then \
974
	  rm -f vcs-version; \
975
	  $(MAKE) vcs-version; \
976
	fi
977

    
978
htools/Ganeti/HTools/Version.hs: htools/Ganeti/HTools/Version.hs.in vcs-version
979
	set -e; \
980
	VCSVER=`cat $(abs_top_srcdir)/vcs-version`; \
981
	sed -e "s/%ver%/$$VCSVER/" < $< > $@
982

    
983
htools/Ganeti/Constants.hs: htools/Ganeti/Constants.hs.in \
984
	lib/constants.py lib/_autoconf.py $(CONVERT_CONSTANTS) \
985
	| lib/_vcsversion.py
986
	set -e; \
987
	{ cat $< ; PYTHONPATH=. $(CONVERT_CONSTANTS); } > $@
988

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

    
1057
lib/_vcsversion.py: Makefile vcs-version | lib/.dir
1058
	set -e; \
1059
	VCSVER=`cat $(abs_top_srcdir)/vcs-version`; \
1060
	{ echo '# This file is automatically generated, do not edit!'; \
1061
	  echo '#'; \
1062
	  echo ''; \
1063
	  echo '"""Build-time VCS version number for Ganeti.'; \
1064
	  echo '';\
1065
	  echo 'This file is autogenerated by the build process.'; \
1066
	  echo 'For any changes you need to re-run ./configure (and'; \
1067
	  echo 'not edit by hand).'; \
1068
	  echo ''; \
1069
	  echo '"""'; \
1070
	  echo ''; \
1071
	  echo '# pylint: disable=C0301,C0324'; \
1072
	  echo '# because this is autogenerated, we do not want'; \
1073
	  echo '# style warnings' ; \
1074
	  echo ''; \
1075
	  echo "VCS_VERSION = '$$VCSVER'"; \
1076
	} > $@
1077

    
1078
lib/_generated_rpc.py: lib/rpc_defs.py $(BUILD_RPC)
1079
	PYTHONPATH=. $(RUN_IN_TEMPDIR) $(CURDIR)/$(BUILD_RPC) lib/rpc_defs.py > $@
1080

    
1081
$(REPLACE_VARS_SED): Makefile
1082
	set -e; \
1083
	{ echo 's#@PREFIX@#$(prefix)#g'; \
1084
	  echo 's#@SYSCONFDIR@#$(sysconfdir)#g'; \
1085
	  echo 's#@LOCALSTATEDIR@#$(localstatedir)#g'; \
1086
	  echo 's#@BINDIR@#$(bindir)#g'; \
1087
	  echo 's#@SBINDIR@#$(sbindir)#g'; \
1088
	  echo 's#@GANETI_VERSION@#$(PACKAGE_VERSION)#g'; \
1089
	  echo 's#@CUSTOM_XEN_BOOTLOADER@#$(XEN_BOOTLOADER)#g'; \
1090
	  echo 's#@CUSTOM_XEN_KERNEL@#$(XEN_KERNEL)#g'; \
1091
	  echo 's#@CUSTOM_XEN_INITRD@#$(XEN_INITRD)#g'; \
1092
	  echo 's#@CUSTOM_IALLOCATOR_SEARCH_PATH@#$(IALLOCATOR_SEARCH_PATH)#g'; \
1093
	  echo 's#@CUSTOM_EXPORT_DIR@#$(EXPORT_DIR)#g'; \
1094
	  echo 's#@RPL_FILE_STORAGE_DIR@#$(FILE_STORAGE_DIR)#g'; \
1095
	  echo 's#@RPL_SSH_INITD_SCRIPT@#$(SSH_INITD_SCRIPT)#g'; \
1096
	  echo 's#@PKGLIBDIR@#$(pkglibdir)#g'; \
1097
	  echo 's#@GNTMASTERUSER@#$(MASTERD_USER)#g'; \
1098
	  echo 's#@GNTRAPIUSER@#$(RAPI_USER)#g'; \
1099
	  echo 's#@GNTCONFDUSER@#$(CONFD_USER)#g'; \
1100
	  echo 's#@GNTNODEDUSER@#$(NODED_USER)#g'; \
1101
	  echo 's#@GNTRAPIGROUP@#$(RAPI_GROUP)#g'; \
1102
	  echo 's#@GNTADMINGROUP@#$(ADMIN_GROUP)#g'; \
1103
	  echo 's#@GNTCONFDGROUP@#$(CONFD_GROUP)#g'; \
1104
	  echo 's#@GNTMASTERDGROUP@#$(MASTERD_GROUP)#g'; \
1105
	  echo 's#@GNTDAEMONSGROUP@#$(DAEMONS_GROUP)#g'; \
1106
	  echo 's#@CUSTOM_ENABLE_CONFD@#$(ENABLE_CONFD)#g'; \
1107
	} > $@
1108

    
1109
# Using deferred evaluation
1110
daemons/ganeti-%: MODULE = ganeti.server.$(patsubst ganeti-%,%,$(notdir $@))
1111
daemons/ganeti-watcher: MODULE = ganeti.watcher
1112
scripts/%: MODULE = ganeti.client.$(subst -,_,$(notdir $@))
1113
tools/ensure-dirs: MODULE = ganeti.tools.ensure_dirs
1114

    
1115
$(PYTHON_BOOTSTRAP): Makefile | $(all_dirfiles)
1116
	test -n "$(MODULE)" || { echo Missing module; exit 1; }
1117
	set -e; \
1118
	{ echo '#!/usr/bin/python'; \
1119
	  echo '# This file is automatically generated, do not edit!'; \
1120
	  echo "# Edit $(MODULE) instead."; \
1121
	  echo; \
1122
	  echo '"""Bootstrap script for L{$(MODULE)}"""'; \
1123
	  echo; \
1124
	  echo '# pylint: disable=C0103'; \
1125
	  echo '# C0103: Invalid name'; \
1126
	  echo; \
1127
	  echo 'import sys'; \
1128
	  echo 'import $(MODULE) as main'; \
1129
	  echo; \
1130
	  echo '# Temporarily alias commands until bash completion'; \
1131
	  echo '# generator is changed'; \
1132
	  echo 'if hasattr(main, "commands"):'; \
1133
	  echo '  commands = main.commands # pylint: disable=E1101'; \
1134
	  echo 'if hasattr(main, "aliases"):'; \
1135
	  echo '  aliases = main.aliases # pylint: disable=E1101'; \
1136
	  echo; \
1137
	  echo 'if __name__ == "__main__":'; \
1138
	  echo '  sys.exit(main.Main())'; \
1139
	} > $@
1140
	chmod u+x $@
1141

    
1142
# We need to create symlinks because "make distcheck" will not install Python
1143
# files when building.
1144
stamp-srclinks: Makefile | $(all_dirfiles)
1145
	set -e; \
1146
	for i in $(srclink_files); do \
1147
		if test ! -f $$i -a -f $(abs_top_srcdir)/$$i; then \
1148
			$(LN_S) $(abs_top_srcdir)/$$i $$i; \
1149
		fi; \
1150
	done
1151
	touch $@
1152

    
1153
.PHONY: ganeti
1154
ganeti:
1155
	cd $(top_builddir) && test -h "$@" || { rm -f $@ && $(LN_S) lib $@; }
1156

    
1157
.PHONY: check-dirs
1158
check-dirs: $(BUILT_SOURCES)
1159
	@set -e; \
1160
	find . -type d \( \( -name . \) -o \( \
1161
		-name .git -o \
1162
		-name autom4te.cache \
1163
		\) -prune -o -print \) | { \
1164
		error=; \
1165
		while read dir; do \
1166
			case "$$dir" in \
1167
				$(strip $(patsubst %,(./%) ;;,$(DIRCHECK_EXCLUDE) $(DIRS))) \
1168
				*) error=1; echo "Directory $$dir not listed in Makefile" >&2 ;; \
1169
			esac; \
1170
		done; \
1171
		for dir in $(DIRS); do \
1172
			if ! test -d "$$dir"; then \
1173
				echo "Directory $$dir listed in DIRS does not exist" >&2; \
1174
				error=1; \
1175
			fi \
1176
		done; \
1177
		if test -n "$$error"; then exit 1; else exit 0; fi; \
1178
	}
1179

    
1180
.PHONY: check-local
1181
check-local: check-dirs $(BUILT_SOURCES)
1182
	$(CHECK_PYTHON_CODE) $(check_python_code)
1183
	PYTHONPATH=. $(CHECK_HEADER) $(check_python_code)
1184
	$(CHECK_VERSION) $(VERSION) $(top_srcdir)/NEWS
1185
	$(CHECK_NEWS) < $(top_srcdir)/NEWS
1186
	PYTHONPATH=. $(RUN_IN_TEMPDIR) $(CURDIR)/$(CHECK_IMPORTS) . $(standalone_python_modules)
1187
	expver=$(VERSION_MAJOR).$(VERSION_MINOR); \
1188
	if test "`head -n 1 $(top_srcdir)/README`" != "Ganeti $$expver"; then \
1189
		echo "Incorrect version in README, expected $$expver"; \
1190
		exit 1; \
1191
	fi; \
1192
	for file in doc/iallocator.rst doc/hooks.rst; do \
1193
		if test "`sed -ne '4 p' $(top_srcdir)/$$file`" != \
1194
			"Documents Ganeti version $$expver"; then \
1195
			echo "Incorrect version in $$file, expected $$expver"; \
1196
			exit 1; \
1197
		fi; \
1198
	done
1199

    
1200
.PHONY: hs-check
1201
hs-check: htools/test
1202
	@rm -f test.tix
1203
	./htools/test
1204

    
1205
# E111: indentation is not a multiple of four
1206
# E261: at least two spaces before inline comment
1207
# E501: line too long (80 characters)
1208
PEP8_IGNORE = E111,E261,E501
1209

    
1210
# For excluding pep8 expects filenames only, not whole paths
1211
PEP8_EXCLUDE = $(subst $(space),$(comma),$(strip $(notdir $(BUILT_PYTHON_SOURCES))))
1212

    
1213
.PHONY: lint
1214
lint: $(BUILT_SOURCES)
1215
	@test -n "$(PYLINT)" || { echo 'pylint' not found during configure; exit 1; }
1216
	if test -z "$(PEP8)"; then \
1217
		echo '"pep8" not found during configure' >&2; \
1218
	else \
1219
		$(PEP8) --repeat --ignore='$(PEP8_IGNORE)' --exclude='$(PEP8_EXCLUDE)' \
1220
			$(pep8_python_code); \
1221
	fi
1222
	$(PYLINT) $(LINT_OPTS) $(lint_python_code)
1223
	cd $(top_srcdir)/qa && \
1224
	  PYTHONPATH=$(abs_top_srcdir) $(PYLINT) $(LINT_OPTS) \
1225
	  --rcfile  ../pylintrc $(patsubst qa/%.py,%,$(qa_scripts))
1226

    
1227
.PHONY: hlint
1228
hlint: $(HS_BUILT_SRCS) htools/lint-hints.hs
1229
	if tty -s; then C="-c"; else C=""; fi; \
1230
	hlint --report=doc/hs-lint.html --cross $$C \
1231
	  --ignore "Use first" \
1232
	  --ignore "Use comparing" \
1233
	  --ignore "Use on" \
1234
	  --ignore "Use Control.Exception.catch" \
1235
	  --ignore "Reduce duplication" \
1236
	  --hint htools/lint-hints \
1237
	  $(filter-out htools/Ganeti/THH.hs,$(HS_LIB_SRCS))
1238

    
1239
# a dist hook rule for updating the vcs-version file; this is
1240
# hardcoded due to where it needs to build the file...
1241
dist-hook:
1242
	$(MAKE) regen-vcs-version && \
1243
	rm -f $(top_distdir)/vcs-version && \
1244
	cp -p $(srcdir)/vcs-version $(top_distdir)
1245

    
1246
# a distcheck hook rule for catching revision control directories
1247
distcheck-hook:
1248
	if find $(top_distdir) -name .svn -or -name .git | grep .; then \
1249
		echo "Found revision control files in final archive." 1>&2; \
1250
		exit 1; \
1251
	fi
1252
	if find $(top_distdir) -name '*.py[co]' | grep .; then \
1253
		echo "Found Python byte code in final archive." 1>&2; \
1254
		exit 1; \
1255
	fi
1256
	if find $(top_distdir) -name '*~' | grep .; then \
1257
		echo "Found backup files in final archive." 1>&2; \
1258
		exit 1; \
1259
	fi
1260
# Empty files or directories should not be distributed. They can cause
1261
# unnecessary warnings for packagers. Directories used by automake during
1262
# distcheck must be excluded.
1263
	if find $(top_distdir) -empty -and -not \( \
1264
			-path $(top_distdir)/_build -or \
1265
			-path $(top_distdir)/_inst \) | grep .; then \
1266
		echo "Found empty files or directories in final archive." 1>&2; \
1267
		exit 1; \
1268
	fi
1269
	if test -n "$(BUILD_RELEASE)" && \
1270
	   grep -n -H -E '^\*.*unreleased' $(top_distdir)/NEWS; then \
1271
		echo "Found unreleased version in NEWS." >&2; \
1272
		exit 1; \
1273
	fi
1274

    
1275
# When building a release, stricter checks should be used
1276
distcheck-release dist-release: export BUILD_RELEASE = 1
1277
distcheck-release: distcheck
1278

    
1279
dist-release: dist
1280
	set -e; \
1281
	for i in $(DIST_ARCHIVES); do \
1282
		echo -n "Checking $$i ... "; \
1283
		autotools/check-tar < $$i; \
1284
		echo OK; \
1285
	done
1286

    
1287
install-exec-local:
1288
	@mkdir_p@ "$(DESTDIR)${localstatedir}/lib/ganeti" \
1289
	  "$(DESTDIR)${localstatedir}/log/ganeti" \
1290
	  "$(DESTDIR)${localstatedir}/run/ganeti"
1291

    
1292
# To avoid conflicts between directory names and other targets, a file inside
1293
# the directory is used to ensure its existence.
1294
%.dir:
1295
	@mkdir_p@ $* && touch $@
1296

    
1297
.PHONY: apidoc
1298
if WANT_HTOOLSAPIDOC
1299
apidoc: py-apidoc hs-apidoc
1300
else
1301
apidoc: py-apidoc
1302
endif
1303

    
1304
.PHONY: py-apidoc
1305
py-apidoc: epydoc.conf $(RUN_IN_TEMPDIR) $(BUILT_SOURCES)
1306
	$(RUN_IN_TEMPDIR) epydoc -v \
1307
		--conf $(CURDIR)/epydoc.conf \
1308
		--output $(CURDIR)/$(APIDOC_PY_DIR)
1309

    
1310
.PHONY: hs-apidoc
1311
hs-apidoc: $(HS_BUILT_SRCS)
1312
	@test -n "$(HSCOLOUR)" || \
1313
	    { echo 'HsColour' not found during configure; exit 1; }
1314
	@test -n "$(HADDOCK)" || \
1315
	    { echo 'haddock' not found during configure; exit 1; }
1316
	rm -rf $(APIDOC_HS_DIR)/*
1317
	@mkdir_p@ $(APIDOC_HS_DIR)/Ganeti/HTools/Program
1318
	$(HSCOLOUR) -print-css > $(APIDOC_HS_DIR)/Ganeti/hscolour.css
1319
	$(LN_S) ../hscolour.css $(APIDOC_HS_DIR)/Ganeti/HTools/hscolour.css
1320
	set -e ; \
1321
	cd htools; \
1322
	if [ "$(HTOOLS_NOCURL)" ]; \
1323
	then OPTGHC="--optghc=$(HTOOLS_NOCURL)"; \
1324
	else OPTGHC=""; \
1325
	fi; \
1326
	if [ "$(HTOOLS_PARALLEL3)" ]; \
1327
	then OPTGHC="$$OPTGHC --optghc=$(HTOOLS_PARALLEL3)"; \
1328
	fi; \
1329
	RELSRCS="$(HS_LIB_SRCS:htools/%=%)  $(HS_BUILT_SRCS:htools/%=%)"; \
1330
	for file in $$RELSRCS; do \
1331
		hfile=`echo $$file|sed 's/\\.hs$$//'`.html; \
1332
		$(HSCOLOUR) -css -anchor $$file > ../$(APIDOC_HS_DIR)/$$hfile ; \
1333
	done ; \
1334
	$(HADDOCK) --odir ../$(APIDOC_HS_DIR) --html --ignore-all-exports -w \
1335
		-t ganeti-htools -p haddock-prologue \
1336
		--source-module="%{MODULE/.//}.html" \
1337
		--source-entity="%{MODULE/.//}.html#%{NAME}" \
1338
		$$OPTGHC \
1339
		$(filter-out Ganeti/HTools/ExtLoader.hs,$(HS_LIB_SRCS:htools/%=%))
1340

    
1341
.PHONY: TAGS
1342
TAGS: $(BUILT_SOURCES)
1343
	rm -f TAGS
1344
	find . -path './lib/*.py' -o -path './scripts/gnt-*' -o \
1345
	  -path './daemons/ganeti-*' -o -path './tools/*' -o \
1346
	  -path './qa/*.py' | \
1347
	  etags -l python -
1348

    
1349
.PHONY: coverage
1350
if WANT_HTOOLS
1351
coverage: py-coverage hs-coverage
1352
else
1353
coverage: py-coverage
1354
endif
1355

    
1356
.PHONY: py-coverage
1357
py-coverage: $(BUILT_SOURCES) $(python_tests)
1358
	set -e; \
1359
	COVERAGE_FILE=$(CURDIR)/$(COVERAGE_PY_DIR)/data \
1360
	TEXT_COVERAGE=$(CURDIR)/$(COVERAGE_PY_DIR)/report.txt \
1361
	HTML_COVERAGE=$(CURDIR)/$(COVERAGE_PY_DIR) \
1362
	$(PLAIN_TESTS_ENVIRONMENT) $(abs_top_srcdir)/autotools/gen-coverage \
1363
	$(python_tests)
1364

    
1365
.PHONY: hs-coverage
1366
hs-coverage: $(haskell_tests)
1367
	cd htools && rm -f *.tix *.mix && ./test
1368
	@mkdir_p@ $(COVERAGE_HS_DIR)
1369
	hpc markup --destdir=$(COVERAGE_HS_DIR) htools/test $(HPCEXCL)
1370
	hpc report htools/test $(HPCEXCL)
1371
	$(LN_S) -f hpc_index.html $(COVERAGE_HS_DIR)/index.html
1372

    
1373
# Special "kind-of-QA" target for htools, needs special setup (all
1374
# tools compiled with -fhpc)
1375
.PHONY: live-test
1376
live-test: all
1377
	set -e ; \
1378
	cd htools; \
1379
	rm -f .hpc; $(LN_S) ../.hpc .hpc; \
1380
	rm -f *.tix *.mix; \
1381
	./live-test.sh; \
1382
	hpc sum --union $(HPCEXCL) $(addsuffix .tix,$(HS_PROGS:htools/%=%)) \
1383
	  --output=live-test.tix ; \
1384
	@mkdir_p@ ../$(COVERAGE_HS_DIR) ; \
1385
	hpc markup --destdir=../$(COVERAGE_HS_DIR) live-test \
1386
		--srcdir=.. $(HPCEXCL) ; \
1387
	hpc report --srcdir=.. live-test $(HPCEXCL)
1388

    
1389
commit-check: distcheck lint apidoc
1390

    
1391
-include ./Makefile.local
1392

    
1393
# vim: set noet :