diff --git a/Makefile.am b/Makefile.am index 0483b4060..34ca59d9d 100644 --- a/Makefile.am +++ b/Makefile.am @@ -15,8 +15,7 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. --include $(top_builddir)/localenv - +include $(top_srcdir)/common-rules.mk ACLOCAL_AMFLAGS = -I m4 diff --git a/appliance/Makefile.am b/appliance/Makefile.am index 8e501565f..54d3379f3 100644 --- a/appliance/Makefile.am +++ b/appliance/Makefile.am @@ -15,9 +15,6 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -# Old RHEL 5 autoconf doesn't have builddir. -builddir ?= . - include $(top_srcdir)/subdir-rules.mk EXTRA_DIST = \ diff --git a/common-rules.mk b/common-rules.mk new file mode 100644 index 000000000..312107ead --- /dev/null +++ b/common-rules.mk @@ -0,0 +1,29 @@ +# libguestfs +# Copyright (C) 2013 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +# 'common-rules.mk' should be included in every Makefile.am. +# cf. 'subdir-rules.mk' + +-include $(top_builddir)/localenv + +# Old RHEL 5 autoconf defines these, but RHEL 5 automake doesn't +# create variables for them. So define them here if they're not +# defined already. +builddir ?= @builddir@ +abs_builddir ?= @abs_builddir@ +srcdir ?= @srcdir@ +abs_srcdir ?= @abs_srcdir@ diff --git a/erlang/examples/Makefile.am b/erlang/examples/Makefile.am index af6cbc76a..92e2c2dca 100644 --- a/erlang/examples/Makefile.am +++ b/erlang/examples/Makefile.am @@ -15,6 +15,8 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +include $(top_srcdir)/subdir-rules.mk + EXTRA_DIST = \ LICENSE \ create_disk.erl \ diff --git a/examples/Makefile.am b/examples/Makefile.am index b92b372dc..28d3c782e 100644 --- a/examples/Makefile.am +++ b/examples/Makefile.am @@ -15,6 +15,8 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +include $(top_srcdir)/subdir-rules.mk + EXTRA_DIST = \ LICENSE \ guestfs-examples.pod \ diff --git a/generator/Makefile.am b/generator/Makefile.am index 007107372..97611e670 100644 --- a/generator/Makefile.am +++ b/generator/Makefile.am @@ -15,14 +15,7 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -# Old RHEL 5 autoconf doesn't have abs_builddir. -abs_builddir ?= $(shell pwd) - -# Old RHEL 5 autoconf doesn't have abs_srcdir. -abs_srcdir ?= $(shell cd $(top_srcdir)/generator && pwd) - -# Old RHEL 5 autoconf doesn't have builddir. -builddir ?= . +include $(top_srcdir)/subdir-rules.mk # In alphabetical order. sources = \ diff --git a/gobject/docs/Makefile.am b/gobject/docs/Makefile.am index 0ee8c6f97..0a831a383 100644 --- a/gobject/docs/Makefile.am +++ b/gobject/docs/Makefile.am @@ -15,14 +15,7 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -# Old RHEL 5 autoconf doesn't have builddir. -builddir ?= . - -# Old RHEL 5 autoconf doesn't have abs_srcdir. -abs_srcdir ?= $(shell cd $(top_srcdir)/gobject/docs && pwd) - -# Old RHEL 5 autoconf doesn't have abs_builddir. -abs_builddir ?= $(shell pwd) +include $(top_srcdir)/subdir-rules.mk # The name of the module, e.g. 'glib'. DOC_MODULE=guestfs diff --git a/inspector/Makefile.am b/inspector/Makefile.am index bd533aabb..7035e0592 100644 --- a/inspector/Makefile.am +++ b/inspector/Makefile.am @@ -15,9 +15,6 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -# Old RHEL 5 autoconf doesn't have builddir. -builddir ?= . - include $(top_srcdir)/subdir-rules.mk export EXAMPLE_XML = \ diff --git a/java/Makefile.am b/java/Makefile.am index 9a2016096..7cb22e9cb 100644 --- a/java/Makefile.am +++ b/java/Makefile.am @@ -15,9 +15,6 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -# Old RHEL 5 autoconf doesn't have builddir. -builddir ?= . - include $(top_srcdir)/subdir-rules.mk java_prefix = com/redhat/et/libguestfs diff --git a/java/examples/Makefile.am b/java/examples/Makefile.am index f611f0350..f49419097 100644 --- a/java/examples/Makefile.am +++ b/java/examples/Makefile.am @@ -15,6 +15,8 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +include $(top_srcdir)/subdir-rules.mk + EXTRA_DIST = \ LICENSE \ CreateDisk.java \ diff --git a/lua/examples/Makefile.am b/lua/examples/Makefile.am index 8dc4650c8..93ba2c54f 100644 --- a/lua/examples/Makefile.am +++ b/lua/examples/Makefile.am @@ -15,6 +15,8 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +include $(top_srcdir)/subdir-rules.mk + EXTRA_DIST = \ LICENSE \ create_disk.lua \ diff --git a/ocaml/Makefile.am b/ocaml/Makefile.am index 7418d0f8f..c781b7e9a 100644 --- a/ocaml/Makefile.am +++ b/ocaml/Makefile.am @@ -15,12 +15,6 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -# Old RHEL 5 autoconf doesn't have builddir. -builddir ?= . - -# Old RHEL 5 autoconf doesn't have abs_srcdir. -abs_srcdir ?= $(shell cd $(top_srcdir)/ocaml && pwd) - include $(top_srcdir)/subdir-rules.mk generator_built = \ diff --git a/ocaml/examples/Makefile.am b/ocaml/examples/Makefile.am index b906ea056..200a0aa5c 100644 --- a/ocaml/examples/Makefile.am +++ b/ocaml/examples/Makefile.am @@ -15,6 +15,8 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +include $(top_srcdir)/subdir-rules.mk + EXTRA_DIST = \ LICENSE \ create_disk.ml \ diff --git a/perl/examples/Makefile.am b/perl/examples/Makefile.am index 037095efe..9b041237d 100644 --- a/perl/examples/Makefile.am +++ b/perl/examples/Makefile.am @@ -15,6 +15,8 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +include $(top_srcdir)/subdir-rules.mk + EXTRA_DIST = \ LICENSE \ create_disk.pl \ diff --git a/php/Makefile.am b/php/Makefile.am index 215295e95..2aca93833 100644 --- a/php/Makefile.am +++ b/php/Makefile.am @@ -17,9 +17,6 @@ include $(top_srcdir)/subdir-rules.mk -# Old RHEL 5 autoconf doesn't have abs_srcdir. -abs_srcdir ?= $(shell cd $(top_srcdir)/php && pwd) - generator_built = \ extension/php_guestfs_php.h \ extension/guestfs_php.c diff --git a/po-docs/Makefile.am b/po-docs/Makefile.am index 1b1da8800..077ace000 100644 --- a/po-docs/Makefile.am +++ b/po-docs/Makefile.am @@ -15,6 +15,8 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +include $(top_srcdir)/subdir-rules.mk + # XXX The use of po4a is naive here. Also we should integrate this # into the po/ directory and the translations into the usual # libguestfs.pot file. diff --git a/po-docs/ja/Makefile.am b/po-docs/ja/Makefile.am index 8e36a6418..0b1b10f8a 100644 --- a/po-docs/ja/Makefile.am +++ b/po-docs/ja/Makefile.am @@ -19,6 +19,8 @@ # identical. If you create a new $lang.po, create the $lang/ # subdirectory and copy the Makefile.am from an existing language. +include $(top_srcdir)/subdir-rules.mk + LINGUA = $(shell basename -- `pwd`) CLEANFILES = *.1 *.3 stamp-update-po diff --git a/po-docs/uk/Makefile.am b/po-docs/uk/Makefile.am index 8e36a6418..0b1b10f8a 100644 --- a/po-docs/uk/Makefile.am +++ b/po-docs/uk/Makefile.am @@ -19,6 +19,8 @@ # identical. If you create a new $lang.po, create the $lang/ # subdirectory and copy the Makefile.am from an existing language. +include $(top_srcdir)/subdir-rules.mk + LINGUA = $(shell basename -- `pwd`) CLEANFILES = *.1 *.3 stamp-update-po diff --git a/po/Makefile.am b/po/Makefile.am index 03fb57998..b53e2974c 100644 --- a/po/Makefile.am +++ b/po/Makefile.am @@ -17,9 +17,6 @@ include $(top_srcdir)/subdir-rules.mk -# Old RHEL 5 autoconf doesn't have abs_srcdir. -abs_srcdir ?= $(shell cd $(top_srcdir)/po && pwd) - DOMAIN = $(PACKAGE_NAME) COPYRIGHT_HOLDER = Red Hat Inc. MSGID_BUGS_ADDRESS = https://bugzilla.redhat.com/enter_bug.cgi?component=libguestfs&product=Virtualization+Tools diff --git a/python/Makefile.am b/python/Makefile.am index d513695ac..3c73d5405 100644 --- a/python/Makefile.am +++ b/python/Makefile.am @@ -15,9 +15,6 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -# Old RHEL 5 autoconf doesn't have builddir. -builddir ?= . - include $(top_srcdir)/subdir-rules.mk generator_built = \ diff --git a/python/examples/Makefile.am b/python/examples/Makefile.am index 303d6ceea..008a66861 100644 --- a/python/examples/Makefile.am +++ b/python/examples/Makefile.am @@ -15,6 +15,8 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +include $(top_srcdir)/subdir-rules.mk + EXTRA_DIST = \ LICENSE \ create_disk.py \ diff --git a/resize/Makefile.am b/resize/Makefile.am index bbff34843..9a62f4cc1 100644 --- a/resize/Makefile.am +++ b/resize/Makefile.am @@ -15,12 +15,6 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -# Old RHEL 5 autoconf doesn't have builddir. -builddir ?= . - -# Old RHEL 5 autoconf doesn't have abs_srcdir. -abs_srcdir ?= $(shell cd $(top_srcdir)/resize && pwd) - include $(top_srcdir)/subdir-rules.mk EXTRA_DIST = \ diff --git a/ruby/Makefile.am b/ruby/Makefile.am index 0c4ee5a4b..8c9684423 100644 --- a/ruby/Makefile.am +++ b/ruby/Makefile.am @@ -15,9 +15,6 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -# Old RHEL 5 autoconf doesn't have builddir. -builddir ?= . - include $(top_srcdir)/subdir-rules.mk generator_built = \ diff --git a/ruby/examples/Makefile.am b/ruby/examples/Makefile.am index 68e2c865b..1329a2a85 100644 --- a/ruby/examples/Makefile.am +++ b/ruby/examples/Makefile.am @@ -15,6 +15,8 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +include $(top_srcdir)/subdir-rules.mk + EXTRA_DIST = \ LICENSE \ create_disk.rb \ diff --git a/sparsify/Makefile.am b/sparsify/Makefile.am index 44857fefb..e29cf178e 100644 --- a/sparsify/Makefile.am +++ b/sparsify/Makefile.am @@ -17,12 +17,6 @@ include $(top_srcdir)/subdir-rules.mk -# Old RHEL 5 autoconf doesn't have builddir. -builddir ?= . - -# Old RHEL 5 autoconf doesn't have abs_srcdir. -abs_srcdir ?= $(shell cd $(top_srcdir)/sparsify && pwd) - EXTRA_DIST = \ $(SOURCES) \ virt-sparsify.pod \ diff --git a/subdir-rules.mk b/subdir-rules.mk index 2a8152c74..d2ebe23ca 100644 --- a/subdir-rules.mk +++ b/subdir-rules.mk @@ -15,6 +15,10 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +# subdir-rules.mk should be included in every *subdirectory* Makefile.am. + +include $(top_srcdir)/common-rules.mk + # Individual Makefile.am's should define generator_built if that # subdirectory contains any files which are built by the generator. # Set generator_built to the list of those files. diff --git a/sysprep/Makefile.am b/sysprep/Makefile.am index 0830424e5..81ffcc736 100644 --- a/sysprep/Makefile.am +++ b/sysprep/Makefile.am @@ -15,15 +15,6 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -# Old RHEL 5 autoconf doesn't have builddir. -builddir ?= . - -# Old RHEL 5 autoconf doesn't have abs_srcdir. -abs_srcdir ?= $(shell cd $(top_srcdir)/sysprep && pwd) - -# Old RHEL 5 autoconf doesn't have abs_builddir. -abs_builddir ?= $(shell pwd) - include $(top_srcdir)/subdir-rules.mk EXTRA_DIST = \ diff --git a/tests/data/Makefile.am b/tests/data/Makefile.am index 68c219700..fec78387f 100644 --- a/tests/data/Makefile.am +++ b/tests/data/Makefile.am @@ -15,9 +15,6 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -# Old RHEL 5 autoconf doesn't have builddir. -builddir ?= . - include $(top_srcdir)/subdir-rules.mk EXTRA_DIST = \ diff --git a/tests/guests/Makefile.am b/tests/guests/Makefile.am index e116a1209..2bc63d58b 100644 --- a/tests/guests/Makefile.am +++ b/tests/guests/Makefile.am @@ -15,9 +15,6 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -# Old RHEL 5 autoconf doesn't have builddir. -builddir ?= . - include $(top_srcdir)/subdir-rules.mk EXTRA_DIST = \ diff --git a/tests/xml/Makefile.am b/tests/xml/Makefile.am index eff67bebb..aa5761938 100644 --- a/tests/xml/Makefile.am +++ b/tests/xml/Makefile.am @@ -15,9 +15,6 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -# Old RHEL 5 autoconf doesn't have abs_srcdir. -abs_srcdir ?= $(shell cd $(top_srcdir)/tests/xml && pwd) - include $(top_srcdir)/subdir-rules.mk if HAVE_LIBVIRT