added basic ssl support to ircu
[ircu2.10.12-pk.git] / configure.in
index 7b0fa7dff8a96e27d8e1739b9f99bad5f1b5112d..d4205cfa3cf51734f64d3e7680d763c0a87094e2 100644 (file)
@@ -41,8 +41,8 @@ ac_default_prefix=$unet_cv_prefix
 dnl Define the input and output configuration header file.
 AC_CONFIG_HEADER([config.h])
 
-dnl Demand at least version 2.13 of autoconf
-AC_PREREQ(2.13)
+dnl Demand at least version 2.59 of autoconf (for AS_HELP_STRING)
+AC_PREREQ(2.59)
 
 dnl Find out what type of system we are
 AC_CANONICAL_HOST
@@ -52,50 +52,6 @@ AC_PROG_CC
 
 dnl ANSIfy the C compiler whenever possible.
 AM_PROG_CC_STDC
-dnl Use -O3 instead of -O2.
-if test x"$CFLAGS" != x; then
-    CFLAGS=`echo "$CFLAGS" | sed -e 's/-O2/-O3/'`
-fi
-dnl Remove -pipe during configure
-if test x"$CFLAGS" != x; then
-    CFLAGS=`echo "$CFLAGS" | sed -e 's/-pipe//g'`
-fi
-dnl Notice the -g flag and deal accordingly
-if test x"$CFLAGS" != x; then
-    unet_old_cflags=$CFLAGS
-    CFLAGS=`echo "$CFLAGS" | sed -e 's/-g//g'`
-fi
-if test x"$CFLAGS" != x"$unet_old_cflags"; then
-    # If -g was already there, force symbols to be enabled
-    unet_cv_enable_symbols=yes
-fi
-dnl Notice the -pg flag and deal accordingly
-if test x"$CFLAGS" != x; then
-    unet_old_cflags=$CFLAGS
-    CFLAGS=`echo "$CFLAGS" | sed -e 's/-pg//g'`
-fi
-if test x"$CFLAGS" != x"$unet_old_cflags"; then
-    # If -pg was already there, force profiling to be enabled
-    unet_cv_enable_profile=yes
-fi
-dnl Notice the -Wall flag and deal accordingly
-if test x"$CFLAGS" != x; then
-    unet_old_cflags=$CFLAGS
-    CFLAGS=`echo "$CFLAGS" | sed -e 's/-Wall//g'`
-fi
-if test x"$CFLAGS" != x"$unet_old_cflags"; then
-    # If -Wall was already there, force warnings to be enabled
-    unet_cv_enable_warnings=yes
-fi
-dnl Notice the -pedantic flag and deal accordingly
-if test x"$CFLAGS" != x; then
-    unet_old_cflags=$CFLAGS
-    CFLAGS=`echo "$CFLAGS" | sed -e 's/-pedantic//g'`
-fi
-if test x"$CFLAGS" != x"$unet_old_cflags"; then
-    # If -pedantic was already there, force pedatic to be enabled
-    unet_cv_enable_pedantic=yes
-fi
 
 dnl Checks for libraries.
 
@@ -108,7 +64,7 @@ AC_LIBRARY_NET
 
 dnl Checks for header files.
 AC_HEADER_STDC
-AC_CHECK_HEADERS(poll.h sys/devpoll.h sys/event.h)
+AC_CHECK_HEADERS(crypt.h poll.h inttypes.h stdint.h sys/devpoll.h sys/epoll.h sys/event.h sys/param.h sys/resource.h sys/socket.h)
 
 dnl Checks for typedefs, structures, and compiler characteristics
 dnl AC_C_CONST
@@ -118,6 +74,34 @@ AC_HEADER_TIME
 AC_STRUCT_TM
 AC_TYPE_UID_T
 unet_CHECK_TYPE_SIZES
