Statistics
| Branch: | Tag: | Revision:

root / Makefile.am @ 656a7fdf

History | View | Annotate | Download (36.8 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 = $(top_srcdir)/autotools/check-man
26
CHECK_VERSION = $(top_srcdir)/autotools/check-version
27
CHECK_NEWS = $(top_srcdir)/autotools/check-news
28
CHECK_IMPORTS = $(top_srcdir)/autotools/check-imports
29
DOCPP = $(top_srcdir)/autotools/docpp
30
REPLACE_VARS_SED = autotools/replace_vars.sed
31
CONVERT_CONSTANTS = $(top_srcdir)/autotools/convert-constants
32
BUILD_RPC = $(top_srcdir)/autotools/build-rpc
33

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

    
51
# Delete output file if an error occurred while building it
52
.DELETE_ON_ERROR:
53

    
54
HTOOLS_DIRS = \
55
	htools \
56
	htools/Ganeti \
57
	htools/Ganeti/HTools \
58
	htools/Ganeti/HTools/Program
59

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

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

    
102
BUILDTIME_DIRS = \
103
	$(BUILDTIME_DIR_AUTOCREATE) \
104
	doc/html
105

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

    
111
all_dirfiles = $(addsuffix /.dir,$(DIRS) $(BUILDTIME_DIR_AUTOCREATE))
112

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

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

    
129
maintainer-clean-local:
130
	rm -rf $(BUILDTIME_DIRS)
131

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

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

    
164
BUILT_PYTHON_SOURCES = \
165
	lib/_autoconf.py \
166
	lib/_vcsversion.py \
167
	lib/_generated_rpc.py
168

    
169
# these are all built from the underlying %.in sources
170
BUILT_EXAMPLES = \
171
	doc/examples/ganeti-kvm-poweroff.initd \
172
	doc/examples/ganeti.cron \
173
	doc/examples/ganeti.initd \
174
	doc/examples/gnt-config-backup \
175
	doc/examples/hooks/ipsec
176

    
177
nodist_pkgpython_PYTHON = \
178
	$(BUILT_PYTHON_SOURCES)
179

    
180
noinst_PYTHON = \
181
	lib/build/__init__.py \
182
	lib/build/sphinx_ext.py
183

    
184
pkgpython_PYTHON = \
185
	lib/__init__.py \
186
	lib/asyncnotifier.py \
187
	lib/backend.py \
188
	lib/bdev.py \
189
	lib/bootstrap.py \
190
	lib/cli.py \
191
	lib/cmdlib.py \
192
	lib/compat.py \
193
	lib/config.py \
194
	lib/constants.py \
195
	lib/daemon.py \
196
	lib/errors.py \
197
	lib/ht.py \
198
	lib/jqueue.py \
199
	lib/jstore.py \
200
	lib/locking.py \
201
	lib/luxi.py \
202
	lib/mcpu.py \
203
	lib/netutils.py \
204
	lib/objects.py \
205
	lib/opcodes.py \
206
	lib/ovf.py \
207
	lib/qlang.py \
208
	lib/query.py \
209
	lib/rpc.py \
210
	lib/rpc_defs.py \
211
	lib/runtime.py \
212
	lib/serializer.py \
213
	lib/ssconf.py \
214
	lib/ssh.py \
215
	lib/storage.py \
216
	lib/uidpool.py \
217
	lib/workerpool.py
218

    
219
client_PYTHON = \
220
	lib/client/__init__.py \
221
	lib/client/gnt_backup.py \
222
	lib/client/gnt_cluster.py \
223
	lib/client/gnt_debug.py \
224
	lib/client/gnt_group.py \
225
	lib/client/gnt_instance.py \
226
	lib/client/gnt_job.py \
227
	lib/client/gnt_node.py \
228
	lib/client/gnt_os.py
229

    
230
hypervisor_PYTHON = \
231
	lib/hypervisor/__init__.py \
232
	lib/hypervisor/hv_base.py \
233
	lib/hypervisor/hv_chroot.py \
234
	lib/hypervisor/hv_fake.py \
235
	lib/hypervisor/hv_kvm.py \
236
	lib/hypervisor/hv_lxc.py \
237
	lib/hypervisor/hv_xen.py
238

    
239
rapi_PYTHON = \
240
	lib/rapi/__init__.py \
241
	lib/rapi/baserlib.py \
242
	lib/rapi/client.py \
243
	lib/rapi/client_utils.py \
244
	lib/rapi/connector.py \
245
	lib/rapi/rlib2.py
246

    
247
http_PYTHON = \
248
	lib/http/__init__.py \
249
	lib/http/auth.py \
250
	lib/http/client.py \
251
	lib/http/server.py
252

    
253
confd_PYTHON = \
254
	lib/confd/__init__.py \
255
	lib/confd/client.py \
256
	lib/confd/querylib.py \
257
	lib/confd/server.py
258

    
259
masterd_PYTHON = \
260
	lib/masterd/__init__.py \
261
	lib/masterd/instance.py
262

    
263
impexpd_PYTHON = \
264
	lib/impexpd/__init__.py
265

    
266
watcher_PYTHON = \
267
	lib/watcher/__init__.py \
268
	lib/watcher/nodemaint.py \
269
	lib/watcher/state.py
270

    
271
server_PYTHON = \
272
	lib/server/__init__.py \
273
	lib/server/confd.py \
274
	lib/server/masterd.py \
275
	lib/server/noded.py \
276
	lib/server/rapi.py
277

    
278
pytools_PYTHON = \
279
	lib/tools/__init__.py \
280
	lib/tools/ensure_dirs.py
281

    
282
utils_PYTHON = \
283
	lib/utils/__init__.py \
284
	lib/utils/algo.py \
285
	lib/utils/filelock.py \
286
	lib/utils/hash.py \
287
	lib/utils/io.py \
288
	lib/utils/log.py \
289
	lib/utils/mlock.py \
290
	lib/utils/nodesetup.py \
291
	lib/utils/process.py \
292
	lib/utils/retry.py \
293
	lib/utils/text.py \
294
	lib/utils/wrapper.py \
295
	lib/utils/x509.py
296

    
297
docrst = \
298
	doc/admin.rst \
299
	doc/design-2.0.rst \
300
	doc/design-2.1.rst \
301
	doc/design-2.2.rst \
302
	doc/design-2.3.rst \
303
	doc/design-htools-2.3.rst \
304
	doc/design-2.4.rst \
305
	doc/design-2.5.rst \
306
	doc/design-draft.rst \
307
	doc/design-oob.rst \
308
	doc/design-cpu-pinning.rst \
309
	doc/design-query2.rst \
310
	doc/design-x509-ca.rst \
311
	doc/design-http-server.rst \
312
	doc/design-impexp2.rst \
313
	doc/design-lu-generated-jobs.rst \
314
	doc/design-multi-reloc.rst \
315
	doc/design-network.rst \
316
	doc/design-chained-jobs.rst \
317
	doc/design-ovf-support.rst \
318
	doc/design-resource-model.rst \
319
	doc/cluster-merge.rst \
320
	doc/design-shared-storage.rst \
321
	doc/design-node-state-cache.rst \
322
	doc/design-virtual-clusters.rst \
323
	doc/devnotes.rst \
324
	doc/glossary.rst \
325
	doc/hooks.rst \
326
	doc/iallocator.rst \
327
	doc/index.rst \
328
	doc/install-quick.rst \
329
	doc/install.rst \
330
	doc/locking.rst \
331
	doc/move-instance.rst \
332
	doc/news.rst \
333
	doc/rapi.rst \
334
	doc/security.rst \
335
	doc/upgrade.rst \
336
	doc/walkthrough.rst
337

    
338
HS_PROGS = htools/htools
339
HS_BIN_ROLES = hbal hscan hspace
340

    
341
HS_ALL_PROGS = $(HS_PROGS) htools/test
342
HS_PROG_SRCS = $(patsubst %,%.hs,$(HS_ALL_PROGS))
343
# we don't add -Werror by default
344
HFLAGS = -O -Wall -fwarn-monomorphism-restriction -fwarn-tabs -ihtools
345
# extra flags that can be overriden on the command line
346
HEXTRA =
347
# exclude options for coverage reports
348
HPCEXCL = --exclude Main \
349
	--exclude Ganeti.Constants \
350
	--exclude Ganeti.THH \
351
	--exclude Ganeti.HTools.QC \
352
	--exclude Ganeti.HTools.QCHelper \
353
	--exclude Ganeti.HTools.Version
354

    
355
HS_LIB_SRCS = \
356
	htools/Ganeti/HTools/CLI.hs \
357
	htools/Ganeti/HTools/Cluster.hs \
358
	htools/Ganeti/HTools/Compat.hs \
359
	htools/Ganeti/HTools/Container.hs \
360
	htools/Ganeti/HTools/ExtLoader.hs \
361
	htools/Ganeti/HTools/Group.hs \
362
	htools/Ganeti/HTools/IAlloc.hs \
363
	htools/Ganeti/HTools/Instance.hs \
364
	htools/Ganeti/HTools/JSON.hs \
365
	htools/Ganeti/HTools/Loader.hs \
366
	htools/Ganeti/HTools/Luxi.hs \
367
	htools/Ganeti/HTools/Node.hs \
368
	htools/Ganeti/HTools/PeerMap.hs \
369
	htools/Ganeti/HTools/QC.hs \
370
	htools/Ganeti/HTools/QCHelper.hs \
371
	htools/Ganeti/HTools/Rapi.hs \
372
	htools/Ganeti/HTools/Simu.hs \
373
	htools/Ganeti/HTools/Text.hs \
374
	htools/Ganeti/HTools/Types.hs \
375
	htools/Ganeti/HTools/Utils.hs \
376
	htools/Ganeti/HTools/Program/Hail.hs \
377
	htools/Ganeti/HTools/Program/Hbal.hs \
378
	htools/Ganeti/HTools/Program/Hscan.hs \
379
	htools/Ganeti/HTools/Program/Hspace.hs \
380
	htools/Ganeti/Jobs.hs \
381
	htools/Ganeti/Luxi.hs \
382
	htools/Ganeti/OpCodes.hs \
383
	htools/Ganeti/THH.hs
384

    
385
HS_BUILT_SRCS = htools/Ganeti/HTools/Version.hs htools/Ganeti/Constants.hs
386
HS_BUILT_SRCS_IN = $(patsubst %,%.in,$(HS_BUILT_SRCS))
387

    
388
$(RUN_IN_TEMPDIR): | $(all_dirfiles)
389

    
390
# Note: we use here an order-only prerequisite, as the contents of
391
# _autoconf.py are not actually influencing the html build output: it
392
# has to exist in order for the sphinx module to be loaded
393
# successfully, but we certainly don't want the docs to be rebuilt if
394
# it changes
395
doc/html/index.html: $(docrst) $(docpng) doc/conf.py configure.ac \
396
	$(RUN_IN_TEMPDIR) lib/build/sphinx_ext.py lib/opcodes.py lib/ht.py \
397
	| $(BUILT_PYTHON_SOURCES)
398
	@test -n "$(SPHINX)" || \
399
	    { echo 'sphinx-build' not found during configure; exit 1; }
400
	@mkdir_p@ $(dir $@)
401
	PYTHONPATH=. $(RUN_IN_TEMPDIR) $(SPHINX) -q -W -b html \
402
	    -d . \
403
	    -D version="$(VERSION_MAJOR).$(VERSION_MINOR)" \
404
	    -D release="$(PACKAGE_VERSION)" \
405
	    $(abs_top_srcdir)/doc $(CURDIR)/doc/html
406
	rm -f doc/html/.buildinfo doc/html/objects.inv
407
	touch $@
408

    
409
doc/html: doc/html/index.html
410

    
411
doc/install-quick.rst: INSTALL
412
doc/news.rst: NEWS
413
doc/upgrade.rst: UPGRADE
414

    
415
doc/install-quick.rst doc/news.rst doc/upgrade.rst:
416
	set -e; \
417
	{ echo '.. This file is automatically updated at build time from $<.'; \
418
	  echo '.. Do not edit.'; \
419
	  echo; \
420
	  cat $<; \
421
	} > $@
422

    
423
docdot = \
424
	doc/arch-2.0.dot \
425
	doc/design-2.1-lock-acquire.dot \
426
	doc/design-2.1-lock-release.dot
427

    
428
docpng = $(patsubst %.dot,%.png,$(docdot))
429

    
430
# Things to build but not to install (add it to EXTRA_DIST if it should be
431
# distributed)
432
noinst_DATA = \
433
	devel/upload \
434
	doc/html \
435
	$(BUILT_EXAMPLES) \
436
	doc/examples/bash_completion \
437
	$(manhtml)
438

    
439
gnt_scripts = \
440
	scripts/gnt-backup \
441
	scripts/gnt-cluster \
442
	scripts/gnt-debug \
443
	scripts/gnt-group \
444
	scripts/gnt-instance \
445
	scripts/gnt-job \
446
	scripts/gnt-node \
447
	scripts/gnt-os
448

    
449
PYTHON_BOOTSTRAP_SBIN = \
450
	daemons/ganeti-confd \
451
	daemons/ganeti-masterd \
452
	daemons/ganeti-noded \
453
	daemons/ganeti-watcher \
454
	daemons/ganeti-rapi \
455
	$(gnt_scripts)
456

    
457
PYTHON_BOOTSTRAP = \
458
	$(PYTHON_BOOTSTRAP_SBIN) \
459
	tools/ensure-dirs
460

    
461
qa_scripts = \
462
	qa/ganeti-qa.py \
463
	qa/qa_cluster.py \
464
	qa/qa_config.py \
465
	qa/qa_daemon.py \
466
	qa/qa_env.py \
467
	qa/qa_error.py \
468
	qa/qa_group.py \
469
	qa/qa_instance.py \
470
	qa/qa_node.py \
471
	qa/qa_os.py \
472
	qa/qa_rapi.py \
473
	qa/qa_tags.py \
474
	qa/qa_utils.py
475

    
476
bin_SCRIPTS =
477
if WANT_HTOOLS
478
bin_SCRIPTS += $(filter-out htools/hail,$(HS_PROGS))
479
install-exec-hook:
480
	@mkdir_p@ $(DESTDIR)$(iallocatorsdir)
481
# FIXME: this is a hardcoded logic, instead of auto-resolving
482
	$(LN_S) -f ../../../bin/htools \
483
		   $(DESTDIR)$(iallocatorsdir)/hail
484
	for role in $(HS_BIN_ROLES); do \
485
		$(LN_S) -f htools \
486
			   $(DESTDIR)$(bindir)/$$role ; \
487
	done
488
endif
489

    
490
$(HS_ALL_PROGS): %: %.hs $(HS_LIB_SRCS) $(HS_BUILT_SRCS) Makefile
491
	@if [ -z "$(HTOOLS)" ]; then \
492
	  echo "Error: htools compilation disabled at configure time" 1>&2 ;\
493
	  exit 1; \
494
	fi
495
	@BINARY=$(@:htools/%=%); \
496
	if [ "$BINARY" = "test" ] && [ -z "$(GHC_PKG_QUICKCHECK)" ]; then \
497
	  echo "Error: cannot run unittests without the QuickCheck library (see devnotes.rst)" 1>&2; \
498
	  exit 1; \
499
	fi
500
	BINARY=$(@:htools/%=%); $(GHC) --make \
501
	  $(HFLAGS) \
502
	  $(HTOOLS_NOCURL) $(HTOOLS_PARALLEL3) \
503
	  -osuf $$BINARY.o -hisuf $$BINARY.hi \
504
	  $(HEXTRA) $@
505

    
506
# for the htools/test binary, we need to enable profiling/coverage
507
htools/test: HEXTRA=-fhpc -Wwarn -fno-warn-missing-signatures \
508
	-fno-warn-monomorphism-restriction -fno-warn-orphans \
509
	-fno-warn-missing-methods -fno-warn-unused-imports
510

    
511
dist_sbin_SCRIPTS = \
512
	tools/ganeti-listrunner
513

    
514
nodist_sbin_SCRIPTS = \
515
	$(PYTHON_BOOTSTRAP_SBIN) \
516
	daemons/ganeti-cleaner
517

    
518
dist_tools_PYTHON = \
519
	tools/burnin \
520
	tools/cfgshell \
521
	tools/cfgupgrade \
522
	tools/cfgupgrade12 \
523
	tools/cluster-merge \
524
	tools/confd-client \
525
	tools/lvmstrap \
526
	tools/move-instance \
527
	tools/ovfconverter \
528
	tools/setup-ssh \
529
	tools/sanitize-config
530

    
531
dist_tools_SCRIPTS = \
532
	$(dist_tools_PYTHON) \
533
	tools/kvm-console-wrapper \
534
	tools/xm-console-wrapper \
535
	tools/master-ip-setup
536

    
537
pkglib_python_scripts = \
538
	daemons/import-export \
539
	tools/check-cert-expired
540

    
541
nodist_pkglib_python_scripts = \
542
	tools/ensure-dirs
543

    
544
pkglib_SCRIPTS = \
545
	daemons/daemon-util \
546
	tools/kvm-ifup \
547
	$(pkglib_python_scripts)
548

    
549
nodist_pkglib_SCRIPTS = \
550
	$(nodist_pkglib_python_scripts)
551

    
552
EXTRA_DIST = \
553
	NEWS \
554
	UPGRADE \
555
	epydoc.conf.in \
556
	pylintrc \
557
	autotools/build-bash-completion \
558
	autotools/build-rpc \
559
	autotools/check-header \
560
	autotools/check-python-code \
561
	autotools/check-imports \
562
	autotools/check-man \
563
	autotools/check-news \
564
	autotools/check-tar \
565
	autotools/check-version \
566
	autotools/convert-constants \
567
	autotools/docpp \
568
	autotools/gen-coverage \
569
	autotools/testrunner \
570
	$(RUN_IN_TEMPDIR) \
571
	daemons/daemon-util.in \
572
	daemons/ganeti-cleaner.in \
573
	$(pkglib_python_scripts) \
574
	devel/upload.in \
575
	tools/kvm-ifup.in \
576
	$(docdot) \
577
	$(docpng) \
578
	$(docrst) \
579
	doc/conf.py \
580
	doc/html \
581
	$(BUILT_EXAMPLES:%=%.in) \
582
	doc/examples/ganeti.default \
583
	doc/examples/ganeti.default-debug \
584
	doc/examples/hooks/ethers \
585
	doc/examples/gnt-debug/README \
586
	doc/examples/gnt-debug/delay0.json \
587
	doc/examples/gnt-debug/delay50.json \
588
	test/testutils.py \
589
	test/mocks.py \
590
	$(dist_TESTS) \
591
	$(TEST_FILES) \
592
	man/footer.rst \
593
	$(manrst) \
594
	$(maninput) \
595
	qa/qa-sample.json \
596
	$(qa_scripts) \
597
	$(HS_LIB_SRCS) $(HS_BUILT_SRCS_IN) \
598
	$(HS_PROG_SRCS)
599

    
600
man_MANS = \
601
	man/ganeti.7 \
602
	man/ganeti-cleaner.8 \
603
	man/ganeti-confd.8 \
604
	man/ganeti-listrunner.8 \
605
	man/ganeti-masterd.8 \
606
	man/ganeti-noded.8 \
607
	man/ganeti-os-interface.7 \
608
	man/ganeti-rapi.8 \
609
	man/ganeti-watcher.8 \
610
	man/gnt-backup.8 \
611
	man/gnt-cluster.8 \
612
	man/gnt-debug.8 \
613
	man/gnt-group.8 \
614
	man/gnt-instance.8 \
615
	man/gnt-job.8 \
616
	man/gnt-node.8 \
617
	man/gnt-os.8 \
618
	man/hail.1 \
619
	man/hbal.1 \
620
	man/hscan.1 \
621
	man/hspace.1 \
622
	man/htools.1
623

    
624
manrst = $(patsubst %.1,%.rst,$(patsubst %.7,%.rst,$(patsubst %.8,%.rst,$(man_MANS))))
625
manhtml = $(patsubst %.rst,%.html,$(manrst))
626
mangen = $(patsubst %.rst,%.gen,$(manrst))
627
maninput = \
628
	$(patsubst %.1,%.1.in,$(patsubst %.7,%.7.in,$(patsubst %.8,%.8.in,$(man_MANS)))) \
629
	$(patsubst %.html,%.html.in,$(manhtml)) \
630
	man/footer.man man/footer.html $(mangen)
631

    
632
TEST_FILES = \
633
	test/data/bdev-drbd-8.0.txt \
634
	test/data/bdev-drbd-8.3.txt \
635
	test/data/bdev-drbd-disk.txt \
636
	test/data/bdev-drbd-net-ip4.txt \
637
	test/data/bdev-drbd-net-ip6.txt \
638
	test/data/cert1.pem \
639
	test/data/ip-addr-show-dummy0.txt \
640
	test/data/ip-addr-show-lo-ipv4.txt \
641
	test/data/ip-addr-show-lo-ipv6.txt \
642
	test/data/ip-addr-show-lo-oneline-ipv4.txt \
643
	test/data/ip-addr-show-lo-oneline-ipv6.txt \
644
	test/data/ip-addr-show-lo-oneline.txt \
645
	test/data/ip-addr-show-lo.txt \
646
	test/data/proc_drbd8.txt \
647
	test/data/proc_drbd80-emptyline.txt \
648
	test/data/proc_drbd83.txt \
649
	test/data/proc_drbd83_sync.txt \
650
	test/data/proc_drbd83_sync_krnl2.6.39.txt \
651
	test/data/sys_drbd_usermode_helper.txt \
652
	test/data/ovfdata/compr_disk.vmdk.gz \
653
	test/data/ovfdata/config.ini \
654
	test/data/ovfdata/corrupted_resources.ovf \
655
	test/data/ovfdata/empty.ini \
656
	test/data/ovfdata/empty.ovf \
657
	test/data/ovfdata/ganeti.mf \
658
	test/data/ovfdata/ganeti.ovf \
659
	test/data/ovfdata/gzip_disk.ovf \
660
	test/data/ovfdata/new_disk.vmdk \
661
	test/data/ovfdata/no_disk.ini \
662
	test/data/ovfdata/no_disk_in_ref.ovf \
663
	test/data/ovfdata/no_os.ini \
664
	test/data/ovfdata/no_ovf.ova \
665
	test/data/ovfdata/ova.ova \
666
	test/data/ovfdata/second_disk.vmdk \
667
	test/data/ovfdata/rawdisk.raw \
668
	test/data/ovfdata/unsafe_path.ini \
669
	test/data/ovfdata/virtualbox.ovf \
670
	test/data/ovfdata/wrong_extension.ovd \
671
	test/data/ovfdata/wrong_config.ini \
672
	test/data/ovfdata/wrong_manifest.mf \
673
	test/data/ovfdata/wrong_manifest.ovf \
674
	test/data/ovfdata/wrong_ova.ova \
675
	test/data/ovfdata/wrong_xml.ovf \
676
	test/data/ovfdata/other/rawdisk.raw \
677
	test/import-export_unittest-helper
678

    
679
python_tests = \
680
	test/ganeti.asyncnotifier_unittest.py \
681
	test/ganeti.backend_unittest.py \
682
	test/ganeti.bdev_unittest.py \
683
	test/ganeti.cli_unittest.py \
684
	test/ganeti.client.gnt_cluster_unittest.py \
685
	test/ganeti.client.gnt_instance_unittest.py \
686
	test/ganeti.daemon_unittest.py \
687
	test/ganeti.cmdlib_unittest.py \
688
	test/ganeti.compat_unittest.py \
689
	test/ganeti.confd.client_unittest.py \
690
	test/ganeti.config_unittest.py \
691
	test/ganeti.constants_unittest.py \
692
	test/ganeti.errors_unittest.py \
693
	test/ganeti.hooks_unittest.py \
694
	test/ganeti.ht_unittest.py \
695
	test/ganeti.http_unittest.py \
696
	test/ganeti.hypervisor_unittest.py \
697
	test/ganeti.hypervisor.hv_chroot_unittest.py \
698
	test/ganeti.hypervisor.hv_fake_unittest.py \
699
	test/ganeti.hypervisor.hv_kvm_unittest.py \
700
	test/ganeti.hypervisor.hv_lxc_unittest.py \
701
	test/ganeti.hypervisor.hv_xen_unittest.py \
702
	test/ganeti.impexpd_unittest.py \
703
	test/ganeti.jqueue_unittest.py \
704
	test/ganeti.locking_unittest.py \
705
	test/ganeti.luxi_unittest.py \
706
	test/ganeti.masterd.instance_unittest.py \
707
	test/ganeti.mcpu_unittest.py \
708
	test/ganeti.netutils_unittest.py \
709
	test/ganeti.objects_unittest.py \
710
	test/ganeti.opcodes_unittest.py \
711
	test/ganeti.ovf_unittest.py \
712
	test/ganeti.qlang_unittest.py \
713
	test/ganeti.query_unittest.py \
714
	test/ganeti.rapi.baserlib_unittest.py \
715
	test/ganeti.rapi.client_unittest.py \
716
	test/ganeti.rapi.resources_unittest.py \
717
	test/ganeti.rapi.rlib2_unittest.py \
718
	test/ganeti.rpc_unittest.py \
719
	test/ganeti.runtime_unittest.py \
720
	test/ganeti.serializer_unittest.py \
721
	test/ganeti.ssh_unittest.py \
722
	test/ganeti.tools.ensure_dirs_unittest.py \
723
	test/ganeti.uidpool_unittest.py \
724
	test/ganeti.utils.algo_unittest.py \
725
	test/ganeti.utils.filelock_unittest.py \
726
	test/ganeti.utils.hash_unittest.py \
727
	test/ganeti.utils.io_unittest.py \
728
	test/ganeti.utils.log_unittest.py \
729
	test/ganeti.utils.mlock_unittest.py \
730
	test/ganeti.utils.nodesetup_unittest.py \
731
	test/ganeti.utils.process_unittest.py \
732
	test/ganeti.utils.retry_unittest.py \
733
	test/ganeti.utils.text_unittest.py \
734
	test/ganeti.utils.wrapper_unittest.py \
735
	test/ganeti.utils.x509_unittest.py \
736
	test/ganeti.utils_unittest.py \
737
	test/ganeti.workerpool_unittest.py \
738
	test/cfgupgrade_unittest.py \
739
	test/docs_unittest.py \
740
	test/pycurl_reset_unittest.py \
741
	test/tempfile_fork_unittest.py
742

    
743
haskell_tests = htools/test
744

    
745
dist_TESTS = \
746
	test/check-cert-expired_unittest.bash \
747
	test/daemon-util_unittest.bash \
748
	test/ganeti-cleaner_unittest.bash \
749
	test/import-export_unittest.bash \
750
	$(python_tests)
751

    
752
nodist_TESTS =
753
if WANT_HTOOLSTESTS
754
nodist_TESTS += $(haskell_tests)
755
endif
756

    
757
TESTS = $(dist_TESTS) $(nodist_TESTS)
758

    
759
# Environment for all tests
760
PLAIN_TESTS_ENVIRONMENT = \
761
	PYTHONPATH=. TOP_SRCDIR=$(abs_top_srcdir) PYTHON=$(PYTHON) $(RUN_IN_TEMPDIR)
762

    
763
# Environment for tests run by automake
764
TESTS_ENVIRONMENT = \
765
	$(PLAIN_TESTS_ENVIRONMENT) $(abs_top_srcdir)/autotools/testrunner
766

    
767
all_python_code = \
768
	$(dist_sbin_SCRIPTS) \
769
	$(dist_tools_PYTHON) \
770
	$(pkglib_python_scripts) \
771
	$(nodist_pkglib_python_scripts) \
772
	$(python_tests) \
773
	$(pkgpython_PYTHON) \
774
	$(client_PYTHON) \
775
	$(hypervisor_PYTHON) \
776
	$(rapi_PYTHON) \
777
	$(server_PYTHON) \
778
	$(pytools_PYTHON) \
779
	$(http_PYTHON) \
780
	$(confd_PYTHON) \
781
	$(masterd_PYTHON) \
782
	$(impexpd_PYTHON) \
783
	$(utils_PYTHON) \
784
	$(watcher_PYTHON) \
785
	$(noinst_PYTHON) \
786
	$(qa_scripts)
787

    
788
srclink_files = \
789
	man/footer.rst \
790
	test/check-cert-expired_unittest.bash \
791
	test/daemon-util_unittest.bash \
792
	test/ganeti-cleaner_unittest.bash \
793
	test/import-export_unittest.bash \
794
	$(all_python_code) \
795
	$(HS_LIB_SRCS) $(HS_PROG_SRCS)
796

    
797
check_python_code = \
798
	$(BUILD_BASH_COMPLETION) \
799
	$(CHECK_IMPORTS) \
800
	$(CHECK_HEADER) \
801
	$(DOCPP) \
802
	$(all_python_code)
803

    
804
lint_python_code = \
805
	ganeti \
806
	ganeti/http/server.py \
807
	$(dist_sbin_SCRIPTS) \
808
	$(dist_tools_PYTHON) \
809
	$(pkglib_python_scripts) \
810
	$(BUILD_BASH_COMPLETION) \
811
	$(CHECK_IMPORTS) \
812
	$(CHECK_HEADER) \
813
	$(DOCPP) \
814
	$(PYTHON_BOOTSTRAP)
815

    
816
standalone_python_modules = \
817
	lib/rapi/client.py \
818
	tools/ganeti-listrunner
819

    
820
pep8_python_code = \
821
	ganeti \
822
	ganeti/http/server.py \
823
	$(dist_sbin_SCRIPTS) \
824
	$(dist_tools_PYTHON) \
825
	$(pkglib_python_scripts) \
826
	$(BUILD_BASH_COMPLETION) \
827
	$(CHECK_HEADER) \
828
	$(DOCPP) \
829
	$(PYTHON_BOOTSTRAP) \
830
	qa
831

    
832
test/daemon-util_unittest.bash: daemons/daemon-util
833

    
834
test/ganeti-cleaner_unittest.bash: daemons/ganeti-cleaner
835

    
836
tools/kvm-ifup: tools/kvm-ifup.in $(REPLACE_VARS_SED)
837
	sed -f $(REPLACE_VARS_SED) < $< > $@
838
	chmod +x $@
839

    
840
devel/upload: devel/upload.in $(REPLACE_VARS_SED)
841
	sed -f $(REPLACE_VARS_SED) < $< > $@
842
	chmod u+x $@
843

    
844
daemons/%: daemons/%.in $(REPLACE_VARS_SED)
845
	sed -f $(REPLACE_VARS_SED) < $< > $@
846
	chmod +x $@
847

    
848
doc/examples/%: doc/examples/%.in $(REPLACE_VARS_SED)
849
	sed -f $(REPLACE_VARS_SED) < $< > $@
850

    
851
doc/examples/hooks/%: doc/examples/hooks/%.in $(REPLACE_VARS_SED)
852
	sed -f $(REPLACE_VARS_SED) < $< > $@
853

    
854
doc/examples/bash_completion: $(BUILD_BASH_COMPLETION) $(RUN_IN_TEMPDIR) \
855
	lib/cli.py $(gnt_scripts) $(client_PYTHON) tools/burnin
856
	PYTHONPATH=. $(RUN_IN_TEMPDIR) $(CURDIR)/$(BUILD_BASH_COMPLETION) > $@
857

    
858
doc/%.png: doc/%.dot
859
	@test -n "$(DOT)" || { echo 'dot' not found during configure; exit 1; }
860
	$(DOT) -Tpng -o $@ $<
861

    
862
man/footer.man: man/footer.rst
863
	@test -n "$(PANDOC)" || \
864
	  { echo 'pandoc' not found during configure; exit 1; }
865
	$(PANDOC) -f rst -t man -o $@ $<
866

    
867
man/footer.html: man/footer.rst
868
	@test -n "$(PANDOC)" || \
869
	  { echo 'pandoc' not found during configure; exit 1; }
870
	$(PANDOC) -f rst -t html -o $@ $<
871

    
872
man/%.gen: man/%.rst lib/query.py lib/build/sphinx_ext.py
873
	PYTHONPATH=. $(RUN_IN_TEMPDIR) $(CURDIR)/$(DOCPP) < $< > $@
874

    
875
man/%.7.in man/%.8.in man/%.1.in: man/%.gen man/footer.man
876
	@test -n "$(PANDOC)" || \
877
	  { echo 'pandoc' not found during configure; exit 1; }
878
	set -o pipefail ; \
879
	$(PANDOC) -s -f rst -t man -A man/footer.man $< | \
880
	  sed -e 's/\\@/@/g' > $@
881
	if test -n "$(MAN_HAS_WARNINGS)"; then $(CHECK_MAN) $@; fi
882

    
883
man/%.html.in: man/%.gen man/footer.html
884
	@test -n "$(PANDOC)" || \
885
	  { echo 'pandoc' not found during configure; exit 1; }
886
	set -o pipefail ; \
887
	$(PANDOC) -s -f rst -t html -A man/footer.html $< | \
888
	  sed -e 's/\\@/@/g' > $@
889

    
890
man/%.1: man/%.1.in $(REPLACE_VARS_SED)
891
	sed -f $(REPLACE_VARS_SED) < $< > $@
892

    
893
man/%.7: man/%.7.in $(REPLACE_VARS_SED)
894
	sed -f $(REPLACE_VARS_SED) < $< > $@
895

    
896
man/%.8: man/%.8.in $(REPLACE_VARS_SED)
897
	sed -f $(REPLACE_VARS_SED) < $< > $@
898

    
899
man/%.html: man/%.html.in $(REPLACE_VARS_SED)
900
	sed -f $(REPLACE_VARS_SED) < $< > $@
901

    
902
epydoc.conf: epydoc.conf.in Makefile
903
	sed -e 's#@MODULES@#$(strip $(lint_python_code))#g' < $< > $@
904

    
905
vcs-version:
906
	if test -d .git; then \
907
	  git describe > $@; \
908
	elif test ! -f $@ ; then \
909
	  echo "Cannot auto-generate $@ file"; exit 1; \
910
	fi
911

    
912
.PHONY: regen-vcs-version
913
regen-vcs-version:
914
	set -e; \
915
	cd $(srcdir); \
916
	if test -d .git; then \
917
	  rm -f vcs-version; \
918
	  $(MAKE) vcs-version; \
919
	fi
920

    
921
htools/Ganeti/HTools/Version.hs: htools/Ganeti/HTools/Version.hs.in vcs-version
922
	set -e; \
923
	VCSVER=`cat $(abs_top_srcdir)/vcs-version`; \
924
	sed -e "s/%ver%/$$VCSVER/" < $< > $@
925

    
926
htools/Ganeti/Constants.hs: htools/Ganeti/Constants.hs.in \
927
	lib/constants.py lib/_autoconf.py $(CONVERT_CONSTANTS) \
928
	| lib/_vcsversion.py
929
	set -e; \
930
	{ cat $< ; PYTHONPATH=. $(CONVERT_CONSTANTS); } > $@
931

    
932
lib/_autoconf.py: Makefile | lib/.dir
933
	set -e; \
934
	{ echo '# This file is automatically generated, do not edit!'; \
935
	  echo '#'; \
936
	  echo ''; \
937
	  echo '"""Build-time configuration for Ganeti.'; \
938
	  echo '';\
939
	  echo 'This file is autogenerated by the build process.'; \
940
	  echo 'For any changes you need to re-run ./configure (and'; \
941
	  echo 'not edit by hand).'; \
942
	  echo ''; \
943
	  echo '"""'; \
944
	  echo ''; \
945
	  echo '# pylint: disable=C0301,C0324'; \
946
	  echo '# because this is autogenerated, we do not want'; \
947
	  echo '# style warnings' ; \
948
	  echo ''; \
949
	  echo "PACKAGE_VERSION = '$(PACKAGE_VERSION)'"; \
950
	  echo "VERSION_MAJOR = '$(VERSION_MAJOR)'"; \
951
	  echo "VERSION_MINOR = '$(VERSION_MINOR)'"; \
952
	  echo "VERSION_REVISION = '$(VERSION_REVISION)'"; \
953
	  echo "VERSION_SUFFIX = '$(VERSION_SUFFIX)'"; \
954
	  echo "VERSION_FULL = '$(VERSION_FULL)'"; \
955
	  echo "LOCALSTATEDIR = '$(localstatedir)'"; \
956
	  echo "SYSCONFDIR = '$(sysconfdir)'"; \
957
	  echo "SSH_CONFIG_DIR = '$(SSH_CONFIG_DIR)'"; \
958
	  echo "EXPORT_DIR = '$(EXPORT_DIR)'"; \
959
	  echo "OS_SEARCH_PATH = [$(OS_SEARCH_PATH)]"; \
960
	  echo "XEN_BOOTLOADER = '$(XEN_BOOTLOADER)'"; \
961
	  echo "XEN_KERNEL = '$(XEN_KERNEL)'"; \
962
	  echo "XEN_INITRD = '$(XEN_INITRD)'"; \
963
	  echo "FILE_STORAGE_DIR = '$(FILE_STORAGE_DIR)'"; \
964
	  echo "ENABLE_FILE_STORAGE = $(ENABLE_FILE_STORAGE)"; \
965
	  echo "SHARED_FILE_STORAGE_DIR = '$(SHARED_FILE_STORAGE_DIR)'"; \
966
	  echo "ENABLE_SHARED_FILE_STORAGE = $(ENABLE_SHARED_FILE_STORAGE)"; \
967
	  echo "IALLOCATOR_SEARCH_PATH = [$(IALLOCATOR_SEARCH_PATH)]"; \
968
	  echo "KVM_PATH = '$(KVM_PATH)'"; \
969
	  echo "IP_PATH = '$(IP_PATH)'"; \
970
	  echo "SOCAT_PATH = '$(SOCAT)'"; \
971
	  echo "SOCAT_USE_ESCAPE = $(SOCAT_USE_ESCAPE)"; \
972
	  echo "SOCAT_USE_COMPRESS = $(SOCAT_USE_COMPRESS)"; \
973
	  echo "LVM_STRIPECOUNT = $(LVM_STRIPECOUNT)"; \
974
	  echo "TOOLSDIR = '$(toolsdir)'"; \
975
	  echo "GNT_SCRIPTS = [$(foreach i,$(notdir $(gnt_scripts)),'$(i)',)]"; \
976
	  echo "PKGLIBDIR = '$(pkglibdir)'"; \
977
	  echo "DRBD_BARRIERS = '$(DRBD_BARRIERS)'"; \
978
	  echo "DRBD_NO_META_FLUSH = $(DRBD_NO_META_FLUSH)"; \
979
	  echo "SYSLOG_USAGE = '$(SYSLOG_USAGE)'"; \
980
	  echo "DAEMONS_GROUP = '$(DAEMONS_GROUP)'"; \
981
	  echo "ADMIN_GROUP = '$(ADMIN_GROUP)'"; \
982
	  echo "MASTERD_USER = '$(MASTERD_USER)'"; \
983
	  echo "MASTERD_GROUP = '$(MASTERD_GROUP)'"; \
984
	  echo "RAPI_USER = '$(RAPI_USER)'"; \
985
	  echo "RAPI_GROUP = '$(RAPI_GROUP)'"; \
986
	  echo "CONFD_USER = '$(CONFD_USER)'"; \
987
	  echo "CONFD_GROUP = '$(CONFD_GROUP)'"; \
988
	  echo "NODED_USER = '$(NODED_USER)'"; \
989
	  echo "NODED_GROUP = '$(NODED_GROUP)'"; \
990
	  echo "DISK_SEPARATOR = '$(DISK_SEPARATOR)'"; \
991
	  echo "QEMUIMG_PATH = '$(QEMUIMG_PATH)'"; \
992
	  if [ "$(HTOOLS)" ]; then \
993
	    echo "HTOOLS = True"; \
994
	  else \
995
	    echo "HTOOLS = False"; \
996
	  fi; \
997
	  echo "ENABLE_CONFD = $(ENABLE_CONFD)"; \
998
	} > $@
999

    
1000
lib/_vcsversion.py: Makefile vcs-version | lib/.dir
1001
	set -e; \
1002
	VCSVER=`cat $(abs_top_srcdir)/vcs-version`; \
1003
	{ echo '# This file is automatically generated, do not edit!'; \
1004
	  echo '#'; \
1005
	  echo ''; \
1006
	  echo '"""Build-time VCS version number for Ganeti.'; \
1007
	  echo '';\
1008
	  echo 'This file is autogenerated by the build process.'; \
1009
	  echo 'For any changes you need to re-run ./configure (and'; \
1010
	  echo 'not edit by hand).'; \
1011
	  echo ''; \
1012
	  echo '"""'; \
1013
	  echo ''; \
1014
	  echo '# pylint: disable=C0301,C0324'; \
1015
	  echo '# because this is autogenerated, we do not want'; \
1016
	  echo '# style warnings' ; \
1017
	  echo ''; \
1018
	  echo "VCS_VERSION = '$$VCSVER'"; \
1019
	} > $@
1020

    
1021
lib/_generated_rpc.py: lib/rpc_defs.py $(BUILD_RPC) | lib/.dir
1022
	PYTHONPATH=. $(RUN_IN_TEMPDIR) $(CURDIR)/$(BUILD_RPC) $< > $@
1023

    
1024
$(REPLACE_VARS_SED): Makefile
1025
	set -e; \
1026
	{ echo 's#@PREFIX@#$(prefix)#g'; \
1027
	  echo 's#@SYSCONFDIR@#$(sysconfdir)#g'; \
1028
	  echo 's#@LOCALSTATEDIR@#$(localstatedir)#g'; \
1029
	  echo 's#@BINDIR@#$(bindir)#g'; \
1030
	  echo 's#@SBINDIR@#$(sbindir)#g'; \
1031
	  echo 's#@GANETI_VERSION@#$(PACKAGE_VERSION)#g'; \
1032
	  echo 's#@CUSTOM_XEN_BOOTLOADER@#$(XEN_BOOTLOADER)#g'; \
1033
	  echo 's#@CUSTOM_XEN_KERNEL@#$(XEN_KERNEL)#g'; \
1034
	  echo 's#@CUSTOM_XEN_INITRD@#$(XEN_INITRD)#g'; \
1035
	  echo 's#@CUSTOM_IALLOCATOR_SEARCH_PATH@#$(IALLOCATOR_SEARCH_PATH)#g'; \
1036
	  echo 's#@CUSTOM_EXPORT_DIR@#$(EXPORT_DIR)#g'; \
1037
	  echo 's#@RPL_FILE_STORAGE_DIR@#$(FILE_STORAGE_DIR)#g'; \
1038
	  echo 's#@RPL_SSH_INITD_SCRIPT@#$(SSH_INITD_SCRIPT)#g'; \
1039
	  echo 's#@PKGLIBDIR@#$(pkglibdir)#g'; \
1040
	  echo 's#@GNTMASTERUSER@#$(MASTERD_USER)#g'; \
1041
	  echo 's#@GNTRAPIUSER@#$(RAPI_USER)#g'; \
1042
	  echo 's#@GNTCONFDUSER@#$(CONFD_USER)#g'; \
1043
	  echo 's#@GNTNODEDUSER@#$(NODED_USER)#g'; \
1044
	  echo 's#@GNTRAPIGROUP@#$(RAPI_GROUP)#g'; \
1045
	  echo 's#@GNTADMINGROUP@#$(ADMIN_GROUP)#g'; \
1046
	  echo 's#@GNTCONFDGROUP@#$(CONFD_GROUP)#g'; \
1047
	  echo 's#@GNTMASTERDGROUP@#$(MASTERD_GROUP)#g'; \
1048
	  echo 's#@GNTDAEMONSGROUP@#$(DAEMONS_GROUP)#g'; \
1049
	  echo 's#@CUSTOM_ENABLE_CONFD@#$(ENABLE_CONFD)#g'; \
1050
	} > $@
1051

    
1052
# Using deferred evaluation
1053
daemons/ganeti-%: MODULE = ganeti.server.$(patsubst ganeti-%,%,$(notdir $@))
1054
daemons/ganeti-watcher: MODULE = ganeti.watcher
1055
scripts/%: MODULE = ganeti.client.$(subst -,_,$(notdir $@))
1056
tools/ensure-dirs: MODULE = ganeti.tools.ensure_dirs
1057

    
1058
$(PYTHON_BOOTSTRAP): Makefile | $(all_dirfiles)
1059
	test -n "$(MODULE)" || { echo Missing module; exit 1; }
1060
	set -e; \
1061
	{ echo '#!/usr/bin/python'; \
1062
	  echo '# This file is automatically generated, do not edit!'; \
1063
	  echo "# Edit $(MODULE) instead."; \
1064
	  echo; \
1065
	  echo '"""Bootstrap script for L{$(MODULE)}"""'; \
1066
	  echo; \
1067
	  echo '# pylint: disable=C0103'; \
1068
	  echo '# C0103: Invalid name'; \
1069
	  echo; \
1070
	  echo 'import sys'; \
1071
	  echo 'import $(MODULE) as main'; \
1072
	  echo; \
1073
	  echo '# Temporarily alias commands until bash completion'; \
1074
	  echo '# generator is changed'; \
1075
	  echo 'if hasattr(main, "commands"):'; \
1076
	  echo '  commands = main.commands # pylint: disable=E1101'; \
1077
	  echo 'if hasattr(main, "aliases"):'; \
1078
	  echo '  aliases = main.aliases # pylint: disable=E1101'; \
1079
	  echo; \
1080
	  echo 'if __name__ == "__main__":'; \
1081
	  echo '  sys.exit(main.Main())'; \
1082
	} > $@
1083
	chmod u+x $@
1084

    
1085
# We need to create symlinks because "make distcheck" will not install Python
1086
# files when building.
1087
stamp-srclinks: Makefile | $(all_dirfiles)
1088
	set -e; \
1089
	for i in $(srclink_files); do \
1090
		if test ! -f $$i -a -f $(abs_top_srcdir)/$$i; then \
1091
			$(LN_S) $(abs_top_srcdir)/$$i $$i; \
1092
		fi; \
1093
	done
1094
	touch $@
1095

    
1096
.PHONY: ganeti
1097
ganeti:
1098
	cd $(top_builddir) && test -h "$@" || { rm -f $@ && $(LN_S) lib $@; }
1099

    
1100
.PHONY: check-dirs
1101
check-dirs: $(BUILT_SOURCES)
1102
	@set -e; \
1103
	find . -type d \( \( -name . \) -o \( \
1104
		-name .git -o \
1105
		-name autom4te.cache \
1106
		\) -prune -o -print \) | { \
1107
		error=; \
1108
		while read dir; do \
1109
			case "$$dir" in \
1110
				$(strip $(patsubst %,(./%) ;;,$(DIRCHECK_EXCLUDE) $(DIRS))) \
1111
				*) error=1; echo "Directory $$dir not listed in Makefile" >&2 ;; \
1112
			esac; \
1113
		done; \
1114
		for dir in $(DIRS); do \
1115
			if ! test -d "$$dir"; then \
1116
				echo "Directory $$dir listed in DIRS does not exist" >&2; \
1117
				error=1; \
1118
			fi \
1119
		done; \
1120
		if test -n "$$error"; then exit 1; else exit 0; fi; \
1121
	}
