import from HEAD:
[freeradius.git] / configure.in
index 2fd8bed..28ba5ef 100644 (file)
@@ -25,8 +25,8 @@ AC_CONFIG_HEADER(src/include/autoconf.h)
 AC_REVISION($Revision$)dnl
 
 dnl # The version of the software
-RADIUSD_MAJOR_VERSION=0
-RADIUSD_MINOR_VERSION=9-pre
+RADIUSD_MAJOR_VERSION=1
+RADIUSD_MINOR_VERSION=1.1
 RADIUSD_VERSION="${RADIUSD_MAJOR_VERSION}.${RADIUSD_MINOR_VERSION}"
 
 dnl #############################################################
@@ -37,11 +37,6 @@ dnl #############################################################
 
 dnl Check for GNU cc
 AC_PROG_CC
-AC_PROG_GCC_TRADITIONAL
-AC_PROG_CC_SUNPRO
-AC_PROG_RANLIB
-
-PACKAGE=freeradius
 
 dnl #
 dnl # check for AIX, to allow us to use some BSD functions
@@ -49,6 +44,22 @@ dnl # must be before macros that call the compiler.
 dnl #
 AC_AIX
 
+AC_PROG_GCC_TRADITIONAL
+AC_PROG_CC_SUNPRO
+AC_PROG_RANLIB
+
+abs_top_builddir=`pwd`
+AC_SUBST(abs_top_builddir)
+
+dnl # autoconf 2.50 and later
+dnl # AC_SYS_LARGEFILE
+
+PACKAGE=freeradius
+
+dnl # check for system bytesex
+dnl # AC_DEFINES WORDS_BIGENDIAN
+AC_C_BIGENDIAN
+
 dnl Find GNU Make.
 AC_CHECK_PROG(GMAKE, gmake, yes, no)
 if test $GMAKE = no; then
@@ -147,21 +158,6 @@ AC_ARG_WITH(raddbdir,
 AC_SUBST(raddbdir)
 AC_MSG_RESULT($raddbdir)
 
-dnl extra argument: --with-dict-nocase
-WITH_DICT_NOCASE=yes
-AC_ARG_WITH(dict-nocase,
-[  --with-dict-nocase      Make dictionary case-independant (default=yes)],
-[  case "$withval" in
-    yes)
-       ;;
-    *)
-       WITH_DICT_NOCASE=""
-  esac ]
-)
-if test "X$WITH_DICT_NOCASE" = "Xyes"; then
-  AC_DEFINE(WITH_DICT_NOCASE)
-fi
-
 dnl extra argument: --with-ascend-binary
 ASCEND_BINARY=yes
 AC_ARG_WITH(ascend-binary,
@@ -201,6 +197,20 @@ AC_ARG_WITH(snmp,
   esac ]
 )
 
+dnl extra argument: --with-large-files
+rad_enable_largefiles=no
+AC_ARG_WITH(large-files,
+[  --with-large-files      Compile in large (2G+) file support. (default=no)],
+[ case "$withval" in
+    yes)
+        rad_enable_largefiles=yes
+       ;;
+    *)
+       ;;
+  esac ]
+)
+
+
 dnl AC_ARG_ENABLE(ltdl-install,
 dnl [  --disable-ltdl-install  do not install libltdl])
 dnl if test x"${enable_ltdl_install+set}" != xset; then
@@ -226,11 +236,11 @@ dnl #  Enable developer C compiler warnings
 dnl #
 AC_ARG_ENABLE(developer,
 [  --enable-developer               Enables features of interest to developers.],
-[ case "$withval" in
-    *)
+[ case "$enableval" in
+    no)
        developer=no
        ;;
-    yes)
+    *)
        developer=yes
   esac ]
 )
@@ -253,6 +263,30 @@ AC_ARG_WITH(experimental-modules,
 )
 
 dnl #
