Statistics
| Branch: | Tag: | Revision:

root / Makefile.am @ 08366664

History | View | Annotate | Download (34.6 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_MAN = $(top_srcdir)/autotools/check-man
25
CHECK_VERSION = $(top_srcdir)/autotools/check-version
26
CHECK_NEWS = $(top_srcdir)/autotools/check-news
27
DOCPP = $(top_srcdir)/autotools/docpp
28
REPLACE_VARS_SED = autotools/replace_vars.sed
29
CONVERT_CONSTANTS = $(top_srcdir)/autotools/convert-constants
30

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

    
48
# Delete output file if an error occurred while building it
49
.DELETE_ON_ERROR:
50

    
51
HTOOLS_DIRS = \
52
	htools \
53
	htools/Ganeti \
54
	htools/Ganeti/HTools \
55
	htools/Ganeti/HTools/Program
56

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

    
85
BUILDTIME_DIR_AUTOCREATE = \
86
	scripts \
87
	$(APIDOC_DIR) \
88
	$(APIDOC_PY_DIR) \
89
	$(APIDOC_HS_DIR) \
90
	$(APIDOC_HS_DIR)/Ganeti $(APIDOC_HS_DIR)/Ganeti/HTools \
91
	$(APIDOC_HS_DIR)/Ganeti/HTools/Program \
92
	$(COVERAGE_DIR) \
93
	$(COVERAGE_PY_DIR) \
94
	$(COVERAGE_HS_DIR) \
95
	.hpc
96

    
97
BUILDTIME_DIRS = \
98
	$(BUILDTIME_DIR_AUTOCREATE) \
99
	doc/html
100

    
101
DIRCHECK_EXCLUDE = \
102
	$(BUILDTIME_DIRS) \
103
	ganeti-[0-9]*.[0-9]*.[0-9]* \
104
	doc/html/_*
105

    
106
all_dirfiles = $(addsuffix /.dir,$(DIRS) $(BUILDTIME_DIR_AUTOCREATE))
107

    
108
# some helper vars
109
COVERAGE_DIR = doc/coverage
110
COVERAGE_PY_DIR = $(COVERAGE_DIR)/py
111
COVERAGE_HS_DIR = $(COVERAGE_DIR)/hs
112
APIDOC_DIR = doc/api
113
APIDOC_PY_DIR = $(APIDOC_DIR)/py
114
APIDOC_HS_DIR = $(APIDOC_DIR)/hs
115

    
116
MAINTAINERCLEANFILES = \
117
	$(docpng) \
118
	$(maninput) \
119
	doc/install-quick.rst \
120
	doc/news.rst \
121
	doc/upgrade.rst \
122
	vcs-version
123

    
124
maintainer-clean-local:
125
	rm -rf $(BUILDTIME_DIRS)
126

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

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

    
162
BUILT_PYTHON_SOURCES = \
163
	lib/_autoconf.py \
164
	lib/_vcsversion.py
165

    
166
nodist_pkgpython_PYTHON = \
167
	$(BUILT_PYTHON_SOURCES)
168

    
169
noinst_PYTHON = \
170
	lib/build/__init__.py \
171
	lib/build/sphinx_ext.py
172

    
173
pkgpython_PYTHON = \
174
	lib/__init__.py \
175
	lib/asyncnotifier.py \
176
	lib/backend.py \
177
	lib/bdev.py \
178
	lib/bootstrap.py \
179
	lib/cli.py \
180
	lib/cmdlib.py \
181
	lib/compat.py \
182
	lib/config.py \
183
	lib/constants.py \
184
	lib/daemon.py \
185
	lib/errors.py \
186
	lib/ht.py \
187
	lib/jqueue.py \
188
	lib/jstore.py \
189
	lib/locking.py \
190
	lib/luxi.py \
191
	lib/mcpu.py \
192
	lib/netutils.py \
193
	lib/objects.py \
194
	lib/opcodes.py \
195
	lib/qlang.py \
196
	lib/query.py \
197
	lib/rpc.py \
198
	lib/runtime.py \
199
	lib/serializer.py \
200
	lib/ssconf.py \
201
	lib/ssh.py \
202
	lib/storage.py \
203
	lib/uidpool.py \
204
	lib/workerpool.py
205

    
206
client_PYTHON = \
207
	lib/client/__init__.py \
208
	lib/client/gnt_backup.py \
209
	lib/client/gnt_cluster.py \
210
	lib/client/gnt_debug.py \
211
	lib/client/gnt_group.py \
212
	lib/client/gnt_instance.py \
213
	lib/client/gnt_job.py \
214
	lib/client/gnt_node.py \
215
	lib/client/gnt_os.py
216

    
217
hypervisor_PYTHON = \
218
	lib/hypervisor/__init__.py \
219
	lib/hypervisor/hv_base.py \
220
	lib/hypervisor/hv_chroot.py \
221
	lib/hypervisor/hv_fake.py \
222
	lib/hypervisor/hv_kvm.py \
223
	lib/hypervisor/hv_lxc.py \
224
	lib/hypervisor/hv_xen.py
225

    
226
rapi_PYTHON = \
227
	lib/rapi/__init__.py \
228
	lib/rapi/baserlib.py \
229
	lib/rapi/client.py \
230
	lib/rapi/client_utils.py \
231
	lib/rapi/connector.py \
232
	lib/rapi/rlib2.py
233

    
234
http_PYTHON = \
235
	lib/http/__init__.py \
236
	lib/http/auth.py \
237
	lib/http/client.py \
238
	lib/http/server.py
239

    
240
confd_PYTHON = \
241
	lib/confd/__init__.py \
242
	lib/confd/client.py \
243
	lib/confd/querylib.py \
244
	lib/confd/server.py
245

    
246
masterd_PYTHON = \
247
	lib/masterd/__init__.py \
248
	lib/masterd/instance.py
249

    
250
impexpd_PYTHON = \
251
	lib/impexpd/__init__.py
252

    
253
watcher_PYTHON = \
254
	lib/watcher/__init__.py \
255
	lib/watcher/nodemaint.py \
256
	lib/watcher/state.py
257

    
258
server_PYTHON = \
259
	lib/server/__init__.py \
260
	lib/server/confd.py \
261
	lib/server/masterd.py \
262
	lib/server/noded.py \
263
	lib/server/rapi.py
264

    
265
pytools_PYTHON = \
266
	lib/tools/__init__.py \
267
	lib/tools/ensure_dirs.py
268

    
269
utils_PYTHON = \
270
	lib/utils/__init__.py \
271
	lib/utils/algo.py \
272
	lib/utils/filelock.py \
273
	lib/utils/hash.py \
274
	lib/utils/io.py \
275
	lib/utils/log.py \
276
	lib/utils/mlock.py \
277
	lib/utils/nodesetup.py \
278
	lib/utils/process.py \
279
	lib/utils/retry.py \
280
	lib/utils/text.py \
281
	lib/utils/wrapper.py \
282
	lib/utils/x509.py
283

    
284
docrst = \
285
	doc/admin.rst \
286
	doc/design-2.0.rst \
287
	doc/design-2.1.rst \
288
	doc/design-2.2.rst \
289
	doc/design-2.3.rst \
290
	doc/design-htools-2.3.rst \
291
	doc/design-2.4.rst \
292
	doc/design-2.5.rst \
293
	doc/design-draft.rst \
294
	doc/design-oob.rst \
295
	doc/design-cpu-pinning.rst \
296
	doc/design-query2.rst \
297
	doc/design-x509-ca.rst \
298
	doc/design-http-server.rst \
299
	doc/design-impexp2.rst \
300
	doc/design-lu-generated-jobs.rst \
301
	doc/design-multi-reloc.rst \
302
	doc/design-network.rst \
303
	doc/design-chained-jobs.rst \
304
	doc/design-ovf-support.rst \
305
	doc/cluster-merge.rst \
306
	doc/design-shared-storage.rst \
307
	doc/devnotes.rst \
308
	doc/glossary.rst \
309
	doc/hooks.rst \
310
	doc/iallocator.rst \
311
	doc/index.rst \
312
	doc/install-quick.rst \
313
	doc/install.rst \
314
	doc/locking.rst \
315
	doc/move-instance.rst \
316
	doc/news.rst \
317
	doc/rapi.rst \
318
	doc/security.rst \
319
	doc/upgrade.rst \
320
	doc/walkthrough.rst
321

    
322
HS_PROGS = htools/htools
323
HS_BIN_ROLES = hbal hscan hspace
324

    
325
HS_ALL_PROGS = $(HS_PROGS) htools/test
326
HS_PROG_SRCS = $(patsubst %,%.hs,$(HS_ALL_PROGS))
327
# we don't add -Werror by default
328
HFLAGS = -O -Wall -fwarn-monomorphism-restriction -fwarn-tabs -ihtools
329
# extra flags that can be overriden on the command line
330
HEXTRA =
331
# exclude options for coverage reports
332
HPCEXCL = --exclude Main --exclude Ganeti.HTools.QC \
333
	--exclude Ganeti.Constants \
334
	--exclude Ganeti.HTools.Version
335

    
336
HS_LIB_SRCS = \
337
	htools/Ganeti/HTools/CLI.hs \
338
	htools/Ganeti/HTools/Cluster.hs \
339
	htools/Ganeti/HTools/Compat.hs \
340
	htools/Ganeti/HTools/Container.hs \
341
	htools/Ganeti/HTools/ExtLoader.hs \
342
	htools/Ganeti/HTools/Group.hs \
343
	htools/Ganeti/HTools/IAlloc.hs \
344
	htools/Ganeti/HTools/Instance.hs \
345
	htools/Ganeti/HTools/Loader.hs \
346
	htools/Ganeti/HTools/Luxi.hs \
347
	htools/Ganeti/HTools/Node.hs \
348
	htools/Ganeti/HTools/PeerMap.hs \
349
	htools/Ganeti/HTools/QC.hs \
350
	htools/Ganeti/HTools/Rapi.hs \
351
	htools/Ganeti/HTools/Simu.hs \
352
	htools/Ganeti/HTools/Text.hs \
353
	htools/Ganeti/HTools/Types.hs \
354
	htools/Ganeti/HTools/Utils.hs \
355
	htools/Ganeti/HTools/Program/Hail.hs \
356
	htools/Ganeti/HTools/Program/Hbal.hs \
357
	htools/Ganeti/HTools/Program/Hscan.hs \
358
	htools/Ganeti/HTools/Program/Hspace.hs \
359
	htools/Ganeti/Jobs.hs \
360
	htools/Ganeti/Luxi.hs \
361
	htools/Ganeti/OpCodes.hs
362

    
363
HS_BUILT_SRCS = htools/Ganeti/HTools/Version.hs htools/Ganeti/Constants.hs
364
HS_BUILT_SRCS_IN = $(patsubst %,%.in,$(HS_BUILT_SRCS))
365

    
366
$(RUN_IN_TEMPDIR): | $(all_dirfiles)
367

    
368
# Note: we use here an order-only prerequisite, as the contents of
369
# _autoconf.py are not actually influencing the html build output: it
370
# has to exist in order for the sphinx module to be loaded
371
# successfully, but we certainly don't want the docs to be rebuilt if
372
# it changes
373
doc/html/index.html: $(docrst) $(docpng) doc/conf.py configure.ac \
374
	$(RUN_IN_TEMPDIR) lib/build/sphinx_ext.py lib/opcodes.py lib/ht.py \
375
	| $(BUILT_PYTHON_SOURCES)
376
	@test -n "$(SPHINX)" || \
377
	    { echo 'sphinx-build' not found during configure; exit 1; }
378
	@mkdir_p@ $(dir $@)
379
	PYTHONPATH=. $(RUN_IN_TEMPDIR) $(SPHINX) -q -W -b html \
380
	    -d . \
381
	    -D version="$(VERSION_MAJOR).$(VERSION_MINOR)" \
382
	    -D release="$(PACKAGE_VERSION)" \
383
	    $(abs_top_srcdir)/doc $(CURDIR)/doc/html
384
	rm -f doc/html/.buildinfo doc/html/objects.inv
385
	touch $@
386

    
387
doc/html: doc/html/index.html
388

    
389
doc/install-quick.rst: INSTALL
390
doc/news.rst: NEWS
391
doc/upgrade.rst: UPGRADE
392

    
393
doc/install-quick.rst doc/news.rst doc/upgrade.rst:
394
	set -e; \
395
	{ echo '.. This file is automatically updated at build time from $<.'; \
396
	  echo '.. Do not edit.'; \
397
	  echo; \
398
	  cat $<; \
399
	} > $@
400

    
401
docdot = \
402
	doc/arch-2.0.dot \
403
	doc/design-2.1-lock-acquire.dot \
404
	doc/design-2.1-lock-release.dot
405

    
406
docpng = $(patsubst %.dot,%.png,$(docdot))
407

    
408
# Things to build but not to install (add it to EXTRA_DIST if it should be
409
# distributed)
410
noinst_DATA = \
411
	devel/upload \
412
	doc/html \
413
	doc/examples/bash_completion \
414
	doc/examples/ganeti.cron \
415
	doc/examples/ganeti.initd \
416
	doc/examples/ganeti-kvm-poweroff.initd \
417
	doc/examples/gnt-config-backup \
418
	doc/examples/hooks/ipsec \
419
	$(manhtml)
420

    
421
gnt_scripts = \
422
	scripts/gnt-backup \
423
	scripts/gnt-cluster \
424
	scripts/gnt-debug \
425
	scripts/gnt-group \
426
	scripts/gnt-instance \
427
	scripts/gnt-job \
428
	scripts/gnt-node \
429
	scripts/gnt-os
430

    
431
PYTHON_BOOTSTRAP_SBIN = \
432
	daemons/ganeti-confd \
433
	daemons/ganeti-masterd \
434
	daemons/ganeti-noded \
435
	daemons/ganeti-watcher \
436
	daemons/ganeti-rapi \
437
	scripts/gnt-backup \
438
	scripts/gnt-cluster \
439
	scripts/gnt-debug \
440
	scripts/gnt-group \
441
	scripts/gnt-instance \
442
	scripts/gnt-job \
443
	scripts/gnt-node \
444
	scripts/gnt-os
445

    
446
PYTHON_BOOTSTRAP = \
447
	$(PYTHON_BOOTSTRAP_SBIN) \
448
	tools/ensure-dirs
449

    
450
qa_scripts = \
451
	qa/ganeti-qa.py \
452
	qa/qa_cluster.py \
453
	qa/qa_config.py \
454
	qa/qa_daemon.py \
455
	qa/qa_env.py \
456
	qa/qa_error.py \
457
	qa/qa_instance.py \
458
	qa/qa_node.py \
459
	qa/qa_os.py \
460
	qa/qa_rapi.py \
461
	qa/qa_tags.py \
462
	qa/qa_utils.py
463

    
464
bin_SCRIPTS =
465
if WANT_HTOOLS
466
bin_SCRIPTS += $(filter-out htools/hail,$(HS_PROGS))
467
install-exec-hook:
468
	@mkdir_p@ $(DESTDIR)$(iallocatorsdir)
469
# FIXME: this is a hardcoded logic, instead of auto-resolving
470
	$(LN_S) -f ../../../bin/htools \
471
		   $(DESTDIR)$(iallocatorsdir)/hail
472
	for role in $(HS_BIN_ROLES); do \
473
		$(LN_S) -f htools \
474
			   $(DESTDIR)$(bindir)/$$role ; \
475
	done
476
endif
477

    
478
$(HS_ALL_PROGS): %: %.hs $(HS_LIB_SRCS) $(HS_BUILT_SRCS) Makefile
479
	@if [ -z "$(HTOOLS)" ]; then \
480
	  echo "Error: htools compilation disabled at configure time" 1>&2 ;\
481
	  exit 1; \
482
	fi
483
	@BINARY=$(@:htools/%=%); \
484
	if [ "$BINARY" = "test" ] && [ -z "$(GHC_PKG_QUICKCHECK)" ]; then \
485
	  echo "Error: cannot run unittests without the QuickCheck library (see devnotes.rst)" 1>&2; \
486
	  exit 1; \
487
	fi
488
	BINARY=$(@:htools/%=%); $(GHC) --make \
489
	  $(HFLAGS) $(HEXTRA) \
490
	  $(HTOOLS_NOCURL) $(HTOOLS_PARALLEL3) \
491
	  -osuf $$BINARY.o -hisuf $$BINARY.hi $@
492

    
493
# for the htools/test binary, we need to enable profiling/coverage
494
htools/test: HEXTRA=-fhpc -Wwarn -fno-warn-missing-signatures \
495
	-fno-warn-monomorphism-restriction -fno-warn-orphans \
496
	-fno-warn-missing-methods -fno-warn-unused-imports
497

    
498
dist_sbin_SCRIPTS = \
499
	tools/ganeti-listrunner
500

    
501
nodist_sbin_SCRIPTS = \
502
	$(PYTHON_BOOTSTRAP_SBIN) \
503
	daemons/ganeti-cleaner
504

    
505
dist_tools_PYTHON = \
506
	tools/burnin \
507
	tools/cfgshell \
508
	tools/cfgupgrade \
509
	tools/cfgupgrade12 \
510
	tools/cluster-merge \
511
	tools/lvmstrap \
512
	tools/move-instance \
513
	tools/setup-ssh \
514
	tools/sanitize-config
515

    
516
dist_tools_SCRIPTS = \
517
	$(dist_tools_PYTHON) \
518
	tools/kvm-console-wrapper \
519
	tools/xm-console-wrapper
520

    
521
pkglib_python_scripts = \
522
	daemons/import-export \
523
	tools/check-cert-expired
524

    
525
nodist_pkglib_python_scripts = \
526
	tools/ensure-dirs
527

    
528
pkglib_SCRIPTS = \
529
	daemons/daemon-util \
530
	tools/kvm-ifup \
531
	$(pkglib_python_scripts)
532

    
533
nodist_pkglib_SCRIPTS = \
534
	$(nodist_pkglib_python_scripts)
535

    
536
EXTRA_DIST = \
537
	NEWS \
538
	UPGRADE \
539
	epydoc.conf.in \
540
	pylintrc \
541
	autotools/build-bash-completion \
542
	autotools/check-python-code \
543
	autotools/check-man \
544
	autotools/check-news \
545
	autotools/check-tar \
546
	autotools/check-version \
547
	autotools/convert-constants \
548
	autotools/docpp \
549
	autotools/gen-coverage \
550
	autotools/testrunner \
551
	$(RUN_IN_TEMPDIR) \
552
	daemons/daemon-util.in \
553
	daemons/ganeti-cleaner.in \
554
	$(pkglib_python_scripts) \
555
	devel/upload.in \
556
	tools/kvm-ifup.in \
557
	$(docdot) \
558
	$(docpng) \
559
	$(docrst) \
560
	doc/conf.py \
561
	doc/html \
562
	doc/examples/ganeti.initd.in \
563
	doc/examples/ganeti-kvm-poweroff.initd.in \
564
	doc/examples/ganeti.cron.in \
565
	doc/examples/gnt-config-backup.in \
566
	doc/examples/ganeti.default \
567
	doc/examples/ganeti.default-debug \
568
	doc/examples/hooks/ethers \
569
	doc/examples/hooks/ipsec.in \
570
	doc/examples/gnt-debug/README \
571
	doc/examples/gnt-debug/delay0.json \
572
	doc/examples/gnt-debug/delay50.json \
573
	test/testutils.py \
574
	test/mocks.py \
575
	$(dist_TESTS) \
576
	$(TEST_FILES) \
577
	man/footer.rst \
578
	$(manrst) \
579
	$(maninput) \
580
	qa/qa-sample.json \
581
	$(qa_scripts) \
582
	$(HS_LIB_SRCS) $(HS_BUILT_SRCS_IN) \
583
	$(HS_PROG_SRCS)
584

    
585
man_MANS = \
586
	man/ganeti.7 \
587
	man/ganeti-cleaner.8 \
588
	man/ganeti-confd.8 \
589
	man/ganeti-listrunner.8 \
590
	man/ganeti-masterd.8 \
591
	man/ganeti-noded.8 \
592
	man/ganeti-os-interface.7 \
593
	man/ganeti-rapi.8 \
594
	man/ganeti-watcher.8 \
595
	man/gnt-backup.8 \
596
	man/gnt-cluster.8 \
597
	man/gnt-debug.8 \
598
	man/gnt-group.8 \
599
	man/gnt-instance.8 \
600
	man/gnt-job.8 \
601
	man/gnt-node.8 \
602
	man/gnt-os.8 \
603
	man/hail.1 \
604
	man/hbal.1 \
605
	man/hscan.1 \
606
	man/hspace.1 \
607
	man/htools.1
608

    
609
manrst = $(patsubst %.1,%.rst,$(patsubst %.7,%.rst,$(patsubst %.8,%.rst,$(man_MANS))))
610
manhtml = $(patsubst %.rst,%.html,$(manrst))
611
mangen = $(patsubst %.rst,%.gen,$(manrst))
612
maninput = \
613
	$(patsubst %.1,%.1.in,$(patsubst %.7,%.7.in,$(patsubst %.8,%.8.in,$(man_MANS)))) \
614
	$(patsubst %.html,%.html.in,$(manhtml)) \
615
	man/footer.man man/footer.html $(mangen)
616

    
617
TEST_FILES = \
618
	test/data/bdev-drbd-8.0.txt \
619
	test/data/bdev-drbd-8.3.txt \
620
	test/data/bdev-drbd-disk.txt \
621
	test/data/bdev-drbd-net-ip4.txt \
622
	test/data/bdev-drbd-net-ip6.txt \
623
	test/data/cert1.pem \
624
	test/data/ip-addr-show-dummy0.txt \
625
	test/data/ip-addr-show-lo-ipv4.txt \
626
	test/data/ip-addr-show-lo-ipv6.txt \
627
	test/data/ip-addr-show-lo-oneline-ipv4.txt \
628
	test/data/ip-addr-show-lo-oneline-ipv6.txt \
629
	test/data/ip-addr-show-lo-oneline.txt \
630
	test/data/ip-addr-show-lo.txt \
631
	test/data/proc_drbd8.txt \
632
	test/data/proc_drbd80-emptyline.txt \
633
	test/data/proc_drbd83.txt \
634
	test/data/sys_drbd_usermode_helper.txt \
635
	test/import-export_unittest-helper
636

    
637
python_tests = \
638
	test/ganeti.asyncnotifier_unittest.py \
639
	test/ganeti.backend_unittest.py \
640
	test/ganeti.bdev_unittest.py \
641
	test/ganeti.cli_unittest.py \
642
	test/ganeti.client.gnt_cluster_unittest.py \
643
	test/ganeti.client.gnt_instance_unittest.py \
644
	test/ganeti.daemon_unittest.py \
645
	test/ganeti.cmdlib_unittest.py \
646
	test/ganeti.compat_unittest.py \
647
	test/ganeti.confd.client_unittest.py \
648
	test/ganeti.config_unittest.py \
649
	test/ganeti.constants_unittest.py \
650
	test/ganeti.errors_unittest.py \
651
	test/ganeti.hooks_unittest.py \
652
	test/ganeti.ht_unittest.py \
653
	test/ganeti.http_unittest.py \
654
	test/ganeti.hypervisor_unittest.py \
655
	test/ganeti.hypervisor.hv_chroot_unittest.py \
656
	test/ganeti.hypervisor.hv_fake_unittest.py \
657
	test/ganeti.hypervisor.hv_kvm_unittest.py \
658
	test/ganeti.hypervisor.hv_lxc_unittest.py \
659
	test/ganeti.hypervisor.hv_xen_unittest.py \
660
	test/ganeti.impexpd_unittest.py \
661
	test/ganeti.jqueue_unittest.py \
662
	test/ganeti.locking_unittest.py \
663
	test/ganeti.luxi_unittest.py \
664
	test/ganeti.masterd.instance_unittest.py \
665
	test/ganeti.mcpu_unittest.py \
666
	test/ganeti.netutils_unittest.py \
667
	test/ganeti.objects_unittest.py \
668
	test/ganeti.opcodes_unittest.py \
669
	test/ganeti.qlang_unittest.py \
670
	test/ganeti.query_unittest.py \
671
	test/ganeti.rapi.baserlib_unittest.py \
672
	test/ganeti.rapi.client_unittest.py \
673
	test/ganeti.rapi.resources_unittest.py \
674
	test/ganeti.rapi.rlib2_unittest.py \
675
	test/ganeti.rpc_unittest.py \
676
	test/ganeti.runtime_unittest.py \
677
	test/ganeti.serializer_unittest.py \
678
	test/ganeti.ssh_unittest.py \
679
	test/ganeti.tools.ensure_dirs_unittest.py \
680
	test/ganeti.uidpool_unittest.py \
681
	test/ganeti.utils.algo_unittest.py \
682
	test/ganeti.utils.filelock_unittest.py \
683
	test/ganeti.utils.hash_unittest.py \
684
	test/ganeti.utils.io_unittest.py \
685
	test/ganeti.utils.log_unittest.py \
686
	test/ganeti.utils.mlock_unittest.py \
687
	test/ganeti.utils.nodesetup_unittest.py \
688
	test/ganeti.utils.process_unittest.py \
689
	test/ganeti.utils.retry_unittest.py \
690
	test/ganeti.utils.text_unittest.py \
691
	test/ganeti.utils.wrapper_unittest.py \
692
	test/ganeti.utils.x509_unittest.py \
693
	test/ganeti.utils_unittest.py \
694
	test/ganeti.workerpool_unittest.py \
695
	test/cfgupgrade_unittest.py \
696
	test/docs_unittest.py \
697
	test/tempfile_fork_unittest.py
698

    
699
haskell_tests = htools/test
700

    
701
dist_TESTS = \
702
	test/check-cert-expired_unittest.bash \
703
	test/daemon-util_unittest.bash \
704
	test/ganeti-cleaner_unittest.bash \
705
	test/import-export_unittest.bash \
706
	$(python_tests)
707

    
708
nodist_TESTS =
709
if WANT_HTOOLSTESTS
710
nodist_TESTS += $(haskell_tests)
711
endif
712

    
713
TESTS = $(dist_TESTS) $(nodist_TESTS)
714

    
715
# Environment for all tests
716
PLAIN_TESTS_ENVIRONMENT = \
717
	PYTHONPATH=. TOP_SRCDIR=$(abs_top_srcdir) PYTHON=$(PYTHON) $(RUN_IN_TEMPDIR)
718

    
719
# Environment for tests run by automake
720
TESTS_ENVIRONMENT = \
721
	$(PLAIN_TESTS_ENVIRONMENT) $(abs_top_srcdir)/autotools/testrunner
722

    
723
all_python_code = \
724
	$(dist_sbin_SCRIPTS) \
725
	$(dist_tools_PYTHON) \
726
	$(pkglib_python_scripts) \
727
	$(nodist_pkglib_python_scripts) \
728
	$(python_tests) \
729
	$(pkgpython_PYTHON) \
730
	$(client_PYTHON) \
731
	$(hypervisor_PYTHON) \
732
	$(rapi_PYTHON) \
733
	$(server_PYTHON) \
734
	$(pytools_PYTHON) \
735
	$(http_PYTHON) \
736
	$(confd_PYTHON) \
737
	$(masterd_PYTHON) \
738
	$(impexpd_PYTHON) \
739
	$(utils_PYTHON) \
740
	$(watcher_PYTHON) \
741
	$(noinst_PYTHON) \
742
	$(qa_scripts)
743

    
744
srclink_files = \
745
	man/footer.rst \
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
	$(all_python_code) \
751
	$(HS_LIB_SRCS) $(HS_PROG_SRCS)
752

    
753
check_python_code = \
754
	$(BUILD_BASH_COMPLETION) \
755
	$(DOCPP) \
756
	$(all_python_code)
757

    
758
lint_python_code = \
759
	ganeti \
760
	ganeti/http/server.py \
761
	$(dist_sbin_SCRIPTS) \
762
	$(dist_tools_PYTHON) \
763
	$(pkglib_python_scripts) \
764
	$(BUILD_BASH_COMPLETION) \
765
	$(DOCPP) \
766
	$(PYTHON_BOOTSTRAP)
767

    
768
test/daemon-util_unittest.bash: daemons/daemon-util
769

    
770
test/ganeti-cleaner_unittest.bash: daemons/ganeti-cleaner
771

    
772
tools/kvm-ifup: tools/kvm-ifup.in $(REPLACE_VARS_SED)
773
	sed -f $(REPLACE_VARS_SED) < $< > $@
774
	chmod +x $@
775

    
776
devel/upload: devel/upload.in $(REPLACE_VARS_SED)
777
	sed -f $(REPLACE_VARS_SED) < $< > $@
778
	chmod u+x $@
779

    
780
daemons/%: daemons/%.in $(REPLACE_VARS_SED)
781
	sed -f $(REPLACE_VARS_SED) < $< > $@
782
	chmod +x $@
783

    
784
doc/examples/%: doc/examples/%.in $(REPLACE_VARS_SED)
785
	sed -f $(REPLACE_VARS_SED) < $< > $@
786

    
787
doc/examples/hooks/%: doc/examples/hooks/%.in $(REPLACE_VARS_SED)
788
	sed -f $(REPLACE_VARS_SED) < $< > $@
789

    
790
doc/examples/bash_completion: $(BUILD_BASH_COMPLETION) $(RUN_IN_TEMPDIR) \
791
	lib/cli.py $(gnt_scripts) $(client_PYTHON) tools/burnin
792
	PYTHONPATH=. $(RUN_IN_TEMPDIR) $(CURDIR)/$(BUILD_BASH_COMPLETION) > $@
793

    
794
doc/%.png: doc/%.dot
795
	@test -n "$(DOT)" || { echo 'dot' not found during configure; exit 1; }
796
	$(DOT) -Tpng -o $@ $<
797

    
798
man/footer.man: man/footer.rst
799
	@test -n "$(PANDOC)" || \
800
	  { echo 'pandoc' not found during configure; exit 1; }
801
	$(PANDOC) -f rst -t man -o $@ $<
802

    
803
man/footer.html: man/footer.rst
804
	@test -n "$(PANDOC)" || \
805
	  { echo 'pandoc' not found during configure; exit 1; }
806
	$(PANDOC) -f rst -t html -o $@ $<
807

    
808
man/%.gen: man/%.rst lib/query.py lib/build/sphinx_ext.py
809
	PYTHONPATH=. $(RUN_IN_TEMPDIR) $(CURDIR)/$(DOCPP) < $< > $@
810

    
811
man/%.7.in man/%.8.in man/%.1.in: man/%.gen man/footer.man
812
	@test -n "$(PANDOC)" || \
813
	  { echo 'pandoc' not found during configure; exit 1; }
814
	set -o pipefail ; \
815
	$(PANDOC) -s -f rst -t man -A man/footer.man $< | \
816
	  sed -e 's/\\@/@/g' > $@
817
	if test -n "$(MAN_HAS_WARNINGS)"; then $(CHECK_MAN) $@; fi
818

    
819
man/%.html.in: man/%.gen man/footer.html
820
	@test -n "$(PANDOC)" || \
821
	  { echo 'pandoc' not found during configure; exit 1; }
822
	set -o pipefail ; \
823
	$(PANDOC) -s -f rst -t html -A man/footer.html $< | \
824
	  sed -e 's/\\@/@/g' > $@
825

    
826
man/%.1: man/%.1.in $(REPLACE_VARS_SED)
827
	sed -f $(REPLACE_VARS_SED) < $< > $@
828

    
829
man/%.7: man/%.7.in $(REPLACE_VARS_SED)
830
	sed -f $(REPLACE_VARS_SED) < $< > $@
831

    
832
man/%.8: man/%.8.in $(REPLACE_VARS_SED)
833
	sed -f $(REPLACE_VARS_SED) < $< > $@
834

    
835
man/%.html: man/%.html.in $(REPLACE_VARS_SED)
836
	sed -f $(REPLACE_VARS_SED) < $< > $@
837

    
838
epydoc.conf: epydoc.conf.in Makefile
839
	sed -e 's#@MODULES@#$(strip $(lint_python_code))#g' < $< > $@
840

    
841
vcs-version:
842
	if test -d .git; then \
843
	  git describe > $@; \
844
	elif test ! -f $@ ; then \
845
	  echo "Cannot auto-generate $@ file"; exit 1; \
846
	fi
847

    
848
.PHONY: regen-vcs-version
849
regen-vcs-version:
850
	set -e; \
851
	cd $(srcdir); \
852
	if test -d .git; then \
853
	  rm -f vcs-version; \
854
	  $(MAKE) vcs-version; \
855
	fi
856

    
857
htools/Ganeti/HTools/Version.hs: htools/Ganeti/HTools/Version.hs.in vcs-version
858
	set -e; \
859
	VCSVER=`cat $(abs_top_srcdir)/vcs-version`; \
860
	sed -e "s/%ver%/$$VCSVER/" < $< > $@
861

    
862
htools/Ganeti/Constants.hs: htools/Ganeti/Constants.hs.in \
863
	lib/constants.py lib/_autoconf.py $(CONVERT_CONSTANTS)
864
	set -e; \
865
	{ cat $< ; PYTHONPATH=. $(CONVERT_CONSTANTS); } > $@
866

    
867
lib/_autoconf.py: Makefile | lib/.dir
868
	set -e; \
869
	{ echo '# This file is automatically generated, do not edit!'; \
870
	  echo '#'; \
871
	  echo ''; \
872
	  echo '"""Build-time configuration for Ganeti.'; \
873
	  echo '';\
874
	  echo 'This file is autogenerated by the build process.'; \
875
	  echo 'For any changes you need to re-run ./configure (and'; \
876
	  echo 'not edit by hand).'; \
877
	  echo ''; \
878
	  echo '"""'; \
879
	  echo ''; \
880
	  echo '# pylint: disable-msg=C0301,C0324'; \
881
	  echo '# because this is autogenerated, we do not want'; \
882
	  echo '# style warnings' ; \
883
	  echo ''; \
884
	  echo "PACKAGE_VERSION = '$(PACKAGE_VERSION)'"; \
885
	  echo "VERSION_MAJOR = '$(VERSION_MAJOR)'"; \
886
	  echo "VERSION_MINOR = '$(VERSION_MINOR)'"; \
887
	  echo "VERSION_REVISION = '$(VERSION_REVISION)'"; \
888
	  echo "VERSION_SUFFIX = '$(VERSION_SUFFIX)'"; \
889
	  echo "VERSION_FULL = '$(VERSION_FULL)'"; \
890
	  echo "LOCALSTATEDIR = '$(localstatedir)'"; \
891
	  echo "SYSCONFDIR = '$(sysconfdir)'"; \
892
	  echo "SSH_CONFIG_DIR = '$(SSH_CONFIG_DIR)'"; \
893
	  echo "EXPORT_DIR = '$(EXPORT_DIR)'"; \
894
	  echo "OS_SEARCH_PATH = [$(OS_SEARCH_PATH)]"; \
895
	  echo "XEN_BOOTLOADER = '$(XEN_BOOTLOADER)'"; \
896
	  echo "XEN_KERNEL = '$(XEN_KERNEL)'"; \
897
	  echo "XEN_INITRD = '$(XEN_INITRD)'"; \
898
	  echo "FILE_STORAGE_DIR = '$(FILE_STORAGE_DIR)'"; \
899
	  echo "ENABLE_FILE_STORAGE = $(ENABLE_FILE_STORAGE)"; \
900
	  echo "SHARED_FILE_STORAGE_DIR = '$(SHARED_FILE_STORAGE_DIR)'"; \
901
	  echo "ENABLE_SHARED_FILE_STORAGE = $(ENABLE_SHARED_FILE_STORAGE)"; \
902
	  echo "IALLOCATOR_SEARCH_PATH = [$(IALLOCATOR_SEARCH_PATH)]"; \
903
	  echo "KVM_PATH = '$(KVM_PATH)'"; \
904
	  echo "IP_PATH = '$(IP_PATH)'"; \
905
	  echo "SOCAT_PATH = '$(SOCAT)'"; \
906
	  echo "SOCAT_USE_ESCAPE = $(SOCAT_USE_ESCAPE)"; \
907
	  echo "SOCAT_USE_COMPRESS = $(SOCAT_USE_COMPRESS)"; \
908
	  echo "LVM_STRIPECOUNT = $(LVM_STRIPECOUNT)"; \
909
	  echo "TOOLSDIR = '$(toolsdir)'"; \
910
	  echo "GNT_SCRIPTS = [$(foreach i,$(notdir $(gnt_scripts)),'$(i)',)]"; \
911
	  echo "PKGLIBDIR = '$(pkglibdir)'"; \
912
	  echo "DRBD_BARRIERS = $(DRBD_BARRIERS)"; \
913
	  echo "SYSLOG_USAGE = '$(SYSLOG_USAGE)'"; \
914
	  echo "DAEMONS_GROUP = '$(DAEMONS_GROUP)'"; \
915
	  echo "ADMIN_GROUP = '$(ADMIN_GROUP)'"; \
916
	  echo "MASTERD_USER = '$(MASTERD_USER)'"; \
917
	  echo "MASTERD_GROUP = '$(MASTERD_GROUP)'"; \
918
	  echo "RAPI_USER = '$(RAPI_USER)'"; \
919
	  echo "RAPI_GROUP = '$(RAPI_GROUP)'"; \
920
	  echo "CONFD_USER = '$(CONFD_USER)'"; \
921
	  echo "CONFD_GROUP = '$(CONFD_GROUP)'"; \
922
	  echo "NODED_USER = '$(NODED_USER)'"; \
923
	  echo "NODED_GROUP = '$(NODED_GROUP)'"; \
924
	  echo "DISK_SEPARATOR = '$(DISK_SEPARATOR)'"; \
925
	  if [ "$(HTOOLS)" ]; then \
926
	    echo "HTOOLS = True"; \
927
	  else \
928
	    echo "HTOOLS = False"; \
929
	  fi; \
930
	} > $@
931

    
932
lib/_vcsversion.py: Makefile vcs-version | lib/.dir
933
	set -e; \
934
	VCSVER=`cat $(abs_top_srcdir)/vcs-version`; \
935
	{ echo '# This file is automatically generated, do not edit!'; \
936
	  echo '#'; \
937
	  echo ''; \
938
	  echo '"""Build-time VCS version number for Ganeti.'; \
939
	  echo '';\
940
	  echo 'This file is autogenerated by the build process.'; \
941
	  echo 'For any changes you need to re-run ./configure (and'; \
942
	  echo 'not edit by hand).'; \
943
	  echo ''; \
944
	  echo '"""'; \
945
	  echo ''; \
946
	  echo '# pylint: disable-msg=C0301,C0324'; \
947
	  echo '# because this is autogenerated, we do not want'; \
948
	  echo '# style warnings' ; \
949
	  echo ''; \
950
	  echo "VCS_VERSION = '$$VCSVER'"; \
951
	} > $@
952

    
953
$(REPLACE_VARS_SED): Makefile
954
	set -e; \
955
	{ echo 's#@PREFIX@#$(prefix)#g'; \
956
	  echo 's#@SYSCONFDIR@#$(sysconfdir)#g'; \
957
	  echo 's#@LOCALSTATEDIR@#$(localstatedir)#g'; \
958
	  echo 's#@BINDIR@#$(bindir)#g'; \
959
	  echo 's#@SBINDIR@#$(sbindir)#g'; \
960
	  echo 's#@GANETI_VERSION@#$(PACKAGE_VERSION)#g'; \
961
	  echo 's#@CUSTOM_XEN_BOOTLOADER@#$(XEN_BOOTLOADER)#g'; \
962
	  echo 's#@CUSTOM_XEN_KERNEL@#$(XEN_KERNEL)#g'; \
963
	  echo 's#@CUSTOM_XEN_INITRD@#$(XEN_INITRD)#g'; \
964
	  echo 's#@CUSTOM_IALLOCATOR_SEARCH_PATH@#$(IALLOCATOR_SEARCH_PATH)#g'; \
965
	  echo 's#@CUSTOM_EXPORT_DIR@#$(EXPORT_DIR)#g'; \
966
	  echo 's#@RPL_FILE_STORAGE_DIR@#$(FILE_STORAGE_DIR)#g'; \
967
	  echo 's#@RPL_SSH_INITD_SCRIPT@#$(SSH_INITD_SCRIPT)#g'; \
968
	  echo 's#@PKGLIBDIR@#$(pkglibdir)#g'; \
969
	  echo 's#@GNTMASTERUSER@#$(MASTERD_USER)#g'; \
970
	  echo 's#@GNTRAPIUSER@#$(RAPI_USER)#g'; \
971
	  echo 's#@GNTCONFDUSER@#$(CONFD_USER)#g'; \
972
	  echo 's#@GNTNODEDUSER@#$(NODED_USER)#g'; \
973
	  echo 's#@GNTRAPIGROUP@#$(RAPI_GROUP)#g'; \
974
	  echo 's#@GNTADMINGROUP@#$(ADMIN_GROUP)#g'; \
975
	  echo 's#@GNTCONFDGROUP@#$(CONFD_GROUP)#g'; \
976
	  echo 's#@GNTMASTERDGROUP@#$(MASTERD_GROUP)#g'; \
977
	  echo 's#@GNTDAEMONSGROUP@#$(DAEMONS_GROUP)#g'; \
978
	} > $@
979

    
980
# Using deferred evaluation
981
daemons/ganeti-%: MODULE = ganeti.server.$(patsubst ganeti-%,%,$(notdir $@))
982
daemons/ganeti-watcher: MODULE = ganeti.watcher
983
scripts/%: MODULE = ganeti.client.$(subst -,_,$(notdir $@))
984
tools/ensure-dirs: MODULE = ganeti.tools.ensure_dirs
985

    
986
$(PYTHON_BOOTSTRAP): Makefile | $(all_dirfiles)
987
	test -n "$(MODULE)" || { echo Missing module; exit 1; }
988
	set -e; \
989
	{ echo '#!/usr/bin/python'; \
990
	  echo '# This file is automatically generated, do not edit!'; \
991
	  echo "# Edit $(MODULE) instead."; \
992
	  echo; \
993
	  echo '"""Bootstrap script for L{$(MODULE)}"""'; \
994
	  echo; \
995
	  echo '# pylint: disable-msg=C0103'; \
996
	  echo '# C0103: Invalid name'; \
997
	  echo; \
998
	  echo 'import sys'; \
999
	  echo 'import $(MODULE) as main'; \
1000
	  echo; \
1001
	  echo '# Temporarily alias commands until bash completion'; \
1002
	  echo '# generator is changed'; \
1003
	  echo 'if hasattr(main, "commands"):'; \
1004
	  echo '  commands = main.commands # pylint: disable-msg=E1101'; \
1005
	  echo 'if hasattr(main, "aliases"):'; \
1006
	  echo '  aliases = main.aliases # pylint: disable-msg=E1101'; \
1007
	  echo; \
1008
	  echo 'if __name__ == "__main__":'; \
1009
	  echo '  sys.exit(main.Main())'; \
1010
	} > $@
1011
	chmod u+x $@
1012

    
1013
# We need to create symlinks because "make distcheck" will not install Python
1014
# files when building.
1015
stamp-srclinks: Makefile | $(all_dirfiles)
1016
	set -e; \
1017
	for i in $(srclink_files); do \
1018
		if test ! -f $$i -a -f $(abs_top_srcdir)/$$i; then \
1019
			$(LN_S) $(abs_top_srcdir)/$$i $$i; \
1020
		fi; \
1021
	done
1022
	touch $@
1023

    
1024
.PHONY: ganeti
1025
ganeti:
1026
	cd $(top_builddir) && test -h "$@" || { rm -f $@ && $(LN_S) lib $@; }
1027

    
1028
.PHONY: check-dirs
1029
check-dirs: $(BUILT_SOURCES)
1030
	@set -e; \
1031
	find . -type d \( \( -name . \) -o \( \
1032
		-name .git -o \
1033
		-name autom4te.cache \
1034
		\) -prune -o -print \) | { \
1035
		error=; \
1036
		while read dir; do \
1037
			case "$$dir" in \
1038
				$(strip $(patsubst %,(./%) ;;,$(DIRCHECK_EXCLUDE) $(DIRS))) \
1039
				*) error=1; echo "Directory $$dir not listed in Makefile" >&2 ;; \
1040
			esac; \
1041
		done; \
1042
		for dir in $(DIRS); do \
1043
			if ! test -d "$$dir"; then \
1044
				echo "Directory $$dir listed in DIRS does not exist" >&2; \
1045
				error=1; \
1046
			fi \
1047
		done; \
1048
		if test -n "$$error"; then exit 1; else exit 0; fi; \
1049
	}
