1 dnl #############################################################
3 dnl # For information about autoconf, see:
5 dnl # http://www.gnu.org/software/autoconf/
7 dnl # The recommended order is:
10 dnl # 0. checks for compiler, libtool, and command line options
11 dnl # 1. checks for programs
12 dnl # 2. checks for libraries
13 dnl # 3. checks for header files
14 dnl # 4. checks for typedefs
15 dnl # 5. checks for structures and functions
16 dnl # 6. checks for compiler characteristics
17 dnl # 7. checks for library functions
18 dnl # 8. checks for system services
19 dnl # AC_OUTPUT([file...])
21 dnl #############################################################
23 AC_INIT(src/main/radiusd.c)
24 AC_CONFIG_HEADER(src/include/autoconf.h)
25 AC_REVISION($Revision$)dnl
27 dnl # The version of the software, 0.5
28 RADIUSD_MAJOR_VERSION=0
29 RADIUSD_MINOR_VERSION=6
30 RADIUSD_VERSION="${RADIUSD_MAJOR_VERSION}.${RADIUSD_MINOR_VERSION}"
32 dnl #############################################################
34 dnl # 0. Checks for compiler, libtool, and command line options.
36 dnl #############################################################
40 AC_PROG_GCC_TRADITIONAL
47 dnl # check for AIX, to allow us to use some BSD functions
48 dnl # must be before macros that call the compiler.
53 AC_CHECK_PROG(GMAKE, gmake, yes, no)
54 if test $GMAKE = no; then
55 AC_PATH_PROG(MAKE, make, /usr/local/bin/make)
57 AC_PATH_PROG(MAKE, gmake, /usr/local/gnu/bin/make)
59 makever=`$ac_cv_path_MAKE --version 2>&1 | grep "GNU Make"`
60 if test -z "$makever"; then
61 AC_MSG_ERROR(GNU Make is not installed. Please download and install it
62 from ftp://prep.ai.mit.edu/pub/gnu/make/ before continuing.)
65 dnl libltdl is installable
66 AC_LIBLTDL_INSTALLABLE
68 dnl ensure that we're looking for dlopen
71 dnl Figure out how to build shared libraries
74 dnl Put this in later, when all distributed modules use autoconf.
75 dnl AC_ARG_WITH(disablemodulefoo,
76 dnl [ --without-rlm_foo Disables module compilation. Module list:]
77 dnl esyscmd([find src/modules -type d -name rlm_\* -print |\
78 dnl sed -e 's%src/modules/.*/% (sub)- %; s%.*/%- %' |\
79 dnl awk '{print " "$0}']))
81 AC_ARG_ENABLE(strict-dependencies,
82 [ --enable-strict-dependencies Fail configure on lack of module dependancy.])
84 dnl extra argument: --with-logdir
85 logdir='${localstatedir}/log/radius'
86 AC_MSG_CHECKING(logdir)
88 [ --with-logdir=DIR Directory for logfiles [LOCALSTATEDIR/log/radius] ],
91 AC_MSG_ERROR(Need logdir)
101 AC_MSG_RESULT($logdir)
103 dnl extra argument: --with-radacctdir
104 radacctdir='${logdir}/radacct'
105 AC_MSG_CHECKING(radacctdir)
106 AC_ARG_WITH(radacctdir,
107 [ --with-radacctdir=PATH Directory for detail files [LOGDIR/radacct] ],
110 AC_MSG_ERROR(Need radacctdir)
115 radacctdir="$withval"
120 AC_MSG_RESULT($radacctdir)
122 dnl extra argument: --with-raddbdir
123 raddbdir='${sysconfdir}/raddb'
124 AC_MSG_CHECKING(raddbdir)
125 AC_ARG_WITH(raddbdir,
126 [ --with-raddbdir=DIR Directory for config files [SYSCONFDIR/raddb] ],
129 AC_MSG_ERROR(Need raddbdir)
139 AC_MSG_RESULT($raddbdir)
141 dnl extra argument: --with-dict-nocase
143 AC_ARG_WITH(dict-nocase,
144 [ --with-dict-nocase Make dictionary case-independant (default=yes)],
152 if test "X$WITH_DICT_NOCASE" = "Xyes"; then
153 AC_DEFINE(WITH_DICT_NOCASE)
156 dnl extra argument: --with-ascend-binary
158 AC_ARG_WITH(ascend-binary,
159 [ --with-ascend-binary Include support for Ascend binary filter attributes (default=yes)],
167 if test "X$ASCEND_BINARY" = "Xyes"; then
168 AC_DEFINE(ASCEND_BINARY)
171 dnl extra argument: --with-threads
175 [ --with-threads Use threads, if available. (default=yes) ],
185 dnl extra argument: --with-snmp
188 [ --with-snmp Compile in SNMP support. (default=yes)],
197 AC_ARG_ENABLE(ltdl-install,
198 [ --disable-ltdl-install do not install libltdl])
199 if test x"${enable_ltdl_install+set}" != xset; then
200 enable_ltdl_install=yes
201 ac_configure_args="$ac_configure_args --enable-ltdl-install"
203 AC_CONFIG_SUBDIRS(libltdl)
206 dnl # Allow the user to specify a list of modules to be linked
207 dnl # statically to the server.
210 AC_ARG_WITH(static_modules,
211 [ --with-static-modules=QUOTED-MODULE-LIST],[
212 for i in $withval; do
213 STATIC_MODULES="$STATIC_MODULES -dlpreopen ../modules/rlm_$i/rlm_$i.la"
218 dnl # Enable developer C compiler warnings
220 AC_ARG_ENABLE(developer,
221 [ --enable-developer Enables features of interest to developers.],
231 if test "x$developer" != "xno" -a -d $srcdir/CVS; then
232 dnl turn on the developer flag when taken from a CVS checkout (not a release)
236 dnl extra argument: --with-experimental-modules
238 AC_ARG_WITH(experimental-modules,
239 [ --with-experimental-modules Use experimental and unstable modules. (default=no) ],
249 dnl # These next two arguments don't actually do anything. They're
250 dnl # place holders so that the top-level configure script can tell
251 dnl # the user how to configure lower-level modules
255 dnl # extra argument: --with-rlm-FOO-lib-dir
257 AC_ARG_WITH(rlm-FOO-lib-dir,
258 [ --with-rlm-FOO-lib-dir=DIR Directory to look for library files used by module FOO],
266 dnl # extra argument: --with-rlm-FOO-include-dir
268 AC_ARG_WITH(rlm-FOO-include-dir,
269 [ --with-rlm-FOO-include-dir=DIR Directory to look for include files used by module FOO],
276 dnl See what include-style is used by the make program.
277 dnl AC_MSG_CHECKING(include style for make)
278 dnl echo "include /dev/null" > testmake.$$
279 dnl echo "all:" >> testmake.$$
280 dnl make -f testmake.$$ >/dev/null 2>&1
289 dnl rm -f testmake.$$
290 dnl AC_MSG_RESULT(" $INCLUDE")
291 dnl AC_SUBST(INCLUDE)
294 dnl #############################################################
296 dnl # 1. Checks for programs
298 dnl #############################################################
301 AC_PATH_PROG(PERL, perl, /usr/local/bin/perl)
302 if test [ "x$ac_cv_path_PERL" = "x" ]; then
303 AC_MSG_WARN(perl not found - Simultaneous-Use and checkrad.pl may not work)
305 AC_PATH_PROG(SNMPGET, snmpget)
306 if test [ "x$ac_cv_path_SNMPGET" = "x" ]; then
307 AC_MSG_WARN(snmpget not found - Simultaneous-Use and checkrad.pl may not work)
310 AC_PATH_PROG(SNMPWALK, snmpwalk)
311 if test [ "x$ac_cv_path_SNMPWALK" = "x" ]; then
312 AC_MSG_WARN(snmpwalk not found - Simultaneous-Use and checkrad.pl may not work)
315 AC_PATH_PROG(RUSERS, rusers, /usr/bin/rusers)
317 dnl FIXME This is truly gross.
318 missing_dir=`cd $ac_aux_dir && pwd`
319 AM_MISSING_PROG(ACLOCAL, aclocal, $missing_dir)
320 AM_MISSING_PROG(AUTOCONF, autoconf, $missing_dir)
321 AM_MISSING_PROG(AUTOHEADER, autoheader, $missing_dir)
323 AC_PATH_PROG(LOCATE,locate)
324 AC_PATH_PROG(DIRNAME,dirname)
325 AC_PATH_PROG(GREP,grep)
327 dnl #############################################################
329 dnl # 2. Checks for libraries
331 dnl #############################################################
333 dnl If using pthreads, check for -lpthread (posix) or -lc_r (*BSD)
335 if test "$WITH_THREADS" = "yes"; then
336 if test $ac_cv_prog_suncc = "yes"; then
340 AC_CHECK_HEADERS(pthread.h)
342 if test "X$ac_cv_header_pthread_h" = "X"; then
343 AC_MSG_ERROR("You are trying to use threads without a POSIX <pthread.h>")
347 dnl # If pthread_create is in the standard libs (e.g. libc),
348 dnl # then don't do anything magical.
350 AC_CHECK_FUNC(pthread_join, PTHREADLIB=" ")
353 dnl # pthread stuff is usually in -lpthread
355 AC_CHECK_LIB(pthread, pthread_join,
356 PTHREADLIB="-lpthread"
359 dnl # HP/UX requires linking with librt, too, to get the sem_* symbols. :\
361 AC_SEARCH_LIBS(sem_init, pthread rt,
363 dnl Er, this usage of $ac_cv_search_sem_init may be unfounded
364 dnl chumminess with the autoconf internals. -chad
365 dnl PTHREADLIB="$PTHREADLIB $ac_cv_search_sem_init"
372 dnl # Except for *BSD, where it's in -lc_r,
373 dnl # and where we've got to add extra CFLAGS.
375 if test "X$PTHREADLIB" = "X"; then
377 CFLAGS="$CFLAGS -pthread -D_THREAD_SAFE"
378 AC_CHECK_LIB(c_r, pthread_create,
383 dnl # Set libs, etc, if we have them.
384 if test "x$PTHREADLIB" != "x"; then
385 LIBS="$LIBS $PTHREADLIB"
386 CFLAGS="$CFLAGS -D_REENTRANT -D_POSIX_PTHREAD_SEMANTICS"
391 dnl # If we have NO pthread libraries, remove any knowledge of threads.
393 if test "x$PTHREADLIB" = "x"; then
395 ac_cv_header_pthread_h="no"
400 dnl Check if we need -lsocket
401 AC_CHECK_LIB(socket, getsockname)
403 dnl Check for -lresolv
404 dnl This library may be needed later.
405 AC_CHECK_LIB(resolv, inet_aton)
407 dnl Check if we need -lnsl. Usually if we want to
408 dnl link against -lsocket we need to include -lnsl as well.
409 AC_CHECK_LIB(nsl, inet_ntoa)
411 dnl #############################################################
413 dnl # 3. Checks for header files
415 dnl #############################################################
452 AC_CHECK_HEADER(regex.h, AC_DEFINE(HAVE_REGEX_H))
453 if test "x$ac_cv_header_regex_h" = "xyes"; then
461 ], [AC_DEFINE(HAVE_REG_EXTENDED) REGEX_EXTENDED=yes])
464 AC_SUBST(REGEX_EXTENDED)
467 dnl # other checks which require headers
469 if test "x$ac_cv_header_sys_security_h" = "xyes" && test "x$ac_cv_header_prot_h" = "xyes"
474 if test "x$ac_cv_header_sia_h" = "xyes" && test "x$ac_cv_header_siad_h" = "xyes"
480 dnl #############################################################
482 dnl # 4. Checks for typedefs
484 dnl #############################################################
487 dnl # Ensure that these are defined
494 dnl check for socklen_t
495 AC_CHECK_TYPE_INCLUDE([
496 #ifdef HAVE_SYS_TYPES_H
497 #include <sys/types.h>
499 #ifdef HAVE_SYS_SOCKET_H
500 #include <sys/socket.h>
504 dnl check for uint8_t
505 AC_CHECK_TYPE_INCLUDE([
506 #ifdef HAVE_INTTYPES_H
507 #include <inttypes.h>
512 ],uint8_t, unsigned char)
514 dnl check for uint16_t
515 AC_CHECK_TYPE_INCLUDE([
516 #ifdef HAVE_INTTYPES_H
517 #include <inttypes.h>
522 ],uint16_t, unsigned short)
524 dnl check for uint32_t
525 AC_CHECK_TYPE_INCLUDE([
526 #ifdef HAVE_INTTYPES_H
527 #include <inttypes.h>
532 ],uint32_t, unsigned int)
534 dnl #############################################################
536 dnl # 5. Checks for structures and functions
538 dnl #############################################################
562 RADIUSD_NEED_DECLARATIONS( \
575 dnl # check if we have utmpx.h
576 dnl # if so, check if struct utmpx has entry ut_xtime
577 dnl # if not, set it to define ut_xtime == ut_tv.tv_sec
578 if test "x$ac_cv_header_utmpx_h" = "xyes"
580 AC_CHECK_STRUCT_HAS_MEMBER([#include <utmpx.h>], [struct utmpx], ut_xtime)
581 if test "x$ac_cv_type_struct_utmpx_ut_xtime" = "x"
583 AC_DEFINE(ut_xtime,ut_tv.tv_sec)
587 dnl #############################################################
589 dnl # 6. Checks for compiler characteristics
591 dnl #############################################################
594 dnl # Ensure that these are defined
599 dnl # See if this is OS/2
601 AC_MSG_CHECKING(type of OS)
604 if test "$OS" = "OS/2"; then
612 dnl # Set Default CFLAGS
614 if test "x$GCC" = "xyes"; then
615 CFLAGS="$CFLAGS -Wall -D_GNU_SOURCE"
618 AC_MSG_CHECKING(for developer gcc flags)
619 if test "x$developer" = "xyes" -a "x$GCC" = "xyes"; then
620 devflags="-g -Wshadow -Wpointer-arith -Wcast-qual -Wcast-align -Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wnested-externs"
621 CFLAGS="$CFLAGS $devflags"
623 AC_MSG_RESULT(yes. Using $devflags)
626 CFLAGS="$CFLAGS -DNDEBUG"
631 dnl #############################################################
633 dnl # 7. Checks for library functions
635 dnl #############################################################
637 dnl Check for libcrypt
638 dnl We use crypt(3) which may be in libc, or in libcrypt (eg FreeBSD)
639 AC_CHECK_LIB(crypt, crypt,
642 if test "$CRYPTLIB" != ""; then
643 AC_DEFINE(HAVE_CRYPT)
645 AC_CHECK_FUNC(crypt, AC_DEFINE(HAVE_CRYPT))
648 dnl Check for libcipher
649 AC_CHECK_LIB(cipher, setkey,
650 CRYPTLIB="${CRYPTLIB} -lcipher"
654 if test "x$WITH_SNMP" = "xyes"; then
659 dnl # Check for sem_init all by itself
661 if test "X$ac_cv_func_sem_init" = "Xno"; then
664 dnl # If not found, sem_init is in -lposix4 on Solaris
666 AC_CHECK_LIB(posix4, sem_init)
668 if test "X$ac_cv_lib_posix4_sem_init" = "X"; then
669 if test "$WITH_THREAD_POOL" = "yes"; then
670 AC_MSG_WARN(You do not have posix semaphores. Disabling thread pools)
677 gethostbyaddrrstyle=""
678 AC_MSG_CHECKING([gethostbyaddr_r() syntax])
679 AC_TRY_COMPILE([#include <netdb.h>], [ gethostbyaddr_r(NULL, 0, 0, NULL, NULL, 0, NULL) ] , [
680 AC_DEFINE(GETHOSTBYADDRRSTYLE, SYSVSTYLE)
681 gethostbyaddrrstyle=SYSV
683 AC_TRY_COMPILE([#include <netdb.h>], [ gethostbyaddr_r(NULL, 0, 0, NULL, NULL, 0, NULL, NULL) ], [
684 AC_DEFINE(GETHOSTBYADDRRSTYLE, GNUSTYLE)
685 gethostbyaddrrstyle=GNU
688 AC_TRY_COMPILE([#include <netdb.h>], [ gethostbyaddr(NULL, 0, 0) ], [
689 AC_DEFINE(GETHOSTBYADDRRSTYLE, BSDSTYLE)
690 gethostbyaddrrstyle=BSD
693 if test "x$gethostbyaddrrstyle" = "x"; then
694 AC_MSG_RESULT([none! It must not exist, here.])
696 AC_MSG_RESULT([${gethostbyaddrrstyle}-style])
700 dnl #############################################################
702 dnl # 8. Checks for system services
704 dnl #############################################################
707 dnl # Figure out where libtool is located,
709 LIBTOOL="`pwd`/libtool"
714 top_srcdir="$top_builddir"
715 AC_SUBST(top_builddir)
718 dnl import libtool stuff
721 dnl # Checks to ensure that the thread pool code can build.
723 if test "$WITH_THREAD_POOL" = "yes"; then
725 dnl # If using thread pools, check that threading is enabled
727 if test "$WITH_THREADS" != "yes"; then
728 AC_MSG_ERROR(You must have threads enabled for thread pools to work.)
732 dnl # If using thread pools, check that we have thread libraries
734 if test "X$PTHREADLIB" = "X"; then
735 AC_MSG_ERROR(You must have threading libraries for thread pools to work.)
740 dnl #############################################################
742 dnl # Configure in any module directories.
744 dnl #############################################################
747 if test "x$EXPERIMENTAL" = "xyes"; then
748 for foo in `find src/modules -name configure -print`; do
749 bar=`echo $foo | sed 's%/configure$%%g'`
750 mysubdirs="$mysubdirs $bar"
754 dnl # Find 'configure' in ONLY the stable modules
756 for foo in `find \`cat src/modules/stable | sed 's%rlm%src/modules/rlm%g'\` -name configure -print`; do
757 bar=`echo $foo | sed 's%/configure$%%g'`
758 mysubdirs="$mysubdirs $bar"
762 dnl ############################################################
763 dnl # make modules by list
764 dnl #############################################################
766 if test "x$EXPERIMENTAL" = "xyes"; then
767 for foo in `ls src/modules | grep rlm_`; do
768 MODULES="$MODULES $foo"
772 dnl # make ONLY the stable modules
774 for foo in `cat src/modules/stable`; do
775 MODULES="$MODULES $foo"
780 dnl # Don't change the variable name here. Autoconf goes bonkers
783 AC_CONFIG_SUBDIRS($mysubdirs)
786 dnl #############################################################
788 dnl # And finally, output the results.
790 dnl #############################################################
793 dnl # Substitute whatever libraries we found to be necessary
796 AC_SUBST(INSTALLSTRIP)
798 USE_SHARED_LIBS=$enable_shared
799 AC_SUBST(USE_SHARED_LIBS)
800 USE_STATIC_LIBS=$enable_static
801 AC_SUBST(USE_STATIC_LIBS)
802 AC_SUBST(STATIC_MODULES)
803 AC_SUBST(RADIUSD_MAJOR_VERSION)
804 AC_SUBST(RADIUSD_MINOR_VERSION)
805 AC_SUBST(RADIUSD_VERSION)
810 ./src/include/build-radpaths-h \
811 ./src/main/checkrad.pl \
814 ./scripts/rc.radiusd \
816 ./scripts/check-radiusd-config \
817 ./scripts/radiusd.cron.daily \
818 ./scripts/radiusd.cron.monthly \
819 ./scripts/cryptpasswd \
823 AC_OUTPUT_COMMANDS([echo timestamp > src/include/stamp-h])
824 AC_OUTPUT_COMMANDS([(cd ./src/include && /bin/sh ./build-radpaths-h)])
825 AC_OUTPUT_COMMANDS([(cd ./src/main && chmod +x checkrad.pl radlast radtest)])
826 AC_OUTPUT_COMMANDS([(cd ./scripts && chmod +x rc.radiusd radwatch check-radiusd-config radiusd.cron.daily radiusd.cron.monthly cryptpasswd)])
828 cat >> src/include/autoconf.h <<EOF
830 #define HOSTINFO "$host"
831 #define RADIUSD_VERSION "$RADIUSD_VERSION"