Statistics
| Branch: | Tag: | Revision:

root / Makefile.am @ aa3adf35

History | View | Annotate | Download (40.3 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
all_dirfiles = $(addsuffix /.dir,$(DIRS) $(BUILDTIME_DIR_AUTOCREATE))
119

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

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

    
136
maintainer-clean-local:
137
	rm -rf $(BUILDTIME_DIRS)
138

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

    
162
# BUILT_SOURCES should only be used as a dependency on phony targets. Otherwise
163
# it'll cause the target to rebuild every time.
164
BUILT_SOURCES = \
165
  $(built_base_sources) \
166
	$(BUILT_PYTHON_SOURCES) \
167
	$(PYTHON_BOOTSTRAP)
168

    
169
built_base_sources = \
170
	ganeti \
171
	stamp-srclinks \
172
	$(all_dirfiles)
173

    
174
built_python_base_sources = \
175
	lib/_autoconf.py \
176
	lib/_vcsversion.py
177

    
178
BUILT_PYTHON_SOURCES = \
179
	$(built_python_base_sources) \
180
	lib/_generated_rpc.py
181

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

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

    
194
nodist_pkgpython_PYTHON = \
195
	$(BUILT_PYTHON_SOURCES)
196

    
197
noinst_PYTHON = \
198
	lib/build/__init__.py \
199
	lib/build/sphinx_ext.py
200

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

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

    
247
hypervisor_PYTHON = \
248
	lib/hypervisor/__init__.py \
249
	lib/hypervisor/hv_base.py \
250
	lib/hypervisor/hv_chroot.py \
251
	lib/hypervisor/hv_fake.py \
252
	lib/hypervisor/hv_kvm.py \
253
	lib/hypervisor/hv_lxc.py \
254
	lib/hypervisor/hv_xen.py
255

    
256
rapi_PYTHON = \
257
	lib/rapi/__init__.py \
258
	lib/rapi/baserlib.py \
259
	lib/rapi/client.py \
260
	lib/rapi/client_utils.py \
261
	lib/rapi/connector.py \
262
	lib/rapi/rlib2.py \
263
	lib/rapi/testutils.py
264

    
265
http_PYTHON = \
266
	lib/http/__init__.py \
267
	lib/http/auth.py \
268
	lib/http/client.py \
269
	lib/http/server.py
270

    
271
confd_PYTHON = \
272
	lib/confd/__init__.py \
273
	lib/confd/client.py \
274
	lib/confd/querylib.py \
275
	lib/confd/server.py
276

    
277
masterd_PYTHON = \
278
	lib/masterd/__init__.py \
279
	lib/masterd/instance.py
280

    
281
impexpd_PYTHON = \
282
	lib/impexpd/__init__.py
283

    
284
watcher_PYTHON = \
285
	lib/watcher/__init__.py \
286
	lib/watcher/nodemaint.py \
287
	lib/watcher/state.py
288

    
289
server_PYTHON = \
290
	lib/server/__init__.py \
291
	lib/server/confd.py \
292
	lib/server/masterd.py \
293
	lib/server/noded.py \
294
	lib/server/rapi.py
295

    
296
pytools_PYTHON = \
297
	lib/tools/__init__.py \
298
	lib/tools/ensure_dirs.py
299

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

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

    
356
HS_PROGS = htools/htools htools/hconfd
357
HS_BIN_ROLES = hbal hscan hspace hinfo
358

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

    
375
HS_LIB_SRCS = \
376
	htools/Ganeti/HTools/CLI.hs \
377
	htools/Ganeti/HTools/Cluster.hs \
378
	htools/Ganeti/HTools/Compat.hs \
379
	htools/Ganeti/HTools/Container.hs \
380
	htools/Ganeti/HTools/ExtLoader.hs \
381
	htools/Ganeti/HTools/Group.hs \
382
	htools/Ganeti/HTools/IAlloc.hs \
383
	htools/Ganeti/HTools/Instance.hs \
384
	htools/Ganeti/HTools/JSON.hs \
385
	htools/Ganeti/HTools/Loader.hs \
386
	htools/Ganeti/HTools/Luxi.hs \
387
	htools/Ganeti/HTools/Node.hs \
388
	htools/Ganeti/HTools/PeerMap.hs \
389
	htools/Ganeti/HTools/QC.hs \
390
	htools/Ganeti/HTools/QCHelper.hs \
391
	htools/Ganeti/HTools/Rapi.hs \
392
	htools/Ganeti/HTools/Simu.hs \
393
	htools/Ganeti/HTools/Text.hs \
394
	htools/Ganeti/HTools/Types.hs \
395
	htools/Ganeti/HTools/Utils.hs \
396
	htools/Ganeti/HTools/Program.hs \
397
	htools/Ganeti/HTools/Program/Hail.hs \
398
	htools/Ganeti/HTools/Program/Hbal.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

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

    
420
$(RUN_IN_TEMPDIR): | $(all_dirfiles)
421

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

    
441
doc/html: doc/html/index.html
442

    
443
doc/install-quick.rst: INSTALL
444
doc/news.rst: NEWS
445
doc/upgrade.rst: UPGRADE
446

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

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

    
460
docpng = $(patsubst %.dot,%.png,$(docdot))
461

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

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

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

    
489
PYTHON_BOOTSTRAP = \
490
	$(PYTHON_BOOTSTRAP_SBIN) \
491
	tools/ensure-dirs
492

    
493
qa_scripts = \
494
	qa/ganeti-qa.py \
495
	qa/qa_cluster.py \
496
	qa/qa_config.py \
497
	qa/qa_daemon.py \
498
	qa/qa_env.py \
499
	qa/qa_error.py \
500
	qa/qa_group.py \
501
	qa/qa_instance.py \
502
	qa/qa_node.py \
503
	qa/qa_os.py \
504
	qa/qa_rapi.py \
505
	qa/qa_tags.py \
506
	qa/qa_utils.py
507

    
508
bin_SCRIPTS =
509
if WANT_HTOOLS
510
bin_SCRIPTS += $(filter-out htools/hail,$(HS_PROGS))
511
install-exec-hook:
512
	@mkdir_p@ $(DESTDIR)$(iallocatorsdir)
513
# FIXME: this is a hardcoded logic, instead of auto-resolving
514
	$(LN_S) -f ../../../bin/htools \
515
		   $(DESTDIR)$(iallocatorsdir)/hail
516
	for role in $(HS_BIN_ROLES); do \
517
		$(LN_S) -f htools \
518
			   $(DESTDIR)$(bindir)/$$role ; \
519
	done
520
endif
521

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

    
539
# for the htools/test binary, we need to enable profiling/coverage
540
htools/test: HEXTRA_INT=-fhpc -Wwarn -fno-warn-missing-signatures \
541
	-fno-warn-monomorphism-restriction -fno-warn-orphans \
542
	-fno-warn-missing-methods -fno-warn-unused-imports
543

    
544
# we compile the hpc-htools binary with the program coverage
545
htools/hpc-htools: HEXTRA_INT=-fhpc
546

    
547
# test dependency
548
htools/offline-tests.sh: htools/hpc-htools
549

    
550
# rules for building profiling-enabled versions of the haskell
551
# programs: hs-prof does the full two-step build, whereas
552
# hs-prof-quick does only the final rebuild (hs-prof must have been
553
# run before)
554
.PHONY: hs-prof hs-prof-quick
555
hs-prof:
556
	$(MAKE) clean
557
	$(MAKE) $(HS_ALL_PROGS) HEXTRA="-osuf .o"
558
	rm -f $(HS_ALL_PROGS)
559
	$(MAKE) hs-prof-quick
560

    
561
hs-prof-quick:
562
	$(MAKE) $(HS_ALL_PROGS) HEXTRA="-osuf .prof_o -prof -auto-all"
563

    
564
dist_sbin_SCRIPTS = \
565
	tools/ganeti-listrunner
566

    
567
nodist_sbin_SCRIPTS = \
568
	$(PYTHON_BOOTSTRAP_SBIN) \
569
	daemons/ganeti-cleaner
570

    
571
python_scripts = \
572
	tools/burnin \
573
	tools/cfgshell \
574
	tools/cfgupgrade \
575
	tools/cfgupgrade12 \
576
	tools/cluster-merge \
577
	tools/confd-client \
578
	tools/fmtjson \
579
	tools/lvmstrap \
580
	tools/move-instance \
581
	tools/ovfconverter \
582
	tools/setup-ssh \
583
	tools/sanitize-config
584

    
585
dist_tools_SCRIPTS = \
586
	$(python_scripts) \
587
	tools/kvm-console-wrapper \
588
	tools/xm-console-wrapper \
589
	tools/master-ip-setup
590

    
591
pkglib_python_scripts = \
592
	daemons/import-export \
593
	tools/check-cert-expired
594

    
595
nodist_pkglib_python_scripts = \
596
	tools/ensure-dirs
597

    
598
myexeclib_SCRIPTS = \
599
	daemons/daemon-util \
600
	tools/kvm-ifup \
601
	$(pkglib_python_scripts)
602

    
603
nodist_myexeclib_SCRIPTS = \
604
	$(nodist_pkglib_python_scripts)
605

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

    
659
man_MANS = \
660
	man/ganeti.7 \
661
	man/ganeti-cleaner.8 \
662
	man/ganeti-confd.8 \
663
	man/ganeti-listrunner.8 \
664
	man/ganeti-masterd.8 \
665
	man/ganeti-noded.8 \
666
	man/ganeti-os-interface.7 \
667
	man/ganeti-rapi.8 \
668
	man/ganeti-watcher.8 \
669
	man/gnt-backup.8 \
670
	man/gnt-cluster.8 \
671
	man/gnt-debug.8 \
672
	man/gnt-group.8 \
673
	man/gnt-instance.8 \
674
	man/gnt-job.8 \
675
	man/gnt-node.8 \
676
	man/gnt-os.8 \
677
	man/hail.1 \
678
	man/hbal.1 \
679
	man/hinfo.1 \
680
	man/hscan.1 \
681
	man/hspace.1 \
682
	man/htools.1
683

    
684
manrst = $(patsubst %.1,%.rst,$(patsubst %.7,%.rst,$(patsubst %.8,%.rst,$(man_MANS))))
685
manhtml = $(patsubst %.rst,%.html,$(manrst))
686
mangen = $(patsubst %.rst,%.gen,$(manrst))
687
maninput = \
688
	$(patsubst %.1,%.1.in,$(patsubst %.7,%.7.in,$(patsubst %.8,%.8.in,$(man_MANS)))) \
689
	$(patsubst %.html,%.html.in,$(manhtml)) \
690
	man/footer.man man/footer.html $(mangen)
691

    
692
TEST_FILES = \
693
	test/data/bdev-drbd-8.0.txt \
694
	test/data/bdev-drbd-8.3.txt \
695
	test/data/bdev-drbd-disk.txt \
696
	test/data/bdev-drbd-net-ip4.txt \
697
	test/data/bdev-drbd-net-ip6.txt \
698
	test/data/cert1.pem \
699
	test/data/ip-addr-show-dummy0.txt \
700
	test/data/ip-addr-show-lo-ipv4.txt \
701
	test/data/ip-addr-show-lo-ipv6.txt \
702
	test/data/ip-addr-show-lo-oneline-ipv4.txt \
703
	test/data/ip-addr-show-lo-oneline-ipv6.txt \
704
	test/data/ip-addr-show-lo-oneline.txt \
705
	test/data/ip-addr-show-lo.txt \
706
	test/data/proc_drbd8.txt \
707
	test/data/proc_drbd80-emptyline.txt \
708
	test/data/proc_drbd83.txt \
709
	test/data/proc_drbd83_sync.txt \
710
	test/data/proc_drbd83_sync_krnl2.6.39.txt \
711
	test/data/kvm_1.0_help.txt \
712
	test/data/kvm_0.15.90_help.txt \
713
	test/data/kvm_0.12.5_help.txt \
714
	test/data/kvm_0.9.1_help.txt \
715
	test/data/sys_drbd_usermode_helper.txt \
716
	test/data/htools/hail-alloc-drbd.json \
717
	test/data/htools/hail-change-group.json \
718
	test/data/htools/hail-node-evac.json \
719
	test/data/htools/hail-reloc-drbd.json \
720
	test/data/htools/common-suffix.data \
721
	test/data/htools/invalid-node.data \
722
	test/data/htools/missing-resources.data \
723
	test/data/htools/rapi/groups.json \
724
	test/data/htools/rapi/info.json \
725
	test/data/htools/rapi/instances.json \
726
	test/data/htools/rapi/nodes.json \
727
	test/data/ovfdata/compr_disk.vmdk.gz \
728
	test/data/ovfdata/config.ini \
729
	test/data/ovfdata/corrupted_resources.ovf \
730
	test/data/ovfdata/empty.ini \
731
	test/data/ovfdata/empty.ovf \
732
	test/data/ovfdata/ganeti.mf \
733
	test/data/ovfdata/ganeti.ovf \
734
	test/data/ovfdata/gzip_disk.ovf \
735
	test/data/ovfdata/new_disk.vmdk \
736
	test/data/ovfdata/no_disk.ini \
737
	test/data/ovfdata/no_disk_in_ref.ovf \
738
	test/data/ovfdata/no_os.ini \
739
	test/data/ovfdata/no_ovf.ova \
740
	test/data/ovfdata/ova.ova \
741
	test/data/ovfdata/second_disk.vmdk \
742
	test/data/ovfdata/rawdisk.raw \
743
	test/data/ovfdata/unsafe_path.ini \
744
	test/data/ovfdata/virtualbox.ovf \
745
	test/data/ovfdata/wrong_extension.ovd \
746
	test/data/ovfdata/wrong_config.ini \
747
	test/data/ovfdata/wrong_manifest.mf \
748
	test/data/ovfdata/wrong_manifest.ovf \
749
	test/data/ovfdata/wrong_ova.ova \
750
	test/data/ovfdata/wrong_xml.ovf \
751
	test/data/ovfdata/other/rawdisk.raw \
752
	test/data/vgreduce-removemissing-2.02.02.txt \
753
	test/data/vgreduce-removemissing-2.02.66-fail.txt \
754
	test/data/vgreduce-removemissing-2.02.66-ok.txt \
755
	test/data/vgs-missing-pvs-2.02.02.txt \
756
	test/data/vgs-missing-pvs-2.02.66.txt \
757
	test/import-export_unittest-helper
758

    
759
python_tests = \
760
	test/ganeti.asyncnotifier_unittest.py \
761
	test/ganeti.backend_unittest.py \
762
	test/ganeti.bdev_unittest.py \
763
	test/ganeti.cli_unittest.py \
764
	test/ganeti.client.gnt_cluster_unittest.py \
765
	test/ganeti.client.gnt_instance_unittest.py \
766
	test/ganeti.daemon_unittest.py \
767
	test/ganeti.cmdlib_unittest.py \
768
	test/ganeti.compat_unittest.py \
769
	test/ganeti.confd.client_unittest.py \
770
	test/ganeti.config_unittest.py \
771
	test/ganeti.constants_unittest.py \
772
	test/ganeti.errors_unittest.py \
773
	test/ganeti.hooks_unittest.py \
774
	test/ganeti.ht_unittest.py \
775
	test/ganeti.http_unittest.py \
776
	test/ganeti.hypervisor_unittest.py \
777
	test/ganeti.hypervisor.hv_chroot_unittest.py \
778
	test/ganeti.hypervisor.hv_fake_unittest.py \
779
	test/ganeti.hypervisor.hv_kvm_unittest.py \
780
	test/ganeti.hypervisor.hv_lxc_unittest.py \
781
	test/ganeti.hypervisor.hv_xen_unittest.py \
782
	test/ganeti.impexpd_unittest.py \
783
	test/ganeti.jqueue_unittest.py \
784
	test/ganeti.locking_unittest.py \
785
	test/ganeti.luxi_unittest.py \
786
	test/ganeti.masterd.instance_unittest.py \
787
	test/ganeti.mcpu_unittest.py \
788
	test/ganeti.netutils_unittest.py \
789
	test/ganeti.objects_unittest.py \
790
	test/ganeti.opcodes_unittest.py \
791
	test/ganeti.ovf_unittest.py \
792
	test/ganeti.qlang_unittest.py \
793
	test/ganeti.query_unittest.py \
794
	test/ganeti.rapi.baserlib_unittest.py \
795
	test/ganeti.rapi.client_unittest.py \
796
	test/ganeti.rapi.resources_unittest.py \
797
	test/ganeti.rapi.rlib2_unittest.py \
798
	test/ganeti.rapi.testutils_unittest.py \
799
	test/ganeti.rpc_unittest.py \
800
	test/ganeti.runtime_unittest.py \
801
	test/ganeti.serializer_unittest.py \
802
	test/ganeti.ssh_unittest.py \
803
	test/ganeti.storage_unittest.py \
804
	test/ganeti.tools.ensure_dirs_unittest.py \
805
	test/ganeti.uidpool_unittest.py \
806
	test/ganeti.utils.algo_unittest.py \
807
	test/ganeti.utils.filelock_unittest.py \
808
	test/ganeti.utils.hash_unittest.py \
809
	test/ganeti.utils.io_unittest.py \
810
	test/ganeti.utils.log_unittest.py \
811
	test/ganeti.utils.mlock_unittest.py \
812
	test/ganeti.utils.nodesetup_unittest.py \
813
	test/ganeti.utils.process_unittest.py \
814
	test/ganeti.utils.retry_unittest.py \
815
	test/ganeti.utils.text_unittest.py \
816
	test/ganeti.utils.wrapper_unittest.py \
817
	test/ganeti.utils.x509_unittest.py \
818
	test/ganeti.utils_unittest.py \
819
	test/ganeti.workerpool_unittest.py \
820
	test/cfgupgrade_unittest.py \
821
	test/docs_unittest.py \
822
	test/pycurl_reset_unittest.py \
823
	test/tempfile_fork_unittest.py
824
if HAS_FAKEROOT
825
python_tests += test/ganeti.utils.io_unittest-runasroot.py
826
endif
827

    
828
haskell_tests = htools/test
829

    
830
dist_TESTS = \
831
	test/check-cert-expired_unittest.bash \
832
	test/daemon-util_unittest.bash \
833
	test/ganeti-cleaner_unittest.bash \
834
	test/import-export_unittest.bash \
835
	$(python_tests)
836

    
837
nodist_TESTS =
838
check_SCRIPTS =
839

    
840
if WANT_HTOOLSTESTS
841
nodist_TESTS += $(haskell_tests)
842
dist_TESTS += htools/offline-test.sh
843
check_SCRIPTS += htools/hpc-htools
844
endif
845

    
846
TESTS = $(dist_TESTS) $(nodist_TESTS)
847

    
848
# Environment for all tests
849
PLAIN_TESTS_ENVIRONMENT = \
850
	PYTHONPATH=. TOP_SRCDIR=$(abs_top_srcdir) PYTHON=$(PYTHON) \
851
	FAKEROOT=$(FAKEROOT_PATH) $(RUN_IN_TEMPDIR)
852

    
853
# Environment for tests run by automake
854
TESTS_ENVIRONMENT = \
855
	$(PLAIN_TESTS_ENVIRONMENT) $(abs_top_srcdir)/autotools/testrunner
856

    
857
all_python_code = \
858
	$(dist_sbin_SCRIPTS) \
859
	$(python_scripts) \
860
	$(pkglib_python_scripts) \
861
	$(nodist_pkglib_python_scripts) \
862
	$(python_tests) \
863
	$(pkgpython_PYTHON) \
864
	$(client_PYTHON) \
865
	$(hypervisor_PYTHON) \
866
	$(rapi_PYTHON) \
867
	$(server_PYTHON) \
868
	$(pytools_PYTHON) \
869
	$(http_PYTHON) \
870
	$(confd_PYTHON) \
871
	$(masterd_PYTHON) \
872
	$(impexpd_PYTHON) \
873
	$(utils_PYTHON) \
874
	$(watcher_PYTHON) \
875
	$(noinst_PYTHON) \
876
	$(qa_scripts)
877

    
878
srclink_files = \
879
	man/footer.rst \
880
	test/check-cert-expired_unittest.bash \
881
	test/daemon-util_unittest.bash \
882
	test/ganeti-cleaner_unittest.bash \
883
	test/import-export_unittest.bash \
884
	htools/offline-test.sh \
885
	htools/cli-tests-defs.sh \
886
	$(all_python_code) \
887
	$(HS_LIB_SRCS) $(HS_PROG_SRCS)
888

    
889
check_python_code = \
890
	$(BUILD_BASH_COMPLETION) \
891
	$(CHECK_IMPORTS) \
892
	$(CHECK_HEADER) \
893
	$(DOCPP) \
894
	$(all_python_code)
895

    
896
lint_python_code = \
897
	ganeti \
898
	ganeti/http/server.py \
899
	$(dist_sbin_SCRIPTS) \
900
	$(python_scripts) \
901
	$(pkglib_python_scripts) \
902
	$(BUILD_BASH_COMPLETION) \
903
	$(CHECK_IMPORTS) \
904
	$(CHECK_HEADER) \
905
	$(DOCPP) \
906
	$(PYTHON_BOOTSTRAP)
907

    
908
standalone_python_modules = \
909
	lib/rapi/client.py \
910
	tools/ganeti-listrunner
911

    
912
pep8_python_code = \
913
	ganeti \
914
	ganeti/http/server.py \
915
	$(dist_sbin_SCRIPTS) \
916
	$(python_scripts) \
917
	$(pkglib_python_scripts) \
918
	$(BUILD_BASH_COMPLETION) \
919
	$(CHECK_HEADER) \
920
	$(DOCPP) \
921
	$(PYTHON_BOOTSTRAP) \
922
	qa
923

    
924
test/daemon-util_unittest.bash: daemons/daemon-util
925

    
926
test/ganeti-cleaner_unittest.bash: daemons/ganeti-cleaner
927

    
928
tools/kvm-ifup: tools/kvm-ifup.in $(REPLACE_VARS_SED)
929
	sed -f $(REPLACE_VARS_SED) < $< > $@
930
	chmod +x $@
931

    
932
devel/upload: devel/upload.in $(REPLACE_VARS_SED)
933
	sed -f $(REPLACE_VARS_SED) < $< > $@
934
	chmod u+x $@
935

    
936
daemons/%: daemons/%.in $(REPLACE_VARS_SED)
937
	sed -f $(REPLACE_VARS_SED) < $< > $@
938
	chmod +x $@
939

    
940
doc/examples/%: doc/examples/%.in $(REPLACE_VARS_SED)
941
	sed -f $(REPLACE_VARS_SED) < $< > $@
942

    
943
doc/examples/hooks/%: doc/examples/hooks/%.in $(REPLACE_VARS_SED)
944
	sed -f $(REPLACE_VARS_SED) < $< > $@
945

    
946
doc/examples/bash_completion: $(BUILD_BASH_COMPLETION) $(RUN_IN_TEMPDIR) \
947
	lib/cli.py $(gnt_scripts) $(client_PYTHON) tools/burnin
948
	PYTHONPATH=. $(RUN_IN_TEMPDIR) $(CURDIR)/$(BUILD_BASH_COMPLETION) > $@
949

    
950
doc/%.png: doc/%.dot
951
	@test -n "$(DOT)" || { echo 'dot' not found during configure; exit 1; }
952
	$(DOT) -Tpng -o $@ $<
953

    
954
man/footer.man: man/footer.rst
955
	@test -n "$(PANDOC)" || \
956
	  { echo 'pandoc' not found during configure; exit 1; }
957
	$(PANDOC) -f rst -t man -o $@ $<
958

    
959
man/footer.html: man/footer.rst
960
	@test -n "$(PANDOC)" || \
961
	  { echo 'pandoc' not found during configure; exit 1; }
962
	$(PANDOC) -f rst -t html -o $@ $<
963

    
964
man/%.gen: man/%.rst lib/query.py lib/build/sphinx_ext.py
965
	PYTHONPATH=. $(RUN_IN_TEMPDIR) $(CURDIR)/$(DOCPP) < $< > $@
966

    
967
man/%.7.in man/%.8.in man/%.1.in: man/%.gen man/footer.man
968
	@test -n "$(PANDOC)" || \
969
	  { echo 'pandoc' not found during configure; exit 1; }
970
	set -o pipefail ; \
971
	trap 'echo auto-removing $@; rm $@' EXIT; \
972
	$(PANDOC) -s -f rst -t man -A man/footer.man $< | \
973
	  sed -e 's/\\@/@/g' > $@; \
974
	if test -n "$(MAN_HAS_WARNINGS)"; then $(CHECK_MAN_WARNINGS) $@; fi; \
975
	$(CHECK_MAN_DASHES) $@; \
976
	trap - EXIT
977

    
978

    
979
man/%.html.in: man/%.gen man/footer.html
980
	@test -n "$(PANDOC)" || \
981
	  { echo 'pandoc' not found during configure; exit 1; }
982
	set -o pipefail ; \
983
	$(PANDOC) -s -f rst -t html -A man/footer.html $< | \
984
	  sed -e 's/\\@/@/g' > $@
985

    
986
man/%.1: man/%.1.in $(REPLACE_VARS_SED)
987
	sed -f $(REPLACE_VARS_SED) < $< > $@
988

    
989
man/%.7: man/%.7.in $(REPLACE_VARS_SED)
990
	sed -f $(REPLACE_VARS_SED) < $< > $@
991

    
992
man/%.8: man/%.8.in $(REPLACE_VARS_SED)
993
	sed -f $(REPLACE_VARS_SED) < $< > $@
994

    
995
man/%.html: man/%.html.in $(REPLACE_VARS_SED)
996
	sed -f $(REPLACE_VARS_SED) < $< > $@
997

    
998
epydoc.conf: epydoc.conf.in Makefile
999
	sed -e 's#@MODULES@#$(strip $(lint_python_code))#g' < $< > $@
1000

    
1001
vcs-version:
1002
	if test -d .git; then \
1003
	  git describe > $@; \
1004
	elif test ! -f $@ ; then \
1005
	  echo "Cannot auto-generate $@ file"; exit 1; \
1006
	fi
1007

    
1008
.PHONY: regen-vcs-version
1009
regen-vcs-version:
1010
	set -e; \
1011
	cd $(srcdir); \
1012
	if test -d .git; then \
1013
	  rm -f vcs-version; \
1014
	  $(MAKE) vcs-version; \
1015
	fi
1016

    
1017
htools/Ganeti/HTools/Version.hs: htools/Ganeti/HTools/Version.hs.in vcs-version
1018
	set -e; \
1019
	VCSVER=`cat $(abs_top_srcdir)/vcs-version`; \
1020
	sed -e "s/%ver%/$$VCSVER/" < $< > $@
1021

    
1022
htools/Ganeti/Constants.hs: htools/Ganeti/Constants.hs.in \
1023
	lib/constants.py lib/_autoconf.py $(CONVERT_CONSTANTS) \
1024
	| lib/_vcsversion.py
1025
	set -e; \
1026
	{ cat $< ; PYTHONPATH=. $(CONVERT_CONSTANTS); } > $@
1027

    
1028
lib/_autoconf.py: Makefile | lib/.dir
1029
	set -e; \
1030
	{ echo '# This file is automatically generated, do not edit!'; \
1031
	  echo '#'; \
1032
	  echo ''; \
1033
	  echo '"""Build-time configuration for Ganeti.'; \
1034
	  echo '';\
1035
	  echo 'This file is autogenerated by the build process.'; \
1036
	  echo 'For any changes you need to re-run ./configure (and'; \
1037
	  echo 'not edit by hand).'; \
1038
	  echo ''; \
1039
	  echo '"""'; \
1040
	  echo ''; \
1041
	  echo '# pylint: disable=C0301,C0324'; \
1042
	  echo '# because this is autogenerated, we do not want'; \
1043
	  echo '# style warnings' ; \
1044
	  echo ''; \
1045
	  echo "PACKAGE_VERSION = '$(PACKAGE_VERSION)'"; \
1046
	  echo "VERSION_MAJOR = '$(VERSION_MAJOR)'"; \
1047
	  echo "VERSION_MINOR = '$(VERSION_MINOR)'"; \
1048
	  echo "VERSION_REVISION = '$(VERSION_REVISION)'"; \
1049
	  echo "VERSION_SUFFIX = '$(VERSION_SUFFIX)'"; \
1050
	  echo "VERSION_FULL = '$(VERSION_FULL)'"; \
1051
	  echo "LOCALSTATEDIR = '$(localstatedir)'"; \
1052
	  echo "SYSCONFDIR = '$(sysconfdir)'"; \
1053
	  echo "SSH_CONFIG_DIR = '$(SSH_CONFIG_DIR)'"; \
1054
	  echo "EXPORT_DIR = '$(EXPORT_DIR)'"; \
1055
	  echo "OS_SEARCH_PATH = [$(OS_SEARCH_PATH)]"; \
1056
	  echo "XEN_BOOTLOADER = '$(XEN_BOOTLOADER)'"; \
1057
	  echo "XEN_KERNEL = '$(XEN_KERNEL)'"; \
1058
	  echo "XEN_INITRD = '$(XEN_INITRD)'"; \
1059
	  echo "FILE_STORAGE_DIR = '$(FILE_STORAGE_DIR)'"; \
1060
	  echo "ENABLE_FILE_STORAGE = $(ENABLE_FILE_STORAGE)"; \
1061
	  echo "SHARED_FILE_STORAGE_DIR = '$(SHARED_FILE_STORAGE_DIR)'"; \
1062
	  echo "ENABLE_SHARED_FILE_STORAGE = $(ENABLE_SHARED_FILE_STORAGE)"; \
1063
	  echo "IALLOCATOR_SEARCH_PATH = [$(IALLOCATOR_SEARCH_PATH)]"; \
1064
	  echo "KVM_PATH = '$(KVM_PATH)'"; \
1065
	  echo "IP_PATH = '$(IP_PATH)'"; \
1066
	  echo "SOCAT_PATH = '$(SOCAT)'"; \
1067
	  echo "SOCAT_USE_ESCAPE = $(SOCAT_USE_ESCAPE)"; \
1068
	  echo "SOCAT_USE_COMPRESS = $(SOCAT_USE_COMPRESS)"; \
1069
	  echo "LVM_STRIPECOUNT = $(LVM_STRIPECOUNT)"; \
1070
	  echo "TOOLSDIR = '$(toolsdir)'"; \
1071
	  echo "GNT_SCRIPTS = [$(foreach i,$(notdir $(gnt_scripts)),'$(i)',)]"; \
1072
	  echo "PKGLIBDIR = '$(pkglibdir)'"; \
1073
	  echo "DRBD_BARRIERS = '$(DRBD_BARRIERS)'"; \
1074
	  echo "DRBD_NO_META_FLUSH = $(DRBD_NO_META_FLUSH)"; \
1075
	  echo "SYSLOG_USAGE = '$(SYSLOG_USAGE)'"; \
1076
	  echo "DAEMONS_GROUP = '$(DAEMONS_GROUP)'"; \
1077
	  echo "ADMIN_GROUP = '$(ADMIN_GROUP)'"; \
1078
	  echo "MASTERD_USER = '$(MASTERD_USER)'"; \
1079
	  echo "MASTERD_GROUP = '$(MASTERD_GROUP)'"; \
1080
	  echo "RAPI_USER = '$(RAPI_USER)'"; \
1081
	  echo "RAPI_GROUP = '$(RAPI_GROUP)'"; \
1082
	  echo "CONFD_USER = '$(CONFD_USER)'"; \
1083
	  echo "CONFD_GROUP = '$(CONFD_GROUP)'"; \
1084
	  echo "NODED_USER = '$(NODED_USER)'"; \
1085
	  echo "NODED_GROUP = '$(NODED_GROUP)'"; \
1086
	  echo "DISK_SEPARATOR = '$(DISK_SEPARATOR)'"; \
1087
	  echo "QEMUIMG_PATH = '$(QEMUIMG_PATH)'"; \
1088
	  if [ "$(HTOOLS)" ]; then \
1089
	    echo "HTOOLS = True"; \
1090
	  else \
1091
	    echo "HTOOLS = False"; \
1092
	  fi; \
1093
	  echo "ENABLE_CONFD = $(ENABLE_CONFD)"; \
1094
	} > $@
1095

    
1096
lib/_vcsversion.py: Makefile vcs-version | lib/.dir
1097
	set -e; \
1098
	VCSVER=`cat $(abs_top_srcdir)/vcs-version`; \
1099
	{ echo '# This file is automatically generated, do not edit!'; \
1100
	  echo '#'; \
1101
	  echo ''; \
1102
	  echo '"""Build-time VCS version number for Ganeti.'; \
1103
	  echo '';\
1104
	  echo 'This file is autogenerated by the build process.'; \
1105
	  echo 'For any changes you need to re-run ./configure (and'; \
1106
	  echo 'not edit by hand).'; \
1107
	  echo ''; \
1108
	  echo '"""'; \
1109
	  echo ''; \
1110
	  echo '# pylint: disable=C0301,C0324'; \
1111
	  echo '# because this is autogenerated, we do not want'; \
1112
	  echo '# style warnings' ; \
1113
	  echo ''; \
1114
	  echo "VCS_VERSION = '$$VCSVER'"; \
1115
	} > $@
1116

    
1117
lib/_generated_rpc.py: lib/rpc_defs.py $(BUILD_RPC)
1118
	PYTHONPATH=. $(RUN_IN_TEMPDIR) $(CURDIR)/$(BUILD_RPC) lib/rpc_defs.py > $@
1119

    
1120
$(REPLACE_VARS_SED): Makefile
1121
	set -e; \
1122
	{ echo 's#@PREFIX@#$(prefix)#g'; \
1123
	  echo 's#@SYSCONFDIR@#$(sysconfdir)#g'; \
1124
	  echo 's#@LOCALSTATEDIR@#$(localstatedir)#g'; \
1125
	  echo 's#@BINDIR@#$(bindir)#g'; \
1126
	  echo 's#@SBINDIR@#$(sbindir)#g'; \
1127
	  echo 's#@GANETI_VERSION@#$(PACKAGE_VERSION)#g'; \
1128
	  echo 's#@CUSTOM_XEN_BOOTLOADER@#$(XEN_BOOTLOADER)#g'; \
1129
	  echo 's#@CUSTOM_XEN_KERNEL@#$(XEN_KERNEL)#g'; \
1130
	  echo 's#@CUSTOM_XEN_INITRD@#$(XEN_INITRD)#g'; \
1131
	  echo 's#@CUSTOM_IALLOCATOR_SEARCH_PATH@#$(IALLOCATOR_SEARCH_PATH)#g'; \
1132
	  echo 's#@CUSTOM_EXPORT_DIR@#$(EXPORT_DIR)#g'; \
1133
	  echo 's#@RPL_FILE_STORAGE_DIR@#$(FILE_STORAGE_DIR)#g'; \
1134
	  echo 's#@RPL_SSH_INITD_SCRIPT@#$(SSH_INITD_SCRIPT)#g'; \
1135
	  echo 's#@PKGLIBDIR@#$(pkglibdir)#g'; \
1136
	  echo 's#@GNTMASTERUSER@#$(MASTERD_USER)#g'; \
1137
	  echo 's#@GNTRAPIUSER@#$(RAPI_USER)#g'; \
1138
	  echo 's#@GNTCONFDUSER@#$(CONFD_USER)#g'; \
1139
	  echo 's#@GNTNODEDUSER@#$(NODED_USER)#g'; \
1140
	  echo 's#@GNTRAPIGROUP@#$(RAPI_GROUP)#g'; \
1141
	  echo 's#@GNTADMINGROUP@#$(ADMIN_GROUP)#g'; \
1142
	  echo 's#@GNTCONFDGROUP@#$(CONFD_GROUP)#g'; \
1143
	  echo 's#@GNTMASTERDGROUP@#$(MASTERD_GROUP)#g'; \
1144
	  echo 's#@GNTDAEMONSGROUP@#$(DAEMONS_GROUP)#g'; \
1145
	  echo 's#@CUSTOM_ENABLE_CONFD@#$(ENABLE_CONFD)#g'; \
1146
	} > $@
1147

    
1148
# Using deferred evaluation
1149
daemons/ganeti-%: MODULE = ganeti.server.$(patsubst ganeti-%,%,$(notdir $@))
1150
daemons/ganeti-watcher: MODULE = ganeti.watcher
1151
scripts/%: MODULE = ganeti.client.$(subst -,_,$(notdir $@))
1152
tools/ensure-dirs: MODULE = ganeti.tools.ensure_dirs
1153

    
1154
$(PYTHON_BOOTSTRAP): Makefile | $(all_dirfiles)
1155
	test -n "$(MODULE)" || { echo Missing module; exit 1; }
1156
	set -e; \
1157
	{ echo '#!/usr/bin/python'; \
1158
	  echo '# This file is automatically generated, do not edit!'; \
1159
	  echo "# Edit $(MODULE) instead."; \
1160
	  echo; \
1161
	  echo '"""Bootstrap script for L{$(MODULE)}"""'; \
1162
	  echo; \
1163
	  echo '# pylint: disable=C0103'; \
1164
	  echo '# C0103: Invalid name'; \
1165
	  echo; \
1166
	  echo 'import sys'; \
1167
	  echo 'import $(MODULE) as main'; \
1168
	  echo; \
1169
	  echo '# Temporarily alias commands until bash completion'; \
1170
	  echo '# generator is changed'; \
1171
	  echo 'if hasattr(main, "commands"):'; \
1172
	  echo '  commands = main.commands # pylint: disable=E1101'; \
1173
	  echo 'if hasattr(main, "aliases"):'; \
1174
	  echo '  aliases = main.aliases # pylint: disable=E1101'; \
1175
	  echo; \
1176
	  echo 'if __name__ == "__main__":'; \
1177
	  echo '  sys.exit(main.Main())'; \
1178
	} > $@
1179
	chmod u+x $@
1180

    
1181
# We need to create symlinks because "make distcheck" will not install Python
1182
# files when building.
1183
stamp-srclinks: Makefile | $(all_dirfiles)
1184
	set -e; \
1185
	for i in $(srclink_files); do \
1186
		if test ! -f $$i -a -f $(abs_top_srcdir)/$$i; then \
1187
			$(LN_S) $(abs_top_srcdir)/$$i $$i; \
1188
		fi; \
1189
	done
1190
	touch $@
1191

    
1192
.PHONY: ganeti
1193
ganeti:
1194
	cd $(top_builddir) && test -h "$@" || { rm -f $@ && $(LN_S) lib $@; }
1195

    
1196
.PHONY: check-dirs
1197
check-dirs: $(BUILT_SOURCES)
1198
	@set -e; \
1199
	find . -type d \( \( -name . \) -o \( \
1200
		-name .git -o \
1201
		-name autom4te.cache \
1202
		\) -prune -o -print \) | { \
1203
		error=; \
1204
		while read dir; do \
1205
			case "$$dir" in \
1206
				$(strip $(patsubst %,(./%) ;;,$(DIRCHECK_EXCLUDE) $(DIRS))) \
1207
				*) error=1; echo "Directory $$dir not listed in Makefile" >&2 ;; \
1208
			esac; \
1209
		done; \
1210
		for dir in $(DIRS); do \
1211
			if ! test -d "$$dir"; then \
1212
				echo "Directory $$dir listed in DIRS does not exist" >&2; \
1213
				error=1; \
1214
			fi \
1215
		done; \
1216
		if test -n "$$error"; then exit 1; else exit 0; fi; \
1217
	}
1218

    
1219
.PHONY: check-local
1220
check-local: check-dirs $(BUILT_SOURCES)
1221
	$(CHECK_PYTHON_CODE) $(check_python_code)
1222
	PYTHONPATH=. $(CHECK_HEADER) $(check_python_code)
1223
	$(CHECK_VERSION) $(VERSION) $(top_srcdir)/NEWS
1224
	$(CHECK_NEWS) < $(top_srcdir)/NEWS
1225
	PYTHONPATH=. $(RUN_IN_TEMPDIR) $(CURDIR)/$(CHECK_IMPORTS) . $(standalone_python_modules)
1226
	expver=$(VERSION_MAJOR).$(VERSION_MINOR); \
1227
	if test "`head -n 1 $(top_srcdir)/README`" != "Ganeti $$expver"; then \
1228
		echo "Incorrect version in README, expected $$expver"; \
1229
		exit 1; \
1230
	fi; \
1231
	for file in doc/iallocator.rst doc/hooks.rst; do \
1232
		if test "`sed -ne '4 p' $(top_srcdir)/$$file`" != \
1233
			"Documents Ganeti version $$expver"; then \
1234
			echo "Incorrect version in $$file, expected $$expver"; \
1235
			exit 1; \
1236
		fi; \
1237
	done
1238

    
1239
.PHONY: hs-check
1240
hs-check: htools/test htools/hpc-htools
1241
	@rm -f test.tix
1242
	./htools/test
1243
	HBINARY="./htools/hpc-htools" ./htools/offline-test.sh
1244

    
1245
# E111: indentation is not a multiple of four
1246
# E261: at least two spaces before inline comment
1247
# E501: line too long (80 characters)
1248
PEP8_IGNORE = E111,E261,E501
1249

    
1250
# For excluding pep8 expects filenames only, not whole paths
1251
PEP8_EXCLUDE = $(subst $(space),$(comma),$(strip $(notdir $(BUILT_PYTHON_SOURCES))))
1252

    
1253
.PHONY: lint
1254
lint: $(BUILT_SOURCES)
1255
	@test -n "$(PYLINT)" || { echo 'pylint' not found during configure; exit 1; }
1256
	if test -z "$(PEP8)"; then \
1257
		echo '"pep8" not found during configure' >&2; \
1258
	else \
1259
		$(PEP8) --repeat --ignore='$(PEP8_IGNORE)' --exclude='$(PEP8_EXCLUDE)' \
1260
			$(pep8_python_code); \
1261
	fi
1262
	$(PYLINT) $(LINT_OPTS) $(lint_python_code)
