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=5
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 AC_CHECK_PROG(GMAKE, gmake, yes, no)
48 if test $GMAKE = no; then
49 AC_PATH_PROG(MAKE, make, /usr/local/bin/make)
51 AC_PATH_PROG(MAKE, gmake, /usr/local/gnu/bin/make)
53 makever=`$ac_cv_path_MAKE --version 2>&1 | grep "GNU Make"`
54 if test -z "$makever"; then
55 AC_MSG_ERROR(GNU Make is not installed. Please download and install it
56 from ftp://prep.ai.mit.edu/pub/gnu/make/ before continuing.)
59 dnl libltdl is installable
60 AC_LIBLTDL_INSTALLABLE
62 dnl ensure that we're looking for dlopen
65 dnl Figure out how to build shared libraries
68 dnl Put this in later, when all distributed modules use autoconf.
69 dnl AC_ARG_WITH(disablemodulefoo,
70 dnl [ --without-rlm_foo Disables module compilation. Module list:]
71 dnl esyscmd([find src/modules -type d -name rlm_\* -print |\
72 dnl sed -e 's%src/modules/.*/% (sub)- %; s%.*/%- %' |\
73 dnl awk '{print " "$0}']))
75 AC_ARG_ENABLE(strict-dependencies,
76 [ --enable-strict-dependencies Fail configure on lack of module dependancy.])
78 AC_ARG_WITH(fooincludedir,
79 [ --with-FOO-include-dir=DIR Dir for includes for FOO, module dependancy.])
81 AC_ARG_WITH(foolibdir,
82 [ --with-FOO-lib-dir=DIR Dir for libraries for FOO, 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 Turns on flags 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)
237 dnl # These next two arguments don't actually do anything. They're
238 dnl # place holders so that the top-level configure script can tell
239 dnl # the user how to configure lower-level modules
243 dnl # extra argument: --with-rlm-FOO-lib-dir
245 AC_ARG_WITH(rlm-FOO-lib-dir,
246 [ --with-rlm-FOO-lib-dir=DIR Directory to look for library files used by module FOO],
254 dnl # extra argument: --with-rlm-FOO-include-dir
256 AC_ARG_WITH(rlm-FOO-include-dir,
257 [ --with-rlm-FOO-include-dir=DIR Directory to look for include files used by module FOO],
264 dnl See what include-style is used by the make program.
265 dnl AC_MSG_CHECKING(include style for make)
266 dnl echo "include /dev/null" > testmake.$$
267 dnl echo "all:" >> testmake.$$
268 dnl make -f testmake.$$ >/dev/null 2>&1
277 dnl rm -f testmake.$$
278 dnl AC_MSG_RESULT(" $INCLUDE")
279 dnl AC_SUBST(INCLUDE)
282 dnl #############################################################
284 dnl # 1. Checks for programs
286 dnl #############################################################
288 AC_PATH_PROG(PERL, perl, /usr/local/bin/perl)
289 if test ! -x $ac_cv_path_PERL; then
290 AC_MSG_ERROR(perl not found - fatal)
292 AC_PATH_PROG(SNMPGET, snmpget, /usr/local/bin/snmpget)
293 AC_PATH_PROG(SNMPWALK, snmpwalk, /usr/local/bin/snmpwalk)
294 AC_PATH_PROG(RUSERS, rusers, /usr/bin/rusers)
296 dnl FIXME This is truly gross.
297 missing_dir=`cd $ac_aux_dir && pwd`
298 AM_MISSING_PROG(ACLOCAL, aclocal, $missing_dir)
299 AM_MISSING_PROG(AUTOCONF, autoconf, $missing_dir)
300 AM_MISSING_PROG(AUTOHEADER, autoheader, $missing_dir)
302 AC_PATH_PROG(LOCATE,locate)
303 AC_PATH_PROG(DIRNAME,dirname)
304 AC_PATH_PROG(GREP,grep)
307 dnl # check for AIX, to allow us to use some BSD functions
308 dnl # must be before macros that call the compiler.
312 dnl #############################################################
314 dnl # 2. Checks for libraries
316 dnl #############################################################
318 dnl If using pthreads, check for -lpthread (posix) or -lc_r (*BSD)
320 if test "$WITH_THREADS" = "yes"; then
321 if test $ac_cv_prog_suncc = "yes"; then
325 AC_CHECK_HEADERS(pthread.h)
327 if test "X$ac_cv_header_pthread_h" = "X"; then
328 AC_MSG_ERROR("You are trying to use threads without a POSIX <pthread.h>")
332 dnl # pthread stuff is usually in -lpthread
334 AC_CHECK_LIB(pthread, pthread_join,
335 PTHREADLIB="-lpthread"
338 dnl # HP/UX requires linking with librt, too, to get the sem_* symbols. :\
340 AC_SEARCH_LIBS(sem_init, pthread rt,
342 dnl Er, this usage of $ac_cv_search_sem_init may be unfounded
343 dnl chumminess with the autoconf internals. -chad
344 PTHREADLIB="$PTHREADLIB $ac_cv_search_sem_init"
351 dnl # Except for *BSD, where it's in -lc_r,
352 dnl # and where we've got to add extra CFLAGS.
354 if test "X$PTHREADLIB" = "X"; then
356 CFLAGS="$CFLAGS -pthread -D_THREAD_SAFE"
357 AC_CHECK_LIB(c_r, pthread_create,
362 dnl # Set libs, etc, if we have them.
363 if test "x$PTHREADLIB" != "x"; then
364 LIBS="$LIBS $PTHREADLIB"
365 CFLAGS="$CFLAGS -D_REENTRANT -D_POSIX_PTHREAD_SEMANTICS"
370 dnl # If we have NO pthread libraries, remove any knowledge of threads.
372 if test "x$PTHREADLIB" = "x"; then
374 ac_cv_header_pthread_h="no"
379 dnl Check if we need -lsocket
380 AC_CHECK_LIB(socket, getsockname)
382 dnl Check for -lresolv
383 dnl This library may be needed later.
384 AC_CHECK_LIB(resolv, inet_aton)
386 dnl Check if we need -lnsl. Usually if we want to
387 dnl link against -lsocket we need to include -lnsl as well.
388 AC_CHECK_LIB(nsl, inet_ntoa)
390 dnl #############################################################
392 dnl # 3. Checks for header files
394 dnl #############################################################
430 AC_CHECK_HEADER(regex.h, AC_DEFINE(HAVE_REGEX_H))
431 if test "x$ac_cv_header_regex_h" = "xyes"; then
439 ], [AC_DEFINE(HAVE_REG_EXTENDED) REGEX_EXTENDED=yes])
442 AC_SUBST(REGEX_EXTENDED)
445 dnl # other checks which require headers
447 if test "x$ac_cv_header_sys_security_h" = "xyes" && test "x$ac_cv_header_prot_h" = "xyes"
452 if test "x$ac_cv_header_sia_h" = "xyes" && test "x$ac_cv_header_siad_h" = "xyes"
458 dnl #############################################################
460 dnl # 4. Checks for typedefs
462 dnl #############################################################
465 dnl # Ensure that these are defined
472 dnl check for socklen_t
473 AC_CHECK_TYPE_INCLUDE([
474 #ifdef HAVE_SYS_TYPES_H
475 #include <sys/types.h>
477 #ifdef HAVE_SYS_SOCKET_H
478 #include <sys/socket.h>
482 dnl check for uint8_t
483 AC_CHECK_TYPE_INCLUDE([
484 #ifdef HAVE_INTTYPES_H
485 #include <inttypes.h>
490 ],uint8_t, unsigned char)
492 dnl check for uint32_t
493 AC_CHECK_TYPE_INCLUDE([
494 #ifdef HAVE_INTTYPES_H
495 #include <inttypes.h>
500 ],uint32_t, unsigned int)
502 dnl #############################################################
504 dnl # 5. Checks for structures and functions
506 dnl #############################################################
529 RADIUSD_NEED_DECLARATIONS( \
542 dnl # check if we have utmpx.h
543 dnl # if so, check if struct utmpx has entry ut_xtime
544 dnl # if not, set it to define ut_xtime == ut_tv.tv_sec
545 if test "x$ac_cv_header_utmpx_h" = "xyes"
547 AC_CHECK_STRUCT_HAS_MEMBER([#include <utmpx.h>], [struct utmpx], ut_xtime)
548 if test "x$ac_cv_type_struct_utmpx_ut_xtime" = "x"
550 AC_DEFINE(ut_xtime,ut_tv.tv_sec)
554 dnl #############################################################
556 dnl # 6. Checks for compiler characteristics
558 dnl #############################################################
561 dnl # Ensure that these are defined
566 dnl # See if this is OS/2
568 AC_MSG_CHECKING(type of OS)
571 if test "$OS" = "OS/2"; then
579 dnl # Set Default CFLAGS
581 if test "x$GCC" = "xyes"; then
582 CFLAGS="$CFLAGS -Wall -D_GNU_SOURCE"
585 AC_MSG_CHECKING(for developer gcc flags)
586 if test "x$developer" = "xyes" -a "x$GCC" = "xyes"; then
587 devflags="-g -Wshadow -Wpointer-arith -Wcast-qual -Wcast-align -Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wnested-externs"
588 CFLAGS="$CFLAGS $devflags"
590 AC_MSG_RESULT(yes. Using $devflags)
593 CFLAGS="$CFLAGS -DNDEBUG"
598 dnl #############################################################
600 dnl # 7. Checks for library functions
602 dnl #############################################################
604 dnl Check for libcrypt
605 dnl We use crypt(3) which may be in libc, or in libcrypt (eg FreeBSD)
606 AC_CHECK_LIB(crypt, crypt,
609 if test "$CRYPTLIB" != ""; then
610 AC_DEFINE(HAVE_CRYPT)
612 AC_CHECK_FUNC(crypt, AC_DEFINE(HAVE_CRYPT))
615 dnl Check for libcipher
616 AC_CHECK_LIB(cipher, setkey,
617 CRYPTLIB="${CRYPTLIB} -lcipher"
621 if test "x$WITH_SNMP" = "xyes"; then
626 dnl # Check for sem_init all by itself
628 if test "X$ac_cv_func_sem_init" = "Xno"; then
631 dnl # If not found, sem_init is in -lposix4 on Solaris
633 AC_CHECK_LIB(posix4, sem_init)
635 if test "X$ac_cv_lib_posix4_sem_init" = "X"; then
636 if test "$WITH_THREAD_POOL" = "yes"; then
637 AC_MSG_WARN(You do not have posix semaphores. Disabling thread pools)
645 dnl #############################################################
647 dnl # 8. Checks for system services
649 dnl #############################################################
652 dnl # Figure out where libtool is located,
654 LIBTOOL="`pwd`/libtool"
659 AC_SUBST(top_builddir)
661 dnl import libtool stuff
664 dnl # Checks to ensure that the thread pool code can build.
666 if test "$WITH_THREAD_POOL" = "yes"; then
668 dnl # If using thread pools, check that threading is enabled
670 if test "$WITH_THREADS" != "yes"; then
671 AC_MSG_ERROR(You must have threads enabled for thread pools to work.)
675 dnl # If using thread pools, check that we have thread libraries
677 if test "X$PTHREADLIB" = "X"; then
678 AC_MSG_ERROR(You must have threading libraries for thread pools to work.)
683 dnl #############################################################
685 dnl # Configure in any module directories.
687 dnl #############################################################
690 for foo in `find src/modules -name configure -print`; do
691 bar=`echo $foo | sed 's%/configure$%%g'`
692 mysubdirs="$mysubdirs $bar"
696 dnl # Don't change the variable name here. Autoconf goes bonkers
699 AC_CONFIG_SUBDIRS($mysubdirs)
701 dnl #############################################################
703 dnl # And finally, output the results.
705 dnl #############################################################
708 dnl # Substitute whatever libraries we found to be necessary
711 AC_SUBST(INSTALLSTRIP)
713 USE_SHARED_LIBS=$enable_shared
714 AC_SUBST(USE_SHARED_LIBS)
715 USE_STATIC_LIBS=$enable_static
716 AC_SUBST(USE_STATIC_LIBS)
717 AC_SUBST(STATIC_MODULES)
718 AC_SUBST(RADIUSD_MAJOR_VERSION)
719 AC_SUBST(RADIUSD_MINOR_VERSION)
720 AC_SUBST(RADIUSD_VERSION)
725 ./src/include/build-radpaths-h \
726 ./src/main/checkrad.pl \
729 ./scripts/rc.radiusd \
731 ./scripts/check-radiusd-config \
732 ./scripts/radiusd.cron.daily \
733 ./scripts/radiusd.cron.monthly \
734 ./scripts/cryptpasswd \
738 AC_OUTPUT_COMMANDS([echo timestamp > src/include/stamp-h])
739 AC_OUTPUT_COMMANDS([(cd ./src/include && /bin/sh ./build-radpaths-h)])
740 AC_OUTPUT_COMMANDS([(cd ./src/main && chmod +x checkrad.pl radlast radtest)])
741 AC_OUTPUT_COMMANDS([(cd ./scripts && chmod +x rc.radiusd radwatch check-radiusd-config radiusd.cron.daily radiusd.cron.monthly cryptpasswd)])
743 cat >> src/include/autoconf.h <<EOF
745 #define HOSTINFO "$host"
746 #define RADIUSD_VERSION "$RADIUSD_VERSION"