forked from lnicola/systemd-zpool-scrub
-
Notifications
You must be signed in to change notification settings - Fork 1
/
makefile
57 lines (46 loc) · 1.33 KB
/
makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
DESTDIR :=
SYSTEMD := /etc/systemd/system
MANUALS := /usr/local/man
# find zpool binary
ZPOOL_BIN := $(shell which zpool || echo /sbin/zpool)
NAME := zpool-scrub
SERVICES := $(NAME)@.service
TIMERS := $(NAME)-weekly@.timer \
$(NAME)-monthly@.timer
.PHONY : build install install-units install-man man
# build systemd unit files
build : $(TIMERS) $(SERVICES)
# render scheduled timers
$(NAME)-%@.timer: $(NAME)@.timer.in
sed 's/@SCHEDULE@/$*/g' $< > $@
# render service
$(NAME)@.service: $(NAME)@.service.in
sed 's,@ZPOOL_BIN@,$(ZPOOL_BIN),g' $< > $@
# install all files
install : install-units install-man
# install systemd units in system
SYSTEMDDIR := $(DESTDIR)$(SYSTEMD)
install-units : $(addprefix $(SYSTEMDDIR)/,$(SERVICES) $(TIMERS))
$(SYSTEMDDIR) :
install -m 755 -d $@
$(SYSTEMDDIR)/% : % $(SYSTEMDDIR)
install -m 644 $< $@
# render manpage from markdown
MANPAGE := $(NAME)-timers.8
man : $(MANPAGE)
$(MANPAGE) : README.md
marked-man \
--version git-$$(git describe --always --abbrev) \
--manual 'ZFS Utilities' \
$< > $@
# install manpage in system
MANPAGEDIR := $(DESTDIR)$(MANUALS)/man8
install-man : $(MANPAGEDIR)/$(MANPAGE)
$(MANPAGEDIR) :
install -m 755 -d $@
$(MANPAGEDIR)/$(MANPAGE) : $(MANPAGE) $(MANPAGEDIR)
install -d $(@D)
install -m 644 $< $@
# clean built files
clean:
rm -f $(TIMERS) $(SERVICES)