Commit e8230860 authored by Michael Hanselmann's avatar Michael Hanselmann

Use a single Makefile.am instead of many

This change allows us to use cleaner dependencies between
directories. The build system is basically rewritten in large parts
and may contain bugs.

Reviewed-by: iustinp
parent ae9da390
# Ganeti makefile
# - Indent with tabs only.
# - Keep files sorted; one line per file.
# - Directories in lib/ must have their own *dir variable (see hypervisor).
# - All directories must be listed DIRS.
# - Use autogen.sh to generate Makefile.in and configure script
# Automake doesn't export these variables before version 1.10.
abs_top_builddir = @abs_top_builddir@
abs_top_srcdir = @abs_top_srcdir@
ACLOCAL_AMFLAGS = -I autotools
DOCBOOK_WRAPPER = $(top_srcdir)/autotools/docbook-wrapper
REPLACE_VARS_SED = autotools/replace_vars.sed
hypervisordir = $(pkgpythondir)/hypervisor
toolsdir = $(pkglibdir)/tools
docdir = $(datadir)/doc/$(PACKAGE)
DIRS = \
autotools \
daemons \
devel \
doc \
doc/examples \
lib \
lib/hypervisor \
man \
qa \
qa/hooks \
scripts \
test \
test/data \
tools
CLEANFILES = \
autotools/replace_vars.sed \
devel/upload \
doc/*.html \
doc/*.in \
doc/*.pdf \
doc/examples/ganeti.initd \
doc/examples/ganeti.cron \
lib/*.py[co] \
lib/hypervisor/*.py[co] \
man/*.[78] \
man/*.in \
qa/*.py[co] \
qa/hooks/*.py[co] \
test/*.py[co] \
stamp-directories \
$(nodist_pkgpython_PYTHON)
nodist_pkgpython_PYTHON = \
lib/_autoconf.py
pkgpython_PYTHON = \
lib/__init__.py \
lib/backend.py \
lib/bdev.py \
lib/bootstrap.py \
lib/cli.py \
lib/cmdlib.py \
lib/config.py \
lib/constants.py \
lib/errors.py \
lib/jqueue.py \
lib/locking.py \
lib/logger.py \
lib/luxi.py \
lib/mcpu.py \
lib/objects.py \
lib/opcodes.py \
lib/rpc.py \
lib/serializer.py \
lib/ssconf.py \
lib/ssh.py \
lib/utils.py
hypervisor_PYTHON = \
lib/hypervisor/__init__.py \
lib/hypervisor/hv_base.py \
lib/hypervisor/hv_fake.py \
lib/hypervisor/hv_xen.py
docsgml = \
doc/hooks.sgml \
doc/install.sgml \
doc/admin.sgml \
doc/iallocator.sgml
doc_DATA = \
$(patsubst %.sgml,%.html,$(docsgml)) \
$(patsubst %.sgml,%.pdf,$(docsgml))
dist_sbin_SCRIPTS = \
daemons/ganeti-noded \
daemons/ganeti-watcher \
daemons/ganeti-master \
daemons/ganeti-masterd \
scripts/gnt-backup \
scripts/gnt-cluster \
scripts/gnt-debug \
scripts/gnt-instance \
scripts/gnt-job \
scripts/gnt-node \
scripts/gnt-os
dist_tools_SCRIPTS = \
tools/burnin \
tools/cfgshell \
tools/cfgupgrade \
tools/lvmstrap
EXTRA_DIST = \
NEWS \
DEVNOTES \
autotools/docbook-wrapper \
devel/upload.in \
$(docsgml) \
doc/examples/ganeti.initd.in \
doc/examples/ganeti.cron.in \
doc/examples/dumb-allocator \
qa/hooks/datehook.py \
qa/hooks/loghook.py \
test/testutils.py \
test/mocks.py \
$(dist_TESTS) \
$(TEST_FILES) \
man/footer.sgml \
$(mansgml) \
qa/ganeti-qa.py \
qa/qa-sample.yaml \
qa/qa_cluster.py \
qa/qa_config.py \
qa/qa_daemon.py \
qa/qa_env.py \
qa/qa_error.py \
qa/qa_instance.py \
qa/qa_node.py \
qa/qa_os.py \
qa/qa_other.py \
qa/qa_tags.py \
qa/qa_utils.py
man_MANS = \
man/ganeti.7 \
man/ganeti-master.8 \
man/ganeti-noded.8 \
man/ganeti-os-interface.7 \
man/ganeti-watcher.8 \
man/gnt-backup.8 \
man/gnt-cluster.8 \
man/gnt-instance.8 \
man/gnt-node.8 \
man/gnt-os.8
maninput = $(patsubst %.7,%.in,$(patsubst %.8,%.in,$(man_MANS)))
mansgml = $(patsubst %.in,%.sgml,$(maninput))
TEST_FILES = \
test/data/bdev-both.txt \
test/data/bdev-disk.txt \
test/data/bdev-net.txt \
test/data/proc_drbd8.txt
dist_TESTS = \
test/ganeti.config_unittest.py \
test/ganeti.hooks_unittest.py \
test/ganeti.utils_unittest.py \
test/ganeti.bdev_unittest.py \
test/ganeti.ssh_unittest.py \
test/ganeti.locking_unittest.py \
test/ganeti.constants_unittest.py
nodist_TESTS =
TESTS = $(dist_TESTS) $(nodist_TESTS)
TESTS_ENVIRONMENT = PYTHONPATH=.:$(top_builddir)
SUBDIRS = man lib scripts daemons doc test tools qa devel
EXTRA_DIST = NEWS DEVNOTES
all-local: stamp-directories lib/_autoconf.py devel/upload \
doc/examples/ganeti.initd doc/examples/ganeti.cron
devel/upload: devel/upload.in stamp-directories $(REPLACE_VARS_SED)
sed -f $(REPLACE_VARS_SED) < $< > $@
chmod u+x $@
doc/examples/ganeti.%: doc/examples/ganeti.%.in stamp-directories \
$(REPLACE_VARS_SED)
sed -f $(REPLACE_VARS_SED) < $< > $@
doc/%.in: doc/%.sgml stamp-directories $(REPLACE_VARS_SED)
sed -f $(REPLACE_VARS_SED) < $< > $@
man/%.in: man/%.sgml stamp-directories $(REPLACE_VARS_SED)
sed -f $(REPLACE_VARS_SED) < $< > $@
doc/%.pdf: doc/%.in $(DOCBOOK_WRAPPER)
$(DOCBOOK_WRAPPER) $< $@
doc/%.html: doc/%.in $(DOCBOOK_WRAPPER)
$(DOCBOOK_WRAPPER) $< $@
man/%.7: man/%.in man/footer.sgml $(DOCBOOK_WRAPPER)
$(DOCBOOK_WRAPPER) $< $@
man/%.8: man/%.in man/footer.sgml $(DOCBOOK_WRAPPER)
$(DOCBOOK_WRAPPER) $< $@
man/footer.sgml $(TESTS): srclinks
$(TESTS): ganeti
lib/_autoconf.py: Makefile stamp-directories
set -e; \
{ echo '# This file is automatically generated, do not edit!'; \
echo '#'; \
echo "PACKAGE_VERSION = '$(PACKAGE_VERSION)'"; \
echo "VERSION_MAJOR = '$(VERSION_MAJOR)'"; \
echo "VERSION_MINOR = '$(VERSION_MINOR)'"; \
echo "VERSION_REVISION = '$(VERSION_REVISION)'"; \
echo "VERSION_SUFFIX = '$(VERSION_SUFFIX)'"; \
echo "VERSION_FULL = '$(VERSION_FULL)'"; \
echo "LOCALSTATEDIR = '$(localstatedir)'"; \
echo "SYSCONFDIR = '$(sysconfdir)'"; \
echo "SSH_INITD_SCRIPT = '$(SSH_INITD_SCRIPT)'"; \
echo "EXPORT_DIR = '$(EXPORT_DIR)'"; \
echo "OS_SEARCH_PATH = [$(OS_SEARCH_PATH)]"; \
echo "XEN_KERNEL = '$(XEN_KERNEL)'"; \
echo "XEN_INITRD = '$(XEN_INITRD)'"; \
echo "FILE_STORAGE_DIR = '$(FILE_STORAGE_DIR)'"; \
echo "IALLOCATOR_SEARCH_PATH = [$(IALLOCATOR_SEARCH_PATH)]"; \
} > $@
$(REPLACE_VARS_SED): Makefile stamp-directories
set -e; \
{ echo 's#@PREFIX@#$(prefix)#g'; \
echo 's#@SYSCONFDIR@#$(sysconfdir)#g'; \
echo 's#@LOCALSTATEDIR@#$(localstatedir)#g'; \
echo 's#@SBINDIR@#$(sbindir)#g'; \
echo 's#@GANETI_VERSION@#$(PACKAGE_VERSION)#g'; \
echo 's#@LOCALSTATEDIR@#$(localstatedir)#g'; \
echo 's#@CUSTOM_XEN_KERNEL@#$(XEN_KERNEL)#g'; \
echo 's#@CUSTOM_XEN_INITRD@#$(XEN_INITRD)#g'; \
} > $@
# We need to create symlinks because "make distcheck" will not install Python
# files when building.
#.PHONY: srclinks
srclinks: stamp-directories
set -e; \
for i in man/footer.sgml $(pkgpython_PYTHON) $(hypervisor_PYTHON); do \
if test ! -f $$i -a -f $(abs_top_srcdir)/$$i; then \
$(LN_S) $(abs_top_srcdir)/$$i $$i; \
fi; \
done
.PHONY: ganeti
ganeti:
cd $(top_builddir) && rm -f $@ && $(LN_S) lib $@
pre-check: ganeti
$(MAKE) -C lib $@
$(MAKE) -C lib/hypervisor $@
# a dist hook rule for catching revision control directories
distcheck-hook:
if find $(top_distdir) | grep -F -e '.svn' -e '.git'; then \
......@@ -18,20 +268,13 @@ distcheck-hook:
exit 1; \
fi
# custom rules
depgraph: depgraph.png
depgraph.png: depgraph.dot
dot -Tpng -o $@ $<
depgraph.ps: depgraph.dot
dot -Tps -o $@ $<
depgraph.dot: ganeti/*.py
pylint.python2.4 --indent-string ' ' --rcfile=/dev/null \
--reports y --int-import-graph $@ --persistent n ganeti >/dev/null
install-exec-local:
@mkdir_p@ "$(DESTDIR)${localstatedir}/lib/ganeti" \
@mkdir_p@ -- "$(DESTDIR)${localstatedir}/lib/ganeti" \
"$(DESTDIR)${localstatedir}/log/ganeti" \
"$(DESTDIR)${localstatedir}/run/ganeti"
stamp-directories: Makefile
@mkdir_p@ $(DIRS)
touch $@
# vim: set noet :
#!/bin/sh
set -e
input="${1}"
output="${2}"
case "${output}" in
*.pdf) cmd=docbook2pdf ;;
*.html) cmd='docbook2html --nochunks' ;;
*.7|*.8) cmd=docbook2man ;;
*)
echo "Unknown filetype: ${output}" >&2
exit 1
;;
esac
tmpdir=`mktemp -d`
trap "rm -rf ${tmpdir}" EXIT
if ! ( cd `dirname ${input}` &&
${cmd} -o ${tmpdir} `basename "${input}"` >/dev/null; )
then
echo "Building ${output} failed." >&2
exit 1
fi;
mv "${tmpdir}/`basename "${output}"`" "${output}"
# Needed for make to recognize output file
touch "${output}"
......@@ -111,20 +111,6 @@ then
AC_MSG_WARN([docbook2man not found.])
fi
AC_CONFIG_FILES([
Makefile
daemons/Makefile
devel/Makefile
doc/Makefile
doc/examples/Makefile
lib/Makefile
lib/hypervisor/Makefile
man/Makefile
qa/Makefile
qa/hooks/Makefile
scripts/Makefile
test/Makefile
tools/Makefile
])
AC_CONFIG_FILES([ Makefile ])
AC_OUTPUT
dist_sbin_SCRIPTS = ganeti-noded ganeti-watcher ganeti-master ganeti-masterd
EXTRA_DIST = upload.in
CLEANFILES = upload
all-local: upload
upload: upload.in
sed \
-e 's#@PREFIX@#$(prefix)#g' \
< $< > $@
chmod u+x $@
docdir = $(datadir)/doc/$(PACKAGE)
SUBDIRS = examples
dist_doc_DATA = \
hooks.html hooks.pdf \
install.html install.pdf \
admin.html admin.pdf \
iallocator.html iallocator.pdf
EXTRA_DIST = hooks.sgml install.sgml admin.sgml iallocator.sgml
MAINTAINERCLEANFILES = *.html *.pdf
%.sgmltmp: %.sgml
sed -e 's#@GANETI_VERSION@#$(PACKAGE_VERSION)#g' < $< > $@
%.html: %.sgmltmp
docbook2html --nochunks $< || rm -f $@
%.pdf: %.sgmltmp
docbook2pdf $< || rm -f $@
EXTRA_DIST = ganeti.initd.in ganeti.cron.in dumb-allocator
CLEANFILES = $(nodist_EXTRA_DATA)
nodist_EXTRA_DATA = ganeti.initd ganeti.cron
all-local: ganeti.initd ganeti.cron
ganeti.%: ganeti.%.in Makefile
sed \
-e "s#@PREFIX@#$(prefix)#g" \
-e "s#@SYSCONFDIR@#$(sysconfdir)#g" \
-e "s#@LOCALSTATEDIR@#$(localstatedir)#g" \
-e "s#@SBINDIR@#$(sbindir)#g" \
< $< > $@
CLEANFILES = $(nodist_pkgpython_PYTHON) *.py[oc]
SUBDIRS = hypervisor
nodist_pkgpython_PYTHON = _autoconf.py
pkgpython_PYTHON = __init__.py backend.py cli.py cmdlib.py config.py \
objects.py errors.py logger.py ssh.py utils.py rpc.py \
bdev.py opcodes.py mcpu.py constants.py \
ssconf.py locking.py luxi.py jqueue.py serializer.py \
bootstrap.py
python_files = $(pkgpython_PYTHON)
all-local: _autoconf.py
_autoconf.py: Makefile
{ echo '# This file is automatically generated, do not edit!'; \
echo '#'; \
echo "PACKAGE_VERSION = '$(PACKAGE_VERSION)'"; \
echo "VERSION_MAJOR = '$(VERSION_MAJOR)'"; \
echo "VERSION_MINOR = '$(VERSION_MINOR)'"; \
echo "VERSION_REVISION = '$(VERSION_REVISION)'"; \
echo "VERSION_SUFFIX = '$(VERSION_SUFFIX)'"; \
echo "VERSION_FULL = '$(VERSION_FULL)'"; \
echo "LOCALSTATEDIR = '$(localstatedir)'"; \
echo "SYSCONFDIR = '$(sysconfdir)'"; \
echo "SSH_INITD_SCRIPT = '$(SSH_INITD_SCRIPT)'"; \
echo "EXPORT_DIR = '$(EXPORT_DIR)'"; \
echo "OS_SEARCH_PATH = [$(OS_SEARCH_PATH)]"; \
echo "XEN_KERNEL = '$(XEN_KERNEL)'"; \
echo "XEN_INITRD = '$(XEN_INITRD)'"; \
echo "FILE_STORAGE_DIR = '$(FILE_STORAGE_DIR)'"; \
echo "IALLOCATOR_SEARCH_PATH = [$(IALLOCATOR_SEARCH_PATH)]"; \
} > $@
include $(srcdir)/Makefile.libcommon
CLEANFILES = *.py[oc]
hypervisordir = $(pkgpythondir)/hypervisor
hypervisor_PYTHON = __init__.py hv_base.py hv_fake.py hv_xen.py
python_files = $(hypervisor_PYTHON)
include $(srcdir)/../Makefile.libcommon
# Build man pages
man_MANS = ganeti.7 ganeti-os-interface.7 gnt-cluster.8 gnt-node.8 gnt-os.8 \
gnt-instance.8 ganeti-noded.8 ganeti-watcher.8 gnt-backup.8 \
ganeti-master.8
maninput = $(patsubst %.7,%.in,$(patsubst %.8,%.in,$(man_MANS)))
EXTRA_DIST = ganeti-os-interface.sgml gnt-cluster.sgml gnt-node.sgml \
ganeti-watcher.sgml ganeti.sgml gnt-instance.sgml gnt-os.sgml \
gnt-backup.sgml ganeti-noded.sgml ganeti-master.sgml \
footer.sgml $(maninput)
CLEANFILES = *.[78]
MAINTAINERCLEANFILES = $(maninput)
# Wrapper around docbook2man to control the output's filename
%.in: %.sgml footer.sgml
tmpdir=`mktemp -d "./manbuildXXXXXX"` && \
docbook2man -o "$$tmpdir" $< && \
ok= && \
for check in `basename $< .sgml`.{7,8}; do \
if test -f "$$tmpdir/$$check"; then \
mv "$$tmpdir/$$check" $@ && \
ok=1 && \
break; \
fi; \
done; \
if test -z "$$ok"; then \
echo "Building $@ failed."; \
exit 1; \
fi; \
rm -rf "$$tmpdir"
%.7 %.8: %.in Makefile
sed -e 's#@LOCALSTATEDIR@#$(localstatedir)#g' \
-e 's#@CUSTOM_XEN_KERNEL@#$(XEN_KERNEL)#g' \
-e 's#@CUSTOM_XEN_INITRD@#$(XEN_INITRD)#g' \
< $< > $@
SUBDIRS = hooks
EXTRA_DIST = ganeti-qa.py qa-sample.yaml \
qa_cluster.py \
qa_config.py \
qa_daemon.py \
qa_env.py \
qa_error.py \
qa_instance.py \
qa_node.py \
qa_os.py \
qa_other.py \
qa_tags.py \
qa_utils.py
CLEANFILES = *.py[co]
EXTRA_DIST = datehook.py loghook.py
CLEANFILES = *.py[co]
dist_sbin_SCRIPTS = gnt-instance gnt-cluster gnt-node gnt-os gnt-backup gnt-debug gnt-job
TESTS = \
ganeti.config_unittest.py \
ganeti.hooks_unittest.py \
ganeti.utils_unittest.py \
ganeti.bdev_unittest.py \
ganeti.ssh_unittest.py \
ganeti.locking_unittest.py \
ganeti.constants_unittest.py
TESTS_ENVIRONMENT = PYTHONPATH=.:$(top_builddir)
check-am: do-pre-check
do-pre-check:
$(MAKE) -C $(top_builddir) pre-check
EXTRA_DIST = $(TESTS) testutils.py mocks.py $(wildcard data/*.txt)
CLEANFILES = *.py[co]
......@@ -51,7 +51,7 @@ class TestDRBD8Runner(unittest.TestCase):
prefix = os.environ.get("srcdir", None)
if prefix:
name = prefix + "/" + name
name = prefix + "/test/" + name
fh = open(name, "r")
try:
data = fh.read()
......@@ -59,7 +59,6 @@ class TestDRBD8Runner(unittest.TestCase):
fh.close()
return data
@staticmethod
def _has_net(data, local, remote):
"""Check network connection parameters"""
......@@ -115,7 +114,7 @@ class TestDRBD8Status(unittest.TestCase):
def setUp(self):
"""Read in txt data"""
proc_data = "data/proc_drbd8.txt"
proc_data = "test/data/proc_drbd8.txt"
prefix = os.environ.get("srcdir", None)
if prefix:
proc_data = prefix + "/" + proc_data
......
toolsdir = $(pkglibdir)/tools
dist_tools_SCRIPTS = lvmstrap burnin cfgshell cfgupgrade
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment