Statistics
| Branch: | Tag: | Revision:

root / Makefile.am @ 896b2850

History | View | Annotate | Download (40.3 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/Confd \
60
	htools/Ganeti/HTools \
61
	htools/Ganeti/HTools/Program
62

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

    
95
BUILDTIME_DIR_AUTOCREATE = \
96
	scripts \
97
	$(APIDOC_DIR) \
98
	$(APIDOC_PY_DIR) \
99
	$(APIDOC_HS_DIR) \
100
	$(APIDOC_HS_DIR)/Ganeti \
101
	$(APIDOC_HS_DIR)/Ganeti/Confd \
102
	$(APIDOC_HS_DIR)/Ganeti/HTools \
103
	$(APIDOC_HS_DIR)/Ganeti/HTools/Program \
104
	$(COVERAGE_DIR) \
105
	$(COVERAGE_PY_DIR) \
106
	$(COVERAGE_HS_DIR) \
107
	.hpc
108

    
109
BUILDTIME_DIRS = \
110
	$(BUILDTIME_DIR_AUTOCREATE) \
111
	doc/html
112

    
113
DIRCHECK_EXCLUDE = \
114
	$(BUILDTIME_DIRS) \
115
	ganeti-[0-9]*.[0-9]*.[0-9]* \
116
	doc/html/_*
117

    
118
all_dirfiles = $(addsuffix /.dir,$(DIRS) $(BUILDTIME_DIR_AUTOCREATE))
119

    
120
# some helper vars
121
COVERAGE_DIR = doc/coverage
122
COVERAGE_PY_DIR = $(COVERAGE_DIR)/py
123
COVERAGE_HS_DIR = $(COVERAGE_DIR)/hs
124
APIDOC_DIR = doc/api
125
APIDOC_PY_DIR = $(APIDOC_DIR)/py
126
APIDOC_HS_DIR = $(APIDOC_DIR)/hs
127

    
128
MAINTAINERCLEANFILES = \
129
	$(docpng) \
130
	$(maninput) \
131
	doc/install-quick.rst \
132
	doc/news.rst \
133
	doc/upgrade.rst \
134
	vcs-version
135

    
136
maintainer-clean-local:
137
	rm -rf $(BUILDTIME_DIRS)
138

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

    
162
# BUILT_SOURCES should only be used as a dependency on phony targets. Otherwise
163
# it'll cause the target to rebuild every time.
164
BUILT_SOURCES = \
165
  $(built_base_sources) \
166
	$(BUILT_PYTHON_SOURCES) \
167
	$(PYTHON_BOOTSTRAP)
168

    
169
built_base_sources = \
170
	ganeti \
171
	stamp-srclinks \
172
	$(all_dirfiles)
173

    
174
built_python_base_sources = \
175
	lib/_autoconf.py \
176
	lib/_vcsversion.py
177

    
178
BUILT_PYTHON_SOURCES = \
179
	$(built_python_base_sources) \
180
	lib/_generated_rpc.py
181

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

    
186
# these are all built from the underlying %.in sources
187
BUILT_EXAMPLES = \
188
	doc/examples/ganeti-kvm-poweroff.initd \
189
	doc/examples/ganeti.cron \
190
	doc/examples/ganeti.initd \
191
	doc/examples/gnt-config-backup \
192
	doc/examples/hooks/ipsec
193

    
194
nodist_pkgpython_PYTHON = \
195
	$(BUILT_PYTHON_SOURCES)
196

    
197
noinst_PYTHON = \
198
	lib/build/__init__.py \
199
	lib/build/sphinx_ext.py
200

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

    
236
client_PYTHON = \
237
	lib/client/__init__.py \
238
	lib/client/gnt_backup.py \
239
	lib/client/gnt_cluster.py \
240
	lib/client/gnt_debug.py \
241
	lib/client/gnt_group.py \
242
	lib/client/gnt_instance.py \
243
	lib/client/gnt_job.py \
244
	lib/client/gnt_node.py \
245
	lib/client/gnt_os.py
246

    
247
hypervisor_PYTHON = \
248
	lib/hypervisor/__init__.py \
249
	lib/hypervisor/hv_base.py \
250
	lib/hypervisor/hv_chroot.py \
251
	lib/hypervisor/hv_fake.py \
252
	lib/hypervisor/hv_kvm.py \
253
	lib/hypervisor/hv_lxc.py \
254
	lib/hypervisor/hv_xen.py
255

    
256
rapi_PYTHON = \
257
	lib/rapi/__init__.py \
258
	lib/rapi/baserlib.py \
259
	lib/rapi/client.py \
260
	lib/rapi/client_utils.py \
261
	lib/rapi/connector.py \
262
	lib/rapi/rlib2.py \
263
	lib/rapi/testutils.py
264

    
265
http_PYTHON = \
266
	lib/http/__init__.py \
267
	lib/http/auth.py \
268
	lib/http/client.py \
269
	lib/http/server.py
270

    
271
confd_PYTHON = \
272
	lib/confd/__init__.py \
273
	lib/confd/client.py \
274
	lib/confd/querylib.py \
275
	lib/confd/server.py
276

    
277
masterd_PYTHON = \
278
	lib/masterd/__init__.py \
279
	lib/masterd/instance.py
280

    
281
impexpd_PYTHON = \
282
	lib/impexpd/__init__.py
283

    
284
watcher_PYTHON = \
285
	lib/watcher/__init__.py \
286
	lib/watcher/nodemaint.py \
287
	lib/watcher/state.py
288

    
289
server_PYTHON = \
290
	lib/server/__init__.py \
291
	lib/server/confd.py \
292
	lib/server/masterd.py \
293
	lib/server/noded.py \
294
	lib/server/rapi.py
295

    
296
pytools_PYTHON = \
297
	lib/tools/__init__.py \
298
	lib/tools/ensure_dirs.py
299

    
300
utils_PYTHON = \
301
	lib/utils/__init__.py \
302
	lib/utils/algo.py \
303
	lib/utils/filelock.py \
304
	lib/utils/hash.py \
305
	lib/utils/io.py \
306
	lib/utils/log.py \
307
	lib/utils/mlock.py \
308
	lib/utils/nodesetup.py \
309
	lib/utils/process.py \
310
	lib/utils/retry.py \
311
	lib/utils/text.py \
312
	lib/utils/wrapper.py \
313
	lib/utils/x509.py
314

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

    
356
HS_PROGS = htools/htools htools/hconfd
357
HS_BIN_ROLES = hbal hscan hspace hinfo
358

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

    
375
HS_LIB_SRCS = \
376
	htools/Ganeti/HTools/CLI.hs \
377
	htools/Ganeti/HTools/Cluster.hs \
378
	htools/Ganeti/HTools/Compat.hs \
379
	htools/Ganeti/HTools/Container.hs \
380
	htools/Ganeti/HTools/ExtLoader.hs \
381
	htools/Ganeti/HTools/Group.hs \
382
	htools/Ganeti/HTools/IAlloc.hs \
383
	htools/Ganeti/HTools/Instance.hs \
384
	htools/Ganeti/HTools/JSON.hs \
385
	htools/Ganeti/HTools/Loader.hs \
386
	htools/Ganeti/HTools/Luxi.hs \
387
	htools/Ganeti/HTools/Node.hs \
388
	htools/Ganeti/HTools/PeerMap.hs \
389
	htools/Ganeti/HTools/QC.hs \
390
	htools/Ganeti/HTools/QCHelper.hs \
391
	htools/Ganeti/HTools/Rapi.hs \
392
	htools/Ganeti/HTools/Simu.hs \
393
	htools/Ganeti/HTools/Text.hs \
394
	htools/Ganeti/HTools/Types.hs \
395
	htools/Ganeti/HTools/Utils.hs \
396
	htools/Ganeti/HTools/Program.hs \
397
	htools/Ganeti/HTools/Program/Hail.hs \
398
	htools/Ganeti/HTools/Program/Hbal.hs \
399
	htools/Ganeti/HTools/Program/Hinfo.hs \
400
	htools/Ganeti/HTools/Program/Hscan.hs \
401
	htools/Ganeti/HTools/Program/Hspace.hs \
402
	htools/Ganeti/BasicTypes.hs \
403
	htools/Ganeti/Confd.hs \
404
	htools/Ganeti/Confd/Server.hs \
405
	htools/Ganeti/Config.hs \
406
	htools/Ganeti/Daemon.hs \
407
	htools/Ganeti/Hash.hs \
408
	htools/Ganeti/Jobs.hs \
409
	htools/Ganeti/Logging.hs \
410
	htools/Ganeti/Luxi.hs \
411
	htools/Ganeti/Objects.hs \
412
	htools/Ganeti/OpCodes.hs \
413
	htools/Ganeti/Runtime.hs \
414
	htools/Ganeti/THH.hs
415

    
416
HS_BUILT_SRCS = htools/Ganeti/HTools/Version.hs htools/Ganeti/Constants.hs
417
HS_BUILT_SRCS_IN = $(patsubst %,%.in,$(HS_BUILT_SRCS))
418

    
419
$(RUN_IN_TEMPDIR): | $(all_dirfiles)
420

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

    
440
doc/html: doc/html/index.html
441

    
442
doc/install-quick.rst: INSTALL
443
doc/news.rst: NEWS
444
doc/upgrade.rst: UPGRADE
445

    
446
doc/install-quick.rst doc/news.rst doc/upgrade.rst:
447
	set -e; \
448
	{ echo '.. This file is automatically updated at build time from $<.'; \
449
	  echo '.. Do not edit.'; \
450
	  echo; \
451
	  cat $<; \
452
	} > $@
453

    
454
docdot = \
455
	doc/arch-2.0.dot \
456
	doc/design-2.1-lock-acquire.dot \
457
	doc/design-2.1-lock-release.dot
458

    
459
docpng = $(patsubst %.dot,%.png,$(docdot))
460

    
461
# Things to build but not to install (add it to EXTRA_DIST if it should be
462
# distributed)
463
noinst_DATA = \
464
	devel/upload \
465
	doc/html \
466
	$(BUILT_EXAMPLES) \
467
	doc/examples/bash_completion \
468
	$(manhtml)
469

    
470
gnt_scripts = \
471
	scripts/gnt-backup \
472
	scripts/gnt-cluster \
473
	scripts/gnt-debug \
474
	scripts/gnt-group \
475
	scripts/gnt-instance \
476
	scripts/gnt-job \
477
	scripts/gnt-node \
478
	scripts/gnt-os
479

    
480
PYTHON_BOOTSTRAP_SBIN = \
481
	daemons/ganeti-confd \
482
	daemons/ganeti-masterd \
483
	daemons/ganeti-noded \
484
	daemons/ganeti-watcher \
485
	daemons/ganeti-rapi \
486
	$(gnt_scripts)
487

    
488
PYTHON_BOOTSTRAP = \
489
	$(PYTHON_BOOTSTRAP_SBIN) \
490
	tools/ensure-dirs
491

    
492
qa_scripts = \
493
	qa/ganeti-qa.py \
494
	qa/qa_cluster.py \
495
	qa/qa_config.py \
496
	qa/qa_daemon.py \
497
	qa/qa_env.py \
498
	qa/qa_error.py \
499
	qa/qa_group.py \
500
	qa/qa_instance.py \
501
	qa/qa_node.py \
502
	qa/qa_os.py \
503
	qa/qa_rapi.py \
504
	qa/qa_tags.py \
505
	qa/qa_utils.py
506

    
507
bin_SCRIPTS =
508
if WANT_HTOOLS
509
bin_SCRIPTS += $(filter-out htools/hail,$(HS_PROGS))
510
install-exec-hook:
511
	@mkdir_p@ $(DESTDIR)$(iallocatorsdir)
512
# FIXME: this is a hardcoded logic, instead of auto-resolving
513
	$(LN_S) -f ../../../bin/htools \
514
		   $(DESTDIR)$(iallocatorsdir)/hail
515
	for role in $(HS_BIN_ROLES); do \
516
		$(LN_S) -f htools \
517
			   $(DESTDIR)$(bindir)/$$role ; \
518
	done
519
endif
520

    
521
$(HS_ALL_PROGS): %: %.hs $(HS_LIB_SRCS) $(HS_BUILT_SRCS) Makefile
522
	@if [ -z "$(HTOOLS)" ]; then \
523
	  echo "Error: htools compilation disabled at configure time" 1>&2 ;\
524
	  exit 1; \
525
	fi
526
	@BINARY=$(@:htools/%=%); \
527
	if [ "$BINARY" = "test" ] && [ -z "$(GHC_PKG_QUICKCHECK)" ]; then \
528
	  echo "Error: cannot run unittests without the QuickCheck library (see devnotes.rst)" 1>&2; \
529
	  exit 1; \
530
	fi
531
	rm -f $(@:htools/%=%).tix
532
	BINARY=$(@:htools/%=%); $(GHC) --make \
533
	  $(HFLAGS) \
534
	  $(HTOOLS_NOCURL) $(HTOOLS_PARALLEL3) \
535
	  -osuf $$BINARY.o -hisuf $$BINARY.hi \
536
	  $(HEXTRA) $(HEXTRA_INT) $@
537

    
538
# for the htools/test binary, we need to enable profiling/coverage
539
htools/test: HEXTRA_INT=-fhpc -Wwarn -fno-warn-missing-signatures \
540
	-fno-warn-monomorphism-restriction -fno-warn-orphans \
541
	-fno-warn-missing-methods -fno-warn-unused-imports
542

    
543
# we compile the hpc-htools binary with the program coverage
544
htools/hpc-htools: HEXTRA_INT=-fhpc
545

    
546
# test dependency
547
htools/offline-tests.sh: htools/hpc-htools
548

    
549
# rules for building profiling-enabled versions of the haskell
550
# programs: hs-prof does the full two-step build, whereas
551
# hs-prof-quick does only the final rebuild (hs-prof must have been
552
# run before)
553
.PHONY: hs-prof hs-prof-quick
554
hs-prof:
555
	$(MAKE) clean
556
	$(MAKE) $(HS_ALL_PROGS) HEXTRA="-osuf .o"
557
	rm -f $(HS_ALL_PROGS)
558
	$(MAKE) hs-prof-quick
559

    
560
hs-prof-quick:
561
	$(MAKE) $(HS_ALL_PROGS) HEXTRA="-osuf .prof_o -prof -auto-all"
562

    
563
dist_sbin_SCRIPTS = \
564
	tools/ganeti-listrunner
565

    
566
nodist_sbin_SCRIPTS = \
567
	$(PYTHON_BOOTSTRAP_SBIN) \
568
	daemons/ganeti-cleaner
569

    
570
python_scripts = \
571
	tools/burnin \
572
	tools/cfgshell \
573
	tools/cfgupgrade \
574
	tools/cfgupgrade12 \
575
	tools/cluster-merge \
576
	tools/confd-client \
577
	tools/fmtjson \
578
	tools/lvmstrap \
579
	tools/move-instance \
580
	tools/ovfconverter \
581
	tools/setup-ssh \
582
	tools/sanitize-config
583

    
584
dist_tools_SCRIPTS = \
585
	$(python_scripts) \
586
	tools/kvm-console-wrapper \
587
	tools/xm-console-wrapper \
588
	tools/master-ip-setup
589

    
590
pkglib_python_scripts = \
591
	daemons/import-export \
592
	tools/check-cert-expired
593

    
594
nodist_pkglib_python_scripts = \
595
	tools/ensure-dirs
596

    
597
myexeclib_SCRIPTS = \
598
	daemons/daemon-util \
599
	tools/kvm-ifup \
600
	$(pkglib_python_scripts)
601

    
602
nodist_myexeclib_SCRIPTS = \
603
	$(nodist_pkglib_python_scripts)
604

    
605
EXTRA_DIST = \
606
	NEWS \
607
	UPGRADE \
608
	epydoc.conf.in \
609
	pylintrc \
610
	autotools/build-bash-completion \
611
	autotools/build-rpc \
612
	autotools/check-header \
613
	autotools/check-python-code \
614
	autotools/check-imports \
615
	autotools/check-man-dashes \
616
	autotools/check-man-warnings \
617
	autotools/check-news \
618
	autotools/check-tar \
619
	autotools/check-version \
620
	autotools/convert-constants \
621
	autotools/docpp \
622
	autotools/gen-coverage \
623
	autotools/testrunner \
624
	$(RUN_IN_TEMPDIR) \
625
	daemons/daemon-util.in \
626
	daemons/ganeti-cleaner.in \
627
	$(pkglib_python_scripts) \
628
	devel/upload.in \
629
	tools/kvm-ifup.in \
630
	$(docdot) \
631
	$(docpng) \
632
	$(docrst) \
633
	doc/conf.py \
634
	doc/html \
635
	$(BUILT_EXAMPLES:%=%.in) \
636
	doc/examples/ganeti.default \
637
	doc/examples/ganeti.default-debug \
638
	doc/examples/hooks/ethers \
639
	doc/examples/gnt-debug/README \
640
	doc/examples/gnt-debug/delay0.json \
641
	doc/examples/gnt-debug/delay50.json \
642
	test/lockperf.py \
643
	test/testutils.py \
644
	test/mocks.py \
645
	$(dist_TESTS) \
646
	$(TEST_FILES) \
647
	man/footer.rst \
648
	$(manrst) \
649
	$(maninput) \
650
	qa/qa-sample.json \
651
	$(qa_scripts) \
652
	$(HS_LIB_SRCS) $(HS_BUILT_SRCS_IN) \
653
	$(HS_PROG_SRCS) \
654
	htools/lint-hints.hs \
655
	htools/cli-tests-defs.sh \
656
	htools/offline-test.sh
657

    
658
man_MANS = \
659
	man/ganeti.7 \
660
	man/ganeti-cleaner.8 \
661
	man/ganeti-confd.8 \
662
	man/ganeti-listrunner.8 \
663
	man/ganeti-masterd.8 \
664
	man/ganeti-noded.8 \
665
	man/ganeti-os-interface.7 \
666
	man/ganeti-rapi.8 \
667
	man/ganeti-watcher.8 \
668
	man/gnt-backup.8 \
669
	man/gnt-cluster.8 \
670
	man/gnt-debug.8 \
671
	man/gnt-group.8 \
672
	man/gnt-instance.8 \
673
	man/gnt-job.8 \
674
	man/gnt-node.8 \
675
	man/gnt-os.8 \
676
	man/hail.1 \
677
	man/hbal.1 \
678
	man/hinfo.1 \
679
	man/hscan.1 \
680
	man/hspace.1 \
681
	man/htools.1
682

    
683
manrst = $(patsubst %.1,%.rst,$(patsubst %.7,%.rst,$(patsubst %.8,%.rst,$(man_MANS))))
684
manhtml = $(patsubst %.rst,%.html,$(manrst))
685
mangen = $(patsubst %.rst,%.gen,$(manrst))
686
maninput = \
687
	$(patsubst %.1,%.1.in,$(patsubst %.7,%.7.in,$(patsubst %.8,%.8.in,$(man_MANS)))) \
688
	$(patsubst %.html,%.html.in,$(manhtml)) \
689
	man/footer.man man/footer.html $(mangen)
690

    
691
TEST_FILES = \
692
	test/data/bdev-drbd-8.0.txt \
693
	test/data/bdev-drbd-8.3.txt \
694
	test/data/bdev-drbd-disk.txt \
695
	test/data/bdev-drbd-net-ip4.txt \
696
	test/data/bdev-drbd-net-ip6.txt \
697
	test/data/cert1.pem \
698
	test/data/ip-addr-show-dummy0.txt \
699
	test/data/ip-addr-show-lo-ipv4.txt \
700
	test/data/ip-addr-show-lo-ipv6.txt \
701
	test/data/ip-addr-show-lo-oneline-ipv4.txt \
702
	test/data/ip-addr-show-lo-oneline-ipv6.txt \
703
	test/data/ip-addr-show-lo-oneline.txt \
704
	test/data/ip-addr-show-lo.txt \
705
	test/data/proc_drbd8.txt \
706
	test/data/proc_drbd80-emptyline.txt \
707
	test/data/proc_drbd83.txt \
708
	test/data/proc_drbd83_sync.txt \
709
	test/data/proc_drbd83_sync_krnl2.6.39.txt \
710
	test/data/kvm_1.0_help.txt \
711
	test/data/kvm_0.15.90_help.txt \
712
	test/data/kvm_0.12.5_help.txt \
713
	test/data/kvm_0.9.1_help.txt \
714
	test/data/sys_drbd_usermode_helper.txt \
715
	test/data/htools/hail-alloc-drbd.json \
716
	test/data/htools/hail-change-group.json \
717
	test/data/htools/hail-node-evac.json \
718
	test/data/htools/hail-reloc-drbd.json \
719
	test/data/htools/common-suffix.data \
720
	test/data/htools/invalid-node.data \
721
	test/data/htools/missing-resources.data \
722
	test/data/htools/rapi/groups.json \
723
	test/data/htools/rapi/info.json \
724
	test/data/htools/rapi/instances.json \
725
	test/data/htools/rapi/nodes.json \
726
	test/data/ovfdata/compr_disk.vmdk.gz \
727
	test/data/ovfdata/config.ini \
728
	test/data/ovfdata/corrupted_resources.ovf \
729
	test/data/ovfdata/empty.ini \
730
	test/data/ovfdata/empty.ovf \
731
	test/data/ovfdata/ganeti.mf \
732
	test/data/ovfdata/ganeti.ovf \
733
	test/data/ovfdata/gzip_disk.ovf \
734
	test/data/ovfdata/new_disk.vmdk \
735
	test/data/ovfdata/no_disk.ini \
736
	test/data/ovfdata/no_disk_in_ref.ovf \
737
	test/data/ovfdata/no_os.ini \
738
	test/data/ovfdata/no_ovf.ova \
739
	test/data/ovfdata/ova.ova \
740
	test/data/ovfdata/second_disk.vmdk \
741
	test/data/ovfdata/rawdisk.raw \
742
	test/data/ovfdata/unsafe_path.ini \
743
	test/data/ovfdata/virtualbox.ovf \
744
	test/data/ovfdata/wrong_extension.ovd \
745
	test/data/ovfdata/wrong_config.ini \
746
	test/data/ovfdata/wrong_manifest.mf \
747
	test/data/ovfdata/wrong_manifest.ovf \
748
	test/data/ovfdata/wrong_ova.ova \
749
	test/data/ovfdata/wrong_xml.ovf \
750
	test/data/ovfdata/other/rawdisk.raw \
751
	test/data/vgreduce-removemissing-2.02.02.txt \
752
	test/data/vgreduce-removemissing-2.02.66-fail.txt \
753
	test/data/vgreduce-removemissing-2.02.66-ok.txt \
754
	test/data/vgs-missing-pvs-2.02.02.txt \
755
	test/data/vgs-missing-pvs-2.02.66.txt \
756
	test/import-export_unittest-helper
757

    
758
python_tests = \
759
	test/ganeti.asyncnotifier_unittest.py \
760
	test/ganeti.backend_unittest.py \
761
	test/ganeti.bdev_unittest.py \
762
	test/ganeti.cli_unittest.py \
763
	test/ganeti.client.gnt_cluster_unittest.py \
764
	test/ganeti.client.gnt_instance_unittest.py \
765
	test/ganeti.daemon_unittest.py \
766
	test/ganeti.cmdlib_unittest.py \
767
	test/ganeti.compat_unittest.py \
768
	test/ganeti.confd.client_unittest.py \
769
	test/ganeti.config_unittest.py \
770
	test/ganeti.constants_unittest.py \
771
	test/ganeti.errors_unittest.py \
772
	test/ganeti.hooks_unittest.py \
773
	test/ganeti.ht_unittest.py \
774
	test/ganeti.http_unittest.py \
775
	test/ganeti.hypervisor_unittest.py \
776
	test/ganeti.hypervisor.hv_chroot_unittest.py \
777
	test/ganeti.hypervisor.hv_fake_unittest.py \
778
	test/ganeti.hypervisor.hv_kvm_unittest.py \
779
	test/ganeti.hypervisor.hv_lxc_unittest.py \
780
	test/ganeti.hypervisor.hv_xen_unittest.py \
781
	test/ganeti.impexpd_unittest.py \
782
	test/ganeti.jqueue_unittest.py \
783
	test/ganeti.locking_unittest.py \
784
	test/ganeti.luxi_unittest.py \
785
	test/ganeti.masterd.instance_unittest.py \
786
	test/ganeti.mcpu_unittest.py \
787
	test/ganeti.netutils_unittest.py \
788
	test/ganeti.objects_unittest.py \
789
	test/ganeti.opcodes_unittest.py \
790
	test/ganeti.ovf_unittest.py \
791
	test/ganeti.qlang_unittest.py \
792
	test/ganeti.query_unittest.py \
793
	test/ganeti.rapi.baserlib_unittest.py \
794
	test/ganeti.rapi.client_unittest.py \
795
	test/ganeti.rapi.resources_unittest.py \
796
	test/ganeti.rapi.rlib2_unittest.py \
797
	test/ganeti.rapi.testutils_unittest.py \
798
	test/ganeti.rpc_unittest.py \
799
	test/ganeti.runtime_unittest.py \
800
	test/ganeti.serializer_unittest.py \
801
	test/ganeti.ssh_unittest.py \
802
	test/ganeti.storage_unittest.py \
803
	test/ganeti.tools.ensure_dirs_unittest.py \
804
	test/ganeti.uidpool_unittest.py \
805
	test/ganeti.utils.algo_unittest.py \
806
	test/ganeti.utils.filelock_unittest.py \
807
	test/ganeti.utils.hash_unittest.py \
808
	test/ganeti.utils.io_unittest.py \
809
	test/ganeti.utils.log_unittest.py \
810
	test/ganeti.utils.mlock_unittest.py \
811
	test/ganeti.utils.nodesetup_unittest.py \
812
	test/ganeti.utils.process_unittest.py \
813
	test/ganeti.utils.retry_unittest.py \
814
	test/ganeti.utils.text_unittest.py \
815
	test/ganeti.utils.wrapper_unittest.py \
816
	test/ganeti.utils.x509_unittest.py \
817
	test/ganeti.utils_unittest.py \
818
	test/ganeti.workerpool_unittest.py \
819
	test/cfgupgrade_unittest.py \
820
	test/docs_unittest.py \
821
	test/pycurl_reset_unittest.py \
822
	test/tempfile_fork_unittest.py
823
if HAS_FAKEROOT
824
python_tests += test/ganeti.utils.io_unittest-runasroot.py
825
endif
826

    
827
haskell_tests = htools/test
828

    
829
dist_TESTS = \
830
	test/check-cert-expired_unittest.bash \
831
	test/daemon-util_unittest.bash \
832
	test/ganeti-cleaner_unittest.bash \
833
	test/import-export_unittest.bash \
834
	$(python_tests)
835

    
836
nodist_TESTS =
837
check_SCRIPTS =
838

    
839
if WANT_HTOOLSTESTS
840
nodist_TESTS += $(haskell_tests)
841
dist_TESTS += htools/offline-test.sh
842
check_SCRIPTS += htools/hpc-htools
843
endif
844

    
845
TESTS = $(dist_TESTS) $(nodist_TESTS)
846

    
847
# Environment for all tests
848
PLAIN_TESTS_ENVIRONMENT = \
849
	PYTHONPATH=. TOP_SRCDIR=$(abs_top_srcdir) PYTHON=$(PYTHON) \
850
	FAKEROOT=$(FAKEROOT_PATH) $(RUN_IN_TEMPDIR)
851

    
852
# Environment for tests run by automake
853
TESTS_ENVIRONMENT = \
854
	$(PLAIN_TESTS_ENVIRONMENT) $(abs_top_srcdir)/autotools/testrunner
855

    
856
all_python_code = \
857
	$(dist_sbin_SCRIPTS) \
858
	$(python_scripts) \
859
	$(pkglib_python_scripts) \
860
	$(nodist_pkglib_python_scripts) \
861
	$(python_tests) \
862
	$(pkgpython_PYTHON) \
863
	$(client_PYTHON) \
864
	$(hypervisor_PYTHON) \
865
	$(rapi_PYTHON) \
866
	$(server_PYTHON) \
867
	$(pytools_PYTHON) \
868
	$(http_PYTHON) \
869
	$(confd_PYTHON) \
870
	$(masterd_PYTHON) \
871
	$(impexpd_PYTHON) \
872
	$(utils_PYTHON) \
873
	$(watcher_PYTHON) \
874
	$(noinst_PYTHON) \
875
	$(qa_scripts)
876

    
877
srclink_files = \
878
	man/footer.rst \
879
	test/check-cert-expired_unittest.bash \
880
	test/daemon-util_unittest.bash \
881
	test/ganeti-cleaner_unittest.bash \
882
	test/import-export_unittest.bash \
883
	htools/offline-test.sh \
884
	htools/cli-tests-defs.sh \
885
	$(all_python_code) \
886
	$(HS_LIB_SRCS) $(HS_PROG_SRCS)
887

    
888
check_python_code = \
889
	$(BUILD_BASH_COMPLETION) \
890
	$(CHECK_IMPORTS) \
891
	$(CHECK_HEADER) \
892
	$(DOCPP) \
893
	$(all_python_code)
894

    
895
lint_python_code = \
896
	ganeti \
897
	ganeti/http/server.py \
898
	$(dist_sbin_SCRIPTS) \
899
	$(python_scripts) \
900
	$(pkglib_python_scripts) \
901
	$(BUILD_BASH_COMPLETION) \
902
	$(CHECK_IMPORTS) \
903
	$(CHECK_HEADER) \
904
	$(DOCPP) \
905
	$(PYTHON_BOOTSTRAP)
906

    
907
standalone_python_modules = \
908
	lib/rapi/client.py \
909
	tools/ganeti-listrunner
910

    
911
pep8_python_code = \
912
	ganeti \
913
	ganeti/http/server.py \
914
	$(dist_sbin_SCRIPTS) \
915
	$(python_scripts) \
916
	$(pkglib_python_scripts) \
917
	$(BUILD_BASH_COMPLETION) \
918
	$(CHECK_HEADER) \
919
	$(DOCPP) \
920
	$(PYTHON_BOOTSTRAP) \
921
	qa
922

    
923
test/daemon-util_unittest.bash: daemons/daemon-util
924

    
925
test/ganeti-cleaner_unittest.bash: daemons/ganeti-cleaner
926

    
927
tools/kvm-ifup: tools/kvm-ifup.in $(REPLACE_VARS_SED)
928
	sed -f $(REPLACE_VARS_SED) < $< > $@
929
	chmod +x $@
930

    
931
devel/upload: devel/upload.in $(REPLACE_VARS_SED)
932
	sed -f $(REPLACE_VARS_SED) < $< > $@
933
	chmod u+x $@
934

    
935
daemons/%: daemons/%.in $(REPLACE_VARS_SED)
936
	sed -f $(REPLACE_VARS_SED) < $< > $@
937
	chmod +x $@
938

    
939
doc/examples/%: doc/examples/%.in $(REPLACE_VARS_SED)
940
	sed -f $(REPLACE_VARS_SED) < $< > $@
941

    
942
doc/examples/hooks/%: doc/examples/hooks/%.in $(REPLACE_VARS_SED)
943
	sed -f $(REPLACE_VARS_SED) < $< > $@
944

    
945
doc/examples/bash_completion: $(BUILD_BASH_COMPLETION) $(RUN_IN_TEMPDIR) \
946
	lib/cli.py $(gnt_scripts) $(client_PYTHON) tools/burnin
947
	PYTHONPATH=. $(RUN_IN_TEMPDIR) $(CURDIR)/$(BUILD_BASH_COMPLETION) > $@
948

    
949
doc/%.png: doc/%.dot
950
	@test -n "$(DOT)" || { echo 'dot' not found during configure; exit 1; }
951
	$(DOT) -Tpng -o $@ $<
952

    
953
man/footer.man: man/footer.rst
954
	@test -n "$(PANDOC)" || \
955
	  { echo 'pandoc' not found during configure; exit 1; }
956
	$(PANDOC) -f rst -t man -o $@ $<
957

    
958
man/footer.html: man/footer.rst
959
	@test -n "$(PANDOC)" || \
960
	  { echo 'pandoc' not found during configure; exit 1; }
961
	$(PANDOC) -f rst -t html -o $@ $<
962

    
963
man/%.gen: man/%.rst lib/query.py lib/build/sphinx_ext.py
964
	PYTHONPATH=. $(RUN_IN_TEMPDIR) $(CURDIR)/$(DOCPP) < $< > $@
965

    
966
man/%.7.in man/%.8.in man/%.1.in: man/%.gen man/footer.man
967
	@test -n "$(PANDOC)" || \
968
	  { echo 'pandoc' not found during configure; exit 1; }
969
	set -o pipefail ; \
970
	trap 'echo auto-removing $@; rm $@' EXIT; \
971
	$(PANDOC) -s -f rst -t man -A man/footer.man $< | \
972
	  sed -e 's/\\@/@/g' > $@; \
973
	if test -n "$(MAN_HAS_WARNINGS)"; then $(CHECK_MAN_WARNINGS) $@; fi; \
974
	$(CHECK_MAN_DASHES) $@; \
975
	trap - EXIT
976

    
977

    
978
man/%.html.in: man/%.gen man/footer.html
979
	@test -n "$(PANDOC)" || \
980
	  { echo 'pandoc' not found during configure; exit 1; }
981
	set -o pipefail ; \
982
	$(PANDOC) -s -f rst -t html -A man/footer.html $< | \
983
	  sed -e 's/\\@/@/g' > $@
984

    
985
man/%.1: man/%.1.in $(REPLACE_VARS_SED)
986
	sed -f $(REPLACE_VARS_SED) < $< > $@
987

    
988
man/%.7: man/%.7.in $(REPLACE_VARS_SED)
989
	sed -f $(REPLACE_VARS_SED) < $< > $@
990

    
991
man/%.8: man/%.8.in $(REPLACE_VARS_SED)
992
	sed -f $(REPLACE_VARS_SED) < $< > $@
993

    
994
man/%.html: man/%.html.in $(REPLACE_VARS_SED)
995
	sed -f $(REPLACE_VARS_SED) < $< > $@
996

    
997
epydoc.conf: epydoc.conf.in Makefile
998
	sed -e 's#@MODULES@#$(strip $(lint_python_code))#g' < $< > $@
999

    
1000
vcs-version:
1001
	if test -d .git; then \
1002
	  git describe > $@; \
1003
	elif test ! -f $@ ; then \
1004
	  echo "Cannot auto-generate $@ file"; exit 1; \
1005
	fi
1006

    
1007
.PHONY: regen-vcs-version
1008
regen-vcs-version:
1009
	set -e; \
1010
	cd $(srcdir); \
1011
	if test -d .git; then \
1012
	  rm -f vcs-version; \
1013
	  $(MAKE) vcs-version; \
1014
	fi
1015

    
1016
htools/Ganeti/HTools/Version.hs: htools/Ganeti/HTools/Version.hs.in vcs-version
1017
	set -e; \
1018
	VCSVER=`cat $(abs_top_srcdir)/vcs-version`; \
1019
	sed -e "s/%ver%/$$VCSVER/" < $< > $@
1020

    
1021
htools/Ganeti/Constants.hs: htools/Ganeti/Constants.hs.in \
1022
	lib/constants.py lib/_autoconf.py $(CONVERT_CONSTANTS) \
1023
	| lib/_vcsversion.py
1024
	set -e; \
1025
	{ cat $< ; PYTHONPATH=. $(CONVERT_CONSTANTS); } > $@
1026

    
1027
lib/_autoconf.py: Makefile | lib/.dir
1028
	set -e; \
1029
	{ echo '# This file is automatically generated, do not edit!'; \
1030
	  echo '#'; \
1031
	  echo ''; \
1032
	  echo '"""Build-time configuration for Ganeti.'; \
1033
	  echo '';\
1034
	  echo 'This file is autogenerated by the build process.'; \
1035
	  echo 'For any changes you need to re-run ./configure (and'; \
1036
	  echo 'not edit by hand).'; \
1037
	  echo ''; \
1038
	  echo '"""'; \
1039
	  echo ''; \
1040
	  echo '# pylint: disable=C0301,C0324'; \
1041
	  echo '# because this is autogenerated, we do not want'; \
1042
	  echo '# style warnings' ; \
1043
	  echo ''; \
1044
	  echo "PACKAGE_VERSION = '$(PACKAGE_VERSION)'"; \
1045
	  echo "VERSION_MAJOR = '$(VERSION_MAJOR)'"; \
1046
	  echo "VERSION_MINOR = '$(VERSION_MINOR)'"; \
1047
	  echo "VERSION_REVISION = '$(VERSION_REVISION)'"; \
1048
	  echo "VERSION_SUFFIX = '$(VERSION_SUFFIX)'"; \
1049
	  echo "VERSION_FULL = '$(VERSION_FULL)'"; \
1050
	  echo "LOCALSTATEDIR = '$(localstatedir)'"; \
1051
	  echo "SYSCONFDIR = '$(sysconfdir)'"; \
1052
	  echo "SSH_CONFIG_DIR = '$(SSH_CONFIG_DIR)'"; \
1053
	  echo "EXPORT_DIR = '$(EXPORT_DIR)'"; \
1054
	  echo "OS_SEARCH_PATH = [$(OS_SEARCH_PATH)]"; \
1055
	  echo "XEN_BOOTLOADER = '$(XEN_BOOTLOADER)'"; \
1056
	  echo "XEN_KERNEL = '$(XEN_KERNEL)'"; \
1057
	  echo "XEN_INITRD = '$(XEN_INITRD)'"; \
1058
	  echo "FILE_STORAGE_DIR = '$(FILE_STORAGE_DIR)'"; \
1059
	  echo "ENABLE_FILE_STORAGE = $(ENABLE_FILE_STORAGE)"; \
1060
	  echo "SHARED_FILE_STORAGE_DIR = '$(SHARED_FILE_STORAGE_DIR)'"; \
1061
	  echo "ENABLE_SHARED_FILE_STORAGE = $(ENABLE_SHARED_FILE_STORAGE)"; \
1062
	  echo "IALLOCATOR_SEARCH_PATH = [$(IALLOCATOR_SEARCH_PATH)]"; \
1063
	  echo "KVM_PATH = '$(KVM_PATH)'"; \
1064
	  echo "IP_PATH = '$(IP_PATH)'"; \
1065
	  echo "SOCAT_PATH = '$(SOCAT)'"; \
1066
	  echo "SOCAT_USE_ESCAPE = $(SOCAT_USE_ESCAPE)"; \
1067
	  echo "SOCAT_USE_COMPRESS = $(SOCAT_USE_COMPRESS)"; \
1068
	  echo "LVM_STRIPECOUNT = $(LVM_STRIPECOUNT)"; \
1069
	  echo "TOOLSDIR = '$(toolsdir)'"; \
1070
	  echo "GNT_SCRIPTS = [$(foreach i,$(notdir $(gnt_scripts)),'$(i)',)]"; \
1071
	  echo "PKGLIBDIR = '$(pkglibdir)'"; \
1072
	  echo "DRBD_BARRIERS = '$(DRBD_BARRIERS)'"; \
1073
	  echo "DRBD_NO_META_FLUSH = $(DRBD_NO_META_FLUSH)"; \
1074
	  echo "SYSLOG_USAGE = '$(SYSLOG_USAGE)'"; \
1075
	  echo "DAEMONS_GROUP = '$(DAEMONS_GROUP)'"; \
1076
	  echo "ADMIN_GROUP = '$(ADMIN_GROUP)'"; \
1077
	  echo "MASTERD_USER = '$(MASTERD_USER)'"; \
1078
	  echo "MASTERD_GROUP = '$(MASTERD_GROUP)'"; \
1079
	  echo "RAPI_USER = '$(RAPI_USER)'"; \
1080
	  echo "RAPI_GROUP = '$(RAPI_GROUP)'"; \
1081
	  echo "CONFD_USER = '$(CONFD_USER)'"; \
1082
	  echo "CONFD_GROUP = '$(CONFD_GROUP)'"; \
1083
	  echo "NODED_USER = '$(NODED_USER)'"; \
1084
	  echo "NODED_GROUP = '$(NODED_GROUP)'"; \
1085
	  echo "DISK_SEPARATOR = '$(DISK_SEPARATOR)'"; \
1086
	  echo "QEMUIMG_PATH = '$(QEMUIMG_PATH)'"; \
1087
	  if [ "$(HTOOLS)" ]; then \
1088
	    echo "HTOOLS = True"; \
1089
	  else \
1090
	    echo "HTOOLS = False"; \
1091
	  fi; \
1092
	  echo "ENABLE_CONFD = $(ENABLE_CONFD)"; \
1093
	} > $@
1094

    
1095
lib/_vcsversion.py: Makefile vcs-version | lib/.dir
1096
	set -e; \
1097
	VCSVER=`cat $(abs_top_srcdir)/vcs-version`; \
1098
	{ echo '# This file is automatically generated, do not edit!'; \
1099
	  echo '#'; \
1100
	  echo ''; \
1101
	  echo '"""Build-time VCS version number for Ganeti.'; \
1102
	  echo '';\
1103
	  echo 'This file is autogenerated by the build process.'; \
1104
	  echo 'For any changes you need to re-run ./configure (and'; \
1105
	  echo 'not edit by hand).'; \
1106
	  echo ''; \
1107
	  echo '"""'; \
1108
	  echo ''; \
1109
	  echo '# pylint: disable=C0301,C0324'; \
1110
	  echo '# because this is autogenerated, we do not want'; \
1111
	  echo '# style warnings' ; \
1112
	  echo ''; \
1113
	  echo "VCS_VERSION = '$$VCSVER'"; \
1114
	} > $@
1115

    
1116
lib/_generated_rpc.py: lib/rpc_defs.py $(BUILD_RPC)
1117
	PYTHONPATH=. $(RUN_IN_TEMPDIR) $(CURDIR)/$(BUILD_RPC) lib/rpc_defs.py > $@
1118

    
1119
$(REPLACE_VARS_SED): Makefile
1120
	set -e; \
1121
	{ echo 's#@PREFIX@#$(prefix)#g'; \
1122
	  echo 's#@SYSCONFDIR@#$(sysconfdir)#g'; \
1123
	  echo 's#@LOCALSTATEDIR@#$(localstatedir)#g'; \
1124
	  echo 's#@BINDIR@#$(bindir)#g'; \
1125
	  echo 's#@SBINDIR@#$(sbindir)#g'; \
1126
	  echo 's#@GANETI_VERSION@#$(PACKAGE_VERSION)#g'; \
1127
	  echo 's#@CUSTOM_XEN_BOOTLOADER@#$(XEN_BOOTLOADER)#g'; \
1128
	  echo 's#@CUSTOM_XEN_KERNEL@#$(XEN_KERNEL)#g'; \
1129
	  echo 's#@CUSTOM_XEN_INITRD@#$(XEN_INITRD)#g'; \
1130
	  echo 's#@CUSTOM_IALLOCATOR_SEARCH_PATH@#$(IALLOCATOR_SEARCH_PATH)#g'; \
1131
	  echo 's#@CUSTOM_EXPORT_DIR@#$(EXPORT_DIR)#g'; \
1132
	  echo 's#@RPL_FILE_STORAGE_DIR@#$(FILE_STORAGE_DIR)#g'; \
1133
	  echo 's#@RPL_SSH_INITD_SCRIPT@#$(SSH_INITD_SCRIPT)#g'; \
1134
	  echo 's#@PKGLIBDIR@#$(pkglibdir)#g'; \
1135
	  echo 's#@GNTMASTERUSER@#$(MASTERD_USER)#g'; \
1136
	  echo 's#@GNTRAPIUSER@#$(RAPI_USER)#g'; \
1137
	  echo 's#@GNTCONFDUSER@#$(CONFD_USER)#g'; \
1138
	  echo 's#@GNTNODEDUSER@#$(NODED_USER)#g'; \
1139
	  echo 's#@GNTRAPIGROUP@#$(RAPI_GROUP)#g'; \
1140
	  echo 's#@GNTADMINGROUP@#$(ADMIN_GROUP)#g'; \
1141
	  echo 's#@GNTCONFDGROUP@#$(CONFD_GROUP)#g'; \
1142
	  echo 's#@GNTMASTERDGROUP@#$(MASTERD_GROUP)#g'; \
1143
	  echo 's#@GNTDAEMONSGROUP@#$(DAEMONS_GROUP)#g'; \
1144
	  echo 's#@CUSTOM_ENABLE_CONFD@#$(ENABLE_CONFD)#g'; \
1145
	} > $@
1146

    
1147
# Using deferred evaluation
1148
daemons/ganeti-%: MODULE = ganeti.server.$(patsubst ganeti-%,%,$(notdir $@))
1149
daemons/ganeti-watcher: MODULE = ganeti.watcher
1150
scripts/%: MODULE = ganeti.client.$(subst -,_,$(notdir $@))
1151
tools/ensure-dirs: MODULE = ganeti.tools.ensure_dirs
1152

    
1153
$(PYTHON_BOOTSTRAP): Makefile | $(all_dirfiles)
1154
	test -n "$(MODULE)" || { echo Missing module; exit 1; }
1155
	set -e; \
1156
	{ echo '#!/usr/bin/python'; \
1157
	  echo '# This file is automatically generated, do not edit!'; \
1158
	  echo "# Edit $(MODULE) instead."; \
1159
	  echo; \
1160
	  echo '"""Bootstrap script for L{$(MODULE)}"""'; \
1161
	  echo; \
1162
	  echo '# pylint: disable=C0103'; \
1163
	  echo '# C0103: Invalid name'; \
1164
	  echo; \
1165
	  echo 'import sys'; \
1166
	  echo 'import $(MODULE) as main'; \
1167
	  echo; \
1168
	  echo '# Temporarily alias commands until bash completion'; \
1169
	  echo '# generator is changed'; \
1170
	  echo 'if hasattr(main, "commands"):'; \
1171
	  echo '  commands = main.commands # pylint: disable=E1101'; \
1172
	  echo 'if hasattr(main, "aliases"):'; \
1173
	  echo '  aliases = main.aliases # pylint: disable=E1101'; \
1174
	  echo; \
1175
	  echo 'if __name__ == "__main__":'; \
1176
	  echo '  sys.exit(main.Main())'; \
1177
	} > $@
1178
	chmod u+x $@
1179

    
1180
# We need to create symlinks because "make distcheck" will not install Python
1181
# files when building.
1182
stamp-srclinks: Makefile | $(all_dirfiles)
1183
	set -e; \
1184
	for i in $(srclink_files); do \
1185
		if test ! -f $$i -a -f $(abs_top_srcdir)/$$i; then \
1186
			$(LN_S) $(abs_top_srcdir)/$$i $$i; \
1187
		fi; \
1188
	done
1189
	touch $@
1190

    
1191
.PHONY: ganeti
1192
ganeti:
1193
	cd $(top_builddir) && test -h "$@" || { rm -f $@ && $(LN_S) lib $@; }
1194

    
1195
.PHONY: check-dirs
1196
check-dirs: $(BUILT_SOURCES)
1197
	@set -e; \
1198
	find . -type d \( \( -name . \) -o \( \
1199
		-name .git -o \
1200
		-name autom4te.cache \
1201
		\) -prune -o -print \) | { \
1202
		error=; \
1203
		while read dir; do \
1204
			case "$$dir" in \
1205
				$(strip $(patsubst %,(./%) ;;,$(DIRCHECK_EXCLUDE) $(DIRS))) \
1206
				*) error=1; echo "Directory $$dir not listed in Makefile" >&2 ;; \
1207
			esac; \
1208
		done; \
1209
		for dir in $(DIRS); do \
1210
			if ! test -d "$$dir"; then \
1211
				echo "Directory $$dir listed in DIRS does not exist" >&2; \
1212
				error=1; \
1213
			fi \
1214
		done; \
1215
		if test -n "$$error"; then exit 1; else exit 0; fi; \
1216
	}
