-
Notifications
You must be signed in to change notification settings - Fork 38
/
Makefile
184 lines (140 loc) · 3.97 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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
# Unix Makefile
# Local files
DUMP_SH = mysqldump-secure
DUMP_CONF = mysqldump-secure.conf
DUMP_CNF = mysqldump-secure.cnf
MAN_PAGE = mysqldump-secure.1
# Configuration
SHELL = /bin/sh
MKDIR_P = mkdir -p
# Check if './configure' has been run
ifneq ("$(wildcard configure.in)","")
CONFIGURED = 1
include configure.in
else
CONFIGURED = 0
endif
# Check if 'make' has been run
ifneq ("$(wildcard Makefile.in)","")
MAKED = 1
else
MAKED = 0
endif
# Check if any file is already installed
ifneq ("$(wildcard $(ETCDIR)/$(DUMP_CONF))","")
INSTALLED = 1
endif
ifneq ("$(wildcard $(ETCDIR)/$(DUMP_CNF))","")
INSTALLED = 1
endif
ifneq ("$(wildcard $(BINDIR)/$(DUMP_SH))","")
INSTALLED = 1
endif
ifneq ("$(wildcard $(MANDIR)/$(MAN_PAGE))","")
INSTALLED = 1
endif
all:
ifeq ($(CONFIGURED),0)
$(error Not configured, run ./configure)
endif
@touch Makefile.in
@echo "finished."
@echo "Type 'make install' or 'make reinstall'"
help:
@echo Options
@echo " make install"
@echo " Install everthing (might require root)"
@echo ""
@echo " make reinstall"
@echo " Install everthing even if it is already"
@echo " installed (might require root)"
@echo ""
@echo " make uninstall"
@echo " Remove everything except the logfiles"
@echo " (might require root)"
@echo ""
@echo " make clean"
@echo " Clean build"
@echo ""
@echo " make help"
@echo " Show this help screen"
install:
ifeq ($(MAKED),0)
$(error Run 'make' first or show help: 'make help')
endif
ifeq ($(INSTALLED),1)
$(error Already installed, use make reinstall)
endif
@echo "Installing files"
@echo ""
@# Create directories
${MKDIR_P} $(BINDIR)
${MKDIR_P} $(ETCDIR)
${MKDIR_P} $(MANDIR)/man1
@# Install binary
install -m 0755 build/$(DUMP_SH) $(BINDIR)/$(DUMP_SH)
@# Install config file and create backup if there is one already
install -b -m 0400 build/$(DUMP_CONF) $(ETCDIR)/$(DUMP_CONF)
@# Install config file and create backup if there is one already
install -b -m 0400 build/$(DUMP_CNF) $(ETCDIR)/$(DUMP_CNF)
@echo ""
@# Install man pages
install -b -m 0644 build/$(MAN_PAGE) $(MANDIR)/man1/$(MAN_PAGE)
@echo ""
@echo "Installation complete:"
@echo " $(BINDIR)/$(DUMP_SH)"
@echo " $(ETCDIR)/$(DUMP_CONF)"
@echo " $(ETCDIR)/$(DUMP_CNF)"
@echo " $(MANDIR)/$(MAN_PAGE)"
@echo ""
@echo "----------------------------------------------------------------------"
@echo "Note:"
@echo ""
@echo "Adjust values in $(ETCDIR)/$(DUMP_CONF)"
@echo "Adjust values in $(ETCDIR)/$(DUMP_CNF)"
@echo "----------------------------------------------------------------------"
@echo ""
reinstall:
ifeq ($(MAKED),0)
$(error Type 'make' first)
endif
@echo "Installing files"
@echo ""
@# Create directories
${MKDIR_P} $(BINDIR)
${MKDIR_P} $(ETCDIR)
${MKDIR_P} $(MANDIR)/man1
@# Install binary
install -m 0755 build/$(DUMP_SH) $(BINDIR)/$(DUMP_SH)
@echo ""
@# Install config file without overwriting
test -f $(ETCDIR)/$(DUMP_CONF) \
&& install -m 0400 build/$(DUMP_CONF) $(ETCDIR)/$(DUMP_CONF).new \
|| install -m 0400 build/$(DUMP_CONF) $(ETCDIR)/$(DUMP_CONF)
@echo ""
@# Install config file without overwriting
test -f $(ETCDIR)/$(DUMP_CNF) \
&& install -m 0400 build/$(DUMP_CNF) $(ETCDIR)/$(DUMP_CNF).new \
|| install -m 0400 build/$(DUMP_CNF) $(ETCDIR)/$(DUMP_CNF)
@echo ""
@# Install man pages
install -b -m 0644 build/$(MAN_PAGE) $(MANDIR)/man1/$(MAN_PAGE)
@echo ""
@echo "Installation complete"
@echo ""
@echo "Compare new config: $(ETCDIR)/$(DUMP_CONF).new"
@echo "Compare new config: $(ETCDIR)/$(DUMP_CNF).new"
@echo "New configuration options might be available"
uninstall:
@# Keep the logfile, as we do not know its location (it is set in config)
@# Just remove the binaries, man(1) and config files.
rm -f $(BINDIR)/$(DUMP_SH)
rm -f $(ETCDIR)/$(DUMP_CONF)
rm -f $(ETCDIR)/$(DUMP_CNF)
rm -f $(ETCDIR)/$(DUMP_CONF).new
rm -f $(ETCDIR)/$(DUMP_CNF).new
rm -f $(MANDIR)/man1/$(MAN_PAGE)
clean:
rm -rf build/*
rm -f configure.in
rm -f Makefile.in