1122

    
1123
.PHONY: check-local
1124
check-local: check-dirs $(BUILT_SOURCES)
1125
	$(CHECK_PYTHON_CODE) $(check_python_code)
1126
	PYTHONPATH=. $(CHECK_HEADER) $(check_python_code)
1127
	$(CHECK_VERSION) $(VERSION) $(top_srcdir)/NEWS
1128
	$(CHECK_NEWS) < $(top_srcdir)/NEWS
1129
	PYTHONPATH=. $(RUN_IN_TEMPDIR) $(CURDIR)/$(CHECK_IMPORTS) . $(standalone_python_modules)
1130
	expver=$(VERSION_MAJOR).$(VERSION_MINOR); \
1131
	if test "`head -n 1 $(top_srcdir)/README`" != "Ganeti $$expver"; then \
1132
		echo "Incorrect version in README, expected $$expver"; \
1133
		exit 1; \
1134
	fi; \
1135
	for file in doc/iallocator.rst doc/hooks.rst; do \
1136
		if test "`sed -ne '4 p' $(top_srcdir)/$$file`" != \
1137
			"Documents Ganeti version $$expver"; then \
1138
			echo "Incorrect version in $$file, expected $$expver"; \
1139
			exit 1; \
1140
		fi; \
1141
	done
