Statistics
| Branch: | Tag: | Revision:

root / Makefile.am @ 5ae4945a

History | View | Annotate | Download (43.2 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/Confd \
60
	htools/Ganeti/HTools \
61
	htools/Ganeti/HTools/Program
62

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

    
95
BUILDTIME_DIR_AUTOCREATE = \
96
	scripts \
97
	$(APIDOC_DIR) \
98
	$(APIDOC_PY_DIR) \
99
	$(APIDOC_HS_DIR) \
100
	$(APIDOC_HS_DIR)/Ganeti \
101
	$(APIDOC_HS_DIR)/Ganeti/Confd \
102
	$(APIDOC_HS_DIR)/Ganeti/HTools \
103
	$(APIDOC_HS_DIR)/Ganeti/HTools/Program \
104
	$(COVERAGE_DIR) \
105
	$(COVERAGE_PY_DIR) \
106
	$(COVERAGE_HS_DIR) \
107
	.hpc
108

    
109
BUILDTIME_DIRS = \
110
	$(BUILDTIME_DIR_AUTOCREATE) \
111
	doc/html
112

    
113
DIRCHECK_EXCLUDE = \
114
	$(BUILDTIME_DIRS) \
115
	ganeti-[0-9]*.[0-9]*.[0-9]* \
116
	doc/html/_*
117

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

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

    
134
maintainer-clean-local:
135
	rm -rf $(BUILDTIME_DIRS)
136

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

    
161
GENERATED_FILES = \
162
	$(built_base_sources) \
163
	$(BUILT_PYTHON_SOURCES) \
164
	$(PYTHON_BOOTSTRAP)
165

    
166
built_base_sources = \
167
	stamp-directories \
168
	stamp-srclinks
169

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

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

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

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

    
190
nodist_pkgpython_PYTHON = \
191
	$(BUILT_PYTHON_SOURCES)
192

    
193
noinst_PYTHON = \
194
	lib/build/__init__.py \
195
	lib/build/sphinx_ext.py \
196
	lib/build/shell_example_lexer.py
197

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

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

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

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

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

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

    
274
masterd_PYTHON = \
275
	lib/masterd/__init__.py \
276
	lib/masterd/instance.py
277

    
278
impexpd_PYTHON = \
279
	lib/impexpd/__init__.py
280

    
281
watcher_PYTHON = \
282
	lib/watcher/__init__.py \
283
	lib/watcher/nodemaint.py \
284
	lib/watcher/state.py
285

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

    
293
pytools_PYTHON = \
294
	lib/tools/__init__.py \
295
	lib/tools/ensure_dirs.py
296

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

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

    
354
HS_PROGS = htools/htools
355
HS_BIN_ROLES = hbal hscan hspace hinfo hcheck
356

    
357
HS_ALL_PROGS = $(HS_PROGS) htools/test htools/hpc-htools htools/hconfd
358
HS_PROG_SRCS = $(patsubst %,%.hs,$(HS_ALL_PROGS))
359
HS_BUILT_TEST_HELPERS = $(HS_BIN_ROLES:%=test/%) test/hail
360

    
361
HFLAGS = -O -Wall -Werror -fwarn-monomorphism-restriction -fwarn-tabs -ihtools
362
# extra flags that can be overriden on the command line (e.g. -Wwarn, etc.)
363
HEXTRA =
364
# internal extra flags (used for htools/test mainly)
365
HEXTRA_INT =
366
# exclude options for coverage reports
367
HPCEXCL = --exclude Main \
368
	--exclude Ganeti.Constants \
369
	--exclude Ganeti.THH \
370
	--exclude Ganeti.HTools.QC \
371
	--exclude Ganeti.HTools.QCHelper \
372
	--exclude Ganeti.HTools.Version
373

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

    
418
HS_BUILT_SRCS = htools/Ganeti/HTools/Version.hs htools/Ganeti/Constants.hs
419
HS_BUILT_SRCS_IN = $(patsubst %,%.in,$(HS_BUILT_SRCS))
420

    
421
$(RUN_IN_TEMPDIR): | stamp-directories
422

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

    
443
doc/html: doc/html/index.html
444

    
445
doc/install-quick.rst: INSTALL
446
doc/news.rst: NEWS
447
doc/upgrade.rst: UPGRADE
448

    
449
doc/install-quick.rst doc/news.rst doc/upgrade.rst:
450
	set -e; \
451
	{ echo '.. This file is automatically updated at build time from $<.'; \
452
	  echo '.. Do not edit.'; \
453
	  echo; \
454
	  cat $<; \
455
	} > $@
456

    
457
docdot = \
458
	doc/arch-2.0.dot \
459
	doc/design-2.1-lock-acquire.dot \
460
	doc/design-2.1-lock-release.dot
461

    
462
docpng = $(patsubst %.dot,%.png,$(docdot))
463

    
464
# Things to build but not to install (add it to EXTRA_DIST if it should be
465
# distributed)
466
noinst_DATA = \
467
	devel/upload \
468
	doc/html \
469
	$(BUILT_EXAMPLES) \
470
	doc/examples/bash_completion \
471
	$(manhtml)
472

    
473
gnt_scripts = \
474
	scripts/gnt-backup \
475
	scripts/gnt-cluster \
476
	scripts/gnt-debug \
477
	scripts/gnt-group \
478
	scripts/gnt-instance \
479
	scripts/gnt-job \
480
	scripts/gnt-node \
481
	scripts/gnt-os
482

    
483
PYTHON_BOOTSTRAP_SBIN = \
484
	daemons/ganeti-masterd \
485
	daemons/ganeti-noded \
486
	daemons/ganeti-watcher \
487
	daemons/ganeti-rapi \
488
	$(gnt_scripts)
489

    
490
if PY_CONFD
491
PYTHON_BOOTSTRAP_SBIN += daemons/ganeti-confd
492
endif
493

    
494
PYTHON_BOOTSTRAP = \
495
	$(PYTHON_BOOTSTRAP_SBIN) \
496
	tools/ensure-dirs
497

    
498
qa_scripts = \
499
	qa/__init__.py \
500
	qa/ganeti-qa.py \
501
	qa/qa_cluster.py \
502
	qa/qa_config.py \
503
	qa/qa_daemon.py \
504
	qa/qa_env.py \
505
	qa/qa_error.py \
506
	qa/qa_group.py \
507
	qa/qa_instance.py \
508
	qa/qa_job.py \
509
	qa/qa_node.py \
510
	qa/qa_os.py \
511
	qa/qa_rapi.py \
512
	qa/qa_tags.py \
513
	qa/qa_utils.py
514

    
515
bin_SCRIPTS =
516
if WANT_HTOOLS
517
bin_SCRIPTS += $(filter-out htools/hail,$(HS_PROGS))
518
install-exec-hook:
519
	@mkdir_p@ $(DESTDIR)$(iallocatorsdir)
520
# FIXME: this is a hardcoded logic, instead of auto-resolving
521
	$(LN_S) -f ../../../bin/htools \
522
		   $(DESTDIR)$(iallocatorsdir)/hail
523
	for role in $(HS_BIN_ROLES); do \
524
		$(LN_S) -f htools \
525
			   $(DESTDIR)$(bindir)/$$role ; \
526
	done
527
if HS_CONFD
528
	mv $(DESTDIR)$(sbindir)/hconfd $(DESTDIR)$(sbindir)/ganeti-confd
529
endif
530
endif
531

    
532
$(HS_ALL_PROGS): %: %.hs $(HS_LIB_SRCS) $(HS_BUILT_SRCS) Makefile
533
	@if [ -z "$(HTOOLS)" ]; then \
534
	  echo "Error: htools compilation disabled at configure time" 1>&2 ;\
535
	  exit 1; \
536
	fi
537
	@BINARY=$(@:htools/%=%); \
538
	if [ "$BINARY" = "test" ] && [ -z "$(GHC_PKG_QUICKCHECK)" ]; then \
539
	  echo "Error: cannot run unittests without the QuickCheck library (see devnotes.rst)" 1>&2; \
540
	  exit 1; \
541
	fi
542
	rm -f $(@:htools/%=%).tix
543
	BINARY=$(@:htools/%=%); $(GHC) --make \
544
	  $(HFLAGS) \
545
	  $(HTOOLS_NOCURL) $(HTOOLS_PARALLEL3) \
546
	  -osuf $$BINARY.o -hisuf $$BINARY.hi \
547
	  $(HEXTRA) $(HEXTRA_INT) $@
548
	@touch "$@"
549

    
550
# for the htools/test binary, we need to enable profiling/coverage
551
htools/test: HEXTRA_INT=-fhpc
552

    
553
# we compile the hpc-htools binary with the program coverage
554
htools/hpc-htools: HEXTRA_INT=-fhpc
555

    
556
# test dependency
557
htools/offline-tests.sh: htools/hpc-htools
558

    
559
# rules for building profiling-enabled versions of the haskell
560
# programs: hs-prof does the full two-step build, whereas
561
# hs-prof-quick does only the final rebuild (hs-prof must have been
562
# run before)
563
.PHONY: hs-prof hs-prof-quick
564
hs-prof:
565
	$(MAKE) $(AM_MAKEFLAGS) clean
566
	$(MAKE) $(AM_MAKEFLAGS) $(HS_ALL_PROGS) HEXTRA="-osuf .o"
567
	rm -f $(HS_ALL_PROGS)
568
	$(MAKE) $(AM_MAKEFLAGS) hs-prof-quick
569

    
570
hs-prof-quick:
571
	$(MAKE) $(AM_MAKEFLAGS) $(HS_ALL_PROGS) HEXTRA="-osuf .prof_o -prof -auto-all"
572

    
573
dist_sbin_SCRIPTS = \
574
	tools/ganeti-listrunner
575

    
576
nodist_sbin_SCRIPTS = \
577
	$(PYTHON_BOOTSTRAP_SBIN) \
578
	daemons/ganeti-cleaner
579

    
580
if HS_CONFD
581
nodist_sbin_SCRIPTS += htools/hconfd
582
endif
583

    
584
python_scripts = \
585
	tools/burnin \
586
	tools/cfgshell \
587
	tools/cfgupgrade \
588
	tools/cfgupgrade12 \
589
	tools/cluster-merge \
590
	tools/confd-client \
591
	tools/fmtjson \
592
	tools/lvmstrap \
593
	tools/move-instance \
594
	tools/ovfconverter \
595
	tools/setup-ssh \
596
	tools/sanitize-config
597

    
598
dist_tools_SCRIPTS = \
599
	$(python_scripts) \
600
	tools/kvm-console-wrapper \
601
	tools/xm-console-wrapper \
602
	tools/master-ip-setup
603

    
604
pkglib_python_scripts = \
605
	daemons/import-export \
606
	tools/check-cert-expired
607

    
608
nodist_pkglib_python_scripts = \
609
	tools/ensure-dirs
610

    
611
myexeclib_SCRIPTS = \
612
	daemons/daemon-util \
613
	tools/kvm-ifup \
614
	$(pkglib_python_scripts)
615

    
616
nodist_myexeclib_SCRIPTS = \
617
	$(nodist_pkglib_python_scripts)
618

    
619
EXTRA_DIST = \
620
	NEWS \
621
	UPGRADE \
622
	epydoc.conf.in \
623
	pylintrc \
624
	autotools/build-bash-completion \
625
	autotools/build-rpc \
626
	autotools/check-header \
627
	autotools/check-python-code \
628
	autotools/check-imports \
629
	autotools/check-man-dashes \
630
	autotools/check-man-warnings \
631
	autotools/check-news \
632
	autotools/check-tar \
633
	autotools/check-version \
634
	autotools/convert-constants \
635
	autotools/docpp \
636
	autotools/gen-coverage \
637
	autotools/testrunner \
638
	autotools/wrong-hardcoded-paths \
639
	$(RUN_IN_TEMPDIR) \
640
	daemons/daemon-util.in \
641
	daemons/ganeti-cleaner.in \
642
	$(pkglib_python_scripts) \
643
	devel/upload.in \
644
	tools/kvm-ifup.in \
645
	$(docdot) \
646
	$(docpng) \
647
	$(docrst) \
648
	doc/conf.py \
649
	doc/html \
650
	$(BUILT_EXAMPLES:%=%.in) \
651
	doc/examples/ganeti.default \
652
	doc/examples/ganeti.default-debug \
653
	doc/examples/hooks/ethers \
654
	doc/examples/gnt-debug/README \
655
	doc/examples/gnt-debug/delay0.json \
656
	doc/examples/gnt-debug/delay50.json \
657
	test/lockperf.py \
658
	test/testutils.py \
659
	test/mocks.py \
660
	$(dist_TESTS) \
661
	$(TEST_FILES) \
662
	man/footer.rst \
663
	$(manrst) \
664
	$(maninput) \
665
	qa/qa-sample.json \
666
	$(qa_scripts) \
667
	$(HS_LIB_SRCS) $(HS_BUILT_SRCS_IN) \
668
	$(HS_PROG_SRCS) \
669
	htools/lint-hints.hs \
670
	htools/cli-tests-defs.sh \
671
	htools/offline-test.sh
672

    
673
man_MANS = \
674
	man/ganeti.7 \
675
	man/ganeti-cleaner.8 \
676
	man/ganeti-confd.8 \
677
	man/ganeti-listrunner.8 \
678
	man/ganeti-masterd.8 \
679
	man/ganeti-noded.8 \
680
	man/ganeti-os-interface.7 \
681
	man/ganeti-rapi.8 \
682
	man/ganeti-watcher.8 \
683
	man/gnt-backup.8 \
684
	man/gnt-cluster.8 \
685
	man/gnt-debug.8 \
686
	man/gnt-group.8 \
687
	man/gnt-instance.8 \
688
	man/gnt-job.8 \
689
	man/gnt-node.8 \
690
	man/gnt-os.8 \
691
	man/hail.1 \
692
	man/hbal.1 \
693
	man/hcheck.1 \
694
	man/hinfo.1 \
695
	man/hscan.1 \
696
	man/hspace.1 \
697
	man/htools.1
698

    
699
manrst = $(patsubst %.1,%.rst,$(patsubst %.7,%.rst,$(patsubst %.8,%.rst,$(man_MANS))))
700
manhtml = $(patsubst %.rst,%.html,$(manrst))
701
mangen = $(patsubst %.rst,%.gen,$(manrst))
702
maninput = \
703
	$(patsubst %.1,%.1.in,$(patsubst %.7,%.7.in,$(patsubst %.8,%.8.in,$(man_MANS)))) \
704
	$(patsubst %.html,%.html.in,$(manhtml)) \
705
	man/footer.man man/footer.html $(mangen)
706

    
707
TEST_FILES = \
708
	test/data/bdev-drbd-8.0.txt \
709
	test/data/bdev-drbd-8.3.txt \
710
	test/data/bdev-drbd-disk.txt \
711
	test/data/bdev-drbd-net-ip4.txt \
712
	test/data/bdev-drbd-net-ip6.txt \
713
	test/data/cert1.pem \
714
	test/data/ip-addr-show-dummy0.txt \
715
	test/data/ip-addr-show-lo-ipv4.txt \
716
	test/data/ip-addr-show-lo-ipv6.txt \
717
	test/data/ip-addr-show-lo-oneline-ipv4.txt \
718
	test/data/ip-addr-show-lo-oneline-ipv6.txt \
719
	test/data/ip-addr-show-lo-oneline.txt \
720
	test/data/ip-addr-show-lo.txt \
721
	test/data/proc_drbd8.txt \
722
	test/data/proc_drbd80-emptyline.txt \
723
	test/data/proc_drbd83.txt \
724
	test/data/proc_drbd83_sync.txt \
725
	test/data/proc_drbd83_sync_krnl2.6.39.txt \
726
	test/data/kvm_1.0_help.txt \
727
	test/data/kvm_0.15.90_help.txt \
728
	test/data/kvm_0.12.5_help.txt \
729
	test/data/kvm_0.9.1_help.txt \
730
	test/data/sys_drbd_usermode_helper.txt \
731
	test/data/htools/hail-alloc-drbd.json \
732
	test/data/htools/hail-change-group.json \
733
	test/data/htools/hail-invalid-reloc.json \
734
	test/data/htools/hail-node-evac.json \
735
	test/data/htools/hail-reloc-drbd.json \
736
	test/data/htools/hbal-split-insts.data \
737
	test/data/htools/common-suffix.data \
738
	test/data/htools/invalid-node.data \
739
	test/data/htools/missing-resources.data \
740
	test/data/htools/rapi/groups.json \
741
	test/data/htools/rapi/info.json \
742
	test/data/htools/rapi/instances.json \
743
	test/data/htools/rapi/nodes.json \
744
	test/data/ovfdata/compr_disk.vmdk.gz \
745
	test/data/ovfdata/config.ini \
746
	test/data/ovfdata/corrupted_resources.ovf \
747
	test/data/ovfdata/empty.ini \
748
	test/data/ovfdata/empty.ovf \
749
	test/data/ovfdata/ganeti.mf \
750
	test/data/ovfdata/ganeti.ovf \
751
	test/data/ovfdata/gzip_disk.ovf \
752
	test/data/ovfdata/new_disk.vmdk \
753
	test/data/ovfdata/no_disk.ini \
754
	test/data/ovfdata/no_disk_in_ref.ovf \
755
	test/data/ovfdata/no_os.ini \
756
	test/data/ovfdata/no_ovf.ova \
757
	test/data/ovfdata/ova.ova \
758
	test/data/ovfdata/second_disk.vmdk \
759
	test/data/ovfdata/rawdisk.raw \
760
	test/data/ovfdata/unsafe_path.ini \
761
	test/data/ovfdata/virtualbox.ovf \
762
	test/data/ovfdata/wrong_extension.ovd \
763
	test/data/ovfdata/wrong_config.ini \
764
	test/data/ovfdata/wrong_manifest.mf \
765
	test/data/ovfdata/wrong_manifest.ovf \
766
	test/data/ovfdata/wrong_ova.ova \
767
	test/data/ovfdata/wrong_xml.ovf \
768
	test/data/ovfdata/other/rawdisk.raw \
769
	test/data/vgreduce-removemissing-2.02.02.txt \
770
	test/data/vgreduce-removemissing-2.02.66-fail.txt \
771
	test/data/vgreduce-removemissing-2.02.66-ok.txt \
772
	test/data/vgs-missing-pvs-2.02.02.txt \
773
	test/data/vgs-missing-pvs-2.02.66.txt \
774
	test/import-export_unittest-helper \
775
	test/gnt-cli.test \
776
	test/ganeti-cli.test \
777
	test/htools-balancing.test \
778
	test/htools-basic.test \
779
	test/htools-dynutil.test \
780
	test/htools-excl.test \
781
	test/htools-hail.test \
782
	test/htools-hspace.test \
783
	test/htools-invalid.test \
784
	test/htools-multi-group.test \
785
	test/htools-no-backend.test \
786
	test/htools-rapi.test \
787
	test/htools-single-group.test \
788
	test/htools-text-backend.test
789

    
790
python_tests = \
791
	doc/examples/rapi_testutils.py \
792
	test/ganeti.asyncnotifier_unittest.py \
793
	test/ganeti.backend_unittest.py \
794
	test/ganeti.bdev_unittest.py \
795
	test/ganeti.cli_unittest.py \
796
	test/ganeti.client.gnt_cluster_unittest.py \
797
	test/ganeti.client.gnt_instance_unittest.py \
798
	test/ganeti.daemon_unittest.py \
799
	test/ganeti.cmdlib_unittest.py \
800
	test/ganeti.compat_unittest.py \
801
	test/ganeti.confd.client_unittest.py \
802
	test/ganeti.config_unittest.py \
803
	test/ganeti.constants_unittest.py \
804
	test/ganeti.errors_unittest.py \
805
	test/ganeti.hooks_unittest.py \
806
	test/ganeti.ht_unittest.py \
807
	test/ganeti.http_unittest.py \
808
	test/ganeti.hypervisor_unittest.py \
809
	test/ganeti.hypervisor.hv_chroot_unittest.py \
810
	test/ganeti.hypervisor.hv_fake_unittest.py \
811
	test/ganeti.hypervisor.hv_kvm_unittest.py \
812
	test/ganeti.hypervisor.hv_lxc_unittest.py \
813
	test/ganeti.hypervisor.hv_xen_unittest.py \
814
	test/ganeti.impexpd_unittest.py \
815
	test/ganeti.jqueue_unittest.py \
816
	test/ganeti.jstore_unittest.py \
817
	test/ganeti.locking_unittest.py \
818
	test/ganeti.luxi_unittest.py \
819
	test/ganeti.masterd.instance_unittest.py \
820
	test/ganeti.mcpu_unittest.py \
821
	test/ganeti.netutils_unittest.py \
822
	test/ganeti.objects_unittest.py \
823
	test/ganeti.opcodes_unittest.py \
824
	test/ganeti.ovf_unittest.py \
825
	test/ganeti.qlang_unittest.py \
826
	test/ganeti.query_unittest.py \
827
	test/ganeti.rapi.baserlib_unittest.py \
828
	test/ganeti.rapi.client_unittest.py \
829
	test/ganeti.rapi.resources_unittest.py \
830
	test/ganeti.rapi.rlib2_unittest.py \
831
	test/ganeti.rapi.testutils_unittest.py \
832
	test/ganeti.rpc_unittest.py \
833
	test/ganeti.runtime_unittest.py \
834
	test/ganeti.serializer_unittest.py \
835
	test/ganeti.ssh_unittest.py \
836
	test/ganeti.storage_unittest.py \
837
	test/ganeti.tools.ensure_dirs_unittest.py \
838
	test/ganeti.uidpool_unittest.py \
839
	test/ganeti.utils.algo_unittest.py \
840
	test/ganeti.utils.filelock_unittest.py \
841
	test/ganeti.utils.hash_unittest.py \
842
	test/ganeti.utils.io_unittest.py \
843
	test/ganeti.utils.log_unittest.py \
844
	test/ganeti.utils.mlock_unittest.py \
845
	test/ganeti.utils.nodesetup_unittest.py \
846
	test/ganeti.utils.process_unittest.py \
847
	test/ganeti.utils.retry_unittest.py \
848
	test/ganeti.utils.text_unittest.py \
849
	test/ganeti.utils.wrapper_unittest.py \
850
	test/ganeti.utils.x509_unittest.py \
851
	test/ganeti.utils_unittest.py \
852
	test/ganeti.workerpool_unittest.py \
853
	test/qa.qa_config_unittest.py \
854
	test/cfgupgrade_unittest.py \
855
	test/docs_unittest.py \
856
	test/pycurl_reset_unittest.py \
857
	test/tempfile_fork_unittest.py
858
if HAS_FAKEROOT
859
python_tests += test/ganeti.utils.io_unittest-runasroot.py
860
endif
861

    
862
haskell_tests = htools/test
863

    
864
dist_TESTS = \
865
	test/check-cert-expired_unittest.bash \
866
	test/daemon-util_unittest.bash \
867
	test/ganeti-cleaner_unittest.bash \
868
	test/import-export_unittest.bash \
869
	test/cli-test.bash \
870
	$(python_tests)
871

    
872
nodist_TESTS =
873
check_SCRIPTS =
874

    
875
if WANT_HTOOLSTESTS
876
nodist_TESTS += $(haskell_tests)
877
dist_TESTS += htools/offline-test.sh
878
check_SCRIPTS += htools/hpc-htools $(HS_BUILT_TEST_HELPERS)
879
endif
880

    
881
TESTS = $(dist_TESTS) $(nodist_TESTS)
882

    
883
# Environment for all tests
884
PLAIN_TESTS_ENVIRONMENT = \
885
	PYTHONPATH=. \
886
	TOP_SRCDIR=$(abs_top_srcdir) TOP_BUILDDIR=$(abs_top_builddir) \
887
	PYTHON=$(PYTHON) FAKEROOT=$(FAKEROOT_PATH) \
888
	$(RUN_IN_TEMPDIR)
889

    
890
# Environment for tests run by automake
891
TESTS_ENVIRONMENT = \
892
	$(PLAIN_TESTS_ENVIRONMENT) $(abs_top_srcdir)/autotools/testrunner
893

    
894
all_python_code = \
895
	$(dist_sbin_SCRIPTS) \
896
	$(python_scripts) \
897
	$(pkglib_python_scripts) \
898
	$(nodist_pkglib_python_scripts) \
899
	$(python_tests) \
900
	$(pkgpython_PYTHON) \
901
	$(client_PYTHON) \
902
	$(hypervisor_PYTHON) \
903
	$(rapi_PYTHON) \
904
	$(server_PYTHON) \
905
	$(pytools_PYTHON) \
906
	$(http_PYTHON) \
907
	$(confd_PYTHON) \
908
	$(masterd_PYTHON) \
909
	$(impexpd_PYTHON) \
910
	$(utils_PYTHON) \
911
	$(watcher_PYTHON) \
912
	$(noinst_PYTHON) \
913
	$(qa_scripts)
914

    
915
srclink_files = \
916
	man/footer.rst \
917
	test/check-cert-expired_unittest.bash \
918
	test/daemon-util_unittest.bash \
919
	test/ganeti-cleaner_unittest.bash \
920
	test/import-export_unittest.bash \
921
	test/cli-test.bash \
922
	htools/offline-test.sh \
923
	htools/cli-tests-defs.sh \
924
	$(all_python_code) \
925
	$(HS_LIB_SRCS) $(HS_PROG_SRCS)
926

    
927
check_python_code = \
928
	$(BUILD_BASH_COMPLETION) \
929
	$(CHECK_IMPORTS) \
930
	$(CHECK_HEADER) \
931
	$(DOCPP) \
932
	$(all_python_code)
933

    
934
lint_python_code = \
935
	ganeti \
936
	ganeti/http/server.py \
937
	$(dist_sbin_SCRIPTS) \
938
	$(python_scripts) \
939
	$(pkglib_python_scripts) \
940
	$(BUILD_BASH_COMPLETION) \
941
	$(CHECK_IMPORTS) \
942
	$(CHECK_HEADER) \
943
	$(DOCPP) \
944
	$(PYTHON_BOOTSTRAP)
945

    
946
standalone_python_modules = \
947
	lib/rapi/client.py \
948
	tools/ganeti-listrunner
949

    
950
pep8_python_code = \
951
	ganeti \
952
	ganeti/http/server.py \
953
	$(dist_sbin_SCRIPTS) \
954
	$(python_scripts) \
955
	$(pkglib_python_scripts) \
956
	$(BUILD_BASH_COMPLETION) \
957
	$(CHECK_HEADER) \
958
	$(DOCPP) \
959
	$(PYTHON_BOOTSTRAP) \
960
	qa
961

    
962
test/daemon-util_unittest.bash: daemons/daemon-util
963

    
964
test/ganeti-cleaner_unittest.bash: daemons/ganeti-cleaner
965

    
966
tools/kvm-ifup: tools/kvm-ifup.in $(REPLACE_VARS_SED)
967
	sed -f $(REPLACE_VARS_SED) < $< > $@
968
	chmod +x $@
969

    
970
devel/upload: devel/upload.in $(REPLACE_VARS_SED)
971
	sed -f $(REPLACE_VARS_SED) < $< > $@
972
	chmod u+x $@
973

    
974
daemons/%:: daemons/%.in $(REPLACE_VARS_SED)
975
	sed -f $(REPLACE_VARS_SED) < $< > $@
976
	chmod +x $@
977

    
978
doc/examples/%:: doc/examples/%.in $(REPLACE_VARS_SED)
979
	sed -f $(REPLACE_VARS_SED) < $< > $@
980

    
981
doc/examples/bash_completion: $(BUILD_BASH_COMPLETION) $(RUN_IN_TEMPDIR) \
982
	lib/cli.py $(gnt_scripts) $(client_PYTHON) tools/burnin \
983
	$(GENERATED_FILES)
984
	PYTHONPATH=. $(RUN_IN_TEMPDIR) $(CURDIR)/$(BUILD_BASH_COMPLETION) > $@
985

    
986
doc/%.png: doc/%.dot
987
	@test -n "$(DOT)" || { echo 'dot' not found during configure; exit 1; }
988
	$(DOT) -Tpng -o $@ $<
989

    
990
man/footer.man: man/footer.rst
991
	@test -n "$(PANDOC)" || \
992
	  { echo 'pandoc' not found during configure; exit 1; }
993
	$(PANDOC) -f rst -t man -o $@ $<
994

    
995
man/footer.html: man/footer.rst
996
	@test -n "$(PANDOC)" || \
997
	  { echo 'pandoc' not found during configure; exit 1; }
998
	$(PANDOC) -f rst -t html -o $@ $<
999

    
1000
man/%.gen: man/%.rst lib/query.py lib/build/sphinx_ext.py \
1001
	lib/build/shell_example_lexer.py \
1002
	| $(RUN_IN_TEMPDIR) $(BUILT_PYTHON_SOURCES)
1003
	@echo "Checking $< for hardcoded paths..."
1004
	@if grep -nEf autotools/wrong-hardcoded-paths $<; then \
1005
	  echo "Man page $< has harcoded paths (see above)!" 1>&2 ; \
1006
	  exit 1; \
1007
	fi
1008
	set -e ; \
1009
	trap 'echo auto-removing $@; rm $@' EXIT; \
1010
	PYTHONPATH=. $(RUN_IN_TEMPDIR) $(CURDIR)/$(DOCPP) < $< > $@ ;\
1011
	trap - EXIT
1012

    
1013
man/%.7.in man/%.8.in man/%.1.in: man/%.gen man/footer.man
1014
	@test -n "$(PANDOC)" || \
1015
	  { echo 'pandoc' not found during configure; exit 1; }
1016
	set -o pipefail ; \
1017
	trap 'echo auto-removing $@; rm $@' EXIT; \
1018
	$(PANDOC) -s -f rst -t man -A man/footer.man $< | \
1019
	  sed -e 's/\\@/@/g' > $@; \
1020
	if test -n "$(MAN_HAS_WARNINGS)"; then $(CHECK_MAN_WARNINGS) $@; fi; \
1021
	$(CHECK_MAN_DASHES) $@; \
1022
	trap - EXIT
1023

    
1024

    
1025
man/%.html.in: man/%.gen man/footer.html
1026
	@test -n "$(PANDOC)" || \
1027
	  { echo 'pandoc' not found during configure; exit 1; }
1028
	set -o pipefail ; \
1029
	$(PANDOC) -s -f rst -t html -A man/footer.html $< | \
1030
	  sed -e 's/\\@/@/g' > $@
1031

    
1032
man/%: man/%.in  $(REPLACE_VARS_SED)
1033
	sed -f $(REPLACE_VARS_SED) < $< > $@
1034

    
1035
epydoc.conf: epydoc.conf.in $(REPLACE_VARS_SED)
1036
	sed -f $(REPLACE_VARS_SED) < $< > $@
1037

    
1038
vcs-version:
1039
	if test -d .git; then \
1040
	  git describe > $@; \
1041
	elif test ! -f $@ ; then \
1042
	  echo "Cannot auto-generate $@ file"; exit 1; \
1043
	fi
1044

    
1045
.PHONY: clean-vcs-version
1046
clean-vcs-version:
1047
	rm -f vcs-version
1048

    
1049
.PHONY: regen-vcs-version
1050
regen-vcs-version:
1051
	set -e; \
1052
	cd $(srcdir); \
1053
	if test -d .git; then \
1054
	  $(MAKE) $(AM_MAKEFLAGS) clean-vcs-version; \
1055
	  $(MAKE) $(AM_MAKEFLAGS) vcs-version; \
1056
	fi
1057

    
1058
htools/Ganeti/HTools/Version.hs: htools/Ganeti/HTools/Version.hs.in \
1059
	vcs-version $(built_base_sources)
1060
	set -e; \
1061
	VCSVER=`cat $(abs_top_srcdir)/vcs-version`; \
1062
	sed -e "s/%ver%/$$VCSVER/" < $< > $@
1063

    
1064
htools/Ganeti/Constants.hs: htools/Ganeti/Constants.hs.in \
1065
	lib/constants.py lib/_autoconf.py lib/luxi.py \
1066
	$(CONVERT_CONSTANTS) $(built_base_sources) \
1067
	| lib/_vcsversion.py
1068
	set -e; \
1069
	{ cat $< ; PYTHONPATH=. $(CONVERT_CONSTANTS); } > $@
1070

    
1071
lib/_autoconf.py: Makefile | stamp-directories
1072
	set -e; \
1073
	{ echo '# This file is automatically generated, do not edit!'; \
1074
	  echo '#'; \
1075
	  echo ''; \
1076
	  echo '"""Build-time configuration for Ganeti.'; \
1077
	  echo '';\
1078
	  echo 'This file is autogenerated by the build process.'; \
1079
	  echo 'For any changes you need to re-run ./configure (and'; \
1080
	  echo 'not edit by hand).'; \
1081
	  echo ''; \
1082
	  echo '"""'; \
1083
	  echo ''; \
1084
	  echo '# pylint: disable=C0301,C0324'; \
1085
	  echo '# because this is autogenerated, we do not want'; \
1086
	  echo '# style warnings' ; \
1087
	  echo ''; \
1088
	  echo "PACKAGE_VERSION = '$(PACKAGE_VERSION)'"; \
1089
	  echo "VERSION_MAJOR = '$(VERSION_MAJOR)'"; \
1090
	  echo "VERSION_MINOR = '$(VERSION_MINOR)'"; \
1091
	  echo "VERSION_REVISION = '$(VERSION_REVISION)'"; \
1092
	  echo "VERSION_SUFFIX = '$(VERSION_SUFFIX)'"; \
1093
	  echo "VERSION_FULL = '$(VERSION_FULL)'"; \
1094
	  echo "LOCALSTATEDIR = '$(localstatedir)'"; \
1095
	  echo "SYSCONFDIR = '$(sysconfdir)'"; \
1096
	  echo "SSH_CONFIG_DIR = '$(SSH_CONFIG_DIR)'"; \
1097
	  echo "EXPORT_DIR = '$(EXPORT_DIR)'"; \
1098
	  echo "OS_SEARCH_PATH = [$(OS_SEARCH_PATH)]"; \
1099
	  echo "XEN_BOOTLOADER = '$(XEN_BOOTLOADER)'"; \
1100
	  echo "XEN_KERNEL = '$(XEN_KERNEL)'"; \
1101
	  echo "XEN_INITRD = '$(XEN_INITRD)'"; \
1102
	  echo "KVM_KERNEL = '$(KVM_KERNEL)'"; \
1103
	  echo "FILE_STORAGE_DIR = '$(FILE_STORAGE_DIR)'"; \
1104
	  echo "ENABLE_FILE_STORAGE = $(ENABLE_FILE_STORAGE)"; \
1105
	  echo "SHARED_FILE_STORAGE_DIR = '$(SHARED_FILE_STORAGE_DIR)'"; \
1106
	  echo "ENABLE_SHARED_FILE_STORAGE = $(ENABLE_SHARED_FILE_STORAGE)"; \
1107
	  echo "IALLOCATOR_SEARCH_PATH = [$(IALLOCATOR_SEARCH_PATH)]"; \
1108
	  echo "KVM_PATH = '$(KVM_PATH)'"; \
1109
	  echo "IP_PATH = '$(IP_PATH)'"; \
1110
	  echo "SOCAT_PATH = '$(SOCAT)'"; \
1111
	  echo "SOCAT_USE_ESCAPE = $(SOCAT_USE_ESCAPE)"; \
1112
	  echo "SOCAT_USE_COMPRESS = $(SOCAT_USE_COMPRESS)"; \
1113
	  echo "LVM_STRIPECOUNT = $(LVM_STRIPECOUNT)"; \
1114
	  echo "TOOLSDIR = '$(toolsdir)'"; \
1115
	  echo "GNT_SCRIPTS = [$(foreach i,$(notdir $(gnt_scripts)),'$(i)',)]"; \
1116
	  echo "PKGLIBDIR = '$(pkglibdir)'"; \
1117
	  echo "DRBD_BARRIERS = '$(DRBD_BARRIERS)'"; \
1118
	  echo "DRBD_NO_META_FLUSH = $(DRBD_NO_META_FLUSH)"; \
1119
	  echo "SYSLOG_USAGE = '$(SYSLOG_USAGE)'"; \
1120
	  echo "DAEMONS_GROUP = '$(DAEMONS_GROUP)'"; \
1121
	  echo "ADMIN_GROUP = '$(ADMIN_GROUP)'"; \
1122
	  echo "MASTERD_USER = '$(MASTERD_USER)'"; \
1123
	  echo "MASTERD_GROUP = '$(MASTERD_GROUP)'"; \
1124
	  echo "RAPI_USER = '$(RAPI_USER)'"; \
1125
	  echo "RAPI_GROUP = '$(RAPI_GROUP)'"; \
1126
	  echo "CONFD_USER = '$(CONFD_USER)'"; \
1127
	  echo "CONFD_GROUP = '$(CONFD_GROUP)'"; \
1128
	  echo "NODED_USER = '$(NODED_USER)'"; \
1129
	  echo "NODED_GROUP = '$(NODED_GROUP)'"; \
1130
	  echo "DISK_SEPARATOR = '$(DISK_SEPARATOR)'"; \
1131
	  echo "QEMUIMG_PATH = '$(QEMUIMG_PATH)'"; \
1132
	  if [ "$(HTOOLS)" ]; then \
1133
	    echo "HTOOLS = True"; \
1134
	  else \
1135
	    echo "HTOOLS = False"; \
1136
	  fi; \
1137
	  echo "ENABLE_CONFD = $(ENABLE_CONFD)"; \
1138
	  echo "PY_CONFD = $(PY_CONFD)"; \
1139
	  echo "HS_CONFD = $(HS_CONFD)"; \
1140
	  echo "XEN_CMD = '$(XEN_CMD)'"; \
1141
	} > $@
1142

    
1143
lib/_vcsversion.py: Makefile vcs-version | stamp-directories
1144
	set -e; \
1145
	VCSVER=`cat $(abs_top_srcdir)/vcs-version`; \
1146
	{ echo '# This file is automatically generated, do not edit!'; \
1147
	  echo '#'; \
1148
	  echo ''; \
1149
	  echo '"""Build-time VCS version number for Ganeti.'; \
1150
	  echo '';\
1151
	  echo 'This file is autogenerated by the build process.'; \
1152
	  echo 'For any changes you need to re-run ./configure (and'; \
1153
	  echo 'not edit by hand).'; \
1154
	  echo ''; \
1155
	  echo '"""'; \
1156
	  echo ''; \
1157
	  echo '# pylint: disable=C0301,C0324'; \
1158
	  echo '# because this is autogenerated, we do not want'; \
1159
	  echo '# style warnings' ; \
1160
	  echo ''; \
1161
	  echo "VCS_VERSION = '$$VCSVER'"; \
1162
	} > $@
1163

    
1164
lib/_generated_rpc.py: lib/rpc_defs.py $(BUILD_RPC)
1165
	PYTHONPATH=. $(RUN_IN_TEMPDIR) $(CURDIR)/$(BUILD_RPC) lib/rpc_defs.py > $@
1166

    
1167
$(REPLACE_VARS_SED): Makefile stamp-directories
1168
	set -e; \
1169
	{ echo 's#@PREFIX@#$(prefix)#g'; \
1170
	  echo 's#@SYSCONFDIR@#$(sysconfdir)#g'; \
1171
	  echo 's#@LOCALSTATEDIR@#$(localstatedir)#g'; \
1172
	  echo 's#@BINDIR@#$(bindir)#g'; \
1173
	  echo 's#@SBINDIR@#$(sbindir)#g'; \
1174
	  echo 's#@GANETI_VERSION@#$(PACKAGE_VERSION)#g'; \
1175
	  echo 's#@CUSTOM_XEN_BOOTLOADER@#$(XEN_BOOTLOADER)#g'; \
1176
	  echo 's#@CUSTOM_XEN_KERNEL@#$(XEN_KERNEL)#g'; \
1177
	  echo 's#@CUSTOM_XEN_INITRD@#$(XEN_INITRD)#g'; \
1178
	  echo 's#@CUSTOM_IALLOCATOR_SEARCH_PATH@#$(IALLOCATOR_SEARCH_PATH)#g'; \
1179
	  echo 's#@CUSTOM_EXPORT_DIR@#$(EXPORT_DIR)#g'; \
1180
	  echo 's#@RPL_FILE_STORAGE_DIR@#$(FILE_STORAGE_DIR)#g'; \
1181
	  echo 's#@RPL_SSH_INITD_SCRIPT@#$(SSH_INITD_SCRIPT)#g'; \
1182
	  echo 's#@PKGLIBDIR@#$(pkglibdir)#g'; \
1183
	  echo 's#@GNTMASTERUSER@#$(MASTERD_USER)#g'; \
1184
	  echo 's#@GNTRAPIUSER@#$(RAPI_USER)#g'; \
1185
	  echo 's#@GNTCONFDUSER@#$(CONFD_USER)#g'; \
1186
	  echo 's#@GNTNODEDUSER@#$(NODED_USER)#g'; \
1187
	  echo 's#@GNTRAPIGROUP@#$(RAPI_GROUP)#g'; \
1188
	  echo 's#@GNTADMINGROUP@#$(ADMIN_GROUP)#g'; \
1189
	  echo 's#@GNTCONFDGROUP@#$(CONFD_GROUP)#g'; \
1190
	  echo 's#@GNTMASTERDGROUP@#$(MASTERD_GROUP)#g'; \
1191
	  echo 's#@GNTDAEMONSGROUP@#$(DAEMONS_GROUP)#g'; \
1192
	  echo 's#@CUSTOM_ENABLE_CONFD@#$(ENABLE_CONFD)#g'; \
1193
	  echo 's#@MODULES@#$(strip $(lint_python_code))#g'; \
1194
	} > $@
1195

    
1196
# Using deferred evaluation
1197
daemons/ganeti-%: MODULE = ganeti.server.$(patsubst ganeti-%,%,$(notdir $@))
1198
daemons/ganeti-watcher: MODULE = ganeti.watcher
1199
scripts/%: MODULE = ganeti.client.$(subst -,_,$(notdir $@))
1200
tools/ensure-dirs: MODULE = ganeti.tools.ensure_dirs
1201
$(HS_BUILT_TEST_HELPERS): TESTROLE = $(patsubst test/%,%,$@)
1202

    
1203
$(PYTHON_BOOTSTRAP): Makefile | stamp-directories
1204
	test -n "$(MODULE)" || { echo Missing module; exit 1; }
1205
	set -e; \
1206
	{ echo '#!/usr/bin/python'; \
1207
	  echo '# This file is automatically generated, do not edit!'; \
1208
	  echo "# Edit $(MODULE) instead."; \
1209
	  echo; \
1210
	  echo '"""Bootstrap script for L{$(MODULE)}"""'; \
1211
	  echo; \
1212
	  echo '# pylint: disable=C0103'; \
1213
	  echo '# C0103: Invalid name'; \
1214
	  echo; \
1215
	  echo 'import sys'; \
1216
	  echo 'import $(MODULE) as main'; \
1217
	  echo; \
1218
	  echo '# Temporarily alias commands until bash completion'; \
1219
	  echo '# generator is changed'; \
1220
	  echo 'if hasattr(main, "commands"):'; \
1221
	  echo '  commands = main.commands # pylint: disable=E1101'; \
1222
	  echo 'if hasattr(main, "aliases"):'; \
1223
	  echo '  aliases = main.aliases # pylint: disable=E1101'; \
1224
	  echo; \
1225
	  echo 'if __name__ == "__main__":'; \
1226
	  echo '  sys.exit(main.Main())'; \
1227
	} > $@
1228
	chmod u+x $@
1229

    
1230
$(HS_BUILT_TEST_HELPERS): Makefile
1231
	@test -n "$(TESTROLE)" || { echo Missing TESTROLE; exit 1; }
1232
	set -e; \
1233
	{ echo '#!/bin/sh'; \
1234
	  echo '# This file is automatically generated, do not edit!'; \
1235
	  echo "# Edit Makefile.am instead."; \
1236
	  echo; \
1237
	  echo "HTOOLS=$(TESTROLE) exec ./htools/hpc-htools \"\$$@\""; \
1238
	} > $@
1239
	chmod u+x $@
1240

    
1241
stamp-directories: Makefile
1242
	$(MAKE) $(AM_MAKEFLAGS) ganeti
1243
	@mkdir_p@ $(DIRS) $(BUILDTIME_DIR_AUTOCREATE)
1244
	touch $@
1245

    
1246
# We need to create symlinks because "make distcheck" will not install Python
1247
# files when building.
1248
stamp-srclinks: Makefile | stamp-directories
1249
	set -e; \
1250
	for i in $(srclink_files); do \
1251
		if test ! -f $$i -a -f $(abs_top_srcdir)/$$i; then \
1252
			$(LN_S) $(abs_top_srcdir)/$$i $$i; \
1253
		fi; \
1254
	done
1255
	touch $@
1256

    
1257
.PHONY: ganeti
1258
ganeti:
1259
	cd $(top_builddir) && test -h "$@" || { rm -f $@ && $(LN_S) lib $@; }
1260

    
1261
.PHONY: check-dirs
1262
check-dirs: $(GENERATED_FILES)
1263
	@set -e; \
1264
	find . -type d \( \( -name . \) -o \( \
1265
		-name .git -o \
1266
		-name autom4te.cache \
1267
		\) -prune -o -print \) | { \
1268
		error=; \
1269
		while read dir; do \
1270
			case "$$dir" in \
1271
				$(strip $(patsubst %,(./%) ;;,$(DIRCHECK_EXCLUDE) $(DIRS))) \
1272
				*) error=1; echo "Directory $$dir not listed in Makefile" >&2 ;; \
1273
			esac; \
1274
		done; \
1275
		for dir in $(DIRS); do \
1276
			if ! test -d "$$dir"; then \
1277
				echo "Directory $$dir listed in DIRS does not exist" >&2; \
1278
				error=1; \
1279
			fi \
1280
		done; \
1281
		if test -n "$$error"; then exit 1; else exit 0; fi; \
1282
	}
1283

    
1284
.PHONY: check-local
1285
check-local: check-dirs $(GENERATED_FILES)
1286
	$(CHECK_PYTHON_CODE) $(check_python_code)
1287
	PYTHONPATH=. $(CHECK_HEADER) $(check_python_code)
1288
	$(CHECK_VERSION) $(VERSION) $(top_srcdir)/NEWS
1289
	$(CHECK_NEWS) < $(top_srcdir)/NEWS
1290
	PYTHONPATH=. $(RUN_IN_TEMPDIR) $(CURDIR)/$(CHECK_IMPORTS) . $(standalone_python_modules)
1291
	expver=$(VERSION_MAJOR).$(VERSION_MINOR); \
1292
	if test "`head -n 1 $(top_srcdir)/README`" != "Ganeti $$expver"; then \
1293
		echo "Incorrect version in README, expected $$expver"; \
1294
		exit 1; \
1295
	fi; \
1296
	for file in doc/iallocator.rst doc/hooks.rst; do \
1297
		if test "`sed -ne '4 p' $(top_srcdir)/$$file`" != \
1298
			"Documents Ganeti version $$expver"; then \
1299
			echo "Incorrect version in $$file, expected $$expver"; \
1300
			exit 1; \
1301
		fi; \
1302
	done
1303

    
1304
.PHONY: hs-check
1305
hs-check: htools/test htools/hpc-htools $(HS_BUILT_TEST_HELPERS)
1306
	@rm -f test.tix
