Changed around a bunch of things so that it's easy to do common things
from the root directory, html documentation can be built from the .rst
files, and also handy things like 'make distcheck' work.

Signed-off-by: Ben Lipton <[email protected]>
---
 .gitignore                      |   10 +++-----
 Makefile.am                     |   47 ++++++++++++++++++++++++++++++++++----
 configure.ac                    |    7 +++++-
 doc/Makefile.am                 |   14 +++++++++++
 instance-p2v-target/Makefile.am |    8 +-----
 p2v-transfer/Makefile.am        |   14 +++++++++++
 6 files changed, 82 insertions(+), 18 deletions(-)
 create mode 100644 doc/Makefile.am
 create mode 100644 p2v-transfer/Makefile.am

diff --git a/.gitignore b/.gitignore
index 88dfcef..710166a 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,7 +1,8 @@
 # gitignore rules
 # autotools results
-/Makefile
-/Makefile.in
+Makefile
+Makefile.in
+
 /aclocal.m4
 /autom4te.cache
 /autotools
@@ -9,15 +10,12 @@
 /config.status
 /configure
 
-/instance-p2v-target/Makefile
-/instance-p2v-target/Makefile.in
-
 # built files
 /instance-p2v-target/common.sh
 /instance-p2v-target/p2v-target.conf
 
 # archives
-/instance-p2v-target/ganeti-instance-p2v-target-*.tar.gz
+/ganeti-p2v-transfer-*.tar.gz
 
 # extensions
 .*.swp
diff --git a/Makefile.am b/Makefile.am
index 4984cda..e342410 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1,13 +1,50 @@
+# ganeti-p2v-transfer root Makefile.am
+# Goal: make it easy to install the appropriate things for either the
+# bootstrap or transfer operating systems, without accidentally installing
+# both of them. So, this file defines several convenience targets while making
+# sure that a normal 'make' or 'make install' doesn't install everything.
+
 all: help
+install: help
+
 help:
-       @echo 'This package has two parts, please select the one to install:'
-       @echo '  "make target": Install instance OS (on a ganeti node)'
-       @echo '  "make source": Install p2v-transfer script (on source machine)'
+       @echo 'Please select what to install:'
+       @echo '  "make install-target": Install docs and instance OS'\
+       ' (on a ganeti node)'
+       @echo '  "make install-source": Install docs and transfer script'\
+       ' (on source machine)'
+       @if test -n "$(RST2HTML)"; then \
+               echo '  "make doc": Just build html documentation'; \
+               echo '  "make install-doc": Build and install'\
+       ' html documentation'; \
+       else \
+               echo 'Note: rst2html not found, documentation will'\
+               'not be built'; \
+       fi
+
 
-target:
+.PHONY: install-target install-source doc install-doc help check all
+parts = p2v-transfer instance-p2v-target doc
+
+install-target: install-doc
        $(MAKE) -C instance-p2v-target
        $(MAKE) -C instance-p2v-target install
 
-source:
+install-source: install-doc
        $(MAKE) -C p2v-transfer
        $(MAKE) -C p2v-transfer install
+
+doc:
+       $(MAKE) -C doc
+
+install-doc: doc
+       $(MAKE) -C doc install
+
+check:
+       list='$(parts)'; for dir in $$list; do \
+           $(MAKE) -C $$dir check; \
+       done
+
+DIST_SUBDIRS = $(parts)
+
+dist_doc_DATA = COPYING NEWS README
diff --git a/configure.ac b/configure.ac
index 4ea8595..61895a2 100644
--- a/configure.ac
+++ b/configure.ac
@@ -20,6 +20,11 @@ AC_SUBST(OS_DIR, $os_dir)
 AC_PROG_INSTALL
 AC_PROG_LN_S
 
-AC_CONFIG_FILES([ Makefile instance-p2v-target/Makefile ])
+AC_PATH_PROG([RST2HTML], [rst2html])
+
+AC_CONFIG_FILES([ Makefile
+        instance-p2v-target/Makefile
+        p2v-transfer/Makefile
+        doc/Makefile ])
 
 AC_OUTPUT
diff --git a/doc/Makefile.am b/doc/Makefile.am
new file mode 100644
index 0000000..40a4b51
--- /dev/null
+++ b/doc/Makefile.am
@@ -0,0 +1,14 @@
+docrst = \
+       design.rst
+
+dochtml = $(docrst:.rst=.html)
+
+nodist_doc_DATA = $(dochtml)
+dist_doc_DATA = $(docrst)
+
+%.html: %.rst
+       @test -n "$(RST2HTML)" || \
+           { echo 'rst2html' not found, docs will not be built; exit 1; }
+       $(RST2HTML) $< > $@
+
+CLEANFILES = $(dochtml)
diff --git a/instance-p2v-target/Makefile.am b/instance-p2v-target/Makefile.am
index ae36d64..a146d8b 100644
--- a/instance-p2v-target/Makefile.am
+++ b/instance-p2v-target/Makefile.am
@@ -1,4 +1,4 @@
-osname=$(subst ganeti-instance-,,$(PACKAGE))
+osname=p2v-target
 
 osdir=$(DESTDIR)$(OS_DIR)/$(osname)
 configdir=$(DESTDIR)$(sysconfdir)/ganeti/instance-$(osname)
@@ -14,11 +14,7 @@ os_DATA = common.sh
 
 dist_sbin_SCRIPTS = scripts/make_ramboot_initrd.py
 
-dist_doc_DATA = ../COPYING ../NEWS ../README
-
 EXTRA_DIST = common.sh.in p2v-target.conf.in \
-       examples/hooks/grub \
-       examples/hooks/interfaces \
        $(dist_TESTS) \
        $(test_extras)
 
@@ -61,4 +57,4 @@ install-exec-hook:
        @echo *****************************************************************
        @echo
 
-CLEANFILES = common.sh
+CLEANFILES = common.sh p2v-target.conf
diff --git a/p2v-transfer/Makefile.am b/p2v-transfer/Makefile.am
new file mode 100644
index 0000000..1348145
--- /dev/null
+++ b/p2v-transfer/Makefile.am
@@ -0,0 +1,14 @@
+dist_sbin_SCRIPTS =  # coming soon
+
+EXTRA_DIST = \
+       $(dist_TESTS) \
+       $(test_extras)
+
+# Testing python scripts
+dist_TESTS =  # coming soon
+test_extras = # coming soon
+
+srcdir = @abs_srcdir@
+TESTS = $(dist_TESTS)
+TESTS_ENVIRONMENT = \
+       PYTHONPATH=$(srcdir) SRCDIR=$(srcdir)
-- 
1.7.3.1

Reply via email to