1263
	cd $(top_srcdir)/qa && \
1264
	  PYTHONPATH=$(abs_top_srcdir) $(PYLINT) $(LINT_OPTS) \
1265
	  --rcfile  ../pylintrc $(patsubst qa/%.py,%,$(qa_scripts))
1266

    
1267
.PHONY: hlint
1268
hlint: $(HS_BUILT_SRCS) htools/lint-hints.hs
1269
	if tty -s; then C="-c"; else C=""; fi; \
1270
	hlint --report=doc/hs-lint.html --cross $$C \
1271
	  --ignore "Use first" \
1272
	  --ignore "Use comparing" \
1273
	  --ignore "Use on" \
1274
	  --ignore "Use Control.Exception.catch" \
1275
	  --ignore "Reduce duplication" \
1276
	  --hint htools/lint-hints \
1277
	  $(filter-out htools/Ganeti/THH.hs,$(HS_LIB_SRCS))
1278

    
1279
# a dist hook rule for updating the vcs-version file; this is
1280
# hardcoded due to where it needs to build the file...
1281
dist-hook:
1282
	$(MAKE) regen-vcs-version && \
1283
	rm -f $(top_distdir)/vcs-version && \
1284
	cp -p $(srcdir)/vcs-version $(top_distdir)
1285

    
1286
# a distcheck hook rule for catching revision control directories
1287
distcheck-hook:
1288
	if find $(top_distdir) -name .svn -or -name .git | grep .; then \
