-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
137 lines (113 loc) · 3.89 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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
################################################################################
# Makefile - Makefile for installing the 389 Directory Server Backup script
################################################################################
#
# Copyright (C) 2019 Adfinis SyGroup AG
# https://adfinis-sygroup.ch
#
# This program is free software: you can redistribute it and/or
# modify it under the terms of the GNU Affero General Public
# License as published by the Free Software Foundation, version
# 3 of the License.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public
# License along with this program.
# If not, see <http://www.gnu.org/licenses/>.
#
# Please submit enhancements, bugfixes or comments via:
# https://github.com/adfinis-sygroup/389-directory-backup
#
# Authors:
# Christian Affolter <[email protected]>
PN = 389-directory-backup
# Standard commands according to
# https://www.gnu.org/software/make/manual/html_node/Makefile-Conventions.html
SHELL = /bin/sh
INSTALL = /usr/bin/install
INSTALL_PROGRAM = $(INSTALL)
INSTALL_DATA = $(INSTALL) -m 644
# Standard directories according to
# https://www.gnu.org/software/make/manual/html_node/Directory-Variables.html#Directory-Variables
prefix = /usr/local
exec_prefix = $(prefix)
bindir = $(exec_prefix)/bin
datarootdir = $(prefix)/share
datadir = $(datarootdir)
docrootdir = $(datarootdir)/doc
docdir = $(docrootdir)/$(PN)
sbindir = $(exec_prefix)/sbin
sysconfdir = $(prefix)/etc
libdir = $(exec_prefix)/lib
libexecdir = $(exec_prefix)/libexec
localstatedir = $(prefix)/var
runstatedir = $(localstatedir)/run
# Systemd paths
systemddir = $(libdir)/systemd
systemdunitdir = $(systemddir)/system
.PHONY: all
all: 389-directory-backup systemd-units
.PHONY: 389-directory-backup
389-directory-backup:
sed -e 's|^\(confDir\)=.*|\1=$(sysconfdir)|' \
bin/$(PN).sh > \
bin/$(PN).sh.tmp
.PHONY: systemd-units
systemd-units:
sed \
-e 's|/usr/local/bin|$(bindir)|' \
-e 's|/usr/local/etc|$(sysconfdir)|' \
systemd/$(PN)@.service > systemd/$(PN)@.service.tmp
sed \
-e 's|/usr/local/var|$(localstatedir)|' \
-e 's|/usr/local/etc|$(sysconfdir)|' \
systemd/$(PN)-env.conf > systemd/$(PN)-env.conf.tmp
.PHONY: installdirs
installdirs:
$(INSTALL) --directory \
$(DESTDIR)$(bindir) \
$(DESTDIR)$(sysconfdir) \
$(DESTDIR)$(docdir) \
$(DESTDIR)$(systemdunitdir)
.PHONY: install
install: all installdirs
$(INSTALL_PROGRAM) bin/$(PN).sh.tmp \
$(DESTDIR)$(bindir)/$(PN).sh
$(INSTALL_DATA) systemd/$(PN)@.service.tmp \
$(DESTDIR)$(systemdunitdir)/$(PN)@.service
$(INSTALL_DATA) systemd/$(PN)-env.conf.tmp \
$(DESTDIR)$(sysconfdir)/$(PN)-env.conf
$(INSTALL_DATA) systemd/$(PN)@.timer $(DESTDIR)$(systemdunitdir)/
$(INSTALL_DATA) README.md $(DESTDIR)$(docdir)/
.PHONY: uninstall
uninstall:
rm --force \
$(DESTDIR)$(bindir)/$(PN).sh \
$(DESTDIR)$(datadir)/$(PN)/* \
$(DESTDIR)$(systemdunitdir)/$(PN)@.service \
$(DESTDIR)$(sysconfdir)/$(PN)-env.conf \
$(DESTDIR)$(systemdunitdir)/$(PN)@.timer \
$(DESTDIR)$(docdir)/README.md
rmdir --ignore-fail-on-non-empty \
$(DESTDIR)$(bindir) \
$(DESTDIR)$(docdir) \
$(DESTDIR)$(docrootdir) \
$(DESTDIR)$(sysconfdir) \
$(DESTDIR)$(systemdunitdir) \
$(DESTDIR)$(systemddir) \
$(DESTDIR)$(datarootdir) \
$(DESTDIR)$(libdir) \
$(DESTDIR)$(exec_prefix)
# Usually $(prefix) is equal to $(exec_prefix) which was already
# removed, test for the directory existence to prevent errors.
test -d $(DESTDIR)$(prefix) && \
rmdir --ignore-fail-on-non-empty $(DESTDIR)$(exec_prefix) || \
true
.PHONY: clean
clean:
rm --force bin/$(PN).sh.tmp systemd/*.tmp