Statistics
| Branch: | Tag: | Revision:

root / Makefile.am @ 417cc253

History | View | Annotate | Download (39 kB)

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
189
nodist_pkgpython_PYTHON = \
190
	$(BUILT_PYTHON_SOURCES)
191

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
406
HS_BUILT_SRCS = htools/Ganeti/HTools/Version.hs htools/Ganeti/Constants.hs
407
HS_BUILT_SRCS_IN = $(patsubst %,%.in,$(HS_BUILT_SRCS))
408

    
409
$(RUN_IN_TEMPDIR): | $(all_dirfiles)
410

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

    
430
doc/html: doc/html/index.html
431

    
432
doc/install-quick.rst: INSTALL
433
doc/news.rst: NEWS
434
doc/upgrade.rst: UPGRADE
435

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

    
444
docdot = \
445
	doc/arch-2.0.dot \
446
	doc/design-2.1-lock-acquire.dot \
447
	doc/design-2.1-lock-release.dot
448

    
449
docpng = $(patsubst %.dot,%.png,$(docdot))
450

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

    
460
gnt_scripts = \
461
	scripts/gnt-backup \
462
	scripts/gnt-cluster \
463
	scripts/gnt-debug \
464
	scripts/gnt-group \
465
	scripts/gnt-instance \
466
	scripts/gnt-job \
467
	scripts/gnt-node \
468
	scripts/gnt-os
469

    
470
PYTHON_BOOTSTRAP_SBIN = \
471
	daemons/ganeti-confd \
472
	daemons/ganeti-masterd \
473
	daemons/ganeti-noded \
474
	daemons/ganeti-watcher \
475
	daemons/ganeti-rapi \
476
	$(gnt_scripts)
477

    
478
PYTHON_BOOTSTRAP = \
479
	$(PYTHON_BOOTSTRAP_SBIN) \
480
	tools/ensure-dirs
481

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

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

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

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

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

    
544
hs-prof-quick:
545
	$(MAKE) $(HS_ALL_PROGS) HEXTRA="-osuf .prof_o -prof -auto-all"
546

    
547
dist_sbin_SCRIPTS = \
548
	tools/ganeti-listrunner
549

    
550
nodist_sbin_SCRIPTS = \
551
	$(PYTHON_BOOTSTRAP_SBIN) \
552
	daemons/ganeti-cleaner
553

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

    
568
dist_tools_SCRIPTS = \
569
	$(python_scripts) \
570
	tools/kvm-console-wrapper \
571
	tools/xm-console-wrapper \
572
	tools/master-ip-setup
573

    
574
pkglib_python_scripts = \
575
	daemons/import-export \
576
	tools/check-cert-expired
577

    
578
nodist_pkglib_python_scripts = \
579
	tools/ensure-dirs
580

    
581
myexeclib_SCRIPTS = \
582
	daemons/daemon-util \
583
	tools/kvm-ifup \
584
	$(pkglib_python_scripts)
585

    
586
nodist_myexeclib_SCRIPTS = \
587
	$(nodist_pkglib_python_scripts)
588

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

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

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

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

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

    
798
haskell_tests = htools/test
799

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

    
807
nodist_TESTS =
808
if WANT_HTOOLSTESTS
809
nodist_TESTS += $(haskell_tests)
810
endif
811

    
812
TESTS = $(dist_TESTS) $(nodist_TESTS)
813

    
814
# Environment for all tests
815
PLAIN_TESTS_ENVIRONMENT = \
816
	PYTHONPATH=. TOP_SRCDIR=$(abs_top_srcdir) PYTHON=$(PYTHON) \
817
	FAKEROOT=$(FAKEROOT_PATH) $(RUN_IN_TEMPDIR)
818

    
819
# Environment for tests run by automake
820
TESTS_ENVIRONMENT = \
821
	$(PLAIN_TESTS_ENVIRONMENT) $(abs_top_srcdir)/autotools/testrunner
