Statistics
| Branch: | Tag: | Revision:

root / Makefile.am @ ba4e38e8

History | View | Annotate | Download (39.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

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

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

    
56
HTOOLS_DIRS = \
57
	htools \
58
	htools/Ganeti \
59
	htools/Ganeti/HTools \
60
	htools/Ganeti/HTools/Program
61

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

    
92
BUILDTIME_DIR_AUTOCREATE = \
93
	scripts \
94
	$(APIDOC_DIR) \
95
	$(APIDOC_PY_DIR) \
96
	$(APIDOC_HS_DIR) \
97
	$(APIDOC_HS_DIR)/Ganeti $(APIDOC_HS_DIR)/Ganeti/HTools \
98
	$(APIDOC_HS_DIR)/Ganeti/HTools/Program \
99
	$(COVERAGE_DIR) \
100
	$(COVERAGE_PY_DIR) \
101
	$(COVERAGE_HS_DIR) \
102
	.hpc
103

    
104
BUILDTIME_DIRS = \
105
	$(BUILDTIME_DIR_AUTOCREATE) \
106
	doc/html
107

    
108
DIRCHECK_EXCLUDE = \
109
	$(BUILDTIME_DIRS) \
110
	ganeti-[0-9]*.[0-9]*.[0-9]* \
111
	doc/html/_*
112

    
113
all_dirfiles = $(addsuffix /.dir,$(DIRS) $(BUILDTIME_DIR_AUTOCREATE))
114

    
115
# some helper vars
116
COVERAGE_DIR = doc/coverage
117
COVERAGE_PY_DIR = $(COVERAGE_DIR)/py
118
COVERAGE_HS_DIR = $(COVERAGE_DIR)/hs
119
APIDOC_DIR = doc/api
120
APIDOC_PY_DIR = $(APIDOC_DIR)/py
121
APIDOC_HS_DIR = $(APIDOC_DIR)/hs
122

    
123
MAINTAINERCLEANFILES = \
124
	$(docpng) \
125
	$(maninput) \
126
	doc/install-quick.rst \
127
	doc/news.rst \
128
	doc/upgrade.rst \
129
	vcs-version
130

    
131
maintainer-clean-local:
132
	rm -rf $(BUILDTIME_DIRS)
133

    
134
CLEANFILES = \
135
	$(addsuffix /*.py[co],$(DIRS)) \
136
	$(addsuffix /*.hi,$(HTOOLS_DIRS)) \
137
	$(addsuffix /*.o,$(HTOOLS_DIRS)) \
138
	$(all_dirfiles) \
139
	$(PYTHON_BOOTSTRAP) \
140
	epydoc.conf \
141
	autotools/replace_vars.sed \
142
	daemons/daemon-util \
143
	daemons/ganeti-cleaner \
144
	devel/upload \
145
	$(BUILT_EXAMPLES) \
146
	doc/examples/bash_completion \
147
	lib/_generated_rpc.py \
148
	$(man_MANS) \
149
	$(manhtml) \
150
	tools/kvm-ifup \
151
	stamp-srclinks \
152
	$(nodist_pkgpython_PYTHON) \
153
	$(HS_ALL_PROGS) $(HS_BUILT_SRCS) \
154
	.hpc/*.mix htools/*.tix \
155
	doc/hs-lint.html
156

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

    
164
built_base_sources = \
165
	ganeti \
166
	stamp-srclinks \
167
	$(all_dirfiles)
168

    
169
built_python_base_sources = \
170
	lib/_autoconf.py \
171
	lib/_vcsversion.py
172

    
173
BUILT_PYTHON_SOURCES = \
174
	$(built_python_base_sources) \
175
	lib/_generated_rpc.py
176

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

    
181
# these are all built from the underlying %.in sources
182
BUILT_EXAMPLES = \
183
	doc/examples/ganeti-kvm-poweroff.initd \
184
	doc/examples/ganeti.cron \
185
	doc/examples/ganeti.initd \
186
	doc/examples/gnt-config-backup \
187
	doc/examples/hooks/ipsec
188

    
189
nodist_pkgpython_PYTHON = \
190
	$(BUILT_PYTHON_SOURCES)
191

    
192
noinst_PYTHON = \
193
	lib/build/__init__.py \
194
	lib/build/sphinx_ext.py
195

    
196
pkgpython_PYTHON = \
197
	lib/__init__.py \
198
	lib/asyncnotifier.py \
199
	lib/backend.py \
200
	lib/bdev.py \
201
	lib/bootstrap.py \
202
	lib/cli.py \
203
	lib/cmdlib.py \
204
	lib/compat.py \
205
	lib/config.py \
206
	lib/constants.py \
207
	lib/daemon.py \
208
	lib/errors.py \
209
	lib/ht.py \
210
	lib/jqueue.py \
211
	lib/jstore.py \
212
	lib/locking.py \
213
	lib/luxi.py \
214
	lib/mcpu.py \
215
	lib/netutils.py \
216
	lib/objects.py \
217
	lib/opcodes.py \
218
	lib/ovf.py \
219
	lib/qlang.py \
220
	lib/query.py \
221
	lib/rpc.py \
222
	lib/rpc_defs.py \
223
	lib/runtime.py \
224
	lib/serializer.py \
225
	lib/ssconf.py \
226
	lib/ssh.py \
227
	lib/storage.py \
228
	lib/uidpool.py \
229
	lib/workerpool.py
230

    
231
client_PYTHON = \
232
	lib/client/__init__.py \
233
	lib/client/gnt_backup.py \
234
	lib/client/gnt_cluster.py \
235
	lib/client/gnt_debug.py \
236
	lib/client/gnt_group.py \
237
	lib/client/gnt_instance.py \
238
	lib/client/gnt_job.py \
239
	lib/client/gnt_node.py \
240
	lib/client/gnt_os.py
241

    
242
hypervisor_PYTHON = \
243
	lib/hypervisor/__init__.py \
244
	lib/hypervisor/hv_base.py \
245
	lib/hypervisor/hv_chroot.py \
246
	lib/hypervisor/hv_fake.py \
247
	lib/hypervisor/hv_kvm.py \
248
	lib/hypervisor/hv_lxc.py \
249
	lib/hypervisor/hv_xen.py
250

    
251
rapi_PYTHON = \
252
	lib/rapi/__init__.py \
253
	lib/rapi/baserlib.py \
254
	lib/rapi/client.py \
255
	lib/rapi/client_utils.py \
256
	lib/rapi/connector.py \
257
	lib/rapi/rlib2.py \
258
	lib/rapi/testutils.py
259

    
260
http_PYTHON = \
261
	lib/http/__init__.py \
262
	lib/http/auth.py \
263
	lib/http/client.py \
264
	lib/http/server.py
265

    
266
confd_PYTHON = \
267
	lib/confd/__init__.py \
268
	lib/confd/client.py \
269
	lib/confd/querylib.py \
270
	lib/confd/server.py
271

    
272
masterd_PYTHON = \
273
	lib/masterd/__init__.py \
274
	lib/masterd/instance.py
275

    
276
impexpd_PYTHON = \
277
	lib/impexpd/__init__.py
278

    
279
watcher_PYTHON = \
280
	lib/watcher/__init__.py \
281
	lib/watcher/nodemaint.py \
282
	lib/watcher/state.py
283

    
284
server_PYTHON = \
285
	lib/server/__init__.py \
286
	lib/server/confd.py \
287
	lib/server/masterd.py \
288
	lib/server/noded.py \
289
	lib/server/rapi.py
290

    
291
pytools_PYTHON = \
292
	lib/tools/__init__.py \
293
	lib/tools/ensure_dirs.py
294

    
295
utils_PYTHON = \
296
	lib/utils/__init__.py \
297
	lib/utils/algo.py \
298
	lib/utils/filelock.py \
299
	lib/utils/hash.py \
300
	lib/utils/io.py \
301
	lib/utils/log.py \
302
	lib/utils/mlock.py \
303
	lib/utils/nodesetup.py \
304
	lib/utils/process.py \
305
	lib/utils/retry.py \
306
	lib/utils/text.py \
307
	lib/utils/wrapper.py \
308
	lib/utils/x509.py
309

    
310
docrst = \
311
	doc/admin.rst \
312
	doc/design-2.0.rst \
313
	doc/design-2.1.rst \
314
	doc/design-2.2.rst \
315
	doc/design-2.3.rst \
316
	doc/design-htools-2.3.rst \
317
	doc/design-2.4.rst \
318
	doc/design-2.5.rst \
319
	doc/design-draft.rst \
320
	doc/design-oob.rst \
321
	doc/design-cpu-pinning.rst \
322
	doc/design-query2.rst \
323
	doc/design-x509-ca.rst \
324
	doc/design-http-server.rst \
325
	doc/design-impexp2.rst \
326
	doc/design-lu-generated-jobs.rst \
327
	doc/design-multi-reloc.rst \
328
	doc/design-network.rst \
329
	doc/design-chained-jobs.rst \
330
	doc/design-ovf-support.rst \
331
	doc/design-resource-model.rst \
332
	doc/cluster-merge.rst \
333
	doc/design-shared-storage.rst \
334
	doc/design-node-state-cache.rst \
335
	doc/design-virtual-clusters.rst \
336
	doc/devnotes.rst \
337
	doc/glossary.rst \
338
	doc/hooks.rst \
339
	doc/iallocator.rst \
340
	doc/index.rst \
341
	doc/install-quick.rst \
342
	doc/install.rst \
343
	doc/locking.rst \
344
	doc/move-instance.rst \
345
	doc/news.rst \
346
	doc/rapi.rst \
347
	doc/security.rst \
348
	doc/upgrade.rst \
349
	doc/walkthrough.rst
350

    
351
HS_PROGS = htools/htools
352
HS_BIN_ROLES = hbal hscan hspace hinfo
353

    
354
HS_ALL_PROGS = $(HS_PROGS) htools/test
355
HS_PROG_SRCS = $(patsubst %,%.hs,$(HS_ALL_PROGS))
356
# we don't add -Werror by default
357
HFLAGS = -O -Wall -fwarn-monomorphism-restriction -fwarn-tabs -ihtools
358
# extra flags that can be overriden on the command line
359
HEXTRA =
360
# internal extra flags (used for htools/test mainly)
361
HEXTRA_INT =
362
# exclude options for coverage reports
363
HPCEXCL = --exclude Main \
364
	--exclude Ganeti.Constants \
365
	--exclude Ganeti.THH \
366
	--exclude Ganeti.HTools.QC \
367
	--exclude Ganeti.HTools.QCHelper \
368
	--exclude Ganeti.HTools.Version
369

    
370
HS_LIB_SRCS = \
371
	htools/Ganeti/HTools/CLI.hs \
372
	htools/Ganeti/HTools/Cluster.hs \
373
	htools/Ganeti/HTools/Compat.hs \
374
	htools/Ganeti/HTools/Container.hs \
375
	htools/Ganeti/HTools/ExtLoader.hs \
376
	htools/Ganeti/HTools/Group.hs \
377
	htools/Ganeti/HTools/IAlloc.hs \
378
	htools/Ganeti/HTools/Instance.hs \
379
	htools/Ganeti/HTools/JSON.hs \
380
	htools/Ganeti/HTools/Loader.hs \
381
	htools/Ganeti/HTools/Luxi.hs \
382
	htools/Ganeti/HTools/Node.hs \
383
	htools/Ganeti/HTools/PeerMap.hs \
384
	htools/Ganeti/HTools/QC.hs \
385
	htools/Ganeti/HTools/QCHelper.hs \
386
	htools/Ganeti/HTools/Rapi.hs \
387
	htools/Ganeti/HTools/Simu.hs \
388
	htools/Ganeti/HTools/Text.hs \
389
	htools/Ganeti/HTools/Types.hs \
390
	htools/Ganeti/HTools/Utils.hs \
391
	htools/Ganeti/HTools/Program.hs \
392
	htools/Ganeti/HTools/Program/Hail.hs \
393
	htools/Ganeti/HTools/Program/Hbal.hs \
394
	htools/Ganeti/HTools/Program/Hinfo.hs \
395
	htools/Ganeti/HTools/Program/Hscan.hs \
396
	htools/Ganeti/HTools/Program/Hspace.hs \
397
	htools/Ganeti/BasicTypes.hs \
398
	htools/Ganeti/Confd.hs \
399
	htools/Ganeti/Config.hs \
400
	htools/Ganeti/Hash.hs \
401
	htools/Ganeti/Jobs.hs \
402
	htools/Ganeti/Logging.hs \
403
	htools/Ganeti/Luxi.hs \
404
	htools/Ganeti/Objects.hs \
405
	htools/Ganeti/OpCodes.hs \
406
	htools/Ganeti/Runtime.hs \
407
	htools/Ganeti/THH.hs
408

    
409
HS_BUILT_SRCS = htools/Ganeti/HTools/Version.hs htools/Ganeti/Constants.hs
410
HS_BUILT_SRCS_IN = $(patsubst %,%.in,$(HS_BUILT_SRCS))
411

    
412
$(RUN_IN_TEMPDIR): | $(all_dirfiles)
413

    
414
# Note: we use here an order-only prerequisite, as the contents of
415
# _autoconf.py are not actually influencing the html build output: it
416
# has to exist in order for the sphinx module to be loaded
417
# successfully, but we certainly don't want the docs to be rebuilt if
418
# it changes
419
doc/html/index.html: $(docrst) $(docpng) doc/conf.py configure.ac \
420
	$(RUN_IN_TEMPDIR) lib/build/sphinx_ext.py lib/opcodes.py lib/ht.py \
421
	| $(BUILT_PYTHON_SOURCES)
422
	@test -n "$(SPHINX)" || \
423
	    { echo 'sphinx-build' not found during configure; exit 1; }
424
	@mkdir_p@ $(dir $@)
425
	PYTHONPATH=. $(RUN_IN_TEMPDIR) $(SPHINX) -q -W -b html \
426
	    -d . \
427
	    -D version="$(VERSION_MAJOR).$(VERSION_MINOR)" \
428
	    -D release="$(PACKAGE_VERSION)" \
429
	    $(abs_top_srcdir)/doc $(CURDIR)/doc/html
430
	rm -f doc/html/.buildinfo doc/html/objects.inv
431
	touch $@
432

    
433
doc/html: doc/html/index.html
434

    
435
doc/install-quick.rst: INSTALL
436
doc/news.rst: NEWS
437
doc/upgrade.rst: UPGRADE
438

    
439
doc/install-quick.rst doc/news.rst doc/upgrade.rst:
440
	set -e; \
441
	{ echo '.. This file is automatically updated at build time from $<.'; \
442
	  echo '.. Do not edit.'; \
443
	  echo; \
444
	  cat $<; \
445
	} > $@
446

    
447
docdot = \
448
	doc/arch-2.0.dot \
449
	doc/design-2.1-lock-acquire.dot \
450
	doc/design-2.1-lock-release.dot
451

    
452
docpng = $(patsubst %.dot,%.png,$(docdot))
453

    
454
# Things to build but not to install (add it to EXTRA_DIST if it should be
455
# distributed)
456
noinst_DATA = \
457
	devel/upload \
458
	doc/html \
459
	$(BUILT_EXAMPLES) \
460
	doc/examples/bash_completion \
461
	$(manhtml)
462

    
463
gnt_scripts = \
464
	scripts/gnt-backup \
465
	scripts/gnt-cluster \
466
	scripts/gnt-debug \
467
	scripts/gnt-group \
468
	scripts/gnt-instance \
469
	scripts/gnt-job \
470
	scripts/gnt-node \
471
	scripts/gnt-os
472

    
473
PYTHON_BOOTSTRAP_SBIN = \
474
	daemons/ganeti-confd \
475
	daemons/ganeti-masterd \
476
	daemons/ganeti-noded \
477
	daemons/ganeti-watcher \
478
	daemons/ganeti-rapi \
479
	$(gnt_scripts)
480

    
481
PYTHON_BOOTSTRAP = \
482
	$(PYTHON_BOOTSTRAP_SBIN) \
483
	tools/ensure-dirs
484

    
485
qa_scripts = \
486
	qa/ganeti-qa.py \
487
	qa/qa_cluster.py \
488
	qa/qa_config.py \
489
	qa/qa_daemon.py \
490
	qa/qa_env.py \
491
	qa/qa_error.py \
492
	qa/qa_group.py \
493
	qa/qa_instance.py \
494
	qa/qa_node.py \
495
	qa/qa_os.py \
496
	qa/qa_rapi.py \
497
	qa/qa_tags.py \
498
	qa/qa_utils.py
499

    
500
bin_SCRIPTS =
501
if WANT_HTOOLS
502
bin_SCRIPTS += $(filter-out htools/hail,$(HS_PROGS))
503
install-exec-hook:
504
	@mkdir_p@ $(DESTDIR)$(iallocatorsdir)
505
# FIXME: this is a hardcoded logic, instead of auto-resolving
506
	$(LN_S) -f ../../../bin/htools \
507
		   $(DESTDIR)$(iallocatorsdir)/hail
508
	for role in $(HS_BIN_ROLES); do \
509
		$(LN_S) -f htools \
510
			   $(DESTDIR)$(bindir)/$$role ; \
511
	done
512
endif
513

    
514
$(HS_ALL_PROGS): %: %.hs $(HS_LIB_SRCS) $(HS_BUILT_SRCS) Makefile
515
	@if [ -z "$(HTOOLS)" ]; then \
516
	  echo "Error: htools compilation disabled at configure time" 1>&2 ;\
517
	  exit 1; \
518
	fi
519
	@BINARY=$(@:htools/%=%); \
520
	if [ "$BINARY" = "test" ] && [ -z "$(GHC_PKG_QUICKCHECK)" ]; then \
521
	  echo "Error: cannot run unittests without the QuickCheck library (see devnotes.rst)" 1>&2; \
522
	  exit 1; \
523
	fi
524
	rm -f $(@:htools/%=%).tix
525
	BINARY=$(@:htools/%=%); $(GHC) --make \
526
	  $(HFLAGS) \
527
	  $(HTOOLS_NOCURL) $(HTOOLS_PARALLEL3) \
528
	  -osuf $$BINARY.o -hisuf $$BINARY.hi \
529
	  $(HEXTRA) $(HEXTRA_INT) $@
530

    
531
# for the htools/test binary, we need to enable profiling/coverage
532
htools/test: HEXTRA_INT=-fhpc -Wwarn -fno-warn-missing-signatures \
533
	-fno-warn-monomorphism-restriction -fno-warn-orphans \
534
	-fno-warn-missing-methods -fno-warn-unused-imports
535

    
536
# rules for building profiling-enabled versions of the haskell
537
# programs: hs-prof does the full two-step build, whereas
538
# hs-prof-quick does only the final rebuild (hs-prof must have been
539
# run before)
540
.PHONY: hs-prof hs-prof-quick
541
hs-prof:
542
	$(MAKE) clean
543
	$(MAKE) $(HS_ALL_PROGS) HEXTRA="-osuf .o"
544
	rm -f $(HS_ALL_PROGS)
545
	$(MAKE) hs-prof-quick
546

    
547
hs-prof-quick:
548
	$(MAKE) $(HS_ALL_PROGS) HEXTRA="-osuf .prof_o -prof -auto-all"
549

    
550
dist_sbin_SCRIPTS = \
551
	tools/ganeti-listrunner
552

    
553
nodist_sbin_SCRIPTS = \
554
	$(PYTHON_BOOTSTRAP_SBIN) \
555
	daemons/ganeti-cleaner
556

    
557
python_scripts = \
558
	tools/burnin \
559
	tools/cfgshell \
560
	tools/cfgupgrade \
561
	tools/cfgupgrade12 \
562
	tools/cluster-merge \
563
	tools/confd-client \
564
	tools/fmtjson \
565
	tools/lvmstrap \
566
	tools/move-instance \
567
	tools/ovfconverter \
568
	tools/setup-ssh \
569
	tools/sanitize-config
570

    
571
dist_tools_SCRIPTS = \
572
	$(python_scripts) \
573
	tools/kvm-console-wrapper \
574
	tools/xm-console-wrapper \
575
	tools/master-ip-setup
576

    
577
pkglib_python_scripts = \
578
	daemons/import-export \
579
	tools/check-cert-expired
580

    
581
nodist_pkglib_python_scripts = \
582
	tools/ensure-dirs
583

    
584
myexeclib_SCRIPTS = \
585
	daemons/daemon-util \
586
	tools/kvm-ifup \
587
	$(pkglib_python_scripts)
588

    
589
nodist_myexeclib_SCRIPTS = \
590
	$(nodist_pkglib_python_scripts)
591

    
592
EXTRA_DIST = \
593
	NEWS \
594
	UPGRADE \
595
	epydoc.conf.in \
596
	pylintrc \
597
	autotools/build-bash-completion \
598
	autotools/build-rpc \
599
	autotools/check-header \
600
	autotools/check-python-code \
601
	autotools/check-imports \
602
	autotools/check-man-dashes \
603
	autotools/check-man-warnings \
604
	autotools/check-news \
605
	autotools/check-tar \
606
	autotools/check-version \
607
	autotools/convert-constants \
608
	autotools/docpp \
609
	autotools/gen-coverage \
610
	autotools/testrunner \
611
	$(RUN_IN_TEMPDIR) \
612
	daemons/daemon-util.in \
613
	daemons/ganeti-cleaner.in \
614
	$(pkglib_python_scripts) \
615
	devel/upload.in \
616
	tools/kvm-ifup.in \
617
	$(docdot) \
618
	$(docpng) \
619
	$(docrst) \
620
	doc/conf.py \
621
	doc/html \
622
	$(BUILT_EXAMPLES:%=%.in) \
623
	doc/examples/ganeti.default \
624
	doc/examples/ganeti.default-debug \
625
	doc/examples/hooks/ethers \
626
	doc/examples/gnt-debug/README \
627
	doc/examples/gnt-debug/delay0.json \
628
	doc/examples/gnt-debug/delay50.json \
629
	test/lockperf.py \
630
	test/testutils.py \
631
	test/mocks.py \
632
	$(dist_TESTS) \
633
	$(TEST_FILES) \
634
	man/footer.rst \
635
	$(manrst) \
636
	$(maninput) \
637
	qa/qa-sample.json \
638
	$(qa_scripts) \
639
	$(HS_LIB_SRCS) $(HS_BUILT_SRCS_IN) \
640
	$(HS_PROG_SRCS) \
641
	htools/lint-hints.hs
642

    
643
man_MANS = \
644
	man/ganeti.7 \
645
	man/ganeti-cleaner.8 \
646
	man/ganeti-confd.8 \
647
	man/ganeti-listrunner.8 \
648
	man/ganeti-masterd.8 \
649
	man/ganeti-noded.8 \
650
	man/ganeti-os-interface.7 \
651
	man/ganeti-rapi.8 \
652
	man/ganeti-watcher.8 \
653
	man/gnt-backup.8 \
654
	man/gnt-cluster.8 \
655
	man/gnt-debug.8 \
656
	man/gnt-group.8 \
657
	man/gnt-instance.8 \
658
	man/gnt-job.8 \
659
	man/gnt-node.8 \
660
	man/gnt-os.8 \
661
	man/hail.1 \
662
	man/hbal.1 \
663
	man/hinfo.1 \
664
	man/hscan.1 \
665
	man/hspace.1 \
666
	man/htools.1
667

    
668
manrst = $(patsubst %.1,%.rst,$(patsubst %.7,%.rst,$(patsubst %.8,%.rst,$(man_MANS))))
669
manhtml = $(patsubst %.rst,%.html,$(manrst))
670
mangen = $(patsubst %.rst,%.gen,$(manrst))
671
maninput = \
672
	$(patsubst %.1,%.1.in,$(patsubst %.7,%.7.in,$(patsubst %.8,%.8.in,$(man_MANS)))) \
673
	$(patsubst %.html,%.html.in,$(manhtml)) \
674
	man/footer.man man/footer.html $(mangen)
675

    
676
TEST_FILES = \
677
	test/data/bdev-drbd-8.0.txt \
678
	test/data/bdev-drbd-8.3.txt \
679
	test/data/bdev-drbd-disk.txt \
680
	test/data/bdev-drbd-net-ip4.txt \
681
	test/data/bdev-drbd-net-ip6.txt \
682
	test/data/cert1.pem \
683
	test/data/ip-addr-show-dummy0.txt \
684
	test/data/ip-addr-show-lo-ipv4.txt \
685
	test/data/ip-addr-show-lo-ipv6.txt \
686
	test/data/ip-addr-show-lo-oneline-ipv4.txt \
687
	test/data/ip-addr-show-lo-oneline-ipv6.txt \
688
	test/data/ip-addr-show-lo-oneline.txt \
689
	test/data/ip-addr-show-lo.txt \
690
	test/data/proc_drbd8.txt \
691
	test/data/proc_drbd80-emptyline.txt \
692
	test/data/proc_drbd83.txt \
693
	test/data/proc_drbd83_sync.txt \
694
	test/data/proc_drbd83_sync_krnl2.6.39.txt \
695
	test/data/kvm_1.0_help.txt \
696
	test/data/kvm_0.15.90_help.txt \
697
	test/data/kvm_0.12.5_help.txt \
698
	test/data/kvm_0.9.1_help.txt \
699
	test/data/sys_drbd_usermode_helper.txt \
700
	test/data/ovfdata/compr_disk.vmdk.gz \
701
	test/data/ovfdata/config.ini \
702
	test/data/ovfdata/corrupted_resources.ovf \
703
	test/data/ovfdata/empty.ini \
704
	test/data/ovfdata/empty.ovf \
705
	test/data/ovfdata/ganeti.mf \
706
	test/data/ovfdata/ganeti.ovf \
707
	test/data/ovfdata/gzip_disk.ovf \
708
	test/data/ovfdata/new_disk.vmdk \
709
	test/data/ovfdata/no_disk.ini \
710
	test/data/ovfdata/no_disk_in_ref.ovf \
711
	test/data/ovfdata/no_os.ini \
712
	test/data/ovfdata/no_ovf.ova \
713
	test/data/ovfdata/ova.ova \
714
	test/data/ovfdata/second_disk.vmdk \
715
	test/data/ovfdata/rawdisk.raw \
716
	test/data/ovfdata/unsafe_path.ini \
717
	test/data/ovfdata/virtualbox.ovf \
718
	test/data/ovfdata/wrong_extension.ovd \
719
	test/data/ovfdata/wrong_config.ini \
720
	test/data/ovfdata/wrong_manifest.mf \
721
	test/data/ovfdata/wrong_manifest.ovf \
722
	test/data/ovfdata/wrong_ova.ova \
723
	test/data/ovfdata/wrong_xml.ovf \
724
	test/data/ovfdata/other/rawdisk.raw \
725
	test/data/vgreduce-removemissing-2.02.02.txt \
726
	test/data/vgreduce-removemissing-2.02.66-fail.txt \
727
	test/data/vgreduce-removemissing-2.02.66-ok.txt \
728
	test/data/vgs-missing-pvs-2.02.02.txt \
729
	test/data/vgs-missing-pvs-2.02.66.txt \
730
	test/import-export_unittest-helper
731

    
732
python_tests = \
733
	test/ganeti.asyncnotifier_unittest.py \
734
	test/ganeti.backend_unittest.py \
735
	test/ganeti.bdev_unittest.py \
736
	test/ganeti.cli_unittest.py \
737
	test/ganeti.client.gnt_cluster_unittest.py \
738
	test/ganeti.client.gnt_instance_unittest.py \
739
	test/ganeti.daemon_unittest.py \
740
	test/ganeti.cmdlib_unittest.py \
741
	test/ganeti.compat_unittest.py \
742
	test/ganeti.confd.client_unittest.py \
743
	test/ganeti.config_unittest.py \
744
	test/ganeti.constants_unittest.py \
745
	test/ganeti.errors_unittest.py \
746
	test/ganeti.hooks_unittest.py \
747
	test/ganeti.ht_unittest.py \
748
	test/ganeti.http_unittest.py \
749
	test/ganeti.hypervisor_unittest.py \
750
	test/ganeti.hypervisor.hv_chroot_unittest.py \
751
	test/ganeti.hypervisor.hv_fake_unittest.py \
752
	test/ganeti.hypervisor.hv_kvm_unittest.py \
753
	test/ganeti.hypervisor.hv_lxc_unittest.py \
754
	test/ganeti.hypervisor.hv_xen_unittest.py \
755
	test/ganeti.impexpd_unittest.py \
756
	test/ganeti.jqueue_unittest.py \
757
	test/ganeti.locking_unittest.py \
758
	test/ganeti.luxi_unittest.py \
759
	test/ganeti.masterd.instance_unittest.py \
760
	test/ganeti.mcpu_unittest.py \
761
	test/ganeti.netutils_unittest.py \
762
	test/ganeti.objects_unittest.py \
763
	test/ganeti.opcodes_unittest.py \
764
	test/ganeti.ovf_unittest.py \
765
	test/ganeti.qlang_unittest.py \
766
	test/ganeti.query_unittest.py \
767
	test/ganeti.rapi.baserlib_unittest.py \
768
	test/ganeti.rapi.client_unittest.py \
769
	test/ganeti.rapi.resources_unittest.py \
770
	test/ganeti.rapi.rlib2_unittest.py \
771
	test/ganeti.rapi.testutils_unittest.py \
772
	test/ganeti.rpc_unittest.py \
773
	test/ganeti.runtime_unittest.py \
774
	test/ganeti.serializer_unittest.py \
775
	test/ganeti.ssh_unittest.py \
776
	test/ganeti.storage_unittest.py \
777
	test/ganeti.tools.ensure_dirs_unittest.py \
778
	test/ganeti.uidpool_unittest.py \
779
	test/ganeti.utils.algo_unittest.py \
780
	test/ganeti.utils.filelock_unittest.py \
781
	test/ganeti.utils.hash_unittest.py \
782
	test/ganeti.utils.io_unittest.py \
783
	test/ganeti.utils.log_unittest.py \
784
	test/ganeti.utils.mlock_unittest.py \
785
	test/ganeti.utils.nodesetup_unittest.py \
786
	test/ganeti.utils.process_unittest.py \
787
	test/ganeti.utils.retry_unittest.py \
788
	test/ganeti.utils.text_unittest.py \
789
	test/ganeti.utils.wrapper_unittest.py \
790
	test/ganeti.utils.x509_unittest.py \
791
	test/ganeti.utils_unittest.py \
792
	test/ganeti.workerpool_unittest.py \
793
	test/cfgupgrade_unittest.py \
794
	test/docs_unittest.py \
795
	test/pycurl_reset_unittest.py \
796
	test/tempfile_fork_unittest.py
797
if HAS_FAKEROOT
798
python_tests += test/ganeti.utils.io_unittest-runasroot.py
799
endif
800

    
801
haskell_tests = htools/test
802

    
803
dist_TESTS = \
804
	test/check-cert-expired_unittest.bash \
805
	test/daemon-util_unittest.bash \
806
	test/ganeti-cleaner_unittest.bash \
807
	test/import-export_unittest.bash \
808
	$(python_tests)
809

    
810
nodist_TESTS =
811
if WANT_HTOOLSTESTS
812
nodist_TESTS += $(haskell_tests)
813
endif
814

    
815
TESTS = $(dist_TESTS) $(nodist_TESTS)
816

    
817
# Environment for all tests
818
PLAIN_TESTS_ENVIRONMENT = \
819
	PYTHONPATH=. TOP_SRCDIR=$(abs_top_srcdir) PYTHON=$(PYTHON) \
820
	FAKEROOT=$(FAKEROOT_PATH) $(RUN_IN_TEMPDIR)
821

    
822
# Environment for tests run by automake
823
TESTS_ENVIRONMENT = \
824
	$(PLAIN_TESTS_ENVIRONMENT) $(abs_top_srcdir)/autotools/testrunner
825

    
826
all_python_code = \
827
	$(dist_sbin_SCRIPTS) \
828
	$(python_scripts) \
829
	$(pkglib_python_scripts) \
830
	$(nodist_pkglib_python_scripts) \
831
	$(python_tests) \
832
	$(pkgpython_PYTHON) \
833
	$(client_PYTHON) \
834
	$(hypervisor_PYTHON) \
835
	$(rapi_PYTHON) \
836
	$(server_PYTHON) \
837
	$(pytools_PYTHON) \
838
	$(http_PYTHON) \
839
	$(confd_PYTHON) \
840
	$(masterd_PYTHON) \
841
	$(impexpd_PYTHON) \
842
	$(utils_PYTHON) \
843
	$(watcher_PYTHON) \
844
	$(noinst_PYTHON) \
845
	$(qa_scripts)
846

    
847
srclink_files = \
848
	man/footer.rst \
849
	test/check-cert-expired_unittest.bash \
850
	test/daemon-util_unittest.bash \
851
	test/ganeti-cleaner_unittest.bash \
852
	test/import-export_unittest.bash \
853
	$(all_python_code) \
854
	$(HS_LIB_SRCS) $(HS_PROG_SRCS)
855

    
856
check_python_code = \
857
	$(BUILD_BASH_COMPLETION) \
858
	$(CHECK_IMPORTS) \
859
	$(CHECK_HEADER) \
860
	$(DOCPP) \
861
	$(all_python_code)
862

    
863
lint_python_code = \
864
	ganeti \
865
	ganeti/http/server.py \
866
	$(dist_sbin_SCRIPTS) \
867
	$(python_scripts) \
868
	$(pkglib_python_scripts) \
869
	$(BUILD_BASH_COMPLETION) \
870
	$(CHECK_IMPORTS) \
871
	$(CHECK_HEADER) \
872
	$(DOCPP) \
873
	$(PYTHON_BOOTSTRAP)
874

    
875
standalone_python_modules = \
876
	lib/rapi/client.py \
877
	tools/ganeti-listrunner
878

    
879
pep8_python_code = \
880
	ganeti \
881
	ganeti/http/server.py \
882
	$(dist_sbin_SCRIPTS) \
883
	$(python_scripts) \
884
	$(pkglib_python_scripts) \
885
	$(BUILD_BASH_COMPLETION) \
886
	$(CHECK_HEADER) \
887
	$(DOCPP) \
888
	$(PYTHON_BOOTSTRAP) \
889
	qa
890

    
891
test/daemon-util_unittest.bash: daemons/daemon-util
892

    
893
test/ganeti-cleaner_unittest.bash: daemons/ganeti-cleaner
894

    
895
tools/kvm-ifup: tools/kvm-ifup.in $(REPLACE_VARS_SED)
896
	sed -f $(REPLACE_VARS_SED) < $< > $@
897
	chmod +x $@
898

    
899
devel/upload: devel/upload.in $(REPLACE_VARS_SED)
900
	sed -f $(REPLACE_VARS_SED) < $< > $@
901
	chmod u+x $@
902

    
903
daemons/%: daemons/%.in $(REPLACE_VARS_SED)
904
	sed -f $(REPLACE_VARS_SED) < $< > $@
905
	chmod +x $@
906

    
907
doc/examples/%: doc/examples/%.in $(REPLACE_VARS_SED)
908
	sed -f $(REPLACE_VARS_SED) < $< > $@
909

    
910
doc/examples/hooks/%: doc/examples/hooks/%.in $(REPLACE_VARS_SED)
911
	sed -f $(REPLACE_VARS_SED) < $< > $@
912

    
913
doc/examples/bash_completion: $(BUILD_BASH_COMPLETION) $(RUN_IN_TEMPDIR) \
914
	lib/cli.py $(gnt_scripts) $(client_PYTHON) tools/burnin
915
	PYTHONPATH=. $(RUN_IN_TEMPDIR) $(CURDIR)/$(BUILD_BASH_COMPLETION) > $@
916

    
917
doc/%.png: doc/%.dot
918
	@test -n "$(DOT)" || { echo 'dot' not found during configure; exit 1; }
919
	$(DOT) -Tpng -o $@ $<
920

    
921
man/footer.man: man/footer.rst
922
	@test -n "$(PANDOC)" || \
923
	  { echo 'pandoc' not found during configure; exit 1; }
924
	$(PANDOC) -f rst -t man -o $@ $<
925

    
926
man/footer.html: man/footer.rst
927
	@test -n "$(PANDOC)" || \
928
	  { echo 'pandoc' not found during configure; exit 1; }
929
	$(PANDOC) -f rst -t html -o $@ $<
930

    
931
man/%.gen: man/%.rst lib/query.py lib/build/sphinx_ext.py
932
	PYTHONPATH=. $(RUN_IN_TEMPDIR) $(CURDIR)/$(DOCPP) < $< > $@
933

    
934
man/%.7.in man/%.8.in man/%.1.in: man/%.gen man/footer.man
935
	@test -n "$(PANDOC)" || \
936
	  { echo 'pandoc' not found during configure; exit 1; }
937
	set -o pipefail ; \
938
	trap 'echo auto-removing $@; rm $@' EXIT; \
939
	$(PANDOC) -s -f rst -t man -A man/footer.man $< | \
940
	  sed -e 's/\\@/@/g' > $@; \
941
	if test -n "$(MAN_HAS_WARNINGS)"; then $(CHECK_MAN_WARNINGS) $@; fi; \
942
	$(CHECK_MAN_DASHES) $@; \
943
	trap - EXIT
944

    
945

    
946
man/%.html.in: man/%.gen man/footer.html
947
	@test -n "$(PANDOC)" || \
948
	  { echo 'pandoc' not found during configure; exit 1; }
949
	set -o pipefail ; \
950
	$(PANDOC) -s -f rst -t html -A man/footer.html $< | \
951
	  sed -e 's/\\@/@/g' > $@
952

    
953
man/%.1: man/%.1.in $(REPLACE_VARS_SED)
954
	sed -f $(REPLACE_VARS_SED) < $< > $@
955

    
956
man/%.7: man/%.7.in $(REPLACE_VARS_SED)
957
	sed -f $(REPLACE_VARS_SED) < $< > $@
958

    
959
man/%.8: man/%.8.in $(REPLACE_VARS_SED)
960
	sed -f $(REPLACE_VARS_SED) < $< > $@
961

    
962
man/%.html: man/%.html.in $(REPLACE_VARS_SED)
963
	sed -f $(REPLACE_VARS_SED) < $< > $@
964

    
965
epydoc.conf: epydoc.conf.in Makefile
966
	sed -e 's#@MODULES@#$(strip $(lint_python_code))#g' < $< > $@
967

    
968
vcs-version:
969
	if test -d .git; then \
970
	  git describe > $@; \
971
	elif test ! -f $@ ; then \
972
	  echo "Cannot auto-generate $@ file"; exit 1; \
973
	fi
974

    
975
.PHONY: regen-vcs-version
976
regen-vcs-version:
977
	set -e; \
978
	cd $(srcdir); \
979
	if test -d .git; then \
980
	  rm -f vcs-version; \
981
	  $(MAKE) vcs-version; \
982
	fi
983

    
984
htools/Ganeti/HTools/Version.hs: htools/Ganeti/HTools/Version.hs.in vcs-version
985
	set -e; \
986
	VCSVER=`cat $(abs_top_srcdir)/vcs-version`; \
987
	sed -e "s/%ver%/$$VCSVER/" < $< > $@
988

    
989
htools/Ganeti/Constants.hs: htools/Ganeti/Constants.hs.in \
990
	lib/constants.py lib/_autoconf.py $(CONVERT_CONSTANTS) \
991
	| lib/_vcsversion.py
992
	set -e; \
993
	{ cat $< ; PYTHONPATH=. $(CONVERT_CONSTANTS); } > $@
994

    
995
lib/_autoconf.py: Makefile | lib/.dir
996
	set -e; \
997
	{ echo '# This file is automatically generated, do not edit!'; \
998
	  echo '#'; \
999
	  echo ''; \
1000
	  echo '"""Build-time configuration for Ganeti.'; \
1001
	  echo '';\
1002
	  echo 'This file is autogenerated by the build process.'; \
1003
	  echo 'For any changes you need to re-run ./configure (and'; \
1004
	  echo 'not edit by hand).'; \
1005
	  echo ''; \
1006
	  echo '"""'; \
1007
	  echo ''; \
1008
	  echo '# pylint: disable=C0301,C0324'; \
1009
	  echo '# because this is autogenerated, we do not want'; \
1010
	  echo '# style warnings' ; \
1011
	  echo ''; \
1012
	  echo "PACKAGE_VERSION = '$(PACKAGE_VERSION)'"; \
1013
	  echo "VERSION_MAJOR = '$(VERSION_MAJOR)'"; \
1014
	  echo "VERSION_MINOR = '$(VERSION_MINOR)'"; \
1015
	  echo "VERSION_REVISION = '$(VERSION_REVISION)'"; \
1016
	  echo "VERSION_SUFFIX = '$(VERSION_SUFFIX)'"; \
1017
	  echo "VERSION_FULL = '$(VERSION_FULL)'"; \
1018
	  echo "LOCALSTATEDIR = '$(localstatedir)'"; \
1019
	  echo "SYSCONFDIR = '$(sysconfdir)'"; \
1020
	  echo "SSH_CONFIG_DIR = '$(SSH_CONFIG_DIR)'"; \
1021
	  echo "EXPORT_DIR = '$(EXPORT_DIR)'"; \
1022
	  echo "OS_SEARCH_PATH = [$(OS_SEARCH_PATH)]"; \
1023
	  echo "XEN_BOOTLOADER = '$(XEN_BOOTLOADER)'"; \
1024
	  echo "XEN_KERNEL = '$(XEN_KERNEL)'"; \
1025
	  echo "XEN_INITRD = '$(XEN_INITRD)'"; \
1026
	  echo "FILE_STORAGE_DIR = '$(FILE_STORAGE_DIR)'"; \
1027
	  echo "ENABLE_FILE_STORAGE = $(ENABLE_FILE_STORAGE)"; \
1028
	  echo "SHARED_FILE_STORAGE_DIR = '$(SHARED_FILE_STORAGE_DIR)'"; \
1029
	  echo "ENABLE_SHARED_FILE_STORAGE = $(ENABLE_SHARED_FILE_STORAGE)"; \
1030
	  echo "IALLOCATOR_SEARCH_PATH = [$(IALLOCATOR_SEARCH_PATH)]"; \
1031
	  echo "KVM_PATH = '$(KVM_PATH)'"; \
1032
	  echo "IP_PATH = '$(IP_PATH)'"; \
1033
	  echo "SOCAT_PATH = '$(SOCAT)'"; \
1034
	  echo "SOCAT_USE_ESCAPE = $(SOCAT_USE_ESCAPE)"; \
1035
	  echo "SOCAT_USE_COMPRESS = $(SOCAT_USE_COMPRESS)"; \
1036
	  echo "LVM_STRIPECOUNT = $(LVM_STRIPECOUNT)"; \
1037
	  echo "TOOLSDIR = '$(toolsdir)'"; \
1038
	  echo "GNT_SCRIPTS = [$(foreach i,$(notdir $(gnt_scripts)),'$(i)',)]"; \
1039
	  echo "PKGLIBDIR = '$(pkglibdir)'"; \
1040
	  echo "DRBD_BARRIERS = '$(DRBD_BARRIERS)'"; \
1041
	  echo "DRBD_NO_META_FLUSH = $(DRBD_NO_META_FLUSH)"; \
1042
	  echo "SYSLOG_USAGE = '$(SYSLOG_USAGE)'"; \
1043
	  echo "DAEMONS_GROUP = '$(DAEMONS_GROUP)'"; \
1044
	  echo "ADMIN_GROUP = '$(ADMIN_GROUP)'"; \
1045
	  echo "MASTERD_USER = '$(MASTERD_USER)'"; \
1046
	  echo "MASTERD_GROUP = '$(MASTERD_GROUP)'"; \
1047
	  echo "RAPI_USER = '$(RAPI_USER)'"; \
1048
	  echo "RAPI_GROUP = '$(RAPI_GROUP)'"; \
1049
	  echo "CONFD_USER = '$(CONFD_USER)'"; \
1050
	  echo "CONFD_GROUP = '$(CONFD_GROUP)'"; \
1051
	  echo "NODED_USER = '$(NODED_USER)'"; \
1052
	  echo "NODED_GROUP = '$(NODED_GROUP)'"; \
1053
	  echo "DISK_SEPARATOR = '$(DISK_SEPARATOR)'"; \
1054
	  echo "QEMUIMG_PATH = '$(QEMUIMG_PATH)'"; \
1055
	  if [ "$(HTOOLS)" ]; then \
1056
	    echo "HTOOLS = True"; \
1057
	  else \
1058
	    echo "HTOOLS = False"; \
1059
	  fi; \
1060
	  echo "ENABLE_CONFD = $(ENABLE_CONFD)"; \
1061
	} > $@
1062

    
1063
lib/_vcsversion.py: Makefile vcs-version | lib/.dir
1064
	set -e; \
1065
	VCSVER=`cat $(abs_top_srcdir)/vcs-version`; \
1066
	{ echo '# This file is automatically generated, do not edit!'; \
1067
	  echo '#'; \
1068
	  echo ''; \
1069
	  echo '"""Build-time VCS version number for Ganeti.'; \
1070
	  echo '';\
1071
	  echo 'This file is autogenerated by the build process.'; \
1072
	  echo 'For any changes you need to re-run ./configure (and'; \
1073
	  echo 'not edit by hand).'; \
1074
	  echo ''; \
1075
	  echo '"""'; \
1076
	  echo ''; \
1077
	  echo '# pylint: disable=C0301,C0324'; \
1078
	  echo '# because this is autogenerated, we do not want'; \
1079
	  echo '# style warnings' ; \
1080
	  echo ''; \
1081
	  echo "VCS_VERSION = '$$VCSVER'"; \
1082
	} > $@
1083

    
1084
lib/_generated_rpc.py: lib/rpc_defs.py $(BUILD_RPC)
1085
	PYTHONPATH=. $(RUN_IN_TEMPDIR) $(CURDIR)/$(BUILD_RPC) lib/rpc_defs.py > $@
1086

    
1087
$(REPLACE_VARS_SED): Makefile
1088
	set -e; \
1089
	{ echo 's#@PREFIX@#$(prefix)#g'; \
1090
	  echo 's#@SYSCONFDIR@#$(sysconfdir)#g'; \
1091
	  echo 's#@LOCALSTATEDIR@#$(localstatedir)#g'; \
1092
	  echo 's#@BINDIR@#$(bindir)#g'; \
1093
	  echo 's#@SBINDIR@#$(sbindir)#g'; \
1094
	  echo 's#@GANETI_VERSION@#$(PACKAGE_VERSION)#g'; \
1095
	  echo 's#@CUSTOM_XEN_BOOTLOADER@#$(XEN_BOOTLOADER)#g'; \
1096
	  echo 's#@CUSTOM_XEN_KERNEL@#$(XEN_KERNEL)#g'; \
1097
	  echo 's#@CUSTOM_XEN_INITRD@#$(XEN_INITRD)#g'; \
1098
	  echo 's#@CUSTOM_IALLOCATOR_SEARCH_PATH@#$(IALLOCATOR_SEARCH_PATH)#g'; \
1099
	  echo 's#@CUSTOM_EXPORT_DIR@#$(EXPORT_DIR)#g'; \
1100
	  echo 's#@RPL_FILE_STORAGE_DIR@#$(FILE_STORAGE_DIR)#g'; \
1101
	  echo 's#@RPL_SSH_INITD_SCRIPT@#$(SSH_INITD_SCRIPT)#g'; \
1102
	  echo 's#@PKGLIBDIR@#$(pkglibdir)#g'; \
1103
	  echo 's#@GNTMASTERUSER@#$(MASTERD_USER)#g'; \
1104
	  echo 's#@GNTRAPIUSER@#$(RAPI_USER)#g'; \
1105
	  echo 's#@GNTCONFDUSER@#$(CONFD_USER)#g'; \
1106
	  echo 's#@GNTNODEDUSER@#$(NODED_USER)#g'; \
1107
	  echo 's#@GNTRAPIGROUP@#$(RAPI_GROUP)#g'; \
1108
	  echo 's#@GNTADMINGROUP@#$(ADMIN_GROUP)#g'; \
1109
	  echo 's#@GNTCONFDGROUP@#$(CONFD_GROUP)#g'; \
1110
	  echo 's#@GNTMASTERDGROUP@#$(MASTERD_GROUP)#g'; \
1111
	  echo 's#@GNTDAEMONSGROUP@#$(DAEMONS_GROUP)#g'; \
1112
	  echo 's#@CUSTOM_ENABLE_CONFD@#$(ENABLE_CONFD)#g'; \
1113
	} > $@
1114

    
1115
# Using deferred evaluation
1116
daemons/ganeti-%: MODULE = ganeti.server.$(patsubst ganeti-%,%,$(notdir $@))
1117
daemons/ganeti-watcher: MODULE = ganeti.watcher
1118
scripts/%: MODULE = ganeti.client.$(subst -,_,$(notdir $@))
1119
tools/ensure-dirs: MODULE = ganeti.tools.ensure_dirs
1120

    
1121
$(PYTHON_BOOTSTRAP): Makefile | $(all_dirfiles)
1122
	test -n "$(MODULE)" || { echo Missing module; exit 1; }
1123
	set -e; \
1124
	{ echo '#!/usr/bin/python'; \
1125
	  echo '# This file is automatically generated, do not edit!'; \
1126
	  echo "# Edit $(MODULE) instead."; \
1127
	  echo; \
1128
	  echo '"""Bootstrap script for L{$(MODULE)}"""'; \
1129
	  echo; \
1130
	  echo '# pylint: disable=C0103'; \
1131
	  echo '# C0103: Invalid name'; \
1132
	  echo; \
1133
	  echo 'import sys'; \
1134
	  echo 'import $(MODULE) as main'; \
1135
	  echo; \
1136
	  echo '# Temporarily alias commands until bash completion'; \
1137
	  echo '# generator is changed'; \
1138
	  echo 'if hasattr(main, "commands"):'; \
1139
	  echo '  commands = main.commands # pylint: disable=E1101'; \
1140
	  echo 'if hasattr(main, "aliases"):'; \
1141
	  echo '  aliases = main.aliases # pylint: disable=E1101'; \
1142
	  echo; \
1143
	  echo 'if __name__ == "__main__":'; \
1144
	  echo '  sys.exit(main.Main())'; \
1145
	} > $@
1146
	chmod u+x $@
1147

    
1148
# We need to create symlinks because "make distcheck" will not install Python
1149
# files when building.
1150
stamp-srclinks: Makefile | $(all_dirfiles)
1151
	set -e; \
1152
	for i in $(srclink_files); do \
1153
		if test ! -f $$i -a -f $(abs_top_srcdir)/$$i; then \
1154
			$(LN_S) $(abs_top_srcdir)/$$i $$i; \
1155
		fi; \
1156
	done
1157
	touch $@
1158

    
1159
.PHONY: ganeti
1160
ganeti:
1161
	cd $(top_builddir) && test -h "$@" || { rm -f $@ && $(LN_S) lib $@; }
1162

    
1163
.PHONY: check-dirs
1164
check-dirs: $(BUILT_SOURCES)
1165
	@set -e; \
1166
	find . -type d \( \( -name . \) -o \( \
1167
		-name .git -o \
1168
		-name autom4te.cache \
1169
		\) -prune -o -print \) | { \
1170
		error=; \
1171
		while read dir; do \
1172
			case "$$dir" in \
1173
				$(strip $(patsubst %,(./%) ;;,$(DIRCHECK_EXCLUDE) $(DIRS))) \
1174
				*) error=1; echo "Directory $$dir not listed in Makefile" >&2 ;; \
1175
			esac; \
1176
		done; \
1177
		for dir in $(DIRS); do \
1178
			if ! test -d "$$dir"; then \
1179
				echo "Directory $$dir listed in DIRS does not exist" >&2; \
1180
				error=1; \
1181
			fi \
1182
		done; \
1183
		if test -n "$$error"; then exit 1; else exit 0; fi; \
1184
	}
1185

    
1186
.PHONY: check-local
1187
check-local: check-dirs $(BUILT_SOURCES)
1188
	$(CHECK_PYTHON_CODE) $(check_python_code)
1189
	PYTHONPATH=. $(CHECK_HEADER) $(check_python_code)
1190
	$(CHECK_VERSION) $(VERSION) $(top_srcdir)/NEWS
1191
	$(CHECK_NEWS) < $(top_srcdir)/NEWS
1192
	PYTHONPATH=. $(RUN_IN_TEMPDIR) $(CURDIR)/$(CHECK_IMPORTS) . $(standalone_python_modules)
1193
	expver=$(VERSION_MAJOR).$(VERSION_MINOR); \
1194
	if test "`head -n 1 $(top_srcdir)/README`" != "Ganeti $$expver"; then \
1195
		echo "Incorrect version in README, expected $$expver"; \
1196
		exit 1; \
1197
	fi; \
1198
	for file in doc/iallocator.rst doc/hooks.rst; do \
1199
		if test "`sed -ne '4 p' $(top_srcdir)/$$file`" != \
1200
			"Documents Ganeti version $$expver"; then \
1201
			echo "Incorrect version in $$file, expected $$expver"; \
1202
			exit 1; \
1203
		fi; \
1204
	done
1205

    
1206
.PHONY: hs-check
1207
hs-check: htools/test
1208
	@rm -f test.tix
1209
	./htools/test
1210

    
1211
# E111: indentation is not a multiple of four
1212
# E261: at least two spaces before inline comment
1213
# E501: line too long (80 characters)
1214
PEP8_IGNORE = E111,E261,E501
1215

    
1216
# For excluding pep8 expects filenames only, not whole paths
1217
PEP8_EXCLUDE = $(subst $(space),$(comma),$(strip $(notdir $(BUILT_PYTHON_SOURCES))))
1218

    
1219
.PHONY: lint
1220
lint: $(BUILT_SOURCES)
1221
	@test -n "$(PYLINT)" || { echo 'pylint' not found during configure; exit 1; }
1222
	if test -z "$(PEP8)"; then \
1223
		echo '"pep8" not found during configure' >&2; \
1224
	else \
1225
		$(PEP8) --repeat --ignore='$(PEP8_IGNORE)' --exclude='$(PEP8_EXCLUDE)' \
1226
			$(pep8_python_code); \
1227
	fi
1228
	$(PYLINT) $(LINT_OPTS) $(lint_python_code)
1229
	cd $(top_srcdir)/qa && \
1230
	  PYTHONPATH=$(abs_top_srcdir) $(PYLINT) $(LINT_OPTS) \
1231
	  --rcfile  ../pylintrc $(patsubst qa/%.py,%,$(qa_scripts))
1232

    
1233
.PHONY: hlint
1234
hlint: $(HS_BUILT_SRCS) htools/lint-hints.hs
1235
	if tty -s; then C="-c"; else C=""; fi; \
1236
	hlint --report=doc/hs-lint.html --cross $$C \
1237
	  --ignore "Use first" \
1238
	  --ignore "Use comparing" \
1239
	  --ignore "Use on" \
1240
	  --ignore "Use Control.Exception.catch" \
1241
	  --ignore "Reduce duplication" \
1242
	  --hint htools/lint-hints \
1243
	  $(filter-out htools/Ganeti/THH.hs,$(HS_LIB_SRCS))
1244

    
1245
# a dist hook rule for updating the vcs-version file; this is
1246
# hardcoded due to where it needs to build the file...
1247
dist-hook:
1248
	$(MAKE) regen-vcs-version && \
1249
	rm -f $(top_distdir)/vcs-version && \
1250
	cp -p $(srcdir)/vcs-version $(top_distdir)
1251

    
1252
# a distcheck hook rule for catching revision control directories
1253
distcheck-hook:
1254
	if find $(top_distdir) -name .svn -or -name .git | grep .; then \
1255
		echo "Found revision control files in final archive." 1>&2; \
1256
		exit 1; \
1257
	fi
1258
	if find $(top_distdir) -name '*.py[co]' | grep .; then \
1259
		echo "Found Python byte code in final archive." 1>&2; \
1260
		exit 1; \
1261
	fi
1262
	if find $(top_distdir) -name '*~' | grep .; then \
1263
		echo "Found backup files in final archive." 1>&2; \
1264
		exit 1; \
1265
	fi
1266
# Empty files or directories should not be distributed. They can cause
1267
# unnecessary warnings for packagers. Directories used by automake during
1268
# distcheck must be excluded.
1269
	if find $(top_distdir) -empty -and -not \( \
1270
			-path $(top_distdir)/_build -or \
1271
			-path $(top_distdir)/_inst \) | grep .; then \
1272
		echo "Found empty files or directories in final archive." 1>&2; \
1273
		exit 1; \
1274
	fi
1275
	if test -n "$(BUILD_RELEASE)" && \
1276
	   grep -n -H -E '^\*.*unreleased' $(top_distdir)/NEWS; then \
1277
		echo "Found unreleased version in NEWS." >&2; \
1278
		exit 1; \
1279
	fi
1280

    
1281
# When building a release, stricter checks should be used
1282
distcheck-release dist-release: export BUILD_RELEASE = 1
1283
distcheck-release: distcheck
1284

    
1285
dist-release: dist
1286
	set -e; \
1287
	for i in $(DIST_ARCHIVES); do \
1288
		echo -n "Checking $$i ... "; \
1289
		autotools/check-tar < $$i; \
1290
		echo OK; \
1291
	done
1292

    
1293
install-exec-local:
1294
	@mkdir_p@ "$(DESTDIR)${localstatedir}/lib/ganeti" \
1295
	  "$(DESTDIR)${localstatedir}/log/ganeti" \
1296
	  "$(DESTDIR)${localstatedir}/run/ganeti"
1297

    
1298
# To avoid conflicts between directory names and other targets, a file inside
1299
# the directory is used to ensure its existence.
1300
%.dir:
1301
	@mkdir_p@ $* && touch $@
1302

    
1303
.PHONY: apidoc
1304
if WANT_HTOOLSAPIDOC
1305
apidoc: py-apidoc hs-apidoc
1306
else
1307
apidoc: py-apidoc
1308
endif
1309

    
1310
.PHONY: py-apidoc
1311
py-apidoc: epydoc.conf $(RUN_IN_TEMPDIR) $(BUILT_SOURCES)
1312
	$(RUN_IN_TEMPDIR) epydoc -v \
1313
		--conf $(CURDIR)/epydoc.conf \
1314
		--output $(CURDIR)/$(APIDOC_PY_DIR)
1315

    
1316
.PHONY: hs-apidoc
1317
hs-apidoc: $(HS_BUILT_SRCS)
1318
	@test -n "$(HSCOLOUR)" || \
1319
	    { echo 'HsColour' not found during configure; exit 1; }
1320
	@test -n "$(HADDOCK)" || \
1321
	    { echo 'haddock' not found during configure; exit 1; }
1322
	rm -rf $(APIDOC_HS_DIR)/*
1323
	@mkdir_p@ $(APIDOC_HS_DIR)/Ganeti/HTools/Program
1324
	$(HSCOLOUR) -print-css > $(APIDOC_HS_DIR)/Ganeti/hscolour.css
1325
	$(LN_S) ../hscolour.css $(APIDOC_HS_DIR)/Ganeti/HTools/hscolour.css
1326
	set -e ; \
1327
	cd htools; \
1328
	if [ "$(HTOOLS_NOCURL)" ]; \
1329
	then OPTGHC="--optghc=$(HTOOLS_NOCURL)"; \
1330
	else OPTGHC=""; \
1331
	fi; \
1332
	if [ "$(HTOOLS_PARALLEL3)" ]; \
1333
	then OPTGHC="$$OPTGHC --optghc=$(HTOOLS_PARALLEL3)"; \
1334
	fi; \
1335
	RELSRCS="$(HS_LIB_SRCS:htools/%=%)  $(HS_BUILT_SRCS:htools/%=%)"; \
1336
	for file in $$RELSRCS; do \
1337
		hfile=`echo $$file|sed 's/\\.hs$$//'`.html; \
1338
		$(HSCOLOUR) -css -anchor $$file > ../$(APIDOC_HS_DIR)/$$hfile ; \
1339
	done ; \
1340
	$(HADDOCK) --odir ../$(APIDOC_HS_DIR) --html --ignore-all-exports -w \
1341
		-t ganeti-htools -p haddock-prologue \
1342
		--source-module="%{MODULE/.//}.html" \
1343
		--source-entity="%{MODULE/.//}.html#%{NAME}" \
1344
		$$OPTGHC \
1345
		$(filter-out Ganeti/HTools/ExtLoader.hs,$(HS_LIB_SRCS:htools/%=%))
1346

    
1347
.PHONY: TAGS
1348
TAGS: $(BUILT_SOURCES)
1349
	rm -f TAGS
1350
	find . -path './lib/*.py' -o -path './scripts/gnt-*' -o \
1351
	  -path './daemons/ganeti-*' -o -path './tools/*' -o \
1352
	  -path './qa/*.py' | \
1353
	  etags -l python -
1354

    
1355
.PHONY: coverage
1356
if WANT_HTOOLS
1357
coverage: py-coverage hs-coverage
1358
else
1359
coverage: py-coverage
1360
endif
1361

    
1362
.PHONY: py-coverage
1363
py-coverage: $(BUILT_SOURCES) $(python_tests)
1364
	set -e; \
1365
	COVERAGE_FILE=$(CURDIR)/$(COVERAGE_PY_DIR)/data \
1366
	TEXT_COVERAGE=$(CURDIR)/$(COVERAGE_PY_DIR)/report.txt \
1367
	HTML_COVERAGE=$(CURDIR)/$(COVERAGE_PY_DIR) \
1368
	$(PLAIN_TESTS_ENVIRONMENT) $(abs_top_srcdir)/autotools/gen-coverage \
1369
	$(python_tests)
1370

    
1371
.PHONY: hs-coverage
1372
hs-coverage: $(haskell_tests)
1373
	cd htools && rm -f *.tix *.mix && ./test
1374
	@mkdir_p@ $(COVERAGE_HS_DIR)
1375
	hpc markup --destdir=$(COVERAGE_HS_DIR) htools/test $(HPCEXCL)
1376
	hpc report htools/test $(HPCEXCL)
1377
	$(LN_S) -f hpc_index.html $(COVERAGE_HS_DIR)/index.html
1378

    
1379
# Special "kind-of-QA" target for htools, needs special setup (all
1380
# tools compiled with -fhpc)
1381
.PHONY: live-test
1382
live-test: all
1383
	set -e ; \
1384
	cd htools; \
1385
	rm -f .hpc; $(LN_S) ../.hpc .hpc; \
1386
	rm -f *.tix *.mix; \
1387
	./live-test.sh; \
1388
	hpc sum --union $(HPCEXCL) $(addsuffix .tix,$(HS_PROGS:htools/%=%)) \
1389
	  --output=live-test.tix ; \
1390
	@mkdir_p@ ../$(COVERAGE_HS_DIR) ; \
1391
	hpc markup --destdir=../$(COVERAGE_HS_DIR) live-test \
1392
		--srcdir=.. $(HPCEXCL) ; \
1393
	hpc report --srcdir=.. live-test $(HPCEXCL)
1394

    
1395
commit-check: distcheck lint apidoc
1396

    
1397
-include ./Makefile.local
1398

    
1399
# vim: set noet :