1289
		echo "Found revision control files in final archive." 1>&2; \
1290
		exit 1; \
1291
	fi
1292
	if find $(top_distdir) -name '*.py[co]' | grep .; then \
1293
		echo "Found Python byte code in final archive." 1>&2; \
1294
		exit 1; \
1295
	fi
1296
	if find $(top_distdir) -name '*~' | grep .; then \
1297
		echo "Found backup files in final archive." 1>&2; \
1298
		exit 1; \
1299
	fi
1300
# Empty files or directories should not be distributed. They can cause
1301
# unnecessary warnings for packagers. Directories used by automake during
1302
# distcheck must be excluded.
1303
	if find $(top_distdir) -empty -and -not \( \
1304
			-path $(top_distdir)/_build -or \
1305
			-path $(top_distdir)/_inst \) | grep .; then \
1306
		echo "Found empty files or directories in final archive." 1>&2; \
1307
		exit 1; \
1308
	fi
1309
	if test -n "$(BUILD_RELEASE)" && \
1310
	   grep -n -H -E '^\*.*unreleased' $(top_distdir)/NEWS; then \
1311
		echo "Found unreleased version in NEWS." >&2; \
1312
		exit 1; \
1313
	fi
1314

    
1315
# When building a release, stricter checks should be used
1316
distcheck-release dist-release: export BUILD_RELEASE = 1
1317
distcheck-release: distcheck
1318

    
1319
dist-release: dist
1320
	set -e; \