1050

    
1051
check-local: check-dirs
1052
	$(CHECK_PYTHON_CODE) $(check_python_code)
1053
	$(CHECK_VERSION) $(VERSION) $(top_srcdir)/NEWS
1054
	$(CHECK_NEWS) < $(top_srcdir)/NEWS
1055
	expver=$(VERSION_MAJOR).$(VERSION_MINOR); \
1056
	if test "`head -n 1 $(top_srcdir)/README`" != "Ganeti $$expver"; then \
1057
		echo "Incorrect version in README, expected $$expver"; \
1058
		exit 1; \
1059
	fi; \
1060
	for file in doc/iallocator.rst doc/hooks.rst; do \
1061
		if test "`sed -ne '4 p' $(top_srcdir)/$$file`" != \
1062
		        "Documents Ganeti version $$expver"; then \
1063
			echo "Incorrect version in $$file, expected $$expver"; \
1064
			exit 1; \
1065
		fi; \
1066
	done
1067

    
1068
.PHONY: hs-check
1069
hs-check: htools/test
1070
	@rm -f test.tix
1071
	./htools/test
1072

    
1073
# E111: indentation is not a multiple of four
1074
# E261: at least two spaces before inline comment
1075
# E501: line too long (80 characters)
1076
PEP8_IGNORE = E111,E261,E501
1077

    
1078
# For excluding pep8 expects filenames only, not whole paths
1079
PEP8_EXCLUDE = $(subst $(space),$(comma),$(strip $(notdir $(BUILT_PYTHON_SOURCES))))
1080

    
1081
.PHONY: lint
1082
lint: $(BUILT_SOURCES)
1083
	@test -n "$(PYLINT)" || { echo 'pylint' not found during configure; exit 1; }
