Statistics
| Branch: | Tag: | Revision:

root / Makefile.am @ 53d4cdf1

History | View | Annotate | Download (41.2 kB)

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

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

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

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

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

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

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

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

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

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

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

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

    
118
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
	$(HS_BUILT_TEST_HELPERS) \
160
	.hpc/*.mix htools/*.tix \
161
	doc/hs-lint.html
162

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

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

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

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

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

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

    
195
nodist_pkgpython_PYTHON = \
196
	$(BUILT_PYTHON_SOURCES)
197

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
357
HS_PROGS = htools/htools
358
if WANT_CONFD
359
HS_PROGS += htools/hconfd
360
endif
361
HS_BIN_ROLES = hbal hscan hspace hinfo
362

    
363
HS_ALL_PROGS = $(HS_PROGS) htools/test htools/hpc-htools
364
HS_PROG_SRCS = $(patsubst %,%.hs,$(HS_ALL_PROGS))
365
HS_BUILT_TEST_HELPERS = $(HS_BIN_ROLES:%=test/%) test/hail
366

    
367
# we don't add -Werror by default
368
HFLAGS = -O -Wall -fwarn-monomorphism-restriction -fwarn-tabs -ihtools
369
# extra flags that can be overriden on the command line
370
HEXTRA =
371
# internal extra flags (used for htools/test mainly)
372
HEXTRA_INT =
373
# exclude options for coverage reports
374
HPCEXCL = --exclude Main \
375
	--exclude Ganeti.Constants \
376
	--exclude Ganeti.THH \
377
	--exclude Ganeti.HTools.QC \
378
	--exclude Ganeti.HTools.QCHelper \
379
	--exclude Ganeti.HTools.Version
380

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

    
423
HS_BUILT_SRCS = htools/Ganeti/HTools/Version.hs htools/Ganeti/Constants.hs
424
HS_BUILT_SRCS_IN = $(patsubst %,%.in,$(HS_BUILT_SRCS))
425

    
426
$(RUN_IN_TEMPDIR): | $(all_dirfiles)
427

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

    
447
doc/html: doc/html/index.html
448

    
449
doc/install-quick.rst: INSTALL
450
doc/news.rst: NEWS
451
doc/upgrade.rst: UPGRADE
452

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

    
461
docdot = \
462
	doc/arch-2.0.dot \
463
	doc/design-2.1-lock-acquire.dot \
464
	doc/design-2.1-lock-release.dot
465

    
466
docpng = $(patsubst %.dot,%.png,$(docdot))
467

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

    
477
gnt_scripts = \
478
	scripts/gnt-backup \
479
	scripts/gnt-cluster \
480
	scripts/gnt-debug \
481
	scripts/gnt-group \
482
	scripts/gnt-instance \
483
	scripts/gnt-job \
484
	scripts/gnt-node \
485
	scripts/gnt-os
486

    
487
PYTHON_BOOTSTRAP_SBIN = \
488
	daemons/ganeti-confd \
489
	daemons/ganeti-masterd \
490
	daemons/ganeti-noded \
491
	daemons/ganeti-watcher \
492
	daemons/ganeti-rapi \
493
	$(gnt_scripts)
494

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

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

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

    
528
$(HS_ALL_PROGS): %: %.hs $(HS_LIB_SRCS) $(HS_BUILT_SRCS) Makefile
529
	@if [ -z "$(HTOOLS)" ]; then \
530
	  echo "Error: htools compilation disabled at configure time" 1>&2 ;\
531
	  exit 1; \
532
	fi
533
	@BINARY=$(@:htools/%=%); \
534
	if [ "$BINARY" = "test" ] && [ -z "$(GHC_PKG_QUICKCHECK)" ]; then \
535
	  echo "Error: cannot run unittests without the QuickCheck library (see devnotes.rst)" 1>&2; \
536
	  exit 1; \
537
	fi
538
	rm -f $(@:htools/%=%).tix
539
	BINARY=$(@:htools/%=%); $(GHC) --make \
540
	  $(HFLAGS) \
541
	  $(HTOOLS_NOCURL) $(HTOOLS_PARALLEL3) \
542
	  -osuf $$BINARY.o -hisuf $$BINARY.hi \
543
	  $(HEXTRA) $(HEXTRA_INT) $@
544
# for the htools/test binary, we need to enable profiling/coverage
545
htools/test: HEXTRA_INT=-fhpc -Wwarn -fno-warn-missing-signatures \
546
	-fno-warn-monomorphism-restriction -fno-warn-orphans \
547
	-fno-warn-missing-methods -fno-warn-unused-imports
548

    
549
# we compile the hpc-htools binary with the program coverage
550
htools/hpc-htools: HEXTRA_INT=-fhpc
551

    
552
# test dependency
553
htools/offline-tests.sh: htools/hpc-htools
554

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

    
566
hs-prof-quick:
567
	$(MAKE) $(HS_ALL_PROGS) HEXTRA="-osuf .prof_o -prof -auto-all"
568

    
569
dist_sbin_SCRIPTS = \
570
	tools/ganeti-listrunner
571

    
572
nodist_sbin_SCRIPTS = \
573
	$(PYTHON_BOOTSTRAP_SBIN) \
574
	daemons/ganeti-cleaner
575

    
576
python_scripts = \
577
	tools/burnin \
578
	tools/cfgshell \
579
	tools/cfgupgrade \
580
	tools/cfgupgrade12 \
581
	tools/cluster-merge \
582
	tools/confd-client \
583
	tools/fmtjson \
584
	tools/lvmstrap \
585
	tools/move-instance \
586
	tools/ovfconverter \
587
	tools/setup-ssh \
588
	tools/sanitize-config
589

    
590
dist_tools_SCRIPTS = \
591
	$(python_scripts) \
592
	tools/kvm-console-wrapper \
593
	tools/xm-console-wrapper \
594
	tools/master-ip-setup
595

    
596
pkglib_python_scripts = \
597
	daemons/import-export \
598
	tools/check-cert-expired
599

    
600
nodist_pkglib_python_scripts = \
601
	tools/ensure-dirs
602

    
603
myexeclib_SCRIPTS = \
604
	daemons/daemon-util \
605
	tools/kvm-ifup \
606
	$(pkglib_python_scripts)
607

    
608
nodist_myexeclib_SCRIPTS = \
609
	$(nodist_pkglib_python_scripts)
610

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

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

    
689
manrst = $(patsubst %.1,%.rst,$(patsubst %.7,%.rst,$(patsubst %.8,%.rst,$(man_MANS))))
690
manhtml = $(patsubst %.rst,%.html,$(manrst))
691
mangen = $(patsubst %.rst,%.gen,$(manrst))
692
maninput = \
693
	$(patsubst %.1,%.1.in,$(patsubst %.7,%.7.in,$(patsubst %.8,%.8.in,$(man_MANS)))) \
694
	$(patsubst %.html,%.html.in,$(manhtml)) \
695
	man/footer.man man/footer.html $(mangen)
696

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

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

    
845
haskell_tests = htools/test
846

    
847
dist_TESTS = \
848
	test/check-cert-expired_unittest.bash \
849
	test/daemon-util_unittest.bash \
850
	test/ganeti-cleaner_unittest.bash \
851
	test/import-export_unittest.bash \
852
	$(python_tests)
853

    
854
nodist_TESTS =
855
check_SCRIPTS =
856

    
857
if WANT_HTOOLSTESTS
858
nodist_TESTS += $(haskell_tests)
859
dist_TESTS += htools/offline-test.sh
860
check_SCRIPTS += htools/hpc-htools $(HS_BUILT_TEST_HELPERS)
861
endif
862

    
863
TESTS = $(dist_TESTS) $(nodist_TESTS)
864

    
865
# Environment for all tests
866
PLAIN_TESTS_ENVIRONMENT = \
867
	PYTHONPATH=. TOP_SRCDIR=$(abs_top_srcdir) PYTHON=$(PYTHON) \
868
	FAKEROOT=$(FAKEROOT_PATH) $(RUN_IN_TEMPDIR)
869

    
870
# Environment for tests run by automake
871
TESTS_ENVIRONMENT = \
872
	$(PLAIN_TESTS_ENVIRONMENT) $(abs_top_srcdir)/autotools/testrunner
873

    
874
all_python_code = \
875
	$(dist_sbin_SCRIPTS) \
876
	$(python_scripts) \
877
	$(pkglib_python_scripts) \
878
	$(nodist_pkglib_python_scripts) \
879
	$(python_tests) \
880
	$(pkgpython_PYTHON) \
881
	$(client_PYTHON) \
882
	$(hypervisor_PYTHON) \
883
	$(rapi_PYTHON) \
884
	$(server_PYTHON) \
885
	$(pytools_PYTHON) \
886
	$(http_PYTHON) \
887
	$(confd_PYTHON) \
888
	$(masterd_PYTHON) \
889
	$(impexpd_PYTHON) \
890
	$(utils_PYTHON) \
891
	$(watcher_PYTHON) \
892
	$(noinst_PYTHON) \
893
	$(qa_scripts)
894

    
895
srclink_files = \
896
	man/footer.rst \
897
	test/check-cert-expired_unittest.bash \
898
	test/daemon-util_unittest.bash \
899
	test/ganeti-cleaner_unittest.bash \
900
	test/import-export_unittest.bash \
901
	htools/offline-test.sh \
902
	htools/cli-tests-defs.sh \
903
	$(all_python_code) \
904
	$(HS_LIB_SRCS) $(HS_PROG_SRCS)
905

    
906
check_python_code = \
907
	$(BUILD_BASH_COMPLETION) \
908
	$(CHECK_IMPORTS) \
909
	$(CHECK_HEADER) \
910
	$(DOCPP) \
911
	$(all_python_code)
912

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

    
925
standalone_python_modules = \
926
	lib/rapi/client.py \
927
	tools/ganeti-listrunner
928

    
929
pep8_python_code = \
930
	ganeti \
931
	ganeti/http/server.py \
932
	$(dist_sbin_SCRIPTS) \
933
	$(python_scripts) \
934
	$(pkglib_python_scripts) \
935
	$(BUILD_BASH_COMPLETION) \
936
	$(CHECK_HEADER) \
937
	$(DOCPP) \
938
	$(PYTHON_BOOTSTRAP) \
939
	qa
940

    
941
test/daemon-util_unittest.bash: daemons/daemon-util
942

    
943
test/ganeti-cleaner_unittest.bash: daemons/ganeti-cleaner
944

    
945
tools/kvm-ifup: tools/kvm-ifup.in $(REPLACE_VARS_SED)
946
	sed -f $(REPLACE_VARS_SED) < $< > $@
947
	chmod +x $@
948

    
949
devel/upload: devel/upload.in $(REPLACE_VARS_SED)
950
	sed -f $(REPLACE_VARS_SED) < $< > $@
951
	chmod u+x $@
952

    
953
daemons/%: daemons/%.in $(REPLACE_VARS_SED)
954
	sed -f $(REPLACE_VARS_SED) < $< > $@
955
	chmod +x $@
956

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

    
960
doc/examples/hooks/%: doc/examples/hooks/%.in $(REPLACE_VARS_SED)
961
	sed -f $(REPLACE_VARS_SED) < $< > $@
962

    
963
doc/examples/bash_completion: $(BUILD_BASH_COMPLETION) $(RUN_IN_TEMPDIR) \
964
	lib/cli.py $(gnt_scripts) $(client_PYTHON) tools/burnin
965
	PYTHONPATH=. $(RUN_IN_TEMPDIR) $(CURDIR)/$(BUILD_BASH_COMPLETION) > $@
966

    
967
doc/%.png: doc/%.dot
968
	@test -n "$(DOT)" || { echo 'dot' not found during configure; exit 1; }
969
	$(DOT) -Tpng -o $@ $<
970

    
971
man/footer.man: man/footer.rst
972
	@test -n "$(PANDOC)" || \
973
	  { echo 'pandoc' not found during configure; exit 1; }
974
	$(PANDOC) -f rst -t man -o $@ $<
975

    
976
man/footer.html: man/footer.rst
977
	@test -n "$(PANDOC)" || \
978
	  { echo 'pandoc' not found during configure; exit 1; }
979
	$(PANDOC) -f rst -t html -o $@ $<
980

    
981
man/%.gen: man/%.rst lib/query.py lib/build/sphinx_ext.py
982
	PYTHONPATH=. $(RUN_IN_TEMPDIR) $(CURDIR)/$(DOCPP) < $< > $@
983

    
984
man/%.7.in man/%.8.in man/%.1.in: man/%.gen man/footer.man
985
	@test -n "$(PANDOC)" || \
986
	  { echo 'pandoc' not found during configure; exit 1; }
987
	set -o pipefail ; \
988
	trap 'echo auto-removing $@; rm $@' EXIT; \
989
	$(PANDOC) -s -f rst -t man -A man/footer.man $< | \
990
	  sed -e 's/\\@/@/g' > $@; \
991
	if test -n "$(MAN_HAS_WARNINGS)"; then $(CHECK_MAN_WARNINGS) $@; fi; \
992
	$(CHECK_MAN_DASHES) $@; \
993
	trap - EXIT
994

    
995

    
996
man/%.html.in: man/%.gen man/footer.html
997
	@test -n "$(PANDOC)" || \
998
	  { echo 'pandoc' not found during configure; exit 1; }
999
	set -o pipefail ; \
1000
	$(PANDOC) -s -f rst -t html -A man/footer.html $< | \
1001
	  sed -e 's/\\@/@/g' > $@
1002

    
1003
man/%.1: man/%.1.in $(REPLACE_VARS_SED)
1004
	sed -f $(REPLACE_VARS_SED) < $< > $@
1005

    
1006
man/%.7: man/%.7.in $(REPLACE_VARS_SED)
1007
	sed -f $(REPLACE_VARS_SED) < $< > $@
1008

    
1009
man/%.8: man/%.8.in $(REPLACE_VARS_SED)
1010
	sed -f $(REPLACE_VARS_SED) < $< > $@
1011

    
1012
man/%.html: man/%.html.in $(REPLACE_VARS_SED)
1013
	sed -f $(REPLACE_VARS_SED) < $< > $@
1014

    
1015
epydoc.conf: epydoc.conf.in Makefile
1016
	sed -e 's#@MODULES@#$(strip $(lint_python_code))#g' < $< > $@
1017

    
1018
vcs-version:
1019
	if test -d .git; then \
1020
	  git describe > $@; \
1021
	elif test ! -f $@ ; then \
1022
	  echo "Cannot auto-generate $@ file"; exit 1; \
1023
	fi
1024

    
1025
.PHONY: regen-vcs-version
1026
regen-vcs-version:
1027
	set -e; \
1028
	cd $(srcdir); \
1029
	if test -d .git; then \
1030
	  rm -f vcs-version; \
1031
	  $(MAKE) vcs-version; \
1032
	fi
1033

    
1034
htools/Ganeti/HTools/Version.hs: htools/Ganeti/HTools/Version.hs.in vcs-version
1035
	set -e; \
1036
	VCSVER=`cat $(abs_top_srcdir)/vcs-version`; \
1037
	sed -e "s/%ver%/$$VCSVER/" < $< > $@
1038

    
1039
htools/Ganeti/Constants.hs: htools/Ganeti/Constants.hs.in \
1040
	lib/constants.py lib/_autoconf.py $(CONVERT_CONSTANTS) \
1041
	| lib/_vcsversion.py
1042
	set -e; \
1043
	{ cat $< ; PYTHONPATH=. $(CONVERT_CONSTANTS); } > $@
1044

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

    
1113
lib/_vcsversion.py: Makefile vcs-version | lib/.dir
1114
	set -e; \
1115
	VCSVER=`cat $(abs_top_srcdir)/vcs-version`; \
1116
	{ echo '# This file is automatically generated, do not edit!'; \
1117
	  echo '#'; \
1118
	  echo ''; \
1119
	  echo '"""Build-time VCS version number for Ganeti.'; \
1120
	  echo '';\
1121
	  echo 'This file is autogenerated by the build process.'; \
1122
	  echo 'For any changes you need to re-run ./configure (and'; \
1123
	  echo 'not edit by hand).'; \
1124
	  echo ''; \
1125
	  echo '"""'; \
1126
	  echo ''; \
1127
	  echo '# pylint: disable=C0301,C0324'; \
1128
	  echo '# because this is autogenerated, we do not want'; \
1129
	  echo '# style warnings' ; \
1130
	  echo ''; \
1131
	  echo "VCS_VERSION = '$$VCSVER'"; \
1132
	} > $@
1133

    
1134
lib/_generated_rpc.py: lib/rpc_defs.py $(BUILD_RPC)
1135
	PYTHONPATH=. $(RUN_IN_TEMPDIR) $(CURDIR)/$(BUILD_RPC) lib/rpc_defs.py > $@
1136

    
1137
$(REPLACE_VARS_SED): Makefile
1138
	set -e; \
1139
	{ echo 's#@PREFIX@#$(prefix)#g'; \
1140
	  echo 's#@SYSCONFDIR@#$(sysconfdir)#g'; \
1141
	  echo 's#@LOCALSTATEDIR@#$(localstatedir)#g'; \
1142
	  echo 's#@BINDIR@#$(bindir)#g'; \
1143
	  echo 's#@SBINDIR@#$(sbindir)#g'; \
1144
	  echo 's#@GANETI_VERSION@#$(PACKAGE_VERSION)#g'; \
1145
	  echo 's#@CUSTOM_XEN_BOOTLOADER@#$(XEN_BOOTLOADER)#g'; \
1146
	  echo 's#@CUSTOM_XEN_KERNEL@#$(XEN_KERNEL)#g'; \
1147
	  echo 's#@CUSTOM_XEN_INITRD@#$(XEN_INITRD)#g'; \
1148
	  echo 's#@CUSTOM_IALLOCATOR_SEARCH_PATH@#$(IALLOCATOR_SEARCH_PATH)#g'; \
1149
	  echo 's#@CUSTOM_EXPORT_DIR@#$(EXPORT_DIR)#g'; \
1150
	  echo 's#@RPL_FILE_STORAGE_DIR@#$(FILE_STORAGE_DIR)#g'; \
1151
	  echo 's#@RPL_SSH_INITD_SCRIPT@#$(SSH_INITD_SCRIPT)#g'; \
1152
	  echo 's#@PKGLIBDIR@#$(pkglibdir)#g'; \
1153
	  echo 's#@GNTMASTERUSER@#$(MASTERD_USER)#g'; \
1154
	  echo 's#@GNTRAPIUSER@#$(RAPI_USER)#g'; \
1155
	  echo 's#@GNTCONFDUSER@#$(CONFD_USER)#g'; \
1156
	  echo 's#@GNTNODEDUSER@#$(NODED_USER)#g'; \
1157
	  echo 's#@GNTRAPIGROUP@#$(RAPI_GROUP)#g'; \
1158
	  echo 's#@GNTADMINGROUP@#$(ADMIN_GROUP)#g'; \
1159
	  echo 's#@GNTCONFDGROUP@#$(CONFD_GROUP)#g'; \
1160
	  echo 's#@GNTMASTERDGROUP@#$(MASTERD_GROUP)#g'; \
1161
	  echo 's#@GNTDAEMONSGROUP@#$(DAEMONS_GROUP)#g'; \
1162
	  echo 's#@CUSTOM_ENABLE_CONFD@#$(ENABLE_CONFD)#g'; \
1163
	} > $@
1164

    
1165
# Using deferred evaluation
1166
daemons/ganeti-%: MODULE = ganeti.server.$(patsubst ganeti-%,%,$(notdir $@))
1167
daemons/ganeti-watcher: MODULE = ganeti.watcher
1168
scripts/%: MODULE = ganeti.client.$(subst -,_,$(notdir $@))
1169
tools/ensure-dirs: MODULE = ganeti.tools.ensure_dirs
1170
$(HS_BUILT_TEST_HELPERS): TESTROLE = $(patsubst test/%,%,$@)
1171

    
1172
$(PYTHON_BOOTSTRAP): Makefile | $(all_dirfiles)
1173
	test -n "$(MODULE)" || { echo Missing module; exit 1; }
1174
	set -e; \
1175
	{ echo '#!/usr/bin/python'; \
1176
	  echo '# This file is automatically generated, do not edit!'; \
1177
	  echo "# Edit $(MODULE) instead."; \
1178
	  echo; \
1179
	  echo '"""Bootstrap script for L{$(MODULE)}"""'; \
1180
	  echo; \
1181
	  echo '# pylint: disable=C0103'; \
1182
	  echo '# C0103: Invalid name'; \
1183
	  echo; \
1184
	  echo 'import sys'; \
1185
	  echo 'import $(MODULE) as main'; \
1186
	  echo; \
1187
	  echo '# Temporarily alias commands until bash completion'; \
1188
	  echo '# generator is changed'; \
1189
	  echo 'if hasattr(main, "commands"):'; \
1190
	  echo '  commands = main.commands # pylint: disable=E1101'; \
1191
	  echo 'if hasattr(main, "aliases"):'; \
1192
	  echo '  aliases = main.aliases # pylint: disable=E1101'; \
1193
	  echo; \
1194
	  echo 'if __name__ == "__main__":'; \
1195
	  echo '  sys.exit(main.Main())'; \
1196
	} > $@
1197
	chmod u+x $@
1198

    
1199
$(HS_BUILT_TEST_HELPERS): Makefile
1200
	@test -n "$(TESTROLE)" || { echo Missing TESTROLE; exit 1; }
1201
	set -e; \
1202
	{ echo '#!/bin/sh'; \
1203
	  echo '# This file is automatically generated, do not edit!'; \
1204
	  echo "# Edit Makefile.am instead."; \
1205
	  echo; \
1206
	  echo "HTOOLS=$(TESTROLE) exec ./htools/hpc-htools \"\$$@\""; \
1207
	} > $@
1208
	chmod u+x $@
1209

    
1210
# We need to create symlinks because "make distcheck" will not install Python
1211
# files when building.
1212
stamp-srclinks: Makefile | $(all_dirfiles)
1213
	set -e; \
1214
	for i in $(srclink_files); do \
1215
		if test ! -f $$i -a -f $(abs_top_srcdir)/$$i; then \
1216
			$(LN_S) $(abs_top_srcdir)/$$i $$i; \
1217
		fi; \
1218
	done
1219
	touch $@
1220

    
1221
.PHONY: ganeti
1222
ganeti:
1223
	cd $(top_builddir) && test -h "$@" || { rm -f $@ && $(LN_S) lib $@; }
1224

    
1225
.PHONY: check-dirs
1226
check-dirs: $(BUILT_SOURCES)
1227
	@set -e; \
1228
	find . -type d \( \( -name . \) -o \( \
1229
		-name .git -o \
1230
		-name autom4te.cache \
1231
		\) -prune -o -print \) | { \
1232
		error=; \
1233
		while read dir; do \
1234
			case "$$dir" in \
1235
				$(strip $(patsubst %,(./%) ;;,$(DIRCHECK_EXCLUDE) $(DIRS))) \
1236
				*) error=1; echo "Directory $$dir not listed in Makefile" >&2 ;; \
1237
			esac; \
1238
		done; \
1239
		for dir in $(DIRS); do \
1240
			if ! test -d "$$dir"; then \
1241
				echo "Directory $$dir listed in DIRS does not exist" >&2; \
1242
				error=1; \
1243
			fi \
1244
		done; \
1245
		if test -n "$$error"; then exit 1; else exit 0; fi; \
1246
	}
1247

    
1248
.PHONY: check-local
1249
check-local: check-dirs $(BUILT_SOURCES)
1250
	$(CHECK_PYTHON_CODE) $(check_python_code)
1251
	PYTHONPATH=. $(CHECK_HEADER) $(check_python_code)
1252
	$(CHECK_VERSION) $(VERSION) $(top_srcdir)/NEWS
1253
	$(CHECK_NEWS) < $(top_srcdir)/NEWS
1254
	PYTHONPATH=. $(RUN_IN_TEMPDIR) $(CURDIR)/$(CHECK_IMPORTS) . $(standalone_python_modules)
1255
	expver=$(VERSION_MAJOR).$(VERSION_MINOR); \
1256
	if test "`head -n 1 $(top_srcdir)/README`" != "Ganeti $$expver"; then \
1257
		echo "Incorrect version in README, expected $$expver"; \
1258
		exit 1; \
1259
	fi; \
1260
	for file in doc/iallocator.rst doc/hooks.rst; do \
1261
		if test "`sed -ne '4 p' $(top_srcdir)/$$file`" != \
1262
			"Documents Ganeti version $$expver"; then \
1263
			echo "Incorrect version in $$file, expected $$expver"; \
1264
			exit 1; \
1265
		fi; \
1266
	done
1267

    
1268
.PHONY: hs-check
1269
hs-check: htools/test htools/hpc-htools $(HS_BUILT_TEST_HELPERS)
1270
	@rm -f test.tix
1271
	./htools/test
1272
	HBINARY="./htools/hpc-htools" ./htools/offline-test.sh
1273

    
1274
# E111: indentation is not a multiple of four
1275
# E261: at least two spaces before inline comment
1276
# E501: line too long (80 characters)
1277
PEP8_IGNORE = E111,E261,E501
1278

    
1279
# For excluding pep8 expects filenames only, not whole paths
1280
PEP8_EXCLUDE = $(subst $(space),$(comma),$(strip $(notdir $(BUILT_PYTHON_SOURCES))))
1281

    
1282
.PHONY: lint
1283
lint: $(BUILT_SOURCES)
1284
	@test -n "$(PYLINT)" || { echo 'pylint' not found during configure; exit 1; }
1285
	if test -z "$(PEP8)"; then \
1286
		echo '"pep8" not found during configure' >&2; \
1287
	else \
1288
		$(PEP8) --repeat --ignore='$(PEP8_IGNORE)' --exclude='$(PEP8_EXCLUDE)' \
1289
			$(pep8_python_code); \
1290
	fi
1291
	$(PYLINT) $(LINT_OPTS) $(lint_python_code)
1292
	cd $(top_srcdir)/qa && \
1293
	  PYTHONPATH=$(abs_top_srcdir) $(PYLINT) $(LINT_OPTS) \
1294
	  --rcfile  ../pylintrc $(patsubst qa/%.py,%,$(qa_scripts))
1295

    
1296
.PHONY: hlint
1297
hlint: $(HS_BUILT_SRCS) htools/lint-hints.hs
1298
	if tty -s; then C="-c"; else C=""; fi; \
1299
	hlint --report=doc/hs-lint.html --cross $$C \
1300
	  --ignore "Use first" \
1301
	  --ignore "Use comparing" \
1302
	  --ignore "Use on" \
1303
	  --ignore "Use Control.Exception.catch" \
1304
	  --ignore "Reduce duplication" \
1305
	  --hint htools/lint-hints \
1306
	  $(filter-out htools/Ganeti/THH.hs,$(HS_LIB_SRCS))
1307

    
1308
# a dist hook rule for updating the vcs-version file; this is
1309
# hardcoded due to where it needs to build the file...
1310
dist-hook:
1311
	$(MAKE) regen-vcs-version && \
1312
	rm -f $(top_distdir)/vcs-version && \
1313
	cp -p $(srcdir)/vcs-version $(top_distdir)
1314

    
1315
# a distcheck hook rule for catching revision control directories
1316
distcheck-hook:
1317
	if find $(top_distdir) -name .svn -or -name .git | grep .; then \
1318
		echo "Found revision control files in final archive." 1>&2; \
1319
		exit 1; \
1320
	fi
1321
	if find $(top_distdir) -name '*.py[co]' | grep .; then \
1322
		echo "Found Python byte code in final archive." 1>&2; \
1323
		exit 1; \
1324
	fi
1325
	if find $(top_distdir) -name '*~' | grep .; then \
1326
		echo "Found backup files in final archive." 1>&2; \
1327
		exit 1; \
1328
	fi
1329
# Empty files or directories should not be distributed. They can cause
1330
# unnecessary warnings for packagers. Directories used by automake during
1331
# distcheck must be excluded.
1332
	if find $(top_distdir) -empty -and -not \( \
1333
			-path $(top_distdir)/_build -or \
1334
			-path $(top_distdir)/_inst \) | grep .; then \
1335
		echo "Found empty files or directories in final archive." 1>&2; \
1336
		exit 1; \
1337
	fi
1338
	if test -n "$(BUILD_RELEASE)" && \
1339
	   grep -n -H -E '^\*.*unreleased' $(top_distdir)/NEWS; then \
1340
		echo "Found unreleased version in NEWS." >&2; \
1341
		exit 1; \
1342
	fi
1343

    
1344
# When building a release, stricter checks should be used
1345
distcheck-release dist-release: export BUILD_RELEASE = 1
1346
distcheck-release: distcheck
1347

    
1348
dist-release: dist
1349
	set -e; \
1350
	for i in $(DIST_ARCHIVES); do \
1351
		echo -n "Checking $$i ... "; \
1352
		autotools/check-tar < $$i; \
1353
		echo OK; \
1354
	done
1355

    
1356
install-exec-local:
1357
	@mkdir_p@ "$(DESTDIR)${localstatedir}/lib/ganeti" \
1358
	  "$(DESTDIR)${localstatedir}/log/ganeti" \
1359
	  "$(DESTDIR)${localstatedir}/run/ganeti"
1360

    
1361
# To avoid conflicts between directory names and other targets, a file inside
1362
# the directory is used to ensure its existence.
1363
%.dir:
1364
	@mkdir_p@ $* && touch $@
1365

    
1366
.PHONY: apidoc
1367
if WANT_HTOOLSAPIDOC
1368
apidoc: py-apidoc hs-apidoc
1369
else
1370
apidoc: py-apidoc
1371
endif
1372

    
1373
.PHONY: py-apidoc
1374
py-apidoc: epydoc.conf $(RUN_IN_TEMPDIR) $(BUILT_SOURCES)
1375
	$(RUN_IN_TEMPDIR) epydoc -v \
1376
		--conf $(CURDIR)/epydoc.conf \
1377
		--output $(CURDIR)/$(APIDOC_PY_DIR)
1378

    
1379
.PHONY: hs-apidoc
1380
hs-apidoc: $(HS_BUILT_SRCS)
1381
	@test -n "$(HSCOLOUR)" || \
1382
	    { echo 'HsColour' not found during configure; exit 1; }
1383
	@test -n "$(HADDOCK)" || \
1384
	    { echo 'haddock' not found during configure; exit 1; }
1385
	rm -rf $(APIDOC_HS_DIR)/*
1386
	@mkdir_p@ $(APIDOC_HS_DIR)/Ganeti/HTools/Program
1387
	@mkdir_p@ $(APIDOC_HS_DIR)/Ganeti/Confd
1388
	$(HSCOLOUR) -print-css > $(APIDOC_HS_DIR)/Ganeti/hscolour.css
1389
	$(LN_S) ../hscolour.css $(APIDOC_HS_DIR)/Ganeti/HTools/hscolour.css
1390
	$(LN_S) ../hscolour.css $(APIDOC_HS_DIR)/Ganeti/Confd/hscolour.css
1391
	set -e ; \
1392
	cd htools; \
1393
	if [ "$(HTOOLS_NOCURL)" ]; \
1394
	then OPTGHC="--optghc=$(HTOOLS_NOCURL)"; \
1395
	else OPTGHC=""; \
1396
	fi; \
1397
	if [ "$(HTOOLS_PARALLEL3)" ]; \
1398
	then OPTGHC="$$OPTGHC --optghc=$(HTOOLS_PARALLEL3)"; \
1399
	fi; \
1400
	RELSRCS="$(HS_LIB_SRCS:htools/%=%)  $(HS_BUILT_SRCS:htools/%=%)"; \
1401
	for file in $$RELSRCS; do \
1402
		hfile=`echo $$file|sed 's/\\.hs$$//'`.html; \
1403
		$(HSCOLOUR) -css -anchor $$file > ../$(APIDOC_HS_DIR)/$$hfile ; \
1404
	done ; \
1405
	$(HADDOCK) --odir ../$(APIDOC_HS_DIR) --html --ignore-all-exports -w \
1406
		-t ganeti-htools -p haddock-prologue \
1407
		--source-module="%{MODULE/.//}.html" \
1408
		--source-entity="%{MODULE/.//}.html#%{NAME}" \
1409
		$$OPTGHC \
1410
		$(filter-out Ganeti/HTools/ExtLoader.hs,$(HS_LIB_SRCS:htools/%=%))
1411

    
1412
.PHONY: TAGS
1413
TAGS: $(BUILT_SOURCES)
1414
	rm -f TAGS
1415
	find . -path './lib/*.py' -o -path './scripts/gnt-*' -o \
1416
	  -path './daemons/ganeti-*' -o -path './tools/*' -o \
1417
	  -path './qa/*.py' | \
1418
	  etags -l python -
1419

    
1420
.PHONY: coverage
1421
if WANT_HTOOLS
1422
coverage: py-coverage hs-coverage
1423
else
1424
coverage: py-coverage
1425
endif
1426

    
1427
.PHONY: py-coverage
1428
py-coverage: $(BUILT_SOURCES) $(python_tests)
1429
	set -e; \
1430
	COVERAGE_FILE=$(CURDIR)/$(COVERAGE_PY_DIR)/data \
1431
	TEXT_COVERAGE=$(CURDIR)/$(COVERAGE_PY_DIR)/report.txt \
1432
	HTML_COVERAGE=$(CURDIR)/$(COVERAGE_PY_DIR) \
1433
	$(PLAIN_TESTS_ENVIRONMENT) $(abs_top_srcdir)/autotools/gen-coverage \
1434
	$(python_tests)
1435

    
1436
.PHONY: hs-coverage
1437
hs-coverage: $(haskell_tests) htools/hpc-htools
1438
	rm -f *.tix && $(MAKE) hs-check
1439
	@mkdir_p@ $(COVERAGE_HS_DIR)
1440
	hpc combine $(HPCEXCL) test.tix hpc-htools.tix > coverage-htools.tix
1441
	hpc markup --destdir=$(COVERAGE_HS_DIR) coverage-htools.tix
1442
	hpc report coverage-htools.tix
1443
	$(LN_S) -f hpc_index.html $(COVERAGE_HS_DIR)/index.html
1444

    
1445
# Special "kind-of-QA" target for htools, needs special setup (all
1446
# tools compiled with -fhpc)
1447
.PHONY: live-test
1448
live-test: all
1449
	set -e ; \
1450
	cd htools; \
1451
	rm -f .hpc; $(LN_S) ../.hpc .hpc; \
1452
	rm -f *.tix *.mix; \
1453
	./live-test.sh; \
1454
	hpc sum --union $(HPCEXCL) $(addsuffix .tix,$(HS_PROGS:htools/%=%)) \
1455
	  --output=live-test.tix ; \
1456
	@mkdir_p@ ../$(COVERAGE_HS_DIR) ; \
1457
	hpc markup --destdir=../$(COVERAGE_HS_DIR) live-test \
1458
		--srcdir=.. $(HPCEXCL) ; \
1459
	hpc report --srcdir=.. live-test $(HPCEXCL)
1460

    
1461
commit-check: distcheck lint apidoc
1462

    
1463
-include ./Makefile.local
1464

    
1465
# vim: set noet :