Statistics
| Branch: | Tag: | Revision:

root / Makefile.am @ b91e9518

History | View | Annotate | Download (27.9 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
RUN_IN_TEMPDIR = $(top_srcdir)/autotools/run-in-tempdir
18
CHECK_PYTHON_CODE = $(top_srcdir)/autotools/check-python-code
19
CHECK_MAN = $(top_srcdir)/autotools/check-man
20
CHECK_VERSION = $(top_srcdir)/autotools/check-version
21
CHECK_NEWS = $(top_srcdir)/autotools/check-news
22
DOCPP = $(top_srcdir)/autotools/docpp
23
REPLACE_VARS_SED = autotools/replace_vars.sed
24

    
25
# Note: the variable must be named after the directory + 'dir' suffix
26
clientdir = $(pkgpythondir)/client
27
hypervisordir = $(pkgpythondir)/hypervisor
28
httpdir = $(pkgpythondir)/http
29
masterddir = $(pkgpythondir)/masterd
30
confddir = $(pkgpythondir)/confd
31
rapidir = $(pkgpythondir)/rapi
32
serverdir = $(pkgpythondir)/server
33
watcherdir = $(pkgpythondir)/watcher
34
impexpddir = $(pkgpythondir)/impexpd
35
utilsdir = $(pkgpythondir)/utils
36
toolsdir = $(pkglibdir)/tools
37
iallocatorsdir = $(pkglibdir)/iallocators
38
docdir = $(datadir)/doc/$(PACKAGE)
39

    
40
# Delete output file if an error occurred while building it
41
.DELETE_ON_ERROR:
42

    
43
HTOOLS_DIRS = \
44
	htools \
45
	htools/Ganeti \
46
	htools/Ganeti/HTools
47

    
48
DIRS = \
49
	autotools \
50
	daemons \
51
	devel \
52
	doc \
53
	doc/examples \
54
	doc/examples/hooks \
55
	doc/examples/gnt-debug \
56
	$(HTOOLS_DIRS) \
57
	lib \
58
	lib/client \
59
	lib/build \
60
	lib/confd \
61
	lib/http \
62
	lib/hypervisor \
63
	lib/impexpd \
64
	lib/masterd \
65
	lib/rapi \
66
	lib/server \
67
	lib/utils \
68
	lib/watcher \
69
	man \
70
	qa \
71
	test \
72
	test/data \
73
	tools
74

    
75
BUILDTIME_DIR_AUTOCREATE = \
76
	scripts \
77
	doc/api \
78
	doc/py-coverage \
79
	doc/hs-coverage \
80
	.hpc
81

    
82
BUILDTIME_DIRS = \
83
	$(BUILDTIME_DIR_AUTOCREATE) \
84
	doc/html
85

    
86
DIRCHECK_EXCLUDE = \
87
	$(BUILDTIME_DIRS) \
88
	ganeti-[0-9]*.[0-9]*.[0-9]* \
89
	doc/html/_*
90

    
91
all_dirfiles = $(addsuffix /.dir,$(DIRS) $(BUILDTIME_DIR_AUTOCREATE))
92

    
93
MAINTAINERCLEANFILES = \
94
	$(docpng) \
95
	$(maninput) \
96
	doc/install-quick.rst \
97
	doc/news.rst \
98
	doc/upgrade.rst \
99
	vcs-version
100

    
101
maintainer-clean-local:
102
	rm -rf $(BUILDTIME_DIRS)
103

    
104
CLEANFILES = \
105
	$(addsuffix /*.py[co],$(DIRS)) \
106
	$(addsuffix /*.hi,$(HTOOLS_DIRS)) \
107
	$(addsuffix /*.o,$(HTOOLS_DIRS)) \
108
	$(all_dirfiles) \
109
	$(PYTHON_BOOTSTRAP) \
110
	epydoc.conf \
111
	autotools/replace_vars.sed \
112
	daemons/daemon-util \
113
	daemons/ensure-dirs \
114
	daemons/ganeti-cleaner \
115
	devel/upload \
116
	doc/examples/bash_completion \
117
	doc/examples/ganeti.initd \
118
	doc/examples/ganeti-kvm-poweroff.initd \
119
	doc/examples/ganeti.cron \
120
	doc/examples/gnt-config-backup \
121
	doc/examples/hooks/ipsec \
122
	$(man_MANS) \
123
	$(manhtml) \
124
	tools/kvm-ifup \
125
	stamp-srclinks \
126
	$(nodist_pkgpython_PYTHON) \
127
	$(HALLPROGS) $(HSRCS2) \
128
	.hpc/*.mix htools/*.tix
129

    
130
# BUILT_SOURCES should only be used as a dependency on phony targets. Otherwise
131
# it'll cause the target to rebuild every time.
132
BUILT_SOURCES = \
133
	ganeti \
134
	stamp-srclinks \
135
	lib/_autoconf.py \
136
	$(all_dirfiles) \
137
	$(PYTHON_BOOTSTRAP)
138

    
139
nodist_pkgpython_PYTHON = \
140
	lib/_autoconf.py
141

    
142
noinst_PYTHON = \
143
	lib/build/__init__.py \
144
	lib/build/sphinx_ext.py
145

    
146
pkgpython_PYTHON = \
147
	lib/__init__.py \
148
	lib/asyncnotifier.py \
149
	lib/backend.py \
150
	lib/bdev.py \
151
	lib/bootstrap.py \
152
	lib/cli.py \
153
	lib/cmdlib.py \
154
	lib/compat.py \
155
	lib/config.py \
156
	lib/constants.py \
157
	lib/daemon.py \
158
	lib/errors.py \
159
	lib/ht.py \
160
	lib/jqueue.py \
161
	lib/jstore.py \
162
	lib/locking.py \
163
	lib/luxi.py \
164
	lib/mcpu.py \
165
	lib/netutils.py \
166
	lib/objects.py \
167
	lib/opcodes.py \
168
	lib/qlang.py \
169
	lib/query.py \
170
	lib/rpc.py \
171
	lib/runtime.py \
172
	lib/serializer.py \
173
	lib/ssconf.py \
174
	lib/ssh.py \
175
	lib/storage.py \
176
	lib/uidpool.py \
177
	lib/workerpool.py
178

    
179
client_PYTHON = \
180
	lib/client/__init__.py \
181
	lib/client/gnt_backup.py \
182
	lib/client/gnt_cluster.py \
183
	lib/client/gnt_debug.py \
184
	lib/client/gnt_group.py \
185
	lib/client/gnt_instance.py \
186
	lib/client/gnt_job.py \
187
	lib/client/gnt_node.py \
188
	lib/client/gnt_os.py
189

    
190
hypervisor_PYTHON = \
191
	lib/hypervisor/__init__.py \
192
	lib/hypervisor/hv_base.py \
193
	lib/hypervisor/hv_chroot.py \
194
	lib/hypervisor/hv_fake.py \
195
	lib/hypervisor/hv_kvm.py \
196
	lib/hypervisor/hv_lxc.py \
197
	lib/hypervisor/hv_xen.py
198

    
199
rapi_PYTHON = \
200
	lib/rapi/__init__.py \
201
	lib/rapi/baserlib.py \
202
	lib/rapi/client.py \
203
	lib/rapi/client_utils.py \
204
	lib/rapi/connector.py \
205
	lib/rapi/rlib2.py
206

    
207
http_PYTHON = \
208
	lib/http/__init__.py \
209
	lib/http/auth.py \
210
	lib/http/client.py \
211
	lib/http/server.py
212

    
213
confd_PYTHON = \
214
	lib/confd/__init__.py \
215
	lib/confd/client.py \
216
	lib/confd/querylib.py \
217
	lib/confd/server.py
218

    
219
masterd_PYTHON = \
220
	lib/masterd/__init__.py \
221
	lib/masterd/instance.py
222

    
223
impexpd_PYTHON = \
224
	lib/impexpd/__init__.py
225

    
226
watcher_PYTHON = \
227
	lib/watcher/__init__.py
228

    
229
server_PYTHON = \
230
	lib/server/__init__.py \
231
	lib/server/confd.py \
232
	lib/server/masterd.py \
233
	lib/server/noded.py \
234
	lib/server/rapi.py
235

    
236
utils_PYTHON = \
237
	lib/utils/__init__.py \
238
	lib/utils/algo.py \
239
	lib/utils/filelock.py \
240
	lib/utils/hash.py \
241
	lib/utils/io.py \
242
	lib/utils/log.py \
243
	lib/utils/mlock.py \
244
	lib/utils/nodesetup.py \
245
	lib/utils/process.py \
246
	lib/utils/retry.py \
247
	lib/utils/text.py \
248
	lib/utils/wrapper.py \
249
	lib/utils/x509.py
250

    
251
docrst = \
252
	doc/admin.rst \
253
	doc/design-2.0.rst \
254
	doc/design-2.1.rst \
255
	doc/design-2.2.rst \
256
	doc/design-2.3.rst \
257
	doc/design-htools-2.3.rst \
258
	doc/design-2.4.rst \
259
	doc/design-draft.rst \
260
	doc/design-oob.rst \
261
	doc/design-query2.rst \
262
	doc/cluster-merge.rst \
263
	doc/design-shared-storage.rst \
264
	doc/devnotes.rst \
265
	doc/glossary.rst \
266
	doc/hooks.rst \
267
	doc/iallocator.rst \
268
	doc/index.rst \
269
	doc/install-quick.rst \
270
	doc/install.rst \
271
	doc/locking.rst \
272
	doc/move-instance.rst \
273
	doc/news.rst \
274
	doc/rapi.rst \
275
	doc/security.rst \
276
	doc/upgrade.rst \
277
	doc/walkthrough.rst
278

    
279
HPROGS = \
280
	htools/hbal \
281
	htools/hscan \
282
	htools/hail \
283
	htools/hspace
284

    
285
HALLPROGS = $(HPROGS) htools/test
286
HSRCPROGS = $(patsubst %,%.hs,$(HALLPROGS))
287
# we don't add -Werror by default
288
HFLAGS = -O -Wall -fwarn-monomorphism-restriction -fwarn-tabs -ihtools
289
# extra flags that can be overriden on the command line
290
HEXTRA =
291
# exclude options for coverage reports
292
HPCEXCL = --exclude Main --exclude Ganeti.HTools.QC
293

    
294
HSRCS = \
295
	htools/Ganeti/HTools/CLI.hs \
296
	htools/Ganeti/HTools/Cluster.hs \
297
	htools/Ganeti/HTools/Container.hs \
298
	htools/Ganeti/HTools/ExtLoader.hs \
299
	htools/Ganeti/HTools/Group.hs \
300
	htools/Ganeti/HTools/IAlloc.hs \
301
	htools/Ganeti/HTools/Instance.hs \
302
	htools/Ganeti/HTools/Loader.hs \
303
	htools/Ganeti/HTools/Luxi.hs \
304
	htools/Ganeti/HTools/Node.hs \
305
	htools/Ganeti/HTools/PeerMap.hs \
306
	htools/Ganeti/HTools/QC.hs \
307
	htools/Ganeti/HTools/Rapi.hs \
308
	htools/Ganeti/HTools/Simu.hs \
309
	htools/Ganeti/HTools/Text.hs \
310
	htools/Ganeti/HTools/Types.hs \
311
	htools/Ganeti/HTools/Utils.hs \
312
	htools/Ganeti/Jobs.hs \
313
	htools/Ganeti/Luxi.hs \
314
	htools/Ganeti/OpCodes.hs
315

    
316
HSRCS2 = htools/Ganeti/HTools/Version.hs
317
HSRCS2IN = $(patsubst %,%.in,$(HSRCS2))
318

    
319
$(RUN_IN_TEMPDIR): | $(all_dirfiles)
320

    
321
# Note: we use here an order-only prerequisite, as the contents of
322
# _autoconf.py are not actually influencing the html build output: it
323
# has to exist in order for the sphinx module to be loaded
324
# successfully, but we certainly don't want the docs to be rebuilt if
325
# it changes
326
doc/html/index.html: $(docrst) $(docpng) doc/conf.py configure.ac \
327
	$(RUN_IN_TEMPDIR) lib/build/sphinx_ext.py lib/opcodes.py lib/ht.py \
328
	| lib/_autoconf.py
329
	@test -n "$(SPHINX)" || \
330
	    { echo 'sphinx-build' not found during configure; exit 1; }
331
	@mkdir_p@ $(dir $@)
332
	PYTHONPATH=. $(RUN_IN_TEMPDIR) $(SPHINX) -q -W -b html \
333
	    -d . \
334
	    -D version="$(VERSION_MAJOR).$(VERSION_MINOR)" \
335
	    -D release="$(PACKAGE_VERSION)" \
336
	    $(abs_top_srcdir)/doc $(CURDIR)/doc/html
337
	rm -f doc/html/.buildinfo doc/html/objects.inv
338
	touch $@
339

    
340
doc/html: doc/html/index.html
341

    
342
doc/install-quick.rst: INSTALL
343
doc/news.rst: NEWS
344
doc/upgrade.rst: UPGRADE
345

    
346
doc/install-quick.rst doc/news.rst doc/upgrade.rst:
347
	set -e; \
348
	{ echo '.. This file is automatically updated at build time from $<.'; \
349
	  echo '.. Do not edit.'; \
350
	  echo; \
351
	  cat $<; \
352
	} > $@
353

    
354
docdot = \
355
	doc/arch-2.0.dot \
356
	doc/design-2.1-lock-acquire.dot \
357
	doc/design-2.1-lock-release.dot
358

    
359
docpng = $(patsubst %.dot,%.png,$(docdot))
360

    
361
# Things to build but not to install (add it to EXTRA_DIST if it should be
362
# distributed)
363
noinst_DATA = \
364
	devel/upload \
365
	doc/html \
366
	doc/examples/bash_completion \
367
	doc/examples/ganeti.cron \
368
	doc/examples/ganeti.initd \
369
	doc/examples/ganeti-kvm-poweroff.initd \
370
	doc/examples/gnt-config-backup \
371
	doc/examples/hooks/ipsec \
372
	$(manhtml)
373

    
374
gnt_scripts = \
375
	scripts/gnt-backup \
376
	scripts/gnt-cluster \
377
	scripts/gnt-debug \
378
	scripts/gnt-group \
379
	scripts/gnt-instance \
380
	scripts/gnt-job \
381
	scripts/gnt-node \
382
	scripts/gnt-os
383

    
384
PYTHON_BOOTSTRAP = \
385
	daemons/ganeti-confd \
386
	daemons/ganeti-masterd \
387
	daemons/ganeti-noded \
388
	daemons/ganeti-watcher \
389
	daemons/ganeti-rapi \
390
	scripts/gnt-backup \
391
	scripts/gnt-cluster \
392
	scripts/gnt-debug \
393
	scripts/gnt-group \
394
	scripts/gnt-instance \
395
	scripts/gnt-job \
396
	scripts/gnt-node \
397
	scripts/gnt-os
398

    
399
qa_scripts = \
400
	qa/ganeti-qa.py \
401
	qa/qa_cluster.py \
402
	qa/qa_config.py \
403
	qa/qa_daemon.py \
404
	qa/qa_env.py \
405
	qa/qa_error.py \
406
	qa/qa_instance.py \
407
	qa/qa_node.py \
408
	qa/qa_os.py \
409
	qa/qa_rapi.py \
410
	qa/qa_tags.py \
411
	qa/qa_utils.py
412

    
413
bin_SCRIPTS =
414
iallocators_SCRIPTS =
415
if WANT_HTOOLS
416
bin_SCRIPTS += $(filter-out htools/hail,$(HPROGS))
417
iallocators_SCRIPTS += $(filter htools/hail,$(HPROGS))
418
endif
419

    
420
$(HALLPROGS): %: %.hs $(HSRCS) $(HSRCS2) Makefile
421
	BINARY=$(@:htools/%=%); \
422
	$(GHC) --make \
423
	  $(HFLAGS) $(HEXTRA) $(HTOOLS_NOCURL) \
424
	  -osuf $$BINARY.o -hisuf $$BINARY.hi \
425
	  $@
426

    
427
# for the htools/test binary, we need to enable profiling/coverage
428
htools/test: HEXTRA=-fhpc -Wwarn -fno-warn-missing-signatures \
429
	-fno-warn-monomorphism-restriction -fno-warn-orphans \
430
	-fno-warn-missing-methods -fno-warn-unused-imports
431

    
432
dist_sbin_SCRIPTS = \
433
	tools/ganeti-listrunner
434

    
435
nodist_sbin_SCRIPTS = \
436
	$(PYTHON_BOOTSTRAP) \
437
	daemons/ganeti-cleaner
438

    
439
dist_tools_SCRIPTS = \
440
	tools/burnin \
441
	tools/cfgshell \
442
	tools/cfgupgrade \
443
	tools/cfgupgrade12 \
444
	tools/cluster-merge \
445
	tools/lvmstrap \
446
	tools/move-instance \
447
	tools/setup-ssh \
448
	tools/sanitize-config
449

    
450
pkglib_python_scripts = \
451
	daemons/import-export \
452
	tools/check-cert-expired
453

    
454
pkglib_SCRIPTS = \
455
	daemons/daemon-util \
456
	daemons/ensure-dirs \
457
	tools/kvm-ifup \
458
	$(pkglib_python_scripts)
459

    
460
EXTRA_DIST = \
461
	NEWS \
462
	UPGRADE \
463
	epydoc.conf.in \
464
	pylintrc \
465
	autotools/build-bash-completion \
466
	autotools/check-python-code \
467
	autotools/check-man \
468
	autotools/check-news \
469
	autotools/check-tar \
470
	autotools/check-version \
471
	autotools/docpp \
472
	autotools/gen-coverage \
473
	autotools/testrunner \
474
	$(RUN_IN_TEMPDIR) \
475
	daemons/daemon-util.in \
476
	daemons/ensure-dirs.in \
477
	daemons/ganeti-cleaner.in \
478
	$(pkglib_python_scripts) \
479
	devel/upload.in \
480
	tools/kvm-ifup.in \
481
	$(docdot) \
482
	$(docpng) \
483
	$(docrst) \
484
	doc/conf.py \
485
	doc/html \
486
	doc/examples/ganeti.initd.in \
487
	doc/examples/ganeti-kvm-poweroff.initd.in \
488
	doc/examples/ganeti.cron.in \
489
	doc/examples/gnt-config-backup.in \
490
	doc/examples/ganeti.default \
491
	doc/examples/ganeti.default-debug \
492
	doc/examples/hooks/ethers \
493
	doc/examples/hooks/ipsec.in \
494
	doc/examples/gnt-debug/README \
495
	doc/examples/gnt-debug/delay0.json \
496
	doc/examples/gnt-debug/delay50.json \
497
	test/testutils.py \
498
	test/mocks.py \
499
	$(dist_TESTS) \
500
	$(TEST_FILES) \
501
	man/footer.rst \
502
	$(manrst) \
503
	$(maninput) \
504
	qa/qa-sample.json \
505
	$(qa_scripts) \
506
	$(HSRCS) $(HSRCS2IN) \
507
	$(HSRCPROGS)
508

    
509
man_MANS = \
510
	man/ganeti.7 \
511
	man/ganeti-cleaner.8 \
512
	man/ganeti-confd.8 \
513
	man/ganeti-listrunner.8 \
514
	man/ganeti-masterd.8 \
515
	man/ganeti-noded.8 \
516
	man/ganeti-os-interface.7 \
517
	man/ganeti-rapi.8 \
518
	man/ganeti-watcher.8 \
519
	man/gnt-backup.8 \
520
	man/gnt-cluster.8 \
521
	man/gnt-debug.8 \
522
	man/gnt-group.8 \
523
	man/gnt-instance.8 \
524
	man/gnt-job.8 \
525
	man/gnt-node.8 \
526
	man/gnt-os.8 \
527
	man/hail.1 \
528
	man/hbal.1 \
529
	man/hscan.1 \
530
	man/hspace.1
531

    
532
manrst = $(patsubst %.1,%.rst,$(patsubst %.7,%.rst,$(patsubst %.8,%.rst,$(man_MANS))))
533
manhtml = $(patsubst %.rst,%.html,$(manrst))
534
mangen = $(patsubst %.rst,%.gen,$(manrst))
535
maninput = \
536
	$(patsubst %.1,%.1.in,$(patsubst %.7,%.7.in,$(patsubst %.8,%.8.in,$(man_MANS)))) \
537
	$(patsubst %.html,%.html.in,$(manhtml)) \
538
	man/footer.man man/footer.html $(mangen)
539

    
540
TEST_FILES = \
541
	test/data/bdev-drbd-8.0.txt \
542
	test/data/bdev-drbd-8.3.txt \
543
	test/data/bdev-drbd-disk.txt \
544
	test/data/bdev-drbd-net-ip4.txt \
545
	test/data/bdev-drbd-net-ip6.txt \
546
	test/data/cert1.pem \
547
	test/data/proc_drbd8.txt \
548
	test/data/proc_drbd80-emptyline.txt \
549
	test/data/proc_drbd83.txt \
550
	test/data/sys_drbd_usermode_helper.txt \
551
	test/import-export_unittest-helper
552

    
553
python_tests = \
554
	test/ganeti.asyncnotifier_unittest.py \
555
	test/ganeti.backend_unittest.py \
556
	test/ganeti.bdev_unittest.py \
557
	test/ganeti.cli_unittest.py \
558
	test/ganeti.client.gnt_cluster_unittest.py \
559
	test/ganeti.client.gnt_instance_unittest.py \
560
	test/ganeti.daemon_unittest.py \
561
	test/ganeti.cmdlib_unittest.py \
562
	test/ganeti.compat_unittest.py \
563
	test/ganeti.confd.client_unittest.py \
564
	test/ganeti.config_unittest.py \
565
	test/ganeti.constants_unittest.py \
566
	test/ganeti.errors_unittest.py \
567
	test/ganeti.hooks_unittest.py \
568
	test/ganeti.ht_unittest.py \
569
	test/ganeti.http_unittest.py \
570
	test/ganeti.hypervisor_unittest.py \
571
	test/ganeti.hypervisor.hv_chroot_unittest.py \
572
	test/ganeti.hypervisor.hv_fake_unittest.py \
573
	test/ganeti.hypervisor.hv_kvm_unittest.py \
574
	test/ganeti.hypervisor.hv_lxc_unittest.py \
575
	test/ganeti.hypervisor.hv_xen_unittest.py \
576
	test/ganeti.impexpd_unittest.py \
577
	test/ganeti.jqueue_unittest.py \
578
	test/ganeti.locking_unittest.py \
579
	test/ganeti.luxi_unittest.py \
580
	test/ganeti.masterd.instance_unittest.py \
581
	test/ganeti.mcpu_unittest.py \
582
	test/ganeti.netutils_unittest.py \
583
	test/ganeti.objects_unittest.py \
584
	test/ganeti.opcodes_unittest.py \
585
	test/ganeti.qlang_unittest.py \
586
	test/ganeti.query_unittest.py \
587
	test/ganeti.rapi.baserlib_unittest.py \
588
	test/ganeti.rapi.client_unittest.py \
589
	test/ganeti.rapi.resources_unittest.py \
590
	test/ganeti.rapi.rlib2_unittest.py \
591
	test/ganeti.rpc_unittest.py \
592
	test/ganeti.runtime_unittest.py \
593
	test/ganeti.serializer_unittest.py \
594
	test/ganeti.ssh_unittest.py \
595
	test/ganeti.uidpool_unittest.py \
596
	test/ganeti.utils.algo_unittest.py \
597
	test/ganeti.utils.filelock_unittest.py \
598
	test/ganeti.utils.hash_unittest.py \
599
	test/ganeti.utils.io_unittest.py \
600
	test/ganeti.utils.log_unittest.py \
601
	test/ganeti.utils.mlock_unittest.py \
602
	test/ganeti.utils.nodesetup_unittest.py \
603
	test/ganeti.utils.process_unittest.py \
604
	test/ganeti.utils.retry_unittest.py \
605
	test/ganeti.utils.text_unittest.py \
606
	test/ganeti.utils.wrapper_unittest.py \
607
	test/ganeti.utils.x509_unittest.py \
608
	test/ganeti.utils_unittest.py \
609
	test/ganeti.workerpool_unittest.py \
610
	test/cfgupgrade_unittest.py \
611
	test/docs_unittest.py \
612
	test/tempfile_fork_unittest.py
613

    
614
haskell_tests = htools/test
615

    
616
dist_TESTS = \
617
	test/check-cert-expired_unittest.bash \
618
	test/daemon-util_unittest.bash \
619
	test/ganeti-cleaner_unittest.bash \
620
	test/import-export_unittest.bash \
621
	$(python_tests)
622

    
623
nodist_TESTS =
624
if WANT_HTOOLS
625
nodist_TESTS += $(haskell_tests)
626
endif
627

    
628
TESTS = $(dist_TESTS) $(nodist_TESTS)
629

    
630
# Environment for all tests
631
PLAIN_TESTS_ENVIRONMENT = \
632
	PYTHONPATH=. TOP_SRCDIR=$(abs_top_srcdir) PYTHON=$(PYTHON) $(RUN_IN_TEMPDIR)
633

    
634
# Environment for tests run by automake
635
TESTS_ENVIRONMENT = \
636
	$(PLAIN_TESTS_ENVIRONMENT) $(abs_top_srcdir)/autotools/testrunner
637

    
638
all_python_code = \
639
	$(dist_sbin_SCRIPTS) \
640
	$(dist_tools_SCRIPTS) \
641
	$(pkglib_python_scripts) \
642
	$(python_tests) \
643
	$(pkgpython_PYTHON) \
644
	$(client_PYTHON) \
645
	$(hypervisor_PYTHON) \
646
	$(rapi_PYTHON) \
647
	$(server_PYTHON) \
648
	$(http_PYTHON) \
649
	$(confd_PYTHON) \
650
	$(masterd_PYTHON) \
651
	$(impexpd_PYTHON) \
652
	$(utils_PYTHON) \
653
	$(watcher_PYTHON) \
654
	$(noinst_PYTHON) \
655
	$(qa_scripts)
656

    
657
srclink_files = \
658
	man/footer.rst \
659
	test/check-cert-expired_unittest.bash \
660
	test/daemon-util_unittest.bash \
661
	test/ganeti-cleaner_unittest.bash \
662
	test/import-export_unittest.bash \
663
	$(all_python_code) \
664
	$(HSRCS) $(HSRCPROGS)
665

    
666
check_python_code = \
667
	$(BUILD_BASH_COMPLETION) \
668
	$(DOCPP) \
669
	$(all_python_code)
670

    
671
lint_python_code = \
672
	ganeti \
673
	ganeti/http/server.py \
674
	$(dist_sbin_SCRIPTS) \
675
	$(dist_tools_SCRIPTS) \
676
	$(pkglib_python_scripts) \
677
	$(BUILD_BASH_COMPLETION) \
678
	$(DOCPP) \
679
	$(PYTHON_BOOTSTRAP)
680

    
681
test/daemon-util_unittest.bash: daemons/daemon-util
682

    
683
test/ganeti-cleaner_unittest.bash: daemons/ganeti-cleaner
684

    
685
tools/kvm-ifup: tools/kvm-ifup.in $(REPLACE_VARS_SED)
686
	sed -f $(REPLACE_VARS_SED) < $< > $@
687
	chmod +x $@
688

    
689
devel/upload: devel/upload.in $(REPLACE_VARS_SED)
690
	sed -f $(REPLACE_VARS_SED) < $< > $@
691
	chmod u+x $@
692

    
693
daemons/%: daemons/%.in $(REPLACE_VARS_SED)
694
	sed -f $(REPLACE_VARS_SED) < $< > $@
695
	chmod +x $@
696

    
697
doc/examples/%: doc/examples/%.in $(REPLACE_VARS_SED)
698
	sed -f $(REPLACE_VARS_SED) < $< > $@
699

    
700
doc/examples/hooks/%: doc/examples/hooks/%.in $(REPLACE_VARS_SED)
701
	sed -f $(REPLACE_VARS_SED) < $< > $@
702

    
703
doc/examples/bash_completion: $(BUILD_BASH_COMPLETION) $(RUN_IN_TEMPDIR) \
704
	lib/cli.py $(gnt_scripts) $(client_PYTHON) tools/burnin
705
	PYTHONPATH=. $(RUN_IN_TEMPDIR) $(CURDIR)/$(BUILD_BASH_COMPLETION) > $@
706

    
707
doc/%.png: doc/%.dot
708
	@test -n "$(DOT)" || { echo 'dot' not found during configure; exit 1; }
709
	$(DOT) -Tpng -o $@ $<
710

    
711
man/footer.man: man/footer.rst
712
	@test -n "$(PANDOC)" || \
713
	  { echo 'pandoc' not found during configure; exit 1; }
714
	$(PANDOC) -f rst -t man -o $@ $<
715

    
716
man/footer.html: man/footer.rst
717
	@test -n "$(PANDOC)" || \
718
	  { echo 'pandoc' not found during configure; exit 1; }
719
	$(PANDOC) -f rst -t html -o $@ $<
720

    
721
man/%.gen: man/%.rst lib/query.py lib/build/sphinx_ext.py
722
	PYTHONPATH=. $(RUN_IN_TEMPDIR) $(CURDIR)/$(DOCPP) < $< > $@
723

    
724
man/%.7.in man/%.8.in man/%.1.in: man/%.gen man/footer.man
725
	@test -n "$(PANDOC)" || \
726
	  { echo 'pandoc' not found during configure; exit 1; }
727
	set -o pipefail ; \
728
	$(PANDOC) -s -f rst -t man -A man/footer.man $< | \
729
	  sed -e 's/\\@/@/g' > $@
730
	if test -n "$(MAN_HAS_WARNINGS)"; then $(CHECK_MAN) $@; fi
731

    
732
man/%.html.in: man/%.gen man/footer.html
733
	@test -n "$(PANDOC)" || \
734
	  { echo 'pandoc' not found during configure; exit 1; }
735
	set -o pipefail ; \
736
	$(PANDOC) -s -f rst -t html -A man/footer.html $< | \
737
	  sed -e 's/\\@/@/g' > $@
738

    
739
man/%.1: man/%.1.in $(REPLACE_VARS_SED)
740
	sed -f $(REPLACE_VARS_SED) < $< > $@
741

    
742
man/%.7: man/%.7.in $(REPLACE_VARS_SED)
743
	sed -f $(REPLACE_VARS_SED) < $< > $@
744

    
745
man/%.8: man/%.8.in $(REPLACE_VARS_SED)
746
	sed -f $(REPLACE_VARS_SED) < $< > $@
747

    
748
man/%.html: man/%.html.in $(REPLACE_VARS_SED)
749
	sed -f $(REPLACE_VARS_SED) < $< > $@
750

    
751
epydoc.conf: epydoc.conf.in Makefile
752
	sed -e 's#@MODULES@#$(strip $(lint_python_code))#g' < $< > $@
753

    
754
vcs-version:
755
	if test -d .git; then \
756
	  git describe > $@; \
757
	elif test ! -f $@ ; then \
758
	  echo "Cannot auto-generate $@ file"; exit 1; \
759
	fi
760

    
761
.PHONY: regen-vcs-version
762
regen-vcs-version:
763
	set -e; \
764
	cd $(srcdir); \
765
	if test -d .git; then \
766
	  rm -f vcs-version; \
767
	  $(MAKE) vcs-version; \
768
	fi
769

    
770
htools/Ganeti/HTools/Version.hs: htools/Ganeti/HTools/Version.hs.in vcs-version
771
	set -e; \
772
	VCSVER=`cat $(abs_top_srcdir)/vcs-version`; \
773
	sed -e "s/%ver%/$$VCSVER/" < $< > $@
774

    
775
lib/_autoconf.py: Makefile vcs-version | lib/.dir
776
	set -e; \
777
	VCSVER=`cat $(abs_top_srcdir)/vcs-version`; \
778
	{ echo '# This file is automatically generated, do not edit!'; \
779
	  echo '#'; \
780
	  echo ''; \
781
	  echo '"""Build-time configuration for Ganeti.'; \
782
	  echo '';\
783
	  echo 'This file is autogenerated by the build process.'; \
784
	  echo 'For any changes you need to re-run ./configure (and'; \
785
	  echo 'not edit by hand).'; \
786
	  echo ''; \
787
	  echo '"""'; \
788
	  echo ''; \
789
	  echo '# pylint: disable-msg=C0301,C0324'; \
790
	  echo '# because this is autogenerated, we do not want'; \
791
	  echo '# style warnings' ; \
792
	  echo ''; \
793
	  echo "PACKAGE_VERSION = '$(PACKAGE_VERSION)'"; \
794
	  echo "VERSION_MAJOR = '$(VERSION_MAJOR)'"; \
795
	  echo "VERSION_MINOR = '$(VERSION_MINOR)'"; \
796
	  echo "VERSION_REVISION = '$(VERSION_REVISION)'"; \
797
	  echo "VERSION_SUFFIX = '$(VERSION_SUFFIX)'"; \
798
	  echo "VERSION_FULL = '$(VERSION_FULL)'"; \
799
	  echo "LOCALSTATEDIR = '$(localstatedir)'"; \
800
	  echo "SYSCONFDIR = '$(sysconfdir)'"; \
801
	  echo "SSH_CONFIG_DIR = '$(SSH_CONFIG_DIR)'"; \
802
	  echo "EXPORT_DIR = '$(EXPORT_DIR)'"; \
803
	  echo "OS_SEARCH_PATH = [$(OS_SEARCH_PATH)]"; \
804
	  echo "XEN_BOOTLOADER = '$(XEN_BOOTLOADER)'"; \
805
	  echo "XEN_KERNEL = '$(XEN_KERNEL)'"; \
806
	  echo "XEN_INITRD = '$(XEN_INITRD)'"; \
807
	  echo "FILE_STORAGE_DIR = '$(FILE_STORAGE_DIR)'"; \
808
	  echo "ENABLE_FILE_STORAGE = $(ENABLE_FILE_STORAGE)"; \
809
	  echo "SHARED_FILE_STORAGE_DIR = '$(SHARED_FILE_STORAGE_DIR)'"; \
810
	  echo "ENABLE_SHARED_FILE_STORAGE = $(ENABLE_SHARED_FILE_STORAGE)"; \
811
	  echo "IALLOCATOR_SEARCH_PATH = [$(IALLOCATOR_SEARCH_PATH)]"; \
812
	  echo "KVM_PATH = '$(KVM_PATH)'"; \
813
	  echo "SOCAT_PATH = '$(SOCAT)'"; \
814
	  echo "SOCAT_USE_ESCAPE = $(SOCAT_USE_ESCAPE)"; \
815
	  echo "SOCAT_USE_COMPRESS = $(SOCAT_USE_COMPRESS)"; \
816
	  echo "LVM_STRIPECOUNT = $(LVM_STRIPECOUNT)"; \
817
	  echo "TOOLSDIR = '$(toolsdir)'"; \
818
	  echo "GNT_SCRIPTS = [$(foreach i,$(notdir $(gnt_scripts)),'$(i)',)]"; \
819
	  echo "PKGLIBDIR = '$(pkglibdir)'"; \
820
	  echo "DRBD_BARRIERS = $(DRBD_BARRIERS)"; \
821
	  echo "SYSLOG_USAGE = '$(SYSLOG_USAGE)'"; \
822
	  echo "DAEMONS_GROUP = '$(DAEMONS_GROUP)'"; \
823
	  echo "ADMIN_GROUP = '$(ADMIN_GROUP)'"; \
824
	  echo "MASTERD_USER = '$(MASTERD_USER)'"; \
825
	  echo "MASTERD_GROUP = '$(MASTERD_GROUP)'"; \
826
	  echo "RAPI_USER = '$(RAPI_USER)'"; \
827
	  echo "RAPI_GROUP = '$(RAPI_GROUP)'"; \
828
	  echo "CONFD_USER = '$(CONFD_USER)'"; \
829
	  echo "CONFD_GROUP = '$(CONFD_GROUP)'"; \
830
	  echo "NODED_USER = '$(NODED_USER)'"; \
831
	  echo "VCS_VERSION = '$$VCSVER'"; \
832
	  echo "DISK_SEPARATOR = '$(DISK_SEPARATOR)'"; \
833
	} > $@
834

    
835
$(REPLACE_VARS_SED): Makefile
836
	set -e; \
837
	{ echo 's#@PREFIX@#$(prefix)#g'; \
838
	  echo 's#@SYSCONFDIR@#$(sysconfdir)#g'; \
839
	  echo 's#@LOCALSTATEDIR@#$(localstatedir)#g'; \
840
	  echo 's#@BINDIR@#$(bindir)#g'; \
841
	  echo 's#@SBINDIR@#$(sbindir)#g'; \
842
	  echo 's#@GANETI_VERSION@#$(PACKAGE_VERSION)#g'; \
843
	  echo 's#@CUSTOM_XEN_BOOTLOADER@#$(XEN_BOOTLOADER)#g'; \
844
	  echo 's#@CUSTOM_XEN_KERNEL@#$(XEN_KERNEL)#g'; \
845
	  echo 's#@CUSTOM_XEN_INITRD@#$(XEN_INITRD)#g'; \
846
	  echo 's#@CUSTOM_IALLOCATOR_SEARCH_PATH@#$(IALLOCATOR_SEARCH_PATH)#g'; \
847
	  echo 's#@CUSTOM_EXPORT_DIR@#$(EXPORT_DIR)#g'; \
848
	  echo 's#@RPL_FILE_STORAGE_DIR@#$(FILE_STORAGE_DIR)#g'; \
849
	  echo 's#@RPL_SSH_INITD_SCRIPT@#$(SSH_INITD_SCRIPT)#g'; \
850
	  echo 's#@PKGLIBDIR@#$(pkglibdir)#g'; \
851
	  echo 's#@GNTMASTERUSER@#$(MASTERD_USER)#g'; \
852
	  echo 's#@GNTRAPIUSER@#$(RAPI_USER)#g'; \
853
	  echo 's#@GNTCONFDUSER@#$(CONFD_USER)#g'; \
854
	  echo 's#@GNTNODEDUSER@#$(NODED_USER)#g'; \
855
	  echo 's#@GNTRAPIGROUP@#$(RAPI_GROUP)#g'; \
856
	  echo 's#@GNTADMINGROUP@#$(ADMIN_GROUP)#g'; \
857
	  echo 's#@GNTCONFDGROUP@#$(CONFD_GROUP)#g'; \
858
	  echo 's#@GNTMASTERDGROUP@#$(MASTERD_GROUP)#g'; \
859
	  echo 's#@GNTDAEMONSGROUP@#$(DAEMONS_GROUP)#g'; \
860
	} > $@
861

    
862
# Using deferred evaluation
863
daemons/ganeti-%: MODULE = ganeti.server.$(patsubst ganeti-%,%,$(notdir $@))
864
daemons/ganeti-watcher: MODULE = ganeti.watcher
865
scripts/%: MODULE = ganeti.client.$(subst -,_,$(notdir $@))
866

    
867
$(PYTHON_BOOTSTRAP): Makefile | $(all_dirfiles)
868
	test -n "$(MODULE)" || { echo Missing module; exit 1; }
869
	set -e; \
870
	{ echo '#!/usr/bin/python'; \
871
	  echo '# This file is automatically generated, do not edit!'; \
872
	  echo "# Edit $(MODULE) instead."; \
873
	  echo; \
874
	  echo '"""Bootstrap script for L{$(MODULE)}"""'; \
875
	  echo; \
876
	  echo '# pylint: disable-msg=C0103'; \
877
	  echo '# C0103: Invalid name'; \
878
	  echo; \
879
	  echo 'import sys'; \
880
	  echo 'import $(MODULE) as main'; \
881
	  echo; \
882
	  echo '# Temporarily alias commands until bash completion'; \
883
	  echo '# generator is changed'; \
884
	  echo 'if hasattr(main, "commands"):'; \
885
		echo '  commands = main.commands # pylint: disable-msg=E1101'; \
886
	  echo; \
887
	  echo 'if __name__ == "__main__":'; \
888
	  echo '  sys.exit(main.Main())'; \
889
	} > $@
890
	chmod u+x $@
891

    
892
# We need to create symlinks because "make distcheck" will not install Python
893
# files when building.
894
stamp-srclinks: Makefile | $(all_dirfiles)
895
	set -e; \
896
	for i in $(srclink_files); do \
897
		if test ! -f $$i -a -f $(abs_top_srcdir)/$$i; then \
898
			$(LN_S) $(abs_top_srcdir)/$$i $$i; \
899
		fi; \
900
	done
901
	touch $@
902

    
903
.PHONY: ganeti
904
ganeti:
905
	cd $(top_builddir) && test -h "$@" || { rm -f $@ && $(LN_S) lib $@; }
906

    
907
.PHONY: check-dirs
908
check-dirs: $(BUILT_SOURCES)
909
	@set -e; \
910
	find . -type d \( \( -name . \) -o \( \
911
		-name .git -o \
912
		-name autom4te.cache \
913
		\) -prune -o -print \) | { \
914
		error=; \
915
		while read dir; do \
916
			case "$$dir" in \
917
				$(strip $(patsubst %,(./%) ;;,$(DIRCHECK_EXCLUDE) $(DIRS))) \
918
				*) error=1; echo "Directory $$dir not listed in Makefile" >&2 ;; \
919
			esac; \
920
		done; \
921
		for dir in $(DIRS); do \
922
			if ! test -d "$$dir"; then \
923
				echo "Directory $$dir listed in DIRS does not exist" >&2; \
924
				error=1; \
925
			fi \
926
		done; \
927
		if test -n "$$error"; then exit 1; else exit 0; fi; \
928
	}
929

    
930
check-local: check-dirs
931
	$(CHECK_PYTHON_CODE) $(check_python_code)
932
	$(CHECK_VERSION) $(VERSION) $(top_srcdir)/NEWS
933
	$(CHECK_NEWS) < $(top_srcdir)/NEWS
934

    
935
.PHONY: lint
936
lint: $(BUILT_SOURCES)
937
	@test -n "$(PYLINT)" || { echo 'pylint' not found during configure; exit 1; }
938
	$(PYLINT) $(LINT_OPTS) $(lint_python_code)
939
	cd $(top_srcdir)/qa && \
940
	  PYTHONPATH=$(abs_top_srcdir) $(PYLINT) $(LINT_OPTS) \
941
	  --rcfile  ../pylintrc $(patsubst qa/%.py,%,$(qa_scripts))
942

    
943
# a dist hook rule for updating the vcs-version file; this is
944
# hardcoded due to where it needs to build the file...
945
dist-hook:
946
	$(MAKE) regen-vcs-version && \
947
	rm -f $(top_distdir)/vcs-version && \
948
	cp -p $(srcdir)/vcs-version $(top_distdir)
949

    
950
# a distcheck hook rule for catching revision control directories
951
distcheck-hook:
952
	if find $(top_distdir) -name .svn -or -name .git | grep .; then \
953
		echo "Found revision control files in final archive." 1>&2; \
954
		exit 1; \
955
	fi
956
	if find $(top_distdir) -name '*.py[co]' | grep .; then \
957
		echo "Found Python byte code in final archive." 1>&2; \
958
		exit 1; \
959
	fi
960
	if find $(top_distdir) -name '*~' | grep .; then \
961
		echo "Found backup files in final archive." 1>&2; \
962
		exit 1; \
963
	fi
964
# Empty files or directories should not be distributed. They can cause
965
# unnecessary warnings for packagers. Directories used by automake during
966
# distcheck must be excluded.
967
	if find $(top_distdir) -empty -and -not \( \
968
			-path $(top_distdir)/_build -or \
969
			-path $(top_distdir)/_inst \) | grep .; then \
970
		echo "Found empty files or directories in final archive." 1>&2; \
971
		exit 1; \
972
	fi
973
	if test -n "$(BUILD_RELEASE)" && \
974
	   grep -n -H -E '^\*.*unreleased' $(top_distdir)/NEWS; then \
975
		echo "Found unreleased version in NEWS." >&2; \
976
		exit 1; \
977
	fi
978

    
979
# When building a release, stricter checks should be used
980
distcheck-release dist-release: export BUILD_RELEASE = 1
981
distcheck-release: distcheck
982

    
983
dist-release: dist
984
	set -e; \
985
	for i in $(DIST_ARCHIVES); do \
986
		echo -n "Checking $$i ... "; \
987
		autotools/check-tar < $$i; \
988
		echo OK; \
989
	done
990

    
991
install-exec-local:
992
	@mkdir_p@ "$(DESTDIR)${localstatedir}/lib/ganeti" \
993
	  "$(DESTDIR)${localstatedir}/log/ganeti" \
994
	  "$(DESTDIR)${localstatedir}/run/ganeti"
995

    
996
# To avoid conflicts between directory names and other targets, a file inside
997
# the directory is used to ensure its existence.
998
%.dir:
999
	@mkdir_p@ $* && touch $@
1000

    
1001
.PHONY: apidoc
1002
apidoc: epydoc.conf $(RUN_IN_TEMPDIR) $(BUILT_SOURCES)
1003
	$(RUN_IN_TEMPDIR) epydoc -v \
1004
		--conf $(CURDIR)/epydoc.conf \
1005
		--output $(CURDIR)/doc/api
1006

    
1007
.PHONY: TAGS
1008
TAGS: $(BUILT_SOURCES)
1009
	rm -f TAGS
1010
	find . -path './lib/*.py' -o -path './scripts/gnt-*' -o \
1011
	  -path './daemons/ganeti-*' -o -path './tools/*' -o \
1012
	  -path './qa/*.py' | \
1013
	  etags -l python -
1014

    
1015
.PHONY: coverage
1016
if WANT_HTOOLS
1017
coverage: py-coverage hs-coverage
1018
else
1019
coverage: py-coverage
1020
endif
1021

    
1022
.PHONY: py-coverage
1023
py-coverage: $(BUILT_SOURCES) $(python_tests)
1024
	set -e; \
1025
	COVERAGE_FILE=$(CURDIR)/doc/py-coverage/data \
1026
	TEXT_COVERAGE=$(CURDIR)/doc/py-coverage/report.txt \
1027
	HTML_COVERAGE=$(CURDIR)/doc/py-coverage \
1028
	$(PLAIN_TESTS_ENVIRONMENT) $(abs_top_srcdir)/autotools/gen-coverage \
1029
	$(python_tests)
1030

    
1031
.PHONY: hs-coverage
1032
hs-coverage: $(haskell_tests)
1033
	cd htools && rm -f *.tix *.mix && ./test
1034
	mkdir -p doc/hs-coverage
1035
	hpc markup --destdir=doc/hs-coverage htools/test $(HPCEXCL)
1036
	hpc report htools/test $(HPCEXCL)
1037

    
1038

    
1039
commit-check: distcheck lint apidoc
1040

    
1041
-include ./Makefile.local
1042

    
1043
# vim: set noet :