822

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

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

    
853
check_python_code = \
854
	$(BUILD_BASH_COMPLETION) \
855
	$(CHECK_IMPORTS) \
856
	$(CHECK_HEADER) \
857
	$(DOCPP) \
858
	$(all_python_code)
859

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

    
872
standalone_python_modules = \
873
	lib/rapi/client.py \
874
	tools/ganeti-listrunner
875

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

    
888
test/daemon-util_unittest.bash: daemons/daemon-util
889

    
890
test/ganeti-cleaner_unittest.bash: daemons/ganeti-cleaner
891

    
892
tools/kvm-ifup: tools/kvm-ifup.in $(REPLACE_VARS_SED)
893
	sed -f $(REPLACE_VARS_SED) < $< > $@
894
	chmod +x $@
895

    
896
devel/upload: devel/upload.in $(REPLACE_VARS_SED)
897
	sed -f $(REPLACE_VARS_SED) < $< > $@
898
	chmod u+x $@
899

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

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

    
907
doc/examples/hooks/%: doc/examples/hooks/%.in $(REPLACE_VARS_SED)
908
	sed -f $(REPLACE_VARS_SED) < $< > $@
909

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

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

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

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

    
928
man/%.gen: man/%.rst lib/query.py lib/build/sphinx_ext.py
929
	PYTHONPATH=. $(RUN_IN_TEMPDIR) $(CURDIR)/$(DOCPP) < $< > $@
930

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

    
942

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

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

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

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

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

    
962
epydoc.conf: epydoc.conf.in Makefile
963
	sed -e 's#@MODULES@#$(strip $(lint_python_code))#g' < $< > $@
964

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

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

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

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

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

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

    
1081
lib/_generated_rpc.py: lib/rpc_defs.py $(BUILD_RPC)
1082
	PYTHONPATH=. $(RUN_IN_TEMPDIR) $(CURDIR)/$(BUILD_RPC) lib/rpc_defs.py > $@
1083

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

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

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

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

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

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

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

    
1203
.PHONY: hs-check
1204
hs-check: htools/test
1205
	@rm -f test.tix
1206
	./htools/test
1207

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

    
1213
# For excluding pep8 expects filenames only, not whole paths
1214
PEP8_EXCLUDE = $(subst $(space),$(comma),$(strip $(notdir $(BUILT_PYTHON_SOURCES))))
1215

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

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

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

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

    
1278
# When building a release, stricter checks should be used
1279
distcheck-release dist-release: export BUILD_RELEASE = 1
1280
distcheck-release: distcheck
1281

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

    
1290
install-exec-local:
1291
	@mkdir_p@ "$(DESTDIR)${localstatedir}/lib/ganeti" \
1292
	  "$(DESTDIR)${localstatedir}/log/ganeti" \
1293
	  "$(DESTDIR)${localstatedir}/run/ganeti"
1294

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

    
1300
.PHONY: apidoc
1301
if WANT_HTOOLSAPIDOC
1302
apidoc: py-apidoc hs-apidoc
1303
else
1304
apidoc: py-apidoc
1305
endif
1306

    
1307
.PHONY: py-apidoc
1308
py-apidoc: epydoc.conf $(RUN_IN_TEMPDIR) $(BUILT_SOURCES)
1309
	$(RUN_IN_TEMPDIR) epydoc -v \
1310
		--conf $(CURDIR)/epydoc.conf \
1311
		--output $(CURDIR)/$(APIDOC_PY_DIR)
1312

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

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

    
1352
.PHONY: coverage
1353
if WANT_HTOOLS
1354
coverage: py-coverage hs-coverage
1355
else
1356
coverage: py-coverage
1357
endif
1358

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

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

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

    
1392
commit-check: distcheck lint apidoc
1393

    
1394
-include ./Makefile.local
1395

    
1396
# vim: set noet :