1084
	if test -z "$(PEP8)"; then \
1085
		echo '"pep8" not found during configure' >&2; \
1086
	else \
1087
		$(PEP8) --repeat --ignore='$(PEP8_IGNORE)' --exclude='$(PEP8_EXCLUDE)' \
1088
			$(lint_python_code); \
1089
	fi
1090
	$(PYLINT) $(LINT_OPTS) $(lint_python_code)
1091
	cd $(top_srcdir)/qa && \
1092
	  PYTHONPATH=$(abs_top_srcdir) $(PYLINT) $(LINT_OPTS) \
1093
	  --rcfile  ../pylintrc $(patsubst qa/%.py,%,$(qa_scripts))
1094

    
1095
.PHONY: hlint
1096
hlint: $(HS_BUILT_SRCS)
1097
	if tty -s; then C="-c"; else C=""; fi; \
1098
	hlint --report=doc/hs-lint.html $$C htools
1099

    
1100
# a dist hook rule for updating the vcs-version file; this is
1101
# hardcoded due to where it needs to build the file...
1102
dist-hook:
1103
	$(MAKE) regen-vcs-version && \
1104
	rm -f $(top_distdir)/vcs-version && \
1105
	cp -p $(srcdir)/vcs-version $(top_distdir)
1106

    
1107
# a distcheck hook rule for catching revision control directories
1108
distcheck-hook:
1109
	if find $(top_distdir) -name .svn -or -name .git | grep .; then \
