[Libguestfs] [PATCH 3/5] build: Add Makefile.common, ensure libguestfs.la is built when required

Matthew Booth mbooth at redhat.com
Thu Nov 19 13:55:16 UTC 2009


This patch adds a top level Makefile.common and includes it almost everywhere.
It is not included in directories which aren't directly related to the top level
build, for example the daemon.

The force target moves into the new file. It also includes a new rule to rebuild
libguestfs.la automatically as required.
---
 Makefile.am             |    4 ++--
 Makefile.common         |   23 +++++++++++++++++++++++
 appliance/Makefile.am   |    2 ++
 capitests/Makefile.am   |    4 ++--
 examples/Makefile.am    |    2 ++
 fish/Makefile.am        |    4 ++--
 fuse/Makefile.am        |    2 ++
 haskell/Makefile.am     |    4 ++--
 images/Makefile.am      |    2 ++
 inspector/Makefile.am   |    2 ++
 java/Makefile.am        |    7 ++-----
 ocaml/Makefile.am       |    4 ++--
 perl/Makefile.am        |    4 ++--
 python/Makefile.am      |    4 ++--
 regressions/Makefile.am |    2 ++
 ruby/Makefile.am        |    4 ++--
 src/Makefile.am         |    2 ++
 test-tool/Makefile.am   |    2 ++
 tools/Makefile.am       |    2 ++
 19 files changed, 59 insertions(+), 21 deletions(-)
 create mode 100644 Makefile.common

diff --git a/Makefile.am b/Makefile.am
index 09f9217..204a91b 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -15,6 +15,8 @@
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 
+include $(top_srcdir)/Makefile.common
+
 ACLOCAL_AMFLAGS = -I m4
 
 SUBDIRS = gnulib/lib hivex src daemon appliance fish po examples images \
@@ -59,8 +61,6 @@ generator_built = \
 	guestfs-actions.pod \
 	guestfish-actions.pod
 
-.PHONY: force
-
 $(generator_built): force
 	$(MAKE) -C $(top_builddir)/src stamp-generator
 
diff --git a/Makefile.common b/Makefile.common
new file mode 100644
index 0000000..fe954e0
--- /dev/null
+++ b/Makefile.common
@@ -0,0 +1,23 @@
+# libguestfs
+# Copyright (C) 2009 Red Hat Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+# Define a force dependency which will always be rebuilt
+.PHONY: force
+
+# Rebuild rules for common dependencies
+$(top_builddir)/src/libguestfs.la: force
+	$(MAKE) -C $(top_builddir)/src libguestfs.la
diff --git a/appliance/Makefile.am b/appliance/Makefile.am
index b9bf953..aae3385 100644
--- a/appliance/Makefile.am
+++ b/appliance/Makefile.am
@@ -15,6 +15,8 @@
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 
+include $(top_srcdir)/Makefile.common
+
 EXTRA_DIST = \
 	libguestfs-supermin-helper \
 	kmod.whitelist.in \
diff --git a/capitests/Makefile.am b/capitests/Makefile.am
index 6bfce5d..dd70d1a 100644
--- a/capitests/Makefile.am
+++ b/capitests/Makefile.am
@@ -15,9 +15,9 @@
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 
-generator_built = tests.c
+include $(top_srcdir)/Makefile.common
 
-.PHONY: force
+generator_built = tests.c
 
 $(generator_built): force
 	$(MAKE) -C $(top_builddir)/src stamp-generator
diff --git a/examples/Makefile.am b/examples/Makefile.am
index adbb934..c6252e3 100644
--- a/examples/Makefile.am
+++ b/examples/Makefile.am
@@ -1,5 +1,7 @@
 # libguestfs examples
 
+include $(top_srcdir)/Makefile.common
+
 noinst_PROGRAMS = hello to-xml
 
 hello_SOURCES = hello.c
diff --git a/fish/Makefile.am b/fish/Makefile.am
index 962bc00..d9eea5f 100644
--- a/fish/Makefile.am
+++ b/fish/Makefile.am
@@ -15,14 +15,14 @@
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 
+include $(top_srcdir)/Makefile.common
+
 bin_PROGRAMS = guestfish
 
 generator_built = \
 	cmds.c \
 	completion.c
 
-.PHONY: force
-
 $(generator_built): force
 	$(MAKE) -C $(top_builddir)/src stamp-generator
 
diff --git a/fuse/Makefile.am b/fuse/Makefile.am
index d582c65..b6cbe88 100644
--- a/fuse/Makefile.am
+++ b/fuse/Makefile.am
@@ -15,6 +15,8 @@
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 
+include $(top_srcdir)/Makefile.common
+
 EXTRA_DIST = guestmount.pod test-fuse.sh
 
 if HAVE_FUSE
diff --git a/haskell/Makefile.am b/haskell/Makefile.am
index 01a78cb..978801a 100644
--- a/haskell/Makefile.am
+++ b/haskell/Makefile.am
@@ -15,12 +15,12 @@
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 
+include $(top_srcdir)/Makefile.common
+
 generator_built = \
 	Guestfs.hs \
 	Bindtests.hs
 
-.PHONY: force
-
 $(generator_built): force
 	$(MAKE) -C $(top_builddir)/src stamp-generator
 
diff --git a/images/Makefile.am b/images/Makefile.am
index ff6bc5d..19ae9b6 100644
--- a/images/Makefile.am
+++ b/images/Makefile.am
@@ -15,6 +15,8 @@
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 
+include $(top_srcdir)/Makefile.common
+
 # Old RHEL 5 autoconf doesn't have builddir.
 builddir ?= $(top_builddir)/images
 