1307
	./htools/test
1308
	HBINARY="./htools/hpc-htools" ./htools/offline-test.sh
1309

    
1310
# E111: indentation is not a multiple of four
1311
# E121: continuation line indentation is not a multiple of four
1312
#       (since our indent level is not 4)
1313
# E125: continuation line does not distinguish itself from next logical line
1314
#       (since our indent level is not 4)
1315
# E127: continuation line over-indented for visual indent
1316
#       (since our indent level is not 4)
1317
# note: do NOT add E128 here; it's a valid style error in most cases!
1318
# I've seen real errors, but also some cases were we indent wrongly
1319
# due to line length; try to rework the cases where it is triggered,
1320
# instead of silencing it
1321
# E261: at least two spaces before inline comment
1322
# E501: line too long (80 characters)
1323
PEP8_IGNORE = E111,E121,E125,E127,E261,E501
1324

    
1325
# For excluding pep8 expects filenames only, not whole paths
1326
PEP8_EXCLUDE = $(subst $(space),$(comma),$(strip $(notdir $(BUILT_PYTHON_SOURCES))))
1327

    
1328
LINT_TARGETS = pylint pylint-qa
1329
if HAS_PEP8
1330
LINT_TARGETS += pep8
1331
endif
1332
if HAS_HLINT
1333
LINT_TARGETS += hlint
1334
endif
1335

    
1336
.PHONY: lint
1337
lint: $(LINT_TARGETS)
1338

    
1339
.PHONY: pylint
1340
pylint: $(GENERATED_FILES)
1341
	@test -n "$(PYLINT)" || { echo 'pylint' not found during configure; exit 1; }
