commit ebd17b57ebe07281c1f49e7cb723a04e638591d5
Author: Jim Meyering <meyering(a)redhat.com>
Date: Mon Mar 5 22:27:14 2012 +0100
build: work around F16-vs-F17 systemd unitdir difference
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 files changed, 6 insertions(+), 1 deletions(-)
---
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