Statistics
| Branch: | Tag: | Revision:

root / Makefile.am @ 3c899290

History | View | Annotate | Download (39.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/ovfdata \
90
	test/data/ovfdata/other \
91
	tools
92

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
192
nodist_pkgpython_PYTHON = \
193
	$(BUILT_PYTHON_SOURCES)
194

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
438
doc/html: doc/html/index.html
439

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

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

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

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

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

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

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

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

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

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

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

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

    
541
# rules for building profiling-enabled versions of the haskell
542
# programs: hs-prof does the full two-step build, whereas
543
# hs-prof-quick does only the final rebuild (hs-prof must have been
544
# run before)
545
.PHONY: hs-prof hs-prof-quick
546
hs-prof:
547
	$(MAKE) clean
548
	$(MAKE) $(HS_ALL_PROGS) HEXTRA="-osuf .o"
549
	rm -f $(HS_ALL_PROGS)
550
	$(MAKE) hs-prof-quick
551

    
552
hs-prof-quick:
553
	$(MAKE) $(HS_ALL_PROGS) HEXTRA="-osuf .prof_o -prof -auto-all"
554

    
555
dist_sbin_SCRIPTS = \
556
	tools/ganeti-listrunner
557

    
558
nodist_sbin_SCRIPTS = \
559
	$(PYTHON_BOOTSTRAP_SBIN) \
560
	daemons/ganeti-cleaner
561

    
562
python_scripts = \
563
	tools/burnin \
564
	tools/cfgshell \
565
	tools/cfgupgrade \
566
	tools/cfgupgrade12 \
567
	tools/cluster-merge \
568
	tools/confd-client \
569
	tools/fmtjson \
570
	tools/lvmstrap \
571
	tools/move-instance \
572
	tools/ovfconverter \
573
	tools/setup-ssh \
574
	tools/sanitize-config
575

    
576
dist_tools_SCRIPTS = \
577
	$(python_scripts) \
578
	tools/kvm-console-wrapper \
579
	tools/xm-console-wrapper \
580
	tools/master-ip-setup
581

    
582
pkglib_python_scripts = \
583
	daemons/import-export \
584
	tools/check-cert-expired
585

    
586
nodist_pkglib_python_scripts = \
587
	tools/ensure-dirs
588

    
589
myexeclib_SCRIPTS = \
590
	daemons/daemon-util \
591
	tools/kvm-ifup \
592
	$(pkglib_python_scripts)
593

    
594
nodist_myexeclib_SCRIPTS = \
595
	$(nodist_pkglib_python_scripts)
596

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

    
648
man_MANS = \
649
	man/ganeti.7 \
650
	man/ganeti-cleaner.8 \
651
	man/ganeti-confd.8 \
652
	man/ganeti-listrunner.8 \
653
	man/ganeti-masterd.8 \
654
	man/ganeti-noded.8 \
655
	man/ganeti-os-interface.7 \
656
	man/ganeti-rapi.8 \
657
	man/ganeti-watcher.8 \
658
	man/gnt-backup.8 \
659
	man/gnt-cluster.8 \
660
	man/gnt-debug.8 \
661
	man/gnt-group.8 \
662
	man/gnt-instance.8 \
663
	man/gnt-job.8 \
664
	man/gnt-node.8 \
665
	man/gnt-os.8 \
666
	man/hail.1 \
667
	man/hbal.1 \
668
	man/hinfo.1 \
669
	man/hscan.1 \
670
	man/hspace.1 \
671
	man/htools.1
672

    
673
manrst = $(patsubst %.1,%.rst,$(patsubst %.7,%.rst,$(patsubst %.8,%.rst,$(man_MANS))))
674
manhtml = $(patsubst %.rst,%.html,$(manrst))
675
mangen = $(patsubst %.rst,%.gen,$(manrst))
676
maninput = \
677
	$(patsubst %.1,%.1.in,$(patsubst %.7,%.7.in,$(patsubst %.8,%.8.in,$(man_MANS)))) \
678
	$(patsubst %.html,%.html.in,$(manhtml)) \
679
	man/footer.man man/footer.html $(mangen)
680

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

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

    
806
haskell_tests = htools/test
807

    
808
dist_TESTS = \
809
	test/check-cert-expired_unittest.bash \
810
	test/daemon-util_unittest.bash \
811
	test/ganeti-cleaner_unittest.bash \
812
	test/import-export_unittest.bash \
813
	$(python_tests)
814

    
815
nodist_TESTS =
816
if WANT_HTOOLSTESTS
817
nodist_TESTS += $(haskell_tests)
818
endif
819

    
820
TESTS = $(dist_TESTS) $(nodist_TESTS)
821

    
822
# Environment for all tests
823
PLAIN_TESTS_ENVIRONMENT = \
824
	PYTHONPATH=. TOP_SRCDIR=$(abs_top_srcdir) PYTHON=$(PYTHON) \
825
	FAKEROOT=$(FAKEROOT_PATH) $(RUN_IN_TEMPDIR)
826

    
827
# Environment for tests run by automake
828
TESTS_ENVIRONMENT = \
829
	$(PLAIN_TESTS_ENVIRONMENT) $(abs_top_srcdir)/autotools/testrunner
830

    
831
all_python_code = \
832
	$(dist_sbin_SCRIPTS) \
833
	$(python_scripts) \
834
	$(pkglib_python_scripts) \
835
	$(nodist_pkglib_python_scripts) \
836
	$(python_tests) \
837
	$(pkgpython_PYTHON) \
838
	$(client_PYTHON) \
839
	$(hypervisor_PYTHON) \
840
	$(rapi_PYTHON) \
841
	$(server_PYTHON) \
842
	$(pytools_PYTHON) \
843
	$(http_PYTHON) \
844
	$(confd_PYTHON) \
845
	$(masterd_PYTHON) \
846
	$(impexpd_PYTHON) \
847
	$(utils_PYTHON) \
848
	$(watcher_PYTHON) \
849
	$(noinst_PYTHON) \
850
	$(qa_scripts)
851

    
852
srclink_files = \
853
	man/footer.rst \
854
	test/check-cert-expired_unittest.bash \
855
	test/daemon-util_unittest.bash \
856
	test/ganeti-cleaner_unittest.bash \
857
	test/import-export_unittest.bash \
858
	$(all_python_code) \
859
	$(HS_LIB_SRCS) $(HS_PROG_SRCS)
860

    
861
check_python_code = \
862
	$(BUILD_BASH_COMPLETION) \
863
	$(CHECK_IMPORTS) \
864
	$(CHECK_HEADER) \
865
	$(DOCPP) \
866
	$(all_python_code)
867

    
868
lint_python_code = \
869
	ganeti \
870
	ganeti/http/server.py \
871
	$(dist_sbin_SCRIPTS) \
872
	$(python_scripts) \
873
	$(pkglib_python_scripts) \
874
	$(BUILD_BASH_COMPLETION) \
875
	$(CHECK_IMPORTS) \
876
	$(CHECK_HEADER) \
877
	$(DOCPP) \
878
	$(PYTHON_BOOTSTRAP)
879

    
880
standalone_python_modules = \
881
	lib/rapi/client.py \
882
	tools/ganeti-listrunner
883

    
884
pep8_python_code = \
885
	ganeti \
886
	ganeti/http/server.py \
887
	$(dist_sbin_SCRIPTS) \
888
	$(python_scripts) \
889
	$(pkglib_python_scripts) \
890
	$(BUILD_BASH_COMPLETION) \
891
	$(CHECK_HEADER) \
892
	$(DOCPP) \
893
	$(PYTHON_BOOTSTRAP) \
894
	qa
895

    
896
test/daemon-util_unittest.bash: daemons/daemon-util
897

    
898
test/ganeti-cleaner_unittest.bash: daemons/ganeti-cleaner
899

    
900
tools/kvm-ifup: tools/kvm-ifup.in $(REPLACE_VARS_SED)
901
	sed -f $(REPLACE_VARS_SED) < $< > $@
902
	chmod +x $@
903

    
904
devel/upload: devel/upload.in $(REPLACE_VARS_SED)
905
	sed -f $(REPLACE_VARS_SED) < $< > $@
906
	chmod u+x $@
907

    
908
daemons/%: daemons/%.in $(REPLACE_VARS_SED)
909
	sed -f $(REPLACE_VARS_SED) < $< > $@
910
	chmod +x $@
911

    
912
doc/examples/%: doc/examples/%.in $(REPLACE_VARS_SED)
913
	sed -f $(REPLACE_VARS_SED) < $< > $@
914

    
915
doc/examples/hooks/%: doc/examples/hooks/%.in $(REPLACE_VARS_SED)
916
	sed -f $(REPLACE_VARS_SED) < $< > $@
917

    
918
doc/examples/bash_completion: $(BUILD_BASH_COMPLETION) $(RUN_IN_TEMPDIR) \
919
	lib/cli.py $(gnt_scripts) $(client_PYTHON) tools/burnin
920
	PYTHONPATH=. $(RUN_IN_TEMPDIR) $(CURDIR)/$(BUILD_BASH_COMPLETION) > $@
921

    
922
doc/%.png: doc/%.dot
923
	@test -n "$(DOT)" || { echo 'dot' not found during configure; exit 1; }
924
	$(DOT) -Tpng -o $@ $<
925

    
926
man/footer.man: man/footer.rst
927
	@test -n "$(PANDOC)" || \
928
	  { echo 'pandoc' not found during configure; exit 1; }
929
	$(PANDOC) -f rst -t man -o $@ $<
930

    
931
man/footer.html: man/footer.rst
932
	@test -n "$(PANDOC)" || \
933
	  { echo 'pandoc' not found during configure; exit 1; }
934
	$(PANDOC) -f rst -t html -o $@ $<
935

    
936
man/%.gen: man/%.rst lib/query.py lib/build/sphinx_ext.py
937
	PYTHONPATH=. $(RUN_IN_TEMPDIR) $(CURDIR)/$(DOCPP) < $< > $@
938

    
939
man/%.7.in man/%.8.in man/%.1.in: man/%.gen man/footer.man
940
	@test -n "$(PANDOC)" || \
941
	  { echo 'pandoc' not found during configure; exit 1; }
942
	set -o pipefail ; \
943
	trap 'echo auto-removing $@; rm $@' EXIT; \
944
	$(PANDOC) -s -f rst -t man -A man/footer.man $< | \
945
	  sed -e 's/\\@/@/g' > $@; \
946
	if test -n "$(MAN_HAS_WARNINGS)"; then $(CHECK_MAN_WARNINGS) $@; fi; \
947
	$(CHECK_MAN_DASHES) $@; \
948
	trap - EXIT
949

    
950

    
951
man/%.html.in: man/%.gen man/footer.html
952
	@test -n "$(PANDOC)" || \
953
	  { echo 'pandoc' not found during configure; exit 1; }
954
	set -o pipefail ; \
955
	$(PANDOC) -s -f rst -t html -A man/footer.html $< | \
956
	  sed -e 's/\\@/@/g' > $@
957

    
958
man/%.1: man/%.1.in $(REPLACE_VARS_SED)
959
	sed -f $(REPLACE_VARS_SED) < $< > $@
960

    
961
man/%.7: man/%.7.in $(REPLACE_VARS_SED)
962
	sed -f $(REPLACE_VARS_SED) < $< > $@
963

    
964
man/%.8: man/%.8.in $(REPLACE_VARS_SED)
965
	sed -f $(REPLACE_VARS_SED) < $< > $@
966

    
967
man/%.html: man/%.html.in $(REPLACE_VARS_SED)
968
	sed -f $(REPLACE_VARS_SED) < $< > $@
969

    
970
epydoc.conf: epydoc.conf.in Makefile
971
	sed -e 's#@MODULES@#$(strip $(lint_python_code))#g' < $< > $@
972

    
973
vcs-version:
974
	if test -d .git; then \
975
	  git describe > $@; \
976
	elif test ! -f $@ ; then \
977
	  echo "Cannot auto-generate $@ file"; exit 1; \
978
	fi
979

    
980
.PHONY: regen-vcs-version
981
regen-vcs-version:
982
	set -e; \
983
	cd $(srcdir); \
984
	if test -d .git; then \
985
	  rm -f vcs-version; \
986
	  $(MAKE) vcs-version; \
987
	fi
988

    
989
htools/Ganeti/HTools/Version.hs: htools/Ganeti/HTools/Version.hs.in vcs-version
990
	set -e; \
991
	VCSVER=`cat $(abs_top_srcdir)/vcs-version`; \
992
	sed -e "s/%ver%/$$VCSVER/" < $< > $@
993

    
994
htools/Ganeti/Constants.hs: htools/Ganeti/Constants.hs.in \
995
	lib/constants.py lib/_autoconf.py $(CONVERT_CONSTANTS) \
996
	| lib/_vcsversion.py
997
	set -e; \
998
	{ cat $< ; PYTHONPATH=. $(CONVERT_CONSTANTS); } > $@
999

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

    
1068
lib/_vcsversion.py: Makefile vcs-version | lib/.dir
1069
	set -e; \
1070
	VCSVER=`cat $(abs_top_srcdir)/vcs-version`; \
1071
	{ echo '# This file is automatically generated, do not edit!'; \
1072
	  echo '#'; \
1073
	  echo ''; \
1074
	  echo '"""Build-time VCS version number for Ganeti.'; \
1075
	  echo '';\
1076
	  echo 'This file is autogenerated by the build process.'; \
1077
	  echo 'For any changes you need to re-run ./configure (and'; \
1078
	  echo 'not edit by hand).'; \
1079
	  echo ''; \
1080
	  echo '"""'; \
1081
	  echo ''; \
1082
	  echo '# pylint: disable=C0301,C0324'; \
1083
	  echo '# because this is autogenerated, we do not want'; \
1084
	  echo '# style warnings' ; \
1085
	  echo ''; \
1086
	  echo "VCS_VERSION = '$$VCSVER'"; \
1087
	} > $@
1088

    
1089
lib/_generated_rpc.py: lib/rpc_defs.py $(BUILD_RPC)
1090
	PYTHONPATH=. $(RUN_IN_TEMPDIR) $(CURDIR)/$(BUILD_RPC) lib/rpc_defs.py > $@
1091

    
1092
$(REPLACE_VARS_SED): Makefile
1093
	set -e; \
1094
	{ echo 's#@PREFIX@#$(prefix)#g'; \
1095
	  echo 's#@SYSCONFDIR@#$(sysconfdir)#g'; \
1096
	  echo 's#@LOCALSTATEDIR@#$(localstatedir)#g'; \
1097
	  echo 's#@BINDIR@#$(bindir)#g'; \
1098
	  echo 's#@SBINDIR@#$(sbindir)#g'; \
1099
	  echo 's#@GANETI_VERSION@#$(PACKAGE_VERSION)#g'; \
1100
	  echo 's#@CUSTOM_XEN_BOOTLOADER@#$(XEN_BOOTLOADER)#g'; \
1101
	  echo 's#@CUSTOM_XEN_KERNEL@#$(XEN_KERNEL)#g'; \
1102
	  echo 's#@CUSTOM_XEN_INITRD@#$(XEN_INITRD)#g'; \
1103
	  echo 's#@CUSTOM_IALLOCATOR_SEARCH_PATH@#$(IALLOCATOR_SEARCH_PATH)#g'; \
1104
	  echo 's#@CUSTOM_EXPORT_DIR@#$(EXPORT_DIR)#g'; \
1105
	  echo 's#@RPL_FILE_STORAGE_DIR@#$(FILE_STORAGE_DIR)#g'; \
1106
	  echo 's#@RPL_SSH_INITD_SCRIPT@#$(SSH_INITD_SCRIPT)#g'; \
1107
	  echo 's#@PKGLIBDIR@#$(pkglibdir)#g'; \
1108
	  echo 's#@GNTMASTERUSER@#$(MASTERD_USER)#g'; \
1109
	  echo 's#@GNTRAPIUSER@#$(RAPI_USER)#g'; \
1110
	  echo 's#@GNTCONFDUSER@#$(CONFD_USER)#g'; \
1111
	  echo 's#@GNTNODEDUSER@#$(NODED_USER)#g'; \
1112
	  echo 's#@GNTRAPIGROUP@#$(RAPI_GROUP)#g'; \
1113
	  echo 's#@GNTADMINGROUP@#$(ADMIN_GROUP)#g'; \
1114
	  echo 's#@GNTCONFDGROUP@#$(CONFD_GROUP)#g'; \
1115
	  echo 's#@GNTMASTERDGROUP@#$(MASTERD_GROUP)#g'; \
1116
	  echo 's#@GNTDAEMONSGROUP@#$(DAEMONS_GROUP)#g'; \
1117
	  echo 's#@CUSTOM_ENABLE_CONFD@#$(ENABLE_CONFD)#g'; \
1118
	} > $@
1119

    
1120
# Using deferred evaluation
1121
daemons/ganeti-%: MODULE = ganeti.server.$(patsubst ganeti-%,%,$(notdir $@))
1122
daemons/ganeti-watcher: MODULE = ganeti.watcher
1123
scripts/%: MODULE = ganeti.client.$(subst -,_,$(notdir $@))
1124
tools/ensure-dirs: MODULE = ganeti.tools.ensure_dirs
1125

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

    
1153
# We need to create symlinks because "make distcheck" will not install Python
1154
# files when building.
1155
stamp-srclinks: Makefile | $(all_dirfiles)
1156
	set -e; \
1157
	for i in $(srclink_files); do \
1158
		if test ! -f $$i -a -f $(abs_top_srcdir)/$$i; then \
1159
			$(LN_S) $(abs_top_srcdir)/$$i $$i; \
1160
		fi; \
1161
	done
1162
	touch $@
1163

    
1164
.PHONY: ganeti
1165
ganeti:
1166
	cd $(top_builddir) && test -h "$@" || { rm -f $@ && $(LN_S) lib $@; }
1167

    
1168
.PHONY: check-dirs
1169
check-dirs: $(BUILT_SOURCES)
1170
	@set -e; \
1171
	find . -type d \( \( -name . \) -o \( \
1172
		-name .git -o \
1173
		-name autom4te.cache \
1174
		\) -prune -o -print \) | { \
1175
		error=; \
1176
		while read dir; do \
1177
			case "$$dir" in \
1178
				$(strip $(patsubst %,(./%) ;;,$(DIRCHECK_EXCLUDE) $(DIRS))) \
1179
				*) error=1; echo "Directory $$dir not listed in Makefile" >&2 ;; \
1180
			esac; \
1181
		done; \
1182
		for dir in $(DIRS); do \
1183
			if ! test -d "$$dir"; then \
1184
				echo "Directory $$dir listed in DIRS does not exist" >&2; \
1185
				error=1; \
1186
			fi \
1187
		done; \
1188
		if test -n "$$error"; then exit 1; else exit 0; fi; \
1189
	}