1342
	$(PYLINT) $(LINT_OPTS) $(lint_python_code)
1343

    
1344
.PHONY: pylint-qa
1345
pylint-qa: $(GENERATED_FILES)
1346
	@test -n "$(PYLINT)" || { echo 'pylint' not found during configure; exit 1; }
1347
	cd $(top_srcdir)/qa && \
1348
	  PYTHONPATH=$(abs_top_srcdir) $(PYLINT) $(LINT_OPTS) \
1349
	  --rcfile  ../pylintrc $(patsubst qa/%.py,%,$(qa_scripts))
1350

    
1351
.PHONY: pep8
1352
pep8: $(GENERATED_FILES)
1353
	@test -n "$(PEP8)" || { echo 'pep8' not found during configure; exit 1; }
1354
	$(PEP8) --ignore='$(PEP8_IGNORE)' --exclude='$(PEP8_EXCLUDE)' \
1355
		--repeat $(pep8_python_code)
1356

    
1357
.PHONY: hlint
1358
hlint: $(HS_BUILT_SRCS) htools/lint-hints.hs
1359
	@test -n "$(HLINT)" || { echo 'hlint' not found during configure; exit 1; }
1360
	if tty -s; then C="-c"; else C=""; fi; \
1361
	$(HLINT) --report=doc/hs-lint.html --cross $$C \
