[PATCH] build: work around F16-vs-F17 systemd unitdir difference

Jim Meyering meyering at redhat.com
Mon Mar 5 21:27:14 UTC 2012


We have chosen to distribute in the "upstream" tarball (hence also to
install) the systemd unit file, iwhd.service.  Now we pay for that sin.
In Fedora 16, unitdir is /lib/systemd/system, in spite of $(prefix),
but on Fedora 17 and newer it is /usr/lib/systemd/system when
$(prefix) is /usr.
* Makefile.am (unitdir): Compute at make-install time a value for
$(unitdir) that is consistent with rpm --eval '%{_unitdir}'.
---
 Makefile.am |    7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/Makefile.am b/Makefile.am
index b22efc1..16b8fc0 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -138,8 +138,13 @@ iwhd-users.js: $(top_builddir)/config.status
 	$(AM_V_GEN)echo '[ { "name":"admin", "secret":"replaceme" } ]'	\
 	  > $@-t && chmod a-w $@-t && mv $@-t $@

+# F16's unitdir is /lib/systemd/system, in spite of $(prefix), but
+# on F17 it is /usr/lib/systemd/system
+# Account for that by testing rpm --eval '%{_unitdir}'.
+# When that evaluates to "/lib/systemd/system", ignore a prefix of "/usr".
 # Honor $(prefix) in the expansion of $(unitdir), except when it is "/usr".
-p = $$(echo '$(prefix)' | sed 's,^/usr$$,,')
+p = $$(case $$(rpm --eval '%{_unitdir}'):$(prefix) in \
+       /lib/systemd/system:/usr) ;; *) echo '$(prefix)';; esac)
 unitdir = $(DESTDIR)$(p)/lib/systemd/system

 logrotate_dir = $(DESTDIR)$(sysconfdir)/logrotate.d
--
1.7.9.2.385.g24da


More information about the iwhd-devel mailing list