+dnl # extra argument: --with-openssl-includes=dir
+dnl #
+OPENSSL_INCLUDE_DIR=
+AC_ARG_WITH(openssl-includes,
+[  --with-openssl-includes=DIR      Directory to look for OpenSSL include files],
+[ case "$withval" in
+    *) OPENSSL_INCLUDE_DIR="$withval"
+       ;;
+  esac ]
+)
+
+dnl #
+dnl # extra argument: --with-openssl-libraries=dir
+dnl #
+OPENSSL_LIB_DIR=
+AC_ARG_WITH(openssl-libraries,
+[  --with-openssl-libraries=DIR     Directory to look for OpenSSL library files],
+[ case "$withval" in
+    *) OPENSSL_LIB_DIR="$withval"
+       ;;
+  esac ]
+)
+
+dnl #
 dnl #  These next two arguments don't actually do anything.  They're
 dnl #  place holders so that the top-level configure script can tell
 dnl #  the user how to configure lower-level modules
@@ -298,6 +332,28 @@ dnl AC_MSG_RESULT(" $INCLUDE")
 dnl AC_SUBST(INCLUDE)
 dnl AC_SUBST(IQUOTE)
 
+dnl extra argument: --with-udpfromto
+WITH_UDPFROMTO=no
+AC_ARG_WITH(udpfromto,
+[  --with-udpfromto        Compile in UDPFROMTO support. (default=no)],
+[ case "$withval" in
+    yes)
+       WITH_UDPFROMTO=yes
+        ;;
+    *)
+       WITH_UDPFROMTO=no
+  esac ]
+)
+
+if test "x$WITH_UDPFROMTO" = "xyes"; then
+       AC_DEFINE(WITH_UDPFROMTO)
+fi
+
+dnl extra argument: --with-edir
+dnl If using Novell eDirectory, enable UP and Novell specific code
+AC_ARG_WITH(edir,
+[  --with-edir             Enable Novell eDirectory integration.  (default=no) ] , [] )
+
 dnl #############################################################
 dnl #
 dnl #  1. Checks for programs
@@ -396,12 +452,48 @@ dnl Check if we need -lnsl. Usually if we want to
 dnl link against -lsocket we need to include -lnsl as well.
 AC_CHECK_LIB(nsl, inet_ntoa)
 
+dnl Check for OpenSSL libraries.
+OPENSSL_LIBS=
+old_LIBS=$LIBS
+if test "x$OPENSSL_LIB_DIR" != "x"; then
+    LIBS="-L$OPENSSL_LIB_DIR $LIBS"
+fi
+AC_CHECK_LIB(crypto, DH_new,
+    [
+       AC_DEFINE(HAVE_LIBCRYPTO, 1,
+           [Define to 1 if you have the `crypto' library (-lcrypto).])
+       AC_CHECK_LIB(ssl, SSL_new,
+           [
+               AC_DEFINE(HAVE_LIBSSL, 1,
+                   [Define to 1 if you have the `ssl' library (-lssl).])
+               if test "x$OPENSSL_LIB_DIR" != "x"; then
+                   OPENSSL_LIBS="-L$OPENSSL_LIB_DIR"
+               fi
+               OPENSSL_LIBS="$OPENSSL_LIBS -lcrypto -lssl -lcrypto"
+           ], [])
+    ], [])
+LIBS=$old_LIBS
+
 dnl #############################################################
 dnl #
 dnl #  3. Checks for header files
 dnl #
 dnl #############################################################
 
+dnl #
+dnl # Interix requires us to set -D_ALL_SOURCE, otherwise
+dnl # getopt will be #included, but won't link.  <sigh>
+dnl # 
+dnl # 
+case "$host" in
+*-interix*)
+       CFLAGS="$CFLAGS -D_ALL_SOURCE"
+       ;;
+*-darwin*)
+       CFLAGS="$CFLAGS -DDARWIN"
+       ;;
+esac
+
 AC_HEADER_DIRENT
 AC_HEADER_STDC
 AC_HEADER_TIME
