Statistics
| Branch: | Tag: | Revision:

root / Makefile.am @ 36c70d4d

History | View | Annotate | Download (40.2 kB)

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

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

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

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

    
20
ACLOCAL_AMFLAGS = -I autotools
21
BUILD_BASH_COMPLETION = $(top_srcdir)/autotools/build-bash-completion
22
RUN_IN_TEMPDIR = $(top_srcdir)/autotools/run-in-tempdir
23
CHECK_PYTHON_CODE = $(top_srcdir)/autotools/check-python-code
24
CHECK_HEADER = $(top_srcdir)/autotools/check-header
25
CHECK_MAN_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/ovfdata \
91
	test/data/ovfdata/other \
92
	tools
93

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
193
nodist_pkgpython_PYTHON = \
194
	$(BUILT_PYTHON_SOURCES)
195

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
439
doc/html: doc/html/index.html
440

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
562
dist_sbin_SCRIPTS = \
563
	tools/ganeti-listrunner
564

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

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

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

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

    
593
nodist_pkglib_python_scripts = \
594
	tools/ensure-dirs
595

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

    
601
nodist_myexeclib_SCRIPTS = \
602
	$(nodist_pkglib_python_scripts)
603

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

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

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

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

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

    
826
haskell_tests = htools/test
827

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

    
835
nodist_TESTS =
836
check_SCRIPTS =
837

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
976

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
1430
commit-check: distcheck lint apidoc
1431

    
1432
-include ./Makefile.local
1433

    
1434
# vim: set noet :