1142

    
1143
.PHONY: hs-check
1144
hs-check: htools/test
1145
	@rm -f test.tix
1146
	./htools/test
1147

    
1148
# E111: indentation is not a multiple of four
1149
# E261: at least two spaces before inline comment
1150
# E501: line too long (80 characters)
1151
PEP8_IGNORE = E111,E261,E501
1152

    
1153
# For excluding pep8 expects filenames only, not whole paths
1154
PEP8_EXCLUDE = $(subst $(space),$(comma),$(strip $(notdir $(BUILT_PYTHON_SOURCES))))
1155

    
1156
.PHONY: lint
1157
lint: $(BUILT_SOURCES)
1158
	@test -n "$(PYLINT)" || { echo 'pylint' not found during configure; exit 1; }
1159
	if test -z "$(PEP8)"; then \
1160
		echo '"pep8" not found during configure' >&2; \
1161
	else \
1162
		$(PEP8) --repeat --ignore='$(PEP8_IGNORE)' --exclude='$(PEP8_EXCLUDE)' \
1163
			$(pep8_python_code); \
1164
	fi
1165
	$(PYLINT) $(LINT_OPTS) $(lint_python_code)
1166
	cd $(top_srcdir)/qa && \
1167
	  PYTHONPATH=$(abs_top_srcdir) $(PYLINT) $(LINT_OPTS) \