@@ -433,6 +525,7 @@ AC_CHECK_HEADERS( \
        sys/security.h \
        fcntl.h \
        sys/fcntl.h \
+       sys/stat.h \
        prot.h \
        sia.h \
        siad.h
@@ -466,6 +559,50 @@ then
   AC_DEFINE(OSFSIA)
 fi
 
+dnl Check for OpenSSL includes.
+OPENSSL_INCLUDE="-DNO_OPENSSL"
+if test "x$OPENSSL_LIBS" = "x"; then
+    AC_MSG_WARN([skipping test for openssl/ssl.h])
+else
+    old_CPPFLAGS=$CPPFLAGS
+    if test "x$OPENSSL_INCLUDE_DIR" != "x"; then
+       CPPFLAGS="$CPPFLAGS -I$OPENSSL_INCLUDE_DIR"
+    fi
+    dnl # stupid RedHat shit
+    CPPFLAGS="$CPPFLAGS -DOPENSSL_NO_KRB5"
+    AC_CHECK_HEADERS( \
+       openssl/ssl.h \
+       openssl/crypto.h \
+       openssl/err.h \
+       openssl/engine.h,
+       [],
+       OPENSSL_LIBS=
+    )
+    if test "x$OPENSSL_LIBS" != "x"; then
+       AC_MSG_CHECKING([for OpenSSL version >= 0.9.7])
+       AC_EGREP_CPP(yes,
+           [#include <openssl/crypto.h>
+            #if (OPENSSL_VERSION_NUMBER >= 0x00907000L)
+            yes
+            #endif
+           ], goodssl="yes")
+       if test "x$goodssl" != "xyes"; then
+           AC_MSG_RESULT(no)
+           OPENSSL_LIBS=
+       else
+           AC_MSG_RESULT(yes)
+           if test "x$OPENSSL_INCLUDE_DIR" != "x"; then
+               OPENSSL_INCLUDE="-I$OPENSSL_INCLUDE_DIR -DOPENSSL_NO_KRB5"
+           else
+               OPENSSL_INCLUDE="-DOPENSSL_NO_KRB5"
+           fi
+       fi
+    fi
+    CPPFLAGS=$old_CPPFLAGS
+fi
+AC_SUBST(OPENSSL_INCLUDE)
+AC_SUBST(OPENSSL_LIBS)
+export OPENSSL_LIBS
 
 dnl #############################################################
 dnl #
@@ -543,10 +680,13 @@ AC_CHECK_FUNCS( \
        gmtime_r \
        strsep \
        inet_aton \
+       inet_pton \
+       inet_ntop \
        gethostname \
        setlinebuf \
        setvbuf \
-       getusershell
+       getusershell \
+       initgroups
 )
 RADIUSD_NEED_DECLARATIONS( \
        crypt \
@@ -567,12 +707,19 @@ dnl # if not, set it to define ut_xtime == ut_tv.tv_sec
 if test "x$ac_cv_header_utmpx_h" = "xyes"
 then
  AC_CHECK_STRUCT_HAS_MEMBER([#include <utmpx.h>], [struct utmpx], ut_xtime)
- if test "x$ac_cv_type_struct_utmpx_ut_xtime" = "x"
+ if test "x$ac_cv_type_struct_utmpx_has_ut_xtime" = "x"
  then
    AC_DEFINE(ut_xtime,ut_tv.tv_sec)
  fi
 fi
 
+dnl # struct ip_pktinfo
+AC_CHECK_STRUCT_HAS_MEMBER([#include <netinet/in.h>], [struct in_pktinfo], ipi_addr)
+if test "x$ac_cv_type_struct_in_pktinfo_has_ipi_addr" = "xyes"
+then
+       AC_DEFINE(HAVE_IP_PKTINFO)
+fi
+
 dnl #############################################################
 dnl #
 dnl #  6. Checks for compiler characteristics
@@ -606,7 +753,7 @@ fi
 
 AC_MSG_CHECKING(for developer gcc flags)
 if test "x$developer" = "xyes" -a "x$GCC" = "xyes"; then
-  devflags="-g -Wshadow -Wpointer-arith -Wcast-qual -Wcast-align -Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wnested-externs"
+  devflags="-g -Wshadow -Wpointer-arith -Wcast-qual -Wcast-align -Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wnested-externs -W -Wredundant-decls -Wundef"
   CFLAGS="$CFLAGS $devflags"
   INSTALLSTRIP=""
   AC_MSG_RESULT(yes.  Using $devflags)
@@ -644,21 +791,49 @@ if test "x$WITH_SNMP" = "xyes"; then
   SNMP_CHECKS
 fi
 
+dnl Check the style of gethostbyaddr, in order of preference
+dnl GNU (_r eight args)
+dnl SYSV (_r six args)
+dnl BSD (three args, may not be thread safe)
+dnl Tru64 has BSD version, but it is thread safe
+dnl    http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/V51B_HTML/MAN/MAN3/1739____.HTM
+dnl We need #stdio.h to define NULL on FreeBSD (at least)
 gethostbyaddrrstyle=""
 AC_MSG_CHECKING([gethostbyaddr_r() syntax])
-AC_TRY_COMPILE([#include <netdb.h>], [ gethostbyaddr_r(NULL, 0, 0, NULL, NULL, 0, NULL) ] , [
-       AC_DEFINE(GETHOSTBYADDRRSTYLE, SYSVSTYLE)
-       gethostbyaddrrstyle=SYSV
-])
-AC_TRY_COMPILE([#include <netdb.h>], [ gethostbyaddr_r(NULL, 0, 0, NULL, NULL, 0, NULL, NULL) ], [
-       AC_DEFINE(GETHOSTBYADDRRSTYLE, GNUSTYLE)
-       gethostbyaddrrstyle=GNU
-])
-
-AC_TRY_COMPILE([#include <netdb.h>], [ gethostbyaddr(NULL, 0, 0)  ], [
+case "$host" in
+*-freebsd*)
        AC_DEFINE(GETHOSTBYADDRRSTYLE, BSDSTYLE)
        gethostbyaddrrstyle=BSD
+       AC_MSG_WARN([FreeBSD overridden to BSD-style])
+       ;;
+esac
+if test "x$gethostbyaddrrstyle" = "x"; then
+       AC_TRY_LINK([
+#include <stdio.h>
+#include <netdb.h>
+], [ gethostbyaddr_r(NULL, 0, 0, NULL, NULL, 0, NULL, NULL) ], [
+       AC_DEFINE(GETHOSTBYADDRRSTYLE, GNUSTYLE)
+       gethostbyaddrrstyle=GNU
 ])
+fi
+if test "x$gethostbyaddrrstyle" = "x"; then
+       AC_TRY_LINK([
+#include <stdio.h>
+#include <netdb.h>
+], [ gethostbyaddr_r(NULL, 0, 0, NULL, NULL, 0, NULL) ] , [
+               AC_DEFINE(GETHOSTBYADDRRSTYLE, SYSVSTYLE)
+               gethostbyaddrrstyle=SYSV
+       ])
+fi
+if test "x$gethostbyaddrrstyle" = "x"; then
+       AC_TRY_LINK([
+#include <stdio.h>
+#include <netdb.h>
+], [ gethostbyaddr(NULL, 0, 0)  ], [
+               AC_DEFINE(GETHOSTBYADDRRSTYLE, BSDSTYLE)
+               gethostbyaddrrstyle=BSD
+       ])
+fi
 
 if test "x$gethostbyaddrrstyle" = "x"; then
        AC_MSG_RESULT([none!  It must not exist, here.])
@@ -666,6 +841,138 @@ else
        AC_MSG_RESULT([${gethostbyaddrrstyle}-style])
 fi
 
+if test "x$gethostbyaddrrstyle" = "xBSD"; then
+       AC_MSG_WARN([ ****** BSD-style gethostbyaddr might NOT be thread-safe! ****** ])
+fi
+
+dnl Check the style of gethostbyname, in order of preference
+dnl GNU (_r seven args)
+dnl SYSV (_r five args)
+dnl BSD (two args, may not be thread safe)
+dnl Tru64 has BSD version, but it _is_ thread safe
+dnl    http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/V51B_HTML/MAN/MAN3/1946____.HTM
+dnl We need #stdio.h to define NULL on FreeBSD (at least)
+gethostbynamerstyle=""
+AC_MSG_CHECKING([gethostbyname_r() syntax])
+AC_TRY_LINK([
+#include <stdio.h>
+#include <netdb.h>
+], [ gethostbyname_r(NULL, NULL, NULL, 0, NULL, NULL) ], [
+       AC_DEFINE(GETHOSTBYNAMERSTYLE, GNUSTYLE)
+       gethostbynamerstyle=GNU
+])
+if test "x$gethostbynamerstyle" = "x"; then
+       AC_TRY_LINK([
+#include <stdio.h>
+#include <netdb.h>
+], [ gethostbyname_r(NULL, NULL, NULL, 0, NULL) ] , [
+               AC_DEFINE(GETHOSTBYNAMERSTYLE, SYSVSTYLE)
+               gethostbynamerstyle=SYSV
+       ])
+fi
+if test "x$gethostbynamerstyle" = "x"; then
+       AC_TRY_LINK([
+#include <stdio.h>
+#include <netdb.h>
+], [ gethostbyname(NULL)  ], [
+               AC_DEFINE(GETHOSTBYNAMERSTYLE, BSDSTYLE)
+               gethostbynamerstyle=BSD
+       ])
+fi
+
+if test "x$gethostbynamerstyle" = "x"; then
+       AC_MSG_RESULT([none!  It must not exist, here.])
+else
+       AC_MSG_RESULT([${gethostbynamerstyle}-style])
+fi
+
+if test "x$gethostbynamerstyle" = "xBSD"; then
+       AC_MSG_WARN([ ****** BSD-style gethostbyname might NOT be thread-safe! ****** ])
+fi
+
+dnl check for non-posix solaris ctime_r (extra buflen int arg)
+ctimerstyle=""
+AC_MSG_CHECKING([ctime_r() syntax])
+AC_TRY_LINK([
+#include <time.h>
+], [ ctime_r(NULL, NULL, 0) ], [
+       AC_DEFINE(CTIMERSTYLE, SOLARISSTYLE)
+       ctimerstyle="SOLARIS"
+])
+if test "x$ctimerstyle" = "x"; then
+       AC_TRY_LINK([
+#include <time.h>
+], [ ctime_r(NULL, NULL) ], [
+               AC_DEFINE(CTIMERSTYLE, POSIXSTYLE)
+               ctimerstyle="POSIX"
+       ])
+fi
+
+if test "x$ctimerstyle" = "x"; then
+       AC_MSG_RESULT([none!  It must not exist, here.])
+else
+        AC_MSG_RESULT([${ctimerstyle}-style])
+fi
+
+
+dnl If configuring with large file support, determine the right flags to
+dnl use based on the platform.  This is the wrong approach; autoconf 2.50
+dnl comes with a macro that takes the right approach.  But this works well
+dnl enough until we switch to autoconf 2.50 or later.
+if test x"$rad_enable_largefiles" = xyes ; then
+    AC_MSG_CHECKING(for largefile linkage)
+    case "$host" in
+    *-aix4.[01]*)
+        AC_MSG_RESULT(no)
+        AC_MSG_ERROR([AIX before 4.2 does not support large files])
+        ;;
+    *-aix4*)
+        AC_MSG_RESULT(ok)
+        LFS_CFLAGS="-D_LARGE_FILES"
+        LFS_LDFLAGS=""
+        LFS_LIBS=""
+        ;;
+    *-hpux*)
+        AC_MSG_RESULT(ok)
+        LFS_CFLAGS="-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64"
+        LFS_LDFLAGS=""
+        LFS_LIBS=""
+        ;;
+    *-irix*)
+        AC_MSG_RESULT(no)
+        AC_MSG_ERROR([Large files not supported on this platform])
+        ;;
+    *-linux*)
+        AC_MSG_RESULT(maybe)
+        LFS_CFLAGS="-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64"
+        LFS_LDFLAGS=""
+        LFS_LIBS=""
+        AC_DEFINE([_GNU_SOURCE], 1,
+                  [Some versions of glibc need this defined for pread/pwrite.])
+        ;;
+    *-solaris*)
+        AC_MSG_RESULT(ok)
+        AC_PATH_PROG(GETCONF, getconf)
+        if test -z "$GETCONF" ; then
+            AC_MSG_ERROR([getconf required to configure large file support])
+        fi
+        LFS_CFLAGS=`$GETCONF LFS_CFLAGS`
+        LFS_LDFLAGS=`$GETCONF LFS_LDFLAGS`
+        LFS_LIBS=`$GETCONF LFS_LIBS`
+        ;;
+    *)
+        AC_MSG_RESULT(maybe)
+        LFS_CFLAGS="-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64"
+        LFS_LDFLAGS=""
+        LFS_LIBS=""
+        ;;
+    esac
+    AC_SUBST(LFS_CFLAGS)
+    AC_SUBST(LFS_LDFLAGS)
+    AC_SUBST(LFS_LIBS)
+fi
+
+AC_SUBST(HOSTINFO, $host)
 
 dnl #############################################################
 dnl #
