summaryrefslogtreecommitdiffstats
path: root/configure
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@rambler-co.ru>2008-05-08 19:05:30 +0400
committerVsevolod Stakhov <vsevolod@rambler-co.ru>2008-05-08 19:05:30 +0400
commit70c78281e3957bdbaa1204e40f2419a4a1918eb7 (patch)
tree29720ef474513c582f8d1faa855b2e81c5e1d3ae /configure
downloadrspamd-70c78281e3957bdbaa1204e40f2419a4a1918eb7.tar.gz
rspamd-70c78281e3957bdbaa1204e40f2419a4a1918eb7.zip
* Add skeleton
Diffstat (limited to 'configure')
-rwxr-xr-xconfigure516
1 files changed, 516 insertions, 0 deletions
diff --git a/configure b/configure
new file mode 100755
index 000000000..e967bb075
--- /dev/null
+++ b/configure
@@ -0,0 +1,516 @@
+#!/bin/sh
+
+GCC="gcc"
+MAKE=""
+LEX=""
+YACC=""
+OS=""
+
+LOCALBASE=/usr/local
+PREFIX=$LOCALBASE
+
+VERSION=0.0.1
+COMPAT_DIR="./compat"
+
+YACC_SRC="cfg_file.y"
+LEX_SRC="cfg_file.l"
+YACC_OUTPUT="cfg_yacc.c"
+LEX_OUTPUT="cfg_lex.c"
+
+SOURCES="upstream.c cfg_utils.c memcached.c main.c util.c worker.c ${LEX_OUTPUT} ${YACC_OUTPUT}"
+
+CFLAGS="$CFLAGS -W -Wall -Wpointer-arith -Wno-unused-parameter"
+CFLAGS="$CFLAGS -Wno-unused-function -Wunused-variable -Wno-sign-compare"
+CFLAGS="$CFLAGS -Wunused-value -ggdb -I${LOCALBASE}/include"
+CFLAGS="$CFLAGS -DRVERSION=\\\"${VERSION}\\\" -DHASH_COMPAT"
+LDFLAGS="$LDFLAGS -L/usr/lib -L${LOCALBASE}/lib"
+OPT_FLAGS="-O -pipe -fno-omit-frame-pointer"
+DEPS="cfg_file.h memcached.h util.h main.h upstream.h ${LEX_OUTPUT} ${YACC_OUTPUT}"
+EXEC=rspamd
+USER=postfix
+GROUP=postfix
+INSTALL="/usr/bin/install -v"
+MKDIR="/usr/bin/install -v -d"
+MANPATH="${PREFIX}/share/man"
+
+MAKEFILE="Makefile"
+MAKEFILE_IN="Makefile.in"
+
+TARGETS="${EXEC}"
+
+cleanup()
+{
+ rm -f autotest.c
+ rm -f autotest
+ INCLUDE=""
+}
+
+check_compiler()
+{
+ GCC=`PATH="$PATH:$PREFIX/bin:$LOCALBASE/bin" which gcc`
+ echo -n "Testing for gcc: "
+ if [ -x $GCC ] ; then
+ echo "found -> $GCC"
+ return 0
+ else
+ echo "not found"
+ exit 1
+ fi
+}
+
+check_make()
+{
+ MAKE=`PATH="$PATH:$PREFIX/bin:$LOCALBASE/bin" which make`
+ echo -n "Testing for make: "
+ if [ -x $MAKE ] ; then
+ echo "found -> $MAKE"
+ return 0
+ else
+ echo "not found"
+ exit 1
+ fi
+
+}
+
+check_lex()
+{
+ LEX=`PATH="$PATH:$PREFIX/bin:$LOCALBASE/bin" which lex`
+ echo -n "Testing for lex: "
+ if [ -x $LEX ] ; then
+ echo "found -> $LEX"
+ return 0
+ else
+ echo "not found"
+ exit 1
+ fi
+
+}
+
+check_yacc()
+{
+ YACC=`PATH="$PATH:$PREFIX/bin:$LOCALBASE/bin" which yacc`
+ echo -n "Testing for yacc: "
+ if [ -x $YACC ] ; then
+ echo "found -> $YACC"
+ return 0
+ else
+ echo "not found"
+ exit 1
+ fi
+
+}
+
+check_function()
+{
+ FUNCTION=$1
+ while [ $# -ne 0 -a -n $2 ] ; do
+ shift
+ if [ "F$INCLUDE" = "F" ] ; then
+ INCLUDE="$1"
+ else
+ INCLUDE="$INCLUDE $1"
+ fi
+ done
+ echo -n "Testing for $FUNCTION: "
+ echo >> config.log
+ echo "Testing for $FUNCTION: " >> config.log
+ echo "#include <sys/types.h>" > autotest.c
+ if [ "F$INCLUDE" != "F" ] ; then
+ for inc in $INCLUDE ; do
+ echo "#include \"$inc\"" >> autotest.c
+ done
+ fi
+ echo "#include <stdlib.h>" >> autotest.c
+ echo "int main (int argc, char **argv) { $FUNCTION; return 0; }" >> autotest.c
+ echo "$GCC $PTHREAD_CFLAGS $CFLAGS -o autotest $LDFLAGS $LIBS $PTHREAD_LDFLAGS autotest.c" >>config.log
+ $GCC $PTHREAD_CFLAGS $CFLAGS -o autotest $LDFLAGS $LIBS $PTHREAD_LDFLAGS autotest.c >>config.log 2>&1
+ if [ $? -eq 0 ] ; then
+ echo "found"
+ cleanup
+ echo "-> OK" >> config.log
+ return 0
+ else
+ echo "not found"
+ echo "-> FAILED" >> config.log
+ echo "Failed program was:" >> config.log
+ cat autotest.c >> config.log
+ cleanup
+ return 1
+ fi
+}
+
+check_include()
+{
+ INCLUDE="$1"
+ echo -n "Testing for $INCLUDE: "
+ echo >> config.log
+ echo "Testing for $INCLUDE: " >> config.log
+ echo "#include <sys/types.h>" > autotest.c
+ echo "#include \"$INCLUDE\"" >> autotest.c
+ echo "#include <stdlib.h>" >> autotest.c
+ echo "int main (int argc, char **argv) { return 0; }" >> autotest.c
+ echo "$GCC $CFLAGS $PTHREAD_CFLAGS -o autotest $LDFLAGS $LIBS $PTHREAD_LDFLAGS autotest.c" >>config.log
+ $GCC $CFLAGS $PTHREAD_CFLAGS -o autotest $LDFLAGS $LIBS $PTHREAD_LDFLAGS autotest.c >>config.log 2>&1
+ if [ $? -eq 0 ] ; then
+ echo "found"
+ echo "-> OK" >> config.log
+ _CFLAG=`echo "-DHAVE_$INCLUDE" | sed -e 's/[./]/_/g' | tr '[:lower:]' '[:upper:]'`
+ CFLAGS="$CFLAGS $_CFLAG"
+ cleanup
+ return 0
+ else
+ echo "not found"
+ echo "-> FAILED" >> config.log
+ echo "Failed program was:" >> config.log
+ cat autotest.c >> config.log
+ cleanup
+ return 1
+ fi
+}
+
+check_macro()
+{
+ MACRO=$1
+ while [ $# -ne 1 -a -n $1 ] ; do
+ shift
+ if [ "F$INCLUDE" = "F" ] ; then
+ INCLUDE="$1"
+ else
+ INCLUDE="$INCLUDE $1"
+ fi
+ done
+ echo -n "Testing for $MACRO: "
+ echo >> config.log
+ echo "Testing for $MACRO: " >> config.log
+ echo "#include <sys/types.h>" > autotest.c
+ for inc in $INCLUDE ; do
+ echo "#include \"$inc\"" >> autotest.c
+ done
+ echo "#include \"${INCLUDE}\"" >> autotest.c
+ echo "#include <stdlib.h>" >> autotest.c
+ echo "int main (int argc, char **argv) {" >>autotest.c
+ echo "#ifndef $MACRO" >>autotest.c
+ echo "#error \"$MACRO not defined\"" >>autotest.c
+ echo "#endif" >> autotest.c
+ echo "}" >>autotest.c
+ echo "$GCC $CFLAGS $PTHREAD_CFLAGS -o autotest $LDFLAGS $LIBS $PTHREAD_LDFLAGS autotest.c" >> config.log
+ $GCC $CFLAGS $PTHREAD_CFLAGS -o autotest $LDFLAGS $LIBS $PTHREAD_LDFLAGS autotest.c >>config.log 2>&1
+ if [ $? -eq 0 ] ; then
+ echo "found"
+ cleanup
+ echo "-> OK" >> config.log
+ return 0
+ else
+ echo "not found"
+ echo "-> FAILED" >> config.log
+ echo "Failed program was:" >> config.log
+ cat autotest.c >> config.log
+ cleanup
+ return 1
+ fi
+}
+
+
+check_lib()
+{
+ LIB=$1
+ while [ $# -ne 1 -a -n $1 ] ; do
+ shift
+ if [ "F$INCLUDE" = "F" ] ; then
+ INCLUDE="$1"
+ else
+ INCLUDE="$INCLUDE $1"
+ fi
+ done
+ echo -n "Testing for lib$LIB: "
+ echo >> config.log
+ echo "Testing for lib$LIB: " >> config.log
+ echo "#include <sys/types.h>" > autotest.c
+ if [ "F$INCLUDE" != "F" ] ; then
+ for inc in $INCLUDE ; do
+ echo "#include \"$inc\"" >> autotest.c
+ done
+ fi
+ echo "#include <stdlib.h>" >> autotest.c
+ echo "int main (int argc, char **argv) { return 0; }" >> autotest.c
+ echo "$GCC $CFLAGS $PTHREAD_CFLAGS -o autotest $LDFLAGS $LIBS -l$LIB $PTHREAD_LDFLAGS autotest.c" >>config.log
+ $GCC $CFLAGS $PTHREAD_CFLAGS -o autotest $LDFLAGS $LIBS -l$LIB $PTHREAD_LDFLAGS autotest.c >>config.log 2>&1
+ if [ $? -eq 0 ] ; then
+ echo "found"
+ LIBS="$LIBS -l$LIB"
+ cleanup
+ echo "-> OK" >> config.log
+ return 0
+ else
+ echo "not found"
+ echo "-> FAILED" >> config.log
+ echo "Failed program was:" >> config.log
+ cat autotest.c >> config.log
+ cleanup
+ return 1
+ fi
+}
+
+check_os()
+{
+ _OS=`uname -s`
+ case "$_OS" in
+ FreeBSD*)
+ OS="freebsd"
+ CFLAGS="${CFLAGS} -DFREEBSD"
+ INSTALL="/usr/bin/install -C -S -v"
+ MKDIR="/usr/bin/install -d -v"
+ MANPATH="${PREFIX}/man" ;;
+ Linux*) OS="linux" CFLAGS="${CFLAGS} -DLINUX -D_GNU_SOURCE" ;;
+ Solaris*) OS="solaris" CFLAGS="${CFLAGS} -DSOLARIS" ;;
+ *) OS="unknown" ;;
+ esac
+}
+
+check_user()
+{
+ _user=$1
+ echo -n "Checking for user $_user: "
+ grep $_user /etc/passwd > /dev/null 2>&1
+ if [ $? -eq 0 ] ; then
+ echo "found"
+ return 0
+ else
+ echo "not found"
+ return 1
+ fi
+}
+
+check_group()
+{
+ _group=$1
+ echo -n "Checking for group $_group: "
+ grep $_group /etc/group > /dev/null 2>&1
+ if [ $? -eq 0 ] ; then
+ echo "found"
+ return 0
+ else
+ echo "not found"
+ return 1
+ fi
+}
+
+write_result()
+{
+ echo "Compiler: $GCC" >> config.log
+ echo "Make: $MAKE" >> config.log
+ echo "Sources: $SOURCES" >> config.log
+ echo "Cflags: $CFLAGS" >> config.log
+ echo "Ldflags: $LDFLAGS" >> config.log
+ echo "Libs: $LIBS" >> config.log
+ OBJECTS=`echo $SOURCES | sed -e 's/\.c/\.o/g'`
+ cat > $MAKEFILE << END
+# This is ${EXEC} Makefile
+# For options edit Makefile.in, this file is autogenerated by configure
+
+CC=$GCC
+# Optimization flags
+OPT_FLAGS=$OPT_FLAGS
+# Compile time flags
+CFLAGS=$CFLAGS
+# Link time flags
+LDFLAGS=$LDFLAGS
+# Libraries to link
+LIBS=$LIBS
+# ${EXEC} sources
+SOURCES=$SOURCES
+# ${EXEC} objects
+OBJECTS=$OBJECTS
+# Version of product
+VERION=$VERSION
+# Detected operation system
+OS=$OS
+# Lex and yacc executables
+LEX=$LEX
+YACC=$YACC
+# Pthread specific flags
+PTHREAD_CFLAGS=$PTHREAD_CFLAGS
+PTHREAD_LDFLAGS=$PTHREAD_LDFLAGS
+# Prefix to install
+PREFIX=$PREFIX
+# Where local libs and includes are located
+LOCALBASE=$LOCALBASE
+# Install commands
+INSTALL=$INSTALL
+MKDIR=$MKDIR
+# Executable name
+EXEC=$EXEC
+# User and group
+RSPAMD_USER=$USER
+RSPAMD_GROUP=$GROUP
+# All target dependenses
+TARGETS=$TARGETS
+# Common dependenses
+DEPS=$DEPS
+# Path to install manual page
+MANPATH=$MANPATH
+
+END
+ # Write build targets to makefile
+
+ cat $MAKEFILE_IN >> $MAKEFILE
+ cat >> $MAKEFILE << END
+${EXEC}: \$(OBJECTS)
+ \$(CC) \$(PTHREAD_LDFLAGS) \$(LDFLAGS) \$(OBJECTS) \$(LIBS) -o \$(EXEC)
+END
+ for o in $OBJECTS ; do
+ SO=`echo $o | sed -e 's/\.o/\.c/g'`
+ cat >> $MAKEFILE << END
+${o}: \$(DEPS) ${SO}
+ \$(CC) \$(OPT_FLAGS) \$(CFLAGS) \$(PTHREAD_CFLAGS) -c ${SO}
+
+END
+ done
+ cat >> $MAKEFILE << END
+${LEX_OUTPUT}: cfg_file.h ${LEX_SRC} ${YACC_OUTPUT}
+ \$(LEX) -o${LEX_OUTPUT} ${LEX_SRC}
+
+${YACC_OUTPUT}: cfg_file.h ${YACC_SRC}
+ \$(YACC) -d -o ${YACC_OUTPUT} ${YACC_SRC}
+END
+
+}
+
+
+for option
+do
+ case "$option" in
+ -*=*) value=`echo "$option" | sed -e 's/[-_a-zA-Z0-9]*=//'` ;;
+ *) value="" ;;
+ esac
+
+ case "$option" in
+ --help) help=yes ;;
+ --prefix) PREFIX=$value ;;
+ --user) USER=$value ;;
+ --group) GROUP=$value ;;
+ --enable-debug) CFLAGS="$CFLAGS -DWITH_DEBUG" OPT_FLAGS="" ;;
+ --enable-opt) OPT_FLAGS="-O3 -pipe" ;;
+ *)
+ echo "$0: error: invalid option \"$option\""
+ exit 1
+ ;;
+ esac
+done
+
+if [ "F$help" = "Fyes" ] ; then
+ cat << END
+
+ --help this message
+
+ --prefix=PATH set the installation prefix
+ --enable-debug turn on extra debug messages
+ --enable-opt turn on extra optimization
+ --user=USER set user to use
+ --group=GROUP set group to use
+END
+ exit 1
+fi
+
+CFLAGS="$CFLAGS -I$PREFIX/include"
+LDFLAGS="$LDFLAGS -L$PREFIX/lib"
+
+echo "Starting configure for rmilter" >config.log
+echo $0 $@ >> config.log
+
+check_compiler
+check_make
+check_lex
+check_yacc
+check_os
+
+check_lib "event" "event.h"
+if [ $? -eq 1 ] ; then
+ echo "Libevent not found, check config.log for details"
+ exit 1
+fi
+
+check_lib "m"
+check_lib "pcre"
+check_lib "md"
+if [ $? -eq 1 ] ; then
+ cp $COMPAT_DIR/md5.c .
+ cp $COMPAT_DIR/md5.h .
+ SOURCES="$SOURCES md5.c"
+ CFLAGS="$CFLAGS -DHAVE_OWN_MD5"
+ DEPS="$DEPS md5.h"
+fi
+
+check_lib "util"
+if [ $? -eq 0 ] ; then
+ CFLAGS="$CFLAGS -DHAVE_LIBUTIL"
+fi
+
+check_function "pidfile_open" "sys/param.h" "libutil.h"
+if [ $? -eq 0 ] ; then
+ CFLAGS="$CFLAGS -DHAVE_PIDFILE"
+fi
+
+check_function "strlcpy" "string.h"
+if [ $? -eq 1 ] ; then
+ cp $COMPAT_DIR/strlcpy.c .
+ cp $COMPAT_DIR/strlcpy.h .
+ SOURCES="$SOURCES strlcpy.c"
+ CFLAGS="$CFLAGS -DHAVE_STRLCPY_H"
+ DEPS="$DEPS strlcpy.h"
+fi
+check_function "bzero" "string.h"
+check_function "srandomdev"
+if [ $? -eq 0 ] ; then
+ CFLAGS="$CFLAGS -DHAVE_SRANDOMDEV"
+fi
+
+check_function "setproctitle" "unistd.h"
+if [ $? -eq 0 ] ; then
+ CFLAGS="$CFLAGS -DHAVE_SETPROCTITLE"
+fi
+
+check_include "endian.h"
+check_include "libutil.h"
+check_include "machine/endian.h"
+check_include "sys/time.h"
+check_include "time.h"
+check_include "stdint.h"
+if [ $? -eq 1 ] ; then
+ check_include "inttypes.h"
+fi
+check_include "strlcpy.h"
+check_include "md5.h"
+check_include "sys/queue.h"
+if [ $? -eq 1 ] ; then
+ cp $COMPAT_DIR/queue.h .
+ DEPS="$DEPS queue.h"
+fi
+check_macro "SLIST_FOREACH_SAFE" "sys/queue.h"
+if [ $? -eq 1 ] ; then
+ cp $COMPAT_DIR/queue.h .
+ CFLAGS="$CFLAGS -DOWN_QUEUE_H"
+ DEPS="$DEPS queue.h"
+fi
+
+check_macro "PATH_MAX" "limits.h"
+if [ $? -eq 1 ] ; then
+ check_macro "MAXPATHLEN" "sys/param.h"
+ if [ $? -eq 1 ] ; then
+ CFLAGS="$CFLAGS -DHAVE_MAXPATHLEN -DMAXPATHLEN=4096"
+ else
+ CFLAGS="$CFLAGS -DHAVE_MAXPATHLEN"
+ fi
+else
+ CFLAGS="$CFLAGS -DHAVE_PATH_MAX"
+fi
+
+check_group $GROUP
+if [ $? -ne 0 ] ; then
+ TARGETS="$TARGETS creategroup"
+fi
+check_user $USER
+if [ $? -ne 0 ] ; then
+ TARGETS="$TARGETS createuser"
+fi
+write_result