dnl Process this file with autoconf to produce a configure script. AC_INIT(include/class.h) AC_CONFIG_HEADER(include/setup.h) PACKAGE=ircd-hybrid VERSION=4.2 AC_SUBST(PACKAGE) AC_SUBST(VERSION) AC_ARG_ENABLE(encryption, \ [ --enable-encryption enable rc4 link encryption (removes gnu MP dependancy)],,enable_encryption=yes) dnl Checks for programs. AC_PROG_CC AC_ISC_POSIX AC_CANONICAL_SYSTEM AC_AIX AC_PROG_MAKE_SET AC_PATH_PROG(RM,rm) AC_PATH_PROG(CP,cp) AC_PROG_INSTALL EXTRA_UTILS="" AC_PATH_PROG(MD5SUM, md5sum, no, $PATH:.) if test $MD5SUM = no; then EXTRA_UTILS="$EXTRA_UTILS md5" MD5SUM_ROOT="md5/md5sum" MD5SUM_SRC="../md5/md5sum" else MD5SUM_ROOT="$MD5SUM" MD5SUM_SRC="$MD5SUM" fi dnl Checks for libraries. dnl Replace `main' with a function in -lnsl: AC_CHECK_LIB(nsl, gethostbyname) AC_CHECK_FUNC(res_mkquery,, AC_CHECK_LIB(resolv, res_mkquery)) AC_CHECK_LIB(socket, socket) AC_CHECK_FUNC(crypt,, AC_CHECK_LIB(descrypt, crypt,,AC_CHECK_LIB(crypt, crypt,,))) dnl Checks for header files. AC_HEADER_STDC AC_CHECK_HEADERS(sys/param.h unistd.h string.h strings.h sys/syslog.h stdlib.h stddef.h stropts.h limits.h) AC_CHECK_HEADER(malloc.h, AC_DEFINE(MALLOCH, )) AC_MSG_CHECKING(MIN and MAX definition) AC_EGREP_CPP(yes, [ #if defined( HAVE_SYS_PARAM_H ) #include #ifdef MIN yes #endif #endif ], AC_DEFINE(HAVE_MINMAX) AC_MSG_RESULT(yes), AC_MSG_RESULT(no)) dnl Checks for library functions. AC_PROG_GCC_TRADITIONAL AC_CHECK_FUNCS(index strerror strtoken strtok inet_addr inet_ntoa inet_netof inet_aton) AC_CHECK_FUNCS(gettimeofday lrand48 sigaction bzero bcmp bcopy) AC_CHECK_FUNCS(dn_skipname __dn_skipname getrusage times, break) dnl taken from ircd's Config script nonblock=no AC_MSG_CHECKING(for posix (O_NONBLOCK) nonblocking sockets) AC_TRY_RUN( [ #include #include #include #include #include #include alarmed() { exit(1); } int main() { #if defined(O_NONBLOCK) char b[12], x[32]; int f, l = sizeof(x); f = socket(AF_INET, SOCK_DGRAM, 0); if (f >= 0 && !(fcntl(f, F_SETFL, O_NONBLOCK))) { signal(SIGALRM, alarmed); alarm(3); recvfrom(f, b, 12, 0, (struct sockaddr *)x, &l); alarm(0); exit(0); } #endif exit(1); } ], AC_DEFINE(NBLOCK_POSIX) nonblock=yes AC_MSG_RESULT(O_NONBLOCK), AC_MSG_RESULT(no), AC_MSG_RESULT(can't tell)) if test $nonblock = no; then AC_MSG_CHECKING(for bsd (O_NDELAY) nonblocking sockets) AC_TRY_RUN( [ #include #include #include #include #include #include alarmed() { exit(1); } int main() { #if defined( O_NDELAY ) && !defined( NBLOCK_POSIX ) char b[12], x[32]; int f, l = sizeof(x); f = socket(AF_INET, SOCK_DGRAM, 0); if (f >= 0 && !(fcntl(f, F_SETFL, O_NDELAY))) { signal(SIGALRM, alarmed); alarm(3); recvfrom(f, b, 12, 0, (struct sockaddr *)x, &l); alarm(0); exit(0); } #endif exit(1); } ], AC_DEFINE(NBLOCK_BSD) nonblock=yes AC_MSG_RESULT(O_NDELAY), AC_MSG_RESULT(no), AC_MSG_RESULT(can't tell)) fi if test $nonblock = no; then AC_MSG_CHECKING(for sysv (FIONBIO) nonblocking sockets) AC_TRY_RUN( [ #include #include #include #include #include #include alarmed() { exit(1); } int main() { #if !defined(NBLOCK_BSD) && !defined(NBLOCK_POSIX) && defined(FIONBIO) char b[12], x[32]; int f, l = sizeof(x); f = socket(AF_INET, SOCK_DGRAM, 0); if (f >= 0 && !(fcntl(f, F_SETFL, FIONBIO))) { signal(SIGALRM, alarmed); alarm(3); recvfrom(f, b, 12, 0, (struct sockaddr *)x, &l); alarm(0); exit(0); } #endif /* !NBLOCK_POSIX && !NBLOCK_BSD && FIONBIO */ exit(1); } ], AC_DEFINE(NBLOCK_SYSV) nonblock=yes AC_MSG_RESULT(FIONBIO), AC_MSG_RESULT(no), AC_MSG_RESULT(unable to test)) fi if test $nonblock = no; then AC_MSG_ERROR(No nonblocking socket implementation found. ircd requires nonblocking sockets.) fi dnl taken from ircd's Config script AC_MSG_CHECKING(signal implementation) AC_TRY_RUN( [ int main() { #if defined(HAVE_SIGACTION) exit(0); #else exit(1); #endif } ], AC_DEFINE(POSIX_SIGNALS) AC_MSG_RESULT(posix), AC_TRY_RUN( [ #include int calls = 0; void handler() { if (calls) return; calls++; kill(getpid(), SIGTERM); sleep(1); } int main() { signal(SIGTERM, handler); kill(getpid(), SIGTERM); exit (0); } ], AC_DEFINE(BSD_RELIABLE_SIGNALS) AC_MSG_RESULT(bsd), AC_DEFINE(SYSV_UNRELIABLE_SIGNALS) AC_MSG_RESULT(sysv), AC_MSG_RESULT(uknown)), AC_MSG_RESULT(unknown)) dnl Check for sys_errlist dnl Stolen from BitchX AC_MSG_CHECKING(for sys_errlist declaration) AC_TRY_RUN([ #include #include #include main() { char *s = sys_errlist[0]; exit(0); } ], AC_MSG_RESULT(yes) AC_DEFINE(SYS_ERRLIST_DECLARED), AC_MSG_RESULT(no), AC_MSG_RESULT(cross compiling)) dnl Check to see if we should set USE_FAST_FD_ISSET AC_MSG_CHECKING(to see if we should enable fast FD_ISSET code) AC_TRY_COMPILE(, [ #include int main() { fd_set read_set; read_set.fds_bits; exit(0); } ], AC_MSG_RESULT(yes) AC_DEFINE(USE_FAST_FD_ISSET), AC_MSG_RESULT(no)) dnl Check to see if we have a broken FD_SETSIZE DFDSS='-DFD_SETSIZE=1024' AC_MSG_CHECKING(to see if FD_SETSIZE is broken) AC_TRY_RUN([ #define FD_SETSIZE 666 #include #include int main() { if(FD_SETSIZE != 666) exit(1); exit(0); } ], AC_MSG_RESULT(no), AC_MSG_RESULT(YES) AC_MSG_WARN(FD_SETSIZE is hard set by your operating system) AC_MSG_WARN(MAXCONNECTIONS must be no higher than the hardwired FD_SETSIZE) DFDSS="", AC_MSG_RESULT(can't tell)) AC_SUBST(DFDSS) AC_SUBST(EXTRA_UTILS) AC_SUBST(MD5SUM_SRC) AC_SUBST(MD5SUM_ROOT) if test $enable_encryption = no; then echo "encryption disabled, skipping GNU MP checks..." ENCRYPT_SRC="" AC_SUBST(ENCRYPT_SRC) else echo "encryption enabled, looking for GNU MP library..." ENCRYPT_SRC="rc4.c dh.c" AC_SUBST(ENCRYPT_SRC) AC_DEFINE(HAVE_ENCRYPTION_ON) # ---------- check for gmp library (stolen from eggdrop) CURDIR=`pwd` AC_CHECK_PROG(BASENAME,basename,basename) AC_CHECK_PROG(DIRNAME,dirname,dirname) if test $BASENAME = "" || test $DIRNAME = "" ; then echo ack...no basename or dirname, we cant configure gmp without them. exit 1 fi AC_ARG_WITH(gmplib, [ --with-gmplib=PATH full path to gmp library], gmplibname=$withval) AC_ARG_WITH(gmpinc, [ --with-gmpinc=PATH full path to gmp header], gmpincname=$withval) if test -r "$gmplibname"; then GMPLIB=`$DIRNAME $gmplibname` GMPLIBFN=`$BASENAME $gmplibname | cut -c4-` echo "using gmplib $GMPLIB/lib$GMPLIBFN" else libnames="gmp.so gmp.so.3 gmp.so.3 gmp.so.3.1 gmp.so.3.1.1 gmp.so.3.0.1 gmp.so.3.0 \ gmp.a" # look for libgmp.a: if GMPLIB is set, check there first if test "$GMPLIB" != ""; then GMPLIBFN=notfound for checkfn in $libnames; do if test -r $GMPLIB/lib$checkfn; then if test $GMPLIBFN = notfound; then GMPLIBFN=$checkfn fi fi done if test $GMPLIBFN = notfound; then echo "Environment variable GMPLIB is set, but incorrect." unset GMPLIB fi fi # check in common places now AC_MSG_CHECKING(for libgmp) if test "$GMPLIB" = ""; then for check in $CURDIR/gmp $CURDIR/gmp-3.1.1/.libs /usr/local/lib /usr/lib /usr/i486-linuxaout/lib $HOME $HOME/lib; do if test "$GMPLIB" = ""; then for checkfn in $libnames; do if test -r $check/lib$checkfn; then if test "$GMPLIB" = ""; then AC_MSG_RESULT(found in $check/lib$checkfn) GMPLIB=$check GMPLIBFN=$checkfn fi fi done fi done else AC_MSG_RESULT(found in $GMPLIB/lib$GMPLIBFN) fi fi # option # give up if they don't even have that if test "$GMPLIB" = ""; then AC_MSG_RESULT(not found) fi # now look for pesky $GMPINCFN file if test -r "$gmpincname"; then GMPINC=`$DIRNAME $gmpincname` GMPINCFN=`$BASENAME $gmpincname` echo "using gmp header $GMPINC/$GMPINCFN" else GMPINCFN=gmp.h if test "$GMPINC" != ""; then if test ! -r $GMPINC/$GMPINCFN; then echo "Environment variable GMPINC is set, but incorrect." unset GMPINC fi fi # check in common places now AC_MSG_CHECKING(for $GMPINCFN) if test "$GMPINC" = ""; then for check in $CURDIR/gmp $CURDIR/gmp-3.1.1 /usr/local/include /usr/include $HOME $HOME/include; do if test -r $check/$GMPINCFN; then if test "$GMPINC" != ""; then break fi AC_MSG_RESULT(found in $check/$GMPINCFN) GMPINC=$check break fi done else AC_MSG_RESULT(found in $GMPINC/$GMPINCFN) fi # had GMPLIB but not GMPINC? so close... :( if test "$GMPINC" = ""; then AC_MSG_RESULT(not found) unset GMPLIB unset GMPLIBFN fi fi # option # done looking, now either GMPLIB & GMPINC are both set, or neither is set if test "$GMPLIB" = ""; then echo "" echo "I can't find GNU MP on this system, or I found an older version." echo "" echo "bahamut requires the GNU multiprecision library to compile with encryption." echo "If you wish to disable server link encryption, run configure with" echo "the option --disable-encryption." echo "" echo "If you have the gnu multiprecision library installed, I couldn't find it," echo "or I was confused by an older version. You can set the environment" echo "variables GMPLIB and GMPINC to the directories of the library and the" echo "header file, respectively." echo "" echo "You may also make a directory \"gmp\" in the current directory" echo "and place libgmp.a and gmp.h in that directory, and I will" echo "autodetect it next time you run configure." echo "" echo "You can download gmp at http://www.swox.com/gmp, or any of the" echo "GNU distribution sites (http://www.gnu.org for more information)" exit 1 fi echo Checking $GMPINC/$GMPINCFN directory for gmp version AC_MSG_CHECKING(for gmp.h version) AC_TRY_RUN([ #include #include "$GMPINC/$GMPINCFN" int main() { int major = __GNU_MP_VERSION; if(major < 3) exit(1); exit(0); } ], AC_MSG_RESULT(ok), [ AC_MSG_RESULT(too old) echo "I found a version of gmp.h, but it was either not the gmp I know of," echo "or it was not recent enough (I need gmp version 3.0 or later!)" echo "" echo "You should upgrade gmp from the URL below." echo "" echo "If you do not want to upgrade gmp system wide:" echo "You may make a directory \"gmp\" in the current directory" echo "and place libgmp.a and gmp.h in that directory, and I will" echo "autodetect it next time you run configure." echo "" echo "You can download gmp at http://www.swox.com/gmp, or any of the" echo "GNU distribution sites (http://www.gnu.org for more information)" AC_MSG_ERROR(Invalid or too old gmp.h (pre-version 3?)) ], AC_MSG_RESULT(can't tell)) AC_MSG_CHECKING(how to link to the gmp library) AC_TRY_RUN([ #include int main() { char *x = "$GMPLIBFN"; int a; for(a = 0; x[a]; a++) ; if(a < 3) exit(0); if(x[a-1] == 'a' && x[a-2] == '.') exit(1); exit(0); } ], [ AC_MSG_RESULT(dynamic) GMPLIBFNCUT=`echo $GMPLIBFN | cut -d. -f1` GMP_LIBS="-L$GMPLIB -l$GMPLIBFNCUT" ], [ AC_MSG_RESULT(static) GMP_LIBS="$GMPLIB/lib$GMPLIBFN" ], AC_MSG_RESULT(grr cross compiler blah!)) BKLIBS="$LIBS" LIBS="$LIBS $GMP_LIBS" AC_MSG_CHECKING(for gmp library matching with header) AC_TRY_RUN([ #include #include #include "$GMPINC/$GMPINCFN" char *str_next_period(char *x) { while(*x && *x != '.') x++; if(*x) { *x = '\0'; return x + 1; } return NULL; } void *my_lame_strcpy(char *x, char *y, int ml) { while(*y && ml--) { *x++ = *y++; } *x = '\0'; } int main() { int major_h = 0; int minor_h = 0; int plevel_h = 0; int major_l = 0; int minor_l = 0; int plevel_l = 0; char gv[128], *x, *z; FILE *fp; my_lame_strcpy(gv, gmp_version, 128); #ifdef __GNU_MP_VERSION major_h = __GNU_MP_VERSION; #endif #ifdef __GNU_MP_VERSION_MINOR minor_h = __GNU_MP_VERSION_MINOR; #endif #ifdef __GNU_MP_VERSION_PATCHLEVEL plevel_h = __GNU_MP_VERSION_PATCHLEVEL; #endif fp = fopen(".gmp_h_version", "w"); if(fp) { fprintf(fp, "%d.%d.%d", major_h, minor_h, plevel_h); fclose(fp); } z = gv; x = str_next_period(z); major_l = atoi(z); if(x) { z = x; x = str_next_period(z); minor_l = atoi(z); if(x) { z = x; x = str_next_period(z); plevel_l = atoi(z); } } fp = fopen(".gmp_l_version", "w"); if(fp) { fprintf(fp, "%d.%d.%d", major_l, minor_l, plevel_l); fclose(fp); } if(major_l != major_h) exit(1); exit(0); } ], [ AC_MSG_RESULT(no problems) ], [ AC_MSG_RESULT(problem!) if test -r .gmp_h_version; then GMPHV=`cat .gmp_h_version` GMPLV=`cat .gmp_l_version` echo " - gmp header version: $GMPHV" echo " - gmp library version: $GMPLV" else echo "Link failure! Look for stale libgmp.so in your dynamic link path!" fi $RM -f .gmp_h_version .gmp_l_version echo "Your gmp library either has no version symbols, is not the correct 'gmp'," echo "or the major versions of your gmp library and gmp header differ." echo "You cannot have two versions of the gmp library in your dynamic (.so)" echo "library search path, this may be your problem." echo "" echo "You should upgrade gmp from the URL below." echo "" echo "If you do not want to upgrade gmp system wide:" echo "You may make a directory \"gmp\" in the current directory" echo "and place libgmp.a and gmp.h in that directory, and I will" echo "autodetect it next time you run configure." echo "" echo "You can download gmp at http://www.swox.com/gmp, or any of the" echo "GNU distribution sites (http://www.gnu.org for more information)" AC_MSG_ERROR("bad library/header match") ], AC_MSG_RESULT(cross compile)) LIBS="$BKLIBS" GMPHV=`cat .gmp_h_version` GMPLV=`cat .gmp_l_version` echo " - gmp header version: $GMPHV" echo " - gmp library version: $GMPLV" $RM -f .gmp_h_version .gmp_l_version if test "$GMPHV" != "$GMPLV"; then echo "" echo "Warning!" echo "Your gmp.h and gmp library versions seem to differ!" echo "If you get any linking errors regarding gmp functions (mpz_*)," echo "this is probably the source of your problem!" echo "" echo "You can upgrade gmp from the URL below." echo "" echo "If you do not want to upgrade gmp system wide:" echo "You may make a directory \"gmp\" in the current directory" echo "and place libgmp.a and gmp.h in that directory, and I will" echo "autodetect it next time you run configure." echo "" echo "You can download gmp at http://www.swox.com/gmp, or any of the" echo "GNU distribution sites (http://www.gnu.org for more information)" fi AC_SUBST(GMPINC) AC_SUBST(GMPINCFN) AC_SUBST(GMP_LIBS) fi dnl end of gmp library test dnl don't add more of these unless it's critical. Trying to get rid of them. AC_MSG_CHECKING(operating system) case "$target" in *-solaris2*) AC_DEFINE(OS_SOLARIS2) AC_MSG_RESULT(Solaris 2.x) ;; *-aix*) AC_DEFINE(OS_AIX) AC_MSG_RESULT(AIX) ;; *-esix*) AC_DEFINE(OS_ESIX) AC_MSG_RESULT(ESIX) ;; *-next*) AC_DEFINE(OS_NEXT) AC_MSG_RESULT(NeXT something) ;; *-mips*) AC_DEFINE(OS_MIPS) AC_MSG_RESULT(MIPS something) ;; *-sequent-ptx*) AC_DEFINE(OS_DYNIXPTX) AC_MSG_RESULT(Dynix PTX) ;; *-hpux*) AC_DEFINE(OS_HPUX) AC_MSG_RESULT(HP-UX) ;; *) AC_MSG_RESULT(nothing special required) ;; esac AC_OUTPUT(Makefile src/Makefile tools/Makefile include/gmp_irc.h) echo configuring zlib... cd zlib ./configure cd ..