1321
	for i in $(DIST_ARCHIVES); do \
1322
		echo -n "Checking $$i ... "; \
1323
		autotools/check-tar < $$i; \
1324
		echo OK; \
1325
	done
1326

    
1327
install-exec-local:
1328
	@mkdir_p@ "$(DESTDIR)${localstatedir}/lib/ganeti" \
1329
	  "$(DESTDIR)${localstatedir}/log/ganeti" \
1330
	  "$(DESTDIR)${localstatedir}/run/ganeti"
1331

    
1332
# To avoid conflicts between directory names and other targets, a file inside
1333
# the directory is used to ensure its existence.
1334
%.dir:
1335
	@mkdir_p@ $* && touch $@
1336

    
1337
.PHONY: apidoc
1338
if WANT_HTOOLSAPIDOC
1339
apidoc: py-apidoc hs-apidoc
1340
else
1341
apidoc: py-apidoc
1342
endif
1343

    
1344
.PHONY: py-apidoc
1345
py-apidoc: epydoc.conf $(RUN_IN_TEMPDIR) $(BUILT_SOURCES)
1346
	$(RUN_IN_TEMPDIR) epydoc -v \
1347
		--conf $(CURDIR)/epydoc.conf \
1348
		--output $(CURDIR)/$(APIDOC_PY_DIR)
