[Libguestfs] [PATCH] gobject: Move headers into a subdirectory
Richard W.M. Jones
rjones at redhat.com
Thu Apr 26 12:54:47 UTC 2012
On Thu, Apr 26, 2012 at 01:35:09PM +0100, Matthew Booth wrote:
> The gobject bindings generate a large number of header files, which pollute
> /usr/include when installed. This patch moves them all into a guestfs-gobject/
> subdirectory. guestfs-gobject.h remains in the same place.
>
> This change also moves generated source files into src/, because it makes the
> gobject directory a bit tidier.
> ---
> generator/Makefile.am | 3 +
> generator/generator_gobject.ml | 20 ++---
> gobject/.gitignore | 3 +
> gobject/Makefile.am | 5 +-
> gobject/Makefile.inc | 162 ++++++++++++++++++++--------------------
> gobject/docs/Makefile.am | 8 +-
> 6 files changed, 104 insertions(+), 97 deletions(-)
> create mode 100644 gobject/.gitignore
>
> diff --git a/generator/Makefile.am b/generator/Makefile.am
> index fd37f67..eb6b79d 100644
> --- a/generator/Makefile.am
> +++ b/generator/Makefile.am
> @@ -107,6 +107,9 @@ stamp-generator: generator
> mkdir -p $(top_srcdir)/ruby/ext/guestfs
> mkdir -p $(top_srcdir)/java/com/redhat/et/libguestfs
> mkdir -p $(top_srcdir)/csharp
> + mkdir -p $(top_srcdir)/gobject/src
> + mkdir -p $(top_srcdir)/gobject/include
> + mkdir -p $(top_srcdir)/gobject/include/guestfs-gobject
> cd $(top_srcdir) && generator/generator
>
> CLEANFILES = $(noinst_DATA) $(noinst_PROGRAM) *.cmi *.cmo *~
> diff --git a/generator/generator_gobject.ml b/generator/generator_gobject.ml
> index 312ecb4..17c6c36 100644
> --- a/generator/generator_gobject.ml
> +++ b/generator/generator_gobject.ml
> @@ -126,7 +126,7 @@ let output_filenames =
> )
>
> let output_header filename f =
> - let header = sprintf "gobject/guestfs-gobject-%s.h" filename in
> + let header = sprintf "gobject/include/guestfs-gobject/%s.h" filename in
> let guard = Str.global_replace (Str.regexp "-") "_" filename in
> let guard = "GUESTFS_GOBJECT_" ^ String.uppercase guard ^ "_H__" in
> output_to header (fun () ->
> @@ -152,15 +152,14 @@ G_END_DECLS
> )
>
> let output_source filename ?(title=None) ?(shortdesc=None) ?(longdesc=None) f =
> - let file = sprintf "guestfs-gobject-%s" filename in
> - let source = sprintf "gobject/%s.c" file in
> + let source = sprintf "gobject/src/%s.c" filename in
> output_to source (fun () ->
> generate_header CStyle GPLv2plus;
>
> pr "#include \"guestfs-gobject.h\"\n\n";
>
> pr "/**\n";
> - pr " * SECTION:%s\n" file;
> + pr " * SECTION:%s\n" filename;
>
> (match title with
> | Some title ->
> @@ -188,19 +187,20 @@ let output_source filename ?(title=None) ?(shortdesc=None) ?(longdesc=None) f =
> let generate_gobject_makefile () =
> generate_header HashStyle GPLv2plus;
> let headers =
> - List.map (function n -> sprintf "guestfs-gobject-%s.h" n) output_filenames
> + List.map
> + (function n -> sprintf "include/guestfs-gobject/%s.h" n) output_filenames
> in
> let sources =
> - List.map (function n -> sprintf "guestfs-gobject-%s.c" n) output_filenames
> + List.map (function n -> sprintf "src/%s.c" n) output_filenames
> in
> - pr "guestfs_gobject_headers=\\\n guestfs-gobject.h \\\n %s\n\n"
> + pr "guestfs_gobject_headers=\\\n include/guestfs-gobject.h \\\n %s\n\n"
> (String.concat " \\\n " headers);
> pr "guestfs_gobject_sources=\\\n %s\n" (String.concat " \\\n " sources)
>
> let generate_gobject_header () =
> generate_header CStyle GPLv2plus;
> List.iter
> - (function f -> pr "#include <guestfs-gobject-%s.h>\n" f)
> + (function f -> pr "#include <guestfs-gobject/%s.h>\n" f)
> output_filenames
>
> let generate_gobject_doc_title () =
> @@ -216,7 +216,7 @@ let generate_gobject_doc_title () =
> ";
>
> List.iter (
> - function n -> pr " <xi:include href=\"xml/guestfs-gobject-%s.xml\"/>\n" n
> + function n -> pr " <xi:include href=\"xml/%s.xml\"/>\n" n
> ) output_filenames;
>
> pr "</chapter>\n"
> @@ -1286,7 +1286,7 @@ guestfs_session_close(GuestfsSession *session, GError **err)
>
> let generate_gobject () =
> output_to "gobject/Makefile.inc" generate_gobject_makefile;
> - output_to "gobject/guestfs-gobject.h" generate_gobject_header;
> + output_to "gobject/include/guestfs-gobject.h" generate_gobject_header;
> output_to "gobject/docs/guestfs-title.sgml" generate_gobject_doc_title;
>
> generate_gobject_structs;
> diff --git a/gobject/.gitignore b/gobject/.gitignore
> new file mode 100644
> index 0000000..9dbad7b
> --- /dev/null
> +++ b/gobject/.gitignore
> @@ -0,0 +1,3 @@
> +# Generated sources
> +/include
> +/src
> diff --git a/gobject/Makefile.am b/gobject/Makefile.am
> index d482d21..e28a8b1 100644
> --- a/gobject/Makefile.am
> +++ b/gobject/Makefile.am
> @@ -39,7 +39,8 @@ libguestfs_gobject_1_0_ladir = $(includedir)
>
> libguestfs_gobject_1_0_la_HEADERS = $(guestfs_gobject_headers)
> libguestfs_gobject_1_0_la_SOURCES = $(guestfs_gobject_sources)
> -libguestfs_gobject_1_0_la_CFLAGS = -I$(top_srcdir)/src $(GOBJECT_CFLAGS)
> +libguestfs_gobject_1_0_la_CFLAGS = -I$(top_srcdir)/src -I$(srcdir)/include \
> + $(GOBJECT_CFLAGS)
> libguestfs_gobject_1_0_la_LIBS = $(GOBJECT_LIBS)
> libguestfs_gobject_1_0_la_LDFLAGS = $(LDFLAGS) -L$(top_builddir)/src
> libguestfs_gobject_1_0_la_LIBADD = -lguestfs
> @@ -56,7 +57,7 @@ introspection_sources = \
>
> Guestfs-1.0.gir: $(libname)
> Guestfs_1_0_gir_INCLUDES = GObject-2.0 Gio-2.0
> -Guestfs_1_0_gir_CFLAGS = $(INCLUDES) -I$(srcdir)
> +Guestfs_1_0_gir_CFLAGS = $(INCLUDES) -I$(srcdir)/include
> Guestfs_1_0_gir_LIBS = $(libname)
> Guestfs_1_0_gir_FILES = $(introspection_sources)
> INTROSPECTION_GIRS += Guestfs-1.0.gir
> diff --git a/gobject/Makefile.inc b/gobject/Makefile.inc
> index 69bb44b..22ea052 100644
> --- a/gobject/Makefile.inc
> +++ b/gobject/Makefile.inc
> @@ -20,86 +20,86 @@
> # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
>
> guestfs_gobject_headers=\
> - guestfs-gobject.h \
> - guestfs-gobject-session.h \
> - guestfs-gobject-tristate.h \
> - guestfs-gobject-struct-int_bool.h \
> - guestfs-gobject-struct-lvm_pv.h \
> - guestfs-gobject-struct-lvm_vg.h \
> - guestfs-gobject-struct-lvm_lv.h \
> - guestfs-gobject-struct-stat.h \
> - guestfs-gobject-struct-statvfs.h \
> - guestfs-gobject-struct-dirent.h \
> - guestfs-gobject-struct-version.h \
> - guestfs-gobject-struct-xattr.h \
> - guestfs-gobject-struct-inotify_event.h \
> - guestfs-gobject-struct-partition.h \
> - guestfs-gobject-struct-application.h \
> - guestfs-gobject-struct-isoinfo.h \
> - guestfs-gobject-struct-mdstat.h \
> - guestfs-gobject-struct-btrfssubvolume.h \
> - guestfs-gobject-optargs-test0.h \
> - guestfs-gobject-optargs-add_drive_opts.h \
> - guestfs-gobject-optargs-add_domain.h \
> - guestfs-gobject-optargs-inspect_get_icon.h \
> - guestfs-gobject-optargs-mount_local.h \
> - guestfs-gobject-optargs-umount_local.h \
> - guestfs-gobject-optargs-mkfs_opts.h \
> - guestfs-gobject-optargs-mount_9p.h \
> - guestfs-gobject-optargs-ntfsresize_opts.h \
> - guestfs-gobject-optargs-btrfs_filesystem_resize.h \
> - guestfs-gobject-optargs-compress_out.h \
> - guestfs-gobject-optargs-compress_device_out.h \
> - guestfs-gobject-optargs-copy_device_to_device.h \
> - guestfs-gobject-optargs-copy_device_to_file.h \
> - guestfs-gobject-optargs-copy_file_to_device.h \
> - guestfs-gobject-optargs-copy_file_to_file.h \
> - guestfs-gobject-optargs-tune2fs.h \
> - guestfs-gobject-optargs-md_create.h \
> - guestfs-gobject-optargs-e2fsck.h \
> - guestfs-gobject-optargs-ntfsfix.h \
> - guestfs-gobject-optargs-ntfsclone_out.h \
> - guestfs-gobject-optargs-mkfs_btrfs.h \
> - guestfs-gobject-optargs-set_e2attrs.h
> + include/guestfs-gobject.h \
> + include/guestfs-gobject/session.h \
> + include/guestfs-gobject/tristate.h \
> + include/guestfs-gobject/struct-int_bool.h \
> + include/guestfs-gobject/struct-lvm_pv.h \
> + include/guestfs-gobject/struct-lvm_vg.h \
> + include/guestfs-gobject/struct-lvm_lv.h \
> + include/guestfs-gobject/struct-stat.h \
> + include/guestfs-gobject/struct-statvfs.h \
> + include/guestfs-gobject/struct-dirent.h \
> + include/guestfs-gobject/struct-version.h \
> + include/guestfs-gobject/struct-xattr.h \
> + include/guestfs-gobject/struct-inotify_event.h \
> + include/guestfs-gobject/struct-partition.h \
> + include/guestfs-gobject/struct-application.h \
> + include/guestfs-gobject/struct-isoinfo.h \
> + include/guestfs-gobject/struct-mdstat.h \
> + include/guestfs-gobject/struct-btrfssubvolume.h \
> + include/guestfs-gobject/optargs-test0.h \
> + include/guestfs-gobject/optargs-add_drive_opts.h \
> + include/guestfs-gobject/optargs-add_domain.h \
> + include/guestfs-gobject/optargs-inspect_get_icon.h \
> + include/guestfs-gobject/optargs-mount_local.h \
> + include/guestfs-gobject/optargs-umount_local.h \
> + include/guestfs-gobject/optargs-mkfs_opts.h \
> + include/guestfs-gobject/optargs-mount_9p.h \
> + include/guestfs-gobject/optargs-ntfsresize_opts.h \
> + include/guestfs-gobject/optargs-btrfs_filesystem_resize.h \
> + include/guestfs-gobject/optargs-compress_out.h \
> + include/guestfs-gobject/optargs-compress_device_out.h \
> + include/guestfs-gobject/optargs-copy_device_to_device.h \
> + include/guestfs-gobject/optargs-copy_device_to_file.h \
> + include/guestfs-gobject/optargs-copy_file_to_device.h \
> + include/guestfs-gobject/optargs-copy_file_to_file.h \
> + include/guestfs-gobject/optargs-tune2fs.h \
> + include/guestfs-gobject/optargs-md_create.h \
> + include/guestfs-gobject/optargs-e2fsck.h \
> + include/guestfs-gobject/optargs-ntfsfix.h \
> + include/guestfs-gobject/optargs-ntfsclone_out.h \
> + include/guestfs-gobject/optargs-mkfs_btrfs.h \
> + include/guestfs-gobject/optargs-set_e2attrs.h
>
> guestfs_gobject_sources=\
> - guestfs-gobject-session.c \
> - guestfs-gobject-tristate.c \
> - guestfs-gobject-struct-int_bool.c \
> - guestfs-gobject-struct-lvm_pv.c \
> - guestfs-gobject-struct-lvm_vg.c \
> - guestfs-gobject-struct-lvm_lv.c \
> - guestfs-gobject-struct-stat.c \
> - guestfs-gobject-struct-statvfs.c \
> - guestfs-gobject-struct-dirent.c \
> - guestfs-gobject-struct-version.c \
> - guestfs-gobject-struct-xattr.c \
> - guestfs-gobject-struct-inotify_event.c \
> - guestfs-gobject-struct-partition.c \
> - guestfs-gobject-struct-application.c \
> - guestfs-gobject-struct-isoinfo.c \
> - guestfs-gobject-struct-mdstat.c \
> - guestfs-gobject-struct-btrfssubvolume.c \
> - guestfs-gobject-optargs-test0.c \
> - guestfs-gobject-optargs-add_drive_opts.c \
> - guestfs-gobject-optargs-add_domain.c \
> - guestfs-gobject-optargs-inspect_get_icon.c \
> - guestfs-gobject-optargs-mount_local.c \
> - guestfs-gobject-optargs-umount_local.c \
> - guestfs-gobject-optargs-mkfs_opts.c \
> - guestfs-gobject-optargs-mount_9p.c \
> - guestfs-gobject-optargs-ntfsresize_opts.c \
> - guestfs-gobject-optargs-btrfs_filesystem_resize.c \
> - guestfs-gobject-optargs-compress_out.c \
> - guestfs-gobject-optargs-compress_device_out.c \
> - guestfs-gobject-optargs-copy_device_to_device.c \
> - guestfs-gobject-optargs-copy_device_to_file.c \
> - guestfs-gobject-optargs-copy_file_to_device.c \
> - guestfs-gobject-optargs-copy_file_to_file.c \
> - guestfs-gobject-optargs-tune2fs.c \
> - guestfs-gobject-optargs-md_create.c \
> - guestfs-gobject-optargs-e2fsck.c \
> - guestfs-gobject-optargs-ntfsfix.c \
> - guestfs-gobject-optargs-ntfsclone_out.c \
> - guestfs-gobject-optargs-mkfs_btrfs.c \
> - guestfs-gobject-optargs-set_e2attrs.c
> + src/session.c \
> + src/tristate.c \
> + src/struct-int_bool.c \
> + src/struct-lvm_pv.c \
> + src/struct-lvm_vg.c \
> + src/struct-lvm_lv.c \
> + src/struct-stat.c \
> + src/struct-statvfs.c \
> + src/struct-dirent.c \
> + src/struct-version.c \
> + src/struct-xattr.c \
> + src/struct-inotify_event.c \
> + src/struct-partition.c \
> + src/struct-application.c \
> + src/struct-isoinfo.c \
> + src/struct-mdstat.c \
> + src/struct-btrfssubvolume.c \
> + src/optargs-test0.c \
> + src/optargs-add_drive_opts.c \
> + src/optargs-add_domain.c \
> + src/optargs-inspect_get_icon.c \
> + src/optargs-mount_local.c \
> + src/optargs-umount_local.c \
> + src/optargs-mkfs_opts.c \
> + src/optargs-mount_9p.c \
> + src/optargs-ntfsresize_opts.c \
> + src/optargs-btrfs_filesystem_resize.c \
> + src/optargs-compress_out.c \
> + src/optargs-compress_device_out.c \
> + src/optargs-copy_device_to_device.c \
> + src/optargs-copy_device_to_file.c \
> + src/optargs-copy_file_to_device.c \
> + src/optargs-copy_file_to_file.c \
> + src/optargs-tune2fs.c \
> + src/optargs-md_create.c \
> + src/optargs-e2fsck.c \
> + src/optargs-ntfsfix.c \
> + src/optargs-ntfsclone_out.c \
> + src/optargs-mkfs_btrfs.c \
> + src/optargs-set_e2attrs.c
> diff --git a/gobject/docs/Makefile.am b/gobject/docs/Makefile.am
> index 4ea8a28..f43ec9c 100644
> --- a/gobject/docs/Makefile.am
> +++ b/gobject/docs/Makefile.am
> @@ -28,7 +28,7 @@ DOC_MAIN_SGML_FILE=$(DOC_MODULE)-docs.sgml
> # gtk-doc will search all .c and .h files beneath these paths
> # for inline comments documenting functions and macros.
> # e.g. DOC_SOURCE_DIR=$(top_srcdir)/gtk $(top_srcdir)/gdk
> -DOC_SOURCE_DIR=$(srcdir)/..
> +DOC_SOURCE_DIR=$(srcdir)/../src $(srcdir)/../include
>
> # Extra options to pass to gtkdoc-scangobj. Not normally needed.
> SCANGOBJ_OPTIONS=
> @@ -55,8 +55,8 @@ FIXXREF_OPTIONS=
> # Used for dependencies. The docs will be rebuilt if any of these change.
> # e.g. HFILE_GLOB=$(top_srcdir)/gtk/*.h
> # e.g. CFILE_GLOB=$(top_srcdir)/gtk/*.c
> -HFILE_GLOB=$(srcdir)/../*.h
> -CFILE_GLOB=$(srcdir)/../*.c
> +HFILE_GLOB=$(srcdir)/../include/guestfs-gobject/*.h
> +CFILE_GLOB=$(srcdir)/../src/*.c
>
> # Extra header to include when scanning, which are not under DOC_SOURCE_DIR
> # e.g. EXTRA_HFILES=$(top_srcdir}/contrib/extra.h
> @@ -64,7 +64,7 @@ EXTRA_HFILES=
>
> # Header files or dirs to ignore when scanning. Use base file/dir names
> # e.g. IGNORE_HFILES=gtkdebug.h gtkintl.h private_code
> -IGNORE_HFILES=$(srcdir)/../guestfs-gobject.h
> +IGNORE_HFILES=
>
> # Images to copy into HTML directory.
> # e.g. HTML_IMAGES=$(top_srcdir)/gtk/stock-icons/stock_about_24.png
ACK.
We don't have a libguestfs-gobject.pc file. Should be have one?
Rich.
--
Richard Jones, Virtualization Group, Red Hat http://people.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
More information about the Libguestfs
mailing list