summaryrefslogtreecommitdiff
path: root/Makefile
diff options
context:
space:
mode:
authorLuke Shumaker <lukeshu@lukeshu.com>2017-08-16 22:24:09 -0400
committerLuke Shumaker <lukeshu@lukeshu.com>2017-08-16 22:27:35 -0400
commit2e5895c173d4cceb5426619ab877d72671da849d (patch)
tree610a1b13a85334c7f0de38a55df5129a6f24922c /Makefile
parentd6d7ed035c4f4a1f8e968e70726050c9fa4553e4 (diff)
Make installation paths and such configurable
This doesn't change the default behavior at all.
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile36
1 files changed, 27 insertions, 9 deletions
diff --git a/Makefile b/Makefile
index 282ed1a..5be885b 100644
--- a/Makefile
+++ b/Makefile
@@ -1,9 +1,23 @@
-files.out.all += systemd-timesyncd-wait systemd-timesyncd-wrap
-files.sys.all += /usr/lib/systemd/systemd-timesyncd-wait
-files.sys.all += /usr/lib/systemd/systemd-timesyncd-wrap
-files.sys.all += /usr/lib/systemd/system/systemd-timesyncd-wait.socket
-files.sys.all += /usr/lib/systemd/system/systemd-timesyncd-wait.service
-files.sys.all += /usr/lib/systemd/system/systemd-timesyncd.service.d/wait.conf
+prefix = /usr
+rootprefix = $(prefix)
+rootlibexecdir = $(rootprefix)/lib/systemd
+systemunitdir=$(rootprefix)/lib/systemd/system
+
+TIMESYNCD_PATH = $(rootlibexecdir)/systemd-timesyncd
+RM = /usr/bin/rm
+
+####
+
+files.out.all += systemd-timesyncd-wait
+files.out.all += systemd-timesyncd-wrap
+files.out.all += systemd-timesyncd.service.d-wait.conf
+files.out.all += systemd-timesyncd-wait.service
+
+files.sys.all += $(rootlibexecdir)/systemd-timesyncd-wait
+files.sys.all += $(rootlibexecdir)/systemd-timesyncd-wrap
+files.sys.all += $(systemunitdir)/systemd-timesyncd-wait.socket
+files.sys.all += $(systemunitdir)/systemd-timesyncd-wait.service
+files.sys.all += $(systemunitdir)/systemd-timesyncd.service.d/wait.conf
outdir = .
srcdir = .
@@ -16,9 +30,13 @@ install: $(addprefix $(DESTDIR),$(files.sys.all))
$(outdir)/%: $(srcdir)/%.go
go build -o $@ $<
-$(DESTDIR)/usr/lib/systemd/%: $(outdir)/%
+vars = rootlibexecdir TIMESYNCD_PATH RM
+$(outdir)/%: $(srcdir)/%.in
+ sed $(foreach v,$(vars),-e 's|@$v@|$($v)|g') < $< > $@
+
+$(DESTDIR)$(rootlibexecdir)/%: $(outdir)/%
install -DTm755 $< $@
-$(DESTDIR)/usr/lib/systemd/system/%: $(srcdir)/%
+$(DESTDIR)$(systemunitdir)/%: $(srcdir)/%
install -DTm644 $< $@
-$(DESTDIR)/usr/lib/systemd/system/systemd-timesyncd.service.d/wait.conf: systemd-timesyncd.service.d-wait.conf
+$(DESTDIR)$(systemunitdir)/systemd-timesyncd.service.d/wait.conf: $(outdir)/systemd-timesyncd.service.d-wait.conf
install -DTm644 $< $@