[libvirt] [PATCH 5/7] src: Simplify installing/uninstalling data

Andrea Bolognani abologna at redhat.com
Wed Jan 9 18:35:52 UTC 2019


Instead of defining targets conditionally and depending on
them unconditionally, define a couple of variables and
conditionally add targets to them.

In addition to removing a bunch of useless code, this has
the nice effect of no longer requiring the main Makefile.am
to have any knowledge about the contents of the various
snippets it includes.

Signed-off-by: Andrea Bolognani <abologna at redhat.com>
---
 src/Makefile.am            | 54 ++++++++++++++++----------------------
 src/remote/Makefile.inc.am | 30 +++++++++------------
 2 files changed, 34 insertions(+), 50 deletions(-)

diff --git a/src/Makefile.am b/src/Makefile.am
index d3e8a1b572..ce1a810a0f 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -72,6 +72,8 @@ STATEFUL_DRIVER_SOURCE_FILES =
 noinst_LTLIBRARIES =
 mod_LTLIBRARIES =
 INSTALL_DATA_DIRS =
+INSTALL_DATA_LOCAL =
+UNINSTALL_LOCAL =
 libvirt_la_BUILT_LIBADD =
 SYM_FILES =
 USED_SYM_FILES =
@@ -805,10 +807,10 @@ install-logrotate: $(LOGROTATE_FILES)
 uninstall-logrotate:
 	rm -f $(LOGROTATE_FILES:%.logrotate=$(DESTDIR)$(sysconfdir)/logrotate.d/%)
 	rmdir $(DESTDIR)$(sysconfdir)/logrotate.d || :
-else ! WITH_LIBVIRTD
-install-logrotate:
-uninstall-logrotate:
-endif ! WITH_LIBVIRTD
+
+INSTALL_DATA_LOCAL += install-logrotate
+UNINSTALL_LOCAL += uninstall-logrotate
+endif WITH_LIBVIRTD
 
 if LIBVIRT_INIT_SCRIPT_RED_HAT
 install-init:: $(SYSVINIT_FILES) install-sysconfig
@@ -824,10 +826,10 @@ uninstall-init:: uninstall-sysconfig
 
 BUILT_SOURCES += $(SYSVINIT_FILES)
 DISTCLEANFILES += $(SYSVINIT_FILES)
-else ! LIBVIRT_INIT_SCRIPT_RED_HAT
-install-init::
-uninstall-init::
-endif ! LIBVIRT_INIT_SCRIPT_RED_HAT
+
+INSTALL_DATA_LOCAL += install-init
+UNINSTALL_LOCAL += uninstall-init
+endif LIBVIRT_INIT_SCRIPT_RED_HAT
 
 
 %.8: %.8.in $(top_srcdir)/configure.ac
@@ -847,7 +849,6 @@ EXTRA_DIST += \
         $(NULL)
 
 
-if WITH_LIBVIRTD
 if LIBVIRT_INIT_SCRIPT_SYSTEMD
 
 SYSTEMD_UNIT_DIR = $(prefix)/lib/systemd/system
@@ -866,19 +867,14 @@ install-systemd: $(SYSTEMD_UNIT_FILES) install-sysconfig
 uninstall-systemd: uninstall-sysconfig
 	rm -f $(SYSTEMD_UNIT_FILES:%=$(DESTDIR)$(SYSTEMD_UNIT_DIR)/%)
 	rmdir $(DESTDIR)$(SYSTEMD_UNIT_DIR) || :
-else ! LIBVIRT_INIT_SCRIPT_SYSTEMD
-install-systemd:
-uninstall-systemd:
-endif ! LIBVIRT_INIT_SCRIPT_SYSTEMD
-else ! WITH_LIBVIRTD
-install-systemd:
-uninstall-systemd:
-endif ! WITH_LIBVIRTD
+
+INSTALL_DATA_LOCAL += install-systemd
+UNINSTALL_LOCAL += uninstall-systemd
+endif LIBVIRT_INIT_SCRIPT_SYSTEMD
 
 
 EXTRA_DIST += $(UPSTART_FILES)
 
-if WITH_LIBVIRTD
 if LIBVIRT_INIT_SCRIPT_UPSTART
 
 install-upstart: install-sysconfig
@@ -897,14 +893,10 @@ uninstall-upstart: uninstall-sysconfig
 	  rm -f $(DESTDIR)$(sysconfdir)/event.d/$$tgt ; \
 	done
 	rmdir $(DESTDIR)$(sysconfdir)/event.d || :