1217

    
1218
.PHONY: check-local
1219
check-local: check-dirs $(BUILT_SOURCES)
1220
	$(CHECK_PYTHON_CODE) $(check_python_code)
1221
	PYTHONPATH=. $(CHECK_HEADER) $(check_python_code)
1222
	$(CHECK_VERSION) $(VERSION) $(top_srcdir)/NEWS
1223
	$(CHECK_NEWS) < $(top_srcdir)/NEWS
1224
	PYTHONPATH=. $(RUN_IN_TEMPDIR) $(CURDIR)/$(CHECK_IMPORTS) . $(standalone_python_modules)
1225
	expver=$(VERSION_MAJOR).$(VERSION_MINOR); \
1226
	if test "`head -n 1 $(top_srcdir)/README`" != "Ganeti $$expver"; then \
1227
		echo "Incorrect version in README, expected $$expver"; \
1228
		exit 1; \
1229
	fi; \
1230
	for file in doc/iallocator.rst doc/hooks.rst; do \
1231
		if test "`sed -ne '4 p' $(top_srcdir)/$$file`" != \
1232
			"Documents Ganeti version $$expver"; then \
1233
			echo "Incorrect version in $$file, expected $$expver"; \
1234
			exit 1; \
1235
		fi; \
1236
	done