1168
	  --rcfile  ../pylintrc $(patsubst qa/%.py,%,$(qa_scripts))
1169

    
1170
.PHONY: hlint
1171
hlint: $(HS_BUILT_SRCS)
1172
	if tty -s; then C="-c"; else C=""; fi; \
1173
	hlint --report=doc/hs-lint.html $$C htools
1174

    
1175
# a dist hook rule for updating the vcs-version file; this is
1176
# hardcoded due to where it needs to build the file...
1177
dist-hook:
1178
	$(MAKE) regen-vcs-version && \
1179
	rm -f $(top_distdir)/vcs-version && \
1180
	cp -p $(srcdir)/vcs-version $(top_distdir)
1181

    
1182
# a distcheck hook rule for catching revision control directories
1183
distcheck-hook:
1184
	if find $(top_distdir) -name .svn -or -name .git | grep .; then \
1185
		echo "Found revision control files in final archive." 1>&2; \
1186
		exit 1; \
1187
	fi
1188
	if find $(top_distdir) -name '*.py[co]' | grep .; then \
1189
		echo "Found Python byte code in final archive." 1>&2; \
1190
		exit 1; \
1191
	fi
1192
	if find $(top_distdir) -name '*~' | grep .; then \
1193
		echo "Found backup files in final archive." 1>&2; \