1110
		echo "Found revision control files in final archive." 1>&2; \
1111
		exit 1; \
1112
	fi
1113
	if find $(top_distdir) -name '*.py[co]' | grep .; then \
1114
		echo "Found Python byte code in final archive." 1>&2; \
1115
		exit 1; \
1116
	fi
1117
	if find $(top_distdir) -name '*~' | grep .; then \
1118
		echo "Found backup files in final archive." 1>&2; \
1119
		exit 1; \
1120
	fi
1121
# Empty files or directories should not be distributed. They can cause
1122
# unnecessary warnings for packagers. Directories used by automake during
1123
# distcheck must be excluded.
1124
	if find $(top_distdir) -empty -and -not \( \
1125
			-path $(top_distdir)/_build -or \
1126
			-path $(top_distdir)/_inst \) | grep .; then \
1127
		echo "Found empty files or directories in final archive." 1>&2; \
1128
		exit 1; \
1129
	fi
1130
	if test -n "$(BUILD_RELEASE)" && \
1131
	   grep -n -H -E '^\*.*unreleased' $(top_distdir)/NEWS; then \
1132
		echo "Found unreleased version in NEWS." >&2; \
1133
		exit 1; \
1134
	fi
1135

    
1136
# When building a release, stricter checks should be used
1137
distcheck-release dist-release: export BUILD_RELEASE = 1
1138
distcheck-release: distcheck
1139

    
1140
dist-release: dist
1141
	set -e; \
