Statistics
| Branch: | Tag: | Revision:

root / Makefile.am @ 70041061

History | View | Annotate | Download (37.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 = $(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
	autotools/testrunner \
141
	daemons/daemon-util \
142
	daemons/ganeti-cleaner \
143
	devel/upload \
144
	$(BUILT_EXAMPLES) \
145
	doc/examples/bash_completion \
146
	lib/_generated_rpc.py \
147
	$(man_MANS) \
148
	$(manhtml) \
149
	tools/kvm-ifup \
150
	stamp-srclinks \
151
	$(nodist_pkgpython_PYTHON) \
152
	$(HS_ALL_PROGS) $(HS_BUILT_SRCS) \
153
	.hpc/*.mix htools/*.tix \
154
	doc/hs-lint.html
155

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

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

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

    
178
nodist_pkgpython_PYTHON = \
179
	$(BUILT_PYTHON_SOURCES)
180

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
410
doc/html: doc/html/index.html
411

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

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

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

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

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

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

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

    
459
PYTHON_BOOTSTRAP = \
460
	$(PYTHON_BOOTSTRAP_SBIN) \
461
	tools/ensure-dirs
462

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

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

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

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

    
513
dist_sbin_SCRIPTS = \
514
	tools/ganeti-listrunner
515

    
516
nodist_sbin_SCRIPTS = \
517
	$(PYTHON_BOOTSTRAP_SBIN) \
518
	daemons/ganeti-cleaner
519

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

    
533
dist_tools_SCRIPTS = \
534
	$(python_scripts) \
535
	tools/kvm-console-wrapper \
536
	tools/xm-console-wrapper \
537
	tools/master-ip-setup
538

    
539
pkglib_python_scripts = \
540
	daemons/import-export \
541
	tools/check-cert-expired
542

    
543
nodist_pkglib_python_scripts = \
544
	tools/ensure-dirs
545

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

    
551
nodist_pkglib_SCRIPTS = \
552
	$(nodist_pkglib_python_scripts)
553

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

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

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

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

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

    
746
haskell_tests = htools/test
747

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

    
755
nodist_TESTS =
756
if WANT_HTOOLSTESTS
757
nodist_TESTS += $(haskell_tests)
758
endif
759

    
760
TESTS = $(dist_TESTS) $(nodist_TESTS)
761

    
762
# Environment for all tests
763
PLAIN_TESTS_ENVIRONMENT = \
764
	PYTHONPATH=. TOP_SRCDIR=$(abs_top_srcdir) PYTHON=$(PYTHON) $(RUN_IN_TEMPDIR)
765

    
766
# Environment for tests run by automake
767
TESTS_ENVIRONMENT = \
768
	$(PLAIN_TESTS_ENVIRONMENT) $(abs_top_srcdir)/autotools/testrunner
769

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

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

    
800
check_python_code = \
801
	$(BUILD_BASH_COMPLETION) \
802
	$(CHECK_IMPORTS) \
803
	$(CHECK_HEADER) \
804
	$(DOCPP) \
805
	$(all_python_code)
806

    
807
lint_python_code = \
808
	ganeti \
809
	ganeti/http/server.py \
810
	$(dist_sbin_SCRIPTS) \
811
	$(python_scripts) \
812
	$(pkglib_python_scripts) \
813
	$(BUILD_BASH_COMPLETION) \
814
	$(CHECK_IMPORTS) \
815
	$(CHECK_HEADER) \
816
	$(DOCPP) \
817
	$(PYTHON_BOOTSTRAP)
818

    
819
standalone_python_modules = \
820
	lib/rapi/client.py \
821
	tools/ganeti-listrunner
822

    
823
pep8_python_code = \
824
	ganeti \
825
	ganeti/http/server.py \
826
	$(dist_sbin_SCRIPTS) \
827
	$(python_scripts) \
828
	$(pkglib_python_scripts) \
829
	$(BUILD_BASH_COMPLETION) \
830
	$(CHECK_HEADER) \
831
	$(DOCPP) \
832
	$(PYTHON_BOOTSTRAP) \
833
	qa
834

    
835
test/daemon-util_unittest.bash: daemons/daemon-util
836

    
837
test/ganeti-cleaner_unittest.bash: daemons/ganeti-cleaner
838

    
839
tools/kvm-ifup: tools/kvm-ifup.in $(REPLACE_VARS_SED)
840
	sed -f $(REPLACE_VARS_SED) < $< > $@
841
	chmod +x $@
842

    
843
autotools/testrunner: autotools/testrunner.in $(REPLACE_VARS_SED)
844
	sed -f $(REPLACE_VARS_SED) < $< > $@
845
	chmod u+x $@
846

    
847
devel/upload: devel/upload.in $(REPLACE_VARS_SED)
848
	sed -f $(REPLACE_VARS_SED) < $< > $@
849
	chmod u+x $@
850

    
851
daemons/%: daemons/%.in $(REPLACE_VARS_SED)
852
	sed -f $(REPLACE_VARS_SED) < $< > $@
853
	chmod +x $@
854

    
855
doc/examples/%: doc/examples/%.in $(REPLACE_VARS_SED)
856
	sed -f $(REPLACE_VARS_SED) < $< > $@
857

    
858
doc/examples/hooks/%: doc/examples/hooks/%.in $(REPLACE_VARS_SED)
859
	sed -f $(REPLACE_VARS_SED) < $< > $@
860

    
861
doc/examples/bash_completion: $(BUILD_BASH_COMPLETION) $(RUN_IN_TEMPDIR) \
862
	lib/cli.py $(gnt_scripts) $(client_PYTHON) tools/burnin
863
	PYTHONPATH=. $(RUN_IN_TEMPDIR) $(CURDIR)/$(BUILD_BASH_COMPLETION) > $@
864

    
865
doc/%.png: doc/%.dot
866
	@test -n "$(DOT)" || { echo 'dot' not found during configure; exit 1; }
867
	$(DOT) -Tpng -o $@ $<
868

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

    
874
man/footer.html: man/footer.rst
875
	@test -n "$(PANDOC)" || \
876
	  { echo 'pandoc' not found during configure; exit 1; }
877
	$(PANDOC) -f rst -t html -o $@ $<
878

    
879
man/%.gen: man/%.rst lib/query.py lib/build/sphinx_ext.py
880
	PYTHONPATH=. $(RUN_IN_TEMPDIR) $(CURDIR)/$(DOCPP) < $< > $@
881

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

    
890
man/%.html.in: man/%.gen man/footer.html
891
	@test -n "$(PANDOC)" || \
892
	  { echo 'pandoc' not found during configure; exit 1; }
893
	set -o pipefail ; \
894
	$(PANDOC) -s -f rst -t html -A man/footer.html $< | \
895
	  sed -e 's/\\@/@/g' > $@
896

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

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

    
903
man/%.8: man/%.8.in $(REPLACE_VARS_SED)
904
	sed -f $(REPLACE_VARS_SED) < $< > $@
905

    
906
man/%.html: man/%.html.in $(REPLACE_VARS_SED)
907
	sed -f $(REPLACE_VARS_SED) < $< > $@
908

    
909
epydoc.conf: epydoc.conf.in Makefile
910
	sed -e 's#@MODULES@#$(strip $(lint_python_code))#g' < $< > $@
911

    
912
vcs-version:
913
	if test -d .git; then \
914
	  git describe > $@; \
915
	elif test ! -f $@ ; then \
916
	  echo "Cannot auto-generate $@ file"; exit 1; \
917
	fi
918

    
919
.PHONY: regen-vcs-version
920
regen-vcs-version:
921
	set -e; \
922
	cd $(srcdir); \
923
	if test -d .git; then \
924
	  rm -f vcs-version; \
925
	  $(MAKE) vcs-version; \
926
	fi
927

    
928
htools/Ganeti/HTools/Version.hs: htools/Ganeti/HTools/Version.hs.in vcs-version
929
	set -e; \
930
	VCSVER=`cat $(abs_top_srcdir)/vcs-version`; \
931
	sed -e "s/%ver%/$$VCSVER/" < $< > $@
932

    
933
htools/Ganeti/Constants.hs: htools/Ganeti/Constants.hs.in \
934
	lib/constants.py lib/_autoconf.py $(CONVERT_CONSTANTS) \
935
	| lib/_vcsversion.py
936
	set -e; \
937
	{ cat $< ; PYTHONPATH=. $(CONVERT_CONSTANTS); } > $@
938

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

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

    
1028
lib/_generated_rpc.py: lib/rpc_defs.py $(BUILD_RPC) | lib/.dir
1029
	PYTHONPATH=. $(RUN_IN_TEMPDIR) $(CURDIR)/$(BUILD_RPC) $< > $@
1030

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

    
1060
# Using deferred evaluation
1061
daemons/ganeti-%: MODULE = ganeti.server.$(patsubst ganeti-%,%,$(notdir $@))
1062
daemons/ganeti-watcher: MODULE = ganeti.watcher
1063
scripts/%: MODULE = ganeti.client.$(subst -,_,$(notdir $@))
1064
tools/ensure-dirs: MODULE = ganeti.tools.ensure_dirs
1065

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

    
1093
# We need to create symlinks because "make distcheck" will not install Python
1094
# files when building.
1095
stamp-srclinks: Makefile | $(all_dirfiles)
1096
	set -e; \
1097
	for i in $(srclink_files); do \
1098
		if test ! -f $$i -a -f $(abs_top_srcdir)/$$i; then \
1099
			$(LN_S) $(abs_top_srcdir)/$$i $$i; \
1100
		fi; \
1101
	done
1102
	touch $@
1103

    
1104
.PHONY: ganeti
1105
ganeti:
1106
	cd $(top_builddir) && test -h "$@" || { rm -f $@ && $(LN_S) lib $@; }
1107

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

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

    
1151
.PHONY: hs-check
1152
hs-check: htools/test
1153
	@rm -f test.tix
1154
	./htools/test
1155

    
1156
# E111: indentation is not a multiple of four
1157
# E261: at least two spaces before inline comment
1158
# E501: line too long (80 characters)
1159
PEP8_IGNORE = E111,E261,E501
1160

    
1161
# For excluding pep8 expects filenames only, not whole paths
1162
PEP8_EXCLUDE = $(subst $(space),$(comma),$(strip $(notdir $(BUILT_PYTHON_SOURCES))))
1163

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

    
1178
.PHONY: hlint
1179
hlint: $(HS_BUILT_SRCS) htools/lint-hints.hs
1180
	if tty -s; then C="-c"; else C=""; fi; \
1181
	hlint --report=doc/hs-lint.html --cross $$C \
1182
	  --ignore "Use first" \
1183
	  --ignore "Use comparing" \
1184
	  --ignore "Use on" \
1185
	  --ignore "Use Control.Exception.catch" \
1186
	  --ignore "Reduce duplication" \
1187
	  --hint htools/lint-hints \
1188
	  $(filter-out htools/Ganeti/THH.hs,$(HS_LIB_SRCS))
1189

    
1190
# a dist hook rule for updating the vcs-version file; this is
1191
# hardcoded due to where it needs to build the file...
1192
dist-hook:
1193
	$(MAKE) regen-vcs-version && \
1194
	rm -f $(top_distdir)/vcs-version && \
1195
	cp -p $(srcdir)/vcs-version $(top_distdir)
1196

    
1197
# a distcheck hook rule for catching revision control directories
1198
distcheck-hook:
1199
	if find $(top_distdir) -name .svn -or -name .git | grep .; then \
1200
		echo "Found revision control files in final archive." 1>&2; \
1201
		exit 1; \
1202
	fi
1203
	if find $(top_distdir) -name '*.py[co]' | grep .; then \
1204
		echo "Found Python byte code in final archive." 1>&2; \
1205
		exit 1; \
1206
	fi
1207
	if find $(top_distdir) -name '*~' | grep .; then \
1208
		echo "Found backup files in final archive." 1>&2; \
1209
		exit 1; \
1210
	fi
1211
# Empty files or directories should not be distributed. They can cause
1212
# unnecessary warnings for packagers. Directories used by automake during
1213
# distcheck must be excluded.
1214
	if find $(top_distdir) -empty -and -not \( \
1215
			-path $(top_distdir)/_build -or \
1216
			-path $(top_distdir)/_inst \) | grep .; then \
1217
		echo "Found empty files or directories in final archive." 1>&2; \
1218
		exit 1; \
1219
	fi
1220
	if test -n "$(BUILD_RELEASE)" && \
1221
	   grep -n -H -E '^\*.*unreleased' $(top_distdir)/NEWS; then \
1222
		echo "Found unreleased version in NEWS." >&2; \
1223
		exit 1; \
1224
	fi
1225

    
1226
# When building a release, stricter checks should be used
1227
distcheck-release dist-release: export BUILD_RELEASE = 1
1228
distcheck-release: distcheck
1229

    
1230
dist-release: dist
1231
	set -e; \
1232
	for i in $(DIST_ARCHIVES); do \
1233
		echo -n "Checking $$i ... "; \
1234
		autotools/check-tar < $$i; \
1235
		echo OK; \
1236
	done
1237

    
1238
install-exec-local:
1239
	@mkdir_p@ "$(DESTDIR)${localstatedir}/lib/ganeti" \
1240
	  "$(DESTDIR)${localstatedir}/log/ganeti" \
1241
	  "$(DESTDIR)${localstatedir}/run/ganeti"
1242

    
1243
# To avoid conflicts between directory names and other targets, a file inside
1244
# the directory is used to ensure its existence.
1245
%.dir:
1246
	@mkdir_p@ $* && touch $@
1247

    
1248
.PHONY: apidoc
1249
if WANT_HTOOLSAPIDOC
1250
apidoc: py-apidoc hs-apidoc
1251
else
1252
apidoc: py-apidoc
1253
endif
1254

    
1255
.PHONY: py-apidoc
1256
py-apidoc: epydoc.conf $(RUN_IN_TEMPDIR) $(BUILT_SOURCES)
1257
	$(RUN_IN_TEMPDIR) epydoc -v \
1258
		--conf $(CURDIR)/epydoc.conf \
1259
		--output $(CURDIR)/$(APIDOC_PY_DIR)
1260

    
1261
.PHONY: hs-apidoc
1262
hs-apidoc: $(HS_BUILT_SRCS)
1263
	@test -n "$(HSCOLOUR)" || \
1264
	    { echo 'HsColour' not found during configure; exit 1; }
1265
	@test -n "$(HADDOCK)" || \
1266
	    { echo 'haddock' not found during configure; exit 1; }
1267
	rm -rf $(APIDOC_HS_DIR)/*
1268
	@mkdir_p@ $(APIDOC_HS_DIR)/Ganeti/HTools/Program
1269
	$(HSCOLOUR) -print-css > $(APIDOC_HS_DIR)/Ganeti/hscolour.css
1270
	$(LN_S) ../hscolour.css $(APIDOC_HS_DIR)/Ganeti/HTools/hscolour.css
1271
	set -e ; \
1272
	cd htools; \
1273
	if [ "$(HTOOLS_NOCURL)" ]; \
1274
	then OPTGHC="--optghc=$(HTOOLS_NOCURL)"; \
1275
	else OPTGHC=""; \
1276
	fi; \
1277
	if [ "$(HTOOLS_PARALLEL3)" ]; \
1278
	then OPTGHC="$$OPTGHC --optghc=$(HTOOLS_PARALLEL3)"; \
1279
	fi; \
1280
	RELSRCS="$(HS_LIB_SRCS:htools/%=%)  $(HS_BUILT_SRCS:htools/%=%)"; \
1281
	for file in $$RELSRCS; do \
1282
		hfile=`echo $$file|sed 's/\\.hs$$//'`.html; \
1283
		$(HSCOLOUR) -css -anchor $$file > ../$(APIDOC_HS_DIR)/$$hfile ; \
1284
	done ; \
1285
	$(HADDOCK) --odir ../$(APIDOC_HS_DIR) --html --ignore-all-exports -w \
1286
		-t ganeti-htools -p haddock-prologue \
1287
		--source-module="%{MODULE/.//}.html" \
1288
		--source-entity="%{MODULE/.//}.html#%{NAME}" \
1289
		$$OPTGHC \
1290
		$(filter-out Ganeti/HTools/ExtLoader.hs,$(HS_LIB_SRCS:htools/%=%))
1291

    
1292
.PHONY: TAGS
1293
TAGS: $(BUILT_SOURCES)
1294
	rm -f TAGS
1295
	find . -path './lib/*.py' -o -path './scripts/gnt-*' -o \
1296
	  -path './daemons/ganeti-*' -o -path './tools/*' -o \
1297
	  -path './qa/*.py' | \
1298
	  etags -l python -
1299

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

    
1307
.PHONY: py-coverage
1308
py-coverage: $(BUILT_SOURCES) $(python_tests)
1309
	set -e; \
1310
	COVERAGE_FILE=$(CURDIR)/$(COVERAGE_PY_DIR)/data \
1311
	TEXT_COVERAGE=$(CURDIR)/$(COVERAGE_PY_DIR)/report.txt \
1312
	HTML_COVERAGE=$(CURDIR)/$(COVERAGE_PY_DIR) \
1313
	$(PLAIN_TESTS_ENVIRONMENT) $(abs_top_srcdir)/autotools/gen-coverage \
1314
	$(python_tests)
1315

    
1316
.PHONY: hs-coverage
1317
hs-coverage: $(haskell_tests)
1318
	cd htools && rm -f *.tix *.mix && ./test
1319
	@mkdir_p@ $(COVERAGE_HS_DIR)
1320
	hpc markup --destdir=$(COVERAGE_HS_DIR) htools/test $(HPCEXCL)
1321
	hpc report htools/test $(HPCEXCL)
1322
	$(LN_S) -f hpc_index.html $(COVERAGE_HS_DIR)/index.html
1323

    
1324
# Special "kind-of-QA" target for htools, needs special setup (all
1325
# tools compiled with -fhpc)
1326
.PHONY: live-test
1327
live-test: all
1328
	set -e ; \
1329
	cd htools; \
1330
	rm -f .hpc; $(LN_S) ../.hpc .hpc; \
1331
	rm -f *.tix *.mix; \
1332
	./live-test.sh; \
1333
	hpc sum --union $(HPCEXCL) $(addsuffix .tix,$(HS_PROGS:htools/%=%)) \
1334
	  --output=live-test.tix ; \
1335
	@mkdir_p@ ../$(COVERAGE_HS_DIR) ; \
1336
	hpc markup --destdir=../$(COVERAGE_HS_DIR) live-test \
1337
		--srcdir=.. $(HPCEXCL) ; \
1338
	hpc report --srcdir=.. live-test $(HPCEXCL)
1339

    
1340
commit-check: distcheck lint apidoc
1341

    
1342
-include ./Makefile.local
1343

    
1344
# vim: set noet :