1237

    
1238
.PHONY: hs-check
1239
hs-check: htools/test htools/hpc-htools
1240
	@rm -f test.tix
1241
	./htools/test
1242
	HBINARY="./htools/hpc-htools" ./htools/offline-test.sh
1243

    
1244
# E111: indentation is not a multiple of four
1245
# E261: at least two spaces before inline comment
1246
# E501: line too long (80 characters)
1247
PEP8_IGNORE = E111,E261,E501
1248

    
1249
# For excluding pep8 expects filenames only, not whole paths
1250
PEP8_EXCLUDE = $(subst $(space),$(comma),$(strip $(notdir $(BUILT_PYTHON_SOURCES))))
1251

    
1252
.PHONY: lint
1253
lint: $(BUILT_SOURCES)
1254
	@test -n "$(PYLINT)" || { echo 'pylint' not found during configure; exit 1; }
1255
	if test -z "$(PEP8)"; then \
1256
		echo '"pep8" not found during configure' >&2; \
1257
	else \
1258
		$(PEP8) --repeat --ignore='$(PEP8_IGNORE)' --exclude='$(PEP8_EXCLUDE)' \
1259
			$(pep8_python_code); \
1260
	fi
1261
	$(PYLINT) $(LINT_OPTS) $(lint_python_code)
