using gnulib from daemon/
Hi Rich, Prompted by your "New commands to list devices by UUID and label" patch, I've adjusted it to use gnulib. While just compiling hash.[ch] is probably ok, in general (given the strict requirements of libguestfs) using the C files of a module is usually not an option, since you don't get the benefit of the module's m4 tests or automake snippets. For other modules, those pieces are often required. To integrate gnulib into a project like this is not hard at all: I ran this one-time command: ../.gnulib/gnulib-tool --import --with-tests hash That created the file, daemon/m4/gnulib-cache.m4, which I've git-added in the patch below. It records the names of modules we're using (currently only "hash") as well as a few other things, including the fact that I told it to include unit tests. That latter option creates and populates the tests/ directory. The other new directory is lib/. I added the SUBDIRS line in Makefile.am to build in those directories and the corresponding */Makefile names in configure.ac. Now that gnulib-cache.m4 records state, to update from gnulib in the future, you'd just run this, perhaps from an ./autogen.sh script: (I haven't done that yet) ../.gnulib/gnulib-tool --update Also, I added the usual AC_CONFIG_AUX_DIR([build-aux]) directive to configure.ac so that all of the auxilliary files pulled in by autoreconf don't clutter the daemon/ directory. The only other change was the always-required-with-gnulib one to add these two lines to configure.ac: gl_EARLY gl_INIT If you apply this on top of yours, it should still build, with no change in binary size, and it will then be trivial to add a few more gnulib modules.
From 21c185b04a41f61c06a64d1d4076aff4a98d0d40 Mon Sep 17 00:00:00 2001 From: Jim Meyering <meyering@redhat.com> Date: Wed, 5 Aug 2009 05:59:19 -0400 Subject: [PATCH] daemon: use gnulib
* Makefile.am (SUBDIRS): Define. (AM_CPPFLAGS): Define, to include from gnulib's lib/ (LDADD): Define, to link with gnulib's libgnu.a. * configure.ac: Use AC_CONFIG_AUX_DIR([build-aux]), gl_EARLY, gl_INIT. (AC_CONFIG_FILES): Add lib/Makefile and tests/Makefile * m4/gnulib-cache.m4: New file, generated by running ../.gnulib/gnulib-tool --import --with-tests hash * .gitignore: Ignore all of the imported files. --- daemon/.gitignore | 29 +++++++++++++++++++++++++++++ daemon/Makefile.am | 10 ++++++---- daemon/configure.ac | 6 +++++- daemon/m4/gnulib-cache.m4 | 35 +++++++++++++++++++++++++++++++++++ 4 files changed, 75 insertions(+), 5 deletions(-) create mode 100644 daemon/.gitignore create mode 100644 daemon/m4/gnulib-cache.m4 diff --git a/daemon/.gitignore b/daemon/.gitignore new file mode 100644 index 0000000..7f60faf --- /dev/null +++ b/daemon/.gitignore @@ -0,0 +1,29 @@ +build-aux +lib +link-warning.h +m4/00gnulib.m4 +m4/errno_h.m4 +m4/error.m4 +m4/exitfail.m4 +m4/extensions.m4 +m4/gnulib-common.m4 +m4/gnulib-comp.m4 +m4/gnulib-tool.m4 +m4/hash.m4 +m4/include_next.m4 +m4/inline.m4 +m4/inttostr.m4 +m4/longlong.m4 +m4/multiarch.m4 +m4/onceonly.m4 +m4/stdbool.m4 +m4/stdint.m4 +m4/stdlib_h.m4 +m4/strerror.m4 +m4/string_h.m4 +m4/unistd_h.m4 +m4/wchar.m4 +m4/wchar_t.m4 +m4/wint_t.m4 +m4/xalloc.m4 +tests diff --git a/daemon/Makefile.am b/daemon/Makefile.am index 0fec611..090338d 100644 --- a/daemon/Makefile.am +++ b/daemon/Makefile.am @@ -17,6 +17,8 @@ ACLOCAL_AMFLAGS = -I m4 +SUBDIRS = lib tests . + noinst_PROGRAMS = guestfsd guestfsd_SOURCES = \ actions.h \ @@ -75,8 +77,8 @@ guestfsd_SOURCES = \ zero.c \ zerofree.c \ $(top_builddir)/../src/guestfs_protocol.h \ - $(top_builddir)/../src/guestfs_protocol.c \ - $(srcdir)/../.gnulib/lib/hash.h \ - $(srcdir)/../.gnulib/lib/hash.c + $(top_builddir)/../src/guestfs_protocol.c -guestfsd_CFLAGS = -Wall -I$(srcdir)/../.gnulib/lib +AM_CPPFLAGS = -I$(srcdir)/lib -Ilib +guestfsd_CFLAGS = -Wall +LDADD = lib/libgnu.a diff --git a/daemon/configure.ac b/daemon/configure.ac index 3bfd2ed..126e125 100644 --- a/daemon/configure.ac +++ b/daemon/configure.ac @@ -16,6 +16,7 @@ # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. AC_INIT([libguestfs-daemon],[1.0.0]) +AC_CONFIG_AUX_DIR([build-aux]) AM_INIT_AUTOMAKE([foreign]) AC_CONFIG_MACRO_DIR([m4]) @@ -41,6 +42,9 @@ AC_PROG_CC AC_PROG_INSTALL AC_PROG_CPP +gl_EARLY +gl_INIT + AC_C_PROTOTYPES test "x$U" != "x" && AC_MSG_ERROR([Compiler not ANSI compliant]) @@ -86,5 +90,5 @@ AC_CHECK_HEADERS([attr/xattr.h sys/xattr.h]) dnl Produce output files. AC_CONFIG_HEADERS([config.h]) -AC_CONFIG_FILES([Makefile]) +AC_CONFIG_FILES([Makefile lib/Makefile tests/Makefile]) AC_OUTPUT diff --git a/daemon/m4/gnulib-cache.m4 b/daemon/m4/gnulib-cache.m4 new file mode 100644 index 0000000..8aa504a --- /dev/null +++ b/daemon/m4/gnulib-cache.m4 @@ -0,0 +1,35 @@ +# Copyright (C) 2002-2009 Free Software Foundation, Inc. +# +# This file is free software, distributed under the terms of the GNU +# General Public License. As a special exception to the GNU General +# Public License, this file may be distributed as part of a program +# that contains a configuration script generated by Autoconf, under +# the same distribution terms as the rest of that program. +# +# Generated by gnulib-tool. +# +# This file represents the specification of how gnulib-tool is used. +# It acts as a cache: It is written and read by gnulib-tool. +# In projects using CVS, this file is meant to be stored in CVS, +# like the configure.ac and various Makefile.am files. + + +# Specification in the form of a command-line invocation: +# gnulib-tool --import --dir=. --lib=libgnu --source-base=lib --m4-base=m4 --doc-base=doc --tests-base=tests --aux-dir=build-aux --with-tests --no-libtool --macro-prefix=gl hash + +# Specification in the form of a few gnulib-tool.m4 macro invocations: +gl_LOCAL_DIR([]) +gl_MODULES([ + hash +]) +gl_AVOID([]) +gl_SOURCE_BASE([lib]) +gl_M4_BASE([m4]) +gl_PO_BASE([]) +gl_DOC_BASE([doc]) +gl_TESTS_BASE([tests]) +gl_WITH_TESTS +gl_LIB([libgnu]) +gl_MAKEFILE_NAME([]) +gl_MACRO_PREFIX([gl]) +gl_PO_DOMAIN([]) -- 1.6.4.226.g08063
Jim Meyering wrote:
Hi Rich,
Prompted by your "New commands to list devices by UUID and label" patch, I've adjusted it to use gnulib. ...
One additional patch is required, when building from scratch:
From a935ea923c434e14a4babc814db32bda1a5d3dbf Mon Sep 17 00:00:00 2001 From: Jim Meyering <meyering@redhat.com> Date: Wed, 5 Aug 2009 08:01:38 -0400 Subject: [PATCH] build: tell bootstrap about daemon/
* bootstrap: Run gnulib-tool --update in daemon/. --- bootstrap | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-) diff --git a/bootstrap b/bootstrap index d46b3be..8070efa 100755 --- a/bootstrap +++ b/bootstrap @@ -78,6 +78,8 @@ sed ' gnulib_tool=$GNULIB_SRCDIR/gnulib-tool <$gnulib_tool || exit +(cd daemon && $gnulib_tool --update) + modules=' gitlog-to-changelog gnu-make -- 1.6.4.226.g08063
Jim Meyering wrote:
Jim Meyering wrote:
Hi Rich,
Prompted by your "New commands to list devices by UUID and label" patch, I've adjusted it to use gnulib. ...
One additional patch is required, when building from scratch:
From a935ea923c434e14a4babc814db32bda1a5d3dbf Mon Sep 17 00:00:00 2001 From: Jim Meyering <meyering@redhat.com> Date: Wed, 5 Aug 2009 08:01:38 -0400 Subject: [PATCH] build: tell bootstrap about daemon/
* bootstrap: Run gnulib-tool --update in daemon/.
Here's a complete patch, relative to current HEAD. One additional change: remove bootstrap's --gnulib-srcdir option:
From 5e6e79972be244a3a73751461d3774c9681dd98f Mon Sep 17 00:00:00 2001 From: Jim Meyering <meyering@redhat.com> Date: Mon, 3 Aug 2009 11:44:51 +0100 Subject: [PATCH] daemon: use gnulib
* daemon/Makefile.am (SUBDIRS): Define. (AM_CPPFLAGS): Define, to include from gnulib's lib/ (LDADD): Define, to link with gnulib's libgnu.a. * daemon/configure.ac: Use AC_CONFIG_AUX_DIR([build-aux]), gl_EARLY and gl_INIT. (AC_CONFIG_FILES): Add lib/Makefile and tests/Makefile * daemon/m4/gnulib-cache.m4: New file, generated by running ../.gnulib/gnulib-tool --import --with-tests hash * daemon/.gitignore: Ignore all of the imported files. build: tell bootstrap about daemon/ * bootstrap: Run gnulib-tool --update in daemon/. Remove bootstrap's --gnulib-srcdir option, because it probably didn't work, and even if it did, we've discovered that using a separate git repo like that can lead to subtle mix-ups. --- bootstrap | 2 ++ daemon/.gitignore | 29 +++++++++++++++++++++++++++++ daemon/Makefile.am | 4 ++++ daemon/configure.ac | 6 +++++- daemon/m4/gnulib-cache.m4 | 35 +++++++++++++++++++++++++++++++++++ 5 files changed, 75 insertions(+), 1 deletions(-) create mode 100644 daemon/.gitignore create mode 100644 daemon/m4/gnulib-cache.m4 diff --git a/bootstrap b/bootstrap index d46b3be..0f14038 100755 --- a/bootstrap +++ b/bootstrap @@ -78,6 +78,8 @@ sed ' gnulib_tool=$GNULIB_SRCDIR/gnulib-tool <$gnulib_tool || exit +(cd daemon && $GNULIB_SRCDIR/../gnulib-tool --update) + modules=' gitlog-to-changelog gnu-make diff --git a/daemon/.gitignore b/daemon/.gitignore new file mode 100644 index 0000000..7f60faf --- /dev/null +++ b/daemon/.gitignore @@ -0,0 +1,29 @@ +build-aux +lib +link-warning.h +m4/00gnulib.m4 +m4/errno_h.m4 +m4/error.m4 +m4/exitfail.m4 +m4/extensions.m4 +m4/gnulib-common.m4 +m4/gnulib-comp.m4 +m4/gnulib-tool.m4 +m4/hash.m4 +m4/include_next.m4 +m4/inline.m4 +m4/inttostr.m4 +m4/longlong.m4 +m4/multiarch.m4 +m4/onceonly.m4 +m4/stdbool.m4 +m4/stdint.m4 +m4/stdlib_h.m4 +m4/strerror.m4 +m4/string_h.m4 +m4/unistd_h.m4 +m4/wchar.m4 +m4/wchar_t.m4 +m4/wint_t.m4 +m4/xalloc.m4 +tests diff --git a/daemon/Makefile.am b/daemon/Makefile.am index 024c097..43cc752 100644 --- a/daemon/Makefile.am +++ b/daemon/Makefile.am @@ -17,6 +17,8 @@ ACLOCAL_AMFLAGS = -I m4 +SUBDIRS = lib tests . + noinst_PROGRAMS = guestfsd guestfsd_SOURCES = \ actions.h \ @@ -76,4 +78,6 @@ guestfsd_SOURCES = \ $(top_builddir)/../src/guestfs_protocol.h \ $(top_builddir)/../src/guestfs_protocol.c +AM_CPPFLAGS = -I$(srcdir)/lib -Ilib guestfsd_CFLAGS = -Wall +LDADD = lib/libgnu.a diff --git a/daemon/configure.ac b/daemon/configure.ac index 3bfd2ed..126e125 100644 --- a/daemon/configure.ac +++ b/daemon/configure.ac @@ -16,6 +16,7 @@ # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. AC_INIT([libguestfs-daemon],[1.0.0]) +AC_CONFIG_AUX_DIR([build-aux]) AM_INIT_AUTOMAKE([foreign]) AC_CONFIG_MACRO_DIR([m4]) @@ -41,6 +42,9 @@ AC_PROG_CC AC_PROG_INSTALL AC_PROG_CPP +gl_EARLY +gl_INIT + AC_C_PROTOTYPES test "x$U" != "x" && AC_MSG_ERROR([Compiler not ANSI compliant]) @@ -86,5 +90,5 @@ AC_CHECK_HEADERS([attr/xattr.h sys/xattr.h]) dnl Produce output files. AC_CONFIG_HEADERS([config.h]) -AC_CONFIG_FILES([Makefile]) +AC_CONFIG_FILES([Makefile lib/Makefile tests/Makefile]) AC_OUTPUT diff --git a/daemon/m4/gnulib-cache.m4 b/daemon/m4/gnulib-cache.m4 new file mode 100644 index 0000000..8aa504a --- /dev/null +++ b/daemon/m4/gnulib-cache.m4 @@ -0,0 +1,35 @@ +# Copyright (C) 2002-2009 Free Software Foundation, Inc. +# +# This file is free software, distributed under the terms of the GNU +# General Public License. As a special exception to the GNU General +# Public License, this file may be distributed as part of a program +# that contains a configuration script generated by Autoconf, under +# the same distribution terms as the rest of that program. +# +# Generated by gnulib-tool. +# +# This file represents the specification of how gnulib-tool is used. +# It acts as a cache: It is written and read by gnulib-tool. +# In projects using CVS, this file is meant to be stored in CVS, +# like the configure.ac and various Makefile.am files. + + +# Specification in the form of a command-line invocation: +# gnulib-tool --import --dir=. --lib=libgnu --source-base=lib --m4-base=m4 --doc-base=doc --tests-base=tests --aux-dir=build-aux --with-tests --no-libtool --macro-prefix=gl hash + +# Specification in the form of a few gnulib-tool.m4 macro invocations: +gl_LOCAL_DIR([]) +gl_MODULES([ + hash +]) +gl_AVOID([]) +gl_SOURCE_BASE([lib]) +gl_M4_BASE([m4]) +gl_PO_BASE([]) +gl_DOC_BASE([doc]) +gl_TESTS_BASE([tests]) +gl_WITH_TESTS +gl_LIB([libgnu]) +gl_MAKEFILE_NAME([]) +gl_MACRO_PREFIX([gl]) +gl_PO_DOMAIN([]) -- 1.6.4.226.g08063
Jim Meyering wrote:
Jim Meyering wrote:
Jim Meyering wrote:
Hi Rich,
Prompted by your "New commands to list devices by UUID and label" patch, I've adjusted it to use gnulib. ...
One additional patch is required, when building from scratch:
From a935ea923c434e14a4babc814db32bda1a5d3dbf Mon Sep 17 00:00:00 2001 From: Jim Meyering <meyering@redhat.com> Date: Wed, 5 Aug 2009 08:01:38 -0400 Subject: [PATCH] build: tell bootstrap about daemon/
* bootstrap: Run gnulib-tool --update in daemon/.
Here's a complete patch, relative to current HEAD. One additional change: remove bootstrap's --gnulib-srcdir option:
From 5e6e79972be244a3a73751461d3774c9681dd98f Mon Sep 17 00:00:00 2001 From: Jim Meyering <meyering@redhat.com> Date: Mon, 3 Aug 2009 11:44:51 +0100 Subject: [PATCH] daemon: use gnulib
Rich just mentioned on IRC that the lack of daemon/tests and daemon/lib causes a problem. I hit that, manually created them and promptly forgot about it. Here's a patch to make bootstrap do the job for us: diff --git a/bootstrap b/bootstrap index 0f14038..aa3c5dc 100755 --- a/bootstrap +++ b/bootstrap @@ -78,7 +78,7 @@ sed ' gnulib_tool=$GNULIB_SRCDIR/gnulib-tool <$gnulib_tool || exit -(cd daemon && $GNULIB_SRCDIR/../gnulib-tool --update) +(cd daemon && mkdir -p tests lib && $GNULIB_SRCDIR/../gnulib-tool --update) modules=' gitlog-to-changelog
On Wed, Aug 05, 2009 at 12:31:15PM +0200, Jim Meyering wrote:
Prompted by your "New commands to list devices by UUID and label" patch, I've adjusted it to use gnulib.
While just compiling hash.[ch] is probably ok, in general (given the strict requirements of libguestfs) using the C files of a module is usually not an option, since you don't get the benefit of the module's m4 tests or automake snippets. For other modules, those pieces are often required.
To integrate gnulib into a project like this is not hard at all:
Sure - if we're happy to have effectively two copies of gnulib, then I don't see any problem with this patch. Since the second copy just uses hash, should be OK. Rich. -- Richard Jones, Emerging Technologies, Red Hat http://et.redhat.com/~rjones virt-top is 'top' for virtual machines. Tiny program with many powerful monitoring features, net stats, disk stats, logging, etc. http://et.redhat.com/~rjones/virt-top
Richard W.M. Jones wrote:
On Wed, Aug 05, 2009 at 12:31:15PM +0200, Jim Meyering wrote:
Prompted by your "New commands to list devices by UUID and label" patch, I've adjusted it to use gnulib.
While just compiling hash.[ch] is probably ok, in general (given the strict requirements of libguestfs) using the C files of a module is usually not an option, since you don't get the benefit of the module's m4 tests or automake snippets. For other modules, those pieces are often required.
To integrate gnulib into a project like this is not hard at all:
Sure - if we're happy to have effectively two copies of gnulib, then I don't see any problem with this patch. Since the second copy just uses hash, should be OK.
That works for me. FYI, it's not really two copies of gnulib (fortunately! it is 60MB, 18MB of which is the repo). It's a copy only of the pieces determined by selected modules: - top level sources are in gnulib/: 188K - daemon sources are in daemon/{lib,m4,tests}: 700K But source size is misleading, since most of the gnulib sources in daemon/ are used only in the unit tests.
participants (2)
-
Jim Meyering -
Richard W.M. Jones