1 |
lefcha |
1.1 |
#!/bin/sh |
2 |
|
|
|
3 |
|
|
destdir="/usr/local" |
4 |
|
|
bindir="$destdir/bin" |
5 |
|
|
mandir="$destdir/man" |
6 |
|
|
|
7 |
|
|
debug="yes" |
8 |
|
|
checkperms="yes" |
9 |
|
|
ssl="yes" |
10 |
|
|
|
11 |
|
|
libs="" |
12 |
|
|
libssl="-lssl -lcrypto" |
13 |
|
|
|
14 |
|
|
interactive="no" |
15 |
|
|
|
16 |
|
|
|
17 |
|
|
# Get options and arguments |
18 |
|
|
|
19 |
|
|
while getopts "hid:b:m:o:" opt |
20 |
|
|
do |
21 |
|
|
case $opt in |
22 |
|
|
d) |
23 |
|
|
destdir=$OPTARG |
24 |
|
|
bindir=$destdir/bin |
25 |
|
|
mandir=$destdir/man |
26 |
|
|
;; |
27 |
|
|
b) |
28 |
|
|
bindir=$OPTARG |
29 |
|
|
;; |
30 |
|
|
m) |
31 |
|
|
mandir=$OPTARG |
32 |
|
|
;; |
33 |
|
|
o) |
34 |
|
|
typeset $OPTARG |
35 |
|
|
;; |
36 |
|
|
i) |
37 |
|
|
interactive="yes" |
38 |
|
|
;; |
39 |
|
|
h | *) |
40 |
|
|
cat << EOF |
41 |
|
|
Usage: |
42 |
|
|
config [-hi] [-d destdir] [-b bindir] [-m mandir] [-o option=argument] |
43 |
|
|
|
44 |
|
|
Description: |
45 |
|
|
-h This brief usage and description message. |
46 |
|
|
-i Interactive mode. |
47 |
|
|
-d destdir Installation path for program's files [/usr/local] |
48 |
|
|
-b bindir Installation path for binaries [\$destdir/bin] |
49 |
|
|
-m mandir Installation path for manual pages [\$destdir/man] |
50 |
|
|
-o option=argument Enabling/disabling of program's options. |
51 |
|
|
|
52 |
|
|
Options: |
53 |
|
|
debug Debugging information, useful during development [yes] |
54 |
|
|
checkperms Configuration file's permissions checking [yes] |
55 |
|
|
ssl Secure Socket Layer and Transport Layer Security [yes] |
56 |
|
|
EOF |
57 |
|
|
exit 1 |
58 |
|
|
;; |
59 |
|
|
esac |
60 |
|
|
done |
61 |
|
|
|
62 |
|
|
|
63 |
|
|
# Interactive or non-interactive mode |
64 |
|
|
|
65 |
|
|
if [ $interactive = "yes" ] |
66 |
|
|
then |
67 |
|
|
echo -n "Destination directory [$destdir]: " |
68 |
|
|
read tmp |
69 |
|
|
if [ -n "$tmp" ]; then destdir="$tmp"; fi |
70 |
|
|
|
71 |
|
|
echo -n "Binaries directory [$bindir]: " |
72 |
|
|
read tmp |
73 |
|
|
if [ -n "$tmp" ]; then bindir="$tmp"; fi |
74 |
|
|
|
75 |
|
|
echo -n "Manual pages directory [$mandir]: " |
76 |
|
|
read tmp |
77 |
|
|
if [ -n "$tmp" ]; then mandir="$tmp"; fi |
78 |
|
|
|
79 |
|
|
echo -n "Debugging information [$debug]: " |
80 |
|
|
read tmp |
81 |
|
|
if [ -n "$tmp" ]; then debug="$tmp"; fi |
82 |
|
|
|
83 |
|
|
echo -n "Configuration file permissions checking [$checkperms]: " |
84 |
|
|
read tmp |
85 |
|
|
if [ -n "$tmp" ]; then checkperms="$tmp"; fi |
86 |
|
|
|
87 |
|
|
echo -n "Secure Socket Layer and Transport Layer Security [$ssl]: " |
88 |
|
|
read tmp |
89 |
|
|
if [ -n "$tmp" ]; then ssl="$tmp"; fi |
90 |
|
|
else |
91 |
|
|
cat << EOF |
92 |
|
|
Destination directory: $destdir |
93 |
|
|
Binaries directory: $bindir |
94 |
|
|
Manual pages directory: $mandir |
95 |
|
|
Debugging information: $debug |
96 |
|
|
Configuration file permissions checking: $checkperms |
97 |
|
|
Secure Socket Layer and Transport Layer Security: $ssl |
98 |
|
|
EOF |
99 |
|
|
fi |
100 |
|
|
|
101 |
|
|
|
102 |
|
|
# Libraries |
103 |
|
|
|
104 |
|
|
if [ $ssl = "yes" ] |
105 |
|
|
then |
106 |
|
|
libs="$libs $libssl" |
107 |
|
|
fi |
108 |
|
|
|
109 |
|
|
|
110 |
|
|
# Backup of original Makefile and config.h |
111 |
|
|
|
112 |
|
|
if [ ! -f .Makefile ]; then cp Makefile .Makefile; fi |
113 |
|
|
if [ ! -f .config.h ]; then cp config.h .config.h; fi |
114 |
|
|
|
115 |
|
|
|
116 |
|
|
# Write Makefile |
117 |
|
|
|
118 |
|
|
mv Makefile Makefile~ |
119 |
|
|
|
120 |
|
|
cat > Makefile << EOF |
121 |
|
|
CC = cc |
122 |
|
|
CFLAGS = -Wall -O2 |
123 |
|
|
|
124 |
|
|
DESTDIR = $destdir |
125 |
|
|
BINDIR = $bindir |
126 |
|
|
MANDIR = $mandir |
127 |
|
|
|
128 |
|
|
INSTALL = install -c |
129 |
|
|
INST_DIR = install -d |
130 |
|
|
INST_BIN = \$(INSTALL) -m 755 |
131 |
|
|
INST_DOC = \$(INSTALL) -m 644 |
132 |
|
|
|
133 |
|
|
MAN_BIN = imapfilter.1 |
134 |
|
|
MAN_RC = imapfilterrc.5 |
135 |
|
|
|
136 |
|
|
BIN = imapfilter |
137 |
|
|
OBJ = data.o file.o imap.o imapfilter.o log.o memory.o misc.o \\ |
138 |
|
|
response.o request.o socket.o |
139 |
|
|
|
140 |
|
|
LIBS = $libs |
141 |
|
|
|
142 |
|
|
imapfilter: \$(OBJ) |
143 |
|
|
\$(CC) \$(LIBS) \$(CFLAGS) -o \$(BIN) \$(OBJ) |
144 |
|
|
|
145 |
|
|
data.o file.o imap.o imapfilter.o log.o response.o request.o \\ |
146 |
|
|
memory.o socket.o: imapfilter.h config.h |
147 |
|
|
data.o imapfilter.o imap.o file.o request.o socket.o: data.h |
148 |
|
|
|
149 |
|
|
install: imapfilter |
150 |
|
|
if test ! -d \$(BINDIR); then \$(INST_DIR) \$(BINDIR); fi |
151 |
|
|
\$(INST_BIN) \$(BIN) \$(BINDIR) |
152 |
|
|
if test ! -d \$(MANDIR)/man1; then \$(INST_DIR) \$(MANDIR)/man1; fi |
153 |
|
|
\$(INST_DOC) \$(MAN_BIN) \$(MANDIR)/man1 |
154 |
|
|
if test ! -d \$(MANDIR)/man5; then \$(INST_DIR) \$(MANDIR)/man5; fi |
155 |
|
|
\$(INST_DOC) \$(MAN_RC) \$(MANDIR)/man5 |
156 |
|
|
|
157 |
|
|
uninstall: |
158 |
|
|
rm -f \$(BINDIR)/\$(BIN) \$(MANDIR)/man1/\$(MAN_BIN) \$(MANDIR)/man5/\$(MAN_RC) |
159 |
|
|
|
160 |
|
|
clean: |
161 |
|
|
rm -f \$(OBJ) \$(BIN) imapfilter.core core *.BAK *~ |
162 |
|
|
|
163 |
|
|
distclean: clean |
164 |
|
|
@if test -f .Makefile; then mv .Makefile Makefile; fi |
165 |
|
|
@if test -f .config.h; then mv .config.h config.h; fi |
166 |
|
|
|
167 |
|
|
.PHONY : install uninstall clean distclean |
168 |
|
|
EOF |
169 |
|
|
|
170 |
|
|
|
171 |
|
|
# Write config.h |
172 |
|
|
|
173 |
|
|
mv config.h config.h~ |
174 |
|
|
|
175 |
|
|
echo "/* Debugging information. */" > config.h |
176 |
|
|
if [ $debug = "yes" ] |
177 |
|
|
then |
178 |
|
|
echo "#define DEBUG" >> config.h |
179 |
|
|
else |
180 |
|
|
echo "#undef DEBUG" >> config.h |
181 |
|
|
fi |
182 |
|
|
echo >> config.h |
183 |
|
|
|
184 |
|
|
echo "/* Configuration file's permissions checking. */" >> config.h |
185 |
|
|
if [ $checkperms = "yes" ] |
186 |
|
|
then |
187 |
|
|
echo "#define CHECK_PERMISSIONS" >> config.h |
188 |
|
|
else |
189 |
|
|
echo "#undef CHECK_PERMISSIONS" >> config.h |
190 |
|
|
fi |
191 |
|
|
echo >> config.h |
192 |
|
|
|
193 |
|
|
echo "/* Secure Socket Layer and Transport Layer Security support. */" >> config.h |
194 |
|
|
if [ $ssl = "yes" ] |
195 |
|
|
then |
196 |
|
|
echo "#define SSL_TLS" >> config.h |
197 |
|
|
else |
198 |
|
|
echo "#undef SSL_TLS" >> config.h |
199 |
|
|
fi |
200 |
|
|
|
201 |
|
|
|
202 |
|
|
exit 0 |