1262
	cd $(top_srcdir)/qa && \
1263
	  PYTHONPATH=$(abs_top_srcdir) $(PYLINT) $(LINT_OPTS) \
1264
	  --rcfile  ../pylintrc $(patsubst qa/%.py,%,$(qa_scripts))
1265

    
1266
.PHONY: hlint
1267
hlint: $(HS_BUILT_SRCS) htools/lint-hints.hs
1268
	if tty -s; then C="-c"; else C=""; fi; \
1269
	hlint --report=doc/hs-lint.html --cross $$C \
1270
	  --ignore "Use first" \
1271
	  --ignore "Use comparing" \
1272
	  --ignore "Use on" \
1273
	  --ignore "Use Control.Exception.catch" \
1274
	  --ignore "Reduce duplication" \
1275
	  --hint htools/lint-hints \
1276
	  $(filter-out htools/Ganeti/THH.hs,$(HS_LIB_SRCS))
1277

    
1278
# a dist hook rule for updating the vcs-version file; this is
1279
# hardcoded due to where it needs to build the file...
1280
dist-hook:
1281
	$(MAKE) regen-vcs-version && \
1282
	rm -f $(top_distdir)/vcs-version && \
1283
	cp -p $(srcdir)/vcs-version $(top_distdir)
1284

    
1285
# a distcheck hook rule for catching revision control directories
1286
distcheck-hook:
1287
	if find $(top_distdir) -name .svn -or -name .git | grep .; then \