@@ -677,8 +984,9 @@ dnl #
 dnl # Figure out where libtool is located,
 dnl #
 top_builddir=`pwd`
+export top_builddir
 AC_MSG_RESULT([top_builddir=$top_builddir])
-AC_SUBST(top_builddir)
+dnl # AC_SUBST(top_builddir)
 AC_SUBST(LIBLTDL)
 AC_SUBST(INCLTDL)
 
@@ -699,17 +1007,17 @@ dnl #############################################################
 
 mysubdirs=
 if test "x$EXPERIMENTAL" = "xyes"; then
-  for foo in `find src/modules -name configure -print`; do
-    bar=`echo $foo | sed 's%/configure$%%g'`
-    mysubdirs="$mysubdirs $bar"
-  done
+  bar=`ls -1 src/modules/rlm_*/configure | sed 's%/configure%%'`
+  dnl # get rid of LF's.
+  mysubdirs=`echo $bar`
 else
-   dnl # 
-   dnl # Find 'configure' in ONLY the stable modules
-   dnl # 
-   for foo in `find \`cat src/modules/stable | sed 's%rlm%src/modules/rlm%g'\` -name configure -print`; do
-    bar=`echo $foo | sed 's%/configure$%%g'`
-    mysubdirs="$mysubdirs $bar"
+  dnl # 
+  dnl # Find 'configure' in ONLY the stable modules
+  dnl # 
+  for bar in `cat src/modules/stable`; do
+    if test -f src/modules/$bar/configure; then
+      mysubdirs="$mysubdirs src/modules/$bar"
+    fi
   done
 fi
 
