-
-
Notifications
You must be signed in to change notification settings - Fork 124
/
Makefile
113 lines (96 loc) · 3.38 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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
#
# Btrbk is a single perl script, and does not require any special
# installation procedures or libraries. There is no need to run the
# "all" build target if you don't want to build the man pages (see
# doc/Makefile).
#
# Note: systemd units (file names) are hardcoded in "install-systemd"
# build target for simplicity.
#
BIN = btrbk
BIN_LINKS = lsbtr
CONFIGS = btrbk.conf.example
DOCS = ChangeLog \
README.md
SCRIPTS = ssh_filter_btrbk.sh \
contrib/cron/btrbk-mail \
contrib/cron/btrbk-verify \
contrib/migration/raw_suffix2sidecar \
contrib/crypt/kdf_pbkdf2.py \
contrib/tools/btrbk_restore_raw.py
PN = btrbk
PREFIX ?= /usr
CONFDIR = /etc
CRONDIR = /etc/cron.daily
BINDIR = $(PREFIX)/bin
DOCDIR = $(PREFIX)/share/doc/$(PN)
SCRIPTDIR = $(PREFIX)/share/$(PN)/scripts
SYSTEMDDIR = $(PREFIX)/lib/systemd/system
BASHCOMPDIR = $(PREFIX)/share/bash-completion/completions
MAN1DIR = $(PREFIX)/share/man/man1
MAN5DIR = $(PREFIX)/share/man/man5
ifeq ($(COMPRESS), yes)
DOCS := $(addsuffix .gz,$(DOCS))
endif
replace_vars = sed \
-e "s|@PN@|$(PN)|g" \
-e "s|@CONFDIR@|$(CONFDIR)|g" \
-e "s|@CRONDIR@|$(CRONDIR)|g" \
-e "s|@BINDIR@|$(BINDIR)|g" \
-e "s|@DOCDIR@|$(DOCDIR)|g" \
-e "s|@SCRIPTDIR@|$(SCRIPTDIR)|g" \
-e "s|@SYSTEMDDIR@|$(SYSTEMDDIR)|g" \
-e "s|@BASHCOMPDIR@|$(BASHCOMPDIR)|g" \
-e "s|@MAN1DIR@|$(MAN1DIR)|g" \
-e "s|@MAN5DIR@|$(MAN5DIR)|g"
all: man
install: install-bin install-bin-links install-etc install-completion install-systemd install-share install-man install-doc
install-bin:
@echo 'installing binary...'
install -d -m 755 "$(DESTDIR)$(BINDIR)"
install -p -m 755 $(BIN) "$(DESTDIR)$(BINDIR)"
install-bin-links: install-bin
@echo 'installing symlinks...'
for name in $(BIN_LINKS); do \
ln -s -n -f $(BIN) "$(DESTDIR)$(BINDIR)/$$name"; \
done
install-etc:
@echo 'installing example configs...'
install -d -m 755 "$(DESTDIR)$(CONFDIR)/btrbk"
install -p -m 644 $(CONFIGS) "$(DESTDIR)$(CONFDIR)/btrbk"
install-completion:
@echo 'installing bash completion...'
install -d -m 755 "$(DESTDIR)$(BASHCOMPDIR)"
install -p -m 644 contrib/bash/completion.bash "$(DESTDIR)$(BASHCOMPDIR)/$(BIN)"
for name in $(BIN_LINKS); do \
ln -s -n -f $(BIN) "$(DESTDIR)$(BASHCOMPDIR)/$$name"; \
done
install-systemd:
@echo 'installing systemd service units...'
install -d -m 755 "$(DESTDIR)$(SYSTEMDDIR)"
$(replace_vars) contrib/systemd/btrbk.service.in > contrib/systemd/btrbk.service.tmp
$(replace_vars) contrib/systemd/btrbk.timer.in > contrib/systemd/btrbk.timer.tmp
install -p -m 644 contrib/systemd/btrbk.service.tmp "$(DESTDIR)$(SYSTEMDDIR)/btrbk.service"
install -p -m 644 contrib/systemd/btrbk.timer.tmp "$(DESTDIR)$(SYSTEMDDIR)/btrbk.timer"
rm contrib/systemd/btrbk.service.tmp
rm contrib/systemd/btrbk.timer.tmp
install-share:
@echo 'installing auxiliary scripts...'
install -d -m 755 "$(DESTDIR)$(SCRIPTDIR)"
install -p -m 755 $(SCRIPTS) "$(DESTDIR)$(SCRIPTDIR)"
install-man: man
@echo 'installing man pages...'
@$(MAKE) -C doc install-man
install-doc: $(DOCS)
@echo 'installing documentation...'
install -d -m 755 "$(DESTDIR)$(DOCDIR)"
install -p -m 644 $(DOCS) "$(DESTDIR)$(DOCDIR)"
@$(MAKE) -C doc install-doc
man:
@echo 'generating manpages...'
@$(MAKE) -C doc man
clean:
rm -f *.gz
@$(MAKE) -C doc clean
%.gz : %
gzip -9 -n -c $< > $@