1194
		exit 1; \
1195
	fi
1196
# Empty files or directories should not be distributed. They can cause
1197
# unnecessary warnings for packagers. Directories used by automake during
1198
# distcheck must be excluded.
1199
	if find $(top_distdir) -empty -and -not \( \
1200
			-path $(top_distdir)/_build -or \
1201
			-path $(top_distdir)/_inst \) | grep .; then \
1202
		echo "Found empty files or directories in final archive." 1>&2; \
1203
		exit 1; \
1204
	fi
1205
	if test -n "$(BUILD_RELEASE)" && \
1206
	   grep -n -H -E '^\*.*unreleased' $(top_distdir)/NEWS; then \
1207
		echo "Found unreleased version in NEWS." >&2; \
1208
		exit 1; \
1209
	fi
1210

    
1211
# When building a release, stricter checks should be used
1212
distcheck-release dist-release: export BUILD_RELEASE = 1
1213
distcheck-release: distcheck
1214

    
1215
dist-release: dist
1216
	set -e; \
1217
	for i in $(DIST_ARCHIVES); do \
1218
		echo -n "Checking $$i ... "; \
1219
		autotools/check-tar < $$i; \
1220
		echo OK; \
1221
	done
1222

    
1223
install-exec-local:
1224
	@mkdir_p@ "$(DESTDIR)${localstatedir}/lib/ganeti" \