@@ -718,7 +1026,7 @@ dnl # make modules by list
 dnl #############################################################
 MODULES=
 if test "x$EXPERIMENTAL" = "xyes"; then
-  for foo in `ls src/modules | grep rlm_`; do
+  for foo in `ls -1 src/modules | grep rlm_`; do
     MODULES="$MODULES $foo"
   done
 else
@@ -772,6 +1080,7 @@ AC_OUTPUT(\
        ./scripts/radiusd.cron.daily \
        ./scripts/radiusd.cron.monthly \
        ./scripts/cryptpasswd \
+       ./raddb/dictionary \
        ./raddb/radiusd.conf
 )
 
@@ -779,10 +1088,3 @@ AC_OUTPUT_COMMANDS([echo timestamp > src/include/stamp-h])
 AC_OUTPUT_COMMANDS([(cd ./src/include && /bin/sh ./build-radpaths-h)])
 AC_OUTPUT_COMMANDS([(cd ./src/main   && chmod +x checkrad.pl radlast radtest)])
 AC_OUTPUT_COMMANDS([(cd ./scripts    && chmod +x rc.radiusd radwatch check-radiusd-config radiusd.cron.daily radiusd.cron.monthly cryptpasswd)])
-AC_OUTPUT_COMMANDS([
-cat >> src/include/autoconf.h <<EOF
-
-#define HOSTINFO       "$host"
-#define RADIUSD_VERSION "$RADIUSD_VERSION"
-EOF
-],host=$host)