+AC_CHECK_TYPE(struct sockaddr_in6, [unet_have_sockaddr_in6="yes"], [unet_have_sockaddr_in6="no"], [#include <sys/types.h>
+#include <netinet/in.h>])
+
+dnl Check for socklen_t.  In traditional BSD this is an int, but some
+dnl OSes use a different type.  Test until we find something that will
+dnl work properly.  Test borrowed from a patch submitted for Python.
+AC_CHECK_TYPE([socklen_t], ,[
+  AC_MSG_CHECKING([for socklen_t equivalent])
+  AC_CACHE_VAL([curl_cv_socklen_t_equiv],
+  [
+dnl Systems have either "struct sockaddr*" or "void*" as second
+dnl arg to getpeername.
+    curl_cv_socklen_t_equiv=
+    for arg2 in "struct sockaddr" void ; do
+      for t in int size_t unsigned long "unsigned long" ; do
+        AC_TRY_COMPILE([#include <sys/types.h>
+#include <sys/socket.h>
+int getpeername (int $arg2 *, $t *);],[$t len;
+  getpeername(0, 0, &len);], [curl_cv_socklen_t_equiv="$t"
+  break])
+      done
+    done
+  ])
+  AC_MSG_RESULT($curl_cv_socklen_t_equiv)
+  AC_DEFINE_UNQUOTED(socklen_t, $curl_cv_socklen_t_equiv,
+      [type to use in place of socklen_t if not defined])],
+  [#include <sys/types.h>
+#include<sys/socket.h>])
 
 dnl Checks for library functions.
 AC_CHECK_FUNCS([kqueue setrlimit getrusage times])
@@ -137,19 +121,39 @@ AC_PROG_LN_S
 AC_PATH_PROGS(RMPROG, rm, /bin/rm)
 AC_PATH_PROGS(SHPROG, sh, /bin/sh)
 
+dnl (F)LEX - needed for the new conf file parser
+AC_PROG_LEX
+dnl The autoconf docs say $LEX defaults to 'lex'.  They lie.
+if test "$LEX" = ":" ; then
+  AC_MSG_ERROR([Cannot find flex.])
+elif echo "" | $LEX -V -v --version > /dev/null 2>&1 ; then
+  :
+else
+  AC_MSG_ERROR([Cannot use $LEX as flex.])
+fi
+
+dnl YACC - ditto
+AC_PROG_YACC
+dnl The autoconf docs say $YACC defaults to 'yacc'.  This seems to be true,
+dnl but judging from AC_PROG_LEX, it may not stay true.
+if test "$YACC" = ":" ; then
+  AC_MSG_ERROR([Cannot find yacc.])
+elif echo "" | $YACC -V -v --version > /dev/null 2>&1 ; then
+  :
+else
+dnl byacc does not seem to have any way to test for workingness, so only warn.
+  AC_MSG_WARN([$YACC may not work as yacc.])
+fi
+
 unet_NONBLOCKING
 unet_SIGNALS
 
-dnl Add -pipe when possible
-unet_PIPE_CFLAGS
-
 dnl Check OS for os_dep files.
 AC_MSG_CHECKING(for OS-dependent information)
 case "$host" in
     *-linux*)
        AC_MSG_RESULT([Linux ($host) found.])
        unet_poll_syscall=yes
-       OSDEP_C=os_linux.c
        ;;
 
     *-solaris*)
@@ -159,13 +163,12 @@ case "$host" in
        else
            unet_poll_syscall=no
        fi
-       OSDEP_C=os_solaris.c
+        AC_DEFINE([IRCU_SOLARIS], 1, [Define if building on Solaris])
        ;;
 
     *-sunos*)
        AC_MSG_RESULT([Solaris ($host) found.])
        unet_poll_syscall=no
-       OSDEP_C=os_solaris.c
        ;;
 
     *-openbsd*)
@@ -175,7 +178,6 @@ case "$host" in
        else
            unet_poll_syscall=no
        fi
-       OSDEP_C=os_openbsd.c
        ;;
 
     *-*bsd*)