1225
	  "$(DESTDIR)${localstatedir}/log/ganeti" \
1226
	  "$(DESTDIR)${localstatedir}/run/ganeti"
1227

    
1228
# To avoid conflicts between directory names and other targets, a file inside
1229
# the directory is used to ensure its existence.
1230
%.dir:
1231
	@mkdir_p@ $* && touch $@
1232

    
1233
.PHONY: apidoc
1234
if WANT_HTOOLSAPIDOC
1235
apidoc: py-apidoc hs-apidoc
1236
else
1237
apidoc: py-apidoc
1238
endif
1239

    
1240
.PHONY: py-apidoc
1241
py-apidoc: epydoc.conf $(RUN_IN_TEMPDIR) $(BUILT_SOURCES)
1242
	$(RUN_IN_TEMPDIR) epydoc -v \
1243
		--conf $(CURDIR)/epydoc.conf \
1244
		--output $(CURDIR)/$(APIDOC_PY_DIR)
1245

    
1246
.PHONY: hs-apidoc
1247
hs-apidoc: $(HS_BUILT_SRCS)
1248
	@test -n "$(HSCOLOUR)" || \
1249
	    { echo 'HsColour' not found during configure; exit 1; }
1250
	@test -n "$(HADDOCK)" || \
1251
	    { echo 'haddock' not found during configure; exit 1; }
