Statistics
| Branch: | Tag: | Revision:

root / Makefile.am @ aa75500a

History | View | Annotate | Download (49.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
# Helper values for calling builtin functions
13
empty :=
14
space := $(empty) $(empty)
15
comma := ,
16

    
17
# Use bash in order to be able to use pipefail
18
SHELL=/bin/bash
19

    
20
ACLOCAL_AMFLAGS = -I autotools
21
BUILD_BASH_COMPLETION = $(top_srcdir)/autotools/build-bash-completion
22
RUN_IN_TEMPDIR = $(top_srcdir)/autotools/run-in-tempdir
23
CHECK_PYTHON_CODE = $(top_srcdir)/autotools/check-python-code
24
CHECK_HEADER = $(top_srcdir)/autotools/check-header
25
CHECK_MAN_DASHES = $(top_srcdir)/autotools/check-man-dashes
26
CHECK_MAN_WARNINGS = $(top_srcdir)/autotools/check-man-warnings
27
CHECK_VERSION = $(top_srcdir)/autotools/check-version
28
CHECK_NEWS = $(top_srcdir)/autotools/check-news
29
CHECK_IMPORTS = $(top_srcdir)/autotools/check-imports
30
DOCPP = $(top_srcdir)/autotools/docpp
31
REPLACE_VARS_SED = autotools/replace_vars.sed
32
CONVERT_CONSTANTS = $(top_srcdir)/autotools/convert-constants
33
BUILD_RPC = $(top_srcdir)/autotools/build-rpc
34
SHELL_ENV_INIT = autotools/shell-env-init
35

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

    
54
# Delete output file if an error occurred while building it
55
.DELETE_ON_ERROR:
56

    
57
HTOOLS_DIRS = \
58
	htools \
59
	htools/Ganeti \
60
	htools/Ganeti/Confd \
61
	htools/Ganeti/HTools \
62
	htools/Ganeti/HTools/Backend \
63
	htools/Ganeti/HTools/Program \
64
	htools/Ganeti/Query \
65
	htest \
66
	htest/Test \
67
	htest/Test/Ganeti \
68
	htest/Test/Ganeti/Confd \
69
	htest/Test/Ganeti/HTools \
70
	htest/Test/Ganeti/HTools/Backend \
71
	htest/Test/Ganeti/Query
72

    
73
DIRS = \
74
	$(HTOOLS_DIRS) \
75
	autotools \
76
	daemons \
77
	devel \
78
	doc \
79
	doc/examples \
80
	doc/examples/gnt-debug \
81
	doc/examples/hooks \
82
	htest/data \
83
	htest/data/rapi \
84
	htest/shelltests \
85
	lib \
86
	lib/build \
87
	lib/client \
88
	lib/confd \
89
	lib/http \
90
	lib/hypervisor \
91
	lib/impexpd \
92
	lib/masterd \
93
	lib/rapi \
94
	lib/server \
95
	lib/tools \
96
	lib/utils \
97
	lib/watcher \
98
	man \
99
	qa \
100
	test \
101
	test/data \
102
	test/data/ovfdata \
103
	test/data/ovfdata/other \
104
	tools
105

    
106
BUILDTIME_DIR_AUTOCREATE = \
107
	scripts \
108
	$(APIDOC_DIR) \
109
	$(APIDOC_HS_DIR) \
110
	$(APIDOC_HS_DIR)/Ganeti \
111
	$(APIDOC_HS_DIR)/Ganeti/Confd \
112
	$(APIDOC_HS_DIR)/Ganeti/HTools \
113
	$(APIDOC_HS_DIR)/Ganeti/HTools/Backend \
114
	$(APIDOC_HS_DIR)/Ganeti/HTools/Program \
115
	$(APIDOC_HS_DIR)/Ganeti/Query \
116
	$(APIDOC_PY_DIR) \
117
	$(COVERAGE_DIR) \
118
	$(COVERAGE_HS_DIR) \
119
	$(COVERAGE_PY_DIR) \
120
	.hpc
121

    
122
BUILDTIME_DIRS = \
123
	$(BUILDTIME_DIR_AUTOCREATE) \
124
	doc/html
125

    
126
DIRCHECK_EXCLUDE = \
127
	$(BUILDTIME_DIRS) \
128
	ganeti-[0-9]*.[0-9]*.[0-9]* \
129
	doc/html/_*
130

    
131
# some helper vars
132
COVERAGE_DIR = doc/coverage
133
COVERAGE_PY_DIR = $(COVERAGE_DIR)/py
134
COVERAGE_HS_DIR = $(COVERAGE_DIR)/hs
135
APIDOC_DIR = doc/api
136
APIDOC_PY_DIR = $(APIDOC_DIR)/py
137
APIDOC_HS_DIR = $(APIDOC_DIR)/hs
138

    
139
MAINTAINERCLEANFILES = \
140
	$(docpng) \
141
	$(maninput) \
142
	doc/install-quick.rst \
143
	doc/news.rst \
144
	doc/upgrade.rst \
145
	vcs-version
146

    
147
maintainer-clean-local:
148
	rm -rf $(BUILDTIME_DIRS)
149

    
150
CLEANFILES = \
151
	$(addsuffix /*.py[co],$(DIRS)) \
152
	$(addsuffix /*.hi,$(HTOOLS_DIRS)) \
153
	$(addsuffix /*.o,$(HTOOLS_DIRS)) \
154
	$(PYTHON_BOOTSTRAP) \
155
	epydoc.conf \
156
	$(REPLACE_VARS_SED) \
157
	$(SHELL_ENV_INIT) \
158
	daemons/daemon-util \
159
	daemons/ganeti-cleaner \
160
	$(BUILT_EXAMPLES) \
161
	doc/examples/bash_completion \
162
	doc/examples/bash_completion-debug \
163
	lib/_generated_rpc.py \
164
	$(man_MANS) \
165
	$(manhtml) \
166
	tools/kvm-ifup \
167
	tools/vcluster-setup \
168
	stamp-directories \
169
	stamp-srclinks \
170
	$(nodist_pkgpython_PYTHON) \
171
	$(HS_ALL_PROGS) $(HS_BUILT_SRCS) \
172
	$(HS_BUILT_TEST_HELPERS) \
173
	htools/ganeti-confd \
174
	.hpc/*.mix htools/*.tix htest/*.tix \
175
	doc/hs-lint.html
176

    
177
GENERATED_FILES = \
178
	$(built_base_sources) \
179
	$(BUILT_PYTHON_SOURCES) \
180
	$(PYTHON_BOOTSTRAP)
181

    
182
HTOOLS_GENERATED_FILES =
183
if WANT_HTOOLS
184
HTOOLS_GENERATED_FILES += $(HS_PROGS)
185
if ENABLE_CONFD
186
HTOOLS_GENERATED_FILES += htools/hconfd htools/ganeti-confd
187
endif
188
endif
189

    
190
built_base_sources = \
191
	stamp-directories \
192
	stamp-srclinks
193

    
194
built_python_base_sources = \
195
	lib/_autoconf.py \
196
	lib/_vcsversion.py
197

    
198
BUILT_PYTHON_SOURCES = \
199
	$(built_python_base_sources) \
200
	lib/_generated_rpc.py
201

    
202
# Generating the RPC wrappers depends on many things, so make sure
203
# it's built at the end of the built sources
204
lib/_generated_rpc.py: | $(built_base_sources) $(built_python_base_sources)
205

    
206
# these are all built from the underlying %.in sources
207
BUILT_EXAMPLES = \
208
	doc/examples/ganeti-kvm-poweroff.initd \
209
	doc/examples/ganeti.cron \
210
	doc/examples/ganeti.initd \
211
	doc/examples/ganeti-master-role.ocf \
212
	doc/examples/gnt-config-backup \
213
	doc/examples/hooks/ipsec
214

    
215
nodist_pkgpython_PYTHON = \
216
	$(BUILT_PYTHON_SOURCES)
217

    
218
noinst_PYTHON = \
219
	lib/build/__init__.py \
220
	lib/build/shell_example_lexer.py \
221
	lib/build/sphinx_ext.py
222

    
223
pkgpython_PYTHON = \
224
	lib/__init__.py \
225
	lib/asyncnotifier.py \
226
	lib/backend.py \
227
	lib/bdev.py \
228
	lib/bootstrap.py \
229
	lib/cli.py \
230
	lib/cmdlib.py \
231
	lib/compat.py \
232
	lib/config.py \
233
	lib/constants.py \
234
	lib/daemon.py \
235
	lib/errors.py \
236
	lib/ht.py \
237
	lib/jqueue.py \
238
	lib/jstore.py \
239
	lib/locking.py \
240
	lib/luxi.py \
241
	lib/mcpu.py \
242
	lib/netutils.py \
243
	lib/objects.py \
244
	lib/objectutils.py \
245
	lib/opcodes.py \
246
	lib/ovf.py \
247
	lib/pathutils.py \
248
	lib/qlang.py \
249
	lib/query.py \
250
	lib/rpc.py \
251
	lib/rpc_defs.py \
252
	lib/runtime.py \
253
	lib/serializer.py \
254
	lib/ssconf.py \
255
	lib/ssh.py \
256
	lib/storage.py \
257
	lib/uidpool.py \
258
	lib/vcluster.py \
259
	lib/workerpool.py
260

    
261
client_PYTHON = \
262
	lib/client/__init__.py \
263
	lib/client/gnt_backup.py \
264
	lib/client/gnt_cluster.py \
265
	lib/client/gnt_debug.py \
266
	lib/client/gnt_group.py \
267
	lib/client/gnt_instance.py \
268
	lib/client/gnt_job.py \
269
	lib/client/gnt_node.py \
270
	lib/client/gnt_os.py
271

    
272
hypervisor_PYTHON = \
273
	lib/hypervisor/__init__.py \
274
	lib/hypervisor/hv_base.py \
275
	lib/hypervisor/hv_chroot.py \
276
	lib/hypervisor/hv_fake.py \
277
	lib/hypervisor/hv_kvm.py \
278
	lib/hypervisor/hv_lxc.py \
279
	lib/hypervisor/hv_xen.py
280

    
281
rapi_PYTHON = \
282
	lib/rapi/__init__.py \
283
	lib/rapi/baserlib.py \
284
	lib/rapi/client.py \
285
	lib/rapi/client_utils.py \
286
	lib/rapi/connector.py \
287
	lib/rapi/rlib2.py \
288
	lib/rapi/testutils.py
289

    
290
http_PYTHON = \
291
	lib/http/__init__.py \
292
	lib/http/auth.py \
293
	lib/http/client.py \
294
	lib/http/server.py
295

    
296
confd_PYTHON = \
297
	lib/confd/__init__.py \
298
	lib/confd/client.py
299

    
300
masterd_PYTHON = \
301
	lib/masterd/__init__.py \
302
	lib/masterd/iallocator.py \
303
	lib/masterd/instance.py
304

    
305
impexpd_PYTHON = \
306
	lib/impexpd/__init__.py
307

    
308
watcher_PYTHON = \
309
	lib/watcher/__init__.py \
310
	lib/watcher/nodemaint.py \
311
	lib/watcher/state.py
312

    
313
server_PYTHON = \
314
	lib/server/__init__.py \
315
	lib/server/masterd.py \
316
	lib/server/noded.py \
317
	lib/server/rapi.py
318

    
319
pytools_PYTHON = \
320
	lib/tools/__init__.py \
321
	lib/tools/ensure_dirs.py \
322
	lib/tools/prepare_node_join.py
323

    
324
utils_PYTHON = \
325
	lib/utils/__init__.py \
326
	lib/utils/algo.py \
327
	lib/utils/filelock.py \
328
	lib/utils/hash.py \
329
	lib/utils/io.py \
330
	lib/utils/log.py \
331
	lib/utils/mlock.py \
332
	lib/utils/nodesetup.py \
333
	lib/utils/process.py \
334
	lib/utils/retry.py \
335
	lib/utils/text.py \
336
	lib/utils/wrapper.py \
337
	lib/utils/x509.py
338

    
339
docrst = \
340
	doc/admin.rst \
341
	doc/cluster-merge.rst \
342
	doc/design-2.0.rst \
343
	doc/design-2.1.rst \
344
	doc/design-2.2.rst \
345
	doc/design-2.3.rst \
346
	doc/design-2.4.rst \
347
	doc/design-2.5.rst \
348
	doc/design-2.6.rst \
349
	doc/design-2.7.rst \
350
	doc/design-autorepair.rst \
351
	doc/design-bulk-create.rst \
352
	doc/design-chained-jobs.rst \
353
	doc/design-cpu-pinning.rst \
354
	doc/design-draft.rst \
355
	doc/design-htools-2.3.rst \
356
	doc/design-http-server.rst \
357
	doc/design-impexp2.rst \
358
	doc/design-lu-generated-jobs.rst \
359
	doc/design-linuxha.rst \
360
	doc/design-multi-reloc.rst \
361
	doc/design-network.rst \
362
	doc/design-oob.rst \
363
	doc/design-ovf-support.rst \
364
	doc/design-partitioned.rst \
365
	doc/design-query-splitting.rst \
366
	doc/design-query2.rst \
367
	doc/design-remote-commands.rst \
368
	doc/design-resource-model.rst \
369
	doc/design-shared-storage.rst \
370
	doc/design-ssh-setup.rst \
371
	doc/design-monitoring-agent.rst \
372
	doc/design-virtual-clusters.rst \
373
	doc/design-x509-ca.rst \
374
	doc/devnotes.rst \
375
	doc/glossary.rst \
376
	doc/hooks.rst \
377
	doc/iallocator.rst \
378
	doc/index.rst \
379
	doc/install-quick.rst \
380
	doc/install.rst \
381
	doc/locking.rst \
382
	doc/move-instance.rst \
383
	doc/news.rst \
384
	doc/ovfconverter.rst \
385
	doc/rapi.rst \
386
	doc/security.rst \
387
	doc/upgrade.rst \
388
	doc/virtual-cluster.rst \
389
	doc/walkthrough.rst
390

    
391
HS_PROGS = htools/htools
392
HS_BIN_ROLES = hbal hscan hspace hinfo hcheck
393
HS_HTOOLS_PROGS = $(HS_BIN_ROLES) hail
394

    
395
HS_ALL_PROGS = \
396
	$(HS_PROGS) \
397
	htest/hpc-htools \
398
	htest/test \
399
	htools/hconfd \
400
	htools/rpc-test
401

    
402
HS_PROG_SRCS = $(patsubst %,%.hs,$(HS_ALL_PROGS))
403
HS_BUILT_TEST_HELPERS = $(HS_BIN_ROLES:%=htest/%) htest/hail
404

    
405
HFLAGS = \
406
	-O -Wall -Werror -ihtools \
407
	-fwarn-monomorphism-restriction \
408
	-fwarn-tabs \
409
	$(GHC_BYVERSION_FLAGS)
410

    
411
# extra flags that can be overriden on the command line (e.g. -Wwarn, etc.)
412
HEXTRA =
413
# internal extra flags (used for htest/test mainly)
414
HEXTRA_INT =
415
# exclude options for coverage reports
416
HPCEXCL = --exclude Main \
417
	--exclude Ganeti.Constants \
418
	--exclude Ganeti.HTools.QC \
419
	--exclude Ganeti.THH \
420
	--exclude Ganeti.Version \
421
	--exclude Test.Ganeti.TestCommon \
422
	--exclude Test.Ganeti.TestHTools \
423
	--exclude Test.Ganeti.TestHelper \
424
	--exclude Test.Ganeti.TestImports \
425
	$(patsubst htools.%,--exclude Test.%,$(subst /,.,$(patsubst %.hs,%, $(HS_LIB_SRCS))))
426

    
427
HS_LIB_SRCS = \
428
	htools/Ganeti/BasicTypes.hs \
429
	htools/Ganeti/Common.hs \
430
	htools/Ganeti/Compat.hs \
431
	htools/Ganeti/Confd/Server.hs \
432
	htools/Ganeti/Confd/Types.hs \
433
	htools/Ganeti/Confd/Utils.hs \
434
	htools/Ganeti/Config.hs \
435
	htools/Ganeti/Daemon.hs \
436
	htools/Ganeti/Errors.hs \
437
	htools/Ganeti/HTools/Backend/IAlloc.hs \
438
	htools/Ganeti/HTools/Backend/Luxi.hs \
439
	htools/Ganeti/HTools/Backend/Rapi.hs \
440
	htools/Ganeti/HTools/Backend/Simu.hs \
441
	htools/Ganeti/HTools/Backend/Text.hs \
442
	htools/Ganeti/HTools/CLI.hs \
443
	htools/Ganeti/HTools/Cluster.hs \
444
	htools/Ganeti/HTools/Container.hs \
445
	htools/Ganeti/HTools/ExtLoader.hs \
446
	htools/Ganeti/HTools/Group.hs \
447
	htools/Ganeti/HTools/Instance.hs \
448
	htools/Ganeti/HTools/Loader.hs \
449
	htools/Ganeti/HTools/Node.hs \
450
	htools/Ganeti/HTools/PeerMap.hs \
451
	htools/Ganeti/HTools/Program.hs \
452
	htools/Ganeti/HTools/Program/Hail.hs \
453
	htools/Ganeti/HTools/Program/Hbal.hs \
454
	htools/Ganeti/HTools/Program/Hcheck.hs \
455
	htools/Ganeti/HTools/Program/Hinfo.hs \
456
	htools/Ganeti/HTools/Program/Hscan.hs \
457
	htools/Ganeti/HTools/Program/Hspace.hs \
458
	htools/Ganeti/HTools/Types.hs \
459
	htools/Ganeti/Hash.hs \
460
	htools/Ganeti/JSON.hs \
461
	htools/Ganeti/Jobs.hs \
462
	htools/Ganeti/Logging.hs \
463
	htools/Ganeti/Luxi.hs \
464
	htools/Ganeti/Objects.hs \
465
	htools/Ganeti/OpCodes.hs \
466
	htools/Ganeti/Path.hs \
467
	htools/Ganeti/Query/Common.hs \
468
	htools/Ganeti/Query/Filter.hs \
469
	htools/Ganeti/Query/Group.hs \
470
	htools/Ganeti/Query/Language.hs \
471
	htools/Ganeti/Query/Node.hs \
472
	htools/Ganeti/Query/Query.hs \
473
	htools/Ganeti/Query/Server.hs \
474
	htools/Ganeti/Query/Types.hs \
475
	htools/Ganeti/Rpc.hs \
476
	htools/Ganeti/Runtime.hs \
477
	htools/Ganeti/Ssconf.hs \
478
	htools/Ganeti/THH.hs \
479
	htools/Ganeti/Utils.hs
480

    
481
HS_TEST_SRCS = \
482
	htest/Test/Ganeti/Attoparsec.hs \
483
	htest/Test/Ganeti/BasicTypes.hs \
484
	htest/Test/Ganeti/Common.hs \
485
	htest/Test/Ganeti/Confd/Utils.hs \
486
	htest/Test/Ganeti/Daemon.hs \
487
	htest/Test/Ganeti/Errors.hs \
488
	htest/Test/Ganeti/HTools/Backend/Simu.hs \
489
	htest/Test/Ganeti/HTools/Backend/Text.hs \
490
	htest/Test/Ganeti/HTools/CLI.hs \
491
	htest/Test/Ganeti/HTools/Cluster.hs \
492
	htest/Test/Ganeti/HTools/Container.hs \
493
	htest/Test/Ganeti/HTools/Instance.hs \
494
	htest/Test/Ganeti/HTools/Loader.hs \
495
	htest/Test/Ganeti/HTools/Node.hs \
496
	htest/Test/Ganeti/HTools/PeerMap.hs \
497
	htest/Test/Ganeti/HTools/Types.hs \
498
	htest/Test/Ganeti/JSON.hs \
499
	htest/Test/Ganeti/Jobs.hs \
500
	htest/Test/Ganeti/Luxi.hs \
501
	htest/Test/Ganeti/Objects.hs \
502
	htest/Test/Ganeti/OpCodes.hs \
503
	htest/Test/Ganeti/Query/Filter.hs \
504
	htest/Test/Ganeti/Query/Language.hs \
505
	htest/Test/Ganeti/Query/Query.hs \
506
	htest/Test/Ganeti/Rpc.hs \
507
	htest/Test/Ganeti/Ssconf.hs \
508
	htest/Test/Ganeti/THH.hs \
509
	htest/Test/Ganeti/TestCommon.hs \
510
	htest/Test/Ganeti/TestHTools.hs \
511
	htest/Test/Ganeti/TestHelper.hs \
512
	htest/Test/Ganeti/Utils.hs
513

    
514
HS_LIBTEST_SRCS = $(HS_LIB_SRCS) $(HS_TEST_SRCS)
515

    
516
HS_BUILT_SRCS = \
517
	htest/Test/Ganeti/TestImports.hs \
518
	htools/Ganeti/Constants.hs \
519
	htools/Ganeti/Version.hs
520
HS_BUILT_SRCS_IN = $(patsubst %,%.in,$(HS_BUILT_SRCS))
521

    
522
$(RUN_IN_TEMPDIR): | stamp-directories
523

    
524
# Note: we use here an order-only prerequisite, as the contents of
525
# _autoconf.py are not actually influencing the html build output: it
526
# has to exist in order for the sphinx module to be loaded
527
# successfully, but we certainly don't want the docs to be rebuilt if
528
# it changes
529
doc/html/index.html: $(docrst) $(docpng) doc/conf.py configure.ac \
530
	$(RUN_IN_TEMPDIR) lib/build/sphinx_ext.py \
531
	lib/build/shell_example_lexer.py lib/opcodes.py lib/ht.py \
532
	| $(BUILT_PYTHON_SOURCES)
533
	@test -n "$(SPHINX)" || \
534
	    { echo 'sphinx-build' not found during configure; exit 1; }
535
	@mkdir_p@ $(dir $@)
536
	PYTHONPATH=. $(RUN_IN_TEMPDIR) $(SPHINX) -q -W -b html \
537
	    -d . \
538
	    -D version="$(VERSION_MAJOR).$(VERSION_MINOR)" \
539
	    -D release="$(PACKAGE_VERSION)" \
540
	    $(abs_top_srcdir)/doc $(CURDIR)/doc/html
541
	rm -f doc/html/.buildinfo doc/html/objects.inv
542
	touch $@
543

    
544
doc/html: doc/html/index.html
545

    
546
doc/install-quick.rst: INSTALL
547
doc/news.rst: NEWS
548
doc/upgrade.rst: UPGRADE
549

    
550
doc/install-quick.rst doc/news.rst doc/upgrade.rst:
551
	set -e; \
552
	{ echo '.. This file is automatically updated at build time from $<.'; \
553
	  echo '.. Do not edit.'; \
554
	  echo; \
555
	  cat $<; \
556
	} > $@
557

    
558
docdot = \
559
	doc/arch-2.0.dot \
560
	doc/design-2.1-lock-acquire.dot \
561
	doc/design-2.1-lock-release.dot
562

    
563
docpng = $(patsubst %.dot,%.png,$(docdot))
564

    
565
# Things to build but not to install (add it to EXTRA_DIST if it should be
566
# distributed)
567
noinst_DATA = \
568
	doc/html \
569
	$(BUILT_EXAMPLES) \
570
	doc/examples/bash_completion \
571
	doc/examples/bash_completion-debug \
572
	$(manhtml)
573

    
574
gnt_scripts = \
575
	scripts/gnt-backup \
576
	scripts/gnt-cluster \
577
	scripts/gnt-debug \
578
	scripts/gnt-group \
579
	scripts/gnt-instance \
580
	scripts/gnt-job \
581
	scripts/gnt-node \
582
	scripts/gnt-os
583

    
584
PYTHON_BOOTSTRAP_SBIN = \
585
	daemons/ganeti-masterd \
586
	daemons/ganeti-noded \
587
	daemons/ganeti-rapi \
588
	daemons/ganeti-watcher \
589
	$(gnt_scripts)
590

    
591
PYTHON_BOOTSTRAP = \
592
	$(PYTHON_BOOTSTRAP_SBIN) \
593
	tools/ensure-dirs \
594
	tools/prepare-node-join
595

    
596
qa_scripts = \
597
	qa/__init__.py \
598
	qa/ganeti-qa.py \
599
	qa/qa_cluster.py \
600
	qa/qa_config.py \
601
	qa/qa_daemon.py \
602
	qa/qa_env.py \
603
	qa/qa_error.py \
604
	qa/qa_group.py \
605
	qa/qa_instance.py \
606
	qa/qa_job.py \
607
	qa/qa_node.py \
608
	qa/qa_os.py \
609
	qa/qa_rapi.py \
610
	qa/qa_tags.py \
611
	qa/qa_utils.py
612

    
613
bin_SCRIPTS =
614
if WANT_HTOOLS
615
bin_SCRIPTS += $(filter-out htools/hail,$(HS_PROGS))
616
install-exec-hook:
617
	@mkdir_p@ $(DESTDIR)$(iallocatorsdir)
618
# FIXME: this is a hardcoded logic, instead of auto-resolving
619
	$(LN_S) -f ../../../bin/htools \
620
		   $(DESTDIR)$(iallocatorsdir)/hail
621
	for role in $(HS_BIN_ROLES); do \
622
		$(LN_S) -f htools \
623
			   $(DESTDIR)$(bindir)/$$role ; \
624
	done
625
endif
626

    
627
$(HS_ALL_PROGS): %: %.hs $(HS_LIBTEST_SRCS) $(HS_BUILT_SRCS) Makefile
628
	@if [ "$(notdir $@)" = "test" ] && [ "$(HTOOLS_NODEV)" ]; then \
629
	  echo "Error: cannot run unittests without the development" \
630
	       " libraries (see devnotes.rst)" 1>&2; \
631
	  exit 1; \
632
	fi
633
	@rm -f $(notdir $@).tix
634
	$(GHC) --make \
635
	  $(HFLAGS) \
636
	  $(HTOOLS_NOCURL) $(HTOOLS_PARALLEL3) $(HTOOLS_REGEX_PCRE) \
637
	  -osuf $(notdir $@).o -hisuf $(notdir $@).hi \
638
	  $(HEXTRA) $(HEXTRA_INT) $@
639
	@touch "$@"
640

    
641
# for the htest/test binary, we need to enable profiling/coverage
642
htest/test: HEXTRA_INT=-fhpc -ihtest
643

    
644
# we compile the hpc-htools binary with the program coverage
645
htest/hpc-htools: HEXTRA_INT=-fhpc
646

    
647
# test dependency
648
htest/offline-tests.sh: htest/hpc-htools
649

    
650
# rules for building profiling-enabled versions of the haskell
651
# programs: hs-prof does the full two-step build, whereas
652
# hs-prof-quick does only the final rebuild (hs-prof must have been
653
# run before)
654
.PHONY: hs-prof hs-prof-quick
655
hs-prof:
656
	$(MAKE) $(AM_MAKEFLAGS) clean
657
	$(MAKE) $(AM_MAKEFLAGS) $(HS_ALL_PROGS) HEXTRA="-osuf .o"
658
	rm -f $(HS_ALL_PROGS)
659
	$(MAKE) $(AM_MAKEFLAGS) hs-prof-quick
660

    
661
hs-prof-quick:
662
	$(MAKE) $(AM_MAKEFLAGS) $(HS_ALL_PROGS) HEXTRA="-osuf .prof_o -prof -auto-all"
663

    
664
dist_sbin_SCRIPTS = \
665
	tools/ganeti-listrunner
666

    
667
nodist_sbin_SCRIPTS = \
668
	$(PYTHON_BOOTSTRAP_SBIN) \
669
	daemons/ganeti-cleaner
670

    
671
if ENABLE_CONFD
672
htools/ganeti-confd: htools/hconfd
673
	cp -f $< $@
674

    
675
nodist_sbin_SCRIPTS += htools/ganeti-confd
676
endif
677

    
678
python_scripts = \
679
	tools/burnin \
680
	tools/cfgshell \
681
	tools/cfgupgrade \
682
	tools/cfgupgrade12 \
683
	tools/cluster-merge \
684
	tools/confd-client \
685
	tools/fmtjson \
686
	tools/lvmstrap \
687
	tools/move-instance \
688
	tools/ovfconverter \
689
	tools/sanitize-config
690

    
691
dist_tools_SCRIPTS = \
692
	$(python_scripts) \
693
	tools/kvm-console-wrapper \
694
	tools/master-ip-setup \
695
	tools/xen-console-wrapper
696

    
697
nodist_tools_SCRIPTS = \
698
	tools/vcluster-setup
699

    
700
pkglib_python_scripts = \
701
	daemons/import-export \
702
	tools/check-cert-expired
703

    
704
nodist_pkglib_python_scripts = \
705
	tools/ensure-dirs \
706
	tools/prepare-node-join
707

    
708
myexeclib_SCRIPTS = \
709
	daemons/daemon-util \
710
	tools/kvm-ifup \
711
	$(pkglib_python_scripts)
712

    
713
nodist_myexeclib_SCRIPTS = \
714
	$(nodist_pkglib_python_scripts)
715

    
716
EXTRA_DIST = \
717
	NEWS \
718
	UPGRADE \
719
	epydoc.conf.in \
720
	pylintrc \
721
	autotools/build-bash-completion \
722
	autotools/build-rpc \
723
	autotools/check-header \
724
	autotools/check-imports \
725
	autotools/check-man-dashes \
726
	autotools/check-man-warnings \
727
	autotools/check-news \
728
	autotools/check-python-code \
729
	autotools/check-tar \
730
	autotools/check-version \
731
	autotools/convert-constants \
732
	autotools/docpp \
733
	autotools/gen-coverage \
734
	autotools/testrunner \
735
	autotools/wrong-hardcoded-paths \
736
	$(RUN_IN_TEMPDIR) \
737
	daemons/daemon-util.in \
738
	daemons/ganeti-cleaner.in \
739
	$(pkglib_python_scripts) \
740
	devel/upload \
741
	tools/kvm-ifup.in \
742
	tools/vcluster-setup.in \
743
	$(docdot) \
744
	$(docpng) \
745
	$(docrst) \
746
	doc/conf.py \
747
	doc/html \
748
	$(BUILT_EXAMPLES:%=%.in) \
749
	doc/examples/ganeti.default \
750
	doc/examples/ganeti.default-debug \
751
	doc/examples/hooks/ethers \
752
	doc/examples/gnt-debug/README \
753
	doc/examples/gnt-debug/delay0.json \
754
	doc/examples/gnt-debug/delay50.json \
755
	test/lockperf.py \
756
	test/testutils.py \
757
	test/mocks.py \
758
	$(dist_TESTS) \
759
	$(TEST_FILES) \
760
	man/footer.rst \
761
	$(manrst) \
762
	$(maninput) \
763
	qa/qa-sample.json \
764
	$(qa_scripts) \
765
	$(HS_LIBTEST_SRCS) $(HS_BUILT_SRCS_IN) \
766
	$(HS_PROG_SRCS) \
767
	htools/lint-hints.hs \
768
	htest/cli-tests-defs.sh \
769
	htest/offline-test.sh \
770
	.ghci
771

    
772
man_MANS = \
773
	man/ganeti-cleaner.8 \
774
	man/ganeti-confd.8 \
775
	man/ganeti-listrunner.8 \
776
	man/ganeti-masterd.8 \
777
	man/ganeti-noded.8 \
778
	man/ganeti-os-interface.7 \
779
	man/ganeti-rapi.8 \
780
	man/ganeti-watcher.8 \
781
	man/ganeti.7 \
782
	man/gnt-backup.8 \
783
	man/gnt-cluster.8 \
784
	man/gnt-debug.8 \
785
	man/gnt-group.8 \
786
	man/gnt-instance.8 \
787
	man/gnt-job.8 \
788
	man/gnt-node.8 \
789
	man/gnt-os.8 \
790
	man/hail.1 \
791
	man/hbal.1 \
792
	man/hcheck.1 \
793
	man/hinfo.1 \
794
	man/hscan.1 \
795
	man/hspace.1 \
796
	man/htools.1
797

    
798
manrst = $(patsubst %.1,%.rst,$(patsubst %.7,%.rst,$(patsubst %.8,%.rst,$(man_MANS))))
799
manhtml = $(patsubst %.rst,%.html,$(manrst))
800
mangen = $(patsubst %.rst,%.gen,$(manrst))
801
maninput = \
802
	$(patsubst %.1,%.1.in,$(patsubst %.7,%.7.in,$(patsubst %.8,%.8.in,$(man_MANS)))) \
803
	$(patsubst %.html,%.html.in,$(manhtml)) \
804
	man/footer.man man/footer.html $(mangen)
805

    
806
TEST_FILES = \
807
	htest/data/common-suffix.data \
808
	htest/data/hail-alloc-drbd.json \
809
	htest/data/hail-change-group.json \
810
	htest/data/hail-invalid-reloc.json \
811
	htest/data/hail-node-evac.json \
812
	htest/data/hail-reloc-drbd.json \
813
	htest/data/hbal-excl-tags.data \
814
	htest/data/hbal-split-insts.data \
815
	htest/data/invalid-node.data \
816
	htest/data/missing-resources.data \
817
	htest/data/rapi/groups.json \
818
	htest/data/rapi/info.json \
819
	htest/data/rapi/instances.json \
820
	htest/data/rapi/nodes.json \
821
	htest/shelltests/htools-balancing.test \
822
	htest/shelltests/htools-basic.test \
823
	htest/shelltests/htools-dynutil.test \
824
	htest/shelltests/htools-excl.test \
825
	htest/shelltests/htools-hail.test \
826
	htest/shelltests/htools-hspace.test \
827
	htest/shelltests/htools-invalid.test \
828
	htest/shelltests/htools-multi-group.test \
829
	htest/shelltests/htools-no-backend.test \
830
	htest/shelltests/htools-rapi.test \
831
	htest/shelltests/htools-single-group.test \
832
	htest/shelltests/htools-text-backend.test \
833
	test/data/bdev-drbd-8.0.txt \
834
	test/data/bdev-drbd-8.3.txt \
835
	test/data/bdev-drbd-disk.txt \
836
	test/data/bdev-drbd-net-ip4.txt \
837
	test/data/bdev-drbd-net-ip6.txt \
838
	test/data/cert1.pem \
839
	test/data/cert2.pem \
840
	test/data/ip-addr-show-dummy0.txt \
841
	test/data/ip-addr-show-lo-ipv4.txt \
842
	test/data/ip-addr-show-lo-ipv6.txt \
843
	test/data/ip-addr-show-lo-oneline-ipv4.txt \
844
	test/data/ip-addr-show-lo-oneline-ipv6.txt \
845
	test/data/ip-addr-show-lo-oneline.txt \
846
	test/data/ip-addr-show-lo.txt \
847
	test/data/kvm_0.12.5_help.txt \
848
	test/data/kvm_0.15.90_help.txt \
849
	test/data/kvm_0.9.1_help.txt \
850
	test/data/kvm_1.0_help.txt \
851
	test/data/ovfdata/compr_disk.vmdk.gz \
852
	test/data/ovfdata/config.ini \
853
	test/data/ovfdata/corrupted_resources.ovf \
854
	test/data/ovfdata/empty.ini \
855
	test/data/ovfdata/empty.ovf \
856
	test/data/ovfdata/ganeti.mf \
857
	test/data/ovfdata/ganeti.ovf \
858
	test/data/ovfdata/gzip_disk.ovf \
859
	test/data/ovfdata/new_disk.vmdk \
860
	test/data/ovfdata/no_disk.ini \
861
	test/data/ovfdata/no_disk_in_ref.ovf \
862
	test/data/ovfdata/no_os.ini \
863
	test/data/ovfdata/no_ovf.ova \
864
	test/data/ovfdata/other/rawdisk.raw \
865
	test/data/ovfdata/ova.ova \
866
	test/data/ovfdata/rawdisk.raw \
867
	test/data/ovfdata/second_disk.vmdk \
868
	test/data/ovfdata/unsafe_path.ini \
869
	test/data/ovfdata/virtualbox.ovf \
870
	test/data/ovfdata/wrong_config.ini \
871
	test/data/ovfdata/wrong_extension.ovd \
872
	test/data/ovfdata/wrong_manifest.mf \
873
	test/data/ovfdata/wrong_manifest.ovf \
874
	test/data/ovfdata/wrong_ova.ova \
875
	test/data/ovfdata/wrong_xml.ovf \
876
	test/data/proc_drbd8.txt \
877
	test/data/proc_drbd80-emptyline.txt \
878
	test/data/proc_drbd83.txt \
879
	test/data/proc_drbd83_sync.txt \
880
	test/data/proc_drbd83_sync_krnl2.6.39.txt \
881
	test/data/sys_drbd_usermode_helper.txt \
882
	test/data/vgreduce-removemissing-2.02.02.txt \
883
	test/data/vgreduce-removemissing-2.02.66-fail.txt \
884
	test/data/vgreduce-removemissing-2.02.66-ok.txt \
885
	test/data/vgs-missing-pvs-2.02.02.txt \
886
	test/data/vgs-missing-pvs-2.02.66.txt \
887
	test/ganeti-cli.test \
888
	test/gnt-cli.test \
889
	test/import-export_unittest-helper
890

    
891
python_tests = \
892
	doc/examples/rapi_testutils.py \
893
	test/cfgupgrade_unittest.py \
894
	test/docs_unittest.py \
895
	test/ganeti.asyncnotifier_unittest.py \
896
	test/ganeti.backend_unittest.py \
897
	test/ganeti.bdev_unittest.py \
898
	test/ganeti.cli_unittest.py \
899
	test/ganeti.client.gnt_cluster_unittest.py \
900
	test/ganeti.client.gnt_instance_unittest.py \
901
	test/ganeti.client.gnt_job_unittest.py \
902
	test/ganeti.cmdlib_unittest.py \
903
	test/ganeti.compat_unittest.py \
904
	test/ganeti.confd.client_unittest.py \
905
	test/ganeti.config_unittest.py \
906
	test/ganeti.constants_unittest.py \
907
	test/ganeti.daemon_unittest.py \
908
	test/ganeti.errors_unittest.py \
909
	test/ganeti.hooks_unittest.py \
910
	test/ganeti.ht_unittest.py \
911
	test/ganeti.http_unittest.py \
912
	test/ganeti.hypervisor.hv_chroot_unittest.py \
913
	test/ganeti.hypervisor.hv_fake_unittest.py \
914
	test/ganeti.hypervisor.hv_kvm_unittest.py \
915
	test/ganeti.hypervisor.hv_lxc_unittest.py \
916
	test/ganeti.hypervisor.hv_xen_unittest.py \
917
	test/ganeti.hypervisor_unittest.py \
918
	test/ganeti.impexpd_unittest.py \
919
	test/ganeti.jqueue_unittest.py \
920
	test/ganeti.jstore_unittest.py \
921
	test/ganeti.locking_unittest.py \
922
	test/ganeti.luxi_unittest.py \
923
	test/ganeti.masterd.iallocator_unittest.py \
924
	test/ganeti.masterd.instance_unittest.py \
925
	test/ganeti.mcpu_unittest.py \
926
	test/ganeti.netutils_unittest.py \
927
	test/ganeti.objects_unittest.py \
928
	test/ganeti.objectutils_unittest.py \
929
	test/ganeti.opcodes_unittest.py \
930
	test/ganeti.ovf_unittest.py \
931
	test/ganeti.qlang_unittest.py \
932
	test/ganeti.query_unittest.py \
933
	test/ganeti.rapi.baserlib_unittest.py \
934
	test/ganeti.rapi.client_unittest.py \
935
	test/ganeti.rapi.resources_unittest.py \
936
	test/ganeti.rapi.rlib2_unittest.py \
937
	test/ganeti.rapi.testutils_unittest.py \
938
	test/ganeti.rpc_unittest.py \
939
	test/ganeti.runtime_unittest.py \
940
	test/ganeti.serializer_unittest.py \
941
	test/ganeti.server.rapi_unittest.py \
942
	test/ganeti.ssh_unittest.py \
943
	test/ganeti.storage_unittest.py \
944
	test/ganeti.tools.ensure_dirs_unittest.py \
945
	test/ganeti.tools.prepare_node_join_unittest.py \
946
	test/ganeti.uidpool_unittest.py \
947
	test/ganeti.utils.algo_unittest.py \
948
	test/ganeti.utils.filelock_unittest.py \
949
	test/ganeti.utils.hash_unittest.py \
950
	test/ganeti.utils.io_unittest-runasroot.py \
951
	test/ganeti.utils.io_unittest.py \
952
	test/ganeti.utils.log_unittest.py \
953
	test/ganeti.utils.mlock_unittest.py \
954
	test/ganeti.utils.nodesetup_unittest.py \
955
	test/ganeti.utils.process_unittest.py \
956
	test/ganeti.utils.retry_unittest.py \
957
	test/ganeti.utils.text_unittest.py \
958
	test/ganeti.utils.wrapper_unittest.py \
959
	test/ganeti.utils.x509_unittest.py \
960
	test/ganeti.utils_unittest.py \
961
	test/ganeti.vcluster_unittest.py \
962
	test/ganeti.workerpool_unittest.py \
963
	test/pycurl_reset_unittest.py \
964
	test/qa.qa_config_unittest.py \
965
	test/tempfile_fork_unittest.py
966

    
967
haskell_tests = htest/test
968

    
969
dist_TESTS = \
970
	test/check-cert-expired_unittest.bash \
971
	test/daemon-util_unittest.bash \
972
	test/ganeti-cleaner_unittest.bash \
973
	test/import-export_unittest.bash \
974
	test/cli-test.bash \
975
	test/bash_completion.bash \
976
	$(python_tests)
977

    
978
nodist_TESTS =
979
check_SCRIPTS =
980

    
981
if WANT_HTOOLSTESTS
982
nodist_TESTS += $(haskell_tests)
983
dist_TESTS += htest/offline-test.sh
984
check_SCRIPTS += htest/hpc-htools $(HS_BUILT_TEST_HELPERS)
985
endif
986

    
987
TESTS = $(dist_TESTS) $(nodist_TESTS)
988

    
989
# Environment for all tests
990
PLAIN_TESTS_ENVIRONMENT = \
991
	PYTHONPATH=. \
992
	TOP_SRCDIR=$(abs_top_srcdir) TOP_BUILDDIR=$(abs_top_builddir) \
993
	PYTHON=$(PYTHON) FAKEROOT=$(FAKEROOT_PATH) \
994
	$(RUN_IN_TEMPDIR)
995

    
996
# Environment for tests run by automake
997
TESTS_ENVIRONMENT = \
998
	$(PLAIN_TESTS_ENVIRONMENT) $(abs_top_srcdir)/autotools/testrunner
999

    
1000
all_python_code = \
1001
	$(dist_sbin_SCRIPTS) \
1002
	$(python_scripts) \
1003
	$(pkglib_python_scripts) \
1004
	$(nodist_pkglib_python_scripts) \
1005
	$(python_tests) \
1006
	$(pkgpython_PYTHON) \
1007
	$(client_PYTHON) \
1008
	$(hypervisor_PYTHON) \
1009
	$(rapi_PYTHON) \
1010
	$(server_PYTHON) \
1011
	$(pytools_PYTHON) \
1012
	$(http_PYTHON) \
1013
	$(confd_PYTHON) \
1014
	$(masterd_PYTHON) \
1015
	$(impexpd_PYTHON) \
1016
	$(utils_PYTHON) \
1017
	$(watcher_PYTHON) \
1018
	$(noinst_PYTHON) \
1019
	$(qa_scripts)
1020

    
1021
srclink_files = \
1022
	man/footer.rst \
1023
	test/check-cert-expired_unittest.bash \
1024
	test/daemon-util_unittest.bash \
1025
	test/ganeti-cleaner_unittest.bash \
1026
	test/import-export_unittest.bash \
1027
	test/cli-test.bash \
1028
	test/bash_completion.bash \
1029
	htest/offline-test.sh \
1030
	htest/cli-tests-defs.sh \
1031
	$(all_python_code) \
1032
	$(HS_LIBTEST_SRCS) $(HS_PROG_SRCS)
1033

    
1034
check_python_code = \
1035
	$(BUILD_BASH_COMPLETION) \
1036
	$(CHECK_IMPORTS) \
1037
	$(CHECK_HEADER) \
1038
	$(DOCPP) \
1039
	$(all_python_code)
1040

    
1041
lint_python_code = \
1042
	ganeti \
1043
	ganeti/http/server.py \
1044
	$(dist_sbin_SCRIPTS) \
1045
	$(python_scripts) \
1046
	$(pkglib_python_scripts) \
1047
	$(BUILD_BASH_COMPLETION) \
1048
	$(CHECK_IMPORTS) \
1049
	$(CHECK_HEADER) \
1050
	$(DOCPP) \
1051
	$(PYTHON_BOOTSTRAP)
1052

    
1053
standalone_python_modules = \
1054
	lib/rapi/client.py \
1055
	tools/ganeti-listrunner
1056

    
1057
pep8_python_code = \
1058
	ganeti \
1059
	ganeti/http/server.py \
1060
	$(dist_sbin_SCRIPTS) \
1061
	$(python_scripts) \
1062
	$(pkglib_python_scripts) \
1063
	$(BUILD_BASH_COMPLETION) \
1064
	$(CHECK_HEADER) \
1065
	$(DOCPP) \
1066
	$(PYTHON_BOOTSTRAP) \
1067
	qa
1068

    
1069
test/daemon-util_unittest.bash: daemons/daemon-util
1070

    
1071
test/ganeti-cleaner_unittest.bash: daemons/ganeti-cleaner
1072

    
1073
test/bash_completion.bash: doc/examples/bash_completion-debug
1074

    
1075
tools/kvm-ifup: tools/kvm-ifup.in $(REPLACE_VARS_SED)
1076
	sed -f $(REPLACE_VARS_SED) < $< > $@
1077
	chmod +x $@
1078

    
1079
tools/vcluster-setup: tools/vcluster-setup.in $(REPLACE_VARS_SED)
1080
	sed -f $(REPLACE_VARS_SED) < $< > $@
1081
	chmod +x $@
1082

    
1083
daemons/%:: daemons/%.in $(REPLACE_VARS_SED)
1084
	sed -f $(REPLACE_VARS_SED) < $< > $@
1085
	chmod +x $@
1086

    
1087
doc/examples/%:: doc/examples/%.in $(REPLACE_VARS_SED)
1088
	sed -f $(REPLACE_VARS_SED) < $< > $@
1089

    
1090
doc/examples/bash_completion: BC_ARGS = --compact
1091
doc/examples/bash_completion-debug: BC_ARGS =
1092

    
1093
doc/examples/bash_completion doc/examples/bash_completion-debug: \
1094
	$(BUILD_BASH_COMPLETION) $(RUN_IN_TEMPDIR) \
1095
	lib/cli.py $(gnt_scripts) $(client_PYTHON) tools/burnin \
1096
	daemons/ganeti-cleaner \
1097
	$(GENERATED_FILES) $(HTOOLS_GENERATED_FILES)
1098
	PYTHONPATH=. $(RUN_IN_TEMPDIR) \
1099
	  $(CURDIR)/$(BUILD_BASH_COMPLETION) $(BC_ARGS) > $@
1100

    
1101
doc/%.png: doc/%.dot
1102
	@test -n "$(DOT)" || { echo 'dot' not found during configure; exit 1; }
1103
	$(DOT) -Tpng -o $@ $<
1104

    
1105
man/footer.man: man/footer.rst
1106
	@test -n "$(PANDOC)" || \
1107
	  { echo 'pandoc' not found during configure; exit 1; }
1108
	$(PANDOC) -f rst -t man -o $@ $<
1109

    
1110
man/footer.html: man/footer.rst
1111
	@test -n "$(PANDOC)" || \
1112
	  { echo 'pandoc' not found during configure; exit 1; }
1113
	$(PANDOC) -f rst -t html -o $@ $<
1114

    
1115
man/%.gen: man/%.rst lib/query.py lib/build/sphinx_ext.py \
1116
	lib/build/shell_example_lexer.py \
1117
	| $(RUN_IN_TEMPDIR) $(BUILT_PYTHON_SOURCES)
1118
	@echo "Checking $< for hardcoded paths..."
1119
	@if grep -nEf autotools/wrong-hardcoded-paths $<; then \
1120
	  echo "Man page $< has harcoded paths (see above)!" 1>&2 ; \
1121
	  exit 1; \
1122
	fi
1123
	set -e ; \
1124
	trap 'echo auto-removing $@; rm $@' EXIT; \
1125
	PYTHONPATH=. $(RUN_IN_TEMPDIR) $(CURDIR)/$(DOCPP) < $< > $@ ;\
1126
	trap - EXIT
1127

    
1128
man/%.7.in man/%.8.in man/%.1.in: man/%.gen man/footer.man
1129
	@test -n "$(PANDOC)" || \
1130
	  { echo 'pandoc' not found during configure; exit 1; }
1131
	set -o pipefail ; \
1132
	trap 'echo auto-removing $@; rm $@' EXIT; \
1133
	$(PANDOC) -s -f rst -t man -A man/footer.man $< | \
1134
	  sed -e 's/\\@/@/g' > $@; \
1135
	if test -n "$(MAN_HAS_WARNINGS)"; then $(CHECK_MAN_WARNINGS) $@; fi; \
1136
	$(CHECK_MAN_DASHES) $@; \
1137
	trap - EXIT
1138

    
1139

    
1140
man/%.html.in: man/%.gen man/footer.html
1141
	@test -n "$(PANDOC)" || \
1142
	  { echo 'pandoc' not found during configure; exit 1; }
1143
	set -o pipefail ; \
1144
	$(PANDOC) -s -f rst -t html -A man/footer.html $< | \
1145
	  sed -e 's/\\@/@/g' > $@
1146

    
1147
man/%: man/%.in  $(REPLACE_VARS_SED)
1148
	sed -f $(REPLACE_VARS_SED) < $< > $@
1149

    
1150
epydoc.conf: epydoc.conf.in $(REPLACE_VARS_SED)
1151
	sed -f $(REPLACE_VARS_SED) < $< > $@
1152

    
1153
vcs-version:
1154
	if test -d .git; then \
1155
	  git describe > $@; \
1156
	elif test ! -f $@ ; then \
1157
	  echo "Cannot auto-generate $@ file"; exit 1; \
1158
	fi
1159

    
1160
.PHONY: clean-vcs-version
1161
clean-vcs-version:
1162
	rm -f vcs-version
1163

    
1164
.PHONY: regen-vcs-version
1165
regen-vcs-version:
1166
	@set -e; \
1167
	cd $(srcdir); \
1168
	if test -d .git; then \
1169
	  T=`mktemp` ; trap 'rm -f $$T' EXIT; \
1170
	  git describe > $$T; \
1171
	  if ! cmp --quiet $$T vcs-version; then \
1172
	    mv $$T vcs-version; \
1173
	  fi; \
1174
	fi
1175

    
1176
htools/Ganeti/Version.hs: htools/Ganeti/Version.hs.in \
1177
	vcs-version $(built_base_sources)
1178
	set -e; \
1179
	VCSVER=`cat $(abs_top_srcdir)/vcs-version`; \
1180
	sed -e "s/%ver%/$$VCSVER/" < $< > $@
1181

    
1182
htools/Ganeti/Constants.hs: htools/Ganeti/Constants.hs.in \
1183
	lib/constants.py lib/_autoconf.py lib/luxi.py \
1184
	$(CONVERT_CONSTANTS) $(built_base_sources) \
1185
	| lib/_vcsversion.py
1186
	set -e; \
1187
	{ cat $< ; PYTHONPATH=. $(CONVERT_CONSTANTS); } > $@
1188

    
1189
htest/Test/Ganeti/TestImports.hs: htest/Test/Ganeti/TestImports.hs.in \
1190
	$(built_base_sources)
1191
	set -e; \
1192
	{ cat $< ; \
1193
	  echo ; \
1194
	  for name in $(filter-out Ganeti.THH,$(subst /,.,$(patsubst %.hs,%,$(patsubst htools/%,%,$(HS_LIB_SRCS))))) ; do \
1195
	    echo "import $$name ()" ; \
1196
	  done ; \
1197
	} > $@
1198

    
1199
lib/_autoconf.py: Makefile | stamp-directories
1200
	set -e; \
1201
	{ echo '# This file is automatically generated, do not edit!'; \
1202
	  echo '#'; \
1203
	  echo ''; \
1204
	  echo '"""Build-time configuration for Ganeti.'; \
1205
	  echo '';\
1206
	  echo 'This file is autogenerated by the build process.'; \
1207
	  echo 'For any changes you need to re-run ./configure (and'; \
1208
	  echo 'not edit by hand).'; \
1209
	  echo ''; \
1210
	  echo '"""'; \
1211
	  echo ''; \
1212
	  echo '# pylint: disable=C0301,C0324'; \
1213
	  echo '# because this is autogenerated, we do not want'; \
1214
	  echo '# style warnings' ; \
1215
	  echo ''; \
1216
	  echo "PACKAGE_VERSION = '$(PACKAGE_VERSION)'"; \
1217
	  echo "VERSION_MAJOR = '$(VERSION_MAJOR)'"; \
1218
	  echo "VERSION_MINOR = '$(VERSION_MINOR)'"; \
1219
	  echo "VERSION_REVISION = '$(VERSION_REVISION)'"; \
1220
	  echo "VERSION_SUFFIX = '$(VERSION_SUFFIX)'"; \
1221
	  echo "VERSION_FULL = '$(VERSION_FULL)'"; \
1222
	  echo "LOCALSTATEDIR = '$(localstatedir)'"; \
1223
	  echo "SYSCONFDIR = '$(sysconfdir)'"; \
1224
	  echo "SSH_CONFIG_DIR = '$(SSH_CONFIG_DIR)'"; \
1225
	  echo "SSH_LOGIN_USER = '$(SSH_LOGIN_USER)'"; \
1226
	  echo "SSH_CONSOLE_USER = '$(SSH_CONSOLE_USER)'"; \
1227
	  echo "EXPORT_DIR = '$(EXPORT_DIR)'"; \
1228
	  echo "OS_SEARCH_PATH = [$(OS_SEARCH_PATH)]"; \
1229
	  echo "XEN_BOOTLOADER = '$(XEN_BOOTLOADER)'"; \
1230
	  echo "XEN_KERNEL = '$(XEN_KERNEL)'"; \
1231
	  echo "XEN_INITRD = '$(XEN_INITRD)'"; \
1232
	  echo "KVM_KERNEL = '$(KVM_KERNEL)'"; \
1233
	  echo "FILE_STORAGE_DIR = '$(FILE_STORAGE_DIR)'"; \
1234
	  echo "ENABLE_FILE_STORAGE = $(ENABLE_FILE_STORAGE)"; \
1235
	  echo "SHARED_FILE_STORAGE_DIR = '$(SHARED_FILE_STORAGE_DIR)'"; \
1236
	  echo "ENABLE_SHARED_FILE_STORAGE = $(ENABLE_SHARED_FILE_STORAGE)"; \
1237
	  echo "IALLOCATOR_SEARCH_PATH = [$(IALLOCATOR_SEARCH_PATH)]"; \
1238
	  echo "KVM_PATH = '$(KVM_PATH)'"; \
1239
	  echo "IP_PATH = '$(IP_PATH)'"; \
1240
	  echo "SOCAT_PATH = '$(SOCAT)'"; \
1241
	  echo "SOCAT_USE_ESCAPE = $(SOCAT_USE_ESCAPE)"; \
1242
	  echo "SOCAT_USE_COMPRESS = $(SOCAT_USE_COMPRESS)"; \
1243
	  echo "LVM_STRIPECOUNT = $(LVM_STRIPECOUNT)"; \
1244
	  echo "TOOLSDIR = '$(toolsdir)'"; \
1245
	  echo "GNT_SCRIPTS = [$(foreach i,$(notdir $(gnt_scripts)),'$(i)',)]"; \
1246
	  echo "HTOOLS_PROGS = [$(foreach i,$(HS_HTOOLS_PROGS),'$(i)',)]"; \
1247
	  echo "PKGLIBDIR = '$(pkglibdir)'"; \
1248
	  echo "DRBD_BARRIERS = '$(DRBD_BARRIERS)'"; \
1249
	  echo "DRBD_NO_META_FLUSH = $(DRBD_NO_META_FLUSH)"; \
1250
	  echo "SYSLOG_USAGE = '$(SYSLOG_USAGE)'"; \
1251
	  echo "DAEMONS_GROUP = '$(DAEMONS_GROUP)'"; \
1252
	  echo "ADMIN_GROUP = '$(ADMIN_GROUP)'"; \
1253
	  echo "MASTERD_USER = '$(MASTERD_USER)'"; \
1254
	  echo "MASTERD_GROUP = '$(MASTERD_GROUP)'"; \
1255
	  echo "RAPI_USER = '$(RAPI_USER)'"; \
1256
	  echo "RAPI_GROUP = '$(RAPI_GROUP)'"; \
1257
	  echo "CONFD_USER = '$(CONFD_USER)'"; \
1258
	  echo "CONFD_GROUP = '$(CONFD_GROUP)'"; \
1259
	  echo "NODED_USER = '$(NODED_USER)'"; \
1260
	  echo "NODED_GROUP = '$(NODED_GROUP)'"; \
1261
	  echo "DISK_SEPARATOR = '$(DISK_SEPARATOR)'"; \
1262
	  echo "QEMUIMG_PATH = '$(QEMUIMG_PATH)'"; \
1263
	  echo "HTOOLS = True"; \
1264
	  echo "ENABLE_CONFD = $(ENABLE_CONFD)"; \
1265
	  echo "XEN_CMD = '$(XEN_CMD)'"; \
1266
	  echo "ENABLE_SPLIT_QUERY = $(ENABLE_SPLIT_QUERY)"; \
1267
	} > $@
1268

    
1269
lib/_vcsversion.py: Makefile vcs-version | stamp-directories
1270
	set -e; \
1271
	VCSVER=`cat $(abs_top_srcdir)/vcs-version`; \
1272
	{ echo '# This file is automatically generated, do not edit!'; \
1273
	  echo '#'; \
1274
	  echo ''; \
1275
	  echo '"""Build-time VCS version number for Ganeti.'; \
1276
	  echo '';\
1277
	  echo 'This file is autogenerated by the build process.'; \
1278
	  echo 'For any changes you need to re-run ./configure (and'; \
1279
	  echo 'not edit by hand).'; \
1280
	  echo ''; \
1281
	  echo '"""'; \
1282
	  echo ''; \
1283
	  echo '# pylint: disable=C0301,C0324'; \
1284
	  echo '# because this is autogenerated, we do not want'; \
1285
	  echo '# style warnings' ; \
1286
	  echo ''; \
1287
	  echo "VCS_VERSION = '$$VCSVER'"; \
1288
	} > $@
1289

    
1290
lib/_generated_rpc.py: lib/rpc_defs.py $(BUILD_RPC)
1291
	PYTHONPATH=. $(RUN_IN_TEMPDIR) $(CURDIR)/$(BUILD_RPC) lib/rpc_defs.py > $@
1292

    
1293
$(SHELL_ENV_INIT): Makefile stamp-directories
1294
	set -e; \
1295
	{ echo '# Allow overriding for tests'; \
1296
	  echo 'readonly LOCALSTATEDIR=$${LOCALSTATEDIR:-$${GANETI_ROOTDIR:-}$(localstatedir)}'; \
1297
	  echo 'readonly SYSCONFDIR=$${SYSCONFDIR:-$${GANETI_ROOTDIR:-}$(sysconfdir)}'; \
1298
	  echo; \
1299
	  echo 'readonly PKGLIBDIR=$(pkglibdir)'; \
1300
	  echo 'readonly LOG_DIR="$$LOCALSTATEDIR/log/ganeti"'; \
1301
	  echo 'readonly RUN_DIR="$$LOCALSTATEDIR/run/ganeti"'; \
1302
	  echo 'readonly DATA_DIR="$$LOCALSTATEDIR/lib/ganeti"'; \
1303
	  echo 'readonly CONF_DIR="$$SYSCONFDIR/ganeti"'; \
1304
	} > $@
1305

    
1306
$(REPLACE_VARS_SED): $(SHELL_ENV_INIT) Makefile stamp-directories
1307
	set -e; \
1308
	{ echo 's#@PREFIX@#$(prefix)#g'; \
1309
	  echo 's#@SYSCONFDIR@#$(sysconfdir)#g'; \
1310
	  echo 's#@LOCALSTATEDIR@#$(localstatedir)#g'; \
1311
	  echo 's#@BINDIR@#$(bindir)#g'; \
1312
	  echo 's#@SBINDIR@#$(sbindir)#g'; \
1313
	  echo 's#@LIBDIR@#$(libdir)#g'; \
1314
	  echo 's#@GANETI_VERSION@#$(PACKAGE_VERSION)#g'; \
1315
	  echo 's#@CUSTOM_XEN_BOOTLOADER@#$(XEN_BOOTLOADER)#g'; \
1316
	  echo 's#@CUSTOM_XEN_KERNEL@#$(XEN_KERNEL)#g'; \
1317
	  echo 's#@CUSTOM_XEN_INITRD@#$(XEN_INITRD)#g'; \
1318
	  echo 's#@CUSTOM_IALLOCATOR_SEARCH_PATH@#$(IALLOCATOR_SEARCH_PATH)#g'; \
1319
	  echo 's#@CUSTOM_EXPORT_DIR@#$(EXPORT_DIR)#g'; \
1320
	  echo 's#@RPL_FILE_STORAGE_DIR@#$(FILE_STORAGE_DIR)#g'; \
1321
	  echo 's#@RPL_SSH_INITD_SCRIPT@#$(SSH_INITD_SCRIPT)#g'; \
1322
	  echo 's#@PKGLIBDIR@#$(pkglibdir)#g'; \
1323
	  echo 's#@GNTMASTERUSER@#$(MASTERD_USER)#g'; \
1324
	  echo 's#@GNTRAPIUSER@#$(RAPI_USER)#g'; \
1325
	  echo 's#@GNTCONFDUSER@#$(CONFD_USER)#g'; \
1326
	  echo 's#@GNTNODEDUSER@#$(NODED_USER)#g'; \
1327
	  echo 's#@GNTRAPIGROUP@#$(RAPI_GROUP)#g'; \
1328
	  echo 's#@GNTADMINGROUP@#$(ADMIN_GROUP)#g'; \
1329
	  echo 's#@GNTCONFDGROUP@#$(CONFD_GROUP)#g'; \
1330
	  echo 's#@GNTMASTERDGROUP@#$(MASTERD_GROUP)#g'; \
1331
	  echo 's#@GNTDAEMONSGROUP@#$(DAEMONS_GROUP)#g'; \
1332
	  echo 's#@CUSTOM_ENABLE_CONFD@#$(ENABLE_CONFD)#g'; \
1333
	  echo 's#@MODULES@#$(strip $(lint_python_code))#g'; \
1334
	  echo 's#@ENABLE_SPLIT_QUERY@#$(ENABLE_SPLIT_QUERY)#g'; \
1335
	  echo; \
1336
	  echo '/^@SHELL_ENV_INIT@$$/ {'; \
1337
	  echo '  r $(SHELL_ENV_INIT)'; \
1338
	  echo '  d'; \
1339
	  echo '}'; \
1340
	} > $@
1341

    
1342
# Using deferred evaluation
1343
daemons/ganeti-%: MODULE = ganeti.server.$(patsubst ganeti-%,%,$(notdir $@))
1344
daemons/ganeti-watcher: MODULE = ganeti.watcher
1345
scripts/%: MODULE = ganeti.client.$(subst -,_,$(notdir $@))
1346
tools/ensure-dirs: MODULE = ganeti.tools.ensure_dirs
1347
tools/prepare-node-join: MODULE = ganeti.tools.prepare_node_join
1348
$(HS_BUILT_TEST_HELPERS): TESTROLE = $(patsubst htest/%,%,$@)
1349

    
1350
$(PYTHON_BOOTSTRAP): Makefile | stamp-directories
1351
	test -n "$(MODULE)" || { echo Missing module; exit 1; }
1352
	set -e; \
1353
	{ echo '#!/usr/bin/python'; \
1354
	  echo '# This file is automatically generated, do not edit!'; \
1355
	  echo "# Edit $(MODULE) instead."; \
1356
	  echo; \
1357
	  echo '"""Bootstrap script for L{$(MODULE)}"""'; \
1358
	  echo; \
1359
	  echo '# pylint: disable=C0103'; \
1360
	  echo '# C0103: Invalid name'; \
1361
	  echo; \
1362
	  echo 'import sys'; \
1363
	  echo 'import $(MODULE) as main'; \
1364
	  echo; \
1365
	  echo '# Temporarily alias commands until bash completion'; \
1366
	  echo '# generator is changed'; \
1367
	  echo 'if hasattr(main, "commands"):'; \
1368
	  echo '  commands = main.commands # pylint: disable=E1101'; \
1369
	  echo 'if hasattr(main, "aliases"):'; \
1370
	  echo '  aliases = main.aliases # pylint: disable=E1101'; \
1371
	  echo; \
1372
	  echo 'if __name__ == "__main__":'; \
1373
	  echo '  sys.exit(main.Main())'; \
1374
	} > $@
1375
	chmod u+x $@
1376

    
1377
$(HS_BUILT_TEST_HELPERS): Makefile
1378
	@test -n "$(TESTROLE)" || { echo Missing TESTROLE; exit 1; }
1379
	set -e; \
1380
	{ echo '#!/bin/sh'; \
1381
	  echo '# This file is automatically generated, do not edit!'; \
1382
	  echo "# Edit Makefile.am instead."; \
1383
	  echo; \
1384
	  echo "HTOOLS=$(TESTROLE) exec ./htest/hpc-htools \"\$$@\""; \
1385
	} > $@
1386
	chmod u+x $@
1387

    
1388
stamp-directories: Makefile
1389
	$(MAKE) $(AM_MAKEFLAGS) ganeti
1390
	@mkdir_p@ $(DIRS) $(BUILDTIME_DIR_AUTOCREATE)
1391
	touch $@
1392

    
1393
# We need to create symlinks because "make distcheck" will not install Python
1394
# files when building.
1395
stamp-srclinks: Makefile | stamp-directories
1396
	set -e; \
1397
	for i in $(srclink_files); do \
1398
		if test ! -f $$i -a -f $(abs_top_srcdir)/$$i; then \
1399
			$(LN_S) $(abs_top_srcdir)/$$i $$i; \
1400
		fi; \
1401
	done
1402
	touch $@
1403

    
1404
.PHONY: ganeti
1405
ganeti:
1406
	cd $(top_builddir) && test -h "$@" || { rm -f $@ && $(LN_S) lib $@; }
1407

    
1408
.PHONY: check-dirs
1409
check-dirs: $(GENERATED_FILES)
1410
	@set -e; \
1411
	find . -type d \( \( -name . \) -o \( \
1412
		-name .git -o \
1413
		-name autom4te.cache \
1414
		\) -prune -o -print \) | { \
1415
		error=; \
1416
		while read dir; do \
1417
			case "$$dir" in \
1418
				$(strip $(patsubst %,(./%) ;;,$(DIRCHECK_EXCLUDE) $(DIRS))) \
1419
				*) error=1; echo "Directory $$dir not listed in Makefile" >&2 ;; \
1420
			esac; \
1421
		done; \
1422
		for dir in $(DIRS); do \
1423
			if ! test -d "$$dir"; then \
1424
				echo "Directory $$dir listed in DIRS does not exist" >&2; \
1425
				error=1; \
1426
			fi \
1427
		done; \
1428
		if test -n "$$error"; then exit 1; else exit 0; fi; \
1429
	}
1430

    
1431
.PHONY: check-local
1432
check-local: check-dirs $(GENERATED_FILES)
1433
	$(CHECK_PYTHON_CODE) $(check_python_code)
1434
	PYTHONPATH=. $(CHECK_HEADER) $(check_python_code)
1435
	$(CHECK_VERSION) $(VERSION) $(top_srcdir)/NEWS
1436
	$(CHECK_NEWS) < $(top_srcdir)/NEWS
1437
	PYTHONPATH=. $(RUN_IN_TEMPDIR) $(CURDIR)/$(CHECK_IMPORTS) . $(standalone_python_modules)
1438
	@expver=$(VERSION_MAJOR).$(VERSION_MINOR); \
1439
	if test "`head -n 1 $(top_srcdir)/README`" != "Ganeti $$expver"; then \
1440
		echo "Incorrect version in README, expected $$expver"; \
1441
		exit 1; \
1442
	fi; \
1443
	for file in doc/iallocator.rst doc/hooks.rst doc/virtual-cluster.rst \
1444
			doc/security.rst; do \
1445
		if test "`sed -ne '4 p' $(top_srcdir)/$$file`" != \
1446
			"Documents Ganeti version $$expver"; then \
1447
			echo "Incorrect version in $$file, expected $$expver"; \
1448
			exit 1; \
1449
		fi; \
1450
	done; \
1451
	if ! test -f $(top_srcdir)/doc/design-$$expver.rst; then \
1452
		echo "File $(top_srcdir)/doc/design-$$expver.rst not found"; \
1453
		exit 1; \
1454
	fi
1455

    
1456
.PHONY: hs-check
1457
hs-check: htest/test htest/hpc-htools $(HS_BUILT_TEST_HELPERS)
1458
	@rm -f test.tix
1459
	./htest/test
1460
	HBINARY="./htest/hpc-htools" ./htest/offline-test.sh
1461

    
1462
# E111: indentation is not a multiple of four
1463
# E121: continuation line indentation is not a multiple of four
1464
#       (since our indent level is not 4)
1465
# E125: continuation line does not distinguish itself from next logical line
1466
#       (since our indent level is not 4)
1467
# E127: continuation line over-indented for visual indent
1468
#       (since our indent level is not 4)
1469
# note: do NOT add E128 here; it's a valid style error in most cases!
1470
# I've seen real errors, but also some cases were we indent wrongly
1471
# due to line length; try to rework the cases where it is triggered,
1472
# instead of silencing it
1473
# E261: at least two spaces before inline comment
1474
# E501: line too long (80 characters)
1475
PEP8_IGNORE = E111,E121,E125,E127,E261,E501
1476

    
1477
# For excluding pep8 expects filenames only, not whole paths
1478
PEP8_EXCLUDE = $(subst $(space),$(comma),$(strip $(notdir $(BUILT_PYTHON_SOURCES))))
1479

    
1480
LINT_TARGETS = pylint pylint-qa
1481
if HAS_PEP8
1482
LINT_TARGETS += pep8
1483
endif
1484
if HAS_HLINT
1485
LINT_TARGETS += hlint
1486
endif
1487

    
1488
.PHONY: lint
1489
lint: $(LINT_TARGETS)
1490

    
1491
.PHONY: pylint
1492
pylint: $(GENERATED_FILES)
1493
	@test -n "$(PYLINT)" || { echo 'pylint' not found during configure; exit 1; }
1494
	$(PYLINT) $(LINT_OPTS) $(lint_python_code)
1495

    
1496
.PHONY: pylint-qa
1497
pylint-qa: $(GENERATED_FILES)
1498
	@test -n "$(PYLINT)" || { echo 'pylint' not found during configure; exit 1; }
1499
	cd $(top_srcdir)/qa && \
1500
	  PYTHONPATH=$(abs_top_srcdir) $(PYLINT) $(LINT_OPTS) \
1501
	  --rcfile  ../pylintrc $(patsubst qa/%.py,%,$(qa_scripts))
1502

    
1503
.PHONY: pep8
1504
pep8: $(GENERATED_FILES)
1505
	@test -n "$(PEP8)" || { echo 'pep8' not found during configure; exit 1; }
1506
	$(PEP8) --ignore='$(PEP8_IGNORE)' --exclude='$(PEP8_EXCLUDE)' \
1507
		--repeat $(pep8_python_code)
1508

    
1509
# FIXME: remove ignore "Use void" when GHC 6.x is deprecated
1510
.PHONY: hlint
1511
hlint: $(HS_BUILT_SRCS) htools/lint-hints.hs
1512
	@test -n "$(HLINT)" || { echo 'hlint' not found during configure; exit 1; }
1513
	if tty -s; then C="-c"; else C=""; fi; \
1514
	$(HLINT) --report=doc/hs-lint.html --cross $$C \
1515
	  --ignore "Use first" \
1516
	  --ignore "Use comparing" \
1517
	  --ignore "Use on" \
1518
	  --ignore "Reduce duplication" \
1519
	  --ignore "Use &&&" \
1520
	  --ignore "Use void" \
1521
	  --hint htools/lint-hints \
1522
	  $(filter-out htools/Ganeti/THH.hs,$(HS_LIBTEST_SRCS) $(HS_PROG_SRCS))
1523

    
1524
# a dist hook rule for updating the vcs-version file; this is
1525
# hardcoded due to where it needs to build the file...
1526
dist-hook:
1527
	$(MAKE) $(AM_MAKEFLAGS) regen-vcs-version
1528
	rm -f $(top_distdir)/vcs-version
1529
	cp -p $(srcdir)/vcs-version $(top_distdir)
1530

    
1531
# a distcheck hook rule for catching revision control directories
1532
distcheck-hook:
1533
	if find $(top_distdir) -name .svn -or -name .git | grep .; then \
1534
		echo "Found revision control files in final archive." 1>&2; \
1535
		exit 1; \
1536
	fi
1537
	if find $(top_distdir) -name '*.py[co]' | grep .; then \
1538
		echo "Found Python byte code in final archive." 1>&2; \
1539
		exit 1; \
1540
	fi
1541
	if find $(top_distdir) -name '*~' | grep .; then \
1542
		echo "Found backup files in final archive." 1>&2; \
1543
		exit 1; \
1544
	fi
1545
# Empty files or directories should not be distributed. They can cause
1546
# unnecessary warnings for packagers. Directories used by automake during
1547
# distcheck must be excluded.
1548
	if find $(top_distdir) -empty -and -not \( \
1549
			-path $(top_distdir)/_build -or \
1550
			-path $(top_distdir)/_inst \) | grep .; then \
1551
		echo "Found empty files or directories in final archive." 1>&2; \
1552
		exit 1; \
1553
	fi
1554
	if test -n "$(BUILD_RELEASE)" && \
1555
	   grep -n -H -E '^\*.*unreleased' $(top_distdir)/NEWS; then \
1556
		echo "Found unreleased version in NEWS." >&2; \
1557
		exit 1; \
1558
	fi
1559

    
1560
# When building a release, stricter checks should be used
1561
distcheck-release dist-release: export BUILD_RELEASE = 1
1562
distcheck-release: distcheck
1563

    
1564
distrebuildcheck: dist
1565
	set -e; \
1566
	builddir=$$(mktemp -d $(abs_srcdir)/distrebuildcheck.XXXXXXX); \
1567
	trap "echo Removing $$builddir; cd $(abs_srcdir); rm -rf $$builddir" EXIT; \
1568
	cd $$builddir; \
1569
	tar xzf $(abs_srcdir)/$(distdir).tar.gz; \
1570
	cd $(distdir); \
1571
	./configure; \
1572
	$(MAKE) maintainer-clean; \
1573
	cp $(abs_srcdir)/vcs-version .; \
1574
	./configure; \
1575
	$(MAKE) $(AM_MAKEFLAGS)
1576

    
1577
dist-release: dist
1578
	set -e; \
1579
	for i in $(DIST_ARCHIVES); do \
1580
		echo -n "Checking $$i ... "; \
1581
		autotools/check-tar < $$i; \
1582
		echo OK; \
1583
	done
1584

    
1585
install-exec-local:
1586
	@mkdir_p@ "$(DESTDIR)${localstatedir}/lib/ganeti" \
1587
	  "$(DESTDIR)${localstatedir}/log/ganeti" \
1588
	  "$(DESTDIR)${localstatedir}/run/ganeti"
1589

    
1590
.PHONY: apidoc
1591
if WANT_HTOOLSAPIDOC
1592
apidoc: py-apidoc hs-apidoc
1593
else
1594
apidoc: py-apidoc
1595
endif
1596

    
1597
.PHONY: py-apidoc
1598
py-apidoc: epydoc.conf $(RUN_IN_TEMPDIR) $(GENERATED_FILES)
1599
	$(RUN_IN_TEMPDIR) epydoc -v \
1600
		--conf $(CURDIR)/epydoc.conf \
1601
		--output $(CURDIR)/$(APIDOC_PY_DIR)
1602

    
1603
.PHONY: hs-apidoc
1604
hs-apidoc: $(HS_BUILT_SRCS)
1605
	@test -n "$(HSCOLOUR)" || \
1606
	    { echo 'HsColour' not found during configure; exit 1; }
1607
	@test -n "$(HADDOCK)" || \
1608
	    { echo 'haddock' not found during configure; exit 1; }
1609
	rm -rf $(APIDOC_HS_DIR)/*
1610
	@mkdir_p@ $(APIDOC_HS_DIR)/Ganeti/HTools/Backend
1611
	@mkdir_p@ $(APIDOC_HS_DIR)/Ganeti/HTools/Program
1612
	@mkdir_p@ $(APIDOC_HS_DIR)/Ganeti/Confd
1613
	@mkdir_p@ $(APIDOC_HS_DIR)/Ganeti/Query
1614
	$(HSCOLOUR) -print-css > $(APIDOC_HS_DIR)/Ganeti/hscolour.css
1615
	$(LN_S) ../hscolour.css $(APIDOC_HS_DIR)/Ganeti/HTools/hscolour.css
1616
	$(LN_S) ../hscolour.css $(APIDOC_HS_DIR)/Ganeti/Confd/hscolour.css
1617
	set -e ; \
1618
	cd htools; \
1619
	if [ "$(HTOOLS_NOCURL)" ]; \
1620
	then OPTGHC="--optghc=$(HTOOLS_NOCURL)"; \
1621
	else OPTGHC=""; \
1622
	fi; \
1623
	if [ "$(HTOOLS_PARALLEL3)" ]; \
1624
	then OPTGHC="$$OPTGHC --optghc=$(HTOOLS_PARALLEL3)"; \
1625
	fi; \
1626
	if [ "$(HTOOLS_REGEX_PCRE)" ]; \
1627
	then OPTGHC="$$OPTGHC --optghc=$(HTOOLS_REGEX_PCRE)"; \
1628
	fi; \
1629
	RELSRCS="$(HS_LIB_SRCS:htools/%=%) $(patsubst htools/%,%,$(filter htools/%,$(HS_BUILT_SRCS)))"; \
1630
	for file in $$RELSRCS; do \
1631
		hfile=`echo $$file|sed 's/\\.hs$$//'`.html; \
1632
		$(HSCOLOUR) -css -anchor $$file > ../$(APIDOC_HS_DIR)/$$hfile ; \
1633
	done ; \
1634
	$(HADDOCK) --odir ../$(APIDOC_HS_DIR) --html --ignore-all-exports -w \
1635
		-t ganeti -p haddock-prologue \
1636
		--source-module="%{MODULE/.//}.html" \
1637
		--source-entity="%{MODULE/.//}.html#%{NAME}" \
1638
		$$OPTGHC \
1639
		$(filter-out Ganeti/HTools/ExtLoader.hs,$(HS_LIB_SRCS:htools/%=%))
1640

    
1641
.PHONY: TAGS
1642
TAGS: $(GENERATED_FILES)
1643
	rm -f TAGS
1644
	$(GHC) -e ":etags" -v0 \
1645
	  $(filter-out -O -Werror,$(HFLAGS)) \
1646
	  $(HTOOLS_NOCURL) $(HTOOLS_PARALLEL3) $(HTOOLS_REGEX_PCRE) \
1647
	  $(HS_LIBTEST_SRCS)
1648
	find . -path './lib/*.py' -o -path './scripts/gnt-*' -o \
1649
	  -path './daemons/ganeti-*' -o -path './tools/*' -o \
1650
	  -path './qa/*.py' | \
1651
	  etags -l python -a -
1652

    
1653
.PHONY: coverage
1654
if WANT_HTOOLS
1655
coverage: py-coverage hs-coverage
1656
else
1657
coverage: py-coverage
1658
endif
1659

    
1660
.PHONY: py-coverage
1661
py-coverage: $(GENERATED_FILES) $(python_tests)
1662
	@test -n "$(PYCOVERAGE)" || \
1663
	    { echo 'python-coverage' not found during configure; exit 1; }
1664
	set -e; \
1665
	COVERAGE=$(PYCOVERAGE) \
1666
	COVERAGE_FILE=$(CURDIR)/$(COVERAGE_PY_DIR)/data \
1667
	TEXT_COVERAGE=$(CURDIR)/$(COVERAGE_PY_DIR)/report.txt \
1668
	HTML_COVERAGE=$(CURDIR)/$(COVERAGE_PY_DIR) \
1669
	$(PLAIN_TESTS_ENVIRONMENT) $(abs_top_srcdir)/autotools/gen-coverage \
1670
	$(python_tests)
1671

    
1672
.PHONY: hs-coverage
1673
hs-coverage: $(haskell_tests) htest/hpc-htools
1674
	rm -f *.tix
1675
	$(MAKE) $(AM_MAKEFLAGS) hs-check
1676
	@mkdir_p@ $(COVERAGE_HS_DIR)
1677
	hpc combine --union $(HPCEXCL) \
1678
	  test.tix hpc-htools.tix > coverage-htools.tix
1679
	hpc markup --destdir=$(COVERAGE_HS_DIR) coverage-htools.tix
1680
	hpc report coverage-htools.tix
1681
	$(LN_S) -f hpc_index.html $(COVERAGE_HS_DIR)/index.html
1682

    
1683
# Special "kind-of-QA" target for htools, needs special setup (all
1684
# tools compiled with -fhpc)
1685
.PHONY: live-test
1686
live-test: all
1687
	set -e ; \
1688
	cd htools; \
1689
	rm -f .hpc; $(LN_S) ../.hpc .hpc; \
1690
	rm -f *.tix *.mix; \
1691
	./live-test.sh; \
1692
	hpc sum --union $(HPCEXCL) $(addsuffix .tix,$(HS_PROGS:htools/%=%)) \
1693
	  --output=live-test.tix ; \
1694
	@mkdir_p@ ../$(COVERAGE_HS_DIR) ; \
1695
	hpc markup --destdir=../$(COVERAGE_HS_DIR) live-test \
1696
		--srcdir=.. $(HPCEXCL) ; \
1697
	hpc report --srcdir=.. live-test $(HPCEXCL)
1698

    
1699
commit-check: distcheck lint apidoc
1700

    
1701
.PHONY: gitignore-check
1702
gitignore-check:
1703
	@if [ -n "`git status --short`" ]; then \
1704
	  echo "Git status is not clean!" 1>&2 ; \
1705
	  git status --short; \
1706
	  exit 1; \
1707
	fi
1708

    
1709
# Target that builds all binaries (including those that are not
1710
# rebuilt except when running the tests)
1711
.PHONY: really-all
1712
really-all: all $(check_SCRIPTS) $(haskell_tests)
1713

    
1714
# we don't need the ancient implicit rules:
1715
%: %,v
1716
%: RCS/%,v
1717
%: RCS/%
1718
%: s.%
1719
%: SCCS/s.%
1720

    
1721
-include ./Makefile.local
1722

    
1723
# vim: set noet :