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 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216
|
#!/bin/sh
# Default values
destdir="/usr/local"
bindir="$destdir/bin"
sharedir="$destdir/share/imapfilter"
mandir="$destdir/man"
ssltls="yes"
crammd5="yes"
incdirs="-I/usr/local/include"
libdirs="-L/usr/local/lib"
mycflags="-Wall -O"
myldflags=""
libs="-lm -llua -llualib"
libssl="-lssl"
libcrypto="-lcrypto"
defs="-DMAKEFILE_SHAREDIR='\"\$(SHAREDIR)\"'"
bin="imapfilter"
# Get options and arguments
while getopts "d:b:s:m:o:h" opt
do
case $opt in
d)
destdir=$OPTARG
bindir=$destdir/bin
sharedir=$destdir/share/imapfilter
mandir=$destdir/man
;;
b)
bindir=$OPTARG
;;
s)
sharedir=$OPTARG
;;
m)
mandir=$OPTARG
;;
o)
head=`echo $OPTARG | cut -d= -f1`
body=`echo $OPTARG | cut -d= -f2`
if [ $head = "ssltls" ]
then
if [ $body = "yes" ]; then ssltls="yes"
elif [ $body = "no" ]; then ssltls="no"
fi
elif [ $head = "crammd5" ]
then
if [ $body = "yes" ]; then crammd5="yes"
elif [ $body = "no" ]; then crammd5="no"
fi
fi
;;
h | *)
cat << EOF
Usage:
configure [-h] [-d destdir] [-b bindir] [-s sharedir] [-m mandir]
[-o option=argument]
Description:
-h This brief usage and description message.
-d destdir Installation path for program's files [$destdir]
-b bindir Installation path for binaries [$bindir]
-s sharedir Installation path for libraries [$sharedir]
-m mandir Installation path for manual pages [$mandir]
-o option=argument Enabling/disabling of program's compilation options.
Options:
ssltls Secure Socket Layer and Transport Layer Security \
[$ssltls]
crammd5 Challenge-Response Authentication Mechanism [$crammd5]
EOF
exit 1
;;
esac
done
# Print values
cat << EOF
Destination directory: $destdir
Binaries directory: $bindir
Architecture independent libraries: $sharedir
Manual pages directory: $mandir
Secure Socket Layer and Transport Layer Security: $ssltls
Challenge-Response Authentication Mechanism: $crammd5
EOF
# Defines
if [ $ssltls = "no" ]
then
defs="$defs -DNO_SSLTLS"
fi
if [ $crammd5 = "no" ]
then
defs="$defs -DNO_CRAMMD5"
fi
# Libraries
if [ $ssltls = "yes" ]
then
libs="$libs $libssl $libcrypto"
elif [ $crammd5 = "yes" ]
then
libs="$libs $libcrypto"
fi
# Binary name
uname -a | grep -qi cygwin
if [ $? = 0 ]
then
bin="imapfilter.exe"
fi
# Backup of original Makefile
if [ ! -f .Makefile ]; then cp -f Makefile .Makefile; fi
# Write Makefile
mv -f Makefile Makefile~
cat > Makefile << EOF
DESTDIR = $destdir
BINDIR = $bindir
SHAREDIR = $sharedir
MANDIR = $mandir
INCDIRS = $incdirs
LIBDIRS = $libdirs
MYCFLAGS = $mycflags
MYLDFLAGS = $myldflags
DEFS = $defs
CFLAGS = \$(MYCFLAGS) \$(DEFS) \$(INCDIRS)
LDFLAGS = \$(MYLDFLAGS) \$(LIBDIRS)
LIBS = $libs
MAN_BIN = imapfilter.1
MAN_CONFIG = imapfilter_config.5
INTERFACE_LUA = interface.lua
AUXILIARY_LUA = auxiliary.lua
BIN = $bin
OBJ = auth.o buffer.o cert.o core.o file.o imap.o imapfilter.o list.o log.o \\
lua.o memory.o misc.o namespace.o regexp.o request.o response.o \\
session.o signal.o socket.o system.o
all: \$(BIN)
\$(BIN): \$(OBJ)
\$(CC) -o \$(BIN) \$(LDFLAGS) \$(OBJ) \$(LIBS)
\$(OBJ): imapfilter.h
buffer.o imap.o imapfilter.o namespace.o request.o response.o: buffer.h
cert.o file.o imapfilter.o log.o lua.o: pathnames.h
imapfilter.o log.o session.o: list.h
imapfilter.o regexp.o response.o: regexp.h
auth.o cert.o imap.o imapfilter.o log.o request.o response.o session.o \\
socket.o: session.h
imapfilter.o: version.h
install: \$(BIN)
if test ! -d \$(BINDIR); then mkdir -p \$(BINDIR); fi
cp -f \$(BIN) \$(BINDIR) && chmod 0755 \$(BINDIR)/\$(BIN)
if test ! -d \$(SHAREDIR); then mkdir -p \$(SHAREDIR); fi
cp -f \$(INTERFACE_LUA) \$(SHAREDIR) && \\
chmod 0644 \$(SHAREDIR)/\$(INTERFACE_LUA)
cp -f \$(AUXILIARY_LUA) \$(SHAREDIR) && \\
chmod 0644 \$(SHAREDIR)/\$(AUXILIARY_LUA)
if test ! -d \$(MANDIR)/man1; then mkdir -p \$(MANDIR)/man1; fi
cp -f \$(MAN_BIN) \$(MANDIR)/man1 && \\
chmod 0644 \$(MANDIR)/man1/\$(MAN_BIN)
if test ! -d \$(MANDIR)/man5; then mkdir -p \$(MANDIR)/man5; fi
cp -f \$(MAN_CONFIG) \$(MANDIR)/man5 && \\
chmod 0644 \$(MANDIR)/man5/\$(MAN_CONFIG)
deinstall:
rm -f \$(BINDIR)/\$(BIN) \$(SHAREDIR)/\$(INTERFACE_LUA) \\
\$(SHAREDIR)/\$(AUXILIARY_LUA) \$(MANDIR)/man1/\$(MAN_BIN) \\
\$(MANDIR)/man5/\$(MAN_CONFIG)
uninstall: deinstall
clean:
rm -f \$(OBJ) \$(BIN) imapfilter.core core *.orig *.BAK *~
distclean: clean
@if test -f .Makefile; then mv -f .Makefile Makefile; fi
EOF
exit 0
|