dnl dnl Autoconfiguration files for proxytest (a MiX proxy) dnl Konrad Rieck dnl AC_INIT([AN.ON Mix],[00.07.001],[sk13@inf.tu-dresden.de],[mix]) AM_INIT_AUTOMAKE AM_MAINTAINER_MODE AC_PREREQ(2.59) AC_CONFIG_SRCDIR([proxytest.cpp]) AC_CONFIG_HEADERS([config.h]) AC_CANONICAL_HOST dnl Checks for programs. AC_PROG_CC dnl avoid the default flags "-g -o2" SAVEDCXXFLAGS=$CXXFLAGS CXXFLAGS=" " AC_PROG_CXX CXXFLAGS=$SAVEDCXXFLAGS AC_PROG_INSTALL AC_PROG_RANLIB AC_LANG_PUSH(C++) AC_REQUIRE_CPP AC_COMPILE_IFELSE([int main(){return 0;}],[],[AC_MSG_ERROR([Could not run C++ compiler])]) AC_LANG_POP(C++) OFLAGS="" if test "x$GCC" = "xyes" ; then CFLAGS="$CFLAGS -Wall -D_REENTRANT" CXXFLAGS="$CXXFLAGS -Wall -D_REENTRANT" else echo "You need the GNU C Compiler to compile proxytest." exit fi DEFAULTLIBS="$LIBS" #-L/usr/lib -L/usr/local/lib" case "$host" in *-*-solaris*) DEFAULTLIBS="$LIBS -lnsl -lsocket -lposix4" ;; *-*-linux*) DEFAULTLIBS="$LIBS -lpthread" ;; *-*-irix*) CFLAGS="$CFLAGS " ;; *-*-freebsd*) DEFAULTLIBS="$LIBS -L/usr/local/lib -liconv -lpthread"; CFLAGS="$CFLAGS"; CXXFLAGS="$CXXFLAGS"; OFLAGS="-O0" ;; *-*-netbsd*) DEFAULTLIBS="$LIBS -L/usr/pkg/lib -liconv -lpthread" ;; *-*-drops*) CFLAGS="$CFLAGS -DOS_TUDOS" CXXFLAGS="$CXXFLAGS -DOS_TUDOS"; ;; *) ;; esac case "$host" in alpha*) CXXFLAGS="$CXXFLAGS -mieee" ;; m68k*) OFLAGS="-O0" ;; *) if test "x$OFLAGS" == "x" ; then OFLAGS="-O3" fi ;; esac dnl Architecture dependend compiler optimisations MARCH="" AC_ARG_WITH(arch, AS_HELP_STRING([--with-arch=i386|i486|i586|i686|pentium3|opteron],[Specify architecure for optimisation]), [ if test "x$withval" != "xno" ; then MARCH="-march=${withval}" fi ] ) dnl bits for environment AC_ARG_WITH(bits, AS_HELP_STRING([--with-bits=32|64],[Generate code for a 32-bit or 64-bit environment]), [ if test "x$withval" != "xno" ; then MARCH="$MARCH -m${withval}" fi ] ) dnl auto selection --> skip if selecte manually if test -z "$MARCH"; then case "$host_cpu" in i686) MARCH="-march=i686" ;; esac fi OFLAGS="$OFLAGS $MARCH" dnl Static? AC_ARG_ENABLE(static, AS_HELP_STRING([--enable-static],[Static linking]), [ if test "x$enableval" != "xno" ; then CFLAGS="$CFLAGS -static" CXXFLAGS="$CXXFLAGS -static" fi ]) dnl Without epoll? USE_EPOLL=1 AC_ARG_ENABLE(epoll, AS_HELP_STRING([--disable-epoll],[do not use epoll]), [ if test "x$enableval" == "xno" ; then USE_EPOLL=0 fi ]) dnl pool mix ?? POOL="" AC_ARG_ENABLE(pool, AS_HELP_STRING([--enable-pool=POOLSIZE],[Specify if to build a pool mix and optionally the poolsize]), [ if test "x$enableval" != "xno" ; then POOL="-DUSE_POOL" if test "x$enableval" != "xyes" ; then POOL="$POOL -DMIX_POOL_SIZE=$enableval" fi fi ] ) dnl delay channels ?? BANDWIDTH_LIMIT="" AC_ARG_ENABLE(bandwidth-limitation, AS_HELP_STRING([--enable-bandwidth-limitation=LIMITATION_START], [Specify if to build with bandwith limitation and optionally the number of bytes which are transferred without any limitation]), [ if test "x$enableval" != "xno" ; then BANDWIDTH_LIMIT="-DDELAY_CHANNELS" if test "x$enableval" != "xyes" ; then BANDWIDTH_LIMIT="$BANDWIDTH_LIMIT -DDELAY_CHANNEL_TRAFFIC=$enableval" fi fi ] ) BANDWIDTH_LIMIT_THROUGHPUT="" AC_ARG_ENABLE(bandwidth-limitation-throughput, AS_HELP_STRING([--enable-bandwidth-throughput=LIMITATION_THROUGHPUT], [Specify if to build with bandwith limitation and optionally the limit in kByte/s of each communication channel]), [ if test "x$enableval" != "xno" ; then BANDWIDTH_LIMIT_THROUGHPUT="-DDELAY_CHANNELS" if test "x$enableval" != "xyes" ; then BANDWIDTH_LIMIT_THROUGHPUT="$BANDWIDTH_LIMIT_THROUGHPUT -DDELAY_CHANNEL_KBYTE_PER_SECOND=$enableval" fi fi ] ) dnl payment ?? PAYMENT="" AC_ARG_ENABLE(payment, AS_HELP_STRING([--enable-payment], [Specify if to build with payment support]), [ if test "x$enableval" != "xno" ; then PAYMENT="-DPAYMENT" fi ] ) dnl server monitoring ?? SERVER_MONITORING="" AC_ARG_ENABLE(server_monitoring, AS_HELP_STRING([--enable-server_monitoring], [Specify if to build with state tracking for server monitoring]), [ if test "x$enableval" != "xno" ; then SERVER_MONITORING="-DSERVER_MONITORING" fi ] ) dnl replay detection ?? REPLAY_DETECTION="" AC_ARG_ENABLE(replay_detection, AS_HELP_STRING([--enable-replay_detection], [Specify if to build with replay detection support]), [ if test "x$enableval" != "xno" ; then REPLAY_DETECTION="-DREPLAY_DETECTION" fi ] ) dnl type-b mixes ?? NEW_MIX_TYPE="" AC_ARG_ENABLE(new_mix_type, AS_HELP_STRING([--enable-new_mix_type], [Specify if to build with type B mixes]), [ if test "x$enableval" != "xno" ; then NEW_MIX_TYPE="-DNEW_MIX_TYPE" fi ] ) dnl dynamic mix ?? DYNAMIC="" AC_ARG_ENABLE(dynamic, AS_HELP_STRING([--enable-dynamic],[Specify if to build a mix for a dynamic cascade]), [ if test "x$enableval" != "xno" ; then POOL="-DDYNAMIC_MIX" fi ] ) LIBS="$DEFAULTLIBS" dnl Checks for Headers AC_HEADER_STDC AC_CHECK_HEADERS(sys/filio.h) AC_CHECK_HEADERS(sys/epoll.h) AC_CHECK_HEADERS(malloc.h) dnl Check for some "standard" libraries AC_CHECK_LIB(epoll,epoll_ctl) dnl Checks for library functions. AC_FUNC_ALLOCA AC_CHECK_FUNCS([strerror]) AC_CHECK_FUNCS([vsnprintf]) AC_CHECK_FUNCS([snprintf]) AC_CHECK_FUNCS([poll]) AC_CHECK_FUNCS([pthread_mutex_init]) AC_CHECK_FUNCS([pthread_cond_init]) AC_CHECK_FUNCS([sem_init]) AC_CHECK_FUNCS([sbrk]) AC_CHECK_FUNCS([mallinfo]) dnl even if epoll exist it may be unfunctional... if test "x$USE_EPOLL" != "x0" ; then AC_CHECK_FUNC([epoll_wait], [ AC_RUN_IFELSE([AC_LANG_PROGRAM([[#include "sys/epoll.h"]],[[int handle;handle=epoll_create(1);if(handle==-1)exit(-1);]])], [ AC_DEFINE(HAVE_EPOLL,1,[Define if your OS support the epoll() syscall]) ],[],[echo "skip epoll run test because of cross compiling"]) ],[]) fi dnl Checks for declarations. AC_CHECK_DECL(TCP_KEEPALIVE,[AC_DEFINE(HAVE_TCP_KEEPALIVE,,[Define if your OS supports the TCP socket option TCP_KEEPALIVE])],[],[ #include #include ]) AC_CHECK_DECL(AF_UNIX,[AC_DEFINE(HAVE_UNIX_DOMAIN_PROTOCOL,,[Define if your OS supports the Unix Domain protocol])],[],[ #include #include ]) AC_CHECK_DECL(O_BINARY,[],[AC_DEFINE(O_BINARY,0,[This flag is used in open(), in order to open a file in binary mode])],[#include ]) AC_CHECK_DECL(MAX_PATH,[],[AC_DEFINE(MAX_PATH,4096,[This is the maximum length of a file system path])]) AC_CHECK_DECL(INADDR_NONE,[],[AC_DEFINE(INADDR_NONE,-1,[This is the value, which is returned from inet_addr(), in case of an error])],[ #include #include #include ]) AC_CHECK_DECL(FIONREAD,[AC_DEFINE(HAVE_FIONREAD,,[This is a flag to ioctl() to get the number of available bytes on a socket])],[],[#include ]) AC_CHECK_DECL(MSG_NOSIGNAL,[],[AC_DEFINE(MSG_NOSIGNAL,0,[This is a flag to read(), to tell the os to get no signals])],[ #include #include ]) AC_CHECK_DECL(MSG_DONTWAIT,[],[AC_DEFINE(MSG_DONTWAIT,0,[This is a flag to read(), to tell the os does not wait for any bytes to arrive])],[ #include #include ]) AC_CHECK_DECL(O_SYNC,[AC_DEFINE(HAVE_O_SYNC,,[This is a flag to open() to do synchronized I/O])],[],[#include #include ]) AC_CHECK_DECL(O_FSYNC,[AC_DEFINE(HAVE_O_FSYNC,,[This is a flag to open() to do synchronized I/O])],[],[#include #include ]) dnl Checks for types AC_CHECK_TYPE(socklen_t,[AC_DEFINE(HAVE_SOCKLEN_T,,[Define if the type socklen_t is available])],[],[ #include #include ]) dnl Checks for sizes of base types AC_CHECK_SIZEOF(unsigned char) AC_CHECK_SIZEOF(signed char) AC_CHECK_SIZEOF(unsigned short) AC_CHECK_SIZEOF(signed short) AC_CHECK_SIZEOF(unsigned int) AC_CHECK_SIZEOF(signed int) AC_CHECK_SIZEOF(unsigned long) AC_CHECK_SIZEOF(signed long) AC_CHECK_SIZEOF(unsigned long long) AC_CHECK_SIZEOF(__uint64_t) dnl Checks for libraries. dnl Check for OpenSSL libs and includes. Adopted from OpenSSH configure.in dnl defualt palce to look for OpenSSL --> may be overwriten by the option below! tryssldir="/usr/local/openssl /usr/lib/openssl \ /usr/local/ssl /usr/lib/ssl /usr/local /usr/pkg \ /opt /opt/openssl $HOME/ssl $HOME/openssl" AC_ARG_WITH(ssl-dir, AS_HELP_STRING([--with-ssl-dir=PATH],[Specify path to OpenSSL installation]), [ if test "x$withval" != "xno" ; then tryssldir=$withval fi ] ) saved_LIBS="$LIBS" saved_LDFLAGS="$LDFLAGS" saved_CFLAGS="$CFLAGS" if test "x$prefix" != "xNONE" ; then tryssldir="$tryssldir $prefix" fi AC_CACHE_CHECK([for OpenSSL directory], ac_cv_openssldir, [ for ssldir in "" $tryssldir ; do if test ! -z "$ssldir" ; then LDFLAGS="$saved_LDFLAGS -L$ssldir/lib -L$ssldir" CFLAGS="$saved_CFLAGS -I$ssldir/include" if test ! -z "$need_dash_r" ; then LDFLAGS="$LDFLAGS -R$ssldir/lib -R$ssldir" fi else LDFLAGS="$saved_LDFLAGS" fi LIBS="$saved_LIBS -lcrypto" # Basic test to check for compatible version and correct # linking, *does not* test for RSA - that comes later. AC_RUN_IFELSE([AC_LANG_SOURCE([[ #include #include #include int main(void) { char a[2048]; memset(a, 0, sizeof(a)); RAND_add(a, sizeof(a), sizeof(a)); return(RAND_status() <= 0); } ]])], [ found_crypto=1 ],[ ],[ if test -f "$ssldir/libssl.a" && test -f "$ssldir/libcrypto.a"; then found_crypto=1 fi]) if test ! -z "$found_crypto" ; then break; fi done if test -z "$found_crypto" ; then AC_MSG_ERROR([Could not find working SSLeay / OpenSSL libraries (>=0.9.7), please install]) fi if test -z "$ssldir" ; then ssldir="(system)" fi ac_cv_openssldir=$ssldir ]) if (test ! -z "$ac_cv_openssldir" && test "x$ac_cv_openssldir" != "x(system)") ; then AC_DEFINE(HAVE_OPENSSL,,[Define if you have OpenSSL (which is needed!)]) dnl Need to recover ssldir - test above runs in subshell ssldir=$ac_cv_openssldir CFLAGS="$saved_CFLAGS -I$ssldir/include" LDFLAGS="$saved_LDFLAGS -L$ssldir/lib -L$ssldir" if test ! -z "$need_dash_r" ; then LDFLAGS="$LDFLAGS -R$ssldir/lib -R$ssldir" fi if test ! -z "$blibpath" ; then blibpath="$blibpath:$ssldir:$ssldir/lib" fi fi LIBS="-lcrypto -lssl $saved_LIBS" AC_MSG_NOTICE([Xerces-C tests]) dnl Check for Xerces-C AC_LANG_PUSH(C++) dnl Check for XML includes. tryxmlincludedir="/usr/local/include /usr/include" AC_ARG_WITH(xml-include, AS_HELP_STRING([--with-xml-include=PATH], [Specify path to XERCES-C include files (without a trailing '/xercesc')]), [ if test "x$withval" != "xno" ; then tryxmlincludedir=$withval fi ] ) saved_CFLAGS="$CFLAGS" saved_CXXFLAGS="$CXXFLAGS" if test "x$prefix" != "xNONE" ; then tryxmlincludedir="$tryxmlincludedir $prefix" fi AC_MSG_CHECKING([for xerces-c includes]) for xmldir in "" $tryxmlincludedir ; do CFLAGS="$saved_CFLAGS -I$xmldir -I$xmldir/xercesc" CXXFLAGS="$saved_CXXFLAGS -I$xmldir -I$xmldir/xercesc" AC_RUN_IFELSE([AC_LANG_SOURCE([[ #include int main(void) { return 0; } ]])], [ AC_MSG_RESULT([found in $xmldir]) found_xmldir=1 break; ],[ ],[ if test -f "$xmldir/xercesc/util/XMLString.hpp"; then found_xmldir=1 break; fi ]) done if test -z "$found_xmldir"; then AC_MSG_ERROR([Xerces-C includes NOT found - please use --with-xml-include]) fi dnl Check for XML libs AC_MSG_CHECKING([for libxerces-c]) saved_LIBS="$LIBS" saved_LDFLAGS="$LDFLAGS" tryxmllibdir="/usr/local/lib /usr/lib" AC_ARG_WITH(xml-lib, AS_HELP_STRING([--with-xml-lib=PATH],[Specify path to XERCES-C library files]), [ if test "x$withval" != "xno" ; then tryxmllibdir=$withval fi ] ) if test "x$prefix" != "xNONE" ; then tryxmllibdir="$tryxmllibdir $prefix" fi dnl Note: the order is import for compiling on TUDOS LIBS="-lxerces-c $saved_LIBS" for xmllibdir in "" $tryxmllibdir ; do LDFLAGS="$saved_LDFLAGS -L$xmllibdir" AC_LINK_IFELSE([AC_LANG_PROGRAM([ #include "util/XercesDefs.hpp" #include "util/PlatformUtils.hpp" #if (_XERCES_VERSION >= 20200) XERCES_CPP_NAMESPACE_USE #endif ], [XMLPlatformUtils::Initialize() ])],[ AC_MSG_RESULT([found in $xmllibdir]) found_xmllib=1 break; ],[],[found_xmllib=1 AC_MSG_RESULT([skip xml lib run test because of cross compiling]) ]) done if test -z "$found_xmllib"; then AC_MSG_ERROR([Xerces-C libs NOT found - please use --with-xml-lib]) fi AC_LANG_POP(C++) dnl Check for Postgresql libs if (needed if compiled with payment support) if test "x$PAYMENT" != "x" ; then AC_MSG_NOTICE([PostgreSQL tests]) dnl we check for , and AC_CHECK_HEADERS([postgresql/libpq-fe.h],[],[ AC_CHECK_HEADERS([pgsql/libpq-fe.h],[],[ AC_CHECK_HEADERS([libpq-fe.h],[],[ AC_MSG_ERROR([PostgreSQL include file libpq-fe.h not found!]) ] ) ] ) ] ) AC_MSG_CHECKING([for PostgreSQL libs]) saved_LIBS="$LIBS" PAYMENT_LIB="-lpq" LIBS="$LIBS $PAYMENT_LIB" AC_LINK_IFELSE([AC_LANG_PROGRAM([ #ifdef HAVE_POSTGRESQL_LIBPQ_FE_H #include #elif defined(HAVE_PGSQL_LIBPQ_FE_H) #include #else #include #endif ], [PQfinish(0); ])],[AC_MSG_RESULT(libpq found)], [dnl libpq not found trying libpq++ PAYMENT_LIB="-lpq++" LIBS="$saved_LIBS $PAYMENT_LIB" AC_LINK_IFELSE([AC_LANG_PROGRAM([ #ifdef HAVE_POSTGRESQL_LIBPQ_FE_H #include #elif defined(HAVE_PGSQL_LIBPQ_FE_H) #include #else #include #endif ], [PQfinish(0); ])],[AC_MSG_RESULT(libpq++ found)], [AC_MSG_ERROR(PostgreSQL library libpq or libpq++ NOT found - please install them)]) ]) LIBS="$saved_LIBS" fi AC_ARG_ENABLE(debug, AS_HELP_STRING([--enable-debug],[Enable debug mode]), [ if test "x$enableval" != "xno" ; then CFLAGS="$CFLAGS -ggdb3 -D_DEBUG -fno-inline -fno-default-inline" CXXFLAGS="$CXXFLAGS -ggdb3 -D_DEBUG -fno-inline -fno-default-inline" OFLAGS="-O0" else CFLAGS="$CFLAGS -g0" CXXFLAGS="$CXXFLAGS -g0" fi ] ) CRIME="" AC_ARG_ENABLE(crime-detection, AS_HELP_STRING([--enable-crime-detection],[Enable crime detection mode]), [ if test "x$enableval" != "xno" ; then CRIME="-DLOG_CRIME" fi ] ) DOTHETESTS="" AC_ARG_ENABLE(tests, AS_HELP_STRING([--enable-tests],[Build also some functional tests]), [ if test "x$enableval" != "xno" ; then DOTHETESTS="yes" fi ] ) if test "x$DOTHETEST" != "xyes" ; then AC_SUBST(LIBCPPUNIT,cppunit) fi CFLAGS="$CFLAGS $POOL $BANDWIDTH_LIMIT $BANDWIDTH_LIMIT_THROUGHPUT $PAYMENT $SERVER_MONITORING $REPLAY_DETECTION $NEW_MIX_TYPE $CRIME $OFLAGS" CXXFLAGS="$CXXFLAGS $POOL $BANDWIDTH_LIMIT $BANDWIDTH_LIMIT_THROUGHPUT $PAYMENT $SERVER_MONITORING $REPLAY_DETECTION $NEW_MIX_TYPE $CRIME $OFLAGS" LIBS="$LIBS $PAYMENT_LIB" AM_CONDITIONAL([DOTESTS], [test x$DOTHETESTS = xyes]) AC_CONFIG_FILES([Makefile popt/Makefile xml/Makefile trio/Makefile tre/Makefile TypeA/Makefile TypeB/Makefile test/Makefile]) AC_OUTPUT