1349

    
1350
.PHONY: hs-apidoc
1351
hs-apidoc: $(HS_BUILT_SRCS)
1352
	@test -n "$(HSCOLOUR)" || \
1353
	    { echo 'HsColour' not found during configure; exit 1; }
1354
	@test -n "$(HADDOCK)" || \
1355
	    { echo 'haddock' not found during configure; exit 1; }
1356
	rm -rf $(APIDOC_HS_DIR)/*
1357
	@mkdir_p@ $(APIDOC_HS_DIR)/Ganeti/HTools/Program
1358
	@mkdir_p@ $(APIDOC_HS_DIR)/Ganeti/Confd
1359
	$(HSCOLOUR) -print-css > $(APIDOC_HS_DIR)/Ganeti/hscolour.css
1360
	$(LN_S) ../hscolour.css $(APIDOC_HS_DIR)/Ganeti/HTools/hscolour.css
1361
	$(LN_S) ../hscolour.css $(APIDOC_HS_DIR)/Ganeti/Confd/hscolour.css
1362
	set -e ; \
1363
	cd htools; \
1364
	if [ "$(HTOOLS_NOCURL)" ]; \
1365
	then OPTGHC="--optghc=$(HTOOLS_NOCURL)"; \
1366
	else OPTGHC=""; \
1367
	fi; \
1368
	if [ "$(HTOOLS_PARALLEL3)" ]; \
1369
	then OPTGHC="$$OPTGHC --optghc=$(HTOOLS_PARALLEL3)"; \
1370
	fi; \
1371
	RELSRCS="$(HS_LIB_SRCS:htools/%=%)  $(HS_BUILT_SRCS:htools/%=%)"; \
1372
	for file in $$RELSRCS; do \
1373
		hfile=`echo $$file|sed 's/\\.hs$$//'`.html; \
1374
		$(HSCOLOUR) -css -anchor $$file > ../$(APIDOC_HS_DIR)/$$hfile ; \
1375
	done ; \
1376
	$(HADDOCK) --odir ../$(APIDOC_HS_DIR) --html --ignore-all-exports -w \
1377
		-t ganeti-htools -p haddock-prologue \
1378
		--source-module="%{MODULE/.//}.html" \
1379
		--source-entity="%{MODULE/.//}.html#%{NAME}" \
1380
		$$OPTGHC \
1381
		$(filter-out Ganeti/HTools/ExtLoader.hs,$(HS_LIB_SRCS:htools/%=%))
1382

    
1383
.PHONY: TAGS
1384
TAGS: $(BUILT_SOURCES)
1385
	rm -f TAGS
1386
	find . -path './lib/*.py' -o -path './scripts/gnt-*' -o \
1387
	  -path './daemons/ganeti-*' -o -path './tools/*' -o \
1388
	  -path './qa/*.py' | \
1389
	  etags -l python -
1390

    
1391
.PHONY: coverage
1392
if WANT_HTOOLS
1393
coverage: py-coverage hs-coverage
1394
else
1395
coverage: py-coverage
1396
endif
1397

    
1398
.PHONY: py-coverage
1399
py-coverage: $(BUILT_SOURCES) $(python_tests)
1400
	set -e; \
1401
	COVERAGE_FILE=$(CURDIR)/$(COVERAGE_PY_DIR)/data \
1402
	TEXT_COVERAGE=$(CURDIR)/$(COVERAGE_PY_DIR)/report.txt \
1403
	HTML_COVERAGE=$(CURDIR)/$(COVERAGE_PY_DIR) \
1404
	$(PLAIN_TESTS_ENVIRONMENT) $(abs_top_srcdir)/autotools/gen-coverage \
1405
	$(python_tests)
1406

    
1407
.PHONY: hs-coverage
1408
hs-coverage: $(haskell_tests) htools/hpc-htools
1409
	rm -f *.tix && $(MAKE) hs-check
1410
	@mkdir_p@ $(COVERAGE_HS_DIR)
1411
	hpc combine $(HPCEXCL) test.tix hpc-htools.tix > coverage-htools.tix
1412
	hpc markup --destdir=$(COVERAGE_HS_DIR) coverage-htools.tix
1413
	hpc report coverage-htools.tix
1414
	$(LN_S) -f hpc_index.html $(COVERAGE_HS_DIR)/index.html
1415

    
1416
# Special "kind-of-QA" target for htools, needs special setup (all
1417
# tools compiled with -fhpc)
1418
.PHONY: live-test
1419
live-test: all
1420
	set -e ; \
1421
	cd htools; \
1422
	rm -f .hpc; $(LN_S) ../.hpc .hpc; \
1423
	rm -f *.tix *.mix; \
1424
	./live-test.sh; \
1425
	hpc sum --union $(HPCEXCL) $(addsuffix .tix,$(HS_PROGS:htools/%=%)) \
1426
	  --output=live-test.tix ; \
1427
	@mkdir_p@ ../$(COVERAGE_HS_DIR) ; \
1428
	hpc markup --destdir=../$(COVERAGE_HS_DIR) live-test \
1429
		--srcdir=.. $(HPCEXCL) ; \
1430
	hpc report --srcdir=.. live-test $(HPCEXCL)
1431

    
1432
commit-check: distcheck lint apidoc
1433

    
1434
-include ./Makefile.local
1435

    
1436
# vim: set noet :