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; then
303 AC_MSG_WARN(perl not found - Simultaneous-Use and checkrad.pl may not work)
305 AC_PATH_PROG(SNMPGET, snmpget)
307 if test ! -x $ac_cv_path_SNMPGET; then
308 AC_MSG_WARN(snmpget not found - Simultaneous-Use and checkrad.pl may not work)
311 AC_PATH_PROG(SNMPWALK, snmpwalk)
312 if test ! -x $ac_cv_path_SNMPWALK; then
313 AC_MSG_WARN(snmpwalk not found - Simultaneous-Use and checkrad.pl may not work)
316 AC_PATH_PROG(RUSERS, rusers, /usr/bin/rusers)
318 dnl FIXME This is truly gross.
319 missing_dir=`cd $ac_aux_dir && pwd`
320 AM_MISSING_PROG(ACLOCAL, aclocal, $missing_dir)
321 AM_MISSING_PROG(AUTOCONF, autoconf, $missing_dir)
322 AM_MISSING_PROG(AUTOHEADER, autoheader, $missing_dir)
324 AC_PATH_PROG(LOCATE,locate)
325 AC_PATH_PROG(DIRNAME,dirname)
326 AC_PATH_PROG(GREP,grep)
328 dnl #############################################################
330 dnl # 2. Checks for libraries
332 dnl #############################################################
334 dnl If using pthreads, check for -lpthread (posix) or -lc_r (*BSD)
336 if test "$WITH_THREADS" = "yes"; then
337 if test $ac_cv_prog_suncc = "yes"; then
341 AC_CHECK_HEADERS(pthread.h)
343 if test "X$ac_cv_header_pthread_h" = "X"; then
344 AC_MSG_ERROR("You are trying to use threads without a POSIX <pthread.h>")
348 dnl # If pthread_create is in the standard libs (e.g. libc),
349 dnl # then don't do anything magical.
351 AC_CHECK_FUNC(pthread_join, PTHREADLIB=" ")
354 dnl # pthread stuff is usually in -lpthread
356 AC_CHECK_LIB(pthread, pthread_join,
357 PTHREADLIB="-lpthread"
360 dnl # HP/UX requires linking with librt, too, to get the sem_* symbols. :\
362 AC_SEARCH_LIBS(sem_init, pthread rt,
364 dnl Er, this usage of $ac_cv_search_sem_init may be unfounded
365 dnl chumminess with the autoconf internals. -chad
366 dnl PTHREADLIB="$PTHREADLIB $ac_cv_search_sem_init"
373 dnl # Except for *BSD, where it's in -lc_r,
374 dnl # and where we've got to add extra CFLAGS.
376 if test "X$PTHREADLIB" = "X"; then
378 CFLAGS="$CFLAGS -pthread -D_THREAD_SAFE"
379 AC_CHECK_LIB(c_r, pthread_create,
384 dnl # Set libs, etc, if we have them.
385 if test "x$PTHREADLIB" != "x"; then
386 LIBS="$LIBS $PTHREADLIB"
387 CFLAGS="$CFLAGS -D_REENTRANT -D_POSIX_PTHREAD_SEMANTICS"
392 dnl # If we have NO pthread libraries, remove any knowledge of threads.
394 if test "x$PTHREADLIB" = "x"; then
396 ac_cv_header_pthread_h="no"
401 dnl Check if we need -lsocket
402 AC_CHECK_LIB(socket, getsockname)
404 dnl Check for -lresolv
405 dnl This library may be needed later.
406 AC_CHECK_LIB(resolv, inet_aton)
408 dnl Check if we need -lnsl. Usually if we want to
409 dnl link against -lsocket we need to include -lnsl as well.
410 AC_CHECK_LIB(nsl, inet_ntoa)
412 dnl #############################################################
414 dnl # 3. Checks for header files
416 dnl #############################################################
453 AC_CHECK_HEADER(regex.h, AC_DEFINE(HAVE_REGEX_H))
454 if test "x$ac_cv_header_regex_h" = "xyes"; then
462 ], [AC_DEFINE(HAVE_REG_EXTENDED) REGEX_EXTENDED=yes])
465 AC_SUBST(REGEX_EXTENDED)
468 dnl # other checks which require headers
470 if test "x$ac_cv_header_sys_security_h" = "xyes" && test "x$ac_cv_header_prot_h" = "xyes"
475 if test "x$ac_cv_header_sia_h" = "xyes" && test "x$ac_cv_header_siad_h" = "xyes"
481 dnl #############################################################
483 dnl # 4. Checks for typedefs
485 dnl #############################################################
488 dnl # Ensure that these are defined
495 dnl check for socklen_t
496 AC_CHECK_TYPE_INCLUDE([
497 #ifdef HAVE_SYS_TYPES_H
498 #include <sys/types.h>
500 #ifdef HAVE_SYS_SOCKET_H
501 #include <sys/socket.h>
505 dnl check for uint8_t
506 AC_CHECK_TYPE_INCLUDE([
507 #ifdef HAVE_INTTYPES_H
508 #include <inttypes.h>
513 ],uint8_t, unsigned char)
515 dnl check for uint16_t
516 AC_CHECK_TYPE_INCLUDE([
517 #ifdef HAVE_INTTYPES_H
518 #include <inttypes.h>
523 ],uint16_t, unsigned short)
525 dnl check for uint32_t
526 AC_CHECK_TYPE_INCLUDE([
527 #ifdef HAVE_INTTYPES_H
528 #include <inttypes.h>
533 ],uint32_t, unsigned int)
535 dnl #############################################################
537 dnl # 5. Checks for structures and functions
539 dnl #############################################################
563 RADIUSD_NEED_DECLARATIONS( \
576 dnl # check if we have utmpx.h
577 dnl # if so, check if struct utmpx has entry ut_xtime
578 dnl # if not, set it to define ut_xtime == ut_tv.tv_sec
579 if test "x$ac_cv_header_utmpx_h" = "xyes"
581 AC_CHECK_STRUCT_HAS_MEMBER([#include <utmpx.h>], [struct utmpx], ut_xtime)
582 if test "x$ac_cv_type_struct_utmpx_ut_xtime" = "x"
584 AC_DEFINE(ut_xtime,ut_tv.tv_sec)
588 dnl #############################################################
590 dnl # 6. Checks for compiler characteristics
592 dnl #############################################################
595 dnl # Ensure that these are defined
600 dnl # See if this is OS/2
602 AC_MSG_CHECKING(type of OS)
605 if test "$OS" = "OS/2"; then
613 dnl # Set Default CFLAGS
615 if test "x$GCC" = "xyes"; then
616 CFLAGS="$CFLAGS -Wall -D_GNU_SOURCE"
619 AC_MSG_CHECKING(for developer gcc flags)
620 if test "x$developer" = "xyes" -a "x$GCC" = "xyes"; then
621 devflags="-g -Wshadow -Wpointer-arith -Wcast-qual -Wcast-align -Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wnested-externs"
622 CFLAGS="$CFLAGS $devflags"
624 AC_MSG_RESULT(yes. Using $devflags)
627 CFLAGS="$CFLAGS -DNDEBUG"
632 dnl #############################################################
634 dnl # 7. Checks for library functions
636 dnl #############################################################
638 dnl Check for libcrypt
639 dnl We use crypt(3) which may be in libc, or in libcrypt (eg FreeBSD)
640 AC_CHECK_LIB(crypt, crypt,
643 if test "$CRYPTLIB" != ""; then
644 AC_DEFINE(HAVE_CRYPT)
646 AC_CHECK_FUNC(crypt, AC_DEFINE(HAVE_CRYPT))
649 dnl Check for libcipher
650 AC_CHECK_LIB(cipher, setkey,
651 CRYPTLIB="${CRYPTLIB} -lcipher"
655 if test "x$WITH_SNMP" = "xyes"; then
660 dnl # Check for sem_init all by itself
662 if test "X$ac_cv_func_sem_init" = "Xno"; then
665 dnl # If not found, sem_init is in -lposix4 on Solaris
667 AC_CHECK_LIB(posix4, sem_init)
669 if test "X$ac_cv_lib_posix4_sem_init" = "X"; then
670 if test "$WITH_THREAD_POOL" = "yes"; then
671 AC_MSG_WARN(You do not have posix semaphores. Disabling thread pools)
678 gethostbyaddrrstyle=""
679 AC_MSG_CHECKING([gethostbyaddr_r() syntax])
680 AC_TRY_COMPILE([#include <netdb.h>], [ gethostbyaddr_r(NULL, 0, 0, NULL, NULL, 0, NULL) ] , [
681 AC_DEFINE(GETHOSTBYADDRRSTYLE, SYSVSTYLE)
682 gethostbyaddrrstyle=SYSV
684 AC_TRY_COMPILE([#include <netdb.h>], [ gethostbyaddr_r(NULL, 0, 0, NULL, NULL, 0, NULL, NULL) ], [
685 AC_DEFINE(GETHOSTBYADDRRSTYLE, GNUSTYLE)
686 gethostbyaddrrstyle=GNU
689 AC_TRY_COMPILE([#include <netdb.h>], [ gethostbyaddr(NULL, 0, 0) ], [
690 AC_DEFINE(GETHOSTBYADDRRSTYLE, BSDSTYLE)
691 gethostbyaddrrstyle=BSD
694 if test "x$gethostbyaddrrstyle" = "x"; then
695 AC_MSG_RESULT([none! It must not exist, here.])
697 AC_MSG_RESULT([${gethostbyaddrrstyle}-style])
701 dnl #############################################################
703 dnl # 8. Checks for system services
705 dnl #############################################################
708 dnl # Figure out where libtool is located,
710 LIBTOOL="`pwd`/libtool"
715 top_srcdir="$top_builddir"
716 AC_SUBST(top_builddir)
719 dnl import libtool stuff
722 dnl # Checks to ensure that the thread pool code can build.
724 if test "$WITH_THREAD_POOL" = "yes"; then
726 dnl # If using thread pools, check that threading is enabled
728 if test "$WITH_THREADS" != "yes"; then
729 AC_MSG_ERROR(You must have threads enabled for thread pools to work.)
733 dnl # If using thread pools, check that we have thread libraries
735 if test "X$PTHREADLIB" = "X"; then
736 AC_MSG_ERROR(You must have threading libraries for thread pools to work.)
741 dnl #############################################################
743 dnl # Configure in any module directories.
745 dnl #############################################################
748 if test "x$EXPERIMENTAL" = "xyes"; then
749 for foo in `find src/modules -name configure -print`; do
750 bar=`echo $foo | sed 's%/configure$%%g'`
751 mysubdirs="$mysubdirs $bar"
755 dnl # Find 'configure' in ONLY the stable modules
757 for foo in `find \`cat src/modules/stable | sed 's%rlm%src/modules/rlm%g'\` -name configure -print`; do
758 bar=`echo $foo | sed 's%/configure$%%g'`
759 mysubdirs="$mysubdirs $bar"
763 dnl ############################################################
764 dnl # make modules by list
765 dnl #############################################################
767 if test "x$EXPERIMENTAL" = "xyes"; then
768 for foo in `ls src/modules | grep rlm_`; do
769 MODULES="$MODULES $foo"
773 dnl # make ONLY the stable modules
775 for foo in `cat src/modules/stable`; do
776 MODULES="$MODULES $foo"
781 dnl # Don't change the variable name here. Autoconf goes bonkers
784 AC_CONFIG_SUBDIRS($mysubdirs)
787 dnl #############################################################
789 dnl # And finally, output the results.
791 dnl #############################################################
794 dnl # Substitute whatever libraries we found to be necessary
797 AC_SUBST(INSTALLSTRIP)
799 USE_SHARED_LIBS=$enable_shared
800 AC_SUBST(USE_SHARED_LIBS)
801 USE_STATIC_LIBS=$enable_static
802 AC_SUBST(USE_STATIC_LIBS)
803 AC_SUBST(STATIC_MODULES)
804 AC_SUBST(RADIUSD_MAJOR_VERSION)
805 AC_SUBST(RADIUSD_MINOR_VERSION)
806 AC_SUBST(RADIUSD_VERSION)
811 ./src/include/build-radpaths-h \
812 ./src/main/checkrad.pl \
815 ./scripts/rc.radiusd \
817 ./scripts/check-radiusd-config \
818 ./scripts/radiusd.cron.daily \
819 ./scripts/radiusd.cron.monthly \
820 ./scripts/cryptpasswd \
824 AC_OUTPUT_COMMANDS([echo timestamp > src/include/stamp-h])
825 AC_OUTPUT_COMMANDS([(cd ./src/include && /bin/sh ./build-radpaths-h)])
826 AC_OUTPUT_COMMANDS([(cd ./src/main && chmod +x checkrad.pl radlast radtest)])
827 AC_OUTPUT_COMMANDS([(cd ./scripts && chmod +x rc.radiusd radwatch check-radiusd-config radiusd.cron.daily radiusd.cron.monthly cryptpasswd)])
829 cat >> src/include/autoconf.h <<EOF
831 #define HOSTINFO "$host"
832 #define RADIUSD_VERSION "$RADIUSD_VERSION"