import from branch_1_1:
[freeradius.git] / configure.in
index 76d2ae0..b187377 100644 (file)
@@ -3,7 +3,7 @@ dnl #
 dnl #  For information about autoconf, see:
 dnl #
 dnl #  http://www.gnu.org/software/autoconf/
-dnl #  
+dnl #
 dnl #  The recommended order is:
 dnl #
 dnl #  AC_INIT(file)
@@ -20,16 +20,17 @@ dnl #  AC_OUTPUT([file...])
 dnl #
 dnl #############################################################
 
-AC_PREREQ([2.50])
+AC_PREREQ([2.59])
 export CFLAGS LIBS LDFLAGS CPPFLAGS
 AC_INIT(src/main/radiusd.c)
 AC_CONFIG_HEADER(src/include/autoconf.h)
 AC_REVISION($Revision$)dnl
 
 dnl # The version of the software
-RADIUSD_MAJOR_VERSION=1
-RADIUSD_MINOR_VERSION=1.0-pre0
+RADIUSD_MAJOR_VERSION=2
+RADIUSD_MINOR_VERSION=0.0-pre0
 RADIUSD_VERSION="${RADIUSD_MAJOR_VERSION}.${RADIUSD_MINOR_VERSION}"
+PACKAGE=freeradius
 
 dnl #############################################################
 dnl #
@@ -51,13 +52,9 @@ AC_PROG_GCC_TRADITIONAL
 AC_PROG_CC_SUNPRO
 AC_PROG_RANLIB
 
-abs_top_builddir=`pwd`
-AC_SUBST(abs_top_builddir)
-
+dnl Compile in large (2G+) file support.
 AC_SYS_LARGEFILE
 
-PACKAGE=freeradius
-
 dnl # check for system bytesex
 dnl # AC_DEFINES WORDS_BIGENDIAN
 AC_C_BIGENDIAN
@@ -78,8 +75,14 @@ fi
 dnl libltdl is installable
 AC_LIBLTDL_INSTALLABLE
 
+dnl tell Makefile to build ltdl if needed
+if test x"$enable_ltdl_install" = x"yes"; then
+  LTDL_SUBDIRS=libltdl
+fi
+AC_SUBST(LTDL_SUBDIRS)
+
 dnl use system-wide libtool, if it exists
-AC_ARG_WITH(system-libtool, 
+AC_ARG_WITH(system-libtool,
 [  --with-system-libtool              try to use libtool installed in your system [default=use our own]],
 [ AC_PATH_PROG(LIBTOOL, libtool,,$PATH:/usr/local/bin) ],
 [
@@ -103,6 +106,28 @@ dnl        awk '{print "                            "$0}']))
 AC_ARG_ENABLE(strict-dependencies,
 [  --enable-strict-dependencies  Fail configure on lack of module dependancy.])
 
+dnl extra argument: --with-docdir
+docdir='${datadir}/doc/freeradius'
+AC_MSG_CHECKING(docdir)
+AC_ARG_WITH(docdir,
+[  --with-docdir=DIR       Directory for documentation [DATADIR/doc/freeradius] ],
+[ case "$withval" in
+    no)
+       AC_MSG_ERROR(Need docdir)
+       ;;
+    yes)
+       ;;
+    [[\\/$]]* | ?:[[\\/]]* )
+       docdir="$withval"
+       ;;
+    *)
+       AC_MSG_ERROR([expected an absolute directory name for --with-docdir: $withval])
+       ;;
+  esac ]
+)
+AC_SUBST(docdir)
+AC_MSG_RESULT($docdir)
+
 dnl extra argument: --with-logdir
 logdir='${localstatedir}/log/radius'
 AC_MSG_CHECKING(logdir)
@@ -114,9 +139,12 @@ AC_ARG_WITH(logdir,
        ;;
     yes)
        ;;
-    *)
+    [[\\/$]]* | ?:[[\\/]]* )
        logdir="$withval"
        ;;