1142
	for i in $(DIST_ARCHIVES); do \
1143
		echo -n "Checking $$i ... "; \
1144
		autotools/check-tar < $$i; \
1145
		echo OK; \
1146
	done
1147

    
1148
install-exec-local:
1149
	@mkdir_p@ "$(DESTDIR)${localstatedir}/lib/ganeti" \
1150
	  "$(DESTDIR)${localstatedir}/log/ganeti" \
1151
	  "$(DESTDIR)${localstatedir}/run/ganeti"
1152

    
1153
# To avoid conflicts between directory names and other targets, a file inside
1154
# the directory is used to ensure its existence.
1155
%.dir:
1156
	@mkdir_p@ $* && touch $@
1157

    
1158
.PHONY: apidoc
1159
if WANT_HTOOLSAPIDOC
1160
apidoc: py-apidoc hs-apidoc
1161
else
1162
apidoc: py-apidoc
1163
endif
1164

    
1165
.PHONY: py-apidoc
1166
py-apidoc: epydoc.conf $(RUN_IN_TEMPDIR) $(BUILT_SOURCES)
1167
	$(RUN_IN_TEMPDIR) epydoc -v \
1168
		--conf $(CURDIR)/epydoc.conf \
1169
		--output $(CURDIR)/$(APIDOC_PY_DIR)