1190

    
1191
.PHONY: check-local
1192
check-local: check-dirs $(BUILT_SOURCES)
1193
	$(CHECK_PYTHON_CODE) $(check_python_code)
1194
	PYTHONPATH=. $(CHECK_HEADER) $(check_python_code)
1195
	$(CHECK_VERSION) $(VERSION) $(top_srcdir)/NEWS
1196
	$(CHECK_NEWS) < $(top_srcdir)/NEWS
1197
	PYTHONPATH=. $(RUN_IN_TEMPDIR) $(CURDIR)/$(CHECK_IMPORTS) . $(standalone_python_modules)
1198
	expver=$(VERSION_MAJOR).$(VERSION_MINOR); \
1199
	if test "`head -n 1 $(top_srcdir)/README`" != "Ganeti $$expver"; then \
1200
		echo "Incorrect version in README, expected $$expver"; \
1201
		exit 1; \
1202
	fi; \
1203
	for file in doc/iallocator.rst doc/hooks.rst; do \
1204
		if test "`sed -ne '4 p' $(top_srcdir)/$$file`" != \
1205
			"Documents Ganeti version $$expver"; then \
1206
			echo "Incorrect version in $$file, expected $$expver"; \
1207
			exit 1; \
1208
		fi; \
1209
	done
