Pino Toscano
2016-Sep-26 12:24 UTC
[Libguestfs] [PATCH 1/3] build: remove extra libconfig linkage
Some of the C tools were building also config.c as part of the shared sources from guestfish, and thus bringing a dependency on libconfig. Since none of them actually read the libguestfs configuration at all, then exclude fish/config.c from their build, and stop linking to libconfig. --- align/Makefile.am | 3 --- df/Makefile.am | 3 --- edit/Makefile.am | 3 --- format/Makefile.am | 3 --- inspector/Makefile.am | 5 +---- 5 files changed, 1 insertion(+), 16 deletions(-) diff --git a/align/Makefile.am b/align/Makefile.am index eb44263..13f8812 100644 --- a/align/Makefile.am +++ b/align/Makefile.am @@ -32,7 +32,6 @@ SHARED_SOURCE_FILES = \ ../df/estimate-max-threads.h \ ../df/parallel.c \ ../df/parallel.h \ - ../fish/config.c \ ../fish/decrypt.c \ ../fish/display-options.h \ ../fish/display-options.c \ @@ -59,12 +58,10 @@ virt_alignment_scan_CPPFLAGS = \ virt_alignment_scan_CFLAGS = \ -pthread \ $(WARN_CFLAGS) $(WERROR_CFLAGS) \ - $(LIBCONFIG_CFLAGS) \ $(LIBXML2_CFLAGS) \ $(LIBVIRT_CFLAGS) virt_alignment_scan_LDADD = \ - $(LIBCONFIG_LIBS) \ $(top_builddir)/src/libutils.la \ $(top_builddir)/src/libguestfs.la \ $(LIBXML2_LIBS) \ diff --git a/df/Makefile.am b/df/Makefile.am index 6efc1dc..f4a8602 100644 --- a/df/Makefile.am +++ b/df/Makefile.am @@ -27,7 +27,6 @@ EXTRA_DIST = \ bin_PROGRAMS = virt-df SHARED_SOURCE_FILES = \ - ../fish/config.c \ ../fish/decrypt.c \ ../fish/display-options.h \ ../fish/display-options.c \ @@ -62,12 +61,10 @@ virt_df_CPPFLAGS = \ virt_df_CFLAGS = \ -pthread \ $(WARN_CFLAGS) $(WERROR_CFLAGS) \ - $(LIBCONFIG_CFLAGS) \ $(LIBXML2_CFLAGS) \ $(LIBVIRT_CFLAGS) virt_df_LDADD = \ - $(LIBCONFIG_LIBS) \ $(top_builddir)/src/libutils.la \ $(top_builddir)/src/libguestfs.la \ $(LIBXML2_LIBS) \ diff --git a/edit/Makefile.am b/edit/Makefile.am index dc9fbb0..48ad52f 100644 --- a/edit/Makefile.am +++ b/edit/Makefile.am @@ -25,7 +25,6 @@ EXTRA_DIST = \ bin_PROGRAMS = virt-edit SHARED_SOURCE_FILES = \ - ../fish/config.c \ ../fish/decrypt.c \ ../fish/display-options.h \ ../fish/display-options.c \ @@ -54,11 +53,9 @@ virt_edit_CPPFLAGS = \ virt_edit_CFLAGS = \ $(WARN_CFLAGS) $(WERROR_CFLAGS) \ - $(LIBCONFIG_CFLAGS) \ $(LIBXML2_CFLAGS) virt_edit_LDADD = \ - $(LIBCONFIG_LIBS) \ $(top_builddir)/src/libutils.la \ $(top_builddir)/src/libguestfs.la \ $(LIBXML2_LIBS) \ diff --git a/format/Makefile.am b/format/Makefile.am index 0e881a5..6c22beb 100644 --- a/format/Makefile.am +++ b/format/Makefile.am @@ -25,7 +25,6 @@ EXTRA_DIST = \ bin_PROGRAMS = virt-format SHARED_SOURCE_FILES = \ - ../fish/config.c \ ../fish/decrypt.c \ ../fish/display-options.h \ ../fish/display-options.c \ @@ -50,12 +49,10 @@ virt_format_CPPFLAGS = \ virt_format_CFLAGS = \ $(WARN_CFLAGS) $(WERROR_CFLAGS) \ - $(LIBCONFIG_CFLAGS) \ $(LIBXML2_CFLAGS) \ $(LIBVIRT_CFLAGS) virt_format_LDADD = \ - $(LIBCONFIG_LIBS) \ $(top_builddir)/src/libutils.la \ $(top_builddir)/src/libguestfs.la \ $(LIBXML2_LIBS) \ diff --git a/inspector/Makefile.am b/inspector/Makefile.am index 760e810..a872f4b 100644 --- a/inspector/Makefile.am +++ b/inspector/Makefile.am @@ -53,7 +53,6 @@ dist_doc_DATA = \ bin_PROGRAMS = virt-inspector SHARED_SOURCE_FILES = \ - ../fish/config.c \ ../fish/decrypt.c \ ../fish/display-options.h \ ../fish/display-options.c \ @@ -79,11 +78,9 @@ virt_inspector_CPPFLAGS = \ virt_inspector_CFLAGS = \ $(WARN_CFLAGS) $(WERROR_CFLAGS) \ - $(LIBXML2_CFLAGS) \ - $(LIBCONFIG_CFLAGS) + $(LIBXML2_CFLAGS) virt_inspector_LDADD = \ - $(LIBCONFIG_LIBS) \ $(top_builddir)/src/libutils.la \ $(top_builddir)/src/libguestfs.la \ $(LIBXML2_LIBS) \ -- 2.7.4
Pino Toscano
2016-Sep-26 12:24 UTC
[Libguestfs] [PATCH 2/3] fish, inspector: get rid of COMPILING_VIRT_INSPECTOR
All the define was doing in options.h was masking the declaration of inspect_mount_root, which was always built-in in inspect.c (because of the unconditional #define there) anyway. Since this is common code used by all the C tools, try to avoid extra knobs which add different code paths for no benefit. --- fish/inspect.c | 1 - fish/options.h | 6 +----- inspector/Makefile.am | 1 - 3 files changed, 1 insertion(+), 7 deletions(-) diff --git a/fish/inspect.c b/fish/inspect.c index 4a5b3c3..edfd2d4 100644 --- a/fish/inspect.c +++ b/fish/inspect.c @@ -39,7 +39,6 @@ /* These definitions ensure we get all extern definitions from the header. */ #define COMPILING_GUESTFISH 1 -#define COMPILING_VIRT_INSPECTOR 1 #include "options.h" /* Global that saves the root device between inspect_mount and diff --git a/fish/options.h b/fish/options.h index e8a4ebc..a0863ad 100644 --- a/fish/options.h +++ b/fish/options.h @@ -119,17 +119,13 @@ extern int add_libvirt_drives (guestfs_h *g, const char *guest); /* in inspect.c */ extern void inspect_mount_handle (guestfs_h *g); +extern void inspect_mount_root (guestfs_h *g, const char *root); #define inspect_mount() inspect_mount_handle (g) #if COMPILING_GUESTFISH extern void print_inspect_prompt (void); #endif -#if COMPILING_VIRT_INSPECTOR -/* (low-level inspection functions, used by virt-inspector only) */ -extern void inspect_mount_root (guestfs_h *g, const char *root); -#endif - /* in key.c */ extern char *read_key (const char *param); diff --git a/inspector/Makefile.am b/inspector/Makefile.am index a872f4b..fe7bdab 100644 --- a/inspector/Makefile.am +++ b/inspector/Makefile.am @@ -69,7 +69,6 @@ virt_inspector_SOURCES = \ inspector.c virt_inspector_CPPFLAGS = \ - -DCOMPILING_VIRT_INSPECTOR=1 \ -DGUESTFS_WARN_DEPRECATED=1 \ -DLOCALEBASEDIR=\""$(datadir)/locale"\" \ -I$(top_srcdir)/src -I$(top_builddir)/src \ -- 2.7.4
Pino Toscano
2016-Sep-26 12:24 UTC
[Libguestfs] [PATCH 3/3] tools: build common fish sources in a static library
Create a new libfishcommon convenience static library to build just once (instead of 12 times!) the majority of the guestfish sources used in the rest of the C tools (mostly for command line stuff, inspection, and mount). The notable exceptions not using libfishcommon are guestfish itself, and virt-rescue: both need to build at least one of the common sources using additional CPPFLAGS. --- align/Makefile.am | 13 ++----------- cat/Makefile.am | 14 ++++---------- df/Makefile.am | 14 +------------- diff/Makefile.am | 13 ++----------- edit/Makefile.am | 11 +---------- fish/Makefile.am | 33 ++++++++++++++++++++++++++++----- format/Makefile.am | 14 +------------- fuse/Makefile.am | 13 ++----------- inspector/Makefile.am | 14 +------------- make-fs/Makefile.am | 10 +--------- 10 files changed, 43 insertions(+), 106 deletions(-) diff --git a/align/Makefile.am b/align/Makefile.am index 13f8812..8cf7e5c 100644 --- a/align/Makefile.am +++ b/align/Makefile.am @@ -31,17 +31,7 @@ SHARED_SOURCE_FILES = \ ../df/estimate-max-threads.c \ ../df/estimate-max-threads.h \ ../df/parallel.c \ - ../df/parallel.h \ - ../fish/decrypt.c \ - ../fish/display-options.h \ - ../fish/display-options.c \ - ../fish/domain.c \ - ../fish/inspect.c \ - ../fish/keys.c \ - ../fish/options.h \ - ../fish/options.c \ - ../fish/uri.h \ - ../fish/uri.c + ../df/parallel.h virt_alignment_scan_SOURCES = \ $(SHARED_SOURCE_FILES) \ @@ -64,6 +54,7 @@ virt_alignment_scan_CFLAGS = \ virt_alignment_scan_LDADD = \ $(top_builddir)/src/libutils.la \ $(top_builddir)/src/libguestfs.la \ + $(top_builddir)/fish/libfishcommon.la \ $(LIBXML2_LIBS) \ $(LIBVIRT_LIBS) \ $(LTLIBINTL) \ diff --git a/cat/Makefile.am b/cat/Makefile.am index 5e55742..796e808 100644 --- a/cat/Makefile.am +++ b/cat/Makefile.am @@ -31,16 +31,6 @@ EXTRA_DIST = \ bin_PROGRAMS = virt-cat virt-filesystems virt-log virt-ls SHARED_SOURCE_FILES = \ - ../fish/decrypt.c \ - ../fish/display-options.h \ - ../fish/display-options.c \ - ../fish/domain.c \ - ../fish/inspect.c \ - ../fish/keys.c \ - ../fish/options.h \ - ../fish/options.c \ - ../fish/uri.h \ - ../fish/uri.c \ ../fish/windows.h \ ../fish/windows.c @@ -62,6 +52,7 @@ virt_cat_CFLAGS = \ virt_cat_LDADD = \ $(top_builddir)/src/libutils.la \ $(top_builddir)/src/libguestfs.la \ + $(top_builddir)/fish/libfishcommon.la \ $(LIBXML2_LIBS) \ $(LIBVIRT_LIBS) \ $(LTLIBINTL) \ @@ -85,6 +76,7 @@ virt_filesystems_CFLAGS = \ virt_filesystems_LDADD = \ $(top_builddir)/src/libutils.la \ $(top_builddir)/src/libguestfs.la \ + $(top_builddir)/fish/libfishcommon.la \ $(LIBXML2_LIBS) \ $(LIBVIRT_LIBS) \ $(LTLIBINTL) \ @@ -108,6 +100,7 @@ virt_log_CFLAGS = \ virt_log_LDADD = \ $(top_builddir)/src/libutils.la \ $(top_builddir)/src/libguestfs.la \ + $(top_builddir)/fish/libfishcommon.la \ $(LIBXML2_LIBS) \ $(LIBVIRT_LIBS) \ $(LTLIBINTL) \ @@ -133,6 +126,7 @@ virt_ls_CFLAGS = \ virt_ls_LDADD = \ $(top_builddir)/src/libutils.la \ $(top_builddir)/src/libguestfs.la \ + $(top_builddir)/fish/libfishcommon.la \ $(LIBXML2_LIBS) \ $(LIBVIRT_LIBS) \ $(LTLIBINTL) \ diff --git a/df/Makefile.am b/df/Makefile.am index f4a8602..0735a8c 100644 --- a/df/Makefile.am +++ b/df/Makefile.am @@ -26,20 +26,7 @@ EXTRA_DIST = \ bin_PROGRAMS = virt-df -SHARED_SOURCE_FILES = \ - ../fish/decrypt.c \ - ../fish/display-options.h \ - ../fish/display-options.c \ - ../fish/domain.c \ - ../fish/inspect.c \ - ../fish/keys.c \ - ../fish/options.h \ - ../fish/options.c \ - ../fish/uri.h \ - ../fish/uri.c - virt_df_SOURCES = \ - $(SHARED_SOURCE_FILES) \ virt-df.h \ domains.c \ domains.h \ @@ -67,6 +54,7 @@ virt_df_CFLAGS = \ virt_df_LDADD = \ $(top_builddir)/src/libutils.la \ $(top_builddir)/src/libguestfs.la \ + $(top_builddir)/fish/libfishcommon.la \ $(LIBXML2_LIBS) \ $(LIBVIRT_LIBS) \ $(LTLIBINTL) \ diff --git a/diff/Makefile.am b/diff/Makefile.am index 7dfe2cd..921cf23 100644 --- a/diff/Makefile.am +++ b/diff/Makefile.am @@ -26,17 +26,7 @@ bin_PROGRAMS = virt-diff SHARED_SOURCE_FILES = \ ../cat/visit.h \ - ../cat/visit.c \ - ../fish/decrypt.c \ - ../fish/display-options.h \ - ../fish/display-options.c \ - ../fish/domain.c \ - ../fish/inspect.c \ - ../fish/keys.c \ - ../fish/options.h \ - ../fish/options.c \ - ../fish/uri.h \ - ../fish/uri.c + ../cat/visit.c virt_diff_SOURCES = \ $(SHARED_SOURCE_FILES) \ @@ -56,6 +46,7 @@ virt_diff_CFLAGS = \ virt_diff_LDADD = \ $(top_builddir)/src/libutils.la \ $(top_builddir)/src/libguestfs.la \ + $(top_builddir)/fish/libfishcommon.la \ $(LIBXML2_LIBS) \ $(LIBVIRT_LIBS) \ $(LTLIBINTL) \ diff --git a/edit/Makefile.am b/edit/Makefile.am index 48ad52f..cac9e6a 100644 --- a/edit/Makefile.am +++ b/edit/Makefile.am @@ -25,18 +25,8 @@ EXTRA_DIST = \ bin_PROGRAMS = virt-edit SHARED_SOURCE_FILES = \ - ../fish/decrypt.c \ - ../fish/display-options.h \ - ../fish/display-options.c \ - ../fish/domain.c \ ../fish/file-edit.h \ ../fish/file-edit.c \ - ../fish/inspect.c \ - ../fish/keys.c \ - ../fish/options.h \ - ../fish/options.c \ - ../fish/uri.h \ - ../fish/uri.c \ ../fish/windows.h \ ../fish/windows.c @@ -58,6 +48,7 @@ virt_edit_CFLAGS = \ virt_edit_LDADD = \ $(top_builddir)/src/libutils.la \ $(top_builddir)/src/libguestfs.la \ + $(top_builddir)/fish/libfishcommon.la \ $(LIBXML2_LIBS) \ $(LIBVIRT_LIBS) \ $(LTLIBINTL) \ diff --git a/fish/Makefile.am b/fish/Makefile.am index 8fdcd27..924de1f 100644 --- a/fish/Makefile.am +++ b/fish/Makefile.am @@ -71,8 +71,7 @@ EXTRA_DIST = \ # between guestfish, guestmount and some other virt tools. Keep a # convenient list here just so we know which ones are shared. These # files must not include other guestfish files. -SHARED_SOURCE_FILES = \ - config.c \ +FISHCOMMON_SOURCE_FILES = \ decrypt.c \ display-options.h \ display-options.c \ @@ -81,11 +80,35 @@ SHARED_SOURCE_FILES = \ keys.c \ options.h \ options.c \ - progress.h \ - progress.c \ uri.h \ uri.c +SHARED_SOURCE_FILES = \ + $(FISHCOMMON_SOURCE_FILES) \ + config.c \ + progress.h \ + progress.c + +# libfishcommon.la contains guestfish code which is used in other +# C tools. Note this convenience static library is *not* used in +# guestfish, as the sources are built with extra defines +# (e.g. -DCOMPILING_GUESTFISH) in that case. +libfishcommon_la_SOURCES = \ + $(FISHCOMMON_SOURCE_FILES) +libfishcommon_la_CPPFLAGS = \ + -DGUESTFS_WARN_DEPRECATED=1 \ + -I$(top_srcdir)/src -I$(top_builddir)/src \ + -I$(top_srcdir)/fish -I$(top_builddir)/fish \ + -I$(srcdir)/../gnulib/lib -I../gnulib/lib +libfishcommon_la_CFLAGS = \ + $(WARN_CFLAGS) $(WERROR_CFLAGS) \ + $(LIBXML2_CFLAGS) +libfishcommon_la_LIBADD = \ + $(top_builddir)/src/libguestfs.la \ + $(top_builddir)/src/libutils.la \ + $(LIBXML2_LIBS) \ + $(LTLIBINTL) + guestfish_SOURCES = \ $(generator_built) \ $(SHARED_SOURCE_FILES) \ @@ -159,7 +182,7 @@ guestfish_LDADD = \ -lm # Make guestfish use the convenience libraries. -noinst_LTLIBRARIES = libcmds.la librc_protocol.la +noinst_LTLIBRARIES = libcmds.la librc_protocol.la libfishcommon.la guestfish_LDADD += libcmds.la librc_protocol.la ../gnulib/lib/libgnu.la if HAVE_RPCGEN diff --git a/format/Makefile.am b/format/Makefile.am index 6c22beb..6eabd8a 100644 --- a/format/Makefile.am +++ b/format/Makefile.am @@ -24,20 +24,7 @@ EXTRA_DIST = \ bin_PROGRAMS = virt-format -SHARED_SOURCE_FILES = \ - ../fish/decrypt.c \ - ../fish/display-options.h \ - ../fish/display-options.c \ - ../fish/domain.c \ - ../fish/inspect.c \ - ../fish/keys.c \ - ../fish/options.h \ - ../fish/options.c \ - ../fish/uri.h \ - ../fish/uri.c - virt_format_SOURCES = \ - $(SHARED_SOURCE_FILES) \ format.c virt_format_CPPFLAGS = \ @@ -55,6 +42,7 @@ virt_format_CFLAGS = \ virt_format_LDADD = \ $(top_builddir)/src/libutils.la \ $(top_builddir)/src/libguestfs.la \ + $(top_builddir)/fish/libfishcommon.la \ $(LIBXML2_LIBS) \ $(LIBVIRT_LIBS) \ $(LTLIBINTL) \ diff --git a/fuse/Makefile.am b/fuse/Makefile.am index b8f5ad6..9db0215 100644 --- a/fuse/Makefile.am +++ b/fuse/Makefile.am @@ -33,17 +33,7 @@ bin_PROGRAMS = \ # These source files (all related to option parsing) are shared # between guestfish and guestmount. SHARED_SOURCE_FILES = \ - ../fish/config.c \ - ../fish/decrypt.c \ - ../fish/display-options.h \ - ../fish/display-options.c \ - ../fish/domain.c \ - ../fish/inspect.c \ - ../fish/keys.c \ - ../fish/options.h \ - ../fish/options.c \ - ../fish/uri.h \ - ../fish/uri.c + ../fish/config.c # guestmount @@ -69,6 +59,7 @@ guestmount_LDADD = \ $(LIBCONFIG_LIBS) \ $(top_builddir)/src/libutils.la \ $(top_builddir)/src/libguestfs.la \ + $(top_builddir)/fish/libfishcommon.la \ $(LIBXML2_LIBS) \ $(LIBVIRT_LIBS) \ $(LTLIBINTL) \ diff --git a/inspector/Makefile.am b/inspector/Makefile.am index fe7bdab..275bc7c 100644 --- a/inspector/Makefile.am +++ b/inspector/Makefile.am @@ -52,20 +52,7 @@ dist_doc_DATA = \ bin_PROGRAMS = virt-inspector -SHARED_SOURCE_FILES = \ - ../fish/decrypt.c \ - ../fish/display-options.h \ - ../fish/display-options.c \ - ../fish/domain.c \ - ../fish/inspect.c \ - ../fish/keys.c \ - ../fish/options.h \ - ../fish/options.c \ - ../fish/uri.h \ - ../fish/uri.c - virt_inspector_SOURCES = \ - $(SHARED_SOURCE_FILES) \ inspector.c virt_inspector_CPPFLAGS = \ @@ -82,6 +69,7 @@ virt_inspector_CFLAGS = \ virt_inspector_LDADD = \ $(top_builddir)/src/libutils.la \ $(top_builddir)/src/libguestfs.la \ + $(top_builddir)/fish/libfishcommon.la \ $(LIBXML2_LIBS) \ $(LIBVIRT_LIBS) \ $(LTLIBINTL) \ diff --git a/make-fs/Makefile.am b/make-fs/Makefile.am index f4cf0f1..719bc51 100644 --- a/make-fs/Makefile.am +++ b/make-fs/Makefile.am @@ -24,16 +24,7 @@ EXTRA_DIST = \ bin_PROGRAMS = virt-make-fs -SHARED_SOURCE_FILES = \ - ../fish/display-options.h \ - ../fish/display-options.c \ - ../fish/domain.c \ - ../fish/options.h \ - ../fish/options.c \ - ../fish/uri.c - virt_make_fs_SOURCES = \ - $(SHARED_SOURCE_FILES) \ make-fs.c virt_make_fs_CPPFLAGS = \ @@ -50,6 +41,7 @@ virt_make_fs_CFLAGS = \ virt_make_fs_LDADD = \ $(top_builddir)/src/libutils.la \ $(top_builddir)/src/libguestfs.la \ + $(top_builddir)/fish/libfishcommon.la \ $(LIBXML2_LIBS) \ $(LTLIBINTL) \ ../gnulib/lib/libgnu.la -- 2.7.4
Richard W.M. Jones
2016-Sep-26 12:28 UTC
Re: [Libguestfs] [PATCH 3/3] tools: build common fish sources in a static library
ACK series. Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones Read my programming and virtualization blog: http://rwmj.wordpress.com virt-builder quickly builds VMs from scratch http://libguestfs.org/virt-builder.1.html
Possibly Parallel Threads
- [PATCH 1/3] build: remove extra libconfig linkage
- [PATCH v2 2/7] lib: Move utilities to new directory common/utils.
- [PATCH 3/9] build: check for libintl, and use it
- Re: [PATCH 3/9] build: check for libintl, and use it
- [PATCH v6 05/41] utils: Split out cleanups into common/cleanups.