Statistics
| Branch: | Tag: | Revision:

root / Makefile.am @ 6ec7a50e

History | View | Annotate | Download (39.1 kB)

1
# Ganeti makefile
2
# - Indent with tabs only.
3
# - Keep files sorted; one line per file.
4
# - Directories in lib/ must have their own *dir variable (see hypervisor).
5
# - All directories must be listed DIRS.
6
# - Use autogen.sh to generate Makefile.in and configure script.
7

    
8
# Automake doesn't export these variables before version 1.10.
9
abs_top_builddir = @abs_top_builddir@
10
abs_top_srcdir = @abs_top_srcdir@
11

    
12
# Helper values for calling builtin functions
13
empty :=
14
space := $(empty) $(empty)
15
comma := ,
16

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
189
nodist_pkgpython_PYTHON = \
190
	$(BUILT_PYTHON_SOURCES)
191

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
434
doc/html: doc/html/index.html
435

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
551
dist_sbin_SCRIPTS = \
552
	tools/ganeti-listrunner
553

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

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

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

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

    
582
nodist_pkglib_python_scripts = \
583
	tools/ensure-dirs
584

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

    
590
nodist_myexeclib_SCRIPTS = \
591
	$(nodist_pkglib_python_scripts)
592

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

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

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

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

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

    
802
haskell_tests = htools/test
803

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
946

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
1396
commit-check: distcheck lint apidoc
1397

    
1398
-include ./Makefile.local
1399

    
1400
# vim: set noet :