+    *)
+       AC_MSG_ERROR([expected an absolute directory name for --with-logdir: $withval])
+       ;;
   esac ]
 )
 AC_SUBST(logdir)
@@ -126,16 +154,19 @@ dnl extra argument: --with-radacctdir
 radacctdir='${logdir}/radacct'
 AC_MSG_CHECKING(radacctdir)
 AC_ARG_WITH(radacctdir,
-[  --with-radacctdir=PATH  Directory for detail files [LOGDIR/radacct] ],
+[  --with-radacctdir=DIR   Directory for detail files [LOGDIR/radacct] ],
 [ case "$withval" in
     no)
        AC_MSG_ERROR(Need radacctdir)
        ;;
     yes)
        ;;
-    *)
+    [[\\/$]]* | ?:[[\\/]]* )
        radacctdir="$withval"
        ;;
+    *)
+       AC_MSG_ERROR([expected an absolute directory name for --with-radacctdir: $withval])
+       ;;
   esac ]
 )
 AC_SUBST(radacctdir)
@@ -152,9 +183,12 @@ AC_ARG_WITH(raddbdir,
        ;;
     yes)
        ;;
-    *)
+    [[\\/$]]* | ?:[[\\/]]* )
        raddbdir="$withval"
        ;;
+    *)
+       AC_MSG_ERROR([expected an absolute directory name for --with-raddbdir: $withval])
+       ;;
   esac ]
 )
 AC_SUBST(raddbdir)
@@ -199,28 +233,6 @@ 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
-dnl   enable_ltdl_install=yes
-dnl   ac_configure_args="$ac_configure_args --enable-ltdl-install"
-dnl fi
-dnl AC_CONFIG_SUBDIRS(libltdl)
-
 dnl #
 dnl #  Allow the user to specify a list of modules to be linked
 dnl #  statically to the server.
@@ -233,6 +245,14 @@ AC_ARG_WITH(static_modules,
   done
 ])
 
+MODULES=
+AC_ARG_WITH(modules,
+[ --with-modules=QUOTED-MODULE-LIST],[
+ for i in $withval; do
+   MODULES="$MODULES $i"
+ done
+])
+
 dnl #
 dnl #  Enable developer C compiler warnings
 dnl #
@@ -265,8 +285,9 @@ AC_ARG_WITH(experimental-modules,
 )
 
 dnl #
-dnl # extra argument: --openssl-includes=dir
+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
@@ -276,8 +297,9 @@ AC_ARG_WITH(openssl-includes,
 )
 
 dnl #
-dnl # extra argument: --openssl-libraries=dir
+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
@@ -390,20 +412,20 @@ dnl #############################################################
 
 dnl If using pthreads, check for -lpthread (posix) or -lc_r (*BSD)
 old_CFLAGS=$CFLAGS
-if test "x$WITH_THREADS" = "xyes"; then 
+if test "x$WITH_THREADS" = "xyes"; then
   if test $ac_cv_prog_suncc = "yes"; then
     CFLAGS="$CFLAGS -mt"
   fi
 
   AC_CHECK_HEADERS(pthread.h, [], [ WITH_THREADS="no" ])
 
-dnl # 
+dnl #
 dnl # pthread stuff is usually in -lpthread
 dnl # or in -lc_r, on *BSD
-dnl # 
+dnl #
 dnl # On Some systems, we need extra pre-processor flags, to get them to
 dnl # to do the threading properly.
-dnl # 
+dnl #
   AC_CHECK_LIB(pthread, pthread_create,
                [ CFLAGS="$CFLAGS -D_REENTRANT -D_POSIX_PTHREAD_SEMANTICS"
                   LIBS="$LIBS -lpthread" ],
@@ -414,9 +436,9 @@ dnl #
                )
 fi
 
-dnl # 
+dnl #
 dnl # If we have NO pthread libraries, remove any knowledge of threads.