diff --git a/inspector/Makefile.am b/inspector/Makefile.am
index 058e565..1d210bb 100644
--- a/inspector/Makefile.am
+++ b/inspector/Makefile.am
@@ -15,6 +15,8 @@
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 
+include $(top_srcdir)/Makefile.common
+
 EXTRA_DIST = \
 	run-inspector-locally \
 	virt-inspector \
diff --git a/java/Makefile.am b/java/Makefile.am
index 0ca7f7c..fe1476a 100644
--- a/java/Makefile.am
+++ b/java/Makefile.am
@@ -15,6 +15,8 @@
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 
+include $(top_srcdir)/Makefile.common
+
 # Old RHEL 5 autoconf doesn't have builddir.
 builddir ?= $(top_builddir)/java
 
@@ -70,11 +72,6 @@ libguestfs_jni_la_SOURCES = \
 	com_redhat_et_libguestfs_GuestFS.h \
 	com_redhat_et_libguestfs_GuestFS.c
 
-.PHONY: force
-
-$(top_builddir)/src/libguestfs.la: force
-	make -C $(top_builddir)/src libguestfs.la
-
 libguestfs_jni_la_LIBADD = $(top_builddir)/src/libguestfs.la
 libguestfs_jni_la_LDFLAGS = -version-info $(JNI_VERSION_INFO)
 libguestfs_jni_la_CFLAGS = -Wall -I$(top_srcdir)/src -I$(top_builddir)/src $(JNI_CFLAGS)
diff --git a/ocaml/Makefile.am b/ocaml/Makefile.am
index 99fbe6b..38fa35e 100644
--- a/ocaml/Makefile.am
+++ b/ocaml/Makefile.am
@@ -15,14 +15,14 @@
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 
+include $(top_srcdir)/Makefile.common
+
 generator_built = \
 	guestfs.mli \
 	guestfs.ml \
 	guestfs_c_actions.c \
 	bindtests.ml
 
-.PHONY: force
-
 $(generator_built): force
 	$(MAKE) -C $(top_builddir)/src stamp-generator
 
diff --git a/perl/Makefile.am b/perl/Makefile.am
index 0a67269..ccc1b85 100644
--- a/perl/Makefile.am
+++ b/perl/Makefile.am
@@ -15,13 +15,13 @@
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 
+include $(top_srcdir)/Makefile.common
+
 generator_built = \
 	Guestfs.xs \
 	lib/Sys/Guestfs.pm \
 	bindtests.pl
 
-.PHONY: force
-
 $(generator_built): force
 	$(MAKE) -C $(top_builddir)/src stamp-generator
 
diff --git a/python/Makefile.am b/python/Makefile.am
index 9a5aab6..0cf99aa 100644
--- a/python/Makefile.am
+++ b/python/Makefile.am
@@ -18,13 +18,13 @@
 # Old RHEL 5 autoconf doesn't have builddir.
 builddir ?= $(top_builddir)/python
 
+include $(top_srcdir)/Makefile.common
+
 generator_built = \
 	guestfs-py.c \
 	guestfs.py \
 	bindtests.py
 
-.PHONY: force
-
 $(generator_built): force
 	$(MAKE) -C $(top_builddir)/src stamp-generator
 
diff --git a/regressions/Makefile.am b/regressions/Makefile.am
index 058b60d..d861c54 100644
--- a/regressions/Makefile.am
+++ b/regressions/Makefile.am
@@ -21,6 +21,8 @@
 #
 # See also capitests/
 
+include $(top_srcdir)/Makefile.common
+
 TESTS = \
 	rhbz503169c10.sh \
 	rhbz503169c13.sh \
diff --git a/ruby/Makefile.am b/ruby/Makefile.am
index ae18684..5829dcc 100644
--- a/ruby/Makefile.am
+++ b/ruby/Makefile.am
@@ -15,12 +15,12 @@
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 
+include $(top_srcdir)/Makefile.common
+
 generator_built = \
 	ext/guestfs/_guestfs.c \
 	bindtests.rb
 
-.PHONY: force
-
 $(generator_built): force
 	$(MAKE) -C $(top_builddir)/src stamp-generator
 
diff --git a/src/Makefile.am b/src/Makefile.am
index 373f1d2..01fe384 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -15,6 +15,8 @@
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 
+include $(top_srcdir)/Makefile.common
+
 generator_built = \
 	guestfs_protocol.x \
 	guestfs-structs.h \
diff --git a/test-tool/Makefile.am b/test-tool/Makefile.am
index 510a42f..549e232 100644
--- a/test-tool/Makefile.am
+++ b/test-tool/Makefile.am
@@ -15,6 +15,8 @@
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 
+include $(top_srcdir)/Makefile.common
+
 EXTRA_DIST = libguestfs-test-tool.pod
 
 CLEANFILES =
diff --git a/tools/Makefile.am b/tools/Makefile.am
index f48edae..88aad54 100644
--- a/tools/Makefile.am
+++ b/tools/Makefile.am
@@ -15,6 +15,8 @@
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 
+include $(top_srcdir)/Makefile.common
+
 tools = cat df edit ls rescue tar win-reg
 
 EXTRA_DIST = \
-- 
1.6.5.2




More information about the Libguestfs mailing list