1288
		echo "Found revision control files in final archive." 1>&2; \
1289
		exit 1; \
1290
	fi
1291
	if find $(top_distdir) -name '*.py[co]' | grep .; then \
1292
		echo "Found Python byte code in final archive." 1>&2; \
1293
		exit 1; \
1294
	fi
1295
	if find $(top_distdir) -name '*~' | grep .; then \
1296
		echo "Found backup files in final archive." 1>&2; \
1297
		exit 1; \
1298
	fi
1299
# Empty files or directories should not be distributed. They can cause
1300
# unnecessary warnings for packagers. Directories used by automake during
1301
# distcheck must be excluded.
1302
	if find $(top_distdir) -empty -and -not \( \
1303
			-path $(top_distdir)/_build -or \
1304
			-path $(top_distdir)/_inst \) | grep .; then \
1305
		echo "Found empty files or directories in final archive." 1>&2; \
1306
		exit 1; \
1307
	fi
1308
	if test -n "$(BUILD_RELEASE)" && \
1309
	   grep -n -H -E '^\*.*unreleased' $(top_distdir)/NEWS; then \
1310
		echo "Found unreleased version in NEWS." >&2; \
1311
		exit 1; \
1312
	fi
1313

    
1314
# When building a release, stricter checks should be used
1315
distcheck-release dist-release: export BUILD_RELEASE = 1
1316
distcheck-release: distcheck
1317

    
1318
dist-release: dist
1319
	set -e; \
1320
	for i in $(DIST_ARCHIVES); do \
1321
		echo -n "Checking $$i ... "; \
1322
		autotools/check-tar < $$i; \
1323
		echo OK; \
1324
	done
1325

    
1326
install-exec-local:
1327
	@mkdir_p@ "$(DESTDIR)${localstatedir}/lib/ganeti" \
1328
	  "$(DESTDIR)${localstatedir}/log/ganeti" \
1329
	  "$(DESTDIR)${localstatedir}/run/ganeti"
1330

    
1331
# To avoid conflicts between directory names and other targets, a file inside
1332
# the directory is used to ensure its existence.
1333
%.dir:
1334
	@mkdir_p@ $* && touch $@
1335

    
1336
.PHONY: apidoc
1337
if WANT_HTOOLSAPIDOC
1338
apidoc: py-apidoc hs-apidoc
1339
else
1340
apidoc: py-apidoc
1341
endif
1342

    
1343
.PHONY: py-apidoc
1344
py-apidoc: epydoc.conf $(RUN_IN_TEMPDIR) $(BUILT_SOURCES)
1345
	$(RUN_IN_TEMPDIR) epydoc -v \
1346
		--conf $(CURDIR)/epydoc.conf \
1347
		--output $(CURDIR)/$(APIDOC_PY_DIR)
1348

    
1349
.PHONY: hs-apidoc
1350
hs-apidoc: $(HS_BUILT_SRCS)
1351
	@test -n "$(HSCOLOUR)" || \
1352
	    { echo 'HsColour' not found during configure; exit 1; }
1353
	@test -n "$(HADDOCK)" || \
1354
	    { echo 'haddock' not found during configure; exit 1; }
1355
	rm -rf $(APIDOC_HS_DIR)/*
1356
	@mkdir_p@ $(APIDOC_HS_DIR)/Ganeti/HTools/Program
1357
	@mkdir_p@ $(APIDOC_HS_DIR)/Ganeti/Confd
1358
	$(HSCOLOUR) -print-css > $(APIDOC_HS_DIR)/Ganeti/hscolour.css
1359
	$(LN_S) ../hscolour.css $(APIDOC_HS_DIR)/Ganeti/HTools/hscolour.css
1360
	$(LN_S) ../hscolour.css $(APIDOC_HS_DIR)/Ganeti/Confd/hscolour.css
1361
	set -e ; \
1362
	cd htools; \
1363
	if [ "$(HTOOLS_NOCURL)" ]; \
1364
	then OPTGHC="--optghc=$(HTOOLS_NOCURL)"; \
1365
	else OPTGHC=""; \
1366
	fi; \
1367
	if [ "$(HTOOLS_PARALLEL3)" ]; \
1368
	then OPTGHC="$$OPTGHC --optghc=$(HTOOLS_PARALLEL3)"; \
1369
	fi; \
1370
	RELSRCS="$(HS_LIB_SRCS:htools/%=%)  $(HS_BUILT_SRCS:htools/%=%)"; \
1371
	for file in $$RELSRCS; do \
1372
		hfile=`echo $$file|sed 's/\\.hs$$//'`.html; \
1373
		$(HSCOLOUR) -css -anchor $$file > ../$(APIDOC_HS_DIR)/$$hfile ; \
1374
	done ; \
1375
	$(HADDOCK) --odir ../$(APIDOC_HS_DIR) --html --ignore-all-exports -w \
1376
		-t ganeti-htools -p haddock-prologue \
1377
		--source-module="%{MODULE/.//}.html" \
1378
		--source-entity="%{MODULE/.//}.html#%{NAME}" \
1379
		$$OPTGHC \
1380
		$(filter-out Ganeti/HTools/ExtLoader.hs,$(HS_LIB_SRCS:htools/%=%))
1381

    
1382
.PHONY: TAGS
1383
TAGS: $(BUILT_SOURCES)
1384
	rm -f TAGS
1385
	find . -path './lib/*.py' -o -path './scripts/gnt-*' -o \
1386
	  -path './daemons/ganeti-*' -o -path './tools/*' -o \
1387
	  -path './qa/*.py' | \
1388
	  etags -l python -
1389

    
1390
.PHONY: coverage
1391
if WANT_HTOOLS
1392
coverage: py-coverage hs-coverage
1393
else
1394
coverage: py-coverage
1395
endif
1396

    
1397
.PHONY: py-coverage
1398
py-coverage: $(BUILT_SOURCES) $(python_tests)
1399
	set -e; \
1400
	COVERAGE_FILE=$(CURDIR)/$(COVERAGE_PY_DIR)/data \
1401
	TEXT_COVERAGE=$(CURDIR)/$(COVERAGE_PY_DIR)/report.txt \
1402
	HTML_COVERAGE=$(CURDIR)/$(COVERAGE_PY_DIR) \
1403
	$(PLAIN_TESTS_ENVIRONMENT) $(abs_top_srcdir)/autotools/gen-coverage \
1404
	$(python_tests)
1405

    
1406
.PHONY: hs-coverage
1407
hs-coverage: $(haskell_tests) htools/hpc-htools
1408
	rm -f *.tix && $(MAKE) hs-check
1409
	@mkdir_p@ $(COVERAGE_HS_DIR)
1410
	hpc combine $(HPCEXCL) test.tix hpc-htools.tix > coverage-htools.tix
1411
	hpc markup --destdir=$(COVERAGE_HS_DIR) coverage-htools.tix
1412
	hpc report coverage-htools.tix
1413
	$(LN_S) -f hpc_index.html $(COVERAGE_HS_DIR)/index.html
1414

    
1415
# Special "kind-of-QA" target for htools, needs special setup (all
1416
# tools compiled with -fhpc)
1417
.PHONY: live-test
1418
live-test: all
1419
	set -e ; \
1420
	cd htools; \
1421
	rm -f .hpc; $(LN_S) ../.hpc .hpc; \
1422
	rm -f *.tix *.mix; \
1423
	./live-test.sh; \
1424
	hpc sum --union $(HPCEXCL) $(addsuffix .tix,$(HS_PROGS:htools/%=%)) \
1425
	  --output=live-test.tix ; \
1426
	@mkdir_p@ ../$(COVERAGE_HS_DIR) ; \
1427
	hpc markup --destdir=../$(COVERAGE_HS_DIR) live-test \
1428
		--srcdir=.. $(HPCEXCL) ; \
1429
	hpc report --srcdir=.. live-test $(HPCEXCL)
1430

    
1431
commit-check: distcheck lint apidoc
1432

    
1433
-include ./Makefile.local
1434

    
1435
# vim: set noet :