1362
	  --ignore "Use first" \
1363
	  --ignore "Use comparing" \
1364
	  --ignore "Use on" \
1365
	  --ignore "Reduce duplication" \
1366
	  --hint htools/lint-hints \
1367
	  $(filter-out htools/Ganeti/THH.hs,$(HS_LIB_SRCS))
1368

    
1369
# a dist hook rule for updating the vcs-version file; this is
1370
# hardcoded due to where it needs to build the file...
1371
dist-hook:
1372
	$(MAKE) $(AM_MAKEFLAGS) regen-vcs-version
1373
	rm -f $(top_distdir)/vcs-version
1374
	cp -p $(srcdir)/vcs-version $(top_distdir)
1375

    
1376
# a distcheck hook rule for catching revision control directories
1377
distcheck-hook:
1378
	if find $(top_distdir) -name .svn -or -name .git | grep .; then \
1379
		echo "Found revision control files in final archive." 1>&2; \
1380
		exit 1; \
1381
	fi
1382
	if find $(top_distdir) -name '*.py[co]' | grep .; then \
1383
		echo "Found Python byte code in final archive." 1>&2; \
1384
		exit 1; \
1385
	fi
1386
	if find $(top_distdir) -name '*~' | grep .; then \
1387
		echo "Found backup files in final archive." 1>&2; \
1388
		exit 1; \
1389
	fi
1390
# Empty files or directories should not be distributed. They can cause
1391
# unnecessary warnings for packagers. Directories used by automake during
1392
# distcheck must be excluded.
1393
	if find $(top_distdir) -empty -and -not \( \
1394
			-path $(top_distdir)/_build -or \
1395
			-path $(top_distdir)/_inst \) | grep .; then \
1396
		echo "Found empty files or directories in final archive." 1>&2; \
1397
		exit 1; \
1398
	fi
1399
	if test -n "$(BUILD_RELEASE)" && \
1400
	   grep -n -H -E '^\*.*unreleased' $(top_distdir)/NEWS; then \
1401
		echo "Found unreleased version in NEWS." >&2; \
1402
		exit 1; \
1403
	fi
1404

    
1405
# When building a release, stricter checks should be used
1406
distcheck-release dist-release: export BUILD_RELEASE = 1
1407
distcheck-release: distcheck
1408

    
1409
dist-release: dist
1410
	set -e; \
1411
	for i in $(DIST_ARCHIVES); do \
1412
		echo -n "Checking $$i ... "; \
1413
		autotools/check-tar < $$i; \
1414
		echo OK; \
1415
	done
1416

    
1417
install-exec-local:
1418
	@mkdir_p@ "$(DESTDIR)${localstatedir}/lib/ganeti" \
