[libvirt] [PATCH v3 16/48] remote: reduce duplication in systemd unit file make rules into one

Daniel P. Berrangé berrange at redhat.com
Mon Jul 29 17:10:58 UTC 2019


The make rules for the systemd socket unit files are all essentially
identical and can be collapsed into a single generic rule. The service
unit file rule can be simplified too.

Reviewed-by: Andrea Bolognani <abologna at redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange at redhat.com>
---
 src/Makefile.am            |  6 +++++
 src/remote/Makefile.inc.am | 49 +++++++-------------------------------
 2 files changed, 14 insertions(+), 41 deletions(-)

diff --git a/src/Makefile.am b/src/Makefile.am
index 255e8e2b57..b4544b12a7 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -89,6 +89,12 @@ man8_MANS =
 DRIVER_SOURCES =
 man7_MANS =
 
+COMMON_UNIT_VARS = \
+	-e 's|[@]localstatedir[@]|$(localstatedir)|g' \
+	-e 's|[@]sbindir[@]|$(sbindir)|g' \
+	-e 's|[@]sysconfdir[@]|$(sysconfdir)|g' \
+	$(NULL)
+
 include util/Makefile.inc.am
 include conf/Makefile.inc.am
 include cpu/Makefile.inc.am
diff --git a/src/remote/Makefile.inc.am b/src/remote/Makefile.inc.am
index fc04af5cb5..0c6d859a41 100644
--- a/src/remote/Makefile.inc.am
+++ b/src/remote/Makefile.inc.am
@@ -292,48 +292,15 @@ INSTALL_DATA_LOCAL += install-sasl
 UNINSTALL_LOCAL += uninstall-sasl
 endif WITH_SASL
 
+LIBVIRTD_UNIT_VARS = \
+	$(COMMON_UNIT_VARS) \
+	$(NULL)
+
 libvirtd.service: remote/libvirtd.service.in $(top_builddir)/config.status
-	$(AM_V_GEN)sed \
-	    -e 's|[@]localstatedir[@]|$(localstatedir)|g' \
-	    -e 's|[@]sbindir[@]|$(sbindir)|g' \
-	    -e 's|[@]sysconfdir[@]|$(sysconfdir)|g' \
-	    < $< > $@-t && \
-	    mv $@-t $@
-
-libvirtd.socket: remote/libvirtd.socket.in $(top_builddir)/config.status
-	$(AM_V_GEN)sed \
-	    -e 's|[@]localstatedir[@]|$(localstatedir)|g' \
-	    -e 's|[@]sysconfdir[@]|$(sysconfdir)|g' \
-	    < $< > $@-t && \
-	    mv $@-t $@
-
-libvirtd-ro.socket: remote/libvirtd-ro.socket.in $(top_builddir)/config.status
-	$(AM_V_GEN)sed \
-	    -e 's|[@]localstatedir[@]|$(localstatedir)|g' \
-	    -e 's|[@]sysconfdir[@]|$(sysconfdir)|g' \
-	    < $< > $@-t && \
-	    mv $@-t $@
-
-libvirtd-admin.socket: remote/libvirtd-admin.socket.in $(top_builddir)/config.status
-	$(AM_V_GEN)sed \
-	    -e 's|[@]localstatedir[@]|$(localstatedir)|g' \
-	    -e 's|[@]sysconfdir[@]|$(sysconfdir)|g' \
-	    < $< > $@-t && \
-	    mv $@-t $@
-
-libvirtd-tcp.socket: remote/libvirtd-tcp.socket.in $(top_builddir)/config.status
-	$(AM_V_GEN)sed \
-	    -e 's|[@]localstatedir[@]|$(localstatedir)|g' \
-	    -e 's|[@]sysconfdir[@]|$(sysconfdir)|g' \
-	    < $< > $@-t && \
-	    mv $@-t $@
-
-libvirtd-tls.socket: remote/libvirtd-tls.socket.in $(top_builddir)/config.status
-	$(AM_V_GEN)sed \
-	    -e 's|[@]localstatedir[@]|$(localstatedir)|g' \
-	    -e 's|[@]sysconfdir[@]|$(sysconfdir)|g' \
-	    < $< > $@-t && \
-	    mv $@-t $@
+	$(AM_V_GEN)sed $(LIBVIRTD_UNIT_VARS) < $< > $@-t && mv $@-t $@
+
+libvirt%.socket: remote/libvirt%.socket.in $(top_builddir)/config.status
+	$(AM_V_GEN)sed $(LIBVIRTD_UNIT_VARS) < $< > $@-t && mv $@-t $@
 
 virt-guest-shutdown.target: remote/virt-guest-shutdown.target.in \
 			$(top_builddir)/config.status
-- 
2.21.0




More information about the libvir-list mailing list