-else ! LIBVIRT_INIT_SCRIPT_UPSTART
-install-upstart:
-uninstall-upstart:
-endif ! LIBVIRT_INIT_SCRIPT_UPSTART
-else ! WITH_LIBVIRTD
-install-upstart:
-uninstall-upstart:
-endif ! WITH_LIBVIRTD
+
+INSTALL_DATA_LOCAL += install-upstart
+UNINSTALL_LOCAL += uninstall-upstart
+endif LIBVIRT_INIT_SCRIPT_UPSTART
 
 
 EXTRA_DIST += dtrace2systemtap.pl
@@ -1003,17 +995,15 @@ libvirt_nss_la_LIBADD = \
 endif WITH_NSS
 
 
-install-data-local: install-init install-systemd install-upstart \
-		install-sysctl install-polkit install-sasl \
-		install-logrotate $(INSTALL_DATA_DIRS:%=install-data-%)
+install-data-local: $(INSTALL_DATA_LOCAL) \
+		$(INSTALL_DATA_DIRS:%=install-data-%)
 	$(MKDIR_P) "$(DESTDIR)$(localstatedir)/cache/libvirt"
 	$(MKDIR_P) "$(DESTDIR)$(localstatedir)/lib/libvirt/images"
 	$(MKDIR_P) "$(DESTDIR)$(localstatedir)/lib/libvirt/filesystems"
 	$(MKDIR_P) "$(DESTDIR)$(localstatedir)/lib/libvirt/boot"
 
-uninstall-local:: uninstall-init uninstall-systemd uninstall-upstart \
-		uninstall-sysctl uninstall-polkit uninstall-sasl \
-		uninstall-logrotate $(INSTALL_DATA_DIRS:%=uninstall-data-%)
+uninstall-local:: $(UNINSTALL_LOCAL) \
+		$(INSTALL_DATA_DIRS:%=uninstall-data-%)
 	rmdir "$(DESTDIR)$(localstatedir)/cache/libvirt" ||:
 	rmdir "$(DESTDIR)$(localstatedir)/lib/libvirt/images" ||:
 	rmdir "$(DESTDIR)$(localstatedir)/lib/libvirt/filesystems" ||:
diff --git a/src/remote/Makefile.inc.am b/src/remote/Makefile.inc.am
index 5ef082c595..4a415d4482 100644
--- a/src/remote/Makefile.inc.am
+++ b/src/remote/Makefile.inc.am
@@ -203,10 +203,10 @@ install-sysctl:
 uninstall-sysctl:
 	rm -f $(DESTDIR)$(sysctldir)/60-libvirtd.conf
 	rmdir $(DESTDIR)$(sysctldir) || :
-else ! WITH_SYSCTL
-install-sysctl:
-uninstall-sysctl:
-endif ! WITH_SYSCTL
+
+INSTALL_DATA_LOCAL += install-sysctl
+UNINSTALL_LOCAL += uninstall-sysctl
+endif WITH_SYSCTL
 
 if WITH_POLKIT
 polkitactionsdir = $(datadir)/polkit-1/actions
@@ -226,17 +226,11 @@ uninstall-polkit::
 	rm -f $(DESTDIR)$(polkitrulesdir)/50-libvirt.rules
 	rmdir $(DESTDIR)$(polkitrulesdir) || :
 
-else ! WITH_POLKIT
-install-polkit::
-uninstall-polkit::
-endif ! WITH_POLKIT
+INSTALL_DATA_LOCAL += install-polkit
+UNINSTALL_LOCAL += uninstall-polkit
+endif WITH_POLKIT
 
-else ! WITH_LIBVIRTD
-install-polkit::
-uninstall-polkit::
-install-sysctl::
-uninstall-sysctl::
-endif ! WITH_LIBVIRTD
+endif WITH_LIBVIRTD
 
 .PHONY: \
 	install-data-remote \
@@ -257,10 +251,10 @@ install-sasl:
 uninstall-sasl:
 	rm -f $(DESTDIR)$(sasldir)/libvirt.conf
 	rmdir $(DESTDIR)$(sasldir) || :
-else ! WITH_SASL
-install-sasl:
-uninstall-sasl:
-endif ! WITH_SASL
+
+INSTALL_DATA_LOCAL += install-sasl
+UNINSTALL_LOCAL += uninstall-sasl
+endif WITH_SASL
 
 libvirtd.init: remote/libvirtd.init.in $(top_builddir)/config.status
 	$(AM_V_GEN)sed \
-- 
2.20.1




More information about the libvir-list mailing list