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
28 RADIUSD_MAJOR_VERSION=1
29 RADIUSD_MINOR_VERSION=0.0-pre0
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
44 dnl # autoconf 2.50 and later
45 dnl # AC_SYS_LARGEFILE
50 dnl # check for AIX, to allow us to use some BSD functions
51 dnl # must be before macros that call the compiler.
56 AC_CHECK_PROG(GMAKE, gmake, yes, no)
57 if test $GMAKE = no; then
58 AC_PATH_PROG(MAKE, make, /usr/local/bin/make)
60 AC_PATH_PROG(MAKE, gmake, /usr/local/gnu/bin/make)
62 makever=`$ac_cv_path_MAKE --version 2>&1 | grep "GNU Make"`
63 if test -z "$makever"; then
64 AC_MSG_ERROR(GNU Make is not installed. Please download and install it
65 from ftp://prep.ai.mit.edu/pub/gnu/make/ before continuing.)
68 dnl libltdl is installable
69 AC_LIBLTDL_INSTALLABLE
71 dnl use system-wide libtool, if it exists
72 AC_ARG_WITH(system-libtool,
73 [ --with-system-libtool try to use libtool installed in your system [default=use our own]],
74 [ AC_PATH_PROG(LIBTOOL, libtool,,$PATH:/usr/local/bin) ],
76 LIBTOOL="`pwd`/libtool"
78 dnl ensure that we're looking for dlopen
81 dnl Figure out how to build shared libraries
86 dnl Put this in later, when all distributed modules use autoconf.
87 dnl AC_ARG_WITH(disablemodulefoo,
88 dnl [ --without-rlm_foo Disables module compilation. Module list:]
89 dnl esyscmd([find src/modules -type d -name rlm_\* -print |\
90 dnl sed -e 's%src/modules/.*/% (sub)- %; s%.*/%- %' |\
91 dnl awk '{print " "$0}']))
93 AC_ARG_ENABLE(strict-dependencies,
94 [ --enable-strict-dependencies Fail configure on lack of module dependancy.])
96 dnl extra argument: --with-logdir
97 logdir='${localstatedir}/log/radius'
98 AC_MSG_CHECKING(logdir)
100 [ --with-logdir=DIR Directory for logfiles [LOCALSTATEDIR/log/radius] ],
103 AC_MSG_ERROR(Need logdir)
113 AC_MSG_RESULT($logdir)
115 dnl extra argument: --with-radacctdir
116 radacctdir='${logdir}/radacct'
117 AC_MSG_CHECKING(radacctdir)
118 AC_ARG_WITH(radacctdir,
119 [ --with-radacctdir=PATH Directory for detail files [LOGDIR/radacct] ],
122 AC_MSG_ERROR(Need radacctdir)
127 radacctdir="$withval"
132 AC_MSG_RESULT($radacctdir)
134 dnl extra argument: --with-raddbdir
135 raddbdir='${sysconfdir}/raddb'
136 AC_MSG_CHECKING(raddbdir)
137 AC_ARG_WITH(raddbdir,
138 [ --with-raddbdir=DIR Directory for config files [SYSCONFDIR/raddb] ],
141 AC_MSG_ERROR(Need raddbdir)
151 AC_MSG_RESULT($raddbdir)
153 dnl extra argument: --with-ascend-binary
155 AC_ARG_WITH(ascend-binary,
156 [ --with-ascend-binary Include support for Ascend binary filter attributes (default=yes)],
164 if test "X$ASCEND_BINARY" = "Xyes"; then
165 AC_DEFINE(ASCEND_BINARY)
168 dnl extra argument: --with-threads
171 [ --with-threads Use threads, if available. (default=yes) ],
180 dnl extra argument: --with-snmp
183 [ --with-snmp Compile in SNMP support. (default=yes)],
192 dnl extra argument: --with-large-files
193 rad_enable_largefiles=no
194 AC_ARG_WITH(large-files,
195 [ --with-large-files Compile in large (2G+) file support. (default=no)],
198 rad_enable_largefiles=yes
206 dnl AC_ARG_ENABLE(ltdl-install,
207 dnl [ --disable-ltdl-install do not install libltdl])
208 dnl if test x"${enable_ltdl_install+set}" != xset; then
209 dnl enable_ltdl_install=yes
210 dnl ac_configure_args="$ac_configure_args --enable-ltdl-install"
212 dnl AC_CONFIG_SUBDIRS(libltdl)
215 dnl # Allow the user to specify a list of modules to be linked
216 dnl # statically to the server.
219 AC_ARG_WITH(static_modules,
220 [ --with-static-modules=QUOTED-MODULE-LIST],[
221 for i in $withval; do
222 STATIC_MODULES="$STATIC_MODULES -dlpreopen ../modules/rlm_$i/rlm_$i.la"
227 dnl # Enable developer C compiler warnings
229 AC_ARG_ENABLE(developer,
230 [ --enable-developer Enables features of interest to developers.],
231 [ case "$enableval" in
240 if test "x$developer" != "xno" -a -d $srcdir/CVS; then
241 dnl turn on the developer flag when taken from a CVS checkout (not a release)
245 dnl extra argument: --with-experimental-modules
247 AC_ARG_WITH(experimental-modules,
248 [ --with-experimental-modules Use experimental and unstable modules. (default=no) ],
258 dnl # extra argument: --openssl-includes=dir
260 AC_ARG_WITH(openssl-includes,
261 [ --with-openssl-includes=DIR Directory to look for OpenSSL include files],
269 dnl # extra argument: --openssl-libraries=dir
271 AC_ARG_WITH(openssl-libraries,
272 [ --with-openssl-libraries=DIR Directory to look for OpenSSL library files],
281 dnl # These next two arguments don't actually do anything. They're
282 dnl # place holders so that the top-level configure script can tell
283 dnl # the user how to configure lower-level modules
287 dnl # extra argument: --with-rlm-FOO-lib-dir
289 AC_ARG_WITH(rlm-FOO-lib-dir,
290 [ --with-rlm-FOO-lib-dir=DIR Directory to look for library files used by module FOO],
298 dnl # extra argument: --with-rlm-FOO-include-dir
300 AC_ARG_WITH(rlm-FOO-include-dir,
301 [ --with-rlm-FOO-include-dir=DIR Directory to look for include files used by module FOO],
308 dnl See what include-style is used by the make program.
309 dnl AC_MSG_CHECKING(include style for make)
310 dnl echo "include /dev/null" > testmake.$$
311 dnl echo "all:" >> testmake.$$
312 dnl make -f testmake.$$ >/dev/null 2>&1
321 dnl rm -f testmake.$$
322 dnl AC_MSG_RESULT(" $INCLUDE")
323 dnl AC_SUBST(INCLUDE)
326 dnl #############################################################
328 dnl # 1. Checks for programs
330 dnl #############################################################
333 AC_PATH_PROG(PERL, perl, /usr/local/bin/perl)
334 if test "x$ac_cv_path_PERL" = "x"; then
335 AC_MSG_WARN(perl not found - Simultaneous-Use and checkrad.pl may not work)
337 AC_PATH_PROG(SNMPGET, snmpget)
338 if test "x$ac_cv_path_SNMPGET" = "x"; then
339 AC_MSG_WARN(snmpget not found - Simultaneous-Use and checkrad.pl may not work)
342 AC_PATH_PROG(SNMPWALK, snmpwalk)
343 if test "x$ac_cv_path_SNMPWALK" = "x"; then
344 AC_MSG_WARN(snmpwalk not found - Simultaneous-Use and checkrad.pl may not work)
347 AC_PATH_PROG(RUSERS, rusers, /usr/bin/rusers)
349 dnl FIXME This is truly gross.
350 missing_dir=`cd $ac_aux_dir && pwd`
351 AM_MISSING_PROG(ACLOCAL, aclocal, $missing_dir)
352 AM_MISSING_PROG(AUTOCONF, autoconf, $missing_dir)
353 AM_MISSING_PROG(AUTOHEADER, autoheader, $missing_dir)
355 AC_PATH_PROG(LOCATE,locate)
356 AC_PATH_PROG(DIRNAME,dirname)
357 AC_PATH_PROG(GREP,grep)
359 dnl #############################################################
361 dnl # 2. Checks for libraries
363 dnl #############################################################
365 dnl If using pthreads, check for -lpthread (posix) or -lc_r (*BSD)
367 if test "x$WITH_THREADS" = "xyes"; then
368 if test $ac_cv_prog_suncc = "yes"; then
372 AC_CHECK_HEADERS(pthread.h, [], [ WITH_THREADS="no" ])
375 dnl # pthread stuff is usually in -lpthread
376 dnl # or in -lc_r, on *BSD
378 dnl # On Some systems, we need extra pre-processor flags, to get them to
379 dnl # to do the threading properly.
381 AC_CHECK_LIB(pthread, pthread_create,
382 [ CFLAGS="$CFLAGS -D_REENTRANT -D_POSIX_PTHREAD_SEMANTICS"
383 LIBS="$LIBS -lpthread" ],
384 AC_CHECK_LIB(c_r, pthread_create,
385 [ CFLAGS="$CFLAGS -pthread -D_THREAD_SAFE" ],
386 [ WITH_THREADS="no" ]
392 dnl # If we have NO pthread libraries, remove any knowledge of threads.
394 if test "x$WITH_THREADS" != "xyes"; then
396 ac_cv_header_pthread_h="no"
400 dnl # We need sem_init() and friends, as they're the friendliest
401 dnl # semaphore functions for threading.
403 dnl # HP/UX requires linking with librt, too, to get the sem_* symbols.
404 dnl # Some systems have them in -lsem
405 dnl # Solaris has them in -lposix4
407 AC_SEARCH_LIBS(sem_init, pthread sem posix4 rt,
409 [AC_MSG_ERROR(-lsem not found. You may want to download it from ftp://ftp.to.gd-es.com/pub/BSDI/libsem.tar.bz2 or ftp://ftp.freeradius.org/pub/radius/contrib/libsem.tar.gz)]
413 dnl Check if we need -lsocket
414 AC_CHECK_LIB(socket, getsockname)
416 dnl Check for -lresolv
417 dnl This library may be needed later.
418 AC_CHECK_LIB(resolv, inet_aton)
420 dnl Check if we need -lnsl. Usually if we want to
421 dnl link against -lsocket we need to include -lnsl as well.
422 AC_CHECK_LIB(nsl, inet_ntoa)
424 dnl #############################################################
426 dnl # 3. Checks for header files
428 dnl #############################################################
467 AC_CHECK_HEADER(regex.h, AC_DEFINE(HAVE_REGEX_H))
468 if test "x$ac_cv_header_regex_h" = "xyes"; then
476 ], [AC_DEFINE(HAVE_REG_EXTENDED) REGEX_EXTENDED=yes])
479 AC_SUBST(REGEX_EXTENDED)
482 dnl # other checks which require headers
484 if test "x$ac_cv_header_sys_security_h" = "xyes" && test "x$ac_cv_header_prot_h" = "xyes"
489 if test "x$ac_cv_header_sia_h" = "xyes" && test "x$ac_cv_header_siad_h" = "xyes"
495 dnl #############################################################
497 dnl # 4. Checks for typedefs
499 dnl #############################################################
502 dnl # Ensure that these are defined
509 dnl check for socklen_t
510 AC_CHECK_TYPE_INCLUDE([
511 #ifdef HAVE_SYS_TYPES_H
512 #include <sys/types.h>
514 #ifdef HAVE_SYS_SOCKET_H
515 #include <sys/socket.h>
519 dnl check for uint8_t
520 AC_CHECK_TYPE_INCLUDE([
521 #ifdef HAVE_INTTYPES_H
522 #include <inttypes.h>
527 ],uint8_t, unsigned char)
529 dnl check for uint16_t
530 AC_CHECK_TYPE_INCLUDE([
531 #ifdef HAVE_INTTYPES_H
532 #include <inttypes.h>
537 ],uint16_t, unsigned short)
539 dnl check for uint32_t
540 AC_CHECK_TYPE_INCLUDE([
541 #ifdef HAVE_INTTYPES_H
542 #include <inttypes.h>
547 ],uint32_t, unsigned int)
549 dnl #############################################################
551 dnl # 5. Checks for structures and functions
553 dnl #############################################################
576 RADIUSD_NEED_DECLARATIONS( \
589 dnl # check if we have utmpx.h
590 dnl # if so, check if struct utmpx has entry ut_xtime
591 dnl # if not, set it to define ut_xtime == ut_tv.tv_sec
592 if test "x$ac_cv_header_utmpx_h" = "xyes"
594 AC_CHECK_STRUCT_HAS_MEMBER([#include <utmpx.h>], [struct utmpx], ut_xtime)
595 if test "x$ac_cv_type_struct_utmpx_has_ut_xtime" = "x"
597 AC_DEFINE(ut_xtime,ut_tv.tv_sec)
601 dnl #############################################################
603 dnl # 6. Checks for compiler characteristics
605 dnl #############################################################
608 dnl # Ensure that these are defined
613 dnl # See if this is OS/2
615 AC_MSG_CHECKING(type of OS)
618 if test "$OS" = "OS/2"; then
626 dnl # Set Default CFLAGS
628 if test "x$GCC" = "xyes"; then
629 CFLAGS="$CFLAGS -Wall -D_GNU_SOURCE"
632 AC_MSG_CHECKING(for developer gcc flags)
633 if test "x$developer" = "xyes" -a "x$GCC" = "xyes"; then
634 devflags="-g -Wshadow -Wpointer-arith -Wcast-qual -Wcast-align -Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wnested-externs -W -Wredundant-decls -Wundef"
635 CFLAGS="$CFLAGS $devflags"
637 AC_MSG_RESULT(yes. Using $devflags)
640 CFLAGS="$CFLAGS -DNDEBUG"
645 dnl #############################################################
647 dnl # 7. Checks for library functions
649 dnl #############################################################
651 dnl Check for libcrypt
652 dnl We use crypt(3) which may be in libc, or in libcrypt (eg FreeBSD)
653 AC_CHECK_LIB(crypt, crypt,
656 if test "$CRYPTLIB" != ""; then
657 AC_DEFINE(HAVE_CRYPT)
659 AC_CHECK_FUNC(crypt, AC_DEFINE(HAVE_CRYPT))
662 dnl Check for libcipher
663 AC_CHECK_LIB(cipher, setkey,
664 CRYPTLIB="${CRYPTLIB} -lcipher"
668 if test "x$WITH_SNMP" = "xyes"; then
672 dnl Check the style of gethostbyaddr, in order of preference
673 dnl GNU (_r eight args)
674 dnl SYSV (_r six args)
675 dnl BSD (three args, may not be thread safe)
676 dnl Tru64 has BSD version, but it is thread safe
677 dnl http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/V51B_HTML/MAN/MAN3/1739____.HTM
678 dnl We need #stdio.h to define NULL on FreeBSD (at least)
679 gethostbyaddrrstyle=""
680 AC_MSG_CHECKING([gethostbyaddr_r() syntax])
684 ], [ gethostbyaddr_r(NULL, 0, 0, NULL, NULL, 0, NULL, NULL) ], [
685 AC_DEFINE(GETHOSTBYADDRRSTYLE, GNUSTYLE)
686 gethostbyaddrrstyle=GNU
688 if test "x$gethostbyaddrrstyle" = "x"; then
692 ], [ gethostbyaddr_r(NULL, 0, 0, NULL, NULL, 0, NULL) ] , [
693 AC_DEFINE(GETHOSTBYADDRRSTYLE, SYSVSTYLE)
694 gethostbyaddrrstyle=SYSV
697 if test "x$gethostbyaddrrstyle" = "x"; then
701 ], [ gethostbyaddr(NULL, 0, 0) ], [
702 AC_DEFINE(GETHOSTBYADDRRSTYLE, BSDSTYLE)
703 gethostbyaddrrstyle=BSD
707 if test "x$gethostbyaddrrstyle" = "x"; then
708 AC_MSG_RESULT([none! It must not exist, here.])
710 AC_MSG_RESULT([${gethostbyaddrrstyle}-style])
713 if test "x$gethostbyaddrrstyle" = "xBSD"; then
714 AC_MSG_WARN([ ****** BSD-style gethostbyaddr might NOT be thread-safe! ****** ])
718 dnl Check the style of gethostbyname, in order of preference
719 dnl GNU (_r seven args)
720 dnl SYSV (_r five args)
721 dnl BSD (two args, may not be thread safe)
722 dnl Tru64 has BSD version, but it _is_ thread safe
723 dnl http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/V51B_HTML/MAN/MAN3/1946____.HTM
724 dnl We need #stdio.h to define NULL on FreeBSD (at least)
725 gethostbynamerstyle=""
726 AC_MSG_CHECKING([gethostbyname_r() syntax])
730 ], [ gethostbyname_r(NULL, NULL, NULL, 0, NULL, NULL) ], [
731 AC_DEFINE(GETHOSTBYNAMERSTYLE, GNUSTYLE)
732 gethostbynamerstyle=GNU
734 if test "x$gethostbynamerstyle" = "x"; then
738 ], [ gethostbyname_r(NULL, NULL, NULL, 0, NULL) ] , [
739 AC_DEFINE(GETHOSTBYNAMERSTYLE, SYSVSTYLE)
740 gethostbynamerstyle=SYSV
743 if test "x$gethostbynamerstyle" = "x"; then
747 ], [ gethostbyname(NULL) ], [
748 AC_DEFINE(GETHOSTBYNAMERSTYLE, BSDSTYLE)
749 gethostbynamerstyle=BSD
753 if test "x$gethostbynamerstyle" = "x"; then
754 AC_MSG_RESULT([none! It must not exist, here.])
756 AC_MSG_RESULT([${gethostbynamerstyle}-style])
759 if test "x$gethostbynamerstyle" = "xBSD"; then
760 AC_MSG_WARN([ ****** BSD-style gethostbyname might NOT be thread-safe! ****** ])
763 dnl If configuring with large file support, determine the right flags to
764 dnl use based on the platform. This is the wrong approach; autoconf 2.50
765 dnl comes with a macro that takes the right approach. But this works well
766 dnl enough until we switch to autoconf 2.50 or later.
767 if test x"$rad_enable_largefiles" = xyes ; then
768 AC_MSG_CHECKING(for largefile linkage)
772 AC_MSG_ERROR([AIX before 4.2 does not support large files])
776 LFS_CFLAGS="-D_LARGE_FILES"
782 LFS_CFLAGS="-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64"
788 AC_MSG_ERROR([Large files not supported on this platform])
792 LFS_CFLAGS="-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64"
795 AC_DEFINE([_GNU_SOURCE], 1,
796 [Some versions of glibc need this defined for pread/pwrite.])
800 AC_PATH_PROG(GETCONF, getconf)
801 if test -z "$GETCONF" ; then
802 AC_MSG_ERROR([getconf required to configure large file support])
804 LFS_CFLAGS=`$GETCONF LFS_CFLAGS`
805 LFS_LDFLAGS=`$GETCONF LFS_LDFLAGS`
806 LFS_LIBS=`$GETCONF LFS_LIBS`
810 LFS_CFLAGS="-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64"
816 AC_SUBST(LFS_LDFLAGS)
820 dnl #############################################################
822 dnl # 8. Checks for system services
824 dnl #############################################################
827 dnl # Figure out where libtool is located,
831 AC_MSG_RESULT([top_builddir=$top_builddir])
832 AC_SUBST(top_builddir)
837 dnl # Work around stupid autoconf crap
839 if test "x$INCLTDL" != "x";then
840 INCLTDL='-I${top_builddir}/''libltdl'
843 dnl import libtool stuff
845 dnl #############################################################
847 dnl # Configure in any module directories.
849 dnl #############################################################
852 if test "x$EXPERIMENTAL" = "xyes"; then
853 bar=`ls -1 src/modules/rlm_*/configure | sed 's%/configure%%'`
854 dnl # get rid of LF's.
855 mysubdirs=`echo $bar`
858 dnl # Find 'configure' in ONLY the stable modules
860 for bar in `cat src/modules/stable`; do
861 if test -f src/modules/$bar/configure; then
862 mysubdirs="$mysubdirs src/modules/$bar"
867 dnl ############################################################
868 dnl # make modules by list
869 dnl #############################################################
871 if test "x$EXPERIMENTAL" = "xyes"; then
872 for foo in `ls -1 src/modules | grep rlm_`; do
873 MODULES="$MODULES $foo"
877 dnl # make ONLY the stable modules
879 for foo in `cat src/modules/stable`; do
880 MODULES="$MODULES $foo"
885 dnl # Don't change the variable name here. Autoconf goes bonkers
888 AC_CONFIG_SUBDIRS($mysubdirs)
891 dnl #############################################################
893 dnl # And finally, output the results.
895 dnl #############################################################
898 dnl # Substitute whatever libraries we found to be necessary
901 AC_SUBST(INSTALLSTRIP)
903 USE_SHARED_LIBS=$enable_shared
904 AC_SUBST(USE_SHARED_LIBS)
905 USE_STATIC_LIBS=$enable_static
906 AC_SUBST(USE_STATIC_LIBS)
907 AC_SUBST(STATIC_MODULES)
908 AC_SUBST(RADIUSD_MAJOR_VERSION)
909 AC_SUBST(RADIUSD_MINOR_VERSION)
910 AC_SUBST(RADIUSD_VERSION)
915 ./src/include/build-radpaths-h \
916 ./src/main/Makefile \
917 ./src/main/checkrad.pl \
920 ./scripts/rc.radiusd \
922 ./scripts/check-radiusd-config \
923 ./scripts/radiusd.cron.daily \
924 ./scripts/radiusd.cron.monthly \
925 ./scripts/cryptpasswd \
930 AC_OUTPUT_COMMANDS([echo timestamp > src/include/stamp-h])
931 AC_OUTPUT_COMMANDS([(cd ./src/include && /bin/sh ./build-radpaths-h)])
932 AC_OUTPUT_COMMANDS([(cd ./src/main && chmod +x checkrad.pl radlast radtest)])
933 AC_OUTPUT_COMMANDS([(cd ./scripts && chmod +x rc.radiusd radwatch check-radiusd-config radiusd.cron.daily radiusd.cron.monthly cryptpasswd)])
935 cat >> src/include/autoconf.h <<EOF
937 #define HOSTINFO "$host"
938 #define RADIUSD_VERSION "$RADIUSD_VERSION"