mirror of
https://github.com/moparisthebest/imapfilter
synced 2024-12-22 07:38:49 -05:00
4fe1a3d649
Move the source code to the src dir, the man pages to the doc dir, and the example configuration files to the samples dir, and update all relevant files to reflect the changes.
256 lines
6.0 KiB
Bash
Executable File
256 lines
6.0 KiB
Bash
Executable File
#!/bin/sh
|
|
|
|
# Default values
|
|
|
|
prefix="/usr/local"
|
|
bindir="$prefix/bin"
|
|
sharedir="$prefix/share/imapfilter"
|
|
mandir="$prefix/man"
|
|
|
|
ssltls="yes"
|
|
crammd5="yes"
|
|
|
|
incdirs="-I/usr/local/include"
|
|
libdirs="-L/usr/local/lib"
|
|
|
|
mycflags="$CFLAGS -Wall -O"
|
|
myldflags="$LDFLAGS"
|
|
|
|
libs="-lm -llua -lpcre"
|
|
libssl="-lssl"
|
|
libcrypto="-lcrypto"
|
|
|
|
defs="-DMAKEFILE_SHAREDIR='\"\$(SHAREDIR)\"'"
|
|
|
|
bin="imapfilter"
|
|
|
|
|
|
# Get options and arguments
|
|
|
|
while getopts "d:p:b:s:m:o:h" opt
|
|
do
|
|
case $opt in
|
|
d | p)
|
|
prefix=$OPTARG
|
|
bindir=$prefix/bin
|
|
sharedir=$prefix/share/imapfilter
|
|
mandir=$prefix/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] [-p prefix] [-b bindir] [-s sharedir] [-m mandir]
|
|
[-o option=argument]
|
|
|
|
Description:
|
|
-h This brief usage and description message.
|
|
-p prefix Installation path for program's files [$prefix]
|
|
-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
|
|
Installation directory: $prefix
|
|
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
|
|
|
|
|
|
# Change to the source directory
|
|
cd src
|
|
|
|
|
|
# Backup of original Makefile
|
|
|
|
if [ ! -f .Makefile ]; then cp -f Makefile .Makefile; fi
|
|
|
|
|
|
# Write Makefile
|
|
|
|
mv -f Makefile Makefile~
|
|
|
|
cat > Makefile << EOF
|
|
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
|
|
|
|
COMMON_LUA = common.lua
|
|
SET_LUA = set.lua
|
|
REGEX_LUA = regex.lua
|
|
ACCOUNT_LUA = account.lua
|
|
MAILBOX_LUA = mailbox.lua
|
|
MESSAGE_LUA = message.lua
|
|
OPTIONS_LUA = options.lua
|
|
AUXILIARY_LUA = auxiliary.lua
|
|
DEPRECATED_LUA = deprecated.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 pcre.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 \$(DESTDIR)\$(BINDIR); then \\
|
|
mkdir -p \$(DESTDIR)\$(BINDIR); fi
|
|
cp -f \$(BIN) \$(DESTDIR)\$(BINDIR) && \\
|
|
chmod 0755 \$(DESTDIR)\$(BINDIR)/\$(BIN)
|
|
if test ! -d \$(DESTDIR)\$(SHAREDIR); then \\
|
|
mkdir -p \$(DESTDIR)\$(SHAREDIR); fi
|
|
cp -f \$(COMMON_LUA) \$(DESTDIR)\$(SHAREDIR) && \\
|
|
chmod 0644 \$(DESTDIR)\$(SHAREDIR)/\$(COMMON_LUA)
|
|
cp -f \$(SET_LUA) \$(DESTDIR)\$(SHAREDIR) && \\
|
|
chmod 0644 \$(DESTDIR)\$(SHAREDIR)/\$(SET_LUA)
|
|
cp -f \$(REGEX_LUA) \$(DESTDIR)\$(SHAREDIR) && \\
|
|
chmod 0644 \$(DESTDIR)\$(SHAREDIR)/\$(REGEX_LUA)
|
|
cp -f \$(ACCOUNT_LUA) \$(DESTDIR)\$(SHAREDIR) && \\
|
|
chmod 0644 \$(DESTDIR)\$(SHAREDIR)/\$(ACCOUNT_LUA)
|
|
cp -f \$(MAILBOX_LUA) \$(DESTDIR)\$(SHAREDIR) && \\
|
|
chmod 0644 \$(DESTDIR)\$(SHAREDIR)/\$(MAILBOX_LUA)
|
|
cp -f \$(MESSAGE_LUA) \$(DESTDIR)\$(SHAREDIR) && \\
|
|
chmod 0644 \$(DESTDIR)\$(SHAREDIR)/\$(MESSAGE_LUA)
|
|
cp -f \$(OPTIONS_LUA) \$(DESTDIR)\$(SHAREDIR) && \\
|
|
chmod 0644 \$(DESTDIR)\$(SHAREDIR)/\$(OPTIONS_LUA)
|
|
cp -f \$(AUXILIARY_LUA) \$(DESTDIR)\$(SHAREDIR) && \\
|
|
chmod 0644 \$(DESTDIR)\$(SHAREDIR)/\$(AUXILIARY_LUA)
|
|
cp -f \$(DEPRECATED_LUA) \$(DESTDIR)\$(SHAREDIR) && \\
|
|
chmod 0644 \$(DESTDIR)\$(SHAREDIR)/\$(DEPRECATED_LUA)
|
|
if test ! -d \$(DESTDIR)\$(MANDIR)/man1; then \\
|
|
mkdir -p \$(DESTDIR)\$(MANDIR)/man1; fi
|
|
cp -f ../doc/\$(MAN_BIN) \$(DESTDIR)\$(MANDIR)/man1 && \\
|
|
chmod 0644 \$(DESTDIR)\$(MANDIR)/man1/\$(MAN_BIN)
|
|
if test ! -d \$(DESTDIR)\$(MANDIR)/man5; then \\
|
|
mkdir -p \$(DESTDIR)\$(MANDIR)/man5; fi
|
|
cp -f ../doc/\$(MAN_CONFIG) \$(DESTDIR)\$(MANDIR)/man5 && \\
|
|
chmod 0644 \$(DESTDIR)\$(MANDIR)/man5/\$(MAN_CONFIG)
|
|
|
|
deinstall:
|
|
rm -f \$(DESTDIR)\$(BINDIR)/\$(BIN) \\
|
|
\$(DESTDIR)\$(SHAREDIR)/\$(COMMON_LUA) \\
|
|
\$(DESTDIR)\$(SHAREDIR)/\$(SET_LUA) \\
|
|
\$(DESTDIR)\$(SHAREDIR)/\$(REGEX_LUA) \\
|
|
\$(DESTDIR)\$(SHAREDIR)/\$(ACCOUNT_LUA) \\
|
|
\$(DESTDIR)\$(SHAREDIR)/\$(MAILBOX_LUA) \\
|
|
\$(DESTDIR)\$(SHAREDIR)/\$(MESSAGE_LUA) \\
|
|
\$(DESTDIR)\$(SHAREDIR)/\$(OPTIONS_LUA) \\
|
|
\$(DESTDIR)\$(SHAREDIR)/\$(AUXILIARY_LUA) \\
|
|
\$(DESTDIR)\$(SHAREDIR)/\$(DEPRECATED_LUA) \\
|
|
\$(DESTDIR)\$(MANDIR)/man1/\$(MAN_BIN) \\
|
|
\$(DESTDIR)\$(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
|