-dnl # 
+dnl #
 if test "x$WITH_THREADS" != "xyes"; then
   CFLAGS=$old_CFLAGS
   ac_cv_header_pthread_h="no"
@@ -448,6 +470,37 @@ 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 Check the pcap library for the RADIUS sniffer.
+PCAP_LIBS=
+AC_CHECK_LIB(pcap, pcap_open_live,
+       [ PCAP_LIBS="-lpcap"
+       AC_DEFINE(HAVE_LIBPCAP, 1,
+               [Define to 1 if you have the `pcap' library (-lpcap).])
+       ],
+       [ AC_MSG_WARN([pcap library not found, silently disabling the RADIUS sniffer.]) ])
+
 dnl #############################################################
 dnl #
 dnl #  3. Checks for header files
@@ -457,8 +510,8 @@ dnl #############################################################
 dnl #
 dnl # Interix requires us to set -D_ALL_SOURCE, otherwise
 dnl # getopt will be #included, but won't link.  <sigh>
-dnl # 
-dnl # 
+dnl #
+dnl #
 case "$host" in
 *-interix*)
        CFLAGS="$CFLAGS -D_ALL_SOURCE"
@@ -533,71 +586,64 @@ then
   AC_DEFINE(OSFSIA, [], [define if you have OSFSIA authentication])
 fi
 
-smart_try_dir="$OPENSSL_INCLUDE_DIR"
-dnl # stupid RedHat shit
-CFLAGS="$CFLAGS -DOPENSSL_NO_KRB5"
-FR_SMART_CHECK_INCLUDE(openssl/ssl.h)
-OPENSSL_INCLUDE=
-OPENSSL_LIBS=
-if test "x$ac_cv_header_openssl_ssl_h" = "xyes"; then
-  AC_DEFINE(HAVE_OPENSSL_SSL_H, [], [define if you have openssl/ssl.h])
-  old_CPPFLAGS="$CPPFLAGS"
-  if test "x$OPENSSL_INCLUDE_DIR" != "x"; then
-      CPPFLAGS="-I$OPENSSL_INCLUDE_DIR $CPPFLAGS"
-  fi
-  AC_CHECK_HEADERS( \
-         openssl/err.h \
-         openssl/crypto.h \
-         openssl/rand.h \
-         openssl/engine.h
-  )
-  CPPFLAGS="$old_CPPFLAGS"
-
-  AC_MSG_CHECKING([for OpenSSL version >= 0.9.7])
-       old_CPPFLAGS=$CPPFLAGS
-       old_LIBS="$LIBS"
-       if test "x$OPENSSL_INCLUDE_DIR" != "x"; then
-           CPPFLAGS="-I$OPENSSL_INCLUDE_DIR"
-          fi
-       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_INCLUDE=
-            OPENSSL_LIBS=
-           else
-             AC_MSG_RESULT(yes)
-
-             # Look for the OpenSSL libraries.
-            smart_try_dir=$OPENSSL_LIB_DIR
-            FR_SMART_CHECK_LIB(crypto, DH_new)
-            if test "x$ac_cv_lib_crypto_DH_new" = "xyes"; then
-              FR_SMART_CHECK_LIB(ssl, SSL_new)
-              if test "x$ac_cv_lib_ssl_SSL_new" = "xyes"; then
-                 if test "x$OPENSSL_INCLUDE_DIR" != "x"; then
-                  OPENSSL_INCLUDE="-I$OPENSSL_INCLUDE_DIR"
-                fi
-                if test "x$OPENSSL_LIB_DIR" != "x"; then
-                  OPENSSL_LIBS="-L$OPENSSL_LIB_DIR"
-                fi
-                 OPENSSL_LIBS="$OPENSSL_LIBS -lcrypto -lssl -lcrypto"
-              else
-                OPENSSL_INCLUDE=
-                OPENSSL_LIBS=
-              fi
-            fi
-           fi
-       CPPFLAGS=$old_CPPFLAGS
-       LIBS="$old_LIBS"
+dnl Check for OpenSSL includes.
+OPENSSL_INCLUDE="-DNO_OPENSSL"
+if test "x$OPENSSL_LIBS" = "x"; then
+    AC_MSG_NOTICE([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 Check the pcap includes for the RADIUS sniffer.
+if test "x$PCAP_LIBS" = x; then
+    AC_MSG_NOTICE([skipping test for pcap.h.])
+else
+    AC_CHECK_HEADER(pcap.h,
+       AC_DEFINE(HAVE_PCAP_H, 1,
+               [Define to 1 if you have the <pcap.h> header file.]),
+       [ PCAP_LIBS=
+       AC_MSG_WARN([pcap.h not found, silently disabling the RADIUS sniffer.])
+       ])
+fi
+AC_SUBST(PCAP_LIBS)
+
 dnl #############################################################
 dnl #
 dnl #  4. Checks for typedefs
@@ -607,7 +653,7 @@ dnl #############################################################
 dnl #
 dnl # Ensure that these are defined
 dnl #
-AC_TYPE_OFF_T 
+AC_TYPE_OFF_T
 AC_TYPE_PID_T
 AC_TYPE_SIZE_T
 AC_TYPE_UID_T
@@ -768,7 +814,7 @@ dnl #############################################################
 dnl #
 dnl # Ensure that these are defined
 dnl #
-AC_C_CONST 
+AC_C_CONST
 
 dnl #
 dnl # See if this is OS/2
@@ -976,13 +1022,6 @@ dnl # AC_SUBST(top_builddir)
 AC_SUBST(LIBLTDL)
 AC_SUBST(INCLTDL)
 
-dnl #
-dnl #  Work around stupid autoconf crap
-dnl #
-if test "x$INCLTDL" != "x";then
-  INCLTDL='-I${top_builddir}/''libltdl'
-fi
-
 dnl import libtool stuff
 
 dnl #############################################################
@@ -993,15 +1032,15 @@ dnl #############################################################
 
 mysubdirs="$LIBLTDLPATH"
 if test "x$EXPERIMENTAL" = "xyes"; then
-  bar=`ls -1 src/modules/rlm_*/configure | sed 's%/configure%%'`
+  bar=`ls -1 "${srcdir}"/src/modules/rlm_*/configure | sed 's%/configure%%'`
   dnl # get rid of LF's.
   mysubdirs=`echo $mysubdirs $bar`
 else
-  dnl # 
+  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
+  dnl #
+  for bar in `cat "${srcdir}"/src/modules/stable`; do
+    if test -f "${srcdir}"/src/modules/$bar/configure; then
       mysubdirs="$mysubdirs src/modules/$bar"
     fi
   done
@@ -1010,16 +1049,15 @@ fi
 dnl ############################################################
 dnl # make modules by list
 dnl #############################################################
-MODULES=
 if test "x$EXPERIMENTAL" = "xyes"; then
-  for foo in `ls -1 src/modules | grep rlm_`; do
+  for foo in `ls -1 "${srcdir}"/src/modules | grep rlm_`; do
     MODULES="$MODULES $foo"
   done
 else
    dnl #
    dnl # make ONLY the stable modules
    dnl #
-   for foo in `cat src/modules/stable`; do
+   for foo in `cat "${srcdir}"/src/modules/stable`; do
     MODULES="$MODULES $foo"
    done
 fi
@@ -1028,7 +1066,7 @@ dnl #
 dnl #  Don't change the variable name here.  Autoconf goes bonkers
 dnl #  if you do.
 dnl #
-AC_CONFIG_SUBDIRS($mysubdirs)
+AC_CONFIG_SUBDIRS($LTDL_SUBDIRS $mysubdirs)
 AC_SUBST(MODULES)
 
 dnl #############################################################