@@ -185,23 +187,19 @@ case "$host" in
        else
            unet_poll_syscall=no
        fi
-       OSDEP_C=os_bsd.c
        ;;
 
     *-darwin*)
        AC_MSG_RESULT([Darwin (Mac OS X) ($host) found.])
        unet_poll_syscall=no
-       OSDEP_C=os_bsd.c
        ;;
 
     *)
        AC_MSG_RESULT([Unknown system type $host found.])
        AC_MSG_WARN([Unknown OS type; using generic routines.])
        unet_poll_syscall=no
-       OSDEP_C=os_generic.c
        ;;
 esac
-AC_SUBST(OSDEP_C)
 
 dnl Check user configuration options
 dnl Start with --enable-poll
@@ -221,13 +219,31 @@ fi
 AC_MSG_RESULT([$unet_cv_enable_poll])
 
 if test x"$unet_cv_enable_poll" = xyes; then
-    AC_DEFINE([USE_POLL], , [Specify whether or not to use poll()])
+    AC_DEFINE([USE_POLL], 1, [Specify whether or not to use poll()])
     ENGINE_C=engine_poll.c
 else
     ENGINE_C=engine_select.c
 fi
 AC_SUBST(ENGINE_C)
 
+have_gnutls="no"
+AC_CHECK_LIB(gnutls, gnutls_init, [
+  AC_CHECK_HEADERS(gnutls/gnutls.h, [
+    LIBS="$LIBS -lgnutls"
+    have_gnutls="yes"
+  ])
+])
+if test x"$have_gnutls" = xno; then
+  if test x$is_win32 = xyes ; then
+    openssl_deps="-lcrypto -lgdi32"
+  else
+    openssl_deps="-lcrypto"
+  fi
+  AC_CHECK_LIB([ssl],[SSL_library_init], [
+    LIBS="$LIBS -lssl $openssl_deps"
+  ], [], $openssl_deps)
+fi
+
 dnl Now look for --enable-debug
 AC_MSG_CHECKING([whether to enable debug mode])
 AC_ARG_ENABLE([debug],
@@ -238,7 +254,33 @@ AC_ARG_ENABLE([debug],
 AC_MSG_RESULT([$unet_cv_enable_debug])
 
 if test x"$unet_cv_enable_debug" = xyes; then
-    AC_DEFINE([DEBUGMODE], , [Enable debugging code])
+    AC_DEFINE([DEBUGMODE], 1, [Enable debugging code])
+fi
+
+dnl Now look for --enable-leak-detect
+AC_MSG_CHECKING([whether to enable leak detection])
+AC_ARG_WITH([leak-detect],
+[  --with-leak-detect          Turn on the leak detector(requires patched boehm)],
+[unet_cv_with_leak_detect=$with_leak_detect],
+[AC_CACHE_VAL(unet_cv_with_leak_detect,
+[unet_cv_with_leak_detect=no])])
+AC_MSG_RESULT([$unet_cv_enable_leak_detect])
+
+if test x"$unet_cv_with_leak_detect" != xno; then
+    LIBS="-lgc $LIBS"
+    CFLAGS="-DMDEBUG $CFLAGS"
+    if test x"$unet_cv_with_leak_detect" != xyes; then
+       LIBS="-L$unet_cv_with_leak_detect $LIBS"
+    fi
+fi
+
+AC_ARG_WITH([ipv6],
+    AS_HELP_STRING([--without-ipv6], [disable IPv6 support (default is autodetect)]),
+    [ac_cv_use_ipv6=$withval],
+    [ac_cv_use_ipv6=$unet_have_sockaddr_in6])
+AC_CACHE_CHECK([whether to use IPv6], [ac_cv_use_ipv6], [ac_cv_use_ipv6=no])
+if test x"$ac_cv_use_ipv6" != "xno" ; then
+    AC_DEFINE([IPV6], 1, [Enable IPv6 support])
 fi
 
 dnl And now for --disable-asserts
@@ -251,39 +293,13 @@ AC_ARG_ENABLE([asserts],
 AC_MSG_RESULT([$unet_cv_enable_asserts])
 
 if test x"$unet_cv_enable_asserts" = xno; then
-    AC_DEFINE([NDEBUG], , [Disable assertions])
-fi
-
-dnl Check for --enable-symbols
-AC_MSG_CHECKING([whether to enable debugging symbols])
-AC_ARG_ENABLE([symbols],
-[  --disable-symbols       Disable debugging symbols (remove -g from CFLAGS)],
-[unet_cv_enable_symbols=$enable_symbols],
-[AC_CACHE_VAL(unet_cv_enable_symbols,
-[unet_cv_enable_symbols=yes])])
-AC_MSG_RESULT([$unet_cv_enable_symbols])
-
-if test x"$unet_cv_enable_symbols" = xyes; then
-    CFLAGS="-g $CFLAGS"
-fi
-
-dnl Check for --disable-headinsand
-AC_MSG_CHECKING([whether to enable head in sand 'features'])
-AC_ARG_ENABLE([headinsand],
-[  --disable-headinsand      Disable head in sand (-DNO_HEAD_IN_SAND)],
-[unet_cv_enable_headinsand=$enable_headinsand],
-[AC_CACHE_VAL(unet_cv_enable_headinsand,
-[unet_cv_enable_headinsand=yes])])
-AC_MSG_RESULT([$unet_cv_enable_headinsand])
-
-if test x"$unet_cv_enable_headinsand" = xno; then
-    CFLAGS="-DNO_HEAD_IN_SAND $CFLAGS"
+    AC_DEFINE([NDEBUG], 1, [Disable assertions])
 fi
 
 dnl Now check for --enable-profile
 AC_MSG_CHECKING([whether to enable profiling support (gprof)])
 AC_ARG_ENABLE([profile],
-[  --enable-profile        Enable profiling support (add -pg to CFLAGS)],
+[  --enable-profile        Enable profiling support (add -pg to CFLAGS and LDFLAGS)],
 [unet_cv_enable_profile=$enable_profile],
 [AC_CACHE_VAL(unet_cv_enable_profile,
 [unet_cv_enable_profile=no])])
@@ -291,6 +307,7 @@ AC_MSG_RESULT([$unet_cv_enable_profile])
 
 if test x"$unet_cv_enable_profile" = xyes; then
     CFLAGS="-pg $CFLAGS"
+    LDFLAGS="-pg $LDFLAGS"
 fi
 
 dnl Now check for --enable-pedantic
@@ -329,13 +346,13 @@ AC_ARG_ENABLE([inlines],
 AC_MSG_RESULT([$unet_cv_enable_inlines])
 
 if test x"$unet_cv_enable_inlines" = xyes; then
-    AC_DEFINE([FORCEINLINE], , [Force inlining for a few critical functions])
+    AC_DEFINE([FORCEINLINE], 1, [Force inlining for a few critical functions])
 fi
 
 dnl --disable-devpoll check...
 AC_MSG_CHECKING([whether to enable the /dev/poll event engine])
 AC_ARG_ENABLE([devpoll],
-[  --disable-devpoll       Enable the /dev/poll-based engine],
+[  --disable-devpoll       Disable the /dev/poll-based engine],
 [unet_cv_enable_devpoll=$enable_devpoll],
 [AC_CACHE_VAL(unet_cv_enable_devpoll,
 [unet_cv_enable_devpoll=yes])])
@@ -347,14 +364,14 @@ fi
 AC_MSG_RESULT([$unet_cv_enable_devpoll])
 
 if test x"$unet_cv_enable_devpoll" != xno; then
-    AC_DEFINE([USE_DEVPOLL], , [Define to enable the /dev/poll engine])
+    AC_DEFINE([USE_DEVPOLL], 1, [Define to enable the /dev/poll engine])
     ENGINE_C="engine_devpoll.c $ENGINE_C"
 fi
 
 dnl --disable-kqueue check...
 AC_MSG_CHECKING([whether to enable the kqueue event engine])
 AC_ARG_ENABLE([kqueue],
-[  --disable-kqueue        Enable the kqueue-based engine],
+[  --disable-kqueue        Disable the kqueue-based engine],
 [unet_cv_enable_kqueue=$enable_kqueue],
 [AC_CACHE_VAL(unet_cv_enable_kqueue,
 [unet_cv_enable_kqueue=yes])])
@@ -366,37 +383,54 @@ fi
 AC_MSG_RESULT([$unet_cv_enable_kqueue])
 
 if test x"$unet_cv_enable_kqueue" != xno; then
-    AC_DEFINE([USE_KQUEUE], , [Define to enable the kqueue engine])
+    AC_DEFINE([USE_KQUEUE], 1, [Define to enable the kqueue engine])
     ENGINE_C="engine_kqueue.c $ENGINE_C"
 fi
 
-dnl --disable-adns check...
-AC_MSG_CHECKING([whether to enable the adns resolver engine])
-AC_ARG_ENABLE([adns],
-[  --disable-adns          Disable adns resolver],
-[unet_cv_enable_adns=$enable_adns],
-[AC_CACHE_VAL(unet_cv_enable_adns,
-[unet_cv_enable_adns=yes])])
+dnl --disable-epoll check
+AC_MSG_CHECKING([whether to enable the epoll event engine])
+AC_ARG_ENABLE([epoll],
+[  --disable-epoll         Disable the epoll-based engine],
+[unet_cv_enable_epoll=$enable_epoll],
+[AC_CACHE_VAL(unet_cv_enable_epoll,
+[unet_cv_enable_epoll=yes])])
 
-AC_MSG_RESULT([$unet_cv_enable_adns])
+if test x"$ac_cv_header_sys_epoll_h" = xno -o x"$ac_cv_func_epoll" = xno; then
+    unet_cv_enable_epoll=no
+fi
 
-if test x"$unet_cv_enable_adns" != xno; then
-    AC_DEFINE([USE_ADNS], , [Define to enable the adns resolver])
-    AC_CONFIG_SUBDIRS([adns])
-    RES_C="res_adns.c"
-    LIBS="../adns/src/libadns.a $LIBS"
-    ADNS_SUBDIR="adns"
-else
-    RES_C="res_libresolv.c"
-    ADNS_SUBDIR=""
+AC_MSG_RESULT([$unet_cv_enable_epoll])
+
+dnl If we have the header and user has not refused epoll, we still need
+dnl to check whether the functions are properly defined.
+if test x"$unet_cv_enable_epoll" != xno; then
+    AC_MSG_CHECKING([whether epoll functions are properly defined])
+    AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <sys/epoll.h>], [epoll_create(10);])],
+        [AC_MSG_RESULT([yes])],
+        [AC_MSG_RESULT([no])
+         AC_DEFINE([EPOLL_NEED_BODY], 1, [Define to implement epoll system calls])])
+    AC_DEFINE([USE_EPOLL], 1, [Define to enable the epoll engine])
+    ENGINE_C="engine_epoll.c $ENGINE_C"
+fi
+
+dnl How to copy one va_list to another?
+AC_CACHE_CHECK([for va_copy], unet_cv_c_va_copy, [AC_LINK_IFELSE(
+  [AC_LANG_PROGRAM([#include <stdarg.h>], [va_list ap1, ap2; va_copy(ap1, ap2);])],
+  [unet_cv_c_va_copy="yes"],
+  [unet_cv_c_va_copy="no"]
+)])
+if test "$unet_cv_c_va_copy" = "yes" ; then
+  AC_DEFINE(HAVE_VA_COPY, 1, [Define if we have va_copy])
+fi
 
-    dnl Look for res_mkquery.  Done after AC_LIBRARY_NET in case res_mkquery
-    dnl is in one of those libraries somewhere.
-    AC_SEARCH_LIBS(res_mkquery, resolv, ,
-    [AC_MSG_ERROR([Unable to find library containing res_mkquery()])])
+AC_CACHE_CHECK([for __va_copy], unet_cv_c___va_copy, [AC_LINK_IFELSE(
+  [AC_LANG_PROGRAM([#include <stdarg.h>], [va_list ap1, ap2; __va_copy(ap1, ap2);])],
+  [unet_cv_c___va_copy="yes"],
+  [unet_cv_c___va_copy="no"]
+)])
+if test "$unet_cv_c___va_copy" = "yes" ; then
+  AC_DEFINE(HAVE___VA_COPY, 1, [Define if we have __va_copy])
 fi
-AC_SUBST(RES_C)
-AC_SUBST(ADNS_SUBDIR)
 
 dnl --with-symlink lets us set the name of the symlink; defaults to "ircd"
 AC_MSG_CHECKING([what name to give the symlink])
@@ -674,6 +708,9 @@ AC_DEFINE_UNQUOTED(LPATH, "$unet_lpath", [Path to debugging log file])
 
 dnl --with-maxcon allows us to set the maximum connections
 unet_maxcon=`ulimit -Hn`
+if test x"$unet_maxcon" = xunlimited; then
+    unet_maxcon=`ulimit -Sn`
+fi
 unet_maxcon=`expr $unet_maxcon - 4`
 AC_MSG_CHECKING([max connections])
 AC_ARG_WITH([maxcon],
@@ -683,7 +720,12 @@ AC_ARG_WITH([maxcon],
 [unet_cv_with_maxcon=$unet_maxcon])])
 
 if test x"$unet_cv_with_maxcon" = xyes -o x"$unet_cv_with_maxcon" = xno; then
+    if test "$unet_maxcon" -lt 32; then
+      AC_MSG_ERROR([Maximum connections (number of open files minus 4) must be at least 32.])
+    fi
     unet_cv_with_maxcon=$unet_maxcon
+elif test "$unet_cv_with_maxcon" -lt 32; then
+    AC_MSG_ERROR([Maximum connections (--with-maxcon) must be at least 32.])
 fi
 
 AC_MSG_RESULT([$unet_cv_with_maxcon])
@@ -692,7 +734,7 @@ AC_DEFINE_UNQUOTED(MAXCONNECTIONS, $unet_cv_with_maxcon,
 [Maximum number of network connections])
 
 dnl Finally really generate all output files:
-AC_OUTPUT(Makefile ircd/Makefile doc/Makefile, [echo timestamp > stamp-h])
+AC_OUTPUT(Makefile ircd/Makefile ircd/test/Makefile, [echo timestamp > stamp-h])
 
 dnl Report configuration
 AC_OUTPUT_COMMANDS([echo "
@@ -704,18 +746,17 @@ ircu is now hopefully configured for your system.
   Warnings:            $unet_cv_enable_warnings
   Debug:               $unet_cv_enable_debug
   Profile:             $unet_cv_enable_profile
-  Head-in-sand:        $unet_cv_enable_headinsand
-  ADNS:                $unet_cv_enable_adns
   Owner/mode:          $unet_cv_with_owner.$unet_cv_with_group ($unet_cv_with_mode)
   Chroot:              $unet_cv_with_chroot
-  
+
   Domain:              $unet_cv_with_domain
   DPath:               $unet_cv_with_dpath
   CPath:               $unet_cv_with_cpath
   LPath:               $unet_cv_with_lpath
   Maximum connections: $unet_cv_with_maxcon
-  
+
   poll() engine:       $unet_cv_enable_poll
   kqueue() engine:     $unet_cv_enable_kqueue
   /dev/poll engine:    $unet_cv_enable_devpoll
+  epoll() engine:      $unet_cv_enable_epoll
 "])