1419
	  "$(DESTDIR)${localstatedir}/log/ganeti" \
1420
	  "$(DESTDIR)${localstatedir}/run/ganeti"
1421

    
1422
.PHONY: apidoc
1423
if WANT_HTOOLSAPIDOC
1424
apidoc: py-apidoc hs-apidoc
1425
else
1426
apidoc: py-apidoc
1427
endif
1428

    
1429
.PHONY: py-apidoc
1430
py-apidoc: epydoc.conf $(RUN_IN_TEMPDIR) $(GENERATED_FILES)
1431
	$(RUN_IN_TEMPDIR) epydoc -v \
1432
		--conf $(CURDIR)/epydoc.conf \
1433
		--output $(CURDIR)/$(APIDOC_PY_DIR)
1434

    
1435
.PHONY: hs-apidoc
1436
hs-apidoc: $(HS_BUILT_SRCS)
1437
	@test -n "$(HSCOLOUR)" || \
1438
	    { echo 'HsColour' not found during configure; exit 1; }
1439
	@test -n "$(HADDOCK)" || \
1440
	    { echo 'haddock' not found during configure; exit 1; }
1441
	rm -rf $(APIDOC_HS_DIR)/*
1442
	@mkdir_p@ $(APIDOC_HS_DIR)/Ganeti/HTools/Program
1443
	@mkdir_p@ $(APIDOC_HS_DIR)/Ganeti/Confd
1444
	$(HSCOLOUR) -print-css > $(APIDOC_HS_DIR)/Ganeti/hscolour.css
1445
	$(LN_S) ../hscolour.css $(APIDOC_HS_DIR)/Ganeti/HTools/hscolour.css
1446
	$(LN_S) ../hscolour.css $(APIDOC_HS_DIR)/Ganeti/Confd/hscolour.css
1447
	set -e ; \
1448
	cd htools; \
1449
	if [ "$(HTOOLS_NOCURL)" ]; \
1450
	then OPTGHC="--optghc=$(HTOOLS_NOCURL)"; \
1451
	else OPTGHC=""; \
1452
	fi; \
1453
	if [ "$(HTOOLS_PARALLEL3)" ]; \
1454
	then OPTGHC="$$OPTGHC --optghc=$(HTOOLS_PARALLEL3)"; \
1455
	fi; \
1456
	RELSRCS="$(HS_LIB_SRCS:htools/%=%)  $(HS_BUILT_SRCS:htools/%=%)"; \
1457
	for file in $$RELSRCS; do \
1458
		hfile=`echo $$file|sed 's/\\.hs$$//'`.html; \
1459
		$(HSCOLOUR) -css -anchor $$file > ../$(APIDOC_HS_DIR)/$$hfile ; \
1460
	done ; \
1461
	$(HADDOCK) --odir ../$(APIDOC_HS_DIR) --html --ignore-all-exports -w \
1462
		-t ganeti-htools -p haddock-prologue \
1463
		--source-module="%{MODULE/.//}.html" \
1464
		--source-entity="%{MODULE/.//}.html#%{NAME}" \
1465
		$$OPTGHC \
1466
		$(filter-out Ganeti/HTools/ExtLoader.hs,$(HS_LIB_SRCS:htools/%=%))
1467

    
1468
.PHONY: TAGS
1469
TAGS: $(GENERATED_FILES)
1470
	rm -f TAGS
1471
	$(GHC) -e ":etags" -v0 $(HFLAGS) $(HS_LIB_SRCS)
1472
	find . -path './lib/*.py' -o -path './scripts/gnt-*' -o \
1473
	  -path './daemons/ganeti-*' -o -path './tools/*' -o \
1474
	  -path './qa/*.py' | \
1475
	  etags -l python -a -
1476

    
1477
.PHONY: coverage
1478
if WANT_HTOOLS
1479
coverage: py-coverage hs-coverage
1480
else
1481
coverage: py-coverage
1482
endif
1483

    
1484
.PHONY: py-coverage
1485
py-coverage: $(GENERATED_FILES) $(python_tests)
1486
	set -e; \
1487
	COVERAGE_FILE=$(CURDIR)/$(COVERAGE_PY_DIR)/data \
1488
	TEXT_COVERAGE=$(CURDIR)/$(COVERAGE_PY_DIR)/report.txt \
1489
	HTML_COVERAGE=$(CURDIR)/$(COVERAGE_PY_DIR) \
1490
	$(PLAIN_TESTS_ENVIRONMENT) $(abs_top_srcdir)/autotools/gen-coverage \
1491
	$(python_tests)
1492

    
1493
.PHONY: hs-coverage
1494
hs-coverage: $(haskell_tests) htools/hpc-htools
1495
	rm -f *.tix
1496
	$(MAKE) $(AM_MAKEFLAGS) hs-check
1497
	@mkdir_p@ $(COVERAGE_HS_DIR)
1498
	hpc combine --union $(HPCEXCL) \
1499
	  test.tix hpc-htools.tix > coverage-htools.tix
1500
	hpc markup --destdir=$(COVERAGE_HS_DIR) coverage-htools.tix
1501
	hpc report coverage-htools.tix
1502
	$(LN_S) -f hpc_index.html $(COVERAGE_HS_DIR)/index.html
1503

    
1504
# Special "kind-of-QA" target for htools, needs special setup (all
1505
# tools compiled with -fhpc)
1506
.PHONY: live-test
1507
live-test: all
1508
	set -e ; \
1509
	cd htools; \
1510
	rm -f .hpc; $(LN_S) ../.hpc .hpc; \
1511
	rm -f *.tix *.mix; \
1512
	./live-test.sh; \
1513
	hpc sum --union $(HPCEXCL) $(addsuffix .tix,$(HS_PROGS:htools/%=%)) \
1514
	  --output=live-test.tix ; \
1515
	@mkdir_p@ ../$(COVERAGE_HS_DIR) ; \
1516
	hpc markup --destdir=../$(COVERAGE_HS_DIR) live-test \
1517
		--srcdir=.. $(HPCEXCL) ; \
1518
	hpc report --srcdir=.. live-test $(HPCEXCL)
1519

    
1520
commit-check: distcheck lint apidoc
1521

    
1522
.PHONY: gitignore-check
1523
gitignore-check:
1524
	@if [ -n "`git status --short`" ]; then \
1525
	  echo "Git status is not clean!" 1>&2 ; \
1526
	  git status --short; \
1527
	  exit 1; \
1528
	fi
1529

    
1530
# we don't need the ancient implicit rules:
1531
%: %,v
1532
%: RCS/%,v
1533
%: RCS/%
1534
%: s.%
1535
%: SCCS/s.%
1536

    
1537
-include ./Makefile.local
1538

    
1539
# vim: set noet :