1252
	rm -rf $(APIDOC_HS_DIR)/*
1253
	@mkdir_p@ $(APIDOC_HS_DIR)/Ganeti/HTools/Program
1254
	$(HSCOLOUR) -print-css > $(APIDOC_HS_DIR)/Ganeti/hscolour.css
1255
	$(LN_S) ../hscolour.css $(APIDOC_HS_DIR)/Ganeti/HTools/hscolour.css
1256
	set -e ; \
1257
	cd htools; \
1258
	if [ "$(HTOOLS_NOCURL)" ]; \
1259
	then OPTGHC="--optghc=$(HTOOLS_NOCURL)"; \
1260
	else OPTGHC=""; \
1261
	fi; \
1262
	if [ "$(HTOOLS_PARALLEL3)" ]; \
1263
	then OPTGHC="$$OPTGHC --optghc=$(HTOOLS_PARALLEL3)"; \
1264
	fi; \
1265
	RELSRCS="$(HS_LIB_SRCS:htools/%=%)  $(HS_BUILT_SRCS:htools/%=%)"; \
1266
	for file in $$RELSRCS; do \
1267
		hfile=`echo $$file|sed 's/\\.hs$$//'`.html; \
1268
		$(HSCOLOUR) -css -anchor $$file > ../$(APIDOC_HS_DIR)/$$hfile ; \
1269
	done ; \
1270
	$(HADDOCK) --odir ../$(APIDOC_HS_DIR) --html --ignore-all-exports -w \
1271
		-t ganeti-htools -p haddock-prologue \
1272
		--source-module="%{MODULE/.//}.html" \
1273
		--source-entity="%{MODULE/.//}.html#%{NAME}" \
1274
		$$OPTGHC \
1275
		$(filter-out Ganeti/HTools/ExtLoader.hs,$(HS_LIB_SRCS:htools/%=%))
1276

    
1277
.PHONY: TAGS
1278
TAGS: $(BUILT_SOURCES)
1279
	rm -f TAGS
1280
	find . -path './lib/*.py' -o -path './scripts/gnt-*' -o \
1281
	  -path './daemons/ganeti-*' -o -path './tools/*' -o \
1282
	  -path './qa/*.py' | \
1283
	  etags -l python -
1284

    
1285
.PHONY: coverage
1286
if WANT_HTOOLS
1287
coverage: py-coverage hs-coverage
1288
else
1289
coverage: py-coverage
1290
endif
1291

    
1292
.PHONY: py-coverage
1293
py-coverage: $(BUILT_SOURCES) $(python_tests)
1294
	set -e; \
1295
	COVERAGE_FILE=$(CURDIR)/$(COVERAGE_PY_DIR)/data \
1296
	TEXT_COVERAGE=$(CURDIR)/$(COVERAGE_PY_DIR)/report.txt \
1297
	HTML_COVERAGE=$(CURDIR)/$(COVERAGE_PY_DIR) \
1298
	$(PLAIN_TESTS_ENVIRONMENT) $(abs_top_srcdir)/autotools/gen-coverage \
1299
	$(python_tests)
1300

    
1301
.PHONY: hs-coverage
1302
hs-coverage: $(haskell_tests)
1303
	cd htools && rm -f *.tix *.mix && ./test
1304
	@mkdir_p@ $(COVERAGE_HS_DIR)
1305
	hpc markup --destdir=$(COVERAGE_HS_DIR) htools/test $(HPCEXCL)
1306
	hpc report htools/test $(HPCEXCL)
1307
	$(LN_S) -f hpc_index.html $(COVERAGE_HS_DIR)/index.html
1308

    
1309
# Special "kind-of-QA" target for htools, needs special setup (all
1310
# tools compiled with -fhpc)
1311
.PHONY: live-test
1312
live-test: all
1313
	set -e ; \
1314
	cd htools; \
1315
	rm -f .hpc; $(LN_S) ../.hpc .hpc; \
1316
	rm -f *.tix *.mix; \
1317
	./live-test.sh; \
1318
	hpc sum --union $(HPCEXCL) $(addsuffix .tix,$(HS_PROGS:htools/%=%)) \
1319
	  --output=live-test.tix ; \
1320
	@mkdir_p@ ../$(COVERAGE_HS_DIR) ; \
1321
	hpc markup --destdir=../$(COVERAGE_HS_DIR) live-test \
1322
		--srcdir=.. $(HPCEXCL) ; \
1323
	hpc report --srcdir=.. live-test $(HPCEXCL)
1324

    
1325
commit-check: distcheck lint apidoc
1326

    
1327
-include ./Makefile.local
1328

    
1329
# vim: set noet :