1170

    
1171
.PHONY: hs-apidoc
1172
hs-apidoc: $(HS_BUILT_SRCS)
1173
	@test -n "$(HSCOLOUR)" || \
1174
	    { echo 'HsColour' not found during configure; exit 1; }
1175
	@test -n "$(HADDOCK)" || \
1176
	    { echo 'haddock' not found during configure; exit 1; }
1177
	rm -rf $(APIDOC_HS_DIR)/*
1178
	@mkdir_p@ $(APIDOC_HS_DIR)/Ganeti/HTools/Program
1179
	$(HSCOLOUR) -print-css > $(APIDOC_HS_DIR)/Ganeti/hscolour.css
1180
	ln -s ../hscolour.css $(APIDOC_HS_DIR)/Ganeti/HTools/hscolour.css
1181
	set -e ; \
1182
	cd htools; \
1183
	if [ "$(HTOOLS_NOCURL)" ]; \
1184
	then OPTGHC="--optghc=$(HTOOLS_NOCURL)"; \
1185
	else OPTGHC=""; \
1186
	fi; \
1187
	if [ "$(HTOOLS_PARALLEL3)" ]; \
1188
	then OPTGHC="$$OPTGHC --optghc=$(HTOOLS_PARALLEL3)"; \
1189
	fi; \
1190
	RELSRCS="$(HS_LIB_SRCS:htools/%=%)  $(HS_BUILT_SRCS:htools/%=%)"; \
1191
	for file in $$RELSRCS; do \
1192
		hfile=`echo $$file|sed 's/\\.hs$$//'`.html; \
1193
		$(HSCOLOUR) -css -anchor $$file > ../$(APIDOC_HS_DIR)/$$hfile ; \
1194
	done ; \
1195
	$(HADDOCK) --odir ../$(APIDOC_HS_DIR) --html --ignore-all-exports -w \
1196
		-t ganeti-htools -p haddock-prologue \
1197
		--source-module="%{MODULE/.//}.html" \
1198
		--source-entity="%{MODULE/.//}.html#%{NAME}" \
1199
		$$OPTGHC \
1200
		$(filter-out Ganeti/HTools/ExtLoader.hs,$(HS_LIB_SRCS:htools/%=%))
1201

    
1202
.PHONY: TAGS
1203
TAGS: $(BUILT_SOURCES)
1204
	rm -f TAGS
1205
	find . -path './lib/*.py' -o -path './scripts/gnt-*' -o \
1206
	  -path './daemons/ganeti-*' -o -path './tools/*' -o \
1207
	  -path './qa/*.py' | \
1208
	  etags -l python -
1209

    
1210
.PHONY: coverage
1211
if WANT_HTOOLS
1212
coverage: py-coverage hs-coverage
1213
else
1214
coverage: py-coverage
1215
endif
1216

    
1217
.PHONY: py-coverage
1218
py-coverage: $(BUILT_SOURCES) $(python_tests)
1219
	set -e; \
1220
	COVERAGE_FILE=$(CURDIR)/$(COVERAGE_PY_DIR)/data \
1221
	TEXT_COVERAGE=$(CURDIR)/$(COVERAGE_PY_DIR)/report.txt \
1222
	HTML_COVERAGE=$(CURDIR)/$(COVERAGE_PY_DIR) \
1223
	$(PLAIN_TESTS_ENVIRONMENT) $(abs_top_srcdir)/autotools/gen-coverage \
1224
	$(python_tests)
1225

    
1226
.PHONY: hs-coverage
1227
hs-coverage: $(haskell_tests)
1228
	cd htools && rm -f *.tix *.mix && ./test
1229
	@mkdir_p@ $(COVERAGE_HS_DIR)
1230
	hpc markup --destdir=$(COVERAGE_HS_DIR) htools/test $(HPCEXCL)
1231
	hpc report htools/test $(HPCEXCL)
1232
	ln -sf hpc_index.html $(COVERAGE_HS_DIR)/index.html
1233

    
1234
# Special "kind-of-QA" target for htools, needs special setup (all
1235
# tools compiled with -fhpc)
1236
.PHONY: live-test
1237
live-test: all
1238
	set -e ; \
1239
	cd htools; \
1240
	rm -f .hpc; ln -s ../.hpc .hpc; \
1241
	rm -f *.tix *.mix; \
1242
	./live-test.sh; \
1243
	hpc sum --union $(HPCEXCL) $(addsuffix .tix,$(HS_PROGS:htools/%=%)) \
1244
	  --output=live-test.tix ; \
1245
	@mkdir_p@ ../$(COVERAGE_HS_DIR) ; \
1246
	hpc markup --destdir=../$(COVERAGE_HS_DIR) live-test \
1247
		--srcdir=.. $(HPCEXCL) ; \
1248
	hpc report --srcdir=.. live-test $(HPCEXCL)
1249

    
1250
commit-check: distcheck lint apidoc
1251

    
1252
-include ./Makefile.local
1253

    
1254
# vim: set noet :