| 1 |
# |
| 2 |
# Btrbk is a single perl script, and does not require any special |
| 3 |
# installation procedures or libraries. There is no need to run the |
| 4 |
# "all" build target if you don't want to build the man pages (see |
| 5 |
# doc/Makefile). |
| 6 |
# |
| 7 |
# Note: systemd units (file names) are hardcoded in "install-systemd" |
| 8 |
# build target for simplicity. |
| 9 |
# |
| 10 |
|
| 11 |
BIN = btrbk |
| 12 |
BIN_LINKS = lsbtr |
| 13 |
CONFIGS = btrbk.conf.example |
| 14 |
DOCS = ChangeLog \ |
| 15 |
README.md |
| 16 |
SCRIPTS = ssh_filter_btrbk.sh \ |
| 17 |
contrib/cron/btrbk-mail \ |
| 18 |
contrib/cron/btrbk-verify \ |
| 19 |
contrib/migration/raw_suffix2sidecar \ |
| 20 |
contrib/crypt/kdf_pbkdf2.py \ |
| 21 |
contrib/tools/btrbk_restore_raw.py |
| 22 |
|
| 23 |
PN = btrbk |
| 24 |
PREFIX ?= /usr |
| 25 |
CONFDIR = /etc |
| 26 |
CRONDIR = /etc/cron.daily |
| 27 |
BINDIR = $(PREFIX)/bin |
| 28 |
DOCDIR = $(PREFIX)/share/doc/$(PN) |
| 29 |
SCRIPTDIR = $(PREFIX)/share/$(PN)/scripts |
| 30 |
SYSTEMDDIR = $(PREFIX)/lib/systemd/system |
| 31 |
BASHCOMPDIR = $(PREFIX)/share/bash-completion/completions |
| 32 |
MAN1DIR = $(PREFIX)/share/man/man1 |
| 33 |
MAN5DIR = $(PREFIX)/share/man/man5 |
| 34 |
|
| 35 |
ifeq ($(COMPRESS), yes) |
| 36 |
DOCS := $(addsuffix .gz,$(DOCS)) |
| 37 |
endif |
| 38 |
|
| 39 |
replace_vars = sed \ |
| 40 |
-e "s|@PN@|$(PN)|g" \ |
| 41 |
-e "s|@CONFDIR@|$(CONFDIR)|g" \ |
| 42 |
-e "s|@CRONDIR@|$(CRONDIR)|g" \ |
| 43 |
-e "s|@BINDIR@|$(BINDIR)|g" \ |
| 44 |
-e "s|@DOCDIR@|$(DOCDIR)|g" \ |
| 45 |
-e "s|@SCRIPTDIR@|$(SCRIPTDIR)|g" \ |
| 46 |
-e "s|@SYSTEMDDIR@|$(SYSTEMDDIR)|g" \ |
| 47 |
-e "s|@BASHCOMPDIR@|$(BASHCOMPDIR)|g" \ |
| 48 |
-e "s|@MAN1DIR@|$(MAN1DIR)|g" \ |
| 49 |
-e "s|@MAN5DIR@|$(MAN5DIR)|g" |
| 50 |
|
| 51 |
all: man |
| 52 |
|
| 53 |
install: install-bin install-bin-links install-etc install-completion install-systemd install-share install-man install-doc |
| 54 |
|
| 55 |
install-bin: |
| 56 |
@echo 'installing binary...' |
| 57 |
install -d -m 755 "$(DESTDIR)$(BINDIR)" |
| 58 |
install -p -m 755 $(BIN) "$(DESTDIR)$(BINDIR)" |
| 59 |
|
| 60 |
install-bin-links: install-bin |
| 61 |
@echo 'installing symlinks...' |
| 62 |
for name in $(BIN_LINKS); do \ |
| 63 |
ln -s -n -f $(BIN) "$(DESTDIR)$(BINDIR)/$$name"; \ |
| 64 |
done |
| 65 |
|
| 66 |
install-etc: |
| 67 |
@echo 'installing example configs...' |
| 68 |
install -d -m 755 "$(DESTDIR)$(CONFDIR)/btrbk" |
| 69 |
install -p -m 644 $(CONFIGS) "$(DESTDIR)$(CONFDIR)/btrbk" |
| 70 |
|
| 71 |
install-completion: |
| 72 |
@echo 'installing bash completion...' |
| 73 |
install -d -m 755 "$(DESTDIR)$(BASHCOMPDIR)" |
| 74 |
install -p -m 644 contrib/bash/completion.bash "$(DESTDIR)$(BASHCOMPDIR)/$(BIN)" |
| 75 |
for name in $(BIN_LINKS); do \ |
| 76 |
ln -s -n -f $(BIN) "$(DESTDIR)$(BASHCOMPDIR)/$$name"; \ |
| 77 |
done |
| 78 |
|
| 79 |
install-systemd: |
| 80 |
@echo 'installing systemd service units...' |
| 81 |
install -d -m 755 "$(DESTDIR)$(SYSTEMDDIR)" |
| 82 |
$(replace_vars) contrib/systemd/btrbk.service.in > contrib/systemd/btrbk.service.tmp |
| 83 |
$(replace_vars) contrib/systemd/btrbk.timer.in > contrib/systemd/btrbk.timer.tmp |
| 84 |
install -p -m 644 contrib/systemd/btrbk.service.tmp "$(DESTDIR)$(SYSTEMDDIR)/btrbk.service" |
| 85 |
install -p -m 644 contrib/systemd/btrbk.timer.tmp "$(DESTDIR)$(SYSTEMDDIR)/btrbk.timer" |
| 86 |
rm contrib/systemd/btrbk.service.tmp |
| 87 |
rm contrib/systemd/btrbk.timer.tmp |
| 88 |
|
| 89 |
install-share: |
| 90 |
@echo 'installing auxiliary scripts...' |
| 91 |
install -d -m 755 "$(DESTDIR)$(SCRIPTDIR)" |
| 92 |
install -p -m 755 $(SCRIPTS) "$(DESTDIR)$(SCRIPTDIR)" |
| 93 |
|
| 94 |
install-man: man |
| 95 |
@echo 'installing man pages...' |
| 96 |
@$(MAKE) -C doc install-man |
| 97 |
|
| 98 |
install-doc: $(DOCS) |
| 99 |
@echo 'installing documentation...' |
| 100 |
install -d -m 755 "$(DESTDIR)$(DOCDIR)" |
| 101 |
install -p -m 644 $(DOCS) "$(DESTDIR)$(DOCDIR)" |
| 102 |
@$(MAKE) -C doc install-doc |
| 103 |
|
| 104 |
man: |
| 105 |
@echo 'generating manpages...' |
| 106 |
@$(MAKE) -C doc man |
| 107 |
|
| 108 |
clean: |
| 109 |
rm -f *.gz |
| 110 |
@$(MAKE) -C doc clean |
| 111 |
|
| 112 |
%.gz : % |
| 113 |
gzip -9 -n -c $< > $@ |