Statistics
| Branch: | Tag: | Revision:

root / Makefile.am @ 21dc8694

History | View | Annotate | Download (39 kB)

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
189
nodist_pkgpython_PYTHON = \
190
	$(BUILT_PYTHON_SOURCES)
191

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
410
$(RUN_IN_TEMPDIR): | $(all_dirfiles)
411

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

    
431
doc/html: doc/html/index.html
432

    
433
doc/install-quick.rst: INSTALL
434
doc/news.rst: NEWS
435
doc/upgrade.rst: UPGRADE
436

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

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

    
450
docpng = $(patsubst %.dot,%.png,$(docdot))
451

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

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

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

    
479
PYTHON_BOOTSTRAP = \
480
	$(PYTHON_BOOTSTRAP_SBIN) \
481
	tools/ensure-dirs
482

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

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

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

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

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

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

    
548
dist_sbin_SCRIPTS = \
549
	tools/ganeti-listrunner
550

    
551
nodist_sbin_SCRIPTS = \
552
	$(PYTHON_BOOTSTRAP_SBIN) \
553
	daemons/ganeti-cleaner
554

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

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

    
575
pkglib_python_scripts = \
576
	daemons/import-export \
577
	tools/check-cert-expired
578

    
579
nodist_pkglib_python_scripts = \
580
	tools/ensure-dirs
581

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

    
587
nodist_myexeclib_SCRIPTS = \
588
	$(nodist_pkglib_python_scripts)
589

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

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

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

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

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

    
799
haskell_tests = htools/test
800

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

    
808
nodist_TESTS =
809
if WANT_HTOOLSTESTS
810
nodist_TESTS += $(haskell_tests)
811
endif
812

    
813
TESTS = $(dist_TESTS) $(nodist_TESTS)
814

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

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

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

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

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

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

    
873
standalone_python_modules = \
874
	lib/rapi/client.py \
875
	tools/ganeti-listrunner
876

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

    
889
test/daemon-util_unittest.bash: daemons/daemon-util
890

    
891
test/ganeti-cleaner_unittest.bash: daemons/ganeti-cleaner
892

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

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

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

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

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

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

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

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

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

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

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

    
943

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
1393
commit-check: distcheck lint apidoc
1394

    
1395
-include ./Makefile.local
1396

    
1397
# vim: set noet :