Statistics
| Branch: | Tag: | Revision:

root / Makefile.am @ f709cbca

History | View | Annotate | Download (25.1 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
# Use bash in order to be able to use pipefail
13
SHELL=/bin/bash
14

    
15
ACLOCAL_AMFLAGS = -I autotools
16
BUILD_BASH_COMPLETION = $(top_srcdir)/autotools/build-bash-completion
17
BUILD_ZSH_COMPLETION = $(top_srcdir)/autotools/build-zsh-completion
18
RUN_IN_TEMPDIR = $(top_srcdir)/autotools/run-in-tempdir
19
CHECK_PYTHON_CODE = $(top_srcdir)/autotools/check-python-code
20
CHECK_MAN = $(top_srcdir)/autotools/check-man
21
CHECK_VERSION = $(top_srcdir)/autotools/check-version
22
CHECK_NEWS = $(top_srcdir)/autotools/check-news
23
REPLACE_VARS_SED = autotools/replace_vars.sed
24

    
25
clientdir = $(pkgpythondir)/client
26
hypervisordir = $(pkgpythondir)/hypervisor
27
httpdir = $(pkgpythondir)/http
28
masterddir = $(pkgpythondir)/masterd
29
confddir = $(pkgpythondir)/confd
30
rapidir = $(pkgpythondir)/rapi
31
serverdir = $(pkgpythondir)/server
32
watcherdir = $(pkgpythondir)/watcher
33
impexpddir = $(pkgpythondir)/impexpd
34
utilsdir = $(pkgpythondir)/utils
35
toolsdir = $(pkglibdir)/tools
36
docdir = $(datadir)/doc/$(PACKAGE)
37

    
38
# Delete output file if an error occurred while building it
39
.DELETE_ON_ERROR:
40

    
41
DIRS = \
42
	autotools \
43
	daemons \
44
	devel \
45
	doc \
46
	doc/examples \
47
	doc/examples/hooks \
48
	doc/examples/gnt-debug \
49
	lib \
50
	lib/client \
51
	lib/build \
52
	lib/confd \
53
	lib/http \
54
	lib/hypervisor \
55
	lib/impexpd \
56
	lib/masterd \
57
	lib/rapi \
58
	lib/server \
59
	lib/utils \
60
	lib/watcher \
61
	man \
62
	qa \
63
	test \
64
	test/data \
65
	tools
66

    
67
BUILDTIME_DIR_AUTOCREATE = \
68
	scripts \
69
	doc/api \
70
	doc/coverage
71

    
72
BUILDTIME_DIRS = \
73
	$(BUILDTIME_DIR_AUTOCREATE) \
74
	doc/html
75

    
76
DIRCHECK_EXCLUDE = \
77
	$(BUILDTIME_DIRS) \
78
	ganeti-[0-9]*.[0-9]*.[0-9]* \
79
	doc/html/_*
80

    
81
all_dirfiles = $(addsuffix /.dir,$(DIRS) $(BUILDTIME_DIR_AUTOCREATE))
82

    
83
MAINTAINERCLEANFILES = \
84
	$(docpng) \
85
	$(maninput) \
86
	doc/install-quick.rst \
87
	doc/news.rst \
88
	doc/upgrade.rst \
89
	vcs-version
90

    
91
maintainer-clean-local:
92
	rm -rf $(BUILDTIME_DIRS)
93

    
94
CLEANFILES = \
95
	$(addsuffix /*.py[co],$(DIRS)) \
96
	$(all_dirfiles) \
97
	$(PYTHON_BOOTSTRAP) \
98
	epydoc.conf \
99
	autotools/replace_vars.sed \
100
	daemons/daemon-util \
101
	daemons/ensure-dirs \
102
	daemons/ganeti-cleaner \
103
	devel/upload \
104
	doc/examples/bash_completion \
105
	doc/examples/zsh_completion \
106
	doc/examples/ganeti.initd \
107
	doc/examples/ganeti-kvm-poweroff.initd \
108
	doc/examples/ganeti.cron \
109
	doc/examples/gnt-config-backup \
110
	doc/examples/hooks/ipsec \
111
	$(man_MANS) \
112
	$(manhtml) \
113
	tools/kvm-ifup \
114
	stamp-srclinks \
115
	$(nodist_pkgpython_PYTHON)
116

    
117
# BUILT_SOURCES should only be used as a dependency on phony targets. Otherwise
118
# it'll cause the target to rebuild every time.
119
BUILT_SOURCES = \
120
	ganeti \
121
	stamp-srclinks \
122
	lib/_autoconf.py \
123
	$(all_dirfiles) \
124
	$(PYTHON_BOOTSTRAP)
125

    
126
nodist_pkgpython_PYTHON = \
127
	lib/_autoconf.py
128

    
129
noinst_PYTHON = \
130
	lib/build/__init__.py
131

    
132
pkgpython_PYTHON = \
133
	lib/__init__.py \
134
	lib/asyncnotifier.py \
135
	lib/backend.py \
136
	lib/bdev.py \
137
	lib/bootstrap.py \
138
	lib/cli.py \
139
	lib/cmdlib.py \
140
	lib/compat.py \
141
	lib/config.py \
142
	lib/constants.py \
143
	lib/daemon.py \
144
	lib/errors.py \
145
	lib/ht.py \
146
	lib/jqueue.py \
147
	lib/jstore.py \
148
	lib/locking.py \
149
	lib/luxi.py \
150
	lib/mcpu.py \
151
	lib/netutils.py \
152
	lib/objects.py \
153
	lib/opcodes.py \
154
	lib/qlang.py \
155
	lib/query.py \
156
	lib/rpc.py \
157
	lib/runtime.py \
158
	lib/serializer.py \
159
	lib/ssconf.py \
160
	lib/ssh.py \
161
	lib/storage.py \
162
	lib/uidpool.py \
163
	lib/network.py \
164
	lib/workerpool.py
165

    
166
client_PYTHON = \
167
	lib/client/__init__.py \
168
	lib/client/gnt_backup.py \
169
	lib/client/gnt_cluster.py \
170
	lib/client/gnt_debug.py \
171
	lib/client/gnt_group.py \
172
	lib/client/gnt_instance.py \
173
	lib/client/gnt_job.py \
174
	lib/client/gnt_node.py \
175
	lib/client/gnt_network.py \
176
	lib/client/gnt_os.py
177

    
178
hypervisor_PYTHON = \
179
	lib/hypervisor/__init__.py \
180
	lib/hypervisor/hv_base.py \
181
	lib/hypervisor/hv_chroot.py \
182
	lib/hypervisor/hv_fake.py \
183
	lib/hypervisor/hv_kvm.py \
184
	lib/hypervisor/hv_lxc.py \
185
	lib/hypervisor/hv_xen.py
186

    
187
rapi_PYTHON = \
188
	lib/rapi/__init__.py \
189
	lib/rapi/baserlib.py \
190
	lib/rapi/client.py \
191
	lib/rapi/client_utils.py \
192
	lib/rapi/connector.py \
193
	lib/rapi/rlib2.py
194

    
195
http_PYTHON = \
196
	lib/http/__init__.py \
197
	lib/http/auth.py \
198
	lib/http/client.py \
199
	lib/http/server.py
200

    
201
confd_PYTHON = \
202
	lib/confd/__init__.py \
203
	lib/confd/client.py \
204
	lib/confd/querylib.py \
205
	lib/confd/server.py
206

    
207
masterd_PYTHON = \
208
	lib/masterd/__init__.py \
209
	lib/masterd/instance.py
210

    
211
impexpd_PYTHON = \
212
	lib/impexpd/__init__.py
213

    
214
watcher_PYTHON = \
215
	lib/watcher/__init__.py
216

    
217
server_PYTHON = \
218
	lib/server/__init__.py \
219
	lib/server/confd.py \
220
	lib/server/masterd.py \
221
	lib/server/noded.py \
222
	lib/server/rapi.py
223

    
224
utils_PYTHON = \
225
	lib/utils/__init__.py \
226
	lib/utils/algo.py \
227
	lib/utils/filelock.py \
228
	lib/utils/hash.py \
229
	lib/utils/io.py \
230
	lib/utils/log.py \
231
	lib/utils/mlock.py \
232
	lib/utils/nodesetup.py \
233
	lib/utils/process.py \
234
	lib/utils/retry.py \
235
	lib/utils/text.py \
236
	lib/utils/wrapper.py \
237
	lib/utils/x509.py
238

    
239
docrst = \
240
	doc/admin.rst \
241
	doc/design-2.0.rst \
242
	doc/design-2.1.rst \
243
	doc/design-2.2.rst \
244
	doc/design-2.3.rst \
245
	doc/design-2.4.rst \
246
	doc/design-oob.rst \
247
	doc/design-query2.rst \
248
	doc/cluster-merge.rst \
249
	doc/design-shared-storage.rst \
250
	doc/devnotes.rst \
251
	doc/glossary.rst \
252
	doc/hooks.rst \
253
	doc/iallocator.rst \
254
	doc/index.rst \
255
	doc/install-quick.rst \
256
	doc/install.rst \
257
	doc/locking.rst \
258
	doc/move-instance.rst \
259
	doc/news.rst \
260
	doc/rapi.rst \
261
	doc/security.rst \
262
	doc/upgrade.rst \
263
	doc/walkthrough.rst
264

    
265
$(RUN_IN_TEMPDIR): | $(all_dirfiles)
266

    
267
doc/html/index.html: $(docrst) $(docpng) doc/conf.py configure.ac \
268
	$(RUN_IN_TEMPDIR)
269
	@test -n "$(SPHINX)" || \
270
	    { echo 'sphinx-build' not found during configure; exit 1; }
271
	@mkdir_p@ $(dir $@)
272
	PYTHONPATH=. $(RUN_IN_TEMPDIR) $(SPHINX) -q -W -b html \
273
	    -d . \
274
	    -D version="$(VERSION_MAJOR).$(VERSION_MINOR)" \
275
	    -D release="$(PACKAGE_VERSION)" \
276
	    $(abs_top_srcdir)/doc $(CURDIR)/doc/html
277
	rm -f doc/html/.buildinfo doc/html/objects.inv
278
	touch $@
279

    
280
doc/html: doc/html/index.html
281

    
282
doc/install-quick.rst: INSTALL
283
doc/news.rst: NEWS
284
doc/upgrade.rst: UPGRADE
285

    
286
doc/install-quick.rst doc/news.rst doc/upgrade.rst:
287
	set -e; \
288
	{ echo '.. This file is automatically updated at build time from $<.'; \
289
	  echo '.. Do not edit.'; \
290
	  echo; \
291
	  cat $<; \
292
	} > $@
293

    
294
docdot = \
295
	doc/arch-2.0.dot \
296
	doc/design-2.1-lock-acquire.dot \
297
	doc/design-2.1-lock-release.dot
298

    
299
docpng = $(patsubst %.dot,%.png,$(docdot))
300

    
301
# Things to build but not to install (add it to EXTRA_DIST if it should be
302
# distributed)
303
noinst_DATA = \
304
	devel/upload \
305
	doc/html \
306
	doc/examples/bash_completion \
307
	doc/examples/zsh_completion \
308
	doc/examples/ganeti.cron \
309
	doc/examples/ganeti.initd \
310
	doc/examples/ganeti-kvm-poweroff.initd \
311
	doc/examples/gnt-config-backup \
312
	doc/examples/hooks/ipsec \
313
	$(manhtml)
314

    
315
gnt_scripts = \
316
	scripts/gnt-backup \
317
	scripts/gnt-cluster \
318
	scripts/gnt-debug \
319
	scripts/gnt-group \
320
	scripts/gnt-instance \
321
	scripts/gnt-job \
322
	scripts/gnt-network \
323
	scripts/gnt-node \
324
	scripts/gnt-os
325

    
326
PYTHON_BOOTSTRAP = \
327
	daemons/ganeti-confd \
328
	daemons/ganeti-masterd \
329
	daemons/ganeti-noded \
330
	daemons/ganeti-watcher \
331
	daemons/ganeti-rapi \
332
	scripts/gnt-backup \
333
	scripts/gnt-cluster \
334
	scripts/gnt-debug \
335
	scripts/gnt-group \
336
	scripts/gnt-instance \
337
	scripts/gnt-job \
338
	scripts/gnt-network \
339
	scripts/gnt-node \
340
	scripts/gnt-os
341

    
342
qa_scripts = \
343
	qa/ganeti-qa.py \
344
	qa/qa_cluster.py \
345
	qa/qa_config.py \
346
	qa/qa_daemon.py \
347
	qa/qa_env.py \
348
	qa/qa_error.py \
349
	qa/qa_instance.py \
350
	qa/qa_node.py \
351
	qa/qa_os.py \
352
	qa/qa_rapi.py \
353
	qa/qa_tags.py \
354
	qa/qa_utils.py
355

    
356
dist_sbin_SCRIPTS = \
357
	tools/ganeti-listrunner
358

    
359
nodist_sbin_SCRIPTS = \
360
	$(PYTHON_BOOTSTRAP) \
361
	daemons/ganeti-cleaner
362

    
363
dist_tools_SCRIPTS = \
364
	tools/burnin \
365
	tools/cfgshell \
366
	tools/cfgupgrade \
367
	tools/cfgupgrade12 \
368
	tools/cfgupgrade_grnet \
369
	tools/upgrade-kvm-runtime \
370
	tools/cluster-merge \
371
	tools/lvmstrap \
372
	tools/move-instance \
373
	tools/setup-ssh \
374
	tools/sanitize-config
375

    
376
pkglib_python_scripts = \
377
	daemons/import-export \
378
	tools/check-cert-expired
379

    
380
pkglib_SCRIPTS = \
381
	daemons/daemon-util \
382
	daemons/ensure-dirs \
383
	tools/kvm-ifup \
384
	$(pkglib_python_scripts)
385

    
386
EXTRA_DIST = \
387
	NEWS \
388
	UPGRADE \
389
	epydoc.conf.in \
390
	pylintrc \
391
	autotools/build-bash-completion \
392
	autotools/build-zsh-completion \
393
	autotools/check-python-code \
394
	autotools/check-man \
395
	autotools/check-news \
396
	autotools/check-tar \
397
	autotools/check-version \
398
	autotools/gen-coverage \
399
	autotools/testrunner \
400
	$(RUN_IN_TEMPDIR) \
401
	daemons/daemon-util.in \
402
	daemons/ensure-dirs.in \
403
	daemons/ganeti-cleaner.in \
404
	$(pkglib_python_scripts) \
405
	devel/upload.in \
406
	tools/kvm-ifup.in \
407
	$(docdot) \
408
	$(docpng) \
409
	$(docrst) \
410
	doc/conf.py \
411
	doc/html \
412
	doc/examples/ganeti.initd.in \
413
	doc/examples/ganeti-kvm-poweroff.initd.in \
414
	doc/examples/ganeti.cron.in \
415
	doc/examples/gnt-config-backup.in \
416
	doc/examples/ganeti.default \
417
	doc/examples/ganeti.default-debug \
418
	doc/examples/hooks/ethers \
419
	doc/examples/hooks/ipsec.in \
420
	doc/examples/gnt-debug/README \
421
	doc/examples/gnt-debug/delay0.json \
422
	doc/examples/gnt-debug/delay50.json \
423
	test/testutils.py \
424
	test/mocks.py \
425
	$(dist_TESTS) \
426
	$(TEST_FILES) \
427
	man/footer.rst \
428
	$(manrst) \
429
	$(maninput) \
430
	qa/qa-sample.json \
431
	$(qa_scripts)
432

    
433
man_MANS = \
434
	man/ganeti.7 \
435
	man/ganeti-cleaner.8 \
436
	man/ganeti-confd.8 \
437
	man/ganeti-listrunner.8 \
438
	man/ganeti-masterd.8 \
439
	man/ganeti-noded.8 \
440
	man/ganeti-os-interface.7 \
441
	man/ganeti-rapi.8 \
442
	man/ganeti-watcher.8 \
443
	man/gnt-backup.8 \
444
	man/gnt-cluster.8 \
445
	man/gnt-debug.8 \
446
	man/gnt-group.8 \
447
	man/gnt-network.8 \
448
	man/gnt-instance.8 \
449
	man/gnt-job.8 \
450
	man/gnt-node.8 \
451
	man/gnt-os.8
452

    
453
manrst = $(patsubst %.7,%.rst,$(patsubst %.8,%.rst,$(man_MANS)))
454
manhtml = $(patsubst %.rst,%.html,$(manrst))
455
maninput = \
456
	$(patsubst %.7,%.7.in,$(patsubst %.8,%.8.in,$(man_MANS))) \
457
	$(patsubst %.html,%.html.in,$(manhtml)) \
458
	man/footer.man man/footer.html
459

    
460
TEST_FILES = \
461
	test/data/bdev-drbd-8.0.txt \
462
	test/data/bdev-drbd-8.3.txt \
463
	test/data/bdev-drbd-disk.txt \
464
	test/data/bdev-drbd-net-ip4.txt \
465
	test/data/bdev-drbd-net-ip6.txt \
466
	test/data/cert1.pem \
467
	test/data/proc_drbd8.txt \
468
	test/data/proc_drbd80-emptyline.txt \
469
	test/data/proc_drbd83.txt \
470
	test/data/sys_drbd_usermode_helper.txt \
471
	test/import-export_unittest-helper
472

    
473
python_tests = \
474
	test/ganeti.asyncnotifier_unittest.py \
475
	test/ganeti.backend_unittest.py \
476
	test/ganeti.bdev_unittest.py \
477
	test/ganeti.cli_unittest.py \
478
	test/ganeti.client.gnt_instance_unittest.py \
479
	test/ganeti.daemon_unittest.py \
480
	test/ganeti.cmdlib_unittest.py \
481
	test/ganeti.compat_unittest.py \
482
	test/ganeti.confd.client_unittest.py \
483
	test/ganeti.config_unittest.py \
484
	test/ganeti.constants_unittest.py \
485
	test/ganeti.errors_unittest.py \
486
	test/ganeti.hooks_unittest.py \
487
	test/ganeti.ht_unittest.py \
488
	test/ganeti.http_unittest.py \
489
	test/ganeti.hypervisor_unittest.py \
490
	test/ganeti.hypervisor.hv_chroot_unittest.py \
491
	test/ganeti.hypervisor.hv_fake_unittest.py \
492
	test/ganeti.hypervisor.hv_kvm_unittest.py \
493
	test/ganeti.hypervisor.hv_lxc_unittest.py \
494
	test/ganeti.hypervisor.hv_xen_unittest.py \
495
	test/ganeti.impexpd_unittest.py \
496
	test/ganeti.jqueue_unittest.py \
497
	test/ganeti.locking_unittest.py \
498
	test/ganeti.luxi_unittest.py \
499
	test/ganeti.masterd.instance_unittest.py \
500
	test/ganeti.mcpu_unittest.py \
501
	test/ganeti.netutils_unittest.py \
502
	test/ganeti.objects_unittest.py \
503
	test/ganeti.opcodes_unittest.py \
504
	test/ganeti.qlang_unittest.py \
505
	test/ganeti.query_unittest.py \
506
	test/ganeti.rapi.baserlib_unittest.py \
507
	test/ganeti.rapi.client_unittest.py \
508
	test/ganeti.rapi.resources_unittest.py \
509
	test/ganeti.rapi.rlib2_unittest.py \
510
	test/ganeti.rpc_unittest.py \
511
	test/ganeti.runtime_unittest.py \
512
	test/ganeti.serializer_unittest.py \
513
	test/ganeti.ssh_unittest.py \
514
	test/ganeti.uidpool_unittest.py \
515
	test/ganeti.utils.algo_unittest.py \
516
	test/ganeti.utils.filelock_unittest.py \
517
	test/ganeti.utils.hash_unittest.py \
518
	test/ganeti.utils.io_unittest.py \
519
	test/ganeti.utils.log_unittest.py \
520
	test/ganeti.utils.mlock_unittest.py \
521
	test/ganeti.utils.nodesetup_unittest.py \
522
	test/ganeti.utils.process_unittest.py \
523
	test/ganeti.utils.retry_unittest.py \
524
	test/ganeti.utils.text_unittest.py \
525
	test/ganeti.utils.wrapper_unittest.py \
526
	test/ganeti.utils.x509_unittest.py \
527
	test/ganeti.utils_unittest.py \
528
	test/ganeti.workerpool_unittest.py \
529
	test/cfgupgrade_unittest.py \
530
	test/docs_unittest.py \
531
	test/tempfile_fork_unittest.py
532

    
533
dist_TESTS = \
534
	test/check-cert-expired_unittest.bash \
535
	test/daemon-util_unittest.bash \
536
	test/ganeti-cleaner_unittest.bash \
537
	test/import-export_unittest.bash \
538
	$(python_tests)
539

    
540
nodist_TESTS =
541

    
542
TESTS = $(dist_TESTS) $(nodist_TESTS)
543

    
544
# Environment for all tests
545
PLAIN_TESTS_ENVIRONMENT = \
546
	PYTHONPATH=. TOP_SRCDIR=$(abs_top_srcdir) PYTHON=$(PYTHON) $(RUN_IN_TEMPDIR)
547

    
548
# Environment for tests run by automake
549
TESTS_ENVIRONMENT = \
550
	$(PLAIN_TESTS_ENVIRONMENT) $(abs_top_srcdir)/autotools/testrunner
551

    
552
all_python_code = \
553
	$(dist_sbin_SCRIPTS) \
554
	$(dist_tools_SCRIPTS) \
555
	$(pkglib_python_scripts) \
556
	$(python_tests) \
557
	$(pkgpython_PYTHON) \
558
	$(client_PYTHON) \
559
	$(hypervisor_PYTHON) \
560
	$(rapi_PYTHON) \
561
	$(server_PYTHON) \
562
	$(http_PYTHON) \
563
	$(confd_PYTHON) \
564
	$(masterd_PYTHON) \
565
	$(impexpd_PYTHON) \
566
	$(utils_PYTHON) \
567
	$(watcher_PYTHON) \
568
	$(noinst_PYTHON) \
569
	$(qa_scripts)
570

    
571
srclink_files = \
572
	man/footer.rst \
573
	test/check-cert-expired_unittest.bash \
574
	test/daemon-util_unittest.bash \
575
	test/ganeti-cleaner_unittest.bash \
576
	test/import-export_unittest.bash \
577
	$(all_python_code)
578

    
579
check_python_code = \
580
	$(BUILD_BASH_COMPLETION) \
581
	$(BUILD_ZSH_COMPLETION) \
582
	$(all_python_code)
583

    
584
lint_python_code = \
585
	ganeti \
586
	ganeti/http/server.py \
587
	$(dist_sbin_SCRIPTS) \
588
	$(dist_tools_SCRIPTS) \
589
	$(pkglib_python_scripts) \
590
	$(BUILD_BASH_COMPLETION) \
591
	$(BUILD_ZSH_COMPLETION) \
592
	$(PYTHON_BOOTSTRAP)
593

    
594
test/daemon-util_unittest.bash: daemons/daemon-util
595

    
596
test/ganeti-cleaner_unittest.bash: daemons/ganeti-cleaner
597

    
598
tools/kvm-ifup: tools/kvm-ifup.in $(REPLACE_VARS_SED)
599
	sed -f $(REPLACE_VARS_SED) < $< > $@
600
	chmod +x $@
601

    
602
devel/upload: devel/upload.in $(REPLACE_VARS_SED)
603
	sed -f $(REPLACE_VARS_SED) < $< > $@
604
	chmod u+x $@
605

    
606
daemons/%: daemons/%.in $(REPLACE_VARS_SED)
607
	sed -f $(REPLACE_VARS_SED) < $< > $@
608
	chmod +x $@
609

    
610
doc/examples/%: doc/examples/%.in $(REPLACE_VARS_SED)
611
	sed -f $(REPLACE_VARS_SED) < $< > $@
612

    
613
doc/examples/hooks/%: doc/examples/hooks/%.in $(REPLACE_VARS_SED)
614
	sed -f $(REPLACE_VARS_SED) < $< > $@
615

    
616
doc/examples/bash_completion: $(BUILD_BASH_COMPLETION) $(RUN_IN_TEMPDIR) \
617
	lib/cli.py $(gnt_scripts) $(client_PYTHON) tools/burnin
618
	PYTHONPATH=. $(RUN_IN_TEMPDIR) $(CURDIR)/$(BUILD_BASH_COMPLETION) > $@
619

    
620
doc/examples/zsh_completion: $(BUILD_BASH_COMPLETION) $(RUN_IN_TEMPDIR) \
621
	lib/cli.py $(gnt_scripts) $(client_PYTHON)
622
	PYTHONPATH=. $(RUN_IN_TEMPDIR) $(CURDIR)/$(BUILD_ZSH_COMPLETION) > $@
623

    
624
doc/%.png: doc/%.dot
625
	@test -n "$(DOT)" || { echo 'dot' not found during configure; exit 1; }
626
	$(DOT) -Tpng -o $@ $<
627

    
628
man/footer.man: man/footer.rst
629
	@test -n "$(PANDOC)" || \
630
	  { echo 'pandoc' not found during configure; exit 1; }
631
	$(PANDOC) -f rst -t man -o $@ $<
632

    
633
man/footer.html: man/footer.rst
634
	@test -n "$(PANDOC)" || \
635
	  { echo 'pandoc' not found during configure; exit 1; }
636
	$(PANDOC) -f rst -t html -o $@ $<
637

    
638
man/%.7.in man/%.8.in: man/%.rst man/footer.man
639
	@test -n "$(PANDOC)" || \
640
	  { echo 'pandoc' not found during configure; exit 1; }
641
	set -o pipefail ; \
642
	$(PANDOC) -s -f rst -t man -A man/footer.man $< | \
643
	  sed -e 's/\\@/@/g' > $@
644
	if test -n "$(MAN_HAS_WARNINGS)"; then $(CHECK_MAN) $@; fi
645

    
646
man/%.html.in: man/%.rst man/footer.html
647
	@test -n "$(PANDOC)" || \
648
	  { echo 'pandoc' not found during configure; exit 1; }
649
	set -o pipefail ; \
650
	$(PANDOC) -s -f rst -t html -A man/footer.html $< | \
651
	  sed -e 's/\\@/@/g' > $@
652

    
653
man/%.7: man/%.7.in $(REPLACE_VARS_SED)
654
	sed -f $(REPLACE_VARS_SED) < $< > $@
655

    
656
man/%.8: man/%.8.in $(REPLACE_VARS_SED)
657
	sed -f $(REPLACE_VARS_SED) < $< > $@
658

    
659
man/%.html: man/%.html.in $(REPLACE_VARS_SED)
660
	sed -f $(REPLACE_VARS_SED) < $< > $@
661

    
662
epydoc.conf: epydoc.conf.in
663
	sed -e 's#@MODULES@#$(lint_python_code)#g' < $< > $@
664

    
665
vcs-version:
666
	if test -d .git; then \
667
	  git describe > $@; \
668
	elif test ! -f $@ ; then \
669
	  echo "Cannot auto-generate $@ file"; exit 1; \
670
	fi
671

    
672
.PHONY: regen-vcs-version
673
regen-vcs-version:
674
	set -e; \
675
	cd $(srcdir); \
676
	if test -d .git; then \
677
	  rm -f vcs-version; \
678
	  $(MAKE) vcs-version; \
679
	fi
680

    
681
lib/_autoconf.py: Makefile vcs-version | lib/.dir
682
	set -e; \
683
	VCSVER=`cat $(abs_top_srcdir)/vcs-version`; \
684
	{ echo '# This file is automatically generated, do not edit!'; \
685
	  echo '#'; \
686
	  echo ''; \
687
	  echo '"""Build-time configuration for Ganeti.'; \
688
	  echo '';\
689
	  echo 'This file is autogenerated by the build process.'; \
690
	  echo 'For any changes you need to re-run ./configure (and'; \
691
	  echo 'not edit by hand).'; \
692
	  echo ''; \
693
	  echo '"""'; \
694
	  echo ''; \
695
	  echo '# pylint: disable-msg=C0301,C0324'; \
696
	  echo '# because this is autogenerated, we do not want'; \
697
	  echo '# style warnings' ; \
698
	  echo ''; \
699
	  echo "PACKAGE_VERSION = '$(PACKAGE_VERSION)'"; \
700
	  echo "VERSION_MAJOR = '$(VERSION_MAJOR)'"; \
701
	  echo "VERSION_MINOR = '$(VERSION_MINOR)'"; \
702
	  echo "VERSION_REVISION = '$(VERSION_REVISION)'"; \
703
	  echo "VERSION_SUFFIX = '$(VERSION_SUFFIX)'"; \
704
	  echo "VERSION_FULL = '$(VERSION_FULL)'"; \
705
	  echo "LOCALSTATEDIR = '$(localstatedir)'"; \
706
	  echo "SYSCONFDIR = '$(sysconfdir)'"; \
707
	  echo "SSH_CONFIG_DIR = '$(SSH_CONFIG_DIR)'"; \
708
	  echo "EXPORT_DIR = '$(EXPORT_DIR)'"; \
709
	  echo "OS_SEARCH_PATH = [$(OS_SEARCH_PATH)]"; \
710
	  echo "XEN_BOOTLOADER = '$(XEN_BOOTLOADER)'"; \
711
	  echo "XEN_KERNEL = '$(XEN_KERNEL)'"; \
712
	  echo "XEN_INITRD = '$(XEN_INITRD)'"; \
713
	  echo "FILE_STORAGE_DIR = '$(FILE_STORAGE_DIR)'"; \
714
	  echo "ENABLE_FILE_STORAGE = $(ENABLE_FILE_STORAGE)"; \
715
	  echo "SHARED_FILE_STORAGE_DIR = '$(SHARED_FILE_STORAGE_DIR)'"; \
716
	  echo "ENABLE_SHARED_FILE_STORAGE = $(ENABLE_SHARED_FILE_STORAGE)"; \
717
	  echo "IALLOCATOR_SEARCH_PATH = [$(IALLOCATOR_SEARCH_PATH)]"; \
718
	  echo "KVM_PATH = '$(KVM_PATH)'"; \
719
	  echo "SOCAT_PATH = '$(SOCAT)'"; \
720
	  echo "SOCAT_USE_ESCAPE = $(SOCAT_USE_ESCAPE)"; \
721
	  echo "SOCAT_USE_COMPRESS = $(SOCAT_USE_COMPRESS)"; \
722
	  echo "LVM_STRIPECOUNT = $(LVM_STRIPECOUNT)"; \
723
	  echo "TOOLSDIR = '$(toolsdir)'"; \
724
	  echo "GNT_SCRIPTS = [$(foreach i,$(notdir $(gnt_scripts)),'$(i)',)]"; \
725
	  echo "PKGLIBDIR = '$(pkglibdir)'"; \
726
	  echo "DRBD_BARRIERS = $(DRBD_BARRIERS)"; \
727
	  echo "SYSLOG_USAGE = '$(SYSLOG_USAGE)'"; \
728
	  echo "DAEMONS_GROUP = '$(DAEMONS_GROUP)'"; \
729
	  echo "ADMIN_GROUP = '$(ADMIN_GROUP)'"; \
730
	  echo "MASTERD_USER = '$(MASTERD_USER)'"; \
731
	  echo "MASTERD_GROUP = '$(MASTERD_GROUP)'"; \
732
	  echo "RAPI_USER = '$(RAPI_USER)'"; \
733
	  echo "RAPI_GROUP = '$(RAPI_GROUP)'"; \
734
	  echo "CONFD_USER = '$(CONFD_USER)'"; \
735
	  echo "CONFD_GROUP = '$(CONFD_GROUP)'"; \
736
	  echo "NODED_USER = '$(NODED_USER)'"; \
737
	  echo "VCS_VERSION = '$$VCSVER'"; \
738
	  echo "DISK_SEPARATOR = '$(DISK_SEPARATOR)'"; \
739
	} > $@
740

    
741
$(REPLACE_VARS_SED): Makefile
742
	set -e; \
743
	{ echo 's#@PREFIX@#$(prefix)#g'; \
744
	  echo 's#@SYSCONFDIR@#$(sysconfdir)#g'; \
745
	  echo 's#@LOCALSTATEDIR@#$(localstatedir)#g'; \
746
	  echo 's#@BINDIR@#$(bindir)#g'; \
747
	  echo 's#@SBINDIR@#$(sbindir)#g'; \
748
	  echo 's#@GANETI_VERSION@#$(PACKAGE_VERSION)#g'; \
749
	  echo 's#@CUSTOM_XEN_BOOTLOADER@#$(XEN_BOOTLOADER)#g'; \
750
	  echo 's#@CUSTOM_XEN_KERNEL@#$(XEN_KERNEL)#g'; \
751
	  echo 's#@CUSTOM_XEN_INITRD@#$(XEN_INITRD)#g'; \
752
	  echo 's#@CUSTOM_IALLOCATOR_SEARCH_PATH@#$(IALLOCATOR_SEARCH_PATH)#g'; \
753
	  echo 's#@CUSTOM_EXPORT_DIR@#$(EXPORT_DIR)#g'; \
754
	  echo 's#@RPL_FILE_STORAGE_DIR@#$(FILE_STORAGE_DIR)#g'; \
755
	  echo 's#@RPL_SSH_INITD_SCRIPT@#$(SSH_INITD_SCRIPT)#g'; \
756
	  echo 's#@PKGLIBDIR@#$(pkglibdir)#g'; \
757
	  echo 's#@GNTMASTERUSER@#$(MASTERD_USER)#g'; \
758
	  echo 's#@GNTRAPIUSER@#$(RAPI_USER)#g'; \
759
	  echo 's#@GNTCONFDUSER@#$(CONFD_USER)#g'; \
760
	  echo 's#@GNTNODEDUSER@#$(NODED_USER)#g'; \
761
	  echo 's#@GNTRAPIGROUP@#$(RAPI_GROUP)#g'; \
762
	  echo 's#@GNTADMINGROUP@#$(ADMIN_GROUP)#g'; \
763
	  echo 's#@GNTCONFDGROUP@#$(CONFD_GROUP)#g'; \
764
	  echo 's#@GNTMASTERDGROUP@#$(MASTERD_GROUP)#g'; \
765
	  echo 's#@GNTDAEMONSGROUP@#$(DAEMONS_GROUP)#g'; \
766
	} > $@
767

    
768
# Using deferred evaluation
769
daemons/ganeti-%: MODULE = ganeti.server.$(patsubst ganeti-%,%,$(notdir $@))
770
daemons/ganeti-watcher: MODULE = ganeti.watcher
771
scripts/%: MODULE = ganeti.client.$(subst -,_,$(notdir $@))
772

    
773
$(PYTHON_BOOTSTRAP): Makefile | $(all_dirfiles)
774
	test -n "$(MODULE)" || { echo Missing module; exit 1; }
775
	set -e; \
776
	{ echo '#!/usr/bin/python'; \
777
	  echo '# This file is automatically generated, do not edit!'; \
778
	  echo "# Edit $(MODULE) instead."; \
779
	  echo; \
780
	  echo '"""Bootstrap script for L{$(MODULE)}"""'; \
781
	  echo; \
782
	  echo '# pylint: disable-msg=C0103'; \
783
	  echo '# C0103: Invalid name'; \
784
	  echo; \
785
	  echo 'import sys'; \
786
	  echo 'import $(MODULE) as main'; \
787
	  echo; \
788
	  echo '# Temporarily alias commands until bash completion'; \
789
	  echo '# generator is changed'; \
790
	  echo 'if hasattr(main, "commands"):'; \
791
		echo '  commands = main.commands # pylint: disable-msg=E1101'; \
792
	  echo; \
793
	  echo 'if __name__ == "__main__":'; \
794
	  echo '  sys.exit(main.Main())'; \
795
	} > $@
796
	chmod u+x $@
797

    
798
# We need to create symlinks because "make distcheck" will not install Python
799
# files when building.
800
stamp-srclinks: Makefile | $(all_dirfiles)
801
	set -e; \
802
	for i in $(srclink_files); do \
803
		if test ! -f $$i -a -f $(abs_top_srcdir)/$$i; then \
804
			$(LN_S) $(abs_top_srcdir)/$$i $$i; \
805
		fi; \
806
	done
807
	touch $@
808

    
809
.PHONY: ganeti
810
ganeti:
811
	cd $(top_builddir) && test -h "$@" || { rm -f $@ && $(LN_S) lib $@; }
812

    
813
.PHONY: check-dirs
814
check-dirs: $(BUILT_SOURCES)
815
	@set -e; \
816
	find . -type d \( \( -name . \) -o \( \
817
		-name .git -o \
818
		-name autom4te.cache \
819
		\) -prune -o -print \) | { \
820
		error=; \
821
		while read dir; do \
822
			case "$$dir" in \
823
				$(strip $(patsubst %,(./%) ;;,$(DIRCHECK_EXCLUDE) $(DIRS))) \
824
				*) error=1; echo "Directory $$dir not listed in Makefile" >&2 ;; \
825
			esac; \
826
		done; \
827
		for dir in $(DIRS); do \
828
			if ! test -d "$$dir"; then \
829
				echo "Directory $$dir listed in DIRS does not exist" >&2; \
830
				error=1; \
831
			fi \
832
		done; \
833
		if test -n "$$error"; then exit 1; else exit 0; fi; \
834
	}
835

    
836
check-local: check-dirs
837
	$(CHECK_PYTHON_CODE) $(check_python_code)
838
	$(CHECK_VERSION) $(VERSION) $(top_srcdir)/NEWS
839
	$(CHECK_NEWS) < $(top_srcdir)/NEWS
840
	expver=$(VERSION_MAJOR).$(VERSION_MINOR); \
841
	if test "`head -n 1 $(top_srcdir)/README`" != "Ganeti $$expver"; then \
842
		echo "Incorrect version in README, expected $$expver"; \
843
		exit 1; \
844
	fi
845

    
846
.PHONY: lint
847
lint: $(BUILT_SOURCES)
848
	@test -n "$(PYLINT)" || { echo 'pylint' not found during configure; exit 1; }
849
	$(PYLINT) $(LINT_OPTS) $(lint_python_code)
850
	cd $(top_srcdir)/qa && \
851
	  PYTHONPATH=$(abs_top_srcdir) $(PYLINT) $(LINT_OPTS) \
852
	  --rcfile  ../pylintrc $(patsubst qa/%.py,%,$(qa_scripts))
853

    
854
# a dist hook rule for updating the vcs-version file; this is
855
# hardcoded due to where it needs to build the file...
856
dist-hook:
857
	$(MAKE) regen-vcs-version && \
858
	rm -f $(top_distdir)/vcs-version && \
859
	cp -p $(srcdir)/vcs-version $(top_distdir)
860

    
861
# a distcheck hook rule for catching revision control directories
862
distcheck-hook:
863
	if find $(top_distdir) -name .svn -or -name .git | grep .; then \
864
		echo "Found revision control files in final archive." 1>&2; \
865
		exit 1; \
866
	fi
867
	if find $(top_distdir) -name '*.py[co]' | grep .; then \
868
		echo "Found Python byte code in final archive." 1>&2; \
869
		exit 1; \
870
	fi
871
	if find $(top_distdir) -name '*~' | grep .; then \
872
		echo "Found backup files in final archive." 1>&2; \
873
		exit 1; \
874
	fi
875
# Empty files or directories should not be distributed. They can cause
876
# unnecessary warnings for packagers. Directories used by automake during
877
# distcheck must be excluded.
878
	if find $(top_distdir) -empty -and -not \( \
879
			-path $(top_distdir)/_build -or \
880
			-path $(top_distdir)/_inst \) | grep .; then \
881
		echo "Found empty files or directories in final archive." 1>&2; \
882
		exit 1; \
883
	fi
884
	if test -n "$(BUILD_RELEASE)" && \
885
	   grep -n -H -E '^\*.*unreleased' $(top_distdir)/NEWS; then \
886
		echo "Found unreleased version in NEWS." >&2; \
887
		exit 1; \
888
	fi
889

    
890
# When building a release, stricter checks should be used
891
distcheck-release dist-release: export BUILD_RELEASE = 1
892
distcheck-release: distcheck
893

    
894
dist-release: dist
895
	set -e; \
896
	for i in $(DIST_ARCHIVES); do \
897
		echo -n "Checking $$i ... "; \
898
		autotools/check-tar < $$i; \
899
		echo OK; \
900
	done
901

    
902
install-exec-local:
903
	@mkdir_p@ "$(DESTDIR)${localstatedir}/lib/ganeti" \
904
	  "$(DESTDIR)${localstatedir}/log/ganeti" \
905
	  "$(DESTDIR)${localstatedir}/run/ganeti"
906

    
907
# To avoid conflicts between directory names and other targets, a file inside
908
# the directory is used to ensure its existence.
909
%.dir:
910
	@mkdir_p@ $* && touch $@
911

    
912
.PHONY: apidoc
913
apidoc: epydoc.conf $(RUN_IN_TEMPDIR) $(BUILT_SOURCES)
914
	$(RUN_IN_TEMPDIR) epydoc -v \
915
		--conf $(CURDIR)/epydoc.conf \
916
		--output $(CURDIR)/doc/api
917

    
918
.PHONY: TAGS
919
TAGS: $(BUILT_SOURCES)
920
	rm -f TAGS
921
	find . -path './lib/*.py' -o -path './scripts/gnt-*' -o \
922
	  -path './daemons/ganeti-*' -o -path './tools/*' -o \
923
	  -path './qa/*.py' | \
924
	  etags -l python -
925

    
926
.PHONY: coverage
927
coverage: $(BUILT_SOURCES) $(python_tests)
928
	set -e; \
929
	COVERAGE_FILE=$(CURDIR)/doc/coverage/data \
930
	TEXT_COVERAGE=$(CURDIR)/doc/coverage/report.txt \
931
	HTML_COVERAGE=$(CURDIR)/doc/coverage \
932
	$(PLAIN_TESTS_ENVIRONMENT) $(abs_top_srcdir)/autotools/gen-coverage \
933
	$(python_tests)
934

    
935
commit-check: distcheck lint apidoc
936

    
937
-include ./Makefile.local
938

    
939
# vim: set noet :