1210

    
1211
.PHONY: hs-check
1212
hs-check: htools/test
1213
	@rm -f test.tix
1214
	./htools/test
1215

    
1216
# E111: indentation is not a multiple of four
1217
# E261: at least two spaces before inline comment
1218
# E501: line too long (80 characters)
1219
PEP8_IGNORE = E111,E261,E501
1220

    
1221
# For excluding pep8 expects filenames only, not whole paths
1222
PEP8_EXCLUDE = $(subst $(space),$(comma),$(strip $(notdir $(BUILT_PYTHON_SOURCES))))
1223

    
1224
.PHONY: lint
1225
lint: $(BUILT_SOURCES)
1226
	@test -n "$(PYLINT)" || { echo 'pylint' not found during configure; exit 1; }
1227
	if test -z "$(PEP8)"; then \
1228
		echo '"pep8" not found during configure' >&2; \
1229
	else \
1230
		$(PEP8) --repeat --ignore='$(PEP8_IGNORE)' --exclude='$(PEP8_EXCLUDE)' \
1231
			$(pep8_python_code); \
1232
	fi
1233
	$(PYLINT) $(LINT_OPTS) $(lint_python_code)
1234
	cd $(top_srcdir)/qa && \
1235
	  PYTHONPATH=$(abs_top_srcdir) $(PYLINT) $(LINT_OPTS) \
1236
	  --rcfile  ../pylintrc $(patsubst qa/%.py,%,$(qa_scripts))
1237

    
1238
.PHONY: hlint
1239
hlint: $(HS_BUILT_SRCS) htools/lint-hints.hs
1240
	if tty -s; then C="-c"; else C=""; fi; \
1241
	hlint --report=doc/hs-lint.html --cross $$C \
1242
	  --ignore "Use first" \
1243
	  --ignore "Use comparing" \
1244
	  --ignore "Use on" \
1245
	  --ignore "Use Control.Exception.catch" \
1246
	  --ignore "Reduce duplication" \
1247
	  --hint htools/lint-hints \
1248
	  $(filter-out htools/Ganeti/THH.hs,$(HS_LIB_SRCS))
1249

    
1250
# a dist hook rule for updating the vcs-version file; this is
1251
# hardcoded due to where it needs to build the file...
1252
dist-hook:
1253
	$(MAKE) regen-vcs-version && \
1254
	rm -f $(top_distdir)/vcs-version && \
1255
	cp -p $(srcdir)/vcs-version $(top_distdir)
1256

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

    
1286
# When building a release, stricter checks should be used
1287
distcheck-release dist-release: export BUILD_RELEASE = 1
1288
distcheck-release: distcheck
1289

    
1290
dist-release: dist
1291
	set -e; \
1292
	for i in $(DIST_ARCHIVES); do \
1293
		echo -n "Checking $$i ... "; \
1294
		autotools/check-tar < $$i; \
1295
		echo OK; \
1296
	done
1297

    
1298
install-exec-local:
1299
	@mkdir_p@ "$(DESTDIR)${localstatedir}/lib/ganeti" \
1300
	  "$(DESTDIR)${localstatedir}/log/ganeti" \
1301
	  "$(DESTDIR)${localstatedir}/run/ganeti"
1302

    
1303
# To avoid conflicts between directory names and other targets, a file inside
1304
# the directory is used to ensure its existence.
1305
%.dir:
1306
	@mkdir_p@ $* && touch $@
1307

    
1308
.PHONY: apidoc
1309
if WANT_HTOOLSAPIDOC
1310
apidoc: py-apidoc hs-apidoc
1311
else
1312
apidoc: py-apidoc
1313
endif
1314

    
1315
.PHONY: py-apidoc
1316
py-apidoc: epydoc.conf $(RUN_IN_TEMPDIR) $(BUILT_SOURCES)
1317
	$(RUN_IN_TEMPDIR) epydoc -v \
1318
		--conf $(CURDIR)/epydoc.conf \
1319
		--output $(CURDIR)/$(APIDOC_PY_DIR)
1320

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

    
1354
.PHONY: TAGS
1355
TAGS: $(BUILT_SOURCES)
1356
	rm -f TAGS
1357
	find . -path './lib/*.py' -o -path './scripts/gnt-*' -o \
1358
	  -path './daemons/ganeti-*' -o -path './tools/*' -o \
1359
	  -path './qa/*.py' | \
1360
	  etags -l python -
1361

    
1362
.PHONY: coverage
1363
if WANT_HTOOLS
1364
coverage: py-coverage hs-coverage
1365
else
1366
coverage: py-coverage
1367
endif
1368

    
1369
.PHONY: py-coverage
1370
py-coverage: $(BUILT_SOURCES) $(python_tests)
1371
	set -e; \
1372
	COVERAGE_FILE=$(CURDIR)/$(COVERAGE_PY_DIR)/data \
1373
	TEXT_COVERAGE=$(CURDIR)/$(COVERAGE_PY_DIR)/report.txt \
1374
	HTML_COVERAGE=$(CURDIR)/$(COVERAGE_PY_DIR) \
1375
	$(PLAIN_TESTS_ENVIRONMENT) $(abs_top_srcdir)/autotools/gen-coverage \
1376
	$(python_tests)
1377

    
1378
.PHONY: hs-coverage
1379
hs-coverage: $(haskell_tests)
1380
	cd htools && rm -f *.tix *.mix && ./test
1381
	@mkdir_p@ $(COVERAGE_HS_DIR)
1382
	hpc markup --destdir=$(COVERAGE_HS_DIR) htools/test $(HPCEXCL)
1383
	hpc report htools/test $(HPCEXCL)
1384
	$(LN_S) -f hpc_index.html $(COVERAGE_HS_DIR)/index.html
1385

    
1386
# Special "kind-of-QA" target for htools, needs special setup (all
1387
# tools compiled with -fhpc)
1388
.PHONY: live-test
1389
live-test: all
1390
	set -e ; \
1391
	cd htools; \
1392
	rm -f .hpc; $(LN_S) ../.hpc .hpc; \
1393
	rm -f *.tix *.mix; \
1394
	./live-test.sh; \
1395
	hpc sum --union $(HPCEXCL) $(addsuffix .tix,$(HS_PROGS:htools/%=%)) \
1396
	  --output=live-test.tix ; \
1397
	@mkdir_p@ ../$(COVERAGE_HS_DIR) ; \
1398
	hpc markup --destdir=../$(COVERAGE_HS_DIR) live-test \
1399
		--srcdir=.. $(HPCEXCL) ; \
1400
	hpc report --srcdir=.. live-test $(HPCEXCL)
1401

    
1402
commit-check: distcheck lint apidoc
1403

    
1404
-include ./